Crate injectable_time

source ·


  • FakeTime instances return the last value that was configured by testing code via set_ticks() or add_ticks(). Upon initialization, they return 0.
  • IncrementingFakeTime automatically increments itself by increment_by before each call to
  • MonotonicTime instances provide a monotonic clock. On Fuchsia, MonotonicTime uses fuchsia_zircon::Time::get_monotonic().
  • UtcTime instances return the Rust system clock value each time now() is called.


  • TimeSource provides the current time in nanoseconds since the Unix epoch. A &'a dyn TimeSource can be injected into a data structure. TimeSource is implemented by UtcTime for wall-clock system time, and FakeTime for a clock that is explicitly set by testing code.