Skip to main content

tuitbot_server/
state.rs

1//! Shared application state for the tuitbot server.
2
3use std::path::PathBuf;
4
5use tokio::sync::{broadcast, Mutex};
6use tuitbot_core::automation::Runtime;
7use tuitbot_core::storage::DbPool;
8
9use crate::ws::WsEvent;
10
11/// Shared application state accessible by all route handlers.
12pub struct AppState {
13    /// SQLite connection pool.
14    pub db: DbPool,
15    /// Path to the configuration file.
16    pub config_path: PathBuf,
17    /// Broadcast channel sender for real-time WebSocket events.
18    pub event_tx: broadcast::Sender<WsEvent>,
19    /// Local bearer token for API authentication.
20    pub api_token: String,
21    /// Optional automation runtime handle for start/stop control.
22    pub runtime: Mutex<Option<Runtime>>,
23}