pub struct Batch { /* private fields */ }Expand description
Holds multiple packet descriptors to avoid unnecessary allocations
on each Interface::read_batch()
and Interface::write_batch() calls.
Implementations§
Source§impl Batch
impl Batch
Sourcepub fn preallocate(count: usize) -> Batch
pub fn preallocate(count: usize) -> Batch
Preallocates a batch of size count which holds the packet descriptors.
These packet descriptors are used internally by Interface::read_batch()
and Interface::write_batch().
Note that you’ll only be able to receive or send as many packets as preallocated in a batch.
Sourcepub fn packet_sizes(&self) -> impl Iterator<Item = usize> + use<'_>
pub fn packet_sizes(&self) -> impl Iterator<Item = usize> + use<'_>
Retrieves packet sizes received after calling the Interface::read_batch().
Note that since a Batch abstraction lacks any information about the number of packets received,
use Iterator::take() on the returned iterator in order to limit it
to only useful items.
Sourcepub fn packet_sized_bufs<'a, B>(
&self,
bufs: &'a [B],
) -> impl Iterator<Item = &'a [u8]> + use<'a, '_, B>
pub fn packet_sized_bufs<'a, B>( &self, bufs: &'a [B], ) -> impl Iterator<Item = &'a [u8]> + use<'a, '_, B>
Given a slice of buffers used for a call to Interface::read_batch(),
returns an iterator over mutable slices derived from the provided buffers, where each slice is limited
to the corresponding received packet length.
This method is based on Batch::packet_sizes() and is provided for convenience.
Note that since a Batch abstraction lacks any information about the number of packets received,
use Iterator::take() on the returned iterator in order to limit it
to only useful items.