pub struct ReceivedDatagram {
pub bytes_received: usize,
pub source: SocketAddrV4,
pub truncated: bool,
}Expand description
The result of a successful TransportSocket::recv_from.
truncated is set if the backend delivered only a prefix of the
incoming datagram because it did not fit in the caller’s buffer. If
callers use a buffer sized to crate::UDP_BUFFER_SIZE, truncation is
generally not expected on backends whose delivered datagrams are
bounded by that configured application-level cap. Backends that may
deliver larger datagrams should surface this explicitly instead of
silently dropping the fact that data was discarded.
Note: the default Tokio backend currently always reports
truncated: false because tokio::net::UdpSocket::recv_from does not
expose MSG_TRUNC (or equivalent). Reliable truncation detection
requires a backend that does — e.g. a recvmsg-based backend, or a
no_std stack like smoltcp / embassy-net that surfaces the original
datagram length.
Fields§
§bytes_received: usizeNumber of bytes written to the caller’s buffer.
source: SocketAddrV4Source address of the datagram.
truncated: booltrue if the incoming datagram was larger than the caller’s
buffer and the tail was discarded. See the type-level docs for
the default Tokio backend’s caveat.
Trait Implementations§
Source§impl Clone for ReceivedDatagram
impl Clone for ReceivedDatagram
Source§fn clone(&self) -> ReceivedDatagram
fn clone(&self) -> ReceivedDatagram
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ReceivedDatagram
Source§impl Debug for ReceivedDatagram
impl Debug for ReceivedDatagram
impl Eq for ReceivedDatagram
Source§impl PartialEq for ReceivedDatagram
impl PartialEq for ReceivedDatagram
Source§fn eq(&self, other: &ReceivedDatagram) -> bool
fn eq(&self, other: &ReceivedDatagram) -> bool
self and other values to be equal, and is used by ==.