pub struct Duration<Clock>where
Clock: Clock,{
pub(crate) ticks: u64,
pub(crate) _phantom: PhantomData<Clock>,
}Expand description
A span of time represented by an unsigned tick count.
A Duration is generic over a Clock, preventing arithmetic operations
between durations of different clocks at compile-time.
Fields§
§ticks: u64§_phantom: PhantomData<Clock>Implementations§
Source§impl<Clock> Duration<Clock>where
Clock: Clock,
impl<Clock> Duration<Clock>where
Clock: Clock,
Sourcepub const fn from_secs(secs: u64) -> Duration<Clock>
pub const fn from_secs(secs: u64) -> Duration<Clock>
Creates a Duration from a number of seconds.
Sourcepub const fn from_millis(millis: u64) -> Duration<Clock>
pub const fn from_millis(millis: u64) -> Duration<Clock>
Creates a Duration from a number of milliseconds.
Sourcepub const fn from_micros(micros: u64) -> Duration<Clock>
pub const fn from_micros(micros: u64) -> Duration<Clock>
Creates a Duration from a number of microseconds.
Sourcepub const fn from_nanos(nanos: u64) -> Duration<Clock>
pub const fn from_nanos(nanos: u64) -> Duration<Clock>
Creates a Duration from a number of nanoseconds.
Sourcepub fn as_secs(self) -> u64
pub fn as_secs(self) -> u64
Returns the total number of whole seconds contained by this Duration.
Sourcepub fn as_millis(self) -> u128
pub fn as_millis(self) -> u128
Returns the total number of milliseconds contained by this Duration.
Sourcepub fn as_micros(self) -> u128
pub fn as_micros(self) -> u128
Returns the total number of microseconds contained by this Duration.
Sourcepub fn as_nanos(self) -> u128
pub fn as_nanos(self) -> u128
Returns the total number of nanoseconds contained by this Duration.
Sourcepub const fn checked_add(self, rhs: Duration<Clock>) -> Option<Duration<Clock>>
pub const fn checked_add(self, rhs: Duration<Clock>) -> Option<Duration<Clock>>
Adds another Duration, returning None if overflow occurred.
Sourcepub const fn checked_sub(self, rhs: Duration<Clock>) -> Option<Duration<Clock>>
pub const fn checked_sub(self, rhs: Duration<Clock>) -> Option<Duration<Clock>>
Subtracts another Duration, returning None if underflow occurred.
Trait Implementations§
impl<Clock> Copy for Duration<Clock>where
Clock: Clock,
impl<Clock> Eq for Duration<Clock>where
Clock: Clock,
Source§impl<Clock> Ord for Duration<Clock>where
Clock: Clock,
impl<Clock> Ord for Duration<Clock>where
Clock: Clock,
1.21.0 (const: unstable)§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable)§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<Clock> PartialOrd for Duration<Clock>where
Clock: Clock,
impl<Clock> PartialOrd for Duration<Clock>where
Clock: Clock,
Auto Trait Implementations§
impl<Clock> Forget for Duration<Clock>
impl<Clock> Freeze for Duration<Clock>where
PhantomData<Clock>: Freeze,
impl<Clock> Move for Duration<Clock>
impl<Clock> RefUnwindSafe for Duration<Clock>where
PhantomData<Clock>: RefUnwindSafe,
impl<Clock> Send for Duration<Clock>where
PhantomData<Clock>: Send,
impl<Clock> Sync for Duration<Clock>where
PhantomData<Clock>: Sync,
impl<Clock> Unpin for Duration<Clock>where
PhantomData<Clock>: Unpin,
impl<Clock> UnsafeUnpin for Duration<Clock>where
PhantomData<Clock>: UnsafeUnpin,
impl<Clock> UnwindSafe for Duration<Clock>where
PhantomData<Clock>: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§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)