merkle_log

Trait Store

Source
pub trait Store<N: Node> {
    // Required methods
    fn get_node(&self, id: &TreeID) -> Result<N, Error>;
    fn set_node(&mut self, id: TreeID, node: N) -> Result<(), Error>;
    fn get_leaf(&self, id: &TreeID) -> Result<N, Error>;
    fn set_leaf(&mut self, id: TreeID, leaf: N) -> Result<(), Error>;

    // Provided methods
    fn get(&self, id: &TreeID) -> Result<N, Error> { ... }
    fn set(&mut self, id: TreeID, node: N) -> Result<(), Error> { ... }
    fn get_many<'a, I: Iterator<Item = TreeID>>(
        &self,
        ids: I,
    ) -> Result<BTreeMap<TreeID, N>, Error> { ... }
    fn set_many<I: Iterator<Item = (TreeID, N)>>(
        &mut self,
        nodes: I,
    ) -> Result<(), Error> { ... }
}
Expand description

Represents access to immutable merkle tree nodes.

Required Methods§

Source

fn get_node(&self, id: &TreeID) -> Result<N, Error>

Gets an intermediate Node by its TreeID.

Source

fn set_node(&mut self, id: TreeID, node: N) -> Result<(), Error>

Stores an intermediate Node by its TreeID.

Source

fn get_leaf(&self, id: &TreeID) -> Result<N, Error>

Gets a leaf Node by its TreeID.

Source

fn set_leaf(&mut self, id: TreeID, leaf: N) -> Result<(), Error>

Stores a leaf Node by its TreeID.

Provided Methods§

Source

fn get(&self, id: &TreeID) -> Result<N, Error>

Gets a Node by its TreeID.

Source

fn set(&mut self, id: TreeID, node: N) -> Result<(), Error>

Stores a Node by its TreeID.

Source

fn get_many<'a, I: Iterator<Item = TreeID>>( &self, ids: I, ) -> Result<BTreeMap<TreeID, N>, Error>

Gets many Nodes from an Iterator of TreeIDs.

Source

fn set_many<I: Iterator<Item = (TreeID, N)>>( &mut self, nodes: I, ) -> Result<(), Error>

Sets many Nodes from an Iterator of TreeIDs and Nodes.

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.

Implementations on Foreign Types§

Source§

impl<N: Node> Store<N> for BTreeMap<TreeID, N>

Source§

fn get_node(&self, id: &TreeID) -> Result<N, Error>

Delegates to BTreeMap::get.

Source§

fn set_node(&mut self, id: TreeID, node: N) -> Result<(), Error>

Delegates to BTreeMap::insert.

Source§

fn get_leaf(&self, id: &TreeID) -> Result<N, Error>

Delegates to BTreeMap::get.

Source§

fn set_leaf(&mut self, id: TreeID, leaf: N) -> Result<(), Error>

Delegates to BTreeMap::insert.

Implementors§