[−][src]Struct cld::ClDuration
Command line duration
Notes
-
Display
implementation is only for human presentation. The result should not be parsed. -
Supported units for parsing from strings:
Unit Description ns
Nanosecond mc
Microsecond ms
Millisecond s
Second m
Minute h
Hour d
Day w
Week
Examples
use core::{ str::FromStr, time::Duration, }; use cld::ClDuration; assert_eq!(ClDuration::from_str("9s").unwrap(), Duration::from_secs(9)); assert_eq!(ClDuration::from_str("2d").unwrap(), Duration::from_secs(60 * 60 * 24 * 2));
Methods
impl ClDuration
[src]
Methods from Deref<Target = Duration>
pub const SECOND: Duration
[src]
pub const MILLISECOND: Duration
[src]
pub const MICROSECOND: Duration
[src]
pub const NANOSECOND: Duration
[src]
pub const 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 const fn subsec_millis(&self) -> u32
1.27.0[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).
Examples
use std::time::Duration; let duration = Duration::from_millis(5432); assert_eq!(duration.as_secs(), 5); assert_eq!(duration.subsec_millis(), 432);
pub const fn subsec_micros(&self) -> u32
1.27.0[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).
Examples
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 const 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);
pub const fn as_millis(&self) -> u128
1.33.0[src]
Returns the total number of whole milliseconds contained by this Duration
.
Examples
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(duration.as_millis(), 5730);
pub const fn as_micros(&self) -> u128
1.33.0[src]
Returns the total number of whole microseconds contained by this Duration
.
Examples
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(duration.as_micros(), 5730023);
pub const fn as_nanos(&self) -> u128
1.33.0[src]
Returns the total number of nanoseconds contained by this Duration
.
Examples
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(duration.as_nanos(), 5730023852);
pub fn as_secs_f64(&self) -> f64
1.38.0[src]
Returns the number of seconds contained by this Duration
as f64
.
The returned value does include the fractional (nanosecond) part of the duration.
Examples
use std::time::Duration; let dur = Duration::new(2, 700_000_000); assert_eq!(dur.as_secs_f64(), 2.7);
pub fn as_secs_f32(&self) -> f32
1.38.0[src]
Returns the number of seconds contained by this Duration
as f32
.
The returned value does include the fractional (nanosecond) part of the duration.
Examples
use std::time::Duration; let dur = Duration::new(2, 700_000_000); assert_eq!(dur.as_secs_f32(), 2.7);
Trait Implementations
impl From<ClDuration> for Duration
[src]
fn from(cld: ClDuration) -> Self
[src]
impl From<Duration> for ClDuration
[src]
impl Display for ClDuration
[src]
impl Debug for ClDuration
[src]
impl PartialEq<ClDuration> for ClDuration
[src]
fn eq(&self, other: &ClDuration) -> bool
[src]
fn ne(&self, other: &ClDuration) -> bool
[src]
impl PartialEq<ClDuration> for Duration
[src]
impl PartialEq<Duration> for ClDuration
[src]
fn eq(&self, duration: &Duration) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl Eq for ClDuration
[src]
impl Ord for ClDuration
[src]
fn cmp(&self, other: &ClDuration) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialOrd<ClDuration> for ClDuration
[src]
fn partial_cmp(&self, other: &ClDuration) -> Option<Ordering>
[src]
fn lt(&self, other: &ClDuration) -> bool
[src]
fn le(&self, other: &ClDuration) -> bool
[src]
fn gt(&self, other: &ClDuration) -> bool
[src]
fn ge(&self, other: &ClDuration) -> bool
[src]
impl PartialOrd<Duration> for ClDuration
[src]
fn partial_cmp(&self, duration: &Duration) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<ClDuration> for Duration
[src]
fn partial_cmp(&self, cld: &ClDuration) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl FromStr for ClDuration
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Deref for ClDuration
[src]
impl Hash for ClDuration
[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,
impl StructuralPartialEq for ClDuration
[src]
impl StructuralEq for ClDuration
[src]
Auto Trait Implementations
impl Unpin for ClDuration
impl Send for ClDuration
impl Sync for ClDuration
impl UnwindSafe for ClDuration
impl RefUnwindSafe for ClDuration
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
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, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,