pub trait Socket<T> {
// Required methods
async fn send_to(&self, buf: &[u8], addr: T) -> Result<(), SocketError>;
async fn recv_from(
&self,
buf: &mut [u8],
) -> Result<DatagramInfo<T>, SocketError>;
}
Expand description
Abstracts sending and receiving datagrams on a socket.
Required Methods§
Sourceasync fn send_to(&self, buf: &[u8], addr: T) -> Result<(), SocketError>
async fn send_to(&self, buf: &[u8], addr: T) -> Result<(), SocketError>
Sends a datagram containing the contents of buf
to addr
.
Sourceasync fn recv_from(
&self,
buf: &mut [u8],
) -> Result<DatagramInfo<T>, SocketError>
async fn recv_from( &self, buf: &mut [u8], ) -> 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.