pub struct Mbuf { /* private fields */ }Expand description
A memory buffer for packet data
Mbufs are the basic unit for carrying packet data in DPDK. They are allocated from memory pools and contain both metadata and actual packet data.
Implementations§
Source§impl Mbuf
impl Mbuf
Sourcepub unsafe fn from_raw(ptr: *mut rte_mbuf) -> Option<Self>
pub unsafe fn from_raw(ptr: *mut rte_mbuf) -> Option<Self>
Create a new Mbuf from a raw pointer
§Safety
The caller must ensure:
- The pointer is valid and properly aligned
- The mbuf was allocated from a valid mempool
- Ownership is being transferred (the raw pointer should not be freed elsewhere)
Sourcepub fn into_raw(self) -> *mut rte_mbuf
pub fn into_raw(self) -> *mut rte_mbuf
Consume self and return the raw pointer
After calling this, the caller is responsible for freeing the mbuf
Sourcepub fn data_offset(&self) -> u16
pub fn data_offset(&self) -> u16
Get the data offset within the buffer
Sourcepub fn packet_len(&self) -> u32
pub fn packet_len(&self) -> u32
Get the total packet length
Sourcepub fn data(&self) -> Option<&[u8]>
pub fn data(&self) -> Option<&[u8]>
Get a slice to the packet data
Returns None if the buffer address is null
Sourcepub fn data_mut(&mut self) -> Option<&mut [u8]>
pub fn data_mut(&mut self) -> Option<&mut [u8]>
Get a mutable slice to the packet data
Returns None if the buffer address is null
Sourcepub fn set_data_len(&mut self, len: u16)
pub fn set_data_len(&mut self, len: u16)
Set the data length
Sourcepub fn set_packet_len(&mut self, len: u32)
pub fn set_packet_len(&mut self, len: u32)
Set the packet length
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mbuf
impl RefUnwindSafe for Mbuf
impl !Sync for Mbuf
impl Unpin for Mbuf
impl UnsafeUnpin for Mbuf
impl UnwindSafe for Mbuf
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more