pub struct BufferedReassembler { /* private fields */ }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
impl BufferedReassembler
pub fn new() -> Self
Sourcepub fn with_max_buffer(self, max_bytes: usize) -> Self
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.
Sourcepub fn with_overflow_policy(self, policy: OverflowPolicy) -> Self
pub fn with_overflow_policy(self, policy: OverflowPolicy) -> Self
Override the overflow policy. Has no effect unless
with_max_buffer is also called.
Sourcepub fn take(&mut self) -> Vec<u8> ⓘ
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.
Sourcepub fn dropped_segments(&self) -> u64
pub fn dropped_segments(&self) -> u64
Number of segments dropped because they were out of order.
Sourcepub fn bytes_dropped_oversize(&self) -> u64
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.
Sourcepub fn buffered_len(&self) -> usize
pub fn buffered_len(&self) -> usize
Bytes currently buffered (not yet drained).
Sourcepub fn is_poisoned(&self) -> bool
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
impl Debug for BufferedReassembler
Source§impl Default for BufferedReassembler
impl Default for BufferedReassembler
Source§fn default() -> BufferedReassembler
fn default() -> BufferedReassembler
Source§impl Reassembler for BufferedReassembler
impl Reassembler for BufferedReassembler
Source§fn segment(&mut self, seq: u32, payload: &[u8])
fn segment(&mut self, seq: u32, payload: &[u8])
Source§fn dropped_segments(&self) -> u64
fn dropped_segments(&self) -> u64
Source§fn bytes_dropped_oversize(&self) -> u64
fn bytes_dropped_oversize(&self) -> u64
Source§fn is_poisoned(&self) -> bool
fn is_poisoned(&self) -> bool
crate::OverflowPolicy::DropFlow). The driver checks this
once per tick; true triggers synthesis of an
Ended { reason: BufferOverflow } event for the flow.
Default: false.