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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! The anti-rollback time floor.
//!
//! No time reported by a Roughtime server (or the OS clock) is trusted below this floor: a
//! machine cannot legitimately observe a time earlier than when this crate was built, and
//! [`HARDCODED_FLOOR_SECS`] is a belt-and-suspenders lower bound baked directly into source.
//!
//! By default (the `build-time-floor` feature disabled) the effective floor is simply
//! [`HARDCODED_FLOOR_SECS`] — a static value with no dependency on the build machine's clock,
//! keeping builds reproducible. Enabling `build-time-floor` additionally ratchets the floor
//! forward to the start (UTC) of the day the crate was built, at the cost of build
//! reproducibility — see `build.rs` for the mechanism and the crate-level docs for guidance on
//! which mode to pick.
use crateError;
/// The absolute, hardcoded anti-rollback floor: July 1, 2026 00:00:00 UTC, in Unix seconds.
///
/// This value must be kept in sync with the identical constant in `build.rs`.
pub const HARDCODED_FLOOR_SECS: u64 = 1_782_864_000;
include!;
/// The effective anti-rollback floor: the later of [`HARDCODED_FLOOR_SECS`] and the build-time
/// floor (which is `0` — a no-op — unless the crate was built with the `build-time-floor`
/// feature enabled).
pub const EFFECTIVE_FLOOR_SECS: u64 = if HARDCODED_FLOOR_SECS > BUILD_FLOOR_SECS else ;
/// Rejects a candidate Unix timestamp (in seconds) that predates [`EFFECTIVE_FLOOR_SECS`].
///
/// # Errors
///
/// Returns [`Error::BeforeFloor`] if `candidate_secs` is earlier than the effective floor.
pub const
// Compile-time invariant: the effective floor can never regress below the hardcoded one,
// regardless of `BUILD_FLOOR_SECS`.
const _: = assert!;