pub trait Buffer:
Default
+ Deref<Target = [u8]>
+ Sealed {
// Required methods
fn push(&mut self, b: u8) -> Result<(), OutOfMemory>;
fn truncate(&mut self, len: usize);
fn clear(&mut self);
fn extend_from_slice(&mut self, other: &[u8]) -> Result<(), OutOfMemory>;
}Expand description
Interface for byte vectors.
This train provides is used as an abstraction over different byte vector
implementations. It is implemented for static vectors (ArrayBuf)
and (if the alloc feature is used) for dynamic vectors (alloc::Vec<u8>).
Required Methods§
Sourcefn push(&mut self, b: u8) -> Result<(), OutOfMemory>
fn push(&mut self, b: u8) -> Result<(), OutOfMemory>
Appends a byte to the back of the vector.
Returns Err if the vector is full and could not be extended.
Sourcefn truncate(&mut self, len: usize)
fn truncate(&mut self, len: usize)
Shortens the vector, keeping the first len elements and dropping the rest.
Sourcefn extend_from_slice(&mut self, other: &[u8]) -> Result<(), OutOfMemory>
fn extend_from_slice(&mut self, other: &[u8]) -> Result<(), OutOfMemory>
Clones and appends all bytes in a slice to the vector.
Iterates over the slice other and appends each byte to this vector. The other vector is traversed in-order.
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.