Skip to main content

SessionDataStore

Trait SessionDataStore 

Source
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

Required Methods§

Source

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.

Source

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.

Source

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".

Implementors§