2023-06-03 23:03:58 +00:00
|
|
|
use tokio::sync::watch::Receiver;
|
|
|
|
|
2023-06-02 04:07:42 +00:00
|
|
|
use axum::extract::FromRef;
|
2023-06-03 23:03:58 +00:00
|
|
|
use bytes::Bytes;
|
2023-06-02 04:07:42 +00:00
|
|
|
use sqlx::PgPool;
|
|
|
|
|
|
|
|
use crate::config::Config;
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct AppState {
|
|
|
|
pub pool: PgPool,
|
|
|
|
pub config: Config,
|
2023-06-03 23:03:58 +00:00
|
|
|
pub log_receiver: Receiver<Bytes>,
|
2023-06-02 04:07:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl FromRef<AppState> for PgPool {
|
|
|
|
fn from_ref(state: &AppState) -> Self {
|
|
|
|
state.pool.clone()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FromRef<AppState> for Config {
|
|
|
|
fn from_ref(state: &AppState) -> Self {
|
|
|
|
state.config.clone()
|
|
|
|
}
|
|
|
|
}
|
2023-06-03 23:03:58 +00:00
|
|
|
|
|
|
|
impl FromRef<AppState> for Receiver<Bytes> {
|
|
|
|
fn from_ref(state: &AppState) -> Self {
|
|
|
|
state.log_receiver.clone()
|
|
|
|
}
|
|
|
|
}
|