pub struct SendItem<'a> { /* private fields */ }Expand description
A single outbound UDP datagram.
Build with SendItem::new and optionally chain ecn / segment_size
to attach ancillary data.
When segment_size is set and the platform supports it (Linux GSO), the
kernel will segment data into multiple datagrams of segment_size bytes
each (the final segment may be shorter). This allows sending N packets in
a single syscall.
Implementations§
Source§impl<'a> SendItem<'a>
impl<'a> SendItem<'a>
Sourcepub fn new(destination: SocketAddr, data: &'a [u8]) -> Self
pub fn new(destination: SocketAddr, data: &'a [u8]) -> Self
Create a datagram targeting destination with the given data payload.
Address comes first, then data.
Sourcepub fn segment_size(self, segment_size: u16) -> Self
pub fn segment_size(self, segment_size: u16) -> Self
Enable UDP segmentation offload (GSO on Linux). The kernel will split
data into consecutive chunks of segment_size bytes and send each as
a separate UDP datagram to the same destination.
data.len() must be a multiple of segment_size, except for the final
segment which may be shorter.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SendItem<'a>
impl<'a> RefUnwindSafe for SendItem<'a>
impl<'a> Send for SendItem<'a>
impl<'a> Sync for SendItem<'a>
impl<'a> Unpin for SendItem<'a>
impl<'a> UnsafeUnpin for SendItem<'a>
impl<'a> UnwindSafe for SendItem<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more