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.
- Clock
Sync - 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.
- Open
Files - 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.
- Time
Zone - The time zone: its name and the offset now.
Enums§
- Firmware
Kind - 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.
Nonewhere 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.
NoneforC,POSIX, andC.UTF-8, which express no preference (E-94). - model
- The hardware model, from DMI, SMBIOS, the device tree, or
hw.modelon macOS (“Mac14,9”; no marketing-name table is shipped). Cached. - name
- The host name. A live reading on Unix: DHCP and
hostnamectlchange 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).
TZis used only when it is a valid name; it is never opened as a path (T4). When/etc/localtimeis a copy rather than a link, the name comes from/etc/timezoneor isNone: zone files are not compared to guess (E-92). - uptime
- The time since the machine booted, including time suspended: monotonic.