Struct s2n_quic_core::datagram::default::Sender
source · pub struct Sender { /* private fields */ }
Expand description
A struct to handle sending unreliable datagrams.
The Sender struct contains the queue of unreliable datagrams to be sent. During transmission time, we alternate between sending datagrams and sending stream data. This is to ensure there is a balance between the amount of reliable and unreliable data getting sent.
Datagrams are written to the packet in the order they are added to the queue. A datagram that is too large to fit in the packet will be dropped, unless the packet already contains written datagrams. This attempts to prevent the case where all datagrams are dropped because only a small amount of packet space remains.
Note that there is currently no expiration date for datagrams to live on the queue.
Implement the Sender
trait if
this behavior is necessary for your use-case.
Implementations§
source§impl Sender
impl Sender
sourcepub fn poll_send_datagram(
&mut self,
data: &mut Bytes,
cx: &mut Context<'_>
) -> Poll<Result<(), DatagramError>>
pub fn poll_send_datagram( &mut self, data: &mut Bytes, cx: &mut Context<'_> ) -> Poll<Result<(), DatagramError>>
Enqueues a datagram for sending it towards the peer.
§Return value
Poll::Pending
if the datagram’s send buffer capacity is currently exhausted and the datagram was not added to the queue. In this case, the caller should retry sending after theWaker
on the providedContext
is notified.Poll::Ready(Ok(()))
if the datagram was enqueued for sending.Poll::Ready(Err(DatagramError))
if an error occurred while trying to send the datagram.
sourcepub fn send_datagram_forced(
&mut self,
data: Bytes
) -> Result<Option<Bytes>, DatagramError>
pub fn send_datagram_forced( &mut self, data: Bytes ) -> Result<Option<Bytes>, DatagramError>
Adds datagrams on the queue to be sent
If the datagram queue is at capacity the oldest datagram will be popped off the queue and returned to make space for the newest datagram.
§Return value
Ok(None)
if the datagram was enqueued for sendingOk(Some(Bytes))
if the queue is at capacity this will be the oldest datagram on the queueErr(DatagramError)
if some error occurred
sourcepub fn send_datagram(&mut self, data: Bytes) -> Result<(), DatagramError>
pub fn send_datagram(&mut self, data: Bytes) -> Result<(), DatagramError>
Adds datagrams on the queue to be sent
If the queue is full the newest datagram is not added and an error is returned.
§Return value
Ok()
if the datagram was enqueued for sendingErr(DatagramError)
if some error occurred
sourcepub fn retain_datagrams<F>(&mut self, f: F)
pub fn retain_datagrams<F>(&mut self, f: F)
Filter through the datagrams in the send queue and only keep those that match a predicate
sourcepub fn max_packet_space(&self) -> usize
pub fn max_packet_space(&self) -> usize
Returns the largest packet space for datagrams seen during this connection.
Should be used to determine an appropriate datagram size that can be sent in this connection.
sourcepub fn min_packet_space(&self) -> usize
pub fn min_packet_space(&self) -> usize
Returns the smallest packet space for datagrams seen during this connection.
Should be used to determine an appropriate datagram size that can be sent in this connection.
sourcepub fn smoothed_packet_space(&self) -> usize
pub fn smoothed_packet_space(&self) -> usize
Returns a smoothed calculation of the size of packet space for datagrams seen during this connection.
Should be used to determine an appropriate datagram size that can be sent in this connection.