Trait fuel_storage::Storage
source · [−]pub trait Storage<K, V> where
V: Clone, {
type Error;
fn insert(&mut self, key: &K, value: &V) -> Result<Option<V>, Self::Error>;
fn remove(&mut self, key: &K) -> Result<Option<V>, Self::Error>;
fn get<'a>(&'a self, key: &K) -> Result<Option<Cow<'a, V>>, Self::Error>;
fn contains_key(&self, key: &K) -> Result<bool, Self::Error>;
}
Expand description
Base map trait for Fuel infrastructure
Generics:
- K: Key that maps to a value
- V: Stored value
Required Associated Types
Required Methods
Append 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 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 K->V
.