Skip to main content

FastReceiver

Struct FastReceiver 

Source
pub struct FastReceiver<const WIN: usize, const MTU: usize, const REASM: usize, const TOTAL: usize> { /* private fields */ }
Expand description

Fastest backend — O(1) insert and O(1) delivery.

Use when CPU budget is tight and you can afford the extra memory: both buffering an out-of-order segment and delivering a run of consecutive segments are constant-time per packet.

Stores out-of-order segments in WIN fixed MTU-sized slots indexed by seq % WIN. Each slot reserves a full MTU even for shorter payloads.

Static memory: WIN × MTU (reorder) + REASM (reassembly).

  • WIN — receive window (number of slots)
  • MTU — maximum segment payload size
  • REASM — reassembly buffer size
  • TOTAL — total slot storage (WIN * MTU)

Trait Implementations§

Source§

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

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.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.