fuel_core_storage

Trait StorageMutate

Source
pub trait StorageMutate<Type>: StorageInspect<Type>
where Type: Mappable,
{ // Required methods fn replace( &mut self, key: &<Type as Mappable>::Key, value: &<Type as Mappable>::Value, ) -> Result<Option<<Type as Mappable>::OwnedValue>, Self::Error>; fn take( &mut self, key: &<Type as Mappable>::Key, ) -> Result<Option<<Type as Mappable>::OwnedValue>, Self::Error>; // Provided methods fn insert( &mut self, key: &<Type as Mappable>::Key, value: &<Type as Mappable>::Value, ) -> Result<(), Self::Error> { ... } fn remove( &mut self, key: &<Type as Mappable>::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 as Mappable>::Key, value: &<Type as Mappable>::Value, ) -> Result<Option<<Type as Mappable>::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 as Mappable>::Key, ) -> Result<Option<<Type as Mappable>::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 as Mappable>::Key, value: &<Type as Mappable>::Value, ) -> Result<(), Self::Error>

Append Key->Value mapping to the storage.

Source

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

Remove Key->Value mapping from the storage.

Implementations on Foreign Types§

Source§

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

Source§

fn insert( &mut self, key: &<Type as Mappable>::Key, value: &<Type as Mappable>::Value, ) -> Result<(), <&'a mut T as StorageInspect<Type>>::Error>

Source§

fn replace( &mut self, key: &<Type as Mappable>::Key, value: &<Type as Mappable>::Value, ) -> Result<Option<<Type as Mappable>::OwnedValue>, <&'a mut T as StorageInspect<Type>>::Error>

Source§

fn remove( &mut self, key: &<Type as Mappable>::Key, ) -> Result<(), <&'a mut T as StorageInspect<Type>>::Error>

Source§

fn take( &mut self, key: &<Type as Mappable>::Key, ) -> Result<Option<<Type as Mappable>::OwnedValue>, <&'a mut T as StorageInspect<Type>>::Error>

Source§

impl<Type> StorageMutate<Type> for StorageMap<Type>
where Type: Mappable, <Type as Mappable>::Key: Eq + Hash, <Type as Mappable>::OwnedKey: Eq + Hash + Borrow<<Type as Mappable>::Key>,

Source§

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

Source§

fn take( &mut self, key: &<Type as Mappable>::Key, ) -> Result<Option<<Type as Mappable>::OwnedValue>, <StorageMap<Type> as StorageInspect<Type>>::Error>

Source§

impl<Type, D> StorageMutate<Type> for PredicateStorage<D>

Source§

fn replace( &mut self, _key: &<Type as Mappable>::Key, _value: &<Type as Mappable>::Value, ) -> Result<Option<<Type as Mappable>::OwnedValue>, <PredicateStorage<D> as StorageInspect<Type>>::Error>

Source§

fn take( &mut self, _key: &<Type as Mappable>::Key, ) -> Result<Option<<Type as Mappable>::OwnedValue>, <PredicateStorage<D> as StorageInspect<Type>>::Error>

Implementors§

Source§

impl<Column, S, M> StorageMutate<M> for StructuredStorage<S>
where S: KeyValueMutate<Column = Column>, M: TableWithBlueprint<Column = Column>, M::Blueprint: BlueprintMutate<M, StructuredStorage<S>>,

Source§

impl<D, M: Mappable> StorageMutate<M> for VmStorage<D>
where D: StorageMutate<M, Error = Error>,