pub struct Assembler { /* private fields */ }
Expand description
A buffer (re)assembler.
Currently, up to a hardcoded limit of 4 or 32 holes can be tracked in the buffer.
Implementations§
Source§impl Assembler
impl Assembler
pub fn clear(&mut self)
Sourcepub fn peek_front(&self) -> usize
pub fn peek_front(&self) -> usize
Return length of the front contiguous range without removing it from the assembler
Sourcepub fn add(
&mut self,
offset: usize,
size: usize,
) -> Result<(), TooManyHolesError>
pub fn add( &mut self, offset: usize, size: usize, ) -> Result<(), TooManyHolesError>
Add a new contiguous range to the assembler,
or return Err(TooManyHolesError)
if too many discontinuities are already recorded.
Sourcepub fn remove_front(&mut self) -> usize
pub fn remove_front(&mut self) -> usize
Remove a contiguous range from the front of the assembler. If no such range, return 0.
Sourcepub fn add_then_remove_front(
&mut self,
offset: usize,
size: usize,
) -> Result<usize, TooManyHolesError>
pub fn add_then_remove_front( &mut self, offset: usize, size: usize, ) -> Result<usize, TooManyHolesError>
Add a segment, then remove_front.
This is equivalent to calling add
then remove_front
individually,
except it’s guaranteed to not fail when offset = 0.
This is required for TCP: we must never drop the next expected segment, or
the protocol might get stuck.
Sourcepub fn iter_data(&self, first_offset: usize) -> AssemblerIter<'_>
pub fn iter_data(&self, first_offset: usize) -> AssemblerIter<'_>
Iterate over all of the contiguous data ranges.
This is used in calculating what data ranges have been received. The offset indicates the number of bytes of contiguous data received before the beginnings of this Assembler.
Data Hole Data |— 100 —|— 200 —|— 100 —|
An offset of 1500 would return the ranges: (1500, 1600), (1800, 1900)