pub struct Datagrams<'a> { /* private fields */ }
Expand description
API to control datagram traffic
Implementations§
Source§impl<'a> Datagrams<'a>
impl<'a> Datagrams<'a>
Sourcepub fn send(&mut self, data: Bytes, drop: bool) -> Result<(), SendDatagramError>
pub fn send(&mut self, data: Bytes, drop: bool) -> Result<(), SendDatagramError>
Queue an unreliable, unordered datagram for immediate transmission
If drop
is true, previously queued datagrams which are still unsent may be discarded to
make space for this datagram, in order of oldest to newest. If drop
is false, and there
isn’t enough space due to previously queued datagrams, this function will return
SendDatagramError::Blocked
. Event::DatagramsUnblocked
will be emitted once datagrams
have been sent.
Returns Err
iff a len
-byte datagram cannot currently be sent.
Sourcepub fn max_size(&self) -> Option<usize>
pub fn max_size(&self) -> Option<usize>
Compute the maximum size of datagrams that may passed to send_datagram
Returns None
if datagrams are unsupported by the peer or disabled locally.
This may change over the lifetime of a connection according to variation in the path MTU estimate. The peer can also enforce an arbitrarily small fixed limit, but if the peer’s limit is large this is guaranteed to be a little over a kilobyte at minimum.
Not necessarily the maximum size of received datagrams.
Sourcepub fn send_buffer_space(&self) -> usize
pub fn send_buffer_space(&self) -> usize
Bytes available in the outgoing datagram buffer
When greater than zero, send
ing a datagram of at most this size is
guaranteed not to cause older datagrams to be dropped.