use sqlx::SqlitePool; use oauth2::basic::BasicClient; use axum::extract::FromRef; // App state. Pretty basic stuff. Gets passed around by the server to the handlers and whatnot // Use in a handler with the state enum: // async fn handler(State(my_app_state): State) #[derive(Clone)] pub struct AppState { pub db: SqlitePool, pub oauth_client: BasicClient, } // Axum extractors for app state. These allow the handler to just use // pieces of the App state // async fn handler(State(my_db): State) impl FromRef for SqlitePool { fn from_ref(input: &AppState) -> Self { input.db.clone() } } impl FromRef for BasicClient { fn from_ref(input: &AppState) -> Self { input.oauth_client.clone() } }