pub trait SessionDataStore: Send + Sync {
// Required methods
fn set<'life0, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: String,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), SessionDataError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, SessionDataError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), SessionDataError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Pluggable backend for per-session temporary key-value data.
Implementations store ephemeral data associated with a session id. The trait is async so backends like Redis can perform non-blocking I/O.
§Built-in implementations
MemorySessionDataStore— in-processHashMap(default)FileSessionDataStore— JSON files on disk (no external deps)RedisSessionDataStore— Redis hashes (feature =redis)
Required Methods§
Sourcefn set<'life0, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: String,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), SessionDataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set<'life0, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: String,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), SessionDataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stores a value under (session_id, key), overwriting any existing value.
§Errors
Returns SessionDataError::Storage on backend failure.
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, SessionDataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, SessionDataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves the value stored under (session_id, key).
Returns Ok(None) when the key does not exist.
§Errors
Returns SessionDataError::Storage on backend failure.
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), SessionDataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: Uuid,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), SessionDataError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes the value stored under (session_id, key).
Deleting a non-existent key is a no-op (no error).
§Errors
Returns SessionDataError::Storage on backend failure.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".