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
impl BaoTree
Sourcepub fn block_size(&self) -> BlockSize
pub fn block_size(&self) -> BlockSize
The block size of the tree
Sourcepub fn post_order_chunks_iter(&self) -> PostOrderChunkIter ⓘ
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
Sourcepub fn ranges_pre_order_chunks_iter_ref<'a>(
&self,
ranges: &'a RangeSetRef<ChunkNum>,
min_level: u8,
) -> PreOrderPartialChunkIterRef<'a> ⓘ
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.
Sourcepub fn post_order_nodes_iter(&self) -> impl Iterator<Item = TreeNode>
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.
Sourcepub fn pre_order_nodes_iter(&self) -> impl Iterator<Item = TreeNode>
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.
Sourcepub fn blocks(&self) -> u64
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
Sourcepub fn outboard_size(&self) -> u64
pub fn outboard_size(&self) -> u64
The outboard size for this tree.
This is the outboard size without the size prefix.
Sourcepub fn pre_order_offset(&self, node: TreeNode) -> Option<u64>
pub fn pre_order_offset(&self, node: TreeNode) -> Option<u64>
The offset of the given node in the pre order traversal
Sourcepub fn post_order_offset(&self, node: TreeNode) -> Option<PostOrderOffset>
pub fn post_order_offset(&self, node: TreeNode) -> Option<PostOrderOffset>
The offset of the given node in the post order traversal