37 lines
889 B
Rust
37 lines
889 B
Rust
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>>;
|
|
}
|