Crate local_clock

Source
Expand description

An instance-local, reprogrammable, real time clock.

This crate’s primary export is the LocalClock trait, which defines an interface for interacting with instances of reprogrammable real time clocks, decoupled from any particular platform’s global real time clock.

Also included in local_time is SystemTimeClock, which is a basic in-tree implementation of LocalClock backed by std::time::SystemTime. Unless you’re worried about handling instances where SystemTime jumps backwards, this is perfectly reasonable implementation to use.

This crate deliberately takes a minimalist approach to dependencies, and avoids pulling in any “heavyweight” date/time crates by default (e.g: time, chrono, etc…). That said, native integration with some of these crates is provided via optional features.

§Features

  • inspect - Derives the Inspect trait on various types.
  • time_exts - Integration with the [time] crate
    • Provides From/Into implementations to interop with duration and date/time types from time.
    • Changes the Debug implementation of LocalClockTime to print a human readable date (instead of a raw duration since the Unix Epoch).

Structs§

LocalClockDelta
A delta between two LocalClockTime instances.
LocalClockTime
An opaque type, representing an instant in time.
MockLocalClock
A mock implementation of LocalClock, which is manually ticked via a MockLocalClockAccessor. Useful for tests.
MockLocalClockAccessor
Handle to manually tick an instance of MockLocalClock.
OverflowError
Indicates that an overflow error occurred during conversion.
SystemTimeClock
An implementation of LocalClock backed by std::time::SystemTime.

Traits§

InspectableLocalClock
Extends LocalClock with a bound on Inspect
LocalClock
A local real-time clock, hanging-off the platform’s global real-time clock.