1#![warn(clippy::all)]
2#![doc = include_str!("../README.md")]
3#[macro_use]
4extern crate async_trait;
5
6use std::fmt::{Debug, Display};
7use std::time::Duration;
8
9#[cfg(feature = "redis")]
10mod redis;
11
12#[cfg(feature = "in-memory")]
13pub mod in_memory;
14
15#[async_trait]
24pub trait SessionManager {
25 type Error: Debug + Display;
26 async fn set(&self, id: &str, key: &str, val: &str, time: Duration) -> Result<(), Self::Error>;
27 async fn get(&self, id: &str, key: &str) -> Result<Option<String>, Self::Error>;
28 async fn delete(&self, id: &str, key: &str) -> Result<(), Self::Error>;
29 async fn expire_in(&self, id: &str, key: &str, time: Duration) -> Result<(), Self::Error>;
30 async fn clear_all(&self) -> Result<(), Self::Error>;
31}