Trait StateStore

Source
pub trait StateStore: Send + Sync {
    // Required methods
    fn set<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Value>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_keys<'life0, 'life1, 'async_trait>(
        &'life0 self,
        prefix: Option<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_many<'life0, 'life1, 'async_trait>(
        &'life0 self,
        keys: &'life1 [String],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Value>>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set_many<'life0, 'life1, 'async_trait>(
        &'life0 self,
        items: &'life1 [(String, Value)],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear<'life0, 'life1, 'async_trait>(
        &'life0 self,
        prefix: Option<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Transport-agnostic storage trait for state persistence

Required Methods§

Source

fn set<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, value: Value, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a value with a key

Source

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

Get a value by key

Source

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

Delete a value by key

Source

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

List all keys with optional prefix

Source

fn get_many<'life0, 'life1, 'async_trait>( &'life0 self, keys: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Value>>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Batch get multiple values

Source

fn set_many<'life0, 'life1, 'async_trait>( &'life0 self, items: &'life1 [(String, Value)], ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Batch set multiple values

Source

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

Clear all data with optional prefix

Implementors§