Struct NibbleVec
pub struct NibbleVec<A: Array<Item = u8>> { /* private fields */ }
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) -> &[u8]Returns a byte slice of the nibble vector's contents.
fn into_bytes(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) -> usizeGet the number of elements stored in the vector.
fn is_empty(&self) -> boolReturns
trueif the nibble vector has a length of 0.fn get(&self, idx: usize) -> u8Fetch a single entry from the vector.
Guaranteed to be a value in the interval [0, 15].
Panics if
idx >= self.len().fn push(&mut self, val: u8)Add a single nibble to the vector.
Only the 4 least-significant bits of the value are used.
fn split(&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 exactlyidxelements remaining in this vector.Panics if
idx > self.len().fn join(self, other: &NibbleVec<A>) -> NibbleVec<A>Append another nibble vector whilst consuming this vector.
Trait Implementations
impl<'a, A: Array<Item = u8>> From<&'a [u8]> for NibbleVec<A>
fn from(v: &[u8]) -> NibbleVec<A>
impl<A: Array<Item = u8>> Debug for NibbleVec<A>
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
impl<A: Array<Item = u8>> Eq for NibbleVec<A>
impl<A: Array<Item = u8>> From<Vec<u8>> for NibbleVec<A>
fn from(v: Vec<u8>) -> NibbleVec<A>
impl<A: Array<Item = u8>> Into<Vec<u8>> for NibbleVec<A>
fn into(self) -> Vec<u8>
impl<A: Array<Item = u8>> PartialEq for NibbleVec<A>
fn eq(&self, other: &NibbleVec<A>) -> bool
impl<A: Array<Item = u8>> PartialEq<[u8]> for NibbleVec<A>
fn eq(&self, other: &[u8]) -> bool
impl<A: Clone + Array<Item = u8>> Clone for NibbleVec<A>
fn clone(&self) -> Self
impl<A: Default + Array<Item = u8>> Default for NibbleVec<A>
fn default() -> Self
Auto Trait Implementations
impl<A> Freeze for NibbleVec<A>
where
SmallVec<A>: Freeze,
impl<A> RefUnwindSafe for NibbleVec<A>
where
SmallVec<A>: RefUnwindSafe,
impl<A> Send for NibbleVec<A>
where
SmallVec<A>: Send,
impl<A> Sync for NibbleVec<A>
where
SmallVec<A>: Sync,
impl<A> Unpin for NibbleVec<A>
where
SmallVec<A>: Unpin,
impl<A> UnsafeUnpin for NibbleVec<A>
where
SmallVec<A>: UnsafeUnpin,
impl<A> UnwindSafe for NibbleVec<A>
where
SmallVec<A>: UnwindSafe,
Blanket Implementations
impl<T> Any for NibbleVec<A>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for NibbleVec<A>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for NibbleVec<A>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for NibbleVec<A>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for NibbleVec<A>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for NibbleVec<A>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for NibbleVec<A>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for NibbleVec<A>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for NibbleVec<A>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>