You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lib.rs
    path of file: ./repos/Theseus/applications/test_ixgbe/src
    
    the code of the file until where you have to start completion: //! Application which checks the functionality of the ixgbe driver by sending 1 packet on each enabled queue,
//! and then (optionally) endlessly polling the receive queues.
//! There are two ways to test the nic:
//! 
//! 1. Directly accessing the queues through the main ixgbe nic object. This is the default test.
//! In this case all transmit queues can be tested by sending a packet on each transmit queue, but receive functionality will be tested randomly.
//! If Receive Side Scaling is enabled then received packets will be randomly forwarded to different receive queues.
//! If it's disabled, then all packets will be received on queue 0.
//! 
//! 2. Creating multiple virtual NICs and sending and receiving packets with them.
//! In this case all transmit queues can be tested by sending a packet on each transmit queue, and all receive queues can be tested.
//! Each receive queue is associated with a unique IP address, and packets with that destination IP address will be forwarded to that queue.
//! 
//! For the receiving functionality, you will have to set up a program on another machine that sends packets to the IP addresses assigned
//! to the virtual NICs. Since these are static IP addresses and won't be resolved through ARP, I manually add the (mac address, ip address)
//!
    
fn rmain(matches: &Matches, _opts: &Options) -> Result<(), &'static str> {
    
    let (dev_id, mac_address) = {
        let ixgbe_devs = get_ixgbe_nics_list().ok_or("Ixgbe NICs list not initialized")?;
        if ixgbe_devs.is_empty() {
            println!("no IXGBE devices available");
            return Ok(());
        }
        let nic = ixgbe_devs[0].lock();
        (nic.device_id(), nic.mac_address())
    };

    if matches.opt_present("virtual") {
        if IXGBE_NUM_RX_QUEUES_ENABLED != IXGBE_NUM_TX_QUEUES_ENABLED {
            return Err("When using the virtual nic interface, there should be an equal number of RX and TX queues");
        }
        
        let num_nics = IXGBE_NUM_RX_QUEUES_ENABLED - 1;
        let mut nics = Vec::with_capacity(num_nics as usize);
        
        for i in 0..num_nics {
            let nic1 = virtual_function::create_virtual_nic(dev_id, vec!([192,168,0,i as u8 + 1]), 0, 0)?;
            nics.push(nic1);
        }
    
        for nic in &mut nics {
            let buffer = create_raw_packet(&DEST_MAC_ADDR, &mac_address, &[1;46])?;
            nic.send(buffer);
        }
        
        if matches.opt_present("r") {
            loop {
                for nic in &mut nics {
                    if let Some(_buffer) = nic.receive() {
                        println!("Received packet on vnic {}", nic.id());
                    }
                }
            }
        }
    } else {
        for qid in 0..IXGBE_NUM_TX_QUEUES_ENABLED {
            let buffer = create_raw_packet(&DEST_MAC_ADDR, &mac_address, &[1;46])?;
            tx_send_mq(qid as usize, dev_id, Some(buffer))?;
        }

        if matches.opt_present("r") {
            loop {
                for qid in 0..IXGBE_NUM_RX_QUEUES_ENABLED {
                    if let Ok(_buffer) = rx_poll_mq(qid as usize, dev_id) {
                        println!("Received packet on queue {}", qid);
                    }
                }
            }
        }
    }
    


    Ok(())
}