pub trait FixedBuf {
// Required methods
fn input<F: FnMut(&[u8])>(&mut self, input: &[u8], func: F);
fn reset(&mut self);
fn zero_until(&mut self, idx: usize);
fn next(&mut self, len: usize) -> &mut [u8] ⓘ;
fn full_buffer(&mut self) -> &mut [u8] ⓘ;
fn current_buffer(&self) -> &[u8] ⓘ;
fn position(&self) -> usize;
fn remaining(&self) -> usize;
fn size() -> usize;
}
Expand description
A FixedBuffer, likes its name implies, is a fixed size buffer. When the buffer becomes full, it must be processed. The input() method takes care of processing and then clearing the buffer automatically. However, other methods do not and require the caller to process the buffer. Any method that modifies the buffer directory or provides the caller with bytes that can be modifies results in those bytes being marked as used by the buffer.
Required Methods§
Sourcefn input<F: FnMut(&[u8])>(&mut self, input: &[u8], func: F)
fn input<F: FnMut(&[u8])>(&mut self, input: &[u8], func: F)
Input a vector of bytes. If the buffer becomes full, process it with the provided function and then clear the buffer.
Sourcefn zero_until(&mut self, idx: usize)
fn zero_until(&mut self, idx: usize)
Zero the buffer up until the specified index. The buffer position currently must not be greater than that index.
Sourcefn next(&mut self, len: usize) -> &mut [u8] ⓘ
fn next(&mut self, len: usize) -> &mut [u8] ⓘ
Get a slice of the buffer of the specified size. There must be at least that many bytes remaining in the buffer.
Sourcefn full_buffer(&mut self) -> &mut [u8] ⓘ
fn full_buffer(&mut self) -> &mut [u8] ⓘ
Get the current buffer. The buffer must already be full. This clears the buffer as well.
Sourcefn current_buffer(&self) -> &[u8] ⓘ
fn current_buffer(&self) -> &[u8] ⓘ
Get the current buffer.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.