fuel_storage

Trait StorageMutate

source
pub trait StorageMutate<Type: Mappable>: StorageInspect<Type> {
    // Required methods
    fn replace(
        &mut self,
        key: &Type::Key,
        value: &Type::Value,
    ) -> Result<Option<Type::OwnedValue>, Self::Error>;
    fn take(
        &mut self,
        key: &Type::Key,
    ) -> Result<Option<Type::OwnedValue>, Self::Error>;

    // Provided methods
    fn insert(
        &mut self,
        key: &Type::Key,
        value: &Type::Value,
    ) -> Result<(), Self::Error> { ... }
    fn remove(&mut self, key: &Type::Key) -> Result<(), Self::Error> { ... }
}
Expand description

Base storage trait for Fuel infrastructure.

Generic should implement Mappable trait with all storage type information.

Required Methods§

source

fn replace( &mut self, key: &Type::Key, value: &Type::Value, ) -> Result<Option<Type::OwnedValue>, Self::Error>

Append Key->Value mapping to the storage.

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

source

fn take( &mut self, key: &Type::Key, ) -> Result<Option<Type::OwnedValue>, Self::Error>

Remove Key->Value mapping from the storage.

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

Provided Methods§

source

fn insert( &mut self, key: &Type::Key, value: &Type::Value, ) -> Result<(), Self::Error>

Append Key->Value mapping to the storage.

source

fn remove(&mut self, key: &Type::Key) -> Result<(), Self::Error>

Remove Key->Value mapping from the storage.

Implementations on Foreign Types§

source§

impl<'a, T: StorageMutate<Type> + ?Sized, Type: Mappable> StorageMutate<Type> for &'a mut T

source§

fn insert( &mut self, key: &Type::Key, value: &Type::Value, ) -> Result<(), Self::Error>

source§

fn replace( &mut self, key: &Type::Key, value: &Type::Value, ) -> Result<Option<Type::OwnedValue>, Self::Error>

source§

fn remove(&mut self, key: &Type::Key) -> Result<(), Self::Error>

source§

fn take( &mut self, key: &Type::Key, ) -> Result<Option<Type::OwnedValue>, Self::Error>

Implementors§