pub struct MessageDatagram<D> { /* private fields */ }Available on crate feature
net only.Expand description
A whole-message sender/receiver over a DatagramSocket (a UdpSocket, a UnixDatagram, or
— under the mock feature — a MockDatagramSocket). It owns the socket and reuses one
receive buffer, so each datagram is exchanged
as a #[bin] value — the datagram counterpart to MessageStream. Unlike a stream, a
datagram socket talks to many peers, so every call carries the peer address.
Implementations§
Source§impl<D> MessageDatagram<D>
impl<D> MessageDatagram<D>
Sourcepub fn new(sock: D) -> Self
pub fn new(sock: D) -> Self
Wrap a datagram socket, with a receive buffer sized for the largest datagram (64 KiB).
Sourcepub fn with_capacity(sock: D, capacity: usize) -> Self
pub fn with_capacity(sock: D, capacity: usize) -> Self
Wrap a socket with a receive buffer of capacity bytes. A datagram larger than this is
truncated (as the OS itself would truncate an oversized recv).
Sourcepub fn get_ref(&self) -> &D
pub fn get_ref(&self) -> &D
Borrow the underlying socket (e.g. for connect, multicast, or a read timeout).
Sourcepub fn into_inner(self) -> D
pub fn into_inner(self) -> D
Recover the underlying socket.
Source§impl<D: DatagramSocket> MessageDatagram<D>
impl<D: DatagramSocket> MessageDatagram<D>
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for MessageDatagram<D>where
D: Freeze,
impl<D> RefUnwindSafe for MessageDatagram<D>where
D: RefUnwindSafe,
impl<D> Send for MessageDatagram<D>where
D: Send,
impl<D> Sync for MessageDatagram<D>where
D: Sync,
impl<D> Unpin for MessageDatagram<D>where
D: Unpin,
impl<D> UnsafeUnpin for MessageDatagram<D>where
D: UnsafeUnpin,
impl<D> UnwindSafe for MessageDatagram<D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more