Skip to main content

SessionStore

Trait SessionStore 

Source
pub trait SessionStore: Send + Sync {
    // Required methods
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 SessionId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<SessionState>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn save<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        id: &'life1 SessionId,
        state: &'life2 SessionState,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn save_if_version<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        id: &'life1 SessionId,
        state: &'life2 SessionState,
        expected_version: u64,
    ) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Port for session state persistence.

Required Methods§

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionState>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load a session by ID. Returns None if not found.

Source

fn save<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 SessionId, state: &'life2 SessionState, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Persist a session by ID. Increments the version unconditionally.

Provided Methods§

Source

fn save_if_version<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 SessionId, state: &'life2 SessionState, expected_version: u64, ) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Persist a session only if the current version matches expected_version.

On success the store increments the version. On version mismatch the store returns StoreError::VersionConflict with the actual version found, allowing the caller to reload and retry.

Implementors§