#[repr(C, u8)]pub enum Instant {
System(InstantPtr),
Tick(SystemTick),
}Expand description
A point in time, either from the system clock or a tick counter.
Use Instant::System on platforms with std, Instant::Tick on embedded/no_std.
Variants§
System(InstantPtr)
System time from std::time::Instant (requires “std” feature)
Tick(SystemTick)
Tick-based time for embedded systems without a real-time clock
Implementations§
Source§impl Instant
impl Instant
Sourcepub fn now() -> Self
pub fn now() -> Self
Returns the current system time.
On systems with std, this uses std::time::Instant::now().
On no_std systems, this returns a zero tick.
Sourcepub fn linear_interpolate(&self, start: Self, end: Self) -> f32
pub fn linear_interpolate(&self, start: Self, end: Self) -> f32
Returns a number from 0.0 to 1.0 indicating the current linear interpolation value between (start, end)
Sourcepub fn add_optional_duration(&self, duration: Option<&Duration>) -> Self
pub fn add_optional_duration(&self, duration: Option<&Duration>) -> Self
Adds a duration to the instant, does nothing in undefined cases
(i.e. trying to add a Duration::Tick to an Instant::System).
Mismatched kinds (System instant + Tick duration, or vice versa)
saturate to self unchanged instead of panicking — a stray mismatch
must never crash the event loop.
Sourcepub fn into_std_instant(self) -> StdInstant
pub fn into_std_instant(self) -> StdInstant
Converts to std::time::Instant (panics if Tick variant).
Sourcepub fn duration_since(&self, earlier: &Self) -> Duration
pub fn duration_since(&self, earlier: &Self) -> Duration
Calculates the duration since an earlier point in time.
Saturates to a zero duration in the degenerate cases (earlier is actually
later than self, or the two instants are of mismatched kinds) instead
of panicking — this runs on the hot event-loop path and must not crash.
Trait Implementations§
impl Eq for Instant
Source§impl From<Instant> for Instant
Available on crate feature std only.
impl From<Instant> for Instant
std only.