pub struct NibbleSlice<'a> { /* fields omitted */ }Nibble-orientated view onto byte-slice, allowing nibble-precision offsets.
This is an immutable struct. No operations actually change it.
use patricia_trie::nibbleslice::NibbleSlice;
fn main() {
let d1 = &[0x01u8, 0x23, 0x45];
let d2 = &[0x34u8, 0x50, 0x12];
let d3 = &[0x00u8, 0x12];
let n1 = NibbleSlice::new(d1); // 0,1,2,3,4,5
let n2 = NibbleSlice::new(d2); // 3,4,5,0,1,2
let n3 = NibbleSlice::new_offset(d3, 1); // 0,1,2
assert!(n1 > n3); // 0,1,2,... > 0,1,2
assert!(n1 < n2); // 0,... < 3,...
assert!(n2.mid(3) == n3); // 0,1,2 == 0,1,2
assert!(n1.starts_with(&n3));
assert_eq!(n1.common_prefix(&n3), 3);
assert_eq!(n2.mid(3).common_prefix(&n1), 3);
}
Create a new nibble slice with the given byte-slice.
Create a new nibble slice with the given byte-slice with a nibble offset.
Create a composed nibble slice; one followed by the other.
pub fn iter(&'a self) -> NibbleSliceIterator<'a> | [src] |
Get an iterator for the series of nibbles.
Create a new nibble slice from the given HPE encoded data (e.g. output of encoded()).
Get the length (in nibbles, naturally) of this slice.
Get the nibble at position i.
Return object which represents a view on to this slice (further) offset by i nibbles.
Do we start with the same nibbles as the whole of them?
How many of the same nibbles at the beginning do we match with them?
Encode while nibble slice in prefixed hex notation, noting whether it is_leaf.
Encode only the leftmost n bytes of the nibble slice in prefixed hex notation,
noting whether it is_leaf.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=.
Performs copy-assignment from source. Read more
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the minimum of two values. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static