pub struct MonotonicTimestamp(/* private fields */);Expand description
A monotonic timestamp that counts during system sleep, used for drive-window heartbeat math (LD17 + Domain Pitfall: macOS/Linux suspend divergence).
Rust’s std::time::Instant is inconsistent across platforms for the
sleep case: on macOS it uses mach_continuous_time (counts sleep), on
Linux it uses CLOCK_MONOTONIC (does NOT count sleep). A laptop-sleep
during a drive window must EXPIRE the window, so we standardize on the
count-during-sleep semantic on both:
- Linux:
clock_gettime(CLOCK_BOOTTIME). - macOS:
mach_continuous_time()converted to ns viamach_timebase_info.
Stored as nanoseconds since an unspecified epoch; only differences are
meaningful. Wall-clock ts for human audit lives in events.jsonl, tracked
independently (LD17).
Implementations§
Source§impl MonotonicTimestamp
impl MonotonicTimestamp
Sourcepub fn duration_since(&self, earlier: MonotonicTimestamp) -> Duration
pub fn duration_since(&self, earlier: MonotonicTimestamp) -> Duration
Nanoseconds elapsed since earlier. Saturates at 0 if earlier is in
the future (clock readings are monotonic, so this only guards against a
caller passing a later timestamp as earlier).
Sourcepub fn as_nanos(&self) -> u64
pub fn as_nanos(&self) -> u64
Raw nanoseconds, for persisting the heartbeat baseline to state.json.
Sourcepub fn from_nanos(nanos: u64) -> Self
pub fn from_nanos(nanos: u64) -> Self
Reconstruct from raw nanoseconds previously read via as_nanos. Used
by the daemon (Wave 3) to restore a persisted heartbeat baseline. Only
meaningful when paired with a now() from the same daemon incarnation’s
clock (the value is epoch-relative to the running clock).
Trait Implementations§
Source§impl Clone for MonotonicTimestamp
impl Clone for MonotonicTimestamp
Source§fn clone(&self) -> MonotonicTimestamp
fn clone(&self) -> MonotonicTimestamp
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MonotonicTimestamp
Source§impl Debug for MonotonicTimestamp
impl Debug for MonotonicTimestamp
impl Eq for MonotonicTimestamp
Source§impl Ord for MonotonicTimestamp
impl Ord for MonotonicTimestamp
Source§fn cmp(&self, other: &MonotonicTimestamp) -> Ordering
fn cmp(&self, other: &MonotonicTimestamp) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for MonotonicTimestamp
impl PartialEq for MonotonicTimestamp
Source§impl PartialOrd for MonotonicTimestamp
impl PartialOrd for MonotonicTimestamp
impl StructuralPartialEq for MonotonicTimestamp
Auto Trait Implementations§
impl Freeze for MonotonicTimestamp
impl RefUnwindSafe for MonotonicTimestamp
impl Send for MonotonicTimestamp
impl Sync for MonotonicTimestamp
impl Unpin for MonotonicTimestamp
impl UnsafeUnpin for MonotonicTimestamp
impl UnwindSafe for MonotonicTimestamp
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.