pub trait DatagramSocket:
DatagramSocketSend
+ DatagramSocketRecv
+ 'static {
// Required methods
fn as_raw_io(&self) -> Option<BorrowedFd<'_>>;
fn into_fd(self) -> Option<OwnedFd>;
// Provided method
fn as_buf_io(&mut self) -> Option<&mut dyn RawPoolBufDatagramIo> { ... }
}Expand description
Describes an implementation of a connected datagram socket.
Rather than using Socket for datagram-oriented sockets, the DatagramSocket
trait purposely does not implement AsyncRead/AsyncWrite, which are traits
with stream semantics. For example, the AsyncReadExt::read_exact method
which issues as many reads as possible to fill the buffer provided.
For a similar reason, std::net::UdpSocket does not implement
io::Read nor does tokio::net::UdpSocket implement
tokio::io::AsyncRead.
Required Methods§
Provided Methods§
fn as_buf_io(&mut self) -> Option<&mut dyn RawPoolBufDatagramIo>
Implementations on Foreign Types§
Source§impl DatagramSocket for Arc<UdpSocket>
impl DatagramSocket for Arc<UdpSocket>
Source§impl DatagramSocket for UdpSocket
impl DatagramSocket for UdpSocket
Source§impl DatagramSocket for UnixDatagram
Available on Unix only.
impl DatagramSocket for UnixDatagram
Available on Unix only.