Updatable

Trait Updatable 

Source
pub trait Updatable: Gettable {
    // Required method
    fn update<'a>(
        &'a mut self,
        key: Self::Key,
        value: Self::Value,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send + use<'a, Self>;

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

A mutable key-value store.

Required Methods§

Source

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

Update the value of a key.

Provided Methods§

Source

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

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

Source

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

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

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, K, V, D> Updatable for Batch<'a, K, V, D>
where K: Array, V: CodecShared + Clone, D: Gettable<Key = K, Value = V, Error = Error> + Sync,

Source§

impl<E, K, V, T> Updatable for commonware_storage::qmdb::store::db::Db<E, K, V, T, NonDurable>
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> Updatable for commonware_storage::qmdb::current::ordered::fixed::Db<E, K, V, H, T, N, Unmerkleized, NonDurable>

Source§

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

Source§

impl<E: Storage + Metrics + Clock, K: Array, V: CodecShared> Updatable for Freezer<E, K, V>

Source§

impl<E: Storage + Metrics + Clock, V: CodecFixedShared> Updatable for Ordinal<E, V>