Trait DatagramSocketRecv

Source
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§

Source

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::Pending if the socket is not ready to read
  • Poll::Ready(Ok(())) reads data ReadBuf if the socket is ready
  • Poll::Ready(Err(e)) if an error is encountered.
§Errors

This function may encounter any standard I/O error except WouldBlock.

Provided Methods§

Source

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::Pending if the socket is not ready to read
  • Poll::Ready(Ok(addr)) reads data from addr into ReadBuf if the socket is ready
  • Poll::Ready(Err(e)) if an error is encountered.
§Errors

This function may encounter any standard I/O error except WouldBlock.

Source

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::Pending if the socket is not ready to read
  • Poll::Ready(Ok(n)) reads data ReadBuf if the socket is ready n is 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.

Source

fn as_udp_socket(&self) -> Option<&UdpSocket>

If the underlying socket is a UdpSocket, return the reference to it.

Implementations on Foreign Types§

Source§

impl DatagramSocketRecv for Arc<UdpSocket>

Source§

fn poll_recv( &mut self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>

Source§

fn poll_recv_from( &mut self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<SocketAddr>>

Source§

fn poll_recv_many( &mut self, cx: &mut Context<'_>, bufs: &mut [ReadBuf<'_>], ) -> Poll<Result<usize>>

Source§

fn as_udp_socket(&self) -> Option<&UdpSocket>

Source§

impl DatagramSocketRecv for Arc<UnixDatagram>

Source§

fn poll_recv( &mut self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>

Source§

fn poll_recv_many( &mut self, cx: &mut Context<'_>, bufs: &mut [ReadBuf<'_>], ) -> Poll<Result<usize>>

Source§

impl DatagramSocketRecv for UdpSocket

Source§

fn poll_recv( &mut self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>

Source§

fn poll_recv_many( &mut self, cx: &mut Context<'_>, bufs: &mut [ReadBuf<'_>], ) -> Poll<Result<usize>>

Source§

fn as_udp_socket(&self) -> Option<&UdpSocket>

Source§

impl DatagramSocketRecv for UnixDatagram

Source§

fn poll_recv( &mut self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>

Source§

fn poll_recv_many( &mut self, cx: &mut Context<'_>, bufs: &mut [ReadBuf<'_>], ) -> Poll<Result<usize>>

Implementors§