Skip to main content

SessionStore

Trait SessionStore 

Source
pub trait SessionStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn load<'a>(
        &'a self,
        id: &'a str,
        ttl_secs: u64,
    ) -> Pin<Box<dyn Future<Output = Option<Arc<Session>>> + Send + 'a>>;
    fn save<'a>(
        &'a self,
        session: &'a Session,
        ttl_secs: u64,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>;
    fn delete<'a>(
        &'a self,
        id: &'a str,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>;
    fn new_id(&self) -> String;
}
Expand description

Backend store for sessions. Implement this to plug in Redis, Postgres, etc.

Required Methods§

Source

fn load<'a>( &'a self, id: &'a str, ttl_secs: u64, ) -> Pin<Box<dyn Future<Output = Option<Arc<Session>>> + Send + 'a>>

Load a session by ID. ttl_secs is the manager’s configured lifetime and should be used to stamp the returned Session::expires_at so the in-memory expiry matches the store’s TTL configuration.

Source

fn save<'a>( &'a self, session: &'a Session, ttl_secs: u64, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>

Source

fn delete<'a>( &'a self, id: &'a str, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>

Source

fn new_id(&self) -> String

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§