StoreMut

Trait StoreMut 

Source
pub trait StoreMut: Store {
    // Required method
    fn update(
        &mut self,
        key: Self::Key,
        value: Self::Value,
    ) -> impl Future<Output = Result<(), Self::Error>>;

    // Provided methods
    fn upsert(
        &mut self,
        key: Self::Key,
        update: impl FnOnce(&mut Self::Value),
    ) -> impl Future<Output = Result<(), Self::Error>>
       where Self::Value: Default { ... }
    fn create(
        &mut self,
        key: Self::Key,
        value: Self::Value,
    ) -> impl Future<Output = Result<bool, Self::Error>> { ... }
}
Expand description

A mutable key-value store.

Required Methods§

Source

fn update( &mut self, key: Self::Key, value: Self::Value, ) -> impl Future<Output = Result<(), Self::Error>>

Update the value of a key.

Provided Methods§

Source

fn upsert( &mut self, key: Self::Key, update: impl FnOnce(&mut Self::Value), ) -> impl Future<Output = Result<(), Self::Error>>
where Self::Value: Default,

Updates the value associated with the given key in the store, inserting a default value if the key does not already exist.

Source

fn create( &mut self, key: Self::Key, value: Self::Value, ) -> impl Future<Output = Result<bool, Self::Error>>

Creates a new key-value pair in the db. Returns true if the key was created, false if it already existed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<A> StoreMut for AnyExt<A>
where A: CleanAny,

Source§

impl<E, K, V, T> StoreMut for Store<E, K, V, T>
where E: Storage + Clock + Metrics, K: Array, V: VariableValue, T: Translator,

Source§

impl<E: RStorage + Clock + Metrics, K: Array, V: FixedValue, H: Hasher, T: Translator, const N: usize> StoreMut for commonware_storage::qmdb::current::ordered::fixed::Db<E, K, V, H, T, N, Dirty>

Source§

impl<E: RStorage + Clock + Metrics, K: Array, V: FixedValue, H: Hasher, T: Translator, const N: usize> StoreMut for commonware_storage::qmdb::current::unordered::fixed::Db<E, K, V, H, T, N, Dirty>

Source§

impl<E: Storage + Metrics + Clock, K: Array, V: Codec> StoreMut for Freezer<E, K, V>

Source§

impl<E: Storage + Metrics + Clock, V: CodecFixed<Cfg = ()>> StoreMut for Ordinal<E, V>