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 Self: 'async_trait,
'life0: 'async_trait,
'life1: '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 Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Pluggable session-state backend. Implementations must be Send + Sync
— the same store is shared across all concurrent requests.
Invariants:
append_labelsis monotonic — labels added to a session never come back out. Removal (declassification) is a separate operation not covered by v0.load_labelsfor an unknownsession_idreturnsOk(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
Resultso a distributed backend can propagate failures and the caller can fail the request closed. The in-processMemorySessionStoreis infallible and always returnsOk.
Required Methods§
Sourcefn 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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
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
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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.
Sourcefn 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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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".