pub(crate) mod database; use sqlx::PgPool; use tracing_subscriber::EnvFilter; use crate::{WardenError, config::Configuration}; pub type LogHandle = tracing_subscriber::reload::Handle; #[derive(Debug, Clone)] pub struct AppState { pub log_handle: LogHandle, pub database: PgPool, } impl AppState { pub async fn new(log_handle: LogHandle, config: &Configuration) -> Result { let database = database::connect(&config.database).await?; Ok(Self { log_handle, database, }) } }