AsyncUdpSocket

Trait AsyncUdpSocket 

Source
pub trait AsyncUdpSocket:
    Send
    + Sync
    + Debug
    + 'static {
    // Required methods
    fn create_sender(&self) -> Pin<Box<dyn UdpSender>>;
    fn poll_recv(
        &mut self,
        cx: &mut Context<'_>,
        bufs: &mut [IoSliceMut<'_>],
        meta: &mut [RecvMeta],
    ) -> Poll<Result<usize>>;
    fn local_addr(&self) -> Result<SocketAddr>;

    // Provided methods
    fn max_receive_segments(&self) -> usize { ... }
    fn may_fragment(&self) -> bool { ... }
}
Expand description

Abstract implementation of a UDP socket for runtime independence

Required Methods§

Source

fn create_sender(&self) -> Pin<Box<dyn UdpSender>>

Create a UdpSender that can register a single task for write-readiness notifications and send a transmit, if ready.

A poll_send method on a single object can usually store only one Waker at a time, i.e. allow at most one caller to wait for an event. This method allows any number of interested tasks to construct their own UdpSender object. They can all then wait for the same event and be notified concurrently, because each UdpSender can store a separate Waker.

Source

fn poll_recv( &mut self, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta], ) -> Poll<Result<usize>>

Receive UDP datagrams, or register to be woken if receiving may succeed in the future

Source

fn local_addr(&self) -> Result<SocketAddr>

Look up the local IP address and port used by this socket

Provided Methods§

Source

fn max_receive_segments(&self) -> usize

Maximum number of datagrams that might be described by a single RecvMeta

Source

fn may_fragment(&self) -> bool

Whether datagrams might get fragmented into multiple parts

Sockets should prevent this for best performance. See e.g. the IPV6_DONTFRAG socket option.

Implementors§