Trait Outboard

Source
pub trait Outboard {
    // Required methods
    fn root(&self) -> Hash;
    fn tree(&self) -> BaoTree;
    fn load(&self, node: TreeNode) -> Result<Option<(Hash, Hash)>>;
}
Expand description

A binary merkle tree for blake3 hashes of a blob.

This trait contains information about the geometry of the tree, the root hash, and a method to load the hashes at a given node.

It is up to the implementor to decide how to store the hashes.

In the original bao crate, the hashes are stored in a file in pre order. This is implemented for a generic io object in super::outboard::PreOrderOutboard and for a memory region in super::outboard::PreOrderMemOutboard.

For files that grow over time, it is more efficient to store the hashes in post order. This is implemented for a generic io object in super::outboard::PostOrderOutboard and for a memory region in super::outboard::PostOrderMemOutboard.

If you use a different storage engine, you can implement this trait for it. E.g. you could store the hashes in a database and use the node number as the key.

Required Methods§

Source

fn root(&self) -> Hash

The root hash

Source

fn tree(&self) -> BaoTree

The tree. This contains the information about the size of the file and the block size.

Source

fn load(&self, node: TreeNode) -> Result<Option<(Hash, Hash)>>

load the hash pair for a node

Implementations on Foreign Types§

Source§

impl<O: Outboard> Outboard for &O

Source§

fn root(&self) -> Hash

Source§

fn tree(&self) -> BaoTree

Source§

fn load(&self, node: TreeNode) -> Result<Option<(Hash, Hash)>>

Source§

impl<O: Outboard> Outboard for &mut O

Source§

fn root(&self) -> Hash

Source§

fn tree(&self) -> BaoTree

Source§

fn load(&self, node: TreeNode) -> Result<Option<(Hash, Hash)>>

Implementors§