Struct monotree::tree::Monotree

source ·
pub struct Monotree<D = DefaultDatabase, H = DefaultHasher> { /* private fields */ }
Expand description

A structure for monotree.

Implementations§

source§

impl<D, H> Monotree<D, H>where D: Database, H: Hasher,

source

pub fn new(dbpath: &str) -> Self

source

pub fn insert( &mut self, root: Option<&Hash>, key: &Hash, leaf: &Hash ) -> Result<Option<Hash>>

Insert key-leaf entry into the monotree. Returns a new root hash.

source

pub fn get(&mut self, root: Option<&Hash>, key: &Hash) -> Result<Option<Hash>>

Get a leaf hash for the given root and key.

source

pub fn remove( &mut self, root: Option<&Hash>, key: &[u8] ) -> Result<Option<Hash>>

Remove the given key and its corresponding leaf from the tree. Returns a new root hash.

source

pub fn inserts( &mut self, root: Option<&Hash>, keys: &[Hash], leaves: &[Hash] ) -> Result<Option<Hash>>

This method is intended to use the insert() method in batch mode.

source

pub fn gets( &mut self, root: Option<&Hash>, keys: &[Hash] ) -> Result<Vec<Option<Hash>>>

This method is intended to use the get() method in batch mode.

source

pub fn removes( &mut self, root: Option<&Hash>, keys: &[Hash] ) -> Result<Option<Hash>>

This method is intended to use the remove() method in batch mode.

source

pub fn get_merkle_proof( &mut self, root: Option<&Hash>, key: &[u8] ) -> Result<Option<Proof>>

Generate a Merkle proof for the given root and key.

Trait Implementations§

source§

impl<D: Debug, H: Debug> Debug for Monotree<D, H>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Monotree<DefaultDatabase, DefaultHasher>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<D, H> RefUnwindSafe for Monotree<D, H>where D: RefUnwindSafe, H: RefUnwindSafe,

§

impl<D, H> Send for Monotree<D, H>where D: Send, H: Send,

§

impl<D, H> Sync for Monotree<D, H>where D: Sync, H: Sync,

§

impl<D, H> Unpin for Monotree<D, H>where D: Unpin, H: Unpin,

§

impl<D, H> UnwindSafe for Monotree<D, H>where D: UnwindSafe, H: UnwindSafe,

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> Same<T> for T

§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V