1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
pub mod database; use sqlx::PgPool; use crate::{config::Config}; pub struct AppState { database: PgPool, } impl AppState { pub async fn new(config: &Config) -> anyhow::Result<Self> { let database = database::connect(&config.database).await?; Ok(Self{database}) } }