Struct BaoTree

Source
pub struct BaoTree { /* private fields */ }
Expand description

Defines a Bao tree.

This is just the specification of the tree, it does not contain any actual data.

Usually trees are self-contained. This means that the tree starts at chunk 0, and the hash of the root node is computed with the is_root flag set to true.

For some internal use, it is also possible to create trees that are just subtrees of a larger tree. In this case, the start_chunk is the chunk number of the first chunk in the tree, and the is_root flag can be false.

Implementations§

Source§

impl BaoTree

Source

pub fn new(size: u64, block_size: BlockSize) -> Self

Create a new self contained BaoTree

Source

pub fn size(&self) -> u64

The size of the blob from which this tree was constructed, in bytes

Source

pub fn block_size(&self) -> BlockSize

The block size of the tree

Source

pub fn post_order_chunks_iter(&self) -> PostOrderChunkIter

Traverse the entire tree in post order as BaoChunks

This iterator is used by both the sync and async io code for computing an outboard from existing data

Source

pub fn ranges_pre_order_chunks_iter_ref<'a>( &self, ranges: &'a RangeSetRef<ChunkNum>, min_level: u8, ) -> PreOrderPartialChunkIterRef<'a>

Traverse the part of the tree that is relevant for a ranges query in pre order as BaoChunks

This iterator is used by both the sync and async io code for encoding from an outboard and ranges as well as decoding an encoded stream.

Source

pub fn post_order_nodes_iter(&self) -> impl Iterator<Item = TreeNode>

Traverse the entire tree in post order as TreeNodes, down to the level given by the block size.

Source

pub fn pre_order_nodes_iter(&self) -> impl Iterator<Item = TreeNode>

Traverse the entire tree in pre order as TreeNodes, down to the level given by the block size.

Source

pub fn root(&self) -> TreeNode

Root of the tree

Does not consider block size

Source

pub fn blocks(&self) -> u64

Number of blocks in the tree

At chunk group size 1, this is the same as the number of chunks Even a tree with 0 bytes size has a single block

Source

pub fn chunks(&self) -> ChunkNum

Number of chunks in the tree

Source

pub fn outboard_size(&self) -> u64

The outboard size for this tree.

This is the outboard size without the size prefix.

Source

pub fn pre_order_offset(&self, node: TreeNode) -> Option<u64>

The offset of the given node in the pre order traversal

Source

pub fn post_order_offset(&self, node: TreeNode) -> Option<PostOrderOffset>

The offset of the given node in the post order traversal

Trait Implementations§

Source§

impl Clone for BaoTree

Source§

fn clone(&self) -> BaoTree

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 BaoTree

Source§

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

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

impl PartialEq for BaoTree

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for BaoTree

Source§

impl Eq for BaoTree

Source§

impl StructuralPartialEq for BaoTree

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.