[][src]Struct capsule::Mbuf

pub struct Mbuf { /* fields omitted */ }

A DPDK message buffer that carries the network packet.

Remarks

Multi-segment Mbuf is not supported. It's the application's responsibilty to ensure that the ethernet device's MTU is less than the default size of a single Mbuf segment (RTE_MBUF_DEFAULT_DATAROOM = 2048).

Implementations

impl Mbuf[src]

pub fn new() -> Fallible<Self>[src]

Creates a new message buffer.

The Mbuf is allocated from the Mempool assigned to the current executing thread by the Runtime. The call will fail if invoked from a thread not managed by the Runtime.

pub fn from_bytes(data: &[u8]) -> Fallible<Self>[src]

Creates a new message buffer from a byte array.

pub fn data_len(&self) -> usize[src]

Returns amount of data stored in the buffer.

pub fn extend(&mut self, offset: usize, len: usize) -> Fallible<()>[src]

Extends the data buffer at offset by len bytes.

If the offset is not at the end of the data. The data after the offset is shifted down to make room.

pub fn shrink(&mut self, offset: usize, len: usize) -> Fallible<()>[src]

Shrinks the data buffer at offset by len bytes.

The data at offset is shifted up.

pub fn resize(&mut self, offset: usize, len: isize) -> Fallible<()>[src]

Resizes the data buffer.

pub fn truncate(&mut self, to_len: usize) -> Fallible<()>[src]

Truncates the data buffer to len.

pub fn read_data<T: SizeOf>(&self, offset: usize) -> Fallible<NonNull<T>>[src]

Reads the data at offset as T and returns it as a raw pointer.

pub fn write_data<T: SizeOf>(
    &mut self,
    offset: usize,
    item: &T
) -> Fallible<NonNull<T>>
[src]

Writes T to the data buffer at offset and returns the new copy as a raw pointer.

Before writing to the data buffer, should call Mbuf::extend first to make sure enough space is allocated for the write and data is not being overridden.

pub fn read_data_slice<T: SizeOf>(
    &self,
    offset: usize,
    count: usize
) -> Fallible<NonNull<[T]>>
[src]

Reads the data at offset as a slice of T and returns the slice as a raw pointer.

pub fn write_data_slice<T: SizeOf>(
    &mut self,
    offset: usize,
    slice: &[T]
) -> Fallible<NonNull<[T]>>
[src]

Writes a slice of T to the data buffer at offset and returns the new copy as a raw pointer.

Before writing to the data buffer, should call Mbuf::extend first to make sure enough space is allocated for the write and data is not being overridden.

pub fn alloc_bulk(len: usize) -> Fallible<Vec<Mbuf>>[src]

Allocates a Vec of Mbufs of len size.

Trait Implementations

impl Arbitrary for Mbuf[src]

type Parameters = ()

The type of parameters that [arbitrary_with] accepts for configuration of the generated [Strategy]. Parameters must implement [Default]. Read more

type Strategy = fn() -> Self

The type of [Strategy] used to generate values of type Self. Read more

impl Debug for Mbuf[src]

impl Drop for Mbuf[src]

impl Packet for Mbuf[src]

type Envelope = Mbuf

The preceding packet type that encapsulates this packet. Read more

impl Send for Mbuf[src]

Auto Trait Implementations

impl RefUnwindSafe for Mbuf

impl !Sync for Mbuf

impl Unpin for Mbuf

impl UnwindSafe for Mbuf

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,