Crate near_time

Source
Expand description

Time module provides a non-global clock, which should be passed as an argument to functions which need to read the current time. In particular try to avoid storing the clock instances in the objects. Functions which use system clock directly are non-hermetic, which makes them effectively non-deterministic and hard to test.

Clock provides 2 types of time reads:

  1. now() (aka POSIX CLOCK_MONOTONIC, aka time::Instant) time as perceived by the machine making the measurement. The subsequent calls to now() are guaranteed to return monotonic results. It should be used for measuring the latency of operations as observed by the machine. The time::Instant itself doesn’t translate to any specific timestamp, so it is not meaningful for anyone other than the machine doing the measurement.
  2. now_utc() (aka POSIX CLOCK_REALTIME, aka time::Utc) expected to approximate the (global) UTC time. There is NO guarantee that the subsequent reads will be monotonic, as CLOCK_REALTIME it configurable in the OS settings, or can be updated during NTP sync. Should be used whenever you need to communicate a timestamp over the network, or store it for later use. Remember that clocks of different machines are not perfectly synchronized, and in extreme cases can be totally skewed.

Re-exports§

pub use serde::*;

Modules§

error
Various error types returned by methods in the time crate.
serde

Enums§

Deadline

Type Aliases§

Duration
Instant
Utc