pub struct Instant { /* private fields */ }Expand description
An Instant in time, based on the MCU’s clock ticks since startup.
Implementations§
Source§impl Instant
impl Instant
Sourcepub const MIN: Instant
pub const MIN: Instant
The smallest (earliest) value that can be represented by the Instant type.
Sourcepub const fn from_ticks(ticks: u64) -> Self
pub const fn from_ticks(ticks: u64) -> Self
Create an Instant from a tick count since system boot.
Sourcepub const fn from_nanos(nanos: u64) -> Self
pub const fn from_nanos(nanos: u64) -> Self
Create an Instant from a nanosecond count since system boot.
Sourcepub const fn from_micros(micros: u64) -> Self
pub const fn from_micros(micros: u64) -> Self
Create an Instant from a microsecond count since system boot.
Sourcepub const fn from_millis(millis: u64) -> Self
pub const fn from_millis(millis: u64) -> Self
Create an Instant from a millisecond count since system boot.
Sourcepub const fn from_secs(seconds: u64) -> Self
pub const fn from_secs(seconds: u64) -> Self
Create an Instant from a second count since system boot.
Sourcepub const fn try_from_nanos(nanos: u64) -> Option<Self>
pub const fn try_from_nanos(nanos: u64) -> Option<Self>
Try to create an Instant from a nanosecond count since system boot. Fails if the number of nanoseconds is too large.
Sourcepub const fn try_from_micros(micros: u64) -> Option<Self>
pub const fn try_from_micros(micros: u64) -> Option<Self>
Try to create an Instant from a microsecond count since system boot. Fails if the number of microseconds is too large.
Sourcepub const fn try_from_millis(millis: u64) -> Option<Self>
pub const fn try_from_millis(millis: u64) -> Option<Self>
Try to create an Instant from a millisecond count since system boot. Fails if the number of milliseconds is too large.
Sourcepub const fn try_from_secs(seconds: u64) -> Option<Self>
pub const fn try_from_secs(seconds: u64) -> Option<Self>
Try to create an Instant from a second count since system boot. Fails if the number of seconds is too large.
Sourcepub fn duration_since(&self, earlier: Instant) -> Duration
pub fn duration_since(&self, earlier: Instant) -> Duration
Duration between this Instant and another Instant
§Panics
Panics if the computed duration overflows.
Avoid panics with Instant::checked_duration_since() or Instant::saturating_duration_since().
Sourcepub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration>
pub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration>
Duration between this Instant and another Instant
This is a panic-free Instant::duration_since().
Sourcepub fn saturating_duration_since(&self, earlier: Instant) -> Duration
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration
Returns the duration since the “earlier” Instant. If the “earlier” instant is in the future, the duration is set to zero.
This is a panic-free alternative to Instant::duration_since().
Sourcepub fn checked_add(&self, duration: Duration) -> Option<Instant>
pub fn checked_add(&self, duration: Duration) -> Option<Instant>
Adds one Duration to self, returning a new Instant or None in the event of an overflow.
Sourcepub fn checked_sub(&self, duration: Duration) -> Option<Instant>
pub fn checked_sub(&self, duration: Duration) -> Option<Instant>
Subtracts one Duration to self, returning a new Instant or None in the event of an overflow.
Sourcepub fn saturating_add(self, duration: Duration) -> Self
pub fn saturating_add(self, duration: Duration) -> Self
Adds a Duration to self. In case of overflow, the maximum value is returned.
Sourcepub fn saturating_sub(self, duration: Duration) -> Self
pub fn saturating_sub(self, duration: Duration) -> Self
Subtracts a Duration from self. In case of overflow, the minimum value is returned.