pub trait Packet {
    // Required methods
    fn remaining_capacity(&self) -> usize;
    fn write_datagram(&mut self, data: &[u8]) -> Result<(), WriteError>;
    fn write_datagram_vectored(
        &mut self,
        data: &[&[u8]]
    ) -> Result<(), WriteError>;
    fn has_pending_streams(&self) -> bool;
    fn datagrams_prioritized(&self) -> bool;
}
Expand description

A packet will be available during the on_transmit callback. Use the methods defined here to interrogate the packet struct and write datagrams to the packet.

Required Methods§

source

fn remaining_capacity(&self) -> usize

Returns the remaining space in the packet left to write datagrams

source

fn write_datagram(&mut self, data: &[u8]) -> Result<(), WriteError>

Writes a single datagram to a packet. This function should be called per datagram.

source

fn write_datagram_vectored(&mut self, data: &[&[u8]]) -> Result<(), WriteError>

Writes a single datagram to a packet from a collection of buffers. This function should be called per datagram.

source

fn has_pending_streams(&self) -> bool

Returns whether or not there is reliable data waiting to be sent.

Use method to decide whether or not to cede the packet space to the stream data.

source

fn datagrams_prioritized(&self) -> bool

Returns whether or not datagrams are prioritized in this packet or not.

Datagrams get prioritized every other packet, which gives the application the best chance to send a large datagram.

Implementors§