Skip to main content

Module time

Module time 

Expand description

The toolkit’s clock: tilo-clock, under the toolkit’s module path.

Every monotonic and wall-clock reading in ui goes through now and wall, and every clock type is named through this module rather than std::time. A host that has no process clock of its own (or one that must be virtualised, such as a deterministic replay) then has exactly one seam to provide, instead of a hundred scattered Instant::now() calls.

On targets with a native clock the re-exports are std::time’s own types, so values cross freely into crates that name std::time directly.

crates/sdk/ui-core/clippy.toml rejects Instant::now and SystemTime::now everywhere else in the crate.

Structs§

Duration
A Duration type to represent a span of time, typically used for system timeouts.
Instant
A measurement of a monotonically nondecreasing clock. Opaque and useful only with Duration.
SystemTime
A measurement of the system clock, useful for talking to external entities like the file system or other processes.
SystemTimeError
An error returned from the duration_since and elapsed methods on SystemTime, used to learn how far in the opposite direction a system time lies.

Constants§

UNIX_EPOCH
An anchor in time which can be used to create new SystemTime instances or learn about where in time a SystemTime lies.

Functions§

freeze_wall
Pin the wall clock to at for the rest of the process, so a screenshot capture shows the same date and time on every run. The monotonic clock (now) keeps running: animations and timeouts still advance. Never called in a live session.
from_file_time
A std::time wall-clock time, such as a file’s modification time, as this crate’s. The identity where the clock is native.
from_std
A std::time wall-clock time, such as a file’s modification time, as this crate’s. The identity where the clock is native.
now
The current monotonic instant, for measuring elapsed time and scheduling deadlines.
to_std
A wall-clock time as std::time’s, for crates and APIs that name std::time::SystemTime directly. The identity where the clock is native.
try_unix_now
Whole seconds since the Unix epoch, or None if the clock precedes it.
try_unix_now_ms
Milliseconds since the Unix epoch, or None if the clock precedes it.
try_unix_now_ns
Nanoseconds since the Unix epoch, or None if the clock precedes it.
unix_now
Whole seconds since the Unix epoch; 0 if the clock precedes it.
unix_now_i64
Whole seconds since the Unix epoch as a signed timestamp; 0 if the clock precedes it.
unix_now_ms
Milliseconds since the Unix epoch; 0 if the clock precedes it.
unix_now_ns
Nanoseconds since the Unix epoch; 0 if the clock precedes it.
wall
The current wall-clock time, for timestamps shown to people or persisted. After freeze_wall it is that instant, every time.
wall_frozen
Whether freeze_wall pinned the wall clock.