Struct bao_tree::TreeNode

source ·
pub struct TreeNode(_);
Expand description

An u64 that defines a node in a bao tree.

You typically don’t have to use this, but it can be useful for debugging and error handling. Hash validation errors contain a TreeNode that allows you to find the position where validation failed.

Implementations§

source§

impl TreeNode

source

pub const fn mid(&self) -> BlockNum

the middle of the tree node, in blocks

source

pub const fn level(&self) -> u32

The level of the node in the tree, 0 for leafs.

source

pub const fn is_leaf(&self) -> bool

True if this is a leaf node.

source

pub fn byte_range(&self, block_size: BlockSize) -> Range<ByteNum>

Range of blocks that this node covers, given a block size

source

pub const fn as_leaf(&self) -> Option<LeafNode>

Convert to a leaf node, if this is a leaf node.

source

pub const fn count_below(&self) -> u64

Number of nodes below this node, excluding this node.

source

pub fn next_left_ancestor(&self) -> Option<Self>

Get the next left ancestor of this node, or None if there is none.

source

pub fn left_child(&self) -> Option<Self>

Get the left child of this node, or None if it is a child node.

source

pub fn right_child(&self) -> Option<Self>

Get the right child of this node, or None if it is a child node.

source

pub fn parent(&self) -> Option<Self>

Unrestricted parent, can only be None if we are at the top

source

pub fn restricted_parent(&self, len: Self) -> Option<Self>

Restricted parent, will be None if we call parent on the root

source

pub const fn node_range(&self) -> Range<Self>

Get the range of nodes this node covers

source

pub fn block_range(&self) -> Range<BlockNum>

Get the range of blocks this node covers

source

pub fn post_order_offset(&self) -> u64

Get the post order offset of this node

source

pub fn right_count(&self) -> u32

the number of times you have to go right from the root to get to this node

0 for a root node

source

pub fn post_order_range(&self) -> Range<u64>

Get the range of post order offsets this node covers

Trait Implementations§

source§

impl Clone for TreeNode

source§

fn clone(&self) -> TreeNode

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 TreeNode

source§

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

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

impl From<LeafNode> for TreeNode

source§

fn from(leaf: LeafNode) -> TreeNode

Converts to this type from the input type.
source§

impl Ord for TreeNode

source§

fn cmp(&self, other: &TreeNode) -> 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<TreeNode> for TreeNode

source§

fn eq(&self, other: &TreeNode) -> 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<TreeNode> for TreeNode

source§

fn partial_cmp(&self, other: &TreeNode) -> 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 TreeNode

source§

impl Eq for TreeNode

source§

impl StructuralEq for TreeNode

source§

impl StructuralPartialEq for TreeNode

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.