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
//! Clock provider abstraction for injectable time.
use ;
/// Provides the current wall-clock time, injectable for testing.
///
/// Implement this trait to decouple domain logic from `Utc::now()`.
/// Use [`SystemClock`] in production and `MockClock` (from `auths-test-utils`)
/// in tests.
///
/// Usage:
/// ```ignore
/// fn check_expiry(clock: &dyn ClockProvider, expires_at: DateTime<Utc>) -> bool {
/// clock.now() < expires_at
/// }
/// ```
/// Production clock that delegates to [`Utc::now`].
///
/// Usage:
/// ```ignore
/// let clock = SystemClock;
/// let timestamp = clock.now();
/// ```
;