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§
Sourcefn send_to(
&self,
buf: &[u8],
addr: T,
) -> impl Future<Output = Result<(), SocketError>>
fn send_to( &self, buf: &[u8], addr: T, ) -> impl Future<Output = Result<(), SocketError>>
Sends a datagram containing the contents of buf to addr.
Sourcefn recv_from(
&self,
buf: &mut [u8],
) -> impl Future<Output = Result<DatagramInfo<T>, SocketError>>
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.