Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused_variables)]
- use std::error::Error;
- pub trait IxyDevice<'a> {
- fn new(pci_addr: &str, num_rx_queues: u16, num_tx_queues: u16) -> Result<Self, Box<Error>>
- where
- Self: Sized;
- fn init(&'a mut self) -> Result<(), Box<Error>>;
- }
- pub struct IxgbeDevice<'a> {
- rx_queues: Vec<&'a str>,
- }
- impl<'a> IxyDevice<'a> for IxgbeDevice<'a> {
- fn new(pci_addr: &str, num_rx_queues: u16, num_tx_queues: u16) -> Result<Self, Box<Error>> where
- Self: Sized {
- unimplemented!()
- }
- fn init(&'a mut self) -> Result<(), Box<Error>> {
- unimplemented!()
- }
- }
- impl<'a> IxgbeDevice<'a> {
- fn new() -> IxgbeDevice<'a> {
- IxgbeDevice {
- rx_queues: Vec::new(),
- }
- }
- }
- pub fn get_device(pci_addr: &str, rx_queues: u16, tx_queues: u16) -> Result<impl IxyDevice, Box<Error>> {
- let device: IxgbeDevice = IxyDevice::new(pci_addr, rx_queues, tx_queues)?;
- Ok(device)
- }
- fn main() {
- let dev = get_device("0000:03:00.0", 1, 1).unwrap();
- dev.init().unwrap();
- }
Add Comment
Please, Sign In to add comment