1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Trait abstracting over different system clock backends.
//!
//! The mock clock in [`super`] always reads/writes the *system* clock through
//! a pluggable backend, mirroring [`crate::state::file`]'s [`FileBackend`]
//! and [`crate::state::settings`]'s `SettingsBackend`:
//!
//! - **Native** ([`NativeBackend`](super::native::NativeBackend)): the real OS clock, readable
//! everywhere and writable on native targets (Linux/macOS/Windows).
//! - **Memory** ([`MemoryBackend`](super::memory::MemoryBackend)): anchored to a starting value at
//! construction and advances live in real time from there; used on
//! targets with no host clock access (e.g. wasm). Writes just re-anchor
//! it, never touching the real system clock.
//!
//! [`FileBackend`]: crate::state::file::FileBackend
use Timestamp;
/// Abstraction over reading and writing the system clock.
///
/// Implementations must be `Send` so the backend can be shared across
/// threads via a `Mutex<Box<dyn ClockBackend>>`.
/// Errors from system clock operations.