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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! # sys_lib
//!
//! System facts for Rust services: operating system, CPU, memory, disks,
//! network, host, this process, virtualization, power, and device identity,
//! container-aware by default, plus the boot kit every long-running service
//! needs (build info, instance info, and a process guard).
//!
//! Every reading is a file read or a system call. sys-lib never starts a
//! thread or a timer, never runs another program, and has no third-party
//! runtime dependencies.
//!
//! ## Tier 1
//!
//! Add it with Cargo's rename, `sys = { package = "sys-lib", version = "0.2" }`,
//! and every file writes `sys::`; without the rename, `use sys_lib as sys;`
//! does the same (the examples use that form so they compile either way):
//!
//! ```
//! use sys_lib as sys;
//!
//! println!("sys-lib {}", sys::VERSION);
//! ```
//!
//! The Tier 1 functions arrive from `0.3.0` on, one plain call each:
//!
//! ```text
//! sys::os::name() // "Ubuntu 24.04.1 LTS", "macOS 15.1 Sequoia", "Windows 11 Pro"
//! sys::os::distro() // "Ubuntu"; "Windows", "macOS" elsewhere
//! sys::cpu::name() // "AMD Ryzen 9 7950X"
//! sys::cpu::physical() // cores
//! sys::cpu::available() // what this process may use (affinity, cpuset, quota)
//! sys::mem::total()? // the container's limit inside a container
//! sys::mem::used_percent()? // "32.8%"
//! sys::cpu::used()? // blocks for 100 ms
//! sys::net::traffic()? // download and upload; blocks for 1 s
//! sys::disk::space(path)? // the filesystem holding `path`
//! sys::process::guard("site")? // single-instance lock, umask, open-file limit
//! ```
//!
//! ## Status
//!
//! Design locked (`0.2.0`). The complete API is in `docs/API.md`, the design
//! in `dev/PLAN.md`, and the schedule in `dev/ROADMAP.md` (all in the
//! [repository](https://github.com/jamesgober/sys-lib)); the boot kit ships in
//! `0.3.0`.
// `deny`, not `forbid`: the per-platform `sys` modules lift it locally to call
// the OS where std has no API. Nowhere else.
/// Crate version string, populated by Cargo at build time.
pub const VERSION: &str = env!;