StateStore

Trait StateStore 

Source
pub trait StateStore: Send + Sync {
    // Required methods
    fn upsert_latest<'life0, 'async_trait>(
        &'life0 self,
        snapshot: StateSnapshot,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_latest<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<StateSnapshot>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn get_history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StateSnapshot>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Trait for storing and retrieving user state snapshots.

Implementations must be thread-safe (Send + Sync) and support async operations.

Required Methods§

Source

fn upsert_latest<'life0, 'async_trait>( &'life0 self, snapshot: StateSnapshot, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert or update the latest state snapshot for a user.

If a snapshot already exists for the user, it is replaced. The snapshot is validated before storage.

Source

fn get_latest<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<StateSnapshot>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the latest state snapshot for a user.

Returns None if no state exists for the user.

Provided Methods§

Source

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

Delete the state for a user.

This removes all state data for the user (GDPR compliance). Returns Ok(()) even if the user did not exist.

Source

fn get_history<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<StateSnapshot>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get historical snapshots for a user.

Returns up to limit snapshots, ordered by most recent first. Default implementation returns empty vec (history not supported).

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the store is healthy and can accept requests.

Default implementation always returns true.

Implementors§