pub trait DatagramSocketRecvExt: DatagramSocketRecv {
// Provided methods
fn recv(
&mut self,
buf: &mut [u8],
) -> impl Future<Output = Result<usize>> + Send { ... }
fn recv_from(
&mut self,
buf: &mut [u8],
) -> impl Future<Output = Result<(usize, SocketAddr)>> + Send { ... }
fn recv_many(
&mut self,
bufs: &mut [ReadBuf<'_>],
) -> impl Future<Output = Result<usize>> + Send { ... }
}
Expand description
Reads datagrams from a socket.
Implemented as an extension trait, adding utility methods to all
DatagramSocketRecv
types. Callers will tend to import this trait instead
of DatagramSocketRecv
.
Provided Methods§
Sourcefn recv(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<usize>> + Send
fn recv(&mut self, buf: &mut [u8]) -> impl Future<Output = Result<usize>> + Send
Receives a single datagram message on the socket from the remote address to which it is connected. On success, returns the number of bytes read.
Sourcefn recv_from(
&mut self,
buf: &mut [u8],
) -> impl Future<Output = Result<(usize, SocketAddr)>> + Send
fn recv_from( &mut self, buf: &mut [u8], ) -> impl Future<Output = Result<(usize, SocketAddr)>> + Send
Receives a single datagram message on the socket. On success, returns the number of bytes read and the origin.
Sourcefn recv_many(
&mut self,
bufs: &mut [ReadBuf<'_>],
) -> impl Future<Output = Result<usize>> + Send
fn recv_many( &mut self, bufs: &mut [ReadBuf<'_>], ) -> impl Future<Output = Result<usize>> + Send
Receives multiple datagrams on the socket from the remote address
to which it is connected. Returns the number of buffers used (i.e.
number of datagrams read). Each used buffer can be read up to its
filled().len()
.
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.