pub struct Wall(/* private fields */);std only.Expand description
A captured wall-clock instant.
Wall wraps a single sample of the operating system’s real-time clock.
Convert it to Unix time with unix_seconds,
unix_millis, or unix_nanos.
Wall and Monotonic are deliberately distinct
types and cannot be mixed. If your system clock predates the Unix
epoch (1970-01-01 UTC), the unix_* accessors saturate at zero — they
never panic and never silently wrap.
Construct one with Wall::now or the crate-level
wall shortcut.
§Examples
use clock_lib::Wall;
let stamp = Wall::now();
let seconds = stamp.unix_seconds();
assert!(seconds > 0);Implementations§
Source§impl Wall
impl Wall
Sourcepub fn unix_seconds(self) -> u64
pub fn unix_seconds(self) -> u64
Returns Unix time in whole seconds.
Returns zero if the system clock is set to a moment before the Unix
epoch. The return type is u64, which is sufficient to represent
any plausible wall-clock value through year 584,942,417,355 — Unix
time will not overflow this accessor.
§Examples
use clock_lib::Wall;
let seconds = Wall::now().unix_seconds();
assert!(seconds > 0);Sourcepub fn unix_millis(self) -> u128
pub fn unix_millis(self) -> u128
Returns Unix time in whole milliseconds.
Returns zero if the system clock is set to a moment before the Unix
epoch. The return type is u128, which cannot overflow for any
representable SystemTime.
§Examples
use clock_lib::Wall;
let millis = Wall::now().unix_millis();
assert!(millis > 0);Sourcepub fn unix_nanos(self) -> u128
pub fn unix_nanos(self) -> u128
Returns Unix time in whole nanoseconds.
Returns zero if the system clock is set to a moment before the Unix
epoch. The return type is u128, which cannot overflow for any
representable SystemTime.
§Examples
use clock_lib::Wall;
let nanos = Wall::now().unix_nanos();
assert!(nanos > 0);