[−][src]Struct easytime::Duration
A Duration
type to represent a span of time, typically used for system
timeouts.
Each Duration
is composed of a whole number of seconds and a fractional part
represented in nanoseconds. If the underlying system does not support
nanosecond-level precision, APIs binding a system timeout will typically round up
the number of nanoseconds.
Duration
s implement many common traits, including Add
, Sub
, and other
ops
traits.
Methods
impl Duration
[src]
pub fn new(secs: u64, nanos: u32) -> Duration
[src]
Creates a new Duration
from the specified number of whole seconds and
additional nanoseconds.
If the number of nanoseconds is greater than 1 billion (the number of nanoseconds in a second), then it will carry over into the seconds provided.
pub const fn from_secs(secs: u64) -> Duration
[src]
Creates a new Duration
from the specified number of whole seconds.
pub const fn from_millis(millis: u64) -> Duration
[src]
Creates a new Duration
from the specified number of milliseconds.
pub const fn from_micros(micros: u64) -> Duration
[src]
Creates a new Duration
from the specified number of microseconds.
pub const fn from_nanos(nanos: u64) -> Duration
[src]
Creates a new Duration
from the specified number of nanoseconds.
pub fn as_secs(&self) -> Option<u64>
[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
.
pub fn subsec_millis(&self) -> Option<u32>
[src]
Returns the fractional part of this Duration
, in whole 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).
pub fn subsec_micros(&self) -> Option<u32>
[src]
Returns the fractional part of this Duration
, in whole 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).
pub fn subsec_nanos(&self) -> Option<u32>
[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).
pub fn as_millis(&self) -> Option<u128>
[src]
Returns the total number of whole milliseconds contained by this Duration
.
pub fn as_micros(&self) -> Option<u128>
[src]
Returns the total number of whole microseconds contained by this Duration
.
pub fn as_nanos(&self) -> Option<u128>
[src]
Returns the total number of nanoseconds contained by this Duration
.
impl Duration
[src]
pub fn is_some(&self) -> bool
[src]
Returns true
if into_inner
returns Some
.
pub fn is_none(&self) -> bool
[src]
Returns true
if into_inner
returns None
.
pub const fn into_inner(self) -> Option<Duration>
[src]
Returns the contained std::time::Duration
or None
.
pub fn unwrap_or(self, default: Duration) -> Duration
[src]
Returns the contained std::time::Duration
or a default.
dur.unwrap_or(default)
is equivalent to dur.into_inner().unwrap_or(default)
.
pub fn unwrap_or_else<F>(self, default: F) -> Duration where
F: FnOnce() -> Duration,
[src]
F: FnOnce() -> Duration,
Returns the contained std::time::Duration
or computes it from a closure.
dur.unwrap_or_else(default)
is equivalent to dur.into_inner().unwrap_or_else(default)
.
Trait Implementations
impl PartialEq<Duration> for Duration
[src]
impl Clone for Duration
[src]
fn clone(&self) -> Duration
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialOrd<Duration> for Duration
[src]
fn partial_cmp(&self, other: &Duration) -> Option<Ordering>
[src]
fn lt(&self, other: &Duration) -> bool
[src]
fn le(&self, other: &Duration) -> bool
[src]
fn gt(&self, other: &Duration) -> bool
[src]
fn ge(&self, other: &Duration) -> bool
[src]
impl Eq for Duration
[src]
impl Ord for Duration
[src]
fn cmp(&self, other: &Duration) -> Ordering
[src]
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 From<Duration> for Duration
[src]
impl Default for Duration
[src]
impl Copy for Duration
[src]
impl Debug for Duration
[src]
impl Hash for Duration
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
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 Add<Duration> for Duration
[src]
type Output = Duration
The resulting type after applying the +
operator.
fn add(self, rhs: Duration) -> Duration
[src]
impl Add<Duration> for Duration
[src]
type Output = Duration
The resulting type after applying the +
operator.
fn add(self, rhs: Duration) -> Duration
[src]
impl Add<Duration> for Instant
[src]
type Output = Instant
The resulting type after applying the +
operator.
fn add(self, other: Duration) -> Instant
[src]
impl Sub<Duration> for Duration
[src]
type Output = Duration
The resulting type after applying the -
operator.
fn sub(self, rhs: Duration) -> Duration
[src]
impl Sub<Duration> for Duration
[src]
type Output = Duration
The resulting type after applying the -
operator.
fn sub(self, rhs: Duration) -> Duration
[src]
impl Sub<Duration> for Instant
[src]
type Output = Instant
The resulting type after applying the -
operator.
fn sub(self, other: Duration) -> Instant
[src]
impl Mul<u32> for Duration
[src]
type Output = Duration
The resulting type after applying the *
operator.
fn mul(self, rhs: u32) -> Duration
[src]
impl Mul<Duration> for u32
[src]
type Output = Duration
The resulting type after applying the *
operator.
fn mul(self, rhs: Duration) -> Duration
[src]
impl Div<u32> for Duration
[src]
type Output = Duration
The resulting type after applying the /
operator.
fn div(self, rhs: u32) -> Duration
[src]
impl AddAssign<Duration> for Duration
[src]
fn add_assign(&mut self, rhs: Duration)
[src]
impl AddAssign<Duration> for Duration
[src]
fn add_assign(&mut self, rhs: Duration)
[src]
impl AddAssign<Duration> for Instant
[src]
fn add_assign(&mut self, other: Duration)
[src]
impl SubAssign<Duration> for Duration
[src]
fn sub_assign(&mut self, rhs: Duration)
[src]
impl SubAssign<Duration> for Duration
[src]
fn sub_assign(&mut self, rhs: Duration)
[src]
impl SubAssign<Duration> for Instant
[src]
fn sub_assign(&mut self, other: Duration)
[src]
impl MulAssign<u32> for Duration
[src]
fn mul_assign(&mut self, rhs: u32)
[src]
impl DivAssign<u32> for Duration
[src]
fn div_assign(&mut self, rhs: u32)
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,