Skip to main content

Crate sys_lib

Crate sys_lib 

Source
Expand description

§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

The convention in every example is use sys_lib as sys;:

use sys_lib as sys;

println!("sys-lib {}", sys::VERSION);

The Tier 1 functions arrive from 0.3.0 on, one plain call each:

sys::os::name()                // "Ubuntu 24.04.1 LTS", "macOS 15.1 Sequoia", "Windows 11 Pro"
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::disk::space(path)?        // the filesystem holding `path`
sys::process::guard("site")?   // single-instance lock, umask, open-file limit

§Status

Scaffold. The design is written down in dev/PLAN.md and the milestone schedule in dev/ROADMAP.md (both in the repository); the public API is locked in 0.2.0 and the boot kit ships in 0.3.0.

Constants§

VERSION
Crate version string, populated by Cargo at build time.