Struct bao_tree::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.

Implementations§

source§

impl BaoTree

source

pub fn empty(block_size: BlockSize) -> Self

Create a new empty BaoTree with the given block size

source

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

Create a new BaoTree

source

pub fn size(&self) -> ByteNum

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

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 ) -> PreOrderChunkIterRef<'a>

Traverse the part of the tree that is relevant for a ranges querys 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) -> PostOrderNodeIter

Traverse the entire tree in post order as TreeNodes

This is mostly used internally by the PostOrderChunkIter

source

pub fn pre_order_nodes_iter(&self) -> PreOrderNodeIter

Traverse the entire tree in pre order as TreeNodes

source

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

Traverse the part of the tree that is relevant for a ranges querys in pre order as NodeInfos

This is mostly used internally by the PreOrderChunkIterRef

source

pub fn new_with_start_chunk( size: ByteNum, block_size: BlockSize, start_chunk: ChunkNum ) -> Self

Create a new BaoTree with a start chunk

This is used for trees that are part of a larger file. The start chunk is the chunk number of the first chunk in the tree.

This is mostly used internally.

source

pub fn root(&self) -> TreeNode

Root of the tree

source

pub fn blocks(&self) -> BlockNum

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 const fn chunk_num(&self, node: LeafNode) -> ChunkNum

Given a leaf node of this tree, return its start chunk number

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<BaoTree> for BaoTree

source§

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

source§

impl Eq for BaoTree

source§

impl StructuralEq for BaoTree

source§

impl StructuralPartialEq for BaoTree

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.