super-voice-daemon/src/tts/daemon/http/state.rs
Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-3.0-only |
2 | | use crate::tts::daemon::types::SuperTTSDaemon; |
3 | | use axum::extract::FromRef; |
4 | | use std::sync::Arc; |
5 | | use super_engine_daemon::auth::Auth; |
6 | | |
7 | | /// What text to speech's handlers are handed: the feature, and the daemon's one |
8 | | /// [`Auth`], which the guards check requests against. |
9 | | #[derive(Clone)] |
10 | | pub(crate) struct AppState { |
11 | | pub(crate) daemon: Arc<SuperTTSDaemon>, |
12 | | pub(crate) auth: Auth, |
13 | | } |
14 | | |
15 | | impl AppState { |
16 | 200 | pub(crate) fn new(daemon: Arc<SuperTTSDaemon>, auth: Auth) -> Self { |
17 | 200 | Self { daemon, auth } |
18 | 200 | } |
19 | | } |
20 | | |
21 | | /// Lets the guards extract the [`Auth`] alone. |
22 | | impl FromRef<AppState> for Auth { |
23 | 0 | fn from_ref(state: &AppState) -> Self { |
24 | 0 | state.auth.clone() |
25 | 0 | } |
26 | | } |