async_session/session_store.rs
1use crate::{async_trait, Result, Session};
2
3/// An async session backend.
4#[async_trait]
5pub trait SessionStore: std::fmt::Debug + Send + Sync + Clone + 'static {
6 /// Get a session from the storage backend.
7 ///
8 /// The input is expected to be the value of an identifying
9 /// cookie. This will then be parsed by the session middleware
10 /// into a session if possible
11 async fn load_session(&self, cookie_value: String) -> Result<Option<Session>>;
12
13 /// Store a session on the storage backend.
14 ///
15 /// The return value is the value of the cookie to store for the
16 /// user that represents this session
17 async fn store_session(&self, session: Session) -> Result<Option<String>>;
18
19 /// Remove a session from the session store
20 async fn destroy_session(&self, session: Session) -> Result;
21
22 /// Empties the entire store, destroying all sessions
23 async fn clear_store(&self) -> Result;
24}