1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/// Directional change or anomaly direction.
///
/// Used by algorithms that detect shifts, anomalies, or trends in a signal.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Direction {
/// No directional change detected.
Neutral,
/// Upward: mean shifted up, value is high, trend is rising.
Rising,
/// Downward: mean shifted down, value is low, trend is falling.
Falling,
}
/// System condition state.
///
/// Used by algorithms that monitor health, saturation, or pressure.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Condition {
/// Within acceptable bounds.
Normal,
/// Exceeded threshold — degraded performance.
Degraded,
}
/// Configuration error from building a stats primitive.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ConfigError {
/// A required parameter was not set.
Missing(&'static str),
/// A parameter value is invalid.
Invalid(&'static str),
}
impl core::fmt::Display for ConfigError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Missing(param) => write!(f, "configuration error: {param} must be set"),
Self::Invalid(msg) => write!(f, "configuration error: {msg}"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for ConfigError {}