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§
Sourcefn create_sender(&self) -> Pin<Box<dyn UdpSender>>
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.
Sourcefn poll_recv(
&mut self,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>],
meta: &mut [RecvMeta],
) -> Poll<Result<usize>>
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
Sourcefn local_addr(&self) -> Result<SocketAddr>
fn local_addr(&self) -> Result<SocketAddr>
Look up the local IP address and port used by this socket
Provided Methods§
Sourcefn max_receive_segments(&self) -> usize
fn max_receive_segments(&self) -> usize
Maximum number of datagrams that might be described by a single RecvMeta
Sourcefn may_fragment(&self) -> bool
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.