Skip to main content

Buffer

Trait Buffer 

Source
pub trait Buffer: AsRef<[u8]> + AsMut<[u8]> {
    // Required methods
    fn extend_from_slice(&mut self, other: &[u8]) -> Result<()>;
    fn truncate(&mut self, len: usize);

    // Provided methods
    fn len(&self) -> usize { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

In-place encryption/decryption byte buffers.

This trait defines the set of methods needed to support in-place operations on a Vec-like data type.

Required Methods§

Source

fn extend_from_slice(&mut self, other: &[u8]) -> Result<()>

Extend this buffer from the given slice.

§Errors

If the buffer has insufficient capacity.

Source

fn truncate(&mut self, len: usize)

Truncate this buffer to the given size.

Provided Methods§

Source

fn len(&self) -> usize

Get the length of the buffer

Source

fn is_empty(&self) -> bool

Is the buffer empty?

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Buffer for Vec<u8>

Available on crate feature alloc only.
Source§

fn extend_from_slice(&mut self, other: &[u8]) -> Result<()>

Source§

fn truncate(&mut self, len: usize)

Implementors§