//! Application state management //! //! This module contains the shared application state that is passed to all //! route handlers and provides access to database connections, configuration, //! and other shared resources. #![allow(dead_code)] // Prepared for future use use std::sync::Arc; use tokio::sync::RwLock; /// Database connection pool type /// This would typically be a real connection pool in production pub type DbPool = Arc>; /// Application state shared across all handlers #[derive(Clone)] pub struct AppState { /// Database connection pool pub conn: Arc>, /// Configuration cache pub config: Arc>>, /// Session store pub sessions: Arc>>, } /// User session information #[derive(Clone, Debug)] pub struct Session { pub user_id: String, pub username: String, pub email: String, pub created_at: chrono::DateTime, pub expires_at: chrono::DateTime, } impl AppState { /// Create a new application state pub fn new() -> Self { Self { conn: Arc::new(std::sync::Mutex::new(())), config: Arc::new(RwLock::new(std::collections::HashMap::new())), sessions: Arc::new(RwLock::new(std::collections::HashMap::new())), } } } impl Default for AppState { fn default() -> Self { Self::new() } }