pub trait DatagramSocketRecv: Send {
    // Required method
    fn poll_recv(
        &mut self,
        cx: &mut Context<'_>,
        buf: &mut ReadBuf<'_>,
    ) -> Poll<Result<()>>;
    // Provided methods
    fn poll_recv_from(
        &mut self,
        cx: &mut Context<'_>,
        buf: &mut ReadBuf<'_>,
    ) -> Poll<Result<SocketAddr>> { ... }
    fn poll_recv_many(
        &mut self,
        cx: &mut Context<'_>,
        bufs: &mut [ReadBuf<'_>],
    ) -> Poll<Result<usize>> { ... }
    fn as_udp_socket(&self) -> Option<&UdpSocket> { ... }
}Expand description
Describes the receive half of a connected datagram socket.
Required Methods§
Sourcefn poll_recv(
    &mut self,
    cx: &mut Context<'_>,
    buf: &mut ReadBuf<'_>,
) -> Poll<Result<()>>
 
fn poll_recv( &mut self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>
Attempts to receive a single datagram message on the socket from the
remote address to which it is connected.
Note that on multiple calls to a poll_* method in the recv
direction, only the Waker from the Context passed to the most
recent call will be scheduled to receive a wakeup.
§Return value
The function returns:
Poll::Pendingif the socket is not ready to readPoll::Ready(Ok(()))reads dataReadBufif the socket is readyPoll::Ready(Err(e))if an error is encountered.
§Errors
This function may encounter any standard I/O error except WouldBlock.
Provided Methods§
Sourcefn poll_recv_from(
    &mut self,
    cx: &mut Context<'_>,
    buf: &mut ReadBuf<'_>,
) -> Poll<Result<SocketAddr>>
 
fn poll_recv_from( &mut self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<SocketAddr>>
Attempts to receive a single datagram on the socket.
Note that on multiple calls to a poll_* method in the recv
direction, only the Waker from the Context passed to the most
recent call will be scheduled to receive a wakeup.
§Return value
The function returns:
Poll::Pendingif the socket is not ready to readPoll::Ready(Ok(addr))reads data fromaddrintoReadBufif the socket is readyPoll::Ready(Err(e))if an error is encountered.
§Errors
This function may encounter any standard I/O error except WouldBlock.
Sourcefn poll_recv_many(
    &mut self,
    cx: &mut Context<'_>,
    bufs: &mut [ReadBuf<'_>],
) -> Poll<Result<usize>>
 
fn poll_recv_many( &mut self, cx: &mut Context<'_>, bufs: &mut [ReadBuf<'_>], ) -> Poll<Result<usize>>
Attempts to receive multiple datagrams on the socket from the remote
address to which it is connected.
Note that on multiple calls to a poll_* method in the recv
direction, only the Waker from the Context passed to the most
recent call will be scheduled to receive a wakeup.
§Return value
The function returns:
Poll::Pendingif the socket is not ready to readPoll::Ready(Ok(n))reads dataReadBufif the socket is readynis the number of datagrams read.Poll::Ready(Err(e))if an error is encountered.
§Errors
This function may encounter any standard I/O error except WouldBlock.
Sourcefn as_udp_socket(&self) -> Option<&UdpSocket>
 
fn as_udp_socket(&self) -> Option<&UdpSocket>
If the underlying socket is a UdpSocket, return the reference to it.