TreeDB

Struct TreeDB 

Source
pub struct TreeDB<'db, const D: usize, H: Hasher> { /* private fields */ }
Expand description

An immutable merkle tree db that uses a byte slice key to specify the leaves in the tree.

Implementations§

Source§

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

Source

pub fn db(&self) -> &dyn HashDBRef<H, DBValue>

Return the underlying db of a TreeDB

Trait Implementations§

Source§

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

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 associated with the given key

Source§

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

Returns the leaf associated with the given key

Source§

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

Returns an inclusion proof of a value a the specified key. Returns a tuple of form: (value, root, proof)

Source§

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

Verifies that the given value is in the tree with the given root at the given index

Source§

fn depth(&self) -> usize

Returns the depth of the tree.

Auto Trait Implementations§

§

impl<'db, const D: usize, H> !Freeze for TreeDB<'db, D, H>

§

impl<'db, const D: usize, H> !RefUnwindSafe for TreeDB<'db, D, H>

§

impl<'db, const D: usize, H> !Send for TreeDB<'db, D, H>

§

impl<'db, const D: usize, H> !Sync for TreeDB<'db, D, H>

§

impl<'db, const D: usize, H> Unpin for TreeDB<'db, D, H>
where <H as Hasher>::Out: Unpin,

§

impl<'db, const D: usize, H> !UnwindSafe for TreeDB<'db, D, H>

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> 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, 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.