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
Durationtype 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. - System
Time - A measurement of the system clock, useful for talking to external entities like the file system or other processes.
- System
Time Error - An error returned from the
duration_sinceandelapsedmethods onSystemTime, 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
SystemTimeinstances or learn about where in time aSystemTimelies.
Functions§
- freeze_
wall - Pin the wall clock to
atfor 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::timewall-clock time, such as a file’s modification time, as this crate’s. The identity where the clock is native. - from_
std - A
std::timewall-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 namestd::time::SystemTimedirectly. The identity where the clock is native. - try_
unix_ now - Whole seconds since the Unix epoch, or
Noneif the clock precedes it. - try_
unix_ now_ ms - Milliseconds since the Unix epoch, or
Noneif the clock precedes it. - try_
unix_ now_ ns - Nanoseconds since the Unix epoch, or
Noneif the clock precedes it. - unix_
now - Whole seconds since the Unix epoch;
0if the clock precedes it. - unix_
now_ i64 - Whole seconds since the Unix epoch as a signed timestamp;
0if the clock precedes it. - unix_
now_ ms - Milliseconds since the Unix epoch;
0if the clock precedes it. - unix_
now_ ns - Nanoseconds since the Unix epoch;
0if the clock precedes it. - wall
- The current wall-clock time, for timestamps shown to people or persisted.
After
freeze_wallit is that instant, every time. - wall_
frozen - Whether
freeze_wallpinned the wall clock.