[][src]Struct smoltcp::storage::PacketBuffer

pub struct PacketBuffer<'a, H: 'a> { /* fields omitted */ }

An UDP packet ring buffer.

Implementations

impl<'a, H> PacketBuffer<'a, H>[src]

pub fn new<MS, PS>(
    metadata_storage: MS,
    payload_storage: PS
) -> PacketBuffer<'a, H> where
    MS: Into<ManagedSlice<'a, PacketMetadata<H>>>,
    PS: Into<ManagedSlice<'a, u8>>, 
[src]

Create a new packet buffer with the provided metadata and payload storage.

Metadata storage limits the maximum number of packets in the buffer and payload storage limits the maximum total size of packets.

pub fn is_empty(&self) -> bool[src]

Query whether the buffer is empty.

pub fn is_full(&self) -> bool[src]

Query whether the buffer is full.

pub fn enqueue(&mut self, size: usize, header: H) -> Result<&mut [u8]>[src]

Enqueue a single packet with the given header into the buffer, and return a reference to its payload, or return Err(Error::Exhausted) if the buffer is full, or return Err(Error::Truncated) if the buffer does not have enough spare payload space.

pub fn dequeue_with<'c, R, F>(&'c mut self, f: F) -> Result<R> where
    F: FnOnce(&mut H, &'c mut [u8]) -> Result<R>, 
[src]

Call f with a single packet from the buffer, and dequeue the packet if f returns successfully, or return Err(Error::Exhausted) if the buffer is empty.

pub fn dequeue(&mut self) -> Result<(H, &mut [u8])>[src]

Dequeue a single packet from the buffer, and return a reference to its payload as well as its header, or return Err(Error::Exhausted) if the buffer is empty.

pub fn peek(&mut self) -> Result<(&H, &[u8])>[src]

Peek at a single packet from the buffer without removing it, and return a reference to its payload as well as its header, or return Err(Error:Exhaused) if the buffer is empty.

This function otherwise behaves identically to dequeue.

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

Return the maximum number packets that can be stored.

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

Return the maximum number of bytes in the payload ring buffer.

Trait Implementations

impl<'a, H: Debug + 'a> Debug for PacketBuffer<'a, H>[src]

Auto Trait Implementations

impl<'a, H> RefUnwindSafe for PacketBuffer<'a, H> where
    H: RefUnwindSafe
[src]

impl<'a, H> Send for PacketBuffer<'a, H> where
    H: Send
[src]

impl<'a, H> Sync for PacketBuffer<'a, H> where
    H: Sync
[src]

impl<'a, H> Unpin for PacketBuffer<'a, H> where
    H: Unpin
[src]

impl<'a, H> !UnwindSafe for PacketBuffer<'a, H>[src]

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, 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.