pub struct PressureEngine { /* private fields */ }Expand description
Derives the Pressure Radar from a stream of snapshots (§2.3).
Stateful on purpose: hysteresis is memory, and §11.3 requires it. The state is bounded — one fixed-length observation window per signal — so a twelve-hour run occupies exactly as much as the first minute (§16.1).
Implementations§
Source§impl PressureEngine
impl PressureEngine
Sourcepub fn new(thresholds: Thresholds) -> Self
pub fn new(thresholds: Thresholds) -> Self
Builds an engine from configuration, sanitizing it first.
Sourcepub const fn thresholds(&self) -> &Thresholds
pub const fn thresholds(&self) -> &Thresholds
The sanitized thresholds in effect.
Sourcepub fn set_thresholds(&mut self, thresholds: Thresholds)
pub fn set_thresholds(&mut self, thresholds: Thresholds)
Replaces the thresholds, discarding hysteresis state.
§12 makes configuration reload atomic. The observations already collected were judged against the old thresholds, so keeping them would let a reload produce a state that neither configuration justifies; a reset is the honest answer and costs one warm-up period.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Discards every signal’s hysteresis state (§11.3).
The runtime calls this after anything that breaks the continuity of the
measurement stream and that the engine cannot see for itself — a collector
restart, for instance. Sleep/wake gaps are detected automatically by
Self::observe.
Sourcepub const fn observations(&self) -> u64
pub const fn observations(&self) -> u64
How many snapshots have been folded into the current state.
Sourcepub const fn discontinuities(&self) -> u64
pub const fn discontinuities(&self) -> u64
How many measurement discontinuities have been absorbed (§11.3).
Surfaced on the Inspect screen so a user who closed their laptop can see why the radar went back to warming up (§7.5).
Sourcepub fn observe(&mut self, snapshot: &SystemSnapshot) -> PressureSnapshot
pub fn observe(&mut self, snapshot: &SystemSnapshot) -> PressureSnapshot
Folds one snapshot in and returns the radar the UI should render.
The returned snapshot’s psi is the one from snapshot: raw PSI is the
collector’s measurement and is passed through unchanged.
Trait Implementations§
Source§impl Clone for PressureEngine
impl Clone for PressureEngine
Source§fn clone(&self) -> PressureEngine
fn clone(&self) -> PressureEngine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more