pub struct Timestamp(/* private fields */);Expand description
A point on a monotonic timeline, in nanoseconds since an origin the caller chooses. Only differences between timestamps mean anything; the origin itself never enters the schedule.
Absolute timestamps rather than per-frame deltas, on purpose. One
subtraction happens in one place (every caller computing its own can
compute it wrongly), a clock that went the wrong way becomes
Nanos::ZERO instead of 1.1 trillion phantom steps, the first-frame
branch disappears into the constructor’s start argument, and
resynchronizing after a known pause is trivially correct.
Implementations§
Source§impl Timestamp
impl Timestamp
pub const fn from_nanos(nanos: u64) -> Self
Sourcepub const fn get(self) -> u64
pub const fn get(self) -> u64
The raw offset from the caller’s own origin. Meaningful only to whoever chose that origin — for logging and for building a synthetic timeline, never for arithmetic against another clock.
Sourcepub const fn saturating_since(self, earlier: Self) -> Nanos
pub const fn saturating_since(self, earlier: Self) -> Nanos
The span from earlier to self, or Nanos::ZERO if self is
the earlier of the two. A backwards clock is a defined, harmless
input rather than a wrapped u64.
Sourcepub const fn saturating_add(self, span: Nanos) -> Self
pub const fn saturating_add(self, span: Nanos) -> Self
self + span, saturating at the end of the representable
timeline (~584 years).