pub struct UdpRecvBatch { /* private fields */ }Expand description
A batch of UDP packets received.
This structure holds multiple received packets from a single
recvmmsg system call on Linux.
Implementations§
Source§impl UdpRecvBatch
impl UdpRecvBatch
Sourcepub async fn recv(&mut self, socket: &UdpSocket) -> Result<usize>
pub async fn recv(&mut self, socket: &UdpSocket) -> Result<usize>
Receives a batch of packets using the most efficient method available.
On Linux, uses recvmmsg for batched receiving. On other platforms,
receives packets individually up to MAX_BATCH_SIZE.
Returns the number of packets received.
Sourcepub fn get(&self, index: usize) -> Option<(&[u8], SocketAddr)>
pub fn get(&self, index: usize) -> Option<(&[u8], SocketAddr)>
Gets a reference to a packet and its source address by index.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&[u8], SocketAddr)>
pub fn iter(&self) -> impl Iterator<Item = (&[u8], SocketAddr)>
Returns an iterator over the packets and their source addresses.
Trait Implementations§
Source§impl Debug for UdpRecvBatch
impl Debug for UdpRecvBatch
Auto Trait Implementations§
impl Freeze for UdpRecvBatch
impl RefUnwindSafe for UdpRecvBatch
impl Send for UdpRecvBatch
impl Sync for UdpRecvBatch
impl Unpin for UdpRecvBatch
impl UnwindSafe for UdpRecvBatch
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more