Trait FixedBuf

Source
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§

Source

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.

Source

fn reset(&mut self)

Reset the buffer.

Source

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.

Source

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.

Source

fn full_buffer(&mut self) -> &mut [u8]

Get the current buffer. The buffer must already be full. This clears the buffer as well.

Source

fn current_buffer(&self) -> &[u8]

Get the current buffer.

Source

fn position(&self) -> usize

Get the current position of the buffer.

Source

fn remaining(&self) -> usize

Get the number of bytes remaining in the buffer until it is full.

Source

fn size() -> usize

Get the size of the 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.

Implementors§