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
//! Monotonic deadline encoding. Every `Entry::expire_at_ns` is a nanosecond
//! offset from a process-start [`epoch`], packed as `Option<NonZeroU64>` so the
//! niche optimisation keeps the field at 8 bytes. Split out of `lib.rs` to keep
//! it under the 500-LOC house cap.
use NonZeroU64;
use OnceLock;
use ;
/// Process-start anchor: every `Entry::expire_at_ns` is a nanosecond
/// offset from this `Instant`, encoded as `Option<NonZeroU64>` so the
/// niche optimisation lets the field cost 8 bytes (vs 16 for a bare
/// `Option<Instant>`). 584-year range from process start — Y2538-proof.
pub
/// Encode an absolute `Instant` as ns-since-process-start. Returns `None`
/// when `t == epoch()` exactly (sentinel collision); in practice an entry
/// inserted at exactly t=0 from process start with TTL=0 is the only path
/// there, and TTL=0 isn't a valid expiry the API ever takes.
pub
/// Decode a packed deadline back into an `Instant` for the rare paths
/// (`pttl`, snapshot dump) that need real-clock math.
pub
/// Current monotonic time as ns-since-[`epoch`] — the unit `Entry::expire_at_ns`
/// is stored in and `Store::cached_ns` caches. Reads `Instant::now()` once.
pub