pub trait Buffer: Default + Deref<Target = [u8]> {
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 (heapless::Vec<u8>
)
and (if the alloc
feature is used( for dynamic vectors (alloc::Vec<u8>
).
Required Methods
Appends a byte to the back of the vector.
Returns Err
if the vector is full and could not be extended.
Shortens the vector, keeping the first len elements and dropping the rest.
fn 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.