pub trait MerkleStorage<P, K, V> where
    V: Clone
{ type Error: Error; fn insert(
        &mut self,
        parent: &P,
        key: &K,
        value: &V
    ) -> Result<Option<V>, Self::Error>;
fn remove(&mut self, parent: &P, key: &K) -> Result<Option<V>, Self::Error>;
fn get(
        &'a self,
        parent: &P,
        key: &K
    ) -> Result<Option<Cow<'a, V>>, Self::Error>;
fn contains_key(&self, parent: &P, key: &K) -> Result<bool, Self::Error>;
fn root(&mut self, parent: &P) -> Result<[u8; 32], Self::Error>; }
Expand description

Base trait for Fuel Merkle storage

Generics:

  • P: Domain of the merkle tree
  • K: Key that maps to a value
  • V: Stored value

Associated Types

Error implementation of the merkle storage functions

Required methods

Append P->K->V mapping to the storage.

If K was already mappped to a value, return the replaced value as Ok(Some(V)). Return Ok(None) otherwise.

Remove P->K->V mapping from the storage.

Return Ok(Some(V)) if the value was present. If the key wasn’t found, return Ok(None).

Retrieve Cow<V> such as P->K->V.

Return true if there is a P->K mapping to a value in the storage.

Return the merkle root of the domain of P.

The cryptographic primitive is an arbitrary choice of the implementor and this trait won’t impose any restrictions to that.

Implementations on Foreign Types

Implementors