pub mod memory; pub mod redis; use async_trait::async_trait; use thiserror::Error; #[derive(Error, Debug)] pub enum SessionError { #[error("Redis error: {0}")] Redis(String), #[error("Session not found: {0}")] NotFound(String), #[error("Serialization error: {0}")] Serialization(String), #[error("Session expired: {0}")] Expired(String), } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct SessionInfo { pub sid: String, pub transport: String, pub state: String, pub server_id: String, pub created_at: u64, pub last_ping: u64, } #[async_trait] pub trait SessionStoreTrait: Send + Sync + 'static { async fn create(&self, sid: &str, transport: &str, server_id: &str) -> Result<(), SessionError>; async fn get(&self, sid: &str) -> Result, SessionError>; async fn set_state(&self, sid: &str, state: &str) -> Result<(), SessionError>; async fn set_transport(&self, sid: &str, transport: &str) -> Result<(), SessionError>; async fn update_ping(&self, sid: &str) -> Result<(), SessionError>; async fn remove(&self, sid: &str) -> Result<(), SessionError>; async fn exists(&self, sid: &str) -> Result; } pub use memory::InMemorySessionStore; pub use redis::RedisSessionStore;