Trait DatagramSocketSend

Source
pub trait DatagramSocketSend: Sync {
    // Required methods
    fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>;
    fn poll_send_to(
        &self,
        cx: &mut Context<'_>,
        buf: &[u8],
        addr: SocketAddr,
    ) -> Poll<Result<usize>>;

    // Provided methods
    fn poll_send_many(
        &self,
        cx: &mut Context<'_>,
        bufs: &[ReadBuf<'_>],
    ) -> Poll<Result<usize>> { ... }
    fn as_udp_socket(&self) -> Option<&UdpSocket> { ... }
    fn peer_addr(&self) -> Option<SocketAddr> { ... }
}
Expand description

Describes the send half of a connected datagram socket.

Required Methods§

Source

fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>

Attempts to send data on the socket to the remote address to which it was previously connected.

Note that on multiple calls to a poll_* method in the send 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 available to write
  • Poll::Ready(Ok(n)) n is the number of bytes sent
  • Poll::Ready(Err(e)) if an error is encountered.
§Errors

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

Source

fn poll_send_to( &self, cx: &mut Context<'_>, buf: &[u8], addr: SocketAddr, ) -> Poll<Result<usize>>

Attempts to send data on the socket to a given address.

If this socket only supports a single address, it should forward to send. It should not panic or discard the data. It’s recommended that this return an error if addr doesn’t match the only supported address.

Note that on multiple calls to a poll_* method in the send 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 write
  • Poll::Ready(Ok(n)) n is the number of bytes sent.
  • 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_send_many( &self, cx: &mut Context<'_>, bufs: &[ReadBuf<'_>], ) -> Poll<Result<usize>>

Attempts to send multiple packets of data on the socket to the remote address to which it was previously connected.

Note that on multiple calls to a poll_* method in the send 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 write
  • Poll::Ready(Ok(n)) n is the number of packets sent. If any packet was sent only partially, that information is lost.
  • 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.

Source

fn peer_addr(&self) -> Option<SocketAddr>

Returns the socket address of the remote peer this socket was connected to.

Implementations on Foreign Types§

Source§

impl DatagramSocketSend for UdpSocket

Source§

fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>

Source§

fn poll_send_to( &self, cx: &mut Context<'_>, buf: &[u8], addr: SocketAddr, ) -> Poll<Result<usize>>

Source§

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

Source§

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

Source§

fn peer_addr(&self) -> Option<SocketAddr>

Source§

impl DatagramSocketSend for UnixDatagram

Source§

fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>

Source§

fn poll_send_to( &self, _: &mut Context<'_>, _: &[u8], _: SocketAddr, ) -> Poll<Result<usize>>

Source§

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

Implementors§