pub trait KeyValueStorage<K, V>: Sync + Send + 'static {
    // Required methods
    fn put<'life0, 'async_trait>(
        &'life0 self,
        key: K,
        value: V
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 K
    ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 K
    ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

This trait defines a key/value storage

Required Methods§

source

fn put<'life0, 'async_trait>( &'life0 self, key: K, value: V ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Store a key / value

source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 K ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve a value. Return None if no value corresponds to the specified key

source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 K ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a value and return it if found

Implementors§

source§

impl<K: Ord + Send + Sync + 'static, V: Clone + Send + Sync + 'static> KeyValueStorage<K, V> for InMemoryKeyValueStorage<K, V>

source§

impl<K: Serialize + for<'de> Deserialize<'de> + ToStringKey + Ord + Clone + Send + Sync + 'static, V: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static> KeyValueStorage<K, V> for FileKeyValueStorage<K, V>