Skip to main content

ResizeBuffer

Trait ResizeBuffer 

Source
pub trait ResizeBuffer:
    WriteBuffer
    + AsRef<[u8]>
    + AsMut<[u8]> {
    // Required methods
    fn buffer_insert(&mut self, pos: usize, data: &[u8]) -> Result<(), Error>;
    fn buffer_remove(&mut self, range: Range<usize>) -> Result<(), Error>;
    fn buffer_resize(&mut self, len: usize) -> Result<(), Error>;

    // Provided method
    fn buffer_extend(&mut self, len: usize) -> Result<&mut [u8], Error> { ... }
}
Expand description

Support for writing to, accessing, and resizing a byte buffer

Required Methods§

Source

fn buffer_insert(&mut self, pos: usize, data: &[u8]) -> Result<(), Error>

Insert a slice at the given position in the buffer

Source

fn buffer_remove(&mut self, range: Range<usize>) -> Result<(), Error>

Remove an exclusive range from the buffer

Source

fn buffer_resize(&mut self, len: usize) -> Result<(), Error>

Resize the buffer, truncating or padding it with zeroes

Provided Methods§

Source

fn buffer_extend(&mut self, len: usize) -> Result<&mut [u8], Error>

Extend the buffer with len bytes of zeroes and return a mutable reference to the slice

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ResizeBuffer for Vec<u8>

Available on crate feature alloc only.
Source§

fn buffer_insert(&mut self, pos: usize, data: &[u8]) -> Result<(), Error>

Source§

fn buffer_remove(&mut self, range: Range<usize>) -> Result<(), Error>

Source§

fn buffer_resize(&mut self, len: usize) -> Result<(), Error>

Implementors§

Source§

impl ResizeBuffer for SecretBytes

Available on crate feature alloc only.
Source§

impl ResizeBuffer for Writer<'_, [u8]>

Source§

impl<B: ResizeBuffer + ?Sized> ResizeBuffer for Writer<'_, B>