Storage

Trait Storage 

Source
pub trait Storage: Send + Sync {
    // Required methods
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        database_id: DatabaseId,
        key: &'life1 Key,
    ) -> Pin<Box<dyn Future<Output = KVResult<Option<Entry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set<'life0, 'async_trait>(
        &'life0 self,
        database_id: DatabaseId,
        key: Key,
        entry: Entry,
    ) -> Pin<Box<dyn Future<Output = KVResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        database_id: DatabaseId,
        key: &'life1 Key,
    ) -> Pin<Box<dyn Future<Output = KVResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        database_id: DatabaseId,
        key: &'life1 Key,
    ) -> Pin<Box<dyn Future<Output = KVResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn keys<'life0, 'async_trait>(
        &'life0 self,
        database_id: DatabaseId,
    ) -> Pin<Box<dyn Future<Output = KVResult<Vec<Key>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn keys_pattern<'life0, 'life1, 'async_trait>(
        &'life0 self,
        database_id: DatabaseId,
        pattern: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = KVResult<Vec<Key>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear_database<'life0, 'async_trait>(
        &'life0 self,
        database_id: DatabaseId,
    ) -> Pin<Box<dyn Future<Output = KVResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_stats<'life0, 'async_trait>(
        &'life0 self,
        database_id: DatabaseId,
    ) -> Pin<Box<dyn Future<Output = KVResult<StorageStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn flush<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = KVResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = KVResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for storage backends

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, database_id: DatabaseId, key: &'life1 Key, ) -> Pin<Box<dyn Future<Output = KVResult<Option<Entry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an entry by key

Source

fn set<'life0, 'async_trait>( &'life0 self, database_id: DatabaseId, key: Key, entry: Entry, ) -> Pin<Box<dyn Future<Output = KVResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set an entry

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, database_id: DatabaseId, key: &'life1 Key, ) -> Pin<Box<dyn Future<Output = KVResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete an entry

Source

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, database_id: DatabaseId, key: &'life1 Key, ) -> Pin<Box<dyn Future<Output = KVResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a key exists

Source

fn keys<'life0, 'async_trait>( &'life0 self, database_id: DatabaseId, ) -> Pin<Box<dyn Future<Output = KVResult<Vec<Key>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all keys in a database

Source

fn keys_pattern<'life0, 'life1, 'async_trait>( &'life0 self, database_id: DatabaseId, pattern: &'life1 str, ) -> Pin<Box<dyn Future<Output = KVResult<Vec<Key>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get keys matching a pattern

Source

fn clear_database<'life0, 'async_trait>( &'life0 self, database_id: DatabaseId, ) -> Pin<Box<dyn Future<Output = KVResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear all data in a database

Source

fn get_stats<'life0, 'async_trait>( &'life0 self, database_id: DatabaseId, ) -> Pin<Box<dyn Future<Output = KVResult<StorageStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get database statistics

Source

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

Flush all pending writes

Source

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

Close the storage backend

Implementors§