Skip to main content

UdpSend

Trait UdpSend 

Source
pub trait UdpSend: ErrorType {
    // Required method
    async fn send(
        &mut self,
        remote: SocketAddr,
        data: &[u8],
    ) -> Result<(), Self::Error>;
}
Expand description

Re-export the edge-nal crate This trait is implemented by UDP sockets and models their datagram sending functionality.

The socket it represents might be either bound (has a local IP address, port and interface) or connected (also has a remote IP address and port).

The term “connected” here refers to the semantics of POSIX datagram sockets, through which datagrams are sent and received without having a remote address per call. It does not imply any process of establishing a connection (which is absent in UDP). While there is typically no POSIX bind() call in the creation of such sockets, these are implicitly bound to a suitable local address at connect time.

Required Methods§

Source

async fn send( &mut self, remote: SocketAddr, data: &[u8], ) -> Result<(), Self::Error>

Send the provided data to a peer:

  • In case the socket is connected, the provided remote address is ignored.
  • In case the socket is unconnected the remote address is used.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> UdpSend for &mut T
where T: UdpSend,

Source§

async fn send( &mut self, remote: SocketAddr, data: &[u8], ) -> Result<(), <&mut T as ErrorType>::Error>

Implementors§