KeyValueStore

Trait KeyValueStore 

Source
pub trait KeyValueStore: Clone + ConditionalSync {
    // 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]> + ConditionalSend + 'async_trait,
             V: Serialize + ConditionalSend + '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]> + ConditionalSend + 'async_trait,
             V: DeserializeOwned + ConditionalSend + '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]> + ConditionalSend + '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]> + ConditionalSend + Display + 'async_trait,
             V: DeserializeOwned + ConditionalSend + '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]> + ConditionalSend + 'async_trait, V: Serialize + ConditionalSend + '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]> + ConditionalSend + 'async_trait, V: DeserializeOwned + ConditionalSend + '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]> + ConditionalSend + '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]> + ConditionalSend + Display + 'async_trait, V: DeserializeOwned + ConditionalSend + '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

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<S> KeyValueStore for SphereDb<S>
where S: Storage,

Source§

impl<S> KeyValueStore for S
where S: Store,