Skip to main content

monitrs_core/
lib.rs

1//! Platform-neutral core of monitrs: the data model, the rate engine, the
2//! bounded history ring, process list logic, and the diagnostic engine.
3//!
4//! # Dependency direction
5//!
6//! This crate depends on **no** terminal library and **no** OS collector (§10.1).
7//! It cannot know how `/proc` is parsed, and it cannot know how a process row is
8//! coloured. Everything here is testable from fixtures with no live system.
9//!
10//! # Invariants worth stating once
11//!
12//! * **Unavailable is not zero.** Any metric an OS may withhold is wrapped in
13//!   [`model::MetricState`], and there is no API that turns an unavailable metric
14//!   into a number (§4, §26).
15//! * **Stale is not current.** A retained value can only be read together with
16//!   its age (§26).
17//! * **The first sample of delta-based data is warming up, not zero** (§8.2).
18//! * **A PID is not an identity.** [`model::ProcessIdentity`] pairs the PID with
19//!   a start key so PID reuse is detectable (§26).
20//! * **Monotonic time for rates and ordering**, wall-clock for display only
21//!   (§8.1).
22//! * Raw counters and timestamps are integral; only calculated percentages and
23//!   rates use floating point, and both validate at construction (§10.4).
24
25// §15.3: no unsafe code in the core crate, ever.
26#![forbid(unsafe_code)]
27#![warn(missing_docs)]
28// `unwrap`/`expect` stay denied in production code — a panic here corrupts the
29// terminal (§14.3). In tests they are the correct way to assert a precondition,
30// so the allowance is scoped to `cfg(test)` only (§18.2: narrow allowances).
31#![cfg_attr(test, allow(clippy::expect_used, clippy::unwrap_used))]
32
33pub mod diagnostics;
34pub mod history;
35pub mod model;
36pub mod process;
37pub mod rates;
38pub mod units;
39
40pub use model::{MetricState, ProcessIdentity, SystemSnapshot, UnavailableReason};