TypedStore

Trait TypedStore 

Source
pub trait TypedStore: Send + Sync {
    // Required methods
    fn put_item<'life0, 'life1, 'life2, 'async_trait, T>(
        &'life0 self,
        key: &'life1 str,
        item: &'life2 T,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where T: 'async_trait + Serialize + Send + Sync,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_item<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Option<T>>> + Send + 'async_trait>>
       where T: 'async_trait + DeserializeOwned + Send + Sync,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_item<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_keys_with_prefix<'life0, 'life1, 'async_trait>(
        &'life0 self,
        prefix: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn scan_items_with_prefix<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        prefix: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<(String, T)>>> + Send + 'async_trait>>
       where T: 'async_trait + DeserializeOwned + Send + Sync,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn batch_put_items<'life0, 'async_trait, T>(
        &'life0 self,
        items: Vec<(String, T)>,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where T: 'async_trait + Serialize + Send + Sync,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn exists_item<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

High-level typed storage operations

This provides a convenient API on top of KvStore for storing/retrieving typed Rust structs (serialized as JSON or bincode)

Required Methods§

Source

fn put_item<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, key: &'life1 str, item: &'life2 T, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store a typed item

Source

fn get_item<'life0, 'life1, 'async_trait, T>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Option<T>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a typed item

Source

fn delete_item<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete an item

Source

fn list_keys_with_prefix<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all keys with a given prefix

Source

fn scan_items_with_prefix<'life0, 'life1, 'async_trait, T>( &'life0 self, prefix: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<(String, T)>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all items with a given prefix

Source

fn batch_put_items<'life0, 'async_trait, T>( &'life0 self, items: Vec<(String, T)>, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait,

Batch store items

Source

fn exists_item<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if key exists

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: KvStore + ?Sized + 'static> TypedStore for TypedKvStore<S>