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

source

pub fn from_parts(level: Level, index: u64) -> Self

Construct a new address from its constituent parts.

source

pub fn above_position(level: Level, position: Position) -> Self

Returns the address at the given level that contains the specified leaf position.

source

pub fn level(&self) -> Level

Returns the level of the root of the tree having its root at this address.

source

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.

source

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.

source

pub fn sibling(&self) -> Address

Returns the address that shares the same parent as this address.

source

pub fn children(&self) -> Option<(Address, Address)>

Returns the immediate children of this address.

source

pub fn is_ancestor_of(&self, addr: &Self) -> bool

Returns whether this address is an ancestor of the specified address.

source

pub fn common_ancestor(&self, other: &Self) -> Self

Returns the common ancestor of self and other having the smallest level value.

source

pub fn contains(&self, addr: &Self) -> bool

Returns whether this address is an ancestor of, or is equal to, the specified address.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn is_left_child(&self) -> bool

Returns whether this address is the left-hand child of its parent

source

pub fn is_right_child(&self) -> bool

Returns whether this address is the right-hand child of its parent

source

pub fn current_incomplete(&self) -> Address

source

pub fn next_incomplete_parent(&self) -> Address

source

pub fn next_at_level(&self) -> Address

Increments this address’s index by 1 and returns the resulting address.

Trait Implementations§

source§

impl Clone for Address

source§

fn clone(&self) -> Address

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Address

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Address> for Option<Position>

source§

fn from(addr: &'a Address) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Position> for Address

source§

fn from(p: &'a Position) -> Self

Converts to this type from the input type.
source§

impl From<Address> for Option<Position>

source§

fn from(addr: Address) -> Self

Converts to this type from the input type.
source§

impl From<Position> for Address

source§

fn from(p: Position) -> Self

Converts to this type from the input type.
source§

impl Hash for Address

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Address

source§

fn cmp(&self, other: &Address) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Address> for Address

source§

fn eq(&self, other: &Address) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Address> for Address

source§

fn partial_cmp(&self, other: &Address) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Address

source§

impl Eq for Address

source§

impl StructuralEq for Address

source§

impl StructuralPartialEq for Address

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V