[][src]Struct hifitime::Duration

pub struct Duration(_);

Defines generally usable durations for high precision math with Epoch (all data is stored in seconds)

Implementations

impl Duration[src]

pub fn from_days(days: Decimal) -> Self[src]

pub fn from_hours(hours: Decimal) -> Self[src]

pub fn from_minutes(minutes: Decimal) -> Self[src]

pub fn from_seconds(seconds: Decimal) -> Self[src]

pub fn from_milliseconds(ms: Decimal) -> Self[src]

pub fn from_microseconds(ms: Decimal) -> Self[src]

pub fn from_nanoseconds(ns: Decimal) -> Self[src]

pub fn from_f64(value: f64, unit: TimeUnit) -> Self[src]

Creates a new duration from the provided unit

pub fn from_fraction(num: i64, denom: i64, unit: TimeUnit) -> Self[src]

Creates a new duration from the provided fraction and unit

pub fn in_unit_f64(&self, unit: TimeUnit) -> f64[src]

Returns this duration in f64 in the provided unit. For high fidelity comparisons, it is recommended to keep using the Duration structure.

pub fn in_unit(&self, unit: TimeUnit) -> Decimal[src]

Returns the value of this duration in the requested unit.

Trait Implementations

impl Add<Duration> for Epoch[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<Duration> for Duration[src]

type Output = Duration

The resulting type after applying the + operator.

impl Add<TimeUnit> for Duration[src]

type Output = Duration

The resulting type after applying the + operator.

impl AddAssign<Duration> for Epoch[src]

impl AddAssign<Duration> for Duration[src]

impl AddAssign<TimeUnit> for Duration[src]

impl Clone for Duration[src]

impl Copy for Duration[src]

impl Debug for Duration[src]

impl Display for Duration[src]

impl Div<f32> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<f64> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<i16> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<i32> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<i64> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<i8> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<u128> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<u16> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<u32> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<u64> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl Div<u8> for Duration[src]

type Output = Duration

The resulting type after applying the / operator.

impl FromStr for Duration[src]

type Err = Errors

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Self, Self::Err>[src]

Attempts to convert a simple string to a Duration. Does not yet support complicated durations.

Identifiers: + d, days, day + h, hours, hour + min, mins, minute + s, second, seconds + ms, millisecond, milliseconds + us, microsecond, microseconds + ns, nanosecond, nanoseconds

Example

use hifitime::{Duration, TimeUnit};
use std::str::FromStr;

assert_eq!(Duration::from_str("1 d").unwrap(), TimeUnit::Day * 1);
assert_eq!(Duration::from_str("10.598 days").unwrap(), TimeUnit::Day * 10.598);
assert_eq!(Duration::from_str("10.598 min").unwrap(), TimeUnit::Minute * 10.598);
assert_eq!(Duration::from_str("10.598 us").unwrap(), TimeUnit::Microsecond * 10.598);
assert_eq!(Duration::from_str("10.598 seconds").unwrap(), TimeUnit::Second * 10.598);
assert_eq!(Duration::from_str("10.598 nanosecond").unwrap(), TimeUnit::Nanosecond * 10.598);

impl LowerExp for Duration[src]

impl Mul<Duration> for f32[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for f64[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for u128[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for u8[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for i8[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for u16[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for i16[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for u32[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for i32[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for u64[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<Duration> for i64[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<f32> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<f64> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<i16> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<i32> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<i64> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<i8> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<u128> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<u16> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<u32> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<u64> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl Mul<u8> for Duration[src]

type Output = Duration

The resulting type after applying the * operator.

impl PartialEq<Duration> for Duration[src]

impl PartialEq<TimeUnit> for Duration[src]

impl PartialOrd<Duration> for Duration[src]

impl PartialOrd<TimeUnit> for Duration[src]

impl StructuralPartialEq for Duration[src]

impl Sub<Duration> for Epoch[src]

type Output = Self

The resulting type after applying the - operator.

impl Sub<Duration> for Duration[src]

type Output = Duration

The resulting type after applying the - operator.

impl Sub<TimeUnit> for Duration[src]

type Output = Duration

The resulting type after applying the - operator.

impl SubAssign<Duration> for Epoch[src]

impl SubAssign<Duration> for Duration[src]

impl SubAssign<TimeUnit> for Duration[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,