Skip to main content

State

Trait State 

Source
pub trait State: Send + Sync {
    // Required methods
    fn append<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        item: Value,
        max_len: Option<usize>,
        ttl: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: Value,
        ttl: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = ()> + 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 = Option<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Branch-scoped durable key/value state with TTL.

Required Methods§

Source

fn append<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, item: Value, max_len: Option<usize>, ttl: Option<Duration>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Append item to the list at key, keeping at most max_len entries (oldest dropped first). Creates the list if absent. ttl bounds the key’s lifetime.

Source

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

Set key to value (overwrite), with optional ttl.

Source

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

Read key, or None if absent/expired.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§