pub struct AppState {
pub db: Arc<Mutex<Connection>>,
pub config: Arc<SimConfig>,
}Expand description
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.
Fields§
§db: Arc<Mutex<Connection>>Single global SQLite connection. Lock scope is always synchronous
(never across .await) so the mutex never stalls the tokio runtime.
config: Arc<SimConfig>Runtime configuration, shared read-only.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AppState
impl !RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
impl !UnwindSafe for AppState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more