Skip to main content

Mbuf

Struct Mbuf 

Source
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

Source

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)
Source

pub fn as_raw(&self) -> *mut rte_mbuf

Get the raw pointer to the underlying mbuf

Source

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

Source

pub fn data_offset(&self) -> u16

Get the data offset within the buffer

Source

pub fn packet_len(&self) -> u32

Get the total packet length

Source

pub fn data_len(&self) -> u16

Get the data length in this segment

Source

pub fn buf_len(&self) -> u16

Get the buffer length (total available space)

Source

pub fn data(&self) -> Option<&[u8]>

Get a slice to the packet data

Returns None if the buffer address is null

Source

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

Source

pub fn set_data_len(&mut self, len: u16)

Set the data length

Source

pub fn set_packet_len(&mut self, len: u32)

Set the packet length

Trait Implementations§

Source§

impl Drop for Mbuf

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Mbuf

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.