Skip to main content

BufferedReassembler

Struct BufferedReassembler 

Source
pub struct BufferedReassembler { /* private fields */ }
Available on crate feature reassembler only.
Expand description

Built-in: drop OOO segments, accumulate in-order bytes into a Vec<u8> per direction. Drain via take.

Sync, no channel dep. Users who want a channel send via std::sync::mpsc themselves, or use netring’s TokioChannelReassembler for tokio integration.

Optionally bounded via with_max_buffer. When the cap is reached the OverflowPolicy decides whether to rotate bytes out (sliding window) or poison the reassembler so the driver can tear the flow down on the next tick.

Implementations§

Source§

impl BufferedReassembler

Source

pub fn new() -> Self

Source

pub fn with_max_buffer(self, max_bytes: usize) -> Self

Set a maximum in-flight buffer size in bytes. When new in-order segments would push buffered_len() past this cap, the configured OverflowPolicy kicks in.

Default policy is OverflowPolicy::SlidingWindow. Pair with with_overflow_policy to switch to OverflowPolicy::DropFlow for framed binary protocols.

Source

pub fn with_overflow_policy(self, policy: OverflowPolicy) -> Self

Override the overflow policy. Has no effect unless with_max_buffer is also called.

Source

pub fn take(&mut self) -> Vec<u8>

Drain accumulated in-order bytes, leaving the buffer empty. expected_seq is preserved so subsequent in-order segments keep accumulating.

Source

pub fn dropped_segments(&self) -> u64

Number of segments dropped because they were out of order.

Source

pub fn bytes_dropped_oversize(&self) -> u64

Number of payload bytes dropped because the per-side buffer cap was exceeded. Zero when no cap is set or when the cap has not yet been hit.

Source

pub fn buffered_len(&self) -> usize

Bytes currently buffered (not yet drained).

Source

pub fn is_poisoned(&self) -> bool

True after an OverflowPolicy::DropFlow overflow. The driver checks this once per tick; true triggers an Ended { reason: BufferOverflow } event for the flow.

Trait Implementations§

Source§

impl Debug for BufferedReassembler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BufferedReassembler

Source§

fn default() -> BufferedReassembler

Returns the “default value” for a type. Read more
Source§

impl Reassembler for BufferedReassembler

Source§

fn segment(&mut self, seq: u32, payload: &[u8])

New segment arrived in this direction. Read more
Source§

fn dropped_segments(&self) -> u64

Number of TCP segments dropped because they arrived out of order for this side. Default: 0. Read more
Source§

fn bytes_dropped_oversize(&self) -> u64

Number of payload bytes dropped because the per-side buffer cap was exceeded. Default: 0. Read more
Source§

fn is_poisoned(&self) -> bool

True after a fatal-style overflow (e.g. crate::OverflowPolicy::DropFlow). The driver checks this once per tick; true triggers synthesis of an Ended { reason: BufferOverflow } event for the flow. Default: false.
Source§

fn fin(&mut self)

FIN observed in this direction. Default: no-op.
Source§

fn rst(&mut self)

RST observed in this direction (or session aborted). Default: no-op.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more