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
sourcepub const fn from_millis(ms: u128) -> Self
pub const fn from_millis(ms: u128) -> Self
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.
sourcepub fn format_exact(self) -> ExactDisplay
pub fn format_exact(self) -> ExactDisplay
Returns a struct with a lossless Display implementation.
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: StdDuration)
fn add_assign(&mut self, rhs: StdDuration)
+=
operation. Read moresource§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 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 StdDuration
impl PartialEq<Duration> for StdDuration
source§impl PartialOrd for Duration
impl PartialOrd for Duration
source§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: StdDuration)
fn sub_assign(&mut self, rhs: StdDuration)
-=
operation. Read moresource§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 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 moresource§impl ValueParserFactory for Duration
impl ValueParserFactory for Duration
source§type Parser = DurationParser
type Parser = DurationParser
ValueParser
. Read moresource§fn value_parser() -> Self::Parser
fn value_parser() -> Self::Parser
Self::Parser
impl Copy for Duration
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)