Skip to main content

ReceiverBackend

Trait ReceiverBackend 

Source
pub trait ReceiverBackend: Sized {
    // Required methods
    fn new() -> Self;
    fn handle_data(
        &mut self,
        seq: SequenceCount,
        flags: SequenceFlag,
        payload: &[u8],
    ) -> Result<DataOutcome, ReceiverError>;
    fn skip_gap(&mut self) -> Result<GapOutcome, ReceiverError>;
    fn take_message(&mut self) -> Option<&[u8]>;
    fn reassembly_data(&self, len: usize) -> &[u8] ;
    fn has_message(&self) -> bool;
    fn message_len(&self) -> Option<usize>;
    fn consume_message<Ret>(
        &mut self,
        f: impl FnOnce(&[u8]) -> Ret,
    ) -> Option<Ret>;
    fn expected_seq(&self) -> SequenceCount;
    fn recv_bitmap(&self) -> u16;
}
Expand description

Trait abstracting over receiver backends (buffering and delivery only).

Required Methods§

Source

fn new() -> Self

Create a new backend with empty buffers.

Source

fn handle_data( &mut self, seq: SequenceCount, flags: SequenceFlag, payload: &[u8], ) -> Result<DataOutcome, ReceiverError>

Process a received data packet.

Source

fn skip_gap(&mut self) -> Result<GapOutcome, ReceiverError>

Skip the current gap (advance past missing packets).

Source

fn take_message(&mut self) -> Option<&[u8]>

Take the complete message.

Source

fn reassembly_data(&self, len: usize) -> &[u8]

Returns a slice of the reassembly buffer.

Source

fn has_message(&self) -> bool

Check if there’s a complete message ready.

Source

fn message_len(&self) -> Option<usize>

Returns the length of the pending message, if any.

Source

fn consume_message<Ret>(&mut self, f: impl FnOnce(&[u8]) -> Ret) -> Option<Ret>

Pass the pending message to f and mark it consumed.

Source

fn expected_seq(&self) -> SequenceCount

Get the current expected sequence number.

Source

fn recv_bitmap(&self) -> u16

Get the selective ACK bitmap.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const REASM: usize, const WIN: usize, const MTU: usize> ReceiverBackend for LiteReceiver<REASM, WIN, MTU>

Source§

impl<const WIN: usize, const BUF: usize, const REASM: usize> ReceiverBackend for PackedReceiver<WIN, BUF, REASM>

Source§

impl<const WIN: usize, const MTU: usize, const REASM: usize, const TOTAL: usize> ReceiverBackend for FastReceiver<WIN, MTU, REASM, TOTAL>