pub struct Time(/* private fields */);Expand description
A point in time, measured as an offset from the start of a run.
Monotonic by construction: the simulator only ever advances it, and a real driver derives it from a base instant captured at startup. Arithmetic saturates rather than wrapping, so monotonicity cannot be broken by overflow.
Implementations§
Source§impl Time
impl Time
Sourcepub const MAX: Time
pub const MAX: Time
The latest representable time — around 584 billion years in, so useful as a “no deadline” sentinel and unreachable in practice.
Sourcepub const fn from_offset(offset: Duration) -> Self
pub const fn from_offset(offset: Duration) -> Self
A time offset after the start of the run.
pub const fn from_nanos(nanos: u64) -> Self
pub const fn from_micros(micros: u64) -> Self
pub const fn from_millis(millis: u64) -> Self
pub const fn from_secs(secs: u64) -> Self
Sourcepub const fn as_nanos(self) -> u128
pub const fn as_nanos(self) -> u128
Nanoseconds since the start of the run. u128, because the range exceeds u64.
Sourcepub fn saturating_since(self, earlier: Time) -> Duration
pub fn saturating_since(self, earlier: Time) -> Duration
Time elapsed from earlier to self, saturating at zero if earlier is later.
Sourcepub fn saturating_add(self, d: Duration) -> Time
pub fn saturating_add(self, d: Duration) -> Time
self advanced by d, saturating at Time::MAX.
Trait Implementations§
Source§impl AddAssign<Duration> for Time
impl AddAssign<Duration> for Time
Source§fn add_assign(&mut self, d: Duration)
fn add_assign(&mut self, d: Duration)
Performs the
+= operation. Read moreimpl Copy for Time
impl Eq for Time
Source§impl Ord for Time
impl Ord for Time
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Time
impl PartialOrd for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnsafeUnpin for Time
impl UnwindSafe for Time
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