1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/// The Buf trait represents a packet buffer. /// A trait is used so that an implementation can be provided that enables building and testing packet /// pipelines without needing the AF_XDP infrastructure. pub trait Buf<T> where T: std::default::Default, { /// Returns a reference to the u8 slice of the buffer fn get_data(&self) -> &[u8]; /// Returns a mutable reference to the u8 slice of the buffer fn get_data_mut(&mut self) -> &mut [u8]; /// Returns the total capacity of the buffer fn get_capacity(&self) -> u16; /// Returns the length of the portion of the buffer that contains packet data fn get_len(&self) -> u16; /// Sets the length of the portion of the buffer that is contains packet data fn set_len(&mut self, len: u16); /// Returns a reference to the embedded user struct fn get_user(&self) -> &T; /// Returns a mutable reference to the embeded user struct fn get_user_mut(&mut self) -> &mut T; } /* pub trait BufConst<T, const N: usize> where T: std::default::Default { fn get_data(&self) -> &[u8; N]; fn get_data_mut(&mut self) -> &mut [u8; N]; fn get_len(&self) -> u16; fn get_user(&self) -> &T; fn get_user_mut(&mut self) -> &mut T; } */