pub struct DecodeBuffer { /* private fields */ }Expand description
Incremental frame decoder backed by pooled BufferChunk storage.
It supports decoding complete frames while the backing buffer is being filled, and can chain overflow data across chunk boundaries when a frame spans multiple pooled buffers.
Implementations§
Source§impl DecodeBuffer
impl DecodeBuffer
Sourcepub fn new(buffer: BufferChunk, buffer_config: &BufferConfig) -> DecodeBuffer
pub fn new(buffer: BufferChunk, buffer_config: &BufferConfig) -> DecodeBuffer
Creates a new DecodeBuffer from th given BufferChunk.
Sourcepub fn readable_len(&self) -> usize
pub fn readable_len(&self) -> usize
Returns the number of readable bytes currently buffered.
Sourcepub fn writeable_len(&self) -> usize
pub fn writeable_len(&self) -> usize
Returns the number of writable bytes remaining in the current chunk.
Sourcepub fn advance_writeable(&mut self, num_bytes: usize)
pub fn advance_writeable(&mut self, num_bytes: usize)
Advances the write pointer by num_bytes.
Sourcepub fn get_writeable(&mut self) -> Option<&mut [u8]>
pub fn get_writeable(&mut self) -> Option<&mut [u8]>
Returns a writable slice at the current write position.
If something is written to the slice, advance_writeable must be called afterwards.
Sourcepub fn has_frame(&mut self) -> Result<bool, Error>
pub fn has_frame(&mut self) -> Result<bool, Error>
Returns true if there is data to be decoded, else false
Returns true once a complete frame is available for decoding.
Sourcepub fn swap_buffer(&mut self, other: &mut BufferChunk)
pub fn swap_buffer(&mut self, other: &mut BufferChunk)
Swaps the underlying buffer in place with other.
Afterwards other owns the used up bytes and is locked.
get_frame() should be called repeatedly until it returns FramingError::NoData
before calling this method.
Sourcepub fn get_frame(&mut self) -> Result<Frame, FramingError>
pub fn get_frame(&mut self) -> Result<Frame, FramingError>
Tries to decode one frame from the readable part of the buffer.