pub struct Nibbles { /* private fields */ }Expand description
Struct representing a list of nibbles (half-bytes)
Implementations§
Source§impl Nibbles
impl Nibbles
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
Splits incoming bytes into nibbles and appends the leaf flag (a 16 nibble at the end)
Sourcepub fn from_raw(bytes: &[u8], is_leaf: bool) -> Self
pub fn from_raw(bytes: &[u8], is_leaf: bool) -> Self
Splits incoming bytes into nibbles and appends the leaf flag (a 16 nibble at the end) if is_leaf is true
pub fn into_vec(self) -> Vec<u8> ⓘ
Sourcepub fn skip_prefix(&mut self, prefix: &Nibbles) -> bool
pub fn skip_prefix(&mut self, prefix: &Nibbles) -> bool
If prefix is a prefix of self, move the offset after
the prefix and return true, otherwise return false.
Sourcepub fn compare_prefix(&self, prefix: &Nibbles) -> Ordering
pub fn compare_prefix(&self, prefix: &Nibbles) -> Ordering
Compares self to another, comparing prefixes only in case of unequal lengths.
Sourcepub fn count_prefix(&self, other: &Nibbles) -> usize
pub fn count_prefix(&self, other: &Nibbles) -> usize
Compares self to another and returns the shared nibble count (amount of nibbles that are equal, from the start)
Sourcepub fn next_choice(&mut self) -> Option<usize>
pub fn next_choice(&mut self) -> Option<usize>
Removes and returns the first nibble if it is a suitable choice index (aka < 16)
Sourcepub fn slice(&self, start: usize, end: usize) -> Nibbles
pub fn slice(&self, start: usize, end: usize) -> Nibbles
Returns the nibbles beween the start and end indexes
Sourcepub fn at(&self, i: usize) -> usize
pub fn at(&self, i: usize) -> usize
Return the nibble at the given index, will panic if the index is out of range
Sourcepub fn encode_compact(&self) -> Vec<u8> ⓘ
pub fn encode_compact(&self) -> Vec<u8> ⓘ
Taken from https://github.com/citahub/cita_trie/blob/master/src/nibbles.rs#L56 Encodes the nibbles in compact form
Sourcepub fn decode_compact(compact: &[u8]) -> Self
pub fn decode_compact(compact: &[u8]) -> Self
Encodes the nibbles in compact form
Sourcepub fn is_leaf(&self) -> bool
pub fn is_leaf(&self) -> bool
Returns true if the nibbles contain the leaf flag (16) at the end
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Combines the nibbles into bytes, trimming the leaf flag if necessary
Sourcepub fn concat(&self, other: &Nibbles) -> Nibbles
pub fn concat(&self, other: &Nibbles) -> Nibbles
Concatenates self and another Nibbles returning a new Nibbles
Sourcepub fn append_new(&self, nibble: u8) -> Nibbles
pub fn append_new(&self, nibble: u8) -> Nibbles
Returns a copy of self with the nibble added at the end
Trait Implementations§
Source§impl Archive for Nibbles
impl Archive for Nibbles
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§impl<'de> Deserialize<'de> for Nibbles
impl<'de> Deserialize<'de> for Nibbles
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Nibbles
Source§impl Ord for Nibbles
impl Ord for Nibbles
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Nibbles
impl PartialOrd for Nibbles
Source§impl RLPDecode for Nibbles
impl RLPDecode for Nibbles
fn decode_unfinished(rlp: &[u8]) -> Result<(Self, &[u8]), RLPDecodeError>
fn decode(rlp: &[u8]) -> Result<Self, RLPDecodeError>
Auto Trait Implementations§
impl Freeze for Nibbles
impl RefUnwindSafe for Nibbles
impl Send for Nibbles
impl Sync for Nibbles
impl Unpin for Nibbles
impl UnsafeUnpin for Nibbles
impl UnwindSafe for Nibbles
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, S> SerializeUnsized<S> for T
impl<T, S> SerializeUnsized<S> for T
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)