Trait static_buffer::FixedBuf [] [src]

pub trait FixedBuf {
    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;
}

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

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.

fn reset(&mut self)

Reset the buffer.

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.

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.

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

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

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

Get the current buffer.

fn position(&self) -> usize

Get the current position of the buffer.

fn remaining(&self) -> usize

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

fn size() -> usize

Get the size of the buffer

Implementors