Trait den::ExtendVec

source ·
pub trait ExtendVec: Debug {
    // Required methods
    fn extend(&self, vec: &mut Vec<u8>);
    fn replace(&self, vec: &mut Vec<u8>, position: usize);
    fn equals(&self, bytes: &[u8]) -> bool;
    fn len(&self) -> usize;

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

A trait to fill extend a Vec with more data.

This is by default implemented by all types which can cohere to a byte slice &[u8].

Required Methods§


fn extend(&self, vec: &mut Vec<u8>)

Extend vec with our data. This must extend with ExtendVec::len bytes.


fn replace(&self, vec: &mut Vec<u8>, position: usize)

Copy the bytes of this struct to position in vec, overriding any data there. This must replace ExtendVec::len bytes.


fn equals(&self, bytes: &[u8]) -> bool

If our data equals bytes.


fn len(&self) -> usize

The length of the data of this struct.

Provided Methods§


fn is_empty(&self) -> bool

If no data is available.



impl<T: AsRef<[u8]> + Debug> ExtendVec for T