Struct akd_core::types::node_label::NodeLabel
source · pub struct NodeLabel {
pub label_val: [u8; 32],
pub label_len: u32,
}
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) -> Vec<u8> ⓘ
pub fn hash(&self) -> Vec<u8> ⓘ
Hash a NodeLabel into a digest, length-prefixing the label’s value
sourcepub fn is_prefix_of(&self, other: &Self) -> bool
pub fn is_prefix_of(&self, other: &Self) -> bool
Outputs whether or not self is a prefix of the other NodeLabel
sourcepub fn get_longest_common_prefix(&self, other: NodeLabel) -> Self
pub fn get_longest_common_prefix(&self, other: NodeLabel) -> Self
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) -> Self
pub fn get_prefix(&self, len: u32) -> Self
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) -> Self
pub fn new(val: [u8; 32], len: u32) -> Self
Creates a new NodeLabel with the given value and len (in bits).
sourcepub fn get_prefix_ordering(&self, other: Self) -> PrefixOrdering
pub fn get_prefix_ordering(&self, other: Self) -> PrefixOrdering
Gets the prefix ordering of other with respect to self, if self is a prefix of other. If self is not a prefix of other, then this returns PrefixOrdering::Invalid.
Trait Implementations§
source§impl Ord for NodeLabel
impl Ord for NodeLabel
source§impl PartialEq<NodeLabel> for NodeLabel
impl PartialEq<NodeLabel> 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
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more