pub enum TimerDuration {
Elapsed,
Real(Duration),
Infinite,
}Expand description
A duration wrapper supporting elapsed/negative, real, and infinite durations. Due to the solar system’s impending collapse before the 64 bit integer limit of seconds is reached, an Infinite duration is translated to that when turning this back info a normal duration. If you run your program for longer than the sun’s entire lifespan including the past, this may cause an issue. But I think you’ll have much bigger issues long before that, including the fact that you even came up with that idea.
Variants§
Implementations§
Source§impl TimerDuration
impl TimerDuration
Sourcepub fn from_difference(a: TimerDuration, b: Duration) -> TimerDuration
pub fn from_difference(a: TimerDuration, b: Duration) -> TimerDuration
Takes the difference between a TimerDuration a and a Duration b, resulting in either a negative (Elapsed) duration or a Real one. The Infinite duration is passed through as-is, with no subtraction done to it.
Sourcepub fn to_real(&self) -> Duration
pub fn to_real(&self) -> Duration
Converts this into a Duration that is waitable by rust’s standard functions, for use in e.g. specifying timeouts to std operations.
pub const fn is_elapsed(&self) -> bool
pub const fn is_real(&self) -> bool
pub const fn is_infinite(&self) -> bool
Trait Implementations§
Source§impl Clone for TimerDuration
impl Clone for TimerDuration
Source§fn clone(&self) -> TimerDuration
fn clone(&self) -> TimerDuration
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl From<Duration> for TimerDuration
impl From<Duration> for TimerDuration
Source§impl From<u64> for TimerDuration
impl From<u64> for TimerDuration
Source§impl Ord for TimerDuration
impl Ord for TimerDuration
Source§impl PartialEq for TimerDuration
impl PartialEq for TimerDuration
Source§impl PartialOrd for TimerDuration
impl PartialOrd for TimerDuration
impl Copy for TimerDuration
impl Eq for TimerDuration
impl StructuralPartialEq for TimerDuration
Auto Trait Implementations§
impl Freeze for TimerDuration
impl RefUnwindSafe for TimerDuration
impl Send for TimerDuration
impl Sync for TimerDuration
impl Unpin for TimerDuration
impl UnwindSafe for TimerDuration
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)