Guest User

Untitled

a guest
Sep 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. use std::cell::RefCell;
  2.  
  3. pub struct IxgbeDevice<'a> {
  4. rx_queues: Vec<IxgbeRxQueue<'a>>,
  5. }
  6. struct IxgbeRxQueue<'a> {
  7. pool: Packetpool<'a>,
  8. }
  9. pub struct Packetpool<'a> {
  10. free_stack: RefCell<Vec<Packet<'a>>>,
  11. }
  12. pub struct Packet<'a> {
  13. pool: &'a Packetpool<'a>,
  14. }
  15.  
  16. impl<'a> IxgbeDevice<'a> {
  17. fn init() -> IxgbeDevice<'a> {
  18. let mut dev = IxgbeDevice {
  19. rx_queues: Vec::new(),
  20. };
  21.  
  22. dev.init_queue();
  23.  
  24. dev
  25. }
  26.  
  27. fn init_queue(&mut self) {
  28. let mempool = Packetpool {
  29. free_stack: RefCell::new(vec![]),
  30. };
  31.  
  32. let rx_queue = IxgbeRxQueue {
  33. pool: mempool,
  34. };
  35.  
  36. self.rx_queues.push(rx_queue);
  37.  
  38. self.rx_queues[0].pool.free_stack.borrow_mut().push(
  39. Packet {
  40. pool: &self.rx_queues[0].pool,
  41. }
  42. );
  43. }
  44. }
  45.  
  46. fn main() {
  47. let _dev = IxgbeDevice::init();
  48. }
Add Comment
Please, Sign In to add comment