Expand description
Represents the label of a AKD node
Fields§
§label_val: [u8; 32]
Stores a binary string as a 32-byte array of u8
s
label_len: u32
len keeps track of how long the binary string is in bits
Implementations§
source§impl NodeLabel
impl NodeLabel
sourcepub fn hash(&self) -> [u8; 32]
pub fn hash(&self) -> [u8; 32]
Hash a NodeLabel into a digest, length-prefixing the label’s value
sourcepub fn get_longest_common_prefix(&self, other: NodeLabel) -> NodeLabel
pub fn get_longest_common_prefix(&self, other: NodeLabel) -> NodeLabel
Takes as input a pointer to the caller and another NodeLabel, returns a NodeLabel that is the longest common prefix of the two.
sourcepub fn get_prefix(&self, len: u32) -> NodeLabel
pub fn get_prefix(&self, len: u32) -> NodeLabel
Returns the prefix of a specified length, and the entire value on an out of range length
sourcepub fn new(val: [u8; 32], len: u32) -> NodeLabel
pub fn new(val: [u8; 32], len: u32) -> NodeLabel
Creates a new NodeLabel with the given value and len.
sourcepub fn get_sibling_prefix(&self, len: u32) -> NodeLabel
pub fn get_sibling_prefix(&self, len: u32) -> NodeLabel
The sibling of a node in a binary tree has the same label as its sibling except its last bit is flipped (e.g., 000 and 001 are siblings). This function returns the sibling prefix of a specified length. The rest of the node label after the flipped bit is padded with zeroes. For instance, 010100 (length = 6) with sibling prefix length = 3 is 01[1]000 (length = 3) – [bit] denoting flipped bit.
sourcepub fn get_longest_common_prefix_and_dirs(
&self,
other: NodeLabel
) -> (NodeLabel, Option<usize>, Option<usize>)
pub fn get_longest_common_prefix_and_dirs(
&self,
other: NodeLabel
) -> (NodeLabel, Option<usize>, Option<usize>)
Takes as input a pointer to self, another NodeLabel and returns the tuple representing:
- the longest common prefix,
- the direction, with respect to the longest common prefix, of other,
- the direction, with respect to the longest common prefix, of self. If either the node itself, or other is the longest common prefix, the direction of the longest common prefix node is None.
Trait Implementations§
source§impl<'de> Deserialize<'de> for NodeLabel
impl<'de> Deserialize<'de> for NodeLabel
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<NodeLabel, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<NodeLabel, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl Ord for NodeLabel
impl Ord for NodeLabel
source§impl PartialOrd<NodeLabel> for NodeLabel
impl PartialOrd<NodeLabel> for NodeLabel
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for NodeLabel
impl Serialize for NodeLabel
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for NodeLabel
impl Eq for NodeLabel
impl StructuralEq for NodeLabel
impl StructuralPartialEq for NodeLabel
Auto Trait Implementations§
impl RefUnwindSafe for NodeLabel
impl Send for NodeLabel
impl Sync for NodeLabel
impl Unpin for NodeLabel
impl UnwindSafe for NodeLabel
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
key
and return true
if they are equal.