Struct nannou::state::time::Duration
[−]
[src]
pub struct Duration { pub duration: Duration, }
A wrapper around a std duration with simpler methods.
Fields
duration: Duration
The inner std duration.
Methods
impl Duration
[src]
pub fn weeks(&self) -> f64
[src]
A simple way of retrieving the duration as weeks.
pub fn days(&self) -> f64
[src]
A simple way of retrieving the duration as days.
pub fn hrs(&self) -> f64
[src]
A simple way of retrieving the duration as hrs.
pub fn mins(&self) -> f64
[src]
A simple way of retrieving the duration as minutes.
pub fn secs(&self) -> f64
[src]
A simple way of retrieving the duration in seconds.
pub fn ms(&self) -> f64
[src]
A simple way of retrieving the duration in milliseconds.
Methods from Deref<Target = Duration>
pub fn as_secs(&self) -> u64
1.3.0[src]
Returns the number of whole seconds contained by this Duration
.
The returned value does not include the fractional (nanosecond) part of the
duration, which can be obtained using subsec_nanos
.
Examples
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(duration.as_secs(), 5);
To determine the total number of seconds represented by the Duration
,
use as_secs
in combination with subsec_nanos
:
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(5.730023852, duration.as_secs() as f64 + duration.subsec_nanos() as f64 * 1e-9);
pub fn subsec_millis(&self) -> u32
[src]
duration_extras
)Returns the fractional part of this Duration
, in milliseconds.
This method does not return the length of the duration when represented by milliseconds. The returned number always represents a fractional portion of a second (i.e. it is less than one thousand).
Examples
#![feature(duration_extras)] use std::time::Duration; let duration = Duration::from_millis(5432); assert_eq!(duration.as_secs(), 5); assert_eq!(duration.subsec_millis(), 432);
pub fn subsec_micros(&self) -> u32
[src]
duration_extras
)Returns the fractional part of this Duration
, in microseconds.
This method does not return the length of the duration when represented by microseconds. The returned number always represents a fractional portion of a second (i.e. it is less than one million).
Examples
#![feature(duration_extras, duration_from_micros)] use std::time::Duration; let duration = Duration::from_micros(1_234_567); assert_eq!(duration.as_secs(), 1); assert_eq!(duration.subsec_micros(), 234_567);
pub fn subsec_nanos(&self) -> u32
1.3.0[src]
Returns the fractional part of this Duration
, in nanoseconds.
This method does not return the length of the duration when represented by nanoseconds. The returned number always represents a fractional portion of a second (i.e. it is less than one billion).
Examples
use std::time::Duration; let duration = Duration::from_millis(5010); assert_eq!(duration.as_secs(), 5); assert_eq!(duration.subsec_nanos(), 10_000_000);
Trait Implementations
impl Copy for Duration
[src]
impl Clone for Duration
[src]
fn clone(&self) -> Duration
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Duration
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Default for Duration
[src]
impl Eq for Duration
[src]
impl PartialEq for Duration
[src]
fn eq(&self, __arg_0: &Duration) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Duration) -> bool
[src]
This method tests for !=
.
impl Hash for Duration
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Ord for Duration
[src]
fn cmp(&self, __arg_0: &Duration) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl PartialOrd for Duration
[src]
fn partial_cmp(&self, __arg_0: &Duration) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Duration) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Duration) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Duration) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Duration) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl From<Duration> for Duration
[src]
impl Into<Duration> for Duration
[src]
impl Deref for Duration
[src]
type Target = Duration
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
Dereferences the value.