1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Shared application state for the simulator's axum handlers.
//!
//! Holds the single `SQLite` [`rusqlite::Connection`] behind a
//! [`parking_lot::Mutex`] (the whole connection is the critical section — we
//! never hold the lock across `.await`), plus an [`Arc<SimConfig>`] so every
//! request can see the bind address / rate-limit settings without a global.
use Arc;
use Mutex;
use Connection;
use crateSimConfig;
/// Application state shared with every axum handler and middleware.
///
/// Cloning an [`AppState`] is cheap: it is two `Arc` bumps. Handlers receive
/// it via `axum::extract::State(AppState)` thanks to `Router::with_state`.