pub trait Clock {
// Required method
fn now(&self) -> Timestamp;
}Expand description
Pluggable time source for the audit chain.
Implementations are expected to be monotonic with respect to successive
calls. The chain enforces monotonicity at append time and returns
crate::Error::NonMonotonicClock if a regression is observed.
§Example
use audit_trail::{Clock, Timestamp};
/// A fixed clock useful for testing.
struct FixedClock(Timestamp);
impl Clock for FixedClock {
fn now(&self) -> Timestamp { self.0 }
}
let clock = FixedClock(Timestamp::from_nanos(42));
assert_eq!(clock.now().as_nanos(), 42);Required Methods§
Implementors§
impl Clock for SystemClock
Available on crate feature
std only.