Struct NibbleVec

struct NibbleVec<A: Array<Item = u8>> { ... }

A data-structure for storing a sequence of 4-bit values.

Values are stored in a Vec<u8>, with two values per byte.

Values at even indices are stored in the most-significant half of their byte, while values at odd indices are stored in the least-significant half.

Imagine a vector of MSB first bytes, and you'll be right.

n = [_ _ | _ _ | _ _]

Implementations

impl<A: Array<Item = u8>> NibbleVec<A>

fn new() -> NibbleVec<A>

Create an empty nibble vector.

fn from_byte_vec(vec: Vec<u8>) -> NibbleVec<A>

Create a nibble vector from a vector of bytes.

Each byte is split into two 4-bit entries (MSB, LSB).

fn as_bytes(self: &Self) -> &[u8]

Returns a byte slice of the nibble vector's contents.

fn into_bytes(self: Self) -> Vec<u8>

Converts a nibble vector into a byte vector.

This consumes the nibble vector, so we do not need to copy its contents.

fn len(self: &Self) -> usize

Get the number of elements stored in the vector.

fn is_empty(self: &Self) -> bool

Returns true if the nibble vector has a length of 0.

fn get(self: &Self, idx: usize) -> u8

Fetch a single entry from the vector.

Guaranteed to be a value in the interval [0, 15].

Panics if idx >= self.len().

fn push(self: &mut Self, val: u8)

Add a single nibble to the vector.

Only the 4 least-significant bits of the value are used.

fn split(self: &mut Self, idx: usize) -> NibbleVec<A>

Split the vector into two parts.

All elements at or following the given index are returned in a new NibbleVec, with exactly idx elements remaining in this vector.

Panics if idx > self.len().

fn join(self: Self, other: &NibbleVec<A>) -> NibbleVec<A>

Append another nibble vector whilst consuming this vector.

impl<'a, A: Array<Item = u8>> From for NibbleVec<A>

fn from(v: &[u8]) -> NibbleVec<A>

impl<A> Freeze for NibbleVec<A>

impl<A> RefUnwindSafe for NibbleVec<A>

impl<A> Send for NibbleVec<A>

impl<A> Sync for NibbleVec<A>

impl<A> Unpin for NibbleVec<A>

impl<A> UnsafeUnpin for NibbleVec<A>

impl<A> UnwindSafe for NibbleVec<A>

impl<A: $crate::clone::Clone + Array<Item = u8>> Clone for NibbleVec<A>

fn clone(self: &Self) -> NibbleVec<A>

impl<A: $crate::default::Default + Array<Item = u8>> Default for NibbleVec<A>

fn default() -> NibbleVec<A>

impl<A: Array<Item = u8>> Debug for NibbleVec<A>

fn fmt(self: &Self, fmt: &mut Formatter<'_>) -> Result

impl<A: Array<Item = u8>> Eq for NibbleVec<A>

impl<A: Array<Item = u8>> From for NibbleVec<A>

fn from(v: Vec<u8>) -> NibbleVec<A>

impl<A: Array<Item = u8>> Into for NibbleVec<A>

fn into(self: Self) -> Vec<u8>

impl<A: Array<Item = u8>> PartialEq for NibbleVec<A>

fn eq(self: &Self, other: &NibbleVec<A>) -> bool

impl<A: Array<Item = u8>> PartialEq for NibbleVec<A>

fn eq(self: &Self, other: &[u8]) -> bool

impl<T> Any for NibbleVec<A>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for NibbleVec<A>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for NibbleVec<A>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for NibbleVec<A>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for NibbleVec<A>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for NibbleVec<A>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for NibbleVec<A>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for NibbleVec<A>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for NibbleVec<A>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>