Struct incrementalmerkletree::Address
source · pub struct Address { /* private fields */ }
Expand description
The address of a node of the Merkle tree.
When level == 0
, the index has the same value as the
position.
Implementations§
source§impl Address
impl Address
sourcepub fn from_parts(level: Level, index: u64) -> Self
pub fn from_parts(level: Level, index: u64) -> Self
Construct a new address from its constituent parts.
sourcepub fn above_position(level: Level, position: Position) -> Self
pub fn above_position(level: Level, position: Position) -> Self
Returns the address at the given level that contains the specified leaf position.
sourcepub fn level(&self) -> Level
pub fn level(&self) -> Level
Returns the level of the root of the tree having its root at this address.
sourcepub fn index(&self) -> u64
pub fn index(&self) -> u64
Returns the index of the address.
The index of an address is defined as the number of subtrees with their roots at the address’s level that appear to the left of this address in a binary tree of arbitrary height > level * 2 + 1.
sourcepub fn parent(&self) -> Address
pub fn parent(&self) -> Address
The address of the node one level higher than this in a binary tree that contains this address as either its left or right child.
sourcepub fn sibling(&self) -> Address
pub fn sibling(&self) -> Address
Returns the address that shares the same parent as this address.
sourcepub fn children(&self) -> Option<(Address, Address)>
pub fn children(&self) -> Option<(Address, Address)>
Returns the immediate children of this address.
sourcepub fn is_ancestor_of(&self, addr: &Self) -> bool
pub fn is_ancestor_of(&self, addr: &Self) -> bool
Returns whether this address is an ancestor of the specified address.
sourcepub fn common_ancestor(&self, other: &Self) -> Self
pub fn common_ancestor(&self, other: &Self) -> Self
Returns the common ancestor of self
and other
having the smallest level value.
sourcepub fn contains(&self, addr: &Self) -> bool
pub fn contains(&self, addr: &Self) -> bool
Returns whether this address is an ancestor of, or is equal to, the specified address.
sourcepub fn position_range_start(&self) -> Position
pub fn position_range_start(&self) -> Position
Returns the minimum value among the range of leaf positions that are contained within the tree with its root at this address.
sourcepub fn position_range_end(&self) -> Position
pub fn position_range_end(&self) -> Position
Returns the (exclusive) end of the range of leaf positions that are contained within the tree with its root at this address.
sourcepub fn max_position(&self) -> Position
pub fn max_position(&self) -> Position
Returns the maximum value among the range of leaf positions that are contained within the tree with its root at this address.
sourcepub fn position_range(&self) -> Range<Position>
pub fn position_range(&self) -> Range<Position>
Returns the end-exclusive range of leaf positions that are contained within the tree with its root at this address.
sourcepub fn context(&self, level: Level) -> Either<Address, Range<u64>>
pub fn context(&self, level: Level) -> Either<Address, Range<u64>>
Returns either the ancestor of this address at the given level (if the level is greater than or equal to that of this address) or the range of indices of root addresses of subtrees with roots at the given level contained within the tree with its root at this address otherwise.
sourcepub fn position_cmp(&self, pos: Position) -> Ordering
pub fn position_cmp(&self, pos: Position) -> Ordering
Returns whether the tree with this root address contains the given leaf position, or if not whether an address at the same level with a greater or lesser index will contain the specified leaf position.
sourcepub fn is_left_child(&self) -> bool
pub fn is_left_child(&self) -> bool
Returns whether this address is the left-hand child of its parent
sourcepub fn is_right_child(&self) -> bool
pub fn is_right_child(&self) -> bool
Returns whether this address is the right-hand child of its parent
pub fn current_incomplete(&self) -> Address
pub fn next_incomplete_parent(&self) -> Address
sourcepub fn next_at_level(&self) -> Address
pub fn next_at_level(&self) -> Address
Increments this address’s index by 1 and returns the resulting address.
Trait Implementations§
source§impl Ord for Address
impl Ord for Address
source§impl PartialEq for Address
impl PartialEq for Address
source§impl PartialOrd for Address
impl PartialOrd for Address
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 more