Skip to main content

SessionStore

Trait SessionStore 

Source
pub trait SessionStore: Send + Sync {
    // Required methods
    fn load_labels<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, SessionStoreError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn append_labels<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        session_id: &'life1 str,
        labels: &'life2 [String],
    ) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
}
Expand description

Pluggable session-state backend. Implementations must be Send + Sync — the same store is shared across all concurrent requests.

Invariants:

  • append_labels is monotonic — labels added to a session never come back out. Removal (declassification) is a separate operation not covered by v0.
  • load_labels for an unknown session_id returns Ok(empty) — a positively-confirmed key-miss is the right response for non-session traffic, and is distinct from a backend failure (Err).
  • Both methods return Result so a distributed backend can propagate failures and the caller can fail the request closed. The in-process MemorySessionStore is infallible and always returns Ok.

Required Methods§

Source

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

Load the union of labels accumulated for the session. Ok(empty) for new or unknown sessions (a confirmed key-miss); Err only on a backend failure.

Source

fn append_labels<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 str, labels: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Append labels to the session. Existing labels are kept; new ones are unioned in. Caller has already deduped against load_labels in the hot path, but the store re-dedups defensively. Err only on a backend failure.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl SessionStore for ValkeySessionStore

Source§

fn load_labels<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, SessionStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ValkeySessionStore: 'async_trait,

Source§

fn append_labels<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 str, labels: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, ValkeySessionStore: 'async_trait,

Implementors§