Trait fuel_storage::MerkleStorage [−][src]
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>(
&'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<MerkleRoot, 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
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.