Skip to main content

ManagedStateStore

Trait ManagedStateStore 

Source
pub trait ManagedStateStore:
    Send
    + Sync
    + Debug {
    // Required methods
    fn durability(&self) -> Durability;
    fn save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 str,
        state: ManagedSessionState,
    ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ManagedSessionState>, RuntimeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn session_ids<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, RuntimeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Storage for managed session state.

Implementations decide the durability guarantee and must report it truthfully through ManagedStateStore::durability, because that is what a caller uses to decide whether resume-after-restart is available.

Required Methods§

Source

fn durability(&self) -> Durability

What this store guarantees after process loss.

Source

fn save<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, state: ManagedSessionState, ) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Records the state of session_id, replacing any previous snapshot.

§Errors

Returns RuntimeError when the backing store rejects the write. A durable implementation must not acknowledge before the write is persisted, since the whole point of the guarantee is that an acknowledged checkpoint is recoverable.

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ManagedSessionState>, RuntimeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The recorded state for session_id, or None when nothing is stored.

§Errors

Returns RuntimeError when the backing store cannot be read.

Source

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

Removes any state for session_id.

Succeeds when nothing was stored, so deletion is idempotent.

§Errors

Returns RuntimeError when the backing store cannot complete the removal.

Source

fn session_ids<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, RuntimeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The sessions this store holds state for.

A durable implementation uses this at startup to reconstruct sessions; a process-local one only ever reports sessions from the current process.

§Errors

Returns RuntimeError when the backing store cannot be enumerated.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§