pub struct SystemClock;Available on crate feature
std only.Expand description
Wall-clock time source backed by std::time::SystemTime. Requires
the std feature.
Most production deployments want this; it returns nanoseconds since
the Unix epoch using the host’s system clock. The host clock is not
strictly monotonic — if the operator adjusts time backwards, the next
crate::Chain::append will return crate::Error::NonMonotonicClock.
Deployments that need a strictly-monotonic source should wrap a
monotonic instant in a custom Clock instead.
On the unusual case that SystemTime::now() is before the Unix epoch,
this returns Timestamp::EPOCH (0). On the equally-unusual case
that the system clock exceeds u64::MAX nanoseconds past the epoch
(year ~2554 and later), the value saturates at u64::MAX.
§Example
use audit_trail::{Clock, SystemClock};
let clock = SystemClock::new();
let t = clock.now();
assert!(t.as_nanos() > 0);Implementations§
Source§impl SystemClock
impl SystemClock
Trait Implementations§
Source§impl Clone for SystemClock
impl Clone for SystemClock
Source§fn clone(&self) -> SystemClock
fn clone(&self) -> SystemClock
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SystemClock
impl Debug for SystemClock
Source§impl Default for SystemClock
impl Default for SystemClock
Source§fn default() -> SystemClock
fn default() -> SystemClock
Returns the “default value” for a type. Read more
impl Copy for SystemClock
Auto Trait Implementations§
impl Freeze for SystemClock
impl RefUnwindSafe for SystemClock
impl Send for SystemClock
impl Sync for SystemClock
impl Unpin for SystemClock
impl UnsafeUnpin for SystemClock
impl UnwindSafe for SystemClock
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