pub struct MaintenanceState { /* private fields */ }Expand description
Shared maintenance state. Cloned cheaply via Arc. Mounted as Axum
router state and as middleware state.
Implementations§
Source§impl MaintenanceState
impl MaintenanceState
Sourcepub fn from_config(cfg: &MaintenanceConfig) -> Arc<Self> ⓘ
pub fn from_config(cfg: &MaintenanceConfig) -> Arc<Self> ⓘ
Build a fresh state from config. Stamps started_at = now if the
gate is enabled at boot.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Cheap atomic read of the on/off flag.
Sourcepub fn snapshot(&self) -> MaintenanceSnapshot
pub fn snapshot(&self) -> MaintenanceSnapshot
Snapshot of the current state for serialization (status endpoint and 503 body construction).
Sourcepub fn apply_update(&self, update: MaintenanceUpdate) -> MaintenanceSnapshot
pub fn apply_update(&self, update: MaintenanceUpdate) -> MaintenanceSnapshot
Apply a partial update atomically. Toggling on stamps started_at if
not already set; toggling off clears it.
All field changes are applied under a single write lock so concurrent readers cannot observe a half-updated snapshot.
Auto Trait Implementations§
impl !Freeze for MaintenanceState
impl RefUnwindSafe for MaintenanceState
impl Send for MaintenanceState
impl Sync for MaintenanceState
impl Unpin for MaintenanceState
impl UnsafeUnpin for MaintenanceState
impl UnwindSafe for MaintenanceState
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