Struct diem_types::nibble::nibble_path::NibblePath
source · pub struct NibblePath { /* private fields */ }
Expand description
NibblePath defines a path in Merkle tree in the unit of nibble (4 bits).
Implementations§
source§impl NibblePath
impl NibblePath
sourcepub fn new(bytes: Vec<u8>) -> Self
pub fn new(bytes: Vec<u8>) -> Self
Creates a new NibblePath
from a vector of bytes assuming each byte has 2 nibbles.
sourcepub fn new_odd(bytes: Vec<u8>) -> Self
pub fn new_odd(bytes: Vec<u8>) -> Self
Similar to new()
but assumes that the bytes have one less nibble.
sourcepub fn get_nibble(&self, i: usize) -> Nibble
pub fn get_nibble(&self, i: usize) -> Nibble
Get the i-th nibble.
sourcepub fn bits(&self) -> BitIterator<'_> ⓘ
pub fn bits(&self) -> BitIterator<'_> ⓘ
Get a bit iterator iterates over the whole nibble path.
sourcepub fn nibbles(&self) -> NibbleIterator<'_> ⓘ
pub fn nibbles(&self) -> NibbleIterator<'_> ⓘ
Get a nibble iterator iterates over the whole nibble path.
sourcepub fn num_nibbles(&self) -> usize
pub fn num_nibbles(&self) -> usize
Get the total number of nibbles stored.
Trait Implementations§
source§impl Arbitrary for NibblePath
impl Arbitrary for NibblePath
§type Parameters = ()
type Parameters = ()
The type of parameters that
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.source§fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
§type Strategy = BoxedStrategy<NibblePath>
type Strategy = BoxedStrategy<NibblePath>
The type of
Strategy
used to generate values of type Self
.source§impl Clone for NibblePath
impl Clone for NibblePath
source§fn clone(&self) -> NibblePath
fn clone(&self) -> NibblePath
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for NibblePath
impl Debug for NibblePath
Supports debug format by concatenating nibbles literally. For example, [0x12, 0xa0] with 3 nibbles will be printed as “12a”.
source§impl<'de> Deserialize<'de> for NibblePath
impl<'de> Deserialize<'de> for NibblePath
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl FromIterator<Nibble> for NibblePath
impl FromIterator<Nibble> for NibblePath
Convert a vector of bytes into NibblePath
using the lower 4 bits of each byte as nibble.
source§impl Hash for NibblePath
impl Hash for NibblePath
source§impl Ord for NibblePath
impl Ord for NibblePath
source§fn cmp(&self, other: &NibblePath) -> Ordering
fn cmp(&self, other: &NibblePath) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<NibblePath> for NibblePath
impl PartialEq<NibblePath> for NibblePath
source§fn eq(&self, other: &NibblePath) -> bool
fn eq(&self, other: &NibblePath) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<NibblePath> for NibblePath
impl PartialOrd<NibblePath> for NibblePath
source§fn partial_cmp(&self, other: &NibblePath) -> Option<Ordering>
fn partial_cmp(&self, other: &NibblePath) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for NibblePath
impl Serialize for NibblePath
impl Eq for NibblePath
impl StructuralEq for NibblePath
impl StructuralPartialEq for NibblePath
Auto Trait Implementations§
impl RefUnwindSafe for NibblePath
impl Send for NibblePath
impl Sync for NibblePath
impl Unpin for NibblePath
impl UnwindSafe for NibblePath
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> TestOnlyHash for Twhere
T: Serialize + ?Sized,
impl<T> TestOnlyHash for Twhere T: Serialize + ?Sized,
source§fn test_only_hash(&self) -> HashValue
fn test_only_hash(&self) -> HashValue
Generates a hash used only for tests.