Contents
use utopia_system::CpuTimes;pub struct CpuTimesTime spent by all CPUs in each state since boot, in clock ticks, summed
over the per-CPU lines of /proc/stat.
Only cpuN lines count, not the aggregate cpu line. Fields are split
on single spaces, and a later line for the same CPU replaces an earlier
one.
use utopia_system::Io;pub struct IoRead and write volume of a disk over a sampling period, in MiB.
Each volume is an integer when the division is exact, a float otherwise.
use utopia_system::Machine;pub struct MachineThis machine. File reads are of /proc and /sys pseudo-files, which
the kernel serves from memory; sysctl and wmic (macOS and Windows
only) run as child processes.
use utopia_system::System;pub struct System<H: Host = Machine>Facts and measurements of a machine, read through a Host.
use utopia_system::Traffic;pub struct TrafficDownload and upload volume of a network interface, in MiB rounded to two decimals.
use utopia_system::Arch;pub enum ArchA processor architecture family.
use utopia_system::Error;pub enum ErrorWhy a measurement failed.
use utopia_system::Uname;pub enum UnameA field of the system's identity, as Host::uname reports it.
use utopia_system::Host;pub trait HostWhere a System reads the machine from: identity, files, commands,
directories, disk space and the clock.
use utopia_system::count_cpu_list;pub fn count_cpu_list(list: &[u8]) -> Result<i64, Error>The number of CPUs in a Linux CPU list such as 0-3,5,7-8.
Ranges whose bounds are not numeric or are reversed count nothing. A
count beyond i64 fails with Error::Type.
use utopia_system::count_processors;pub fn count_processors(cpuinfo: &[u8]) -> usizeThe number of processors in /proc/cpuinfo content: lines starting
with processor.
use utopia_system::diskstats;pub fn diskstats(content: &[u8]) -> Option<IndexMap<String, Vec<Vec<u8>>>>The lines of /proc/diskstats content, split into fields and keyed by
disk name; None when the content is empty or "0".
Each non-empty line is trimmed, each run of tabs becomes one space, and
the line is split on single spaces. The key is the third field ("" when
there is none), and a later line replaces an earlier one with the same
key.
use utopia_system::env;pub fn env(name: &str) -> Option<String>An environment variable, or None when it is unset, empty or "0".
A variable that is not valid Unicode counts as unset.
use utopia_system::env_or;pub fn env_or<'a>(name: &str, default: &'a str) -> std::borrow::Cow<'a, str>An environment variable, or default when it is unset, empty or "0".
The default is borrowed, not copied: compare the result as it is, or
call Cow::into_owned to keep it.
use utopia_system::env_raw;pub fn env_raw(name: &str) -> Option<String>An environment variable as it is, empty strings and "0" included;
None only when it is unset (or not valid Unicode).
use utopia_system::env_value;pub fn env_value(raw: Option<String>) -> Option<String>The rule env applies to a raw value: one that is empty or "0" is
no value.
use utopia_system::meminfo;pub fn meminfo(content: &[u8], field: &str) -> Option<i64>A field of /proc/meminfo content, such as MemTotal, in MiB rounded
down; None when it is missing.
The value is the first <field>: followed by whitespace and digits, read
as KiB.
use utopia_system::proc_stat_total;pub fn proc_stat_total(content: &[u8]) -> Option<CpuTimes>The CpuTimes of /proc/stat content; None when the content is
empty or "0".