axum_session_manager/
manager.rs1use async_trait::async_trait;
2use std::fmt::Debug;
3
4#[derive(Debug, Clone)]
7pub enum UserState<T> {
8 HaveSession(T),
9 NoSession,
10 NoCookie,
11}
12
13#[derive(Debug, Clone)]
16pub struct UserData<T: Clone>(pub UserState<T>);
17
18#[async_trait]
21pub trait SessionManage<T>: Debug + Clone {
22 type SessionID: Clone + Send;
23 type UserInfo: Clone + Send;
24 type Error;
25
26 async fn add_session(&self, session_data: T) -> Result<Self::SessionID, Self::Error>;
27 async fn verify_session(&self, session_id: &str)
28 -> Result<Option<Self::UserInfo>, Self::Error>;
29 async fn delete_session(&self, session_id: &str) -> Result<(), Self::Error>;
30}