pub struct State {
pub intent: SupervisorState,
pub last_updated: DateTime<Utc>,
pub recent_actions: Vec<ActionRecord>,
}Expand description
Persistent state shape. Kept intentionally small so the
file is human-grippable under cat. Additions that don’t
alter the supervisor’s recovery behaviour should stay out
of this struct and into a sibling file.
Fields§
§intent: SupervisorStateOperator-intent: should the supervisor consider itself “armed” on boot.
last_updated: DateTime<Utc>Monotonically-updated bookkeeping timestamps.
recent_actions: Vec<ActionRecord>Ring buffer of the most recent decisions, newest first.
Capped at MAX_RECENT_ACTIONS on every write.
Implementations§
Source§impl State
impl State
Sourcepub fn load(path: &Path) -> Result<Self, PersistError>
pub fn load(path: &Path) -> Result<Self, PersistError>
Load from disk, or return Default if the file does not
exist yet. An unparseable file is an error, not a
silent reset — the daemon refuses to run rather than
forget the operator’s intent.
Sourcepub fn save(&self, path: &Path) -> Result<(), PersistError>
pub fn save(&self, path: &Path) -> Result<(), PersistError>
Persist atomically. Creates parent directories if missing; the daemon’s lifecycle doesn’t include a separate “install” step that would create them.
Sourcepub fn push_action(&mut self, kind: ActionKind, note: impl Into<String>)
pub fn push_action(&mut self, kind: ActionKind, note: impl Into<String>)
Record an action, pushing it to the front of
recent_actions and trimming to cap. note must be
non-empty — the protocol forbids empty reasons and we
enforce it at the persistence boundary too.
Sourcepub fn set_intent(&mut self, intent: SupervisorState)
pub fn set_intent(&mut self, intent: SupervisorState)
Flip the intent flag and bump last_updated. Does not
push an action — the caller decides whether that edge
deserves a record (e.g. Stop during boot might not).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for State
impl<'de> Deserialize<'de> for State
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for State
impl StructuralPartialEq for State
Auto Trait Implementations§
impl Forget for State
impl Freeze for State
impl Move for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnsafeUnpin for State
impl UnwindSafe for State
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.