feat: init
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
use std::future::Future;
|
||||
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
use super::SessionKey;
|
||||
use crate::error::AppError;
|
||||
|
||||
pub type SessionState = Map<String, Value>;
|
||||
|
||||
pub trait SessionStore {
|
||||
fn load(
|
||||
&self,
|
||||
session_key: &SessionKey,
|
||||
) -> impl Future<Output = Result<Option<SessionState>, AppError>>;
|
||||
|
||||
fn save(
|
||||
&self,
|
||||
session_state: SessionState,
|
||||
ttl_secs: u64,
|
||||
) -> impl Future<Output = Result<SessionKey, AppError>>;
|
||||
|
||||
fn update(
|
||||
&self,
|
||||
session_key: SessionKey,
|
||||
session_state: SessionState,
|
||||
ttl_secs: u64,
|
||||
) -> impl Future<Output = Result<SessionKey, AppError>>;
|
||||
|
||||
fn update_ttl(
|
||||
&self,
|
||||
session_key: &SessionKey,
|
||||
ttl_secs: u64,
|
||||
) -> impl Future<Output = Result<(), AppError>>;
|
||||
|
||||
fn delete(&self, session_key: &SessionKey) -> impl Future<Output = Result<(), AppError>>;
|
||||
}
|
||||
Reference in New Issue
Block a user