Skip to main content

DatagramSender

Trait DatagramSender 

pub trait DatagramSender:
    Send
    + Debug
    + 'static {
    // Required methods
    fn poll_send(
        &mut self,
        cx: &mut Context<'_>,
        datagram: &SendDatagram<'_>,
    ) -> Poll<Result<(), DatagramError>>;
    fn capabilities(&self) -> DatagramCapabilities;

    // Provided method
    fn poll_send_batch(
        &mut self,
        cx: &mut Context<'_>,
        datagrams: &[SendDatagram<'_>],
    ) -> Poll<Result<usize, DatagramError>> { ... }
}
Available on crate features std and udp only.
Expand description

Independently wakeable send side of a DatagramSocket.

The base trait is object-safe. Each handle must use an independent readiness registration or an equivalent multi-waker mechanism.

Required Methods§

fn poll_send( &mut self, cx: &mut Context<'_>, datagram: &SendDatagram<'_>, ) -> Poll<Result<(), DatagramError>>

Send one descriptor, or register for readiness.

A descriptor with segmentation metadata represents several UDP datagrams atomically at this API boundary.

fn capabilities(&self) -> DatagramCapabilities

Current runtime-detected capabilities.

Provided Methods§

fn poll_send_batch( &mut self, cx: &mut Context<'_>, datagrams: &[SendDatagram<'_>], ) -> Poll<Result<usize, DatagramError>>

Send as many descriptors as can be accepted now.

The default is a correct per-datagram fallback. A ready Ok(n) means the first n descriptors were accepted in order. An empty batch returns Ok(0). When the first descriptor is pending, this returns Pending.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§