Enum hifitime::Unit

source ·
pub enum Unit {
    Nanosecond,
    Microsecond,
    Millisecond,
    Second,
    Minute,
    Hour,
    Day,
    Century,
}
Expand description

An Enum to perform time unit conversions.

Variants§

§

Nanosecond

§

Microsecond

§

Millisecond

§

Second

§

Minute

§

Hour

§

Day

§

Century

36525 days, is the number of days per century in the Julian calendar

Implementations§

source§

impl Unit

source

pub fn in_seconds(&self) -> f64

source

pub fn from_seconds(&self) -> f64

Trait Implementations§

source§

impl Add<Unit> for Duration

§

type Output = Duration

The resulting type after applying the + operator.
source§

fn add(self, rhs: Unit) -> Self

Performs the + operation. Read more
source§

impl Add<Unit> for Epoch

§

type Output = Epoch

The resulting type after applying the + operator.
source§

fn add(self, unit: Unit) -> Self

Performs the + operation. Read more
source§

impl Add for Unit

§

type Output = Duration

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Duration

Performs the + operation. Read more
source§

impl AddAssign<Unit> for Duration

source§

fn add_assign(&mut self, rhs: Unit)

Performs the += operation. Read more
source§

impl AddAssign<Unit> for Epoch

source§

fn add_assign(&mut self, unit: Unit)

Performs the += operation. Read more
source§

impl Clone for Unit

source§

fn clone(&self) -> Unit

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Unit

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Unit

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<&Unit> for u8

source§

fn from(unit: &Unit) -> Self

Converts to this type from the input type.
source§

impl From<Unit> for u8

Allows conversion of a Unit into a u8 with the following mapping. 0: Second; 1: Nanosecond; 2: Microsecond; 3: Millisecond; 4: Minute; 5: Hour; 6: Day; 7: Century

source§

fn from(unit: Unit) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Unit

Allows conversion of a u8 into a Unit. Defaults to Second if the u8 is not a valid Unit representation.

source§

fn from(val: u8) -> Self

Converts to this type from the input type.
source§

impl Mul<Unit> for f64

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, q: Unit) -> Duration

Performs the * operation. Read more
source§

impl Mul<Unit> for i64

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, q: Unit) -> Duration

Performs the * operation. Read more
source§

impl Mul<f64> for Unit

source§

fn mul(self, q: f64) -> Duration

Creates a duration from that f64

Limitations
  1. If the input value times the unit does not fit on a Duration, then Duration::MAX or Duration::MIN will be returned depending on whether the value would have overflowed or underflowed (respectively).
  2. Floating point operations may round differently on different processors. It’s advised to use integer initialization of Durations whenever possible.
§

type Output = Duration

The resulting type after applying the * operator.
source§

impl Mul<i64> for Unit

source§

fn mul(self, q: i64) -> Duration

Converts the input values to i128 and creates a duration from that This method will necessarily ignore durations below nanoseconds

§

type Output = Duration

The resulting type after applying the * operator.
source§

impl Ord for Unit

source§

fn cmp(&self, other: &Unit) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Unit> for Duration

source§

fn eq(&self, unit: &Unit) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Unit

source§

fn eq(&self, other: &Unit) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Unit> for Duration

source§

fn partial_cmp(&self, unit: &Unit) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd for Unit

source§

fn partial_cmp(&self, other: &Unit) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<Unit> for Duration

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Unit) -> Duration

Performs the - operation. Read more
source§

impl Sub<Unit> for Epoch

§

type Output = Epoch

The resulting type after applying the - operator.
source§

fn sub(self, unit: Unit) -> Self

Performs the - operation. Read more
source§

impl Sub for Unit

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Duration

Performs the - operation. Read more
source§

impl SubAssign<Unit> for Duration

source§

fn sub_assign(&mut self, rhs: Unit)

Performs the -= operation. Read more
source§

impl SubAssign<Unit> for Epoch

source§

fn sub_assign(&mut self, unit: Unit)

Performs the -= operation. Read more
source§

impl Copy for Unit

source§

impl Eq for Unit

source§

impl StructuralEq for Unit

source§

impl StructuralPartialEq for Unit

Auto Trait Implementations§

§

impl RefUnwindSafe for Unit

§

impl Send for Unit

§

impl Sync for Unit

§

impl Unpin for Unit

§

impl UnwindSafe for Unit

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.