use super::OAuthSession;
use crate::auth::oauth::types::OAuthState;
use async_trait::async_trait;
#[async_trait]
pub trait SessionStore: Send + Sync {
async fn set(&self, session: OAuthSession) -> Result<(), SessionError>;
async fn get(&self, session_id: &str) -> Result<Option<OAuthSession>, SessionError>;
async fn delete(&self, session_id: &str) -> Result<(), SessionError>;
async fn update(&self, session: OAuthSession) -> Result<(), SessionError>;
async fn set_state(&self, state: OAuthState) -> Result<(), SessionError>;
async fn get_and_delete_state(
&self,
state_id: &str,
) -> Result<Option<OAuthState>, SessionError>;
async fn get_user_sessions(&self, user_email: &str) -> Result<Vec<OAuthSession>, SessionError>;
async fn delete_user_sessions(&self, user_email: &str) -> Result<usize, SessionError>;
async fn cleanup_expired(&self) -> Result<usize, SessionError>;
}
#[derive(Debug, thiserror::Error)]
pub enum SessionError {
#[error("Session not found")]
NotFound,
#[error("Session expired")]
Expired,
#[error("Storage error: {0}")]
Storage(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Connection error: {0}")]
Connection(String),
}