pub struct SubstrateMonitor { /* private fields */ }Expand description
Substrate monitor — reads real hardware metrics from /proc and /sys.
On Linux, reads:
/proc/loadavgfor CPU load (1-minute average normalized by CPU count)/proc/meminfofor memory pressure and swap usage/sys/class/thermal/thermal_zone*/tempfor temperature/sys/class/power_supply/BAT*/capacityandstatusfor battery
On non-Linux or when files are unavailable, gracefully degrades to default values. History is stored as a ring buffer.
Implementations§
Source§impl SubstrateMonitor
impl SubstrateMonitor
Sourcepub fn new(max_history: usize) -> Self
pub fn new(max_history: usize) -> Self
Create a new substrate monitor with the given history capacity.
Sourcepub const fn sensors_available(&self) -> bool
pub const fn sensors_available(&self) -> bool
Whether hardware sensors are available on this platform.
When false, sample() returns neutral defaults and homeostasis
runs in degraded mode — health is unknown, not perfect.
Sourcepub fn sample(&self) -> HarmonyVector
pub fn sample(&self) -> HarmonyVector
Sample current hardware state.
Reads /proc and /sys, constructs a HarmonyVector, stores
it in history, and returns it.
Sourcepub fn history(&self, limit: usize) -> Vec<HarmonyVector>
pub fn history(&self, limit: usize) -> Vec<HarmonyVector>
Get historical samples (most recent first, up to limit).
Sourcepub fn last_sample(&self) -> Option<HarmonyVector>
pub fn last_sample(&self) -> Option<HarmonyVector>
Get the most recent sample without taking a new one.
Sourcepub fn history_len(&self) -> usize
pub fn history_len(&self) -> usize
Number of samples in history.
Auto Trait Implementations§
impl !Freeze for SubstrateMonitor
impl RefUnwindSafe for SubstrateMonitor
impl Send for SubstrateMonitor
impl Sync for SubstrateMonitor
impl Unpin for SubstrateMonitor
impl UnsafeUnpin for SubstrateMonitor
impl UnwindSafe for SubstrateMonitor
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