pub struct TimePoint<T: Timeline> { /* private fields */ }Expand description
A point on timeline T: a tick count since the timeline’s zero.
Points on one timeline compare, subtract to Ticks, and can be written down as a tick count
and read back (ticks, from_ticks). Points on different
timelines do not compare at all, because their types differ:
ⓘ
use core::num::NonZeroU64;
use win_time_sys::{TimePoint, Timeline};
enum Boot {}
impl Timeline for Boot {
fn ticks_per_second() -> NonZeroU64 { NonZeroU64::new(10_000_000).unwrap() }
}
enum Calendar {}
impl Timeline for Calendar {
fn ticks_per_second() -> NonZeroU64 { NonZeroU64::new(10_000_000).unwrap() }
}
// The same unit, but not the same zero: refused.
let _ = TimePoint::<Boot>::from_ticks(1) < TimePoint::<Calendar>::from_ticks(2);Implementations§
Source§impl<T: Timeline> TimePoint<T>
impl<T: Timeline> TimePoint<T>
Sourcepub const fn from_ticks(ticks: u64) -> Self
pub const fn from_ticks(ticks: u64) -> Self
The point ticks after the timeline’s zero: how a recorded point is read back.
Sourcepub const fn ticks(self) -> u64
pub const fn ticks(self) -> u64
The tick count since the timeline’s zero: how a point is recorded.
Sourcepub fn checked_since(self, earlier: Self) -> Option<Ticks<T>>
pub fn checked_since(self, earlier: Self) -> Option<Ticks<T>>
How far this point is after earlier – negative if it is before – or None if the
distance does not fit in Ticks.
Sourcepub fn checked_add(self, ticks: Ticks<T>) -> Option<Self>
pub fn checked_add(self, ticks: Ticks<T>) -> Option<Self>
The point ticks later, or None if it falls outside the timeline.
Sourcepub fn checked_sub(self, ticks: Ticks<T>) -> Option<Self>
pub fn checked_sub(self, ticks: Ticks<T>) -> Option<Self>
The point ticks earlier, or None if it falls outside the timeline.
Trait Implementations§
Source§impl<T: Timeline> AddAssign<Ticks<T>> for TimePoint<T>
impl<T: Timeline> AddAssign<Ticks<T>> for TimePoint<T>
Source§fn add_assign(&mut self, ticks: Ticks<T>)
fn add_assign(&mut self, ticks: Ticks<T>)
Performs the
+= operation. Read moreimpl<T: Timeline> Copy for TimePoint<T>
impl<T: Timeline> Eq for TimePoint<T>
Source§impl<T: Timeline> Ord for TimePoint<T>
impl<T: Timeline> Ord for TimePoint<T>
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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<T: Timeline> PartialOrd for TimePoint<T>
impl<T: Timeline> PartialOrd for TimePoint<T>
Auto Trait Implementations§
impl<T> Freeze for TimePoint<T>
impl<T> RefUnwindSafe for TimePoint<T>
impl<T> Send for TimePoint<T>
impl<T> Sync for TimePoint<T>
impl<T> Unpin for TimePoint<T>
impl<T> UnsafeUnpin for TimePoint<T>
impl<T> UnwindSafe for TimePoint<T>
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