pub struct Duration(/* private fields */);Expand description
Implementations§
source§impl Duration
impl Duration
pub const HOUR: Self = _
pub const MICROSECOND: Self = _
pub const MILLISECOND: Self = _
pub const MINUTE: Self = _
pub const NANOSECOND: Self = _
pub const SECOND: Self = _
source§impl Duration
impl Duration
sourcepub const fn from_nanos(ns: u128) -> Self
pub const fn from_nanos(ns: u128) -> Self
Creates a new Duration from the specified number of nanoseconds.
sourcepub const fn from_micros(us: u128) -> Self
pub const fn from_micros(us: u128) -> Self
Creates a new Duration from the specified number of microseconds.
Overflow Behavior
IF the value in nanoseconds overflows a u128, the behavior is the same as with u128 overflow with multiplication.
sourcepub const fn from_millis(ms: u128) -> Self
pub const fn from_millis(ms: u128) -> Self
Creates a new Duration from the specified number of milliseconds.
Overflow Behavior
IF the value in nanoseconds overflows a u128, the behavior is the same as with u128 overflow with multiplication.
sourcepub const fn from_secs(secs: u128) -> Self
pub const fn from_secs(secs: u128) -> Self
Creates a new Duration from the specified number of seconds.
Overflow Behavior
IF the value in nanoseconds overflows a u128, the behavior is the same as with u128 overflow with multiplication.
sourcepub fn to_std(self) -> StdDuration
pub fn to_std(self) -> StdDuration
Convert to StdDuration. equivalent to calling Into::into.
Panics
Panics if self is too big for an StdDuration.
sourcepub fn try_to_std(self) -> Option<StdDuration>
pub fn try_to_std(self) -> Option<StdDuration>
Tries to convert self into an StdDuration.
Returns None if the value is too big for StdDuration.
sourcepub const fn from_std(d: StdDuration) -> Self
pub const fn from_std(d: StdDuration) -> Self
Convert from StdDuration. Equivalent to Duration::from.
sourcepub const fn as_nanos(self) -> u128
pub const fn as_nanos(self) -> u128
Returns the total number of nanoseconds contained by this Duration.
sourcepub const fn as_micros(self) -> u128
pub const fn as_micros(self) -> u128
Returns the total number of whole microseconds contained by this Duration.
sourcepub fn as_micros_dec(self) -> Decimal
pub fn as_micros_dec(self) -> Decimal
Returns this duration in microseconds as a Decimal.
sourcepub const fn as_millis(self) -> u128
pub const fn as_millis(self) -> u128
Returns the total number of whole milliseconds contained by this Duration.
sourcepub fn as_millis_dec(self) -> Decimal
pub fn as_millis_dec(self) -> Decimal
Returns this duration in milliseconds as a Decimal.
sourcepub const fn as_secs(self) -> u128
pub const fn as_secs(self) -> u128
Returns the total number of whole seconds contained by this Duration.
sourcepub fn as_secs_dec(self) -> Decimal
pub fn as_secs_dec(self) -> Decimal
Returns this duration in seconds as a Decimal.
Trait Implementations§
source§impl Add<Duration> for SystemTime
impl Add<Duration> for SystemTime
source§impl AddAssign<Duration> for Duration
impl AddAssign<Duration> for Duration
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moresource§impl AddAssign<Duration> for Duration
impl AddAssign<Duration> for Duration
source§fn add_assign(&mut self, rhs: StdDuration)
fn add_assign(&mut self, rhs: StdDuration)
+= operation. Read moresource§impl AddAssign<Duration> for SystemTime
impl AddAssign<Duration> for SystemTime
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moresource§impl AddAssign for Duration
impl AddAssign for Duration
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moresource§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
source§fn deserialize<D>(deserializer: D) -> Result<Duration, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Duration, D::Error>where
D: Deserializer<'de>,
source§impl<T: Into<u128>> DivAssign<T> for Duration
impl<T: Into<u128>> DivAssign<T> for Duration
source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
/= operation. Read moresource§impl From<Duration> for Duration
impl From<Duration> for Duration
source§fn from(d: StdDuration) -> Self
fn from(d: StdDuration) -> Self
source§impl From<Duration> for StdDuration
impl From<Duration> for StdDuration
source§impl<T: Into<u128>> MulAssign<T> for Duration
impl<T: Into<u128>> MulAssign<T> for Duration
source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*= operation. Read moresource§impl Ord for Duration
impl Ord for Duration
source§impl PartialEq<Duration> for Duration
impl PartialEq<Duration> for Duration
source§fn eq(&self, rhs: &StdDuration) -> bool
fn eq(&self, rhs: &StdDuration) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialEq<Duration> for StdDuration
impl PartialEq<Duration> for StdDuration
source§impl PartialEq for Duration
impl PartialEq for Duration
source§impl PartialOrd for Duration
impl PartialOrd for Duration
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl<T: Into<u128>> RemAssign<T> for Duration
impl<T: Into<u128>> RemAssign<T> for Duration
source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
%= operation. Read moresource§impl Sub<Duration> for SystemTime
impl Sub<Duration> for SystemTime
source§impl SubAssign<Duration> for Duration
impl SubAssign<Duration> for Duration
source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read moresource§impl SubAssign<Duration> for Duration
impl SubAssign<Duration> for Duration
source§fn sub_assign(&mut self, rhs: StdDuration)
fn sub_assign(&mut self, rhs: StdDuration)
-= operation. Read moresource§impl SubAssign<Duration> for SystemTime
impl SubAssign<Duration> for SystemTime
source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read moresource§impl SubAssign for Duration
impl SubAssign for Duration
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more