Skip to main content

Module host

Module host 

Source
Expand description

The machine and its environment.

use sys_lib as sys;

println!("running on {}", sys::host::name()?);

Structs§

Board
The main board. Serial numbers are never part of this answer.
ClockSync
Whether the system clock is kept in sync.
Firmware
The machine’s firmware. Inside a VM this describes the virtual firmware, which is correct for the process.
Locale
The user’s locale.
Model
The hardware model.
OpenFiles
How many files are open across the machine.
Processes
How many processes and threads the machine runs. Totals only: no process is listed or inspected.
Session
A login session.
TimeZone
The time zone: its name and the offset now.

Enums§

FirmwareKind
What kind of firmware the machine boots.

Functions§

board
The main board. Placeholder strings are None. Cached.
boot_time
When the machine booted: stable when the wall clock steps.
clock_sync
Whether the system clock is kept in sync (NTP, chrony, PTP), which leases, distributed locks, and hybrid logical clocks depend on. None where the OS has no unprivileged answer. Reading time itself stays in clock-lib.
firmware
The firmware. Placeholder strings are None. Cached.
locale
The locale, from the environment at the first call. None for C, POSIX, and C.UTF-8, which express no preference (E-94).
model
The hardware model, from DMI, SMBIOS, the device tree, or hw.model on macOS (“Mac14,9”; no marketing-name table is shipped). Cached.
name
The host name. A live reading on Unix: DHCP and hostnamectl change it while processes run. On Windows a new name takes effect only at restart, so it is read once. A name that is not UTF-8 is converted lossily, and one longer than 255 bytes is truncated (E-95).
open_files
How many files are open across the machine, and the maximum.
processes
How many processes and threads the machine runs.
sessions
Who is logged in. User names are personal data: keep them out of output that leaves the machine.
timezone
The time zone: the zone name and the current offset, not zone arithmetic (that is a calendar crate’s job). TZ is used only when it is a valid name; it is never opened as a path (T4). When /etc/localtime is a copy rather than a link, the name comes from /etc/timezone or is None: zone files are not compared to guess (E-92).
uptime
The time since the machine booted, including time suspended: monotonic.