pub struct StreamChunks { /* private fields */ }reassembler only.Expand description
Reassembled output of one direction of a stream: in-order bytes,
the gaps between them, and an optional terminal
ReassemblyStop.
Built-in reassemblers use it as their ready buffer and append it
to the caller’s StreamChunks on Reassembler::drain_into, so
a driver can keep one scratch value and reuse its capacity across
packets (no allocation in steady state).
Walk it in stream order with Self::iter:
use flowscope::{Chunk, StreamChunks};
let mut s = StreamChunks::new();
s.push_data(b"GET / HTTP/1.1\r\n");
s.push_gap(1200);
s.push_data(b"Host: example\r\n");
let parts: Vec<_> = s.iter().collect();
assert_eq!(parts[0], Chunk::Data(b"GET / HTTP/1.1\r\n"));
assert_eq!(parts[1], Chunk::Gap(1200));
assert_eq!(parts[2], Chunk::Data(b"Host: example\r\n"));Implementations§
Source§impl StreamChunks
impl StreamChunks
Sourcepub fn push_gap(&mut self, len: u64)
pub fn push_gap(&mut self, len: u64)
Record that len bytes are missing at the current end.
Adjacent gaps coalesce; len == 0 is ignored.
Sourcepub fn set_stop(&mut self, stop: ReassemblyStop)
pub fn set_stop(&mut self, stop: ReassemblyStop)
Mark the stream as stopped. The first reason wins.
Sourcepub fn stop(&self) -> Option<ReassemblyStop>
pub fn stop(&self) -> Option<ReassemblyStop>
Why the stream stopped, if it did.
Sourcepub fn data(&self) -> &[u8] ⓘ
pub fn data(&self) -> &[u8] ⓘ
All data bytes, concatenated, without gap information.
Use Self::iter when gaps matter (they usually do).
Sourcepub fn append(&mut self, other: &mut StreamChunks)
pub fn append(&mut self, other: &mut StreamChunks)
Move everything from other onto the end of self, leaving
other empty and without capacity: a reassembler drained
into a caller’s buffer keeps no memory. When self is empty
the buffers are moved, not copied.
Trait Implementations§
Source§impl Clone for StreamChunks
impl Clone for StreamChunks
Source§impl Debug for StreamChunks
impl Debug for StreamChunks
Source§impl Default for StreamChunks
impl Default for StreamChunks
impl Eq for StreamChunks
Source§impl PartialEq for StreamChunks
impl PartialEq for StreamChunks
impl StructuralPartialEq for StreamChunks
Auto Trait Implementations§
impl Freeze for StreamChunks
impl RefUnwindSafe for StreamChunks
impl Send for StreamChunks
impl Sync for StreamChunks
impl Unpin for StreamChunks
impl UnsafeUnpin for StreamChunks
impl UnwindSafe for StreamChunks
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.