Struct smoltcp::storage::PacketBuffer
source · pub struct PacketBuffer<'a, 'b, H: 'a> { /* private fields */ }
Expand description
An UDP packet ring buffer.
Implementations§
source§impl<'a, 'b, H> PacketBuffer<'a, 'b, H>
impl<'a, 'b, H> PacketBuffer<'a, 'b, H>
sourcepub fn new<MS, PS>(
metadata_storage: MS,
payload_storage: PS
) -> PacketBuffer<'a, 'b, H>where
MS: Into<ManagedSlice<'a, PacketMetadata<H>>>,
PS: Into<ManagedSlice<'b, u8>>,
pub fn new<MS, PS>(
metadata_storage: MS,
payload_storage: PS
) -> PacketBuffer<'a, 'b, H>where
MS: Into<ManagedSlice<'a, PacketMetadata<H>>>,
PS: Into<ManagedSlice<'b, u8>>,
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.
sourcepub fn enqueue(&mut self, size: usize, header: H) -> Result<&mut [u8]>
pub fn enqueue(&mut self, size: usize, header: H) -> Result<&mut [u8]>
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.