Expand description
The monotonic and wall clocks, on every target NetGet builds for.
std::time::Instant::now() and SystemTime::now() panic on wasm32-unknown-unknown
(“time not implemented on this platform”); the browser has clocks, std just does not know
how to reach them. On that target Instant is the tokio shim’s performance.now() clock
and SystemTime is web_time’s Date.now(); on native both are std, so on native this
module changes nothing but a path.
Use crate::utils::clock::{Instant, SystemTime, UNIX_EPOCH} rather than std::time::* in
anything the browser build compiles: src/state, src/llm, src/protocol, src/cli,
src/tui, the shared server modules and the protocols enabled in crates/netget-web. A
protocol that is only ever built natively can keep using std; the moment it is added to the
web build, every Instant::now() it reaches is a panic on first connection, so run the
rewrite in that direction rather than trusting it. Duration has no clock in it and stays
std::time::Duration everywhere.
Structs§
- 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§
- process_
id - The current process id, or
0where there is no process (the browser). - to_
local_ datetime - A wall-clock time as a local
chronodate-time.