pub trait KeyValueStore: Clone + KeyValueSendSync {
    // Required methods
    fn set_key<'life0, 'async_trait, K, V>(
        &'life0 mut self,
        key: K,
        value: V
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
             V: Serialize + KeyValueStoreSend + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn get_key<'life0, 'async_trait, K, V>(
        &'life0 self,
        key: K
    ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>
       where K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
             V: DeserializeOwned + KeyValueStoreSend + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn unset_key<'life0, 'async_trait, K>(
        &'life0 mut self,
        key: K
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn require_key<'life0, 'async_trait, K, V>(
        &'life0 self,
        key: K
    ) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>>
       where K: AsRef<[u8]> + KeyValueStoreSend + Display + 'async_trait,
             V: DeserializeOwned + KeyValueStoreSend + 'async_trait,
             Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
    fn flush<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A KeyValueStore is a construct that is suitable for persisting generic key/value data to a storage backend.

Required Methods§

source

fn set_key<'life0, 'async_trait, K, V>( &'life0 mut self, key: K, value: V ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait, V: Serialize + KeyValueStoreSend + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Given some key that can be realized as bytes, persist a serializable value to storage so that it can later be retrieved by that key

source

fn get_key<'life0, 'async_trait, K, V>( &'life0 self, key: K ) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>where K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait, V: DeserializeOwned + KeyValueStoreSend + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Given some key that can be realized as bytes, retrieve some data that can be deserialized as the intended data structure

source

fn unset_key<'life0, 'async_trait, K>( &'life0 mut self, key: K ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Given some key that can be realized as bytes, unset the value stored against that key (if any)

Provided Methods§

source

fn require_key<'life0, 'async_trait, K, V>( &'life0 self, key: K ) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>>where K: AsRef<[u8]> + KeyValueStoreSend + Display + 'async_trait, V: DeserializeOwned + KeyValueStoreSend + 'async_trait, Self: Sync + 'async_trait, 'life0: 'async_trait,

Same as get_key, but returns an error if no value is found to be stored against the key

source

fn flush<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: Sync + 'async_trait, 'life0: 'async_trait,

Flushes pending writes if there are any

Implementors§

source§

impl<S> KeyValueStore for SphereDb<S>where S: Storage,

source§

impl<S> KeyValueStore for Swhere S: Store,