pub struct AuditClock {
pub epoch_seconds: i64,
}Expand description
A pinned instant. The library never reads the system clock.
Fields§
§epoch_seconds: i64Seconds since the Unix epoch, in UTC.
Implementations§
Source§impl AuditClock
impl AuditClock
Sourcepub fn parse(text: &str) -> Option<AuditClock>
pub fn parse(text: &str) -> Option<AuditClock>
Build a clock from an OKF RFC 3339 timestamp or bare YYYY-MM-DD date.
Returns None when the text is not a valid calendar date or timestamp.
use perishables_core::AuditClock;
let clock = AuditClock::parse("2026-11-20").unwrap();
assert_eq!(clock.to_rfc3339(), "2026-11-20T00:00:00Z");
assert!(AuditClock::parse("2026-02-29").is_none());Examples found in repository?
examples/audit_bundle.rs (line 14)
10fn main() {
11 let fixture_dir =
12 PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../corpus/fixtures/clean-healthy-chain");
13 let bundle = Bundle::load(&fixture_dir).expect("load clean-healthy-chain fixture");
14 let clock = AuditClock::parse("2026-11-20").expect("parse pinned audit date");
15
16 println!(
17 "Loaded bundle with {} concepts at {}",
18 bundle.concepts.len(),
19 clock
20 );
21
22 for concept in &bundle.concepts {
23 let tier = recompute_tier(concept, &clock);
24 println!(
25 " concept={} raw={} recomputed={}",
26 tier.concept_id,
27 tier.raw_tier.name(),
28 tier.recomputed_tier.name()
29 );
30 }
31
32 let chain = walk_supersession(&bundle, "metrics/old-revenue");
33 assert_eq!(chain.terminal, ChainTerminal::Terminated);
34 println!(
35 " chain start={} hops={:?} terminal={:?}",
36 chain.start, chain.hops, chain.terminal
37 );
38
39 let revenue = bundle
40 .concept("metrics/revenue")
41 .expect("metrics/revenue exists");
42 assert_eq!(
43 recompute_tier(revenue, &clock).recomputed_tier,
44 Tier::HumanReviewed
45 );
46
47 let mut findings = check_currency(&bundle, &clock);
48 findings.extend(check_supersession(&bundle));
49 findings.extend(check_freshness(&bundle, &clock));
50 findings.extend(check_provenance(&bundle));
51 findings.extend(check_drift(&bundle));
52 assert!(
53 findings.is_empty(),
54 "expected zero findings, got {findings:?}"
55 );
56
57 let notes = info_notes(&bundle, &clock);
58 println!(
59 "Audit passed with {} findings and {} info notes.",
60 findings.len(),
61 notes.len()
62 );
63}Sourcepub fn to_rfc3339(&self) -> String
pub fn to_rfc3339(&self) -> String
Format this instant as a canonical UTC RFC 3339 timestamp (YYYY-MM-DDTHH:MM:SSZ).
Trait Implementations§
Source§impl Clone for AuditClock
impl Clone for AuditClock
impl Copy for AuditClock
Source§impl Debug for AuditClock
impl Debug for AuditClock
Source§impl Display for AuditClock
impl Display for AuditClock
impl Eq for AuditClock
Source§impl Ord for AuditClock
impl Ord for AuditClock
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for AuditClock
impl PartialEq for AuditClock
Source§impl PartialOrd for AuditClock
impl PartialOrd for AuditClock
impl StructuralPartialEq for AuditClock
Auto Trait Implementations§
impl Forget for AuditClock
impl Freeze for AuditClock
impl Move for AuditClock
impl RefUnwindSafe for AuditClock
impl Send for AuditClock
impl Sync for AuditClock
impl Unpin for AuditClock
impl UnsafeUnpin for AuditClock
impl UnwindSafe for AuditClock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more