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§fn eq(&self, other: &MonotonicTimestamp) -> bool
fn eq(&self, other: &MonotonicTimestamp) -> bool
self and other values to be equal, and is used by ==.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.