Skip to main content

Socket

Trait Socket 

Source
pub trait Socket<T> {
    // Required methods
    fn send_to(
        &self,
        buf: &[u8],
        addr: T,
    ) -> impl Future<Output = Result<(), SocketError>>;
    fn recv_from(
        &self,
        buf: &mut [u8],
    ) -> impl Future<Output = Result<DatagramInfo<T>, SocketError>>;
}
Expand description

Abstracts sending and receiving datagrams on a socket.

Required Methods§

Source

fn send_to( &self, buf: &[u8], addr: T, ) -> impl Future<Output = Result<(), SocketError>>

Sends a datagram containing the contents of buf to addr.

Source

fn recv_from( &self, buf: &mut [u8], ) -> impl Future<Output = Result<DatagramInfo<T>, SocketError>>

Receives a datagram into buf, returning the number of bytes received and the address the datagram was received from.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§