pub struct FrameTime(/* private fields */);Expand description
A point in time supplied by the shell, in monotonic nanoseconds.
The origin is arbitrary and shell-specific (desktop: nanos since a
shell-owned epoch; Android: a Choreographer frame nanos value; iOS: a
CADisplayLink timestamp). Widgets may therefore only difference two
FrameTimes (via FrameTime::saturating_sub) — never interpret one
absolutely, and never compare FrameTimes produced by different shells.
FrameTime::ZERO is the documented “no time available” fallback used by
legacy/test paint paths that don’t thread a real clock.
Implementations§
Source§impl FrameTime
impl FrameTime
Sourcepub const ZERO: FrameTime
pub const ZERO: FrameTime
The zero instant — also the “no time available” fallback (see the type docs). Differencing against it yields the raw nanosecond value.
Sourcepub const fn from_nanos(nanos: u64) -> Self
pub const fn from_nanos(nanos: u64) -> Self
Build a FrameTime from a raw monotonic-nanosecond count.
Sourcepub const fn as_nanos(self) -> u64
pub const fn as_nanos(self) -> u64
The raw monotonic-nanosecond count. Meaningful only relative to another
FrameTime from the same shell (see the type docs).
Sourcepub fn as_secs_f64(self) -> f64
pub fn as_secs_f64(self) -> f64
This instant as fractional seconds from the (arbitrary) origin. Only differences of two such values carry meaning.
Sourcepub fn saturating_sub(self, earlier: FrameTime) -> Duration
pub fn saturating_sub(self, earlier: FrameTime) -> Duration
The non-negative Duration elapsed from earlier to self.
Saturates at zero when self < earlier (a non-monotonic or reordered
clock), so a widget differencing two frame times can never observe a
negative delta — the basis of AnimationController::advance’s
clamp-and-never-panic guarantee.
Trait Implementations§
impl Copy for FrameTime
impl Eq for FrameTime
Source§impl Ord for FrameTime
impl Ord for FrameTime
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for FrameTime
impl PartialOrd for FrameTime
impl StructuralPartialEq for FrameTime
Auto Trait Implementations§
impl Freeze for FrameTime
impl RefUnwindSafe for FrameTime
impl Send for FrameTime
impl Sync for FrameTime
impl Unpin for FrameTime
impl UnsafeUnpin for FrameTime
impl UnwindSafe for FrameTime
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.