//! The state shared by every route. Topcoat hands it to each handler through the app context. use std::sync::Arc; use iz_core::config::Config; use iz_core::store::Store; use crate::backup::BackupTrigger; use crate::family::FamilyCache; use crate::in_store::InStore; use crate::live::LiveHub; use crate::oidc::OidcClient; /// Everything a request handler reaches through the app context. Every field is cheap to clone. #[allow(dead_code)] // The hub is read by the live pages that come next. #[derive(Clone)] pub struct AppState { /// The configuration the process booted with. pub config: Arc, /// The database. Reads go to a pooled reader and writes to the single writer. pub store: Store, /// The instance key (`iz.key`). Never used directly: sealing and the manifest MAC each derive a subkey. pub key: Arc<[u8; 32]>, /// The change counters of the live pages. pub live: Arc, /// The `im` client. `None` when no `[oidc]` section is configured, so sign-in is off. pub oidc: Option>, /// The family service list that the topbar switcher shows. Filled by the `family` worker. pub family: Arc, /// The Files service (`in`). `None` unless `[in_store]` is enabled with a URL and sign-in gives the token. pub in_store: Option>, /// Held around every step that changes where attachment bytes are: a row's claim, flip or removal, a /// local copy's removal, and a Files copy's deletion. The mover and the deleter take it, so a stale record /// can never remove the live copy (see `attachments.rs`). pub blob_lock: Arc>, /// Asks the backup worker for a run now (the settings page). Shared with the worker. pub backup: Arc, }