KeyedTree

Trait KeyedTree 

Source
pub trait KeyedTree<H: Hasher, const D: usize> {
    // Required methods
    fn root(&self) -> &H::Out;
    fn value(&self, key: &[u8]) -> Result<Option<DBValue>, TreeError>;
    fn leaf(&self, key: &[u8]) -> Result<Option<H::Out>, TreeError>;
    fn proof(
        &self,
        key: &[u8],
    ) -> Result<(Option<DBValue>, <H as Hasher>::Out, Vec<DBValue>), TreeError>;
    fn verify(
        key: &[u8],
        value: &[u8],
        proof: &[DBValue],
        root: &H::Out,
    ) -> Result<bool, TreeError>;

    // Provided method
    fn depth(&self) -> usize { ... }
}
Expand description

A immutable key-value datastore implemented as a database-backed sparse merkle tree.

Required Methods§

Source

fn root(&self) -> &H::Out

Returns the root of the tree.

Source

fn value(&self, key: &[u8]) -> Result<Option<DBValue>, TreeError>

Returns the value at the provided key.

Source

fn leaf(&self, key: &[u8]) -> Result<Option<H::Out>, TreeError>

Returns the leaf at the provided key.

Source

fn proof( &self, key: &[u8], ) -> Result<(Option<DBValue>, <H as Hasher>::Out, Vec<DBValue>), TreeError>

Returns an inclusion proof of a value a the specified key.

Source

fn verify( key: &[u8], value: &[u8], proof: &[DBValue], root: &H::Out, ) -> Result<bool, TreeError>

Verifies an inclusion proof of a value at the specified key.

Provided Methods§

Source

fn depth(&self) -> usize

Returns the depth of the tree.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'db, H: Hasher, const D: usize> KeyedTree<H, D> for TreeDB<'db, D, H>