Skip to main content

SessionStore

Trait SessionStore 

Source
pub trait SessionStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn read<'a>(&'a self, id: &'a str) -> StoreFuture<'a, Option<Session>>;
    fn write<'a>(&'a self, session: &'a Session) -> StoreFuture<'a, ()>;
    fn destroy<'a>(&'a self, id: &'a str) -> StoreFuture<'a, ()>;
    fn gc(&self) -> StoreFuture<'_, usize>;
    fn lifetime(&self) -> Duration;
}

Required Methods§

Source

fn read<'a>(&'a self, id: &'a str) -> StoreFuture<'a, Option<Session>>

Load a session, or None if it is unknown or has expired.

Source

fn write<'a>(&'a self, session: &'a Session) -> StoreFuture<'a, ()>

Persist a session under its current id.

Source

fn destroy<'a>(&'a self, id: &'a str) -> StoreFuture<'a, ()>

Remove a session. Called on logout and after an id rotation.

Source

fn gc(&self) -> StoreFuture<'_, usize>

Drop everything past its lifetime, returning how many were removed.

Expired sessions are already refused by read, so this is housekeeping rather than security: without it a busy site accumulates one dead file per visitor, forever.

Source

fn lifetime(&self) -> Duration

How long a session may sit untouched before it is considered gone.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§