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 theInspect
trait on various types.time_exts
- Integration with the [time
] crate- Provides
From
/Into
implementations to interop with duration and date/time types fromtime
. - Changes the
Debug
implementation ofLocalClockTime
to print a human readable date (instead of a raw duration since the Unix Epoch).
- Provides
Structs§
- A delta between two
LocalClockTime
instances. - An opaque type, representing an instant in time.
- A mock implementation of
LocalClock
, which is manually ticked via aMockLocalClockAccessor
. Useful for tests. - Handle to manually tick an instance of
MockLocalClock
. - Indicates that an overflow error occurred during conversion.
- An implementation of
LocalClock
backed bystd::time::SystemTime
.
Traits§
- Extends
LocalClock
with a bound onInspect
- A local real-time clock, hanging-off the platform’s global real-time clock.