pub struct Timestamp(pub u64);Expand description
Monotonic nanoseconds from an arbitrary epoch chosen by the driver.
Nanoseconds, not milliseconds: milliseconds are too coarse for SRT pacing
and catastrophically wrong for ST 2110-21. The epoch (what 0 means) is
entirely up to whatever is driving the Stage — stages must treat
Timestamp as an opaque, monotonically non-decreasing counter and never
assume it relates to wall-clock time.
All arithmetic saturates rather than panicking: a Stage must not crash
because a driver’s clock underflowed or overflowed.
Tuple Fields§
§0: u64Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const fn from_nanos(nanos: u64) -> Self
pub const fn from_nanos(nanos: u64) -> Self
Construct from a raw nanosecond count.
Sourcepub const fn saturating_sub(self, other: Timestamp) -> Duration
pub const fn saturating_sub(self, other: Timestamp) -> Duration
self - other, saturating at zero instead of underflowing.
Sourcepub const fn checked_add_nanos(self, nanos: u64) -> Self
pub const fn checked_add_nanos(self, nanos: u64) -> Self
self + nanos, saturating at u64::MAX instead of overflowing.
Sourcepub fn saturating_add(self, duration: Duration) -> Self
pub fn saturating_add(self, duration: Duration) -> Self
self + duration, saturating at u64::MAX instead of overflowing.
A Duration in excess of u64::MAX nanoseconds saturates the same way.
Source§impl Timestamp
impl Timestamp
Sourcepub fn from_instant(base: Instant, now: Instant) -> Self
Available on crate feature std only.
pub fn from_instant(base: Instant, now: Instant) -> Self
std only.Derive a Timestamp from a std::time::Instant pair: now - base,
expressed as nanoseconds since base.
base is whatever fixed instant the driver picked as its epoch (e.g.
“when this stage was constructed”); every subsequent call converts an
Instant to a Timestamp on the same epoch. This is a std-only
convenience so std callers are not forced to hand-roll the
subtraction; no_std drivers construct Timestamp directly.