Skip to main content

Duration

Struct Duration 

Source
pub struct Duration<T, const NOM: u64, const DENOM: u64> { /* private fields */ }
Expand description

Reexport fugit Represents a duration of time.

The generic T can either be u32 or u64, and the const generics represent the ratio of the ticks contained within the duration: duration in seconds = NOM / DENOM * ticks

Implementations§

Source§

impl<const NOM: u64, const DENOM: u64> Duration<u32, NOM, DENOM>

Source

pub const ZERO: Duration<u32, NOM, DENOM>

A duration of zero time.

let d = Duration::<u32, 1, 1_000>::ZERO;

assert_eq!(d.as_ticks(), 0);
assert!(d.is_zero());
Source

pub const MAX: Duration<u32, NOM, DENOM>

The maximum duration.

let d = Duration::<u32, 1, 1_000>::MAX;

assert_eq!(d.as_ticks(), u32::MAX);
Source

pub const fn from_ticks(ticks: u32) -> Duration<u32, NOM, DENOM>

Create a Duration from a ticks value.

let _d = Duration::<u32, 1, 1_000>::from_ticks(1);
Source

pub const fn as_ticks(&self) -> u32

Extract the ticks from a Duration.

let d = Duration::<u32, 1, 1_000>::from_ticks(234);

assert_eq!(d.as_ticks(), 234);
Source

pub const fn is_zero(&self) -> bool

Returns true if this Duration spans no time

let zero = Duration::<u32, 1, 1_000>::from_ticks(0);
let one = Duration::<u32, 1, 1_000>::from_ticks(1);

assert_eq!(zero.is_zero(), true);
assert_eq!(one.is_zero(), false);
Source

pub const fn checked_add<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u32, O_NOM, O_DENOM>, ) -> Option<Duration<u32, NOM, DENOM>>

Add two durations.

Returns None on tick overflow or cross-base conversion overflow.

let d1 = Duration::<u32, 1, 1_000>::from_ticks(1);
let d2 = Duration::<u32, 1, 1_000>::from_ticks(2);
let d3 = Duration::<u32, 1, 1_000>::from_ticks(u32::MAX);

assert_eq!(d1.checked_add(d2).unwrap().as_ticks(), 3);
assert_eq!(d1.checked_add(d3), None);
Source

pub const fn checked_sub<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u32, O_NOM, O_DENOM>, ) -> Option<Duration<u32, NOM, DENOM>>

Subtract two durations.

Returns None on tick underflow or cross-base conversion overflow.

let d1 = Duration::<u32, 1, 1_000>::from_ticks(1);
let d2 = Duration::<u32, 1, 1_000>::from_ticks(2);
let d3 = Duration::<u32, 1, 1_000>::from_ticks(u32::MAX);

assert_eq!(d2.checked_sub(d1).unwrap().as_ticks(), 1);
assert_eq!(d1.checked_sub(d3), None);
Source

pub const fn checked_mul(self, rhs: u32) -> Option<Duration<u32, NOM, DENOM>>

Multiply this duration by an integer while checking for overflow.

let d = Duration::<u32, 1, 1_000>::from_ticks(10);

assert_eq!(d.checked_mul(3).unwrap().as_ticks(), 30);
assert_eq!(Duration::<u32, 1, 1_000>::MAX.checked_mul(2), None);
Source

pub const fn checked_div(self, rhs: u32) -> Option<Duration<u32, NOM, DENOM>>

Divide this duration by an integer while checking for division by zero.

let d = Duration::<u32, 1, 1_000>::from_ticks(30);

assert_eq!(d.checked_div(3).unwrap().as_ticks(), 10);
assert_eq!(Duration::<u32, 1, 1_000>::from_ticks(10).checked_div(0), None);
Source

pub const fn checked_rem<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u32, O_NOM, O_DENOM>, ) -> Option<Duration<u32, NOM, DENOM>>

Remainder of dividing two durations.

Returns None if other is zero or the cross-base conversion overflows.

let d1 = Duration::<u32, 1, 1_000>::from_ticks(10);
let d2 = Duration::<u32, 1, 1_000>::from_ticks(3);

assert_eq!(d1.checked_rem(d2).unwrap().as_ticks(), 1);
Source

pub const fn div_ceil(self, rhs: u32) -> Duration<u32, NOM, DENOM>

Divide this duration by an integer, rounding up (ceiling division).

let d = Duration::<u32, 1, 1_000>::from_ticks(31);

assert_eq!(d.div_ceil(3).as_ticks(), 11);
let d = Duration::<u32, 1, 1_000>::from_ticks(30);
assert_eq!(d.div_ceil(3).as_ticks(), 10);
§Panics

This function will panic if rhs is zero.

Source

pub const fn saturating_add<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u32, O_NOM, O_DENOM>, ) -> Duration<u32, NOM, DENOM>

Saturating duration addition. Computes self + other, saturating at the maximum value.

let d1 = Duration::<u32, 1, 1_000>::from_ticks(1);
let d2 = Duration::<u32, 1, 1_000>::from_ticks(2);

assert_eq!(d1.saturating_add(d2).as_ticks(), 3);
assert_eq!(Duration::<u32, 1, 1_000>::MAX.saturating_add(d1).as_ticks(), u32::MAX);
Source

pub const fn saturating_sub<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u32, O_NOM, O_DENOM>, ) -> Duration<u32, NOM, DENOM>

Saturating duration subtraction. Computes self - other, saturating at zero.

let d1 = Duration::<u32, 1, 1_000>::from_ticks(10);
let d2 = Duration::<u32, 1, 1_000>::from_ticks(2);

assert_eq!(d1.saturating_sub(d2).as_ticks(), 8);
assert_eq!(d2.saturating_sub(d1).as_ticks(), 0);
Source

pub const fn saturating_mul(self, rhs: u32) -> Duration<u32, NOM, DENOM>

Saturating duration multiplication. Computes self * rhs, saturating at the maximum value.

let d = Duration::<u32, 1, 1_000>::from_ticks(10);

assert_eq!(d.saturating_mul(3).as_ticks(), 30);
assert_eq!(Duration::<u32, 1, 1_000>::MAX.saturating_mul(2).as_ticks(), u32::MAX);
Source

pub const fn const_partial_cmp<const R_NOM: u64, const R_DENOM: u64>( self, other: Duration<u32, R_NOM, R_DENOM>, ) -> Option<Ordering>

Const partial comparison.

Returns None if either side’s tick value cannot be expressed in the common base without overflowing the storage type.

let d1 = Duration::<u32, 1, 100>::from_ticks(1);
let d2 = Duration::<u32, 1, 1_000>::from_ticks(1);

assert_eq!(d1.const_partial_cmp(d2), Some(core::cmp::Ordering::Greater));
Source

pub const fn const_eq<const R_NOM: u64, const R_DENOM: u64>( self, other: Duration<u32, R_NOM, R_DENOM>, ) -> bool

Const equality check.

Returns false (rather than panicking) if the cross-base conversion overflows the storage type.

let d1 = Duration::<u32, 1, 1_00>::from_ticks(1);
let d2 = Duration::<u32, 1, 1_000>::from_ticks(10);

assert!(d1.const_eq(d2));
Source

pub const fn const_try_from<const I_NOM: u64, const I_DENOM: u64>( duration: Duration<u32, I_NOM, I_DENOM>, ) -> Option<Duration<u32, NOM, DENOM>>

Const try from, checking for overflow.

let d1 = Duration::<u32, 1, 1_00>::from_ticks(1);
let d2 = Duration::<u32, 1, 1_000>::const_try_from(d1);

assert_eq!(d2.unwrap().as_ticks(), 10);
Source

pub const fn const_try_into<const O_NOM: u64, const O_DENOM: u64>( self, ) -> Option<Duration<u32, O_NOM, O_DENOM>>

Const try into, checking for overflow.

let d1 = Duration::<u32, 1, 1_00>::from_ticks(1);
let d2: Option<Duration::<u32, 1, 1_000>> = d1.const_try_into();

assert_eq!(d2.unwrap().as_ticks(), 10);
Source

pub const fn try_to_rate<const O_NOM: u64, const O_DENOM: u64>( self, ) -> Option<Rate<u32, O_NOM, O_DENOM>>

Convert to a rate. Returns None if this duration is zero.

let d1 = Duration::<u32, 1, 1_000>::from_ticks(2);
let r1: Option<Rate::<u32, 1, 1>> = d1.try_to_rate();

assert_eq!(r1.unwrap().to_raw(), 500);
Source

pub const fn to_rate<const O_NOM: u64, const O_DENOM: u64>( self, ) -> Rate<u32, O_NOM, O_DENOM>

Convert to a rate. Panics if this duration is zero.

Source

pub const fn try_from_rate<const I_NOM: u64, const I_DENOM: u64>( rate: Rate<u32, I_NOM, I_DENOM>, ) -> Option<Duration<u32, NOM, DENOM>>

Convert from a rate. Returns None if the rate is zero.

let r1 = Rate::<u32, 1, 1>::from_raw(1);
let d1 = Duration::<u32, 1, 1_000>::try_from_rate(r1);

assert_eq!(d1.unwrap().as_ticks(), 1_000);
Source

pub const fn from_rate<const I_NOM: u64, const I_DENOM: u64>( rate: Rate<u32, I_NOM, I_DENOM>, ) -> Duration<u32, NOM, DENOM>

Convert from a rate. Panics if the rate is zero.

Source

pub const fn convert<const O_NOM: u64, const O_DENOM: u64>( self, ) -> Duration<u32, O_NOM, O_DENOM>

Convert between bases for a duration, rounds to nearest.

Unfortunately not a From impl due to collision with the std lib.

let d1 = Duration::<u32, 1, 100>::from_ticks(1);
let d2: Duration::<u32, 1, 1_000> = d1.convert();

assert_eq!(d2.as_ticks(), 10);

Can be used in const contexts. Compilation will fail if the conversion causes overflow

const TICKS: u32= u32::MAX - 10;
const D1: Duration::<u32, 1, 100> = Duration::<u32, 1, 100>::from_ticks(TICKS);
// Fails conversion due to tick overflow
const D2: Duration::<u32, 1, 200> = D1.convert();
Source

pub const fn as_picos(&self) -> u32

Convert the Duration to an integer number of picoseconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_picos(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of picoseconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_picos_at_least(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of picoseconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn as_nanos(&self) -> u32

Convert the Duration to an integer number of nanoseconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_nanos(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of nanoseconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_nanos_at_least(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of nanoseconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn as_micros(&self) -> u32

Convert the Duration to an integer number of microseconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_micros(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of microseconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_micros_at_least(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of microseconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn as_millis(&self) -> u32

Convert the Duration to an integer number of milliseconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_millis(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of milliseconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_millis_at_least(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of milliseconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn as_secs(&self) -> u32

Convert the Duration to an integer number of seconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_secs(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of seconds.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_secs_at_least(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of seconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn as_minutes(&self) -> u32

Convert the Duration to an integer number of minutes.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_minutes(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of minutes.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_minutes_at_least(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of minutes (ceil rounded).

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn as_hours(&self) -> u32

Convert the Duration to an integer number of hours.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_hours(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of hours.

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn from_hours_at_least(val: u32) -> Duration<u32, NOM, DENOM>

Create a duration from a number of hours (ceil rounded).

Compile-time error if the conversion constants don’t fit in u32. Panics if the multiplication overflows u32.

Source

pub const fn as_secs_f32(&self) -> f32

Convert the Duration to a floating point number of seconds.

Source

pub const fn as_secs_f64(&self) -> f64

Convert the Duration to a floating point number of seconds.

Source

pub const fn from_secs_f32(secs: f32) -> Duration<u32, NOM, DENOM>

Create a duration from a floating point number of seconds.

The value is rounded to the nearest tick.

let d = Duration::<u32, 1, 1_000>::from_secs_f32(1.5);

assert_eq!(d.as_ticks(), 1_500);

let d = Duration::<u32, 1, 1_000>::from_secs_f32(1.5005);
assert_eq!(d.as_ticks(), 1_501);
Source

pub const fn from_secs_f64(secs: f64) -> Duration<u32, NOM, DENOM>

Create a duration from a floating point number of seconds.

The value is rounded to the nearest tick.

let d = Duration::<u32, 1, 1_000>::from_secs_f64(1.5);

assert_eq!(d.as_ticks(), 1_500);

let d = Duration::<u32, 1, 1_000>::from_secs_f64(1.5005);
assert_eq!(d.as_ticks(), 1_501);
Source

pub const fn Hz(val: u32) -> Duration<u32, NOM, DENOM>

Period of a hertz rate. Panics if val is zero.

Source

pub const fn kHz(val: u32) -> Duration<u32, NOM, DENOM>

Period of a kilohertz rate. Panics if val is zero.

Source

pub const fn MHz(val: u32) -> Duration<u32, NOM, DENOM>

Period of a megahertz rate. Panics if val is zero.

Source§

impl<const NOM: u64, const DENOM: u64> Duration<u64, NOM, DENOM>

Source

pub const ZERO: Duration<u64, NOM, DENOM>

A duration of zero time.

let d = Duration::<u64, 1, 1_000>::ZERO;

assert_eq!(d.as_ticks(), 0);
assert!(d.is_zero());
Source

pub const MAX: Duration<u64, NOM, DENOM>

The maximum duration.

let d = Duration::<u64, 1, 1_000>::MAX;

assert_eq!(d.as_ticks(), u64::MAX);
Source

pub const fn from_ticks(ticks: u64) -> Duration<u64, NOM, DENOM>

Create a Duration from a ticks value.

let _d = Duration::<u64, 1, 1_000>::from_ticks(1);
Source

pub const fn as_ticks(&self) -> u64

Extract the ticks from a Duration.

let d = Duration::<u64, 1, 1_000>::from_ticks(234);

assert_eq!(d.as_ticks(), 234);
Source

pub const fn is_zero(&self) -> bool

Returns true if this Duration spans no time

let zero = Duration::<u64, 1, 1_000>::from_ticks(0);
let one = Duration::<u64, 1, 1_000>::from_ticks(1);

assert_eq!(zero.is_zero(), true);
assert_eq!(one.is_zero(), false);
Source

pub const fn checked_add<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u64, O_NOM, O_DENOM>, ) -> Option<Duration<u64, NOM, DENOM>>

Add two durations.

Returns None on tick overflow or cross-base conversion overflow.

let d1 = Duration::<u64, 1, 1_000>::from_ticks(1);
let d2 = Duration::<u64, 1, 1_000>::from_ticks(2);
let d3 = Duration::<u64, 1, 1_000>::from_ticks(u64::MAX);

assert_eq!(d1.checked_add(d2).unwrap().as_ticks(), 3);
assert_eq!(d1.checked_add(d3), None);
Source

pub const fn checked_sub<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u64, O_NOM, O_DENOM>, ) -> Option<Duration<u64, NOM, DENOM>>

Subtract two durations.

Returns None on tick underflow or cross-base conversion overflow.

let d1 = Duration::<u64, 1, 1_000>::from_ticks(1);
let d2 = Duration::<u64, 1, 1_000>::from_ticks(2);
let d3 = Duration::<u64, 1, 1_000>::from_ticks(u64::MAX);

assert_eq!(d2.checked_sub(d1).unwrap().as_ticks(), 1);
assert_eq!(d1.checked_sub(d3), None);
Source

pub const fn checked_mul(self, rhs: u64) -> Option<Duration<u64, NOM, DENOM>>

Multiply this duration by an integer while checking for overflow.

let d = Duration::<u64, 1, 1_000>::from_ticks(10);

assert_eq!(d.checked_mul(3).unwrap().as_ticks(), 30);
assert_eq!(Duration::<u64, 1, 1_000>::MAX.checked_mul(2), None);
Source

pub const fn checked_div(self, rhs: u64) -> Option<Duration<u64, NOM, DENOM>>

Divide this duration by an integer while checking for division by zero.

let d = Duration::<u64, 1, 1_000>::from_ticks(30);

assert_eq!(d.checked_div(3).unwrap().as_ticks(), 10);
assert_eq!(Duration::<u64, 1, 1_000>::from_ticks(10).checked_div(0), None);
Source

pub const fn checked_rem<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u64, O_NOM, O_DENOM>, ) -> Option<Duration<u64, NOM, DENOM>>

Remainder of dividing two durations.

Returns None if other is zero or the cross-base conversion overflows.

let d1 = Duration::<u64, 1, 1_000>::from_ticks(10);
let d2 = Duration::<u64, 1, 1_000>::from_ticks(3);

assert_eq!(d1.checked_rem(d2).unwrap().as_ticks(), 1);
Source

pub const fn div_ceil(self, rhs: u64) -> Duration<u64, NOM, DENOM>

Divide this duration by an integer, rounding up (ceiling division).

let d = Duration::<u64, 1, 1_000>::from_ticks(31);

assert_eq!(d.div_ceil(3).as_ticks(), 11);
let d = Duration::<u64, 1, 1_000>::from_ticks(30);
assert_eq!(d.div_ceil(3).as_ticks(), 10);
§Panics

This function will panic if rhs is zero.

Source

pub const fn saturating_add<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u64, O_NOM, O_DENOM>, ) -> Duration<u64, NOM, DENOM>

Saturating duration addition. Computes self + other, saturating at the maximum value.

let d1 = Duration::<u64, 1, 1_000>::from_ticks(1);
let d2 = Duration::<u64, 1, 1_000>::from_ticks(2);

assert_eq!(d1.saturating_add(d2).as_ticks(), 3);
assert_eq!(Duration::<u64, 1, 1_000>::MAX.saturating_add(d1).as_ticks(), u64::MAX);
Source

pub const fn saturating_sub<const O_NOM: u64, const O_DENOM: u64>( self, other: Duration<u64, O_NOM, O_DENOM>, ) -> Duration<u64, NOM, DENOM>

Saturating duration subtraction. Computes self - other, saturating at zero.

let d1 = Duration::<u64, 1, 1_000>::from_ticks(10);
let d2 = Duration::<u64, 1, 1_000>::from_ticks(2);

assert_eq!(d1.saturating_sub(d2).as_ticks(), 8);
assert_eq!(d2.saturating_sub(d1).as_ticks(), 0);
Source

pub const fn saturating_mul(self, rhs: u64) -> Duration<u64, NOM, DENOM>

Saturating duration multiplication. Computes self * rhs, saturating at the maximum value.

let d = Duration::<u64, 1, 1_000>::from_ticks(10);

assert_eq!(d.saturating_mul(3).as_ticks(), 30);
assert_eq!(Duration::<u64, 1, 1_000>::MAX.saturating_mul(2).as_ticks(), u64::MAX);
Source

pub const fn const_partial_cmp<const R_NOM: u64, const R_DENOM: u64>( self, other: Duration<u64, R_NOM, R_DENOM>, ) -> Option<Ordering>

Const partial comparison.

Returns None if either side’s tick value cannot be expressed in the common base without overflowing the storage type.

let d1 = Duration::<u64, 1, 100>::from_ticks(1);
let d2 = Duration::<u64, 1, 1_000>::from_ticks(1);

assert_eq!(d1.const_partial_cmp(d2), Some(core::cmp::Ordering::Greater));
Source

pub const fn const_eq<const R_NOM: u64, const R_DENOM: u64>( self, other: Duration<u64, R_NOM, R_DENOM>, ) -> bool

Const equality check.

Returns false (rather than panicking) if the cross-base conversion overflows the storage type.

let d1 = Duration::<u64, 1, 1_00>::from_ticks(1);
let d2 = Duration::<u64, 1, 1_000>::from_ticks(10);

assert!(d1.const_eq(d2));
Source

pub const fn const_try_from<const I_NOM: u64, const I_DENOM: u64>( duration: Duration<u64, I_NOM, I_DENOM>, ) -> Option<Duration<u64, NOM, DENOM>>

Const try from, checking for overflow.

let d1 = Duration::<u64, 1, 1_00>::from_ticks(1);
let d2 = Duration::<u64, 1, 1_000>::const_try_from(d1);

assert_eq!(d2.unwrap().as_ticks(), 10);
Source

pub const fn const_try_into<const O_NOM: u64, const O_DENOM: u64>( self, ) -> Option<Duration<u64, O_NOM, O_DENOM>>

Const try into, checking for overflow.

let d1 = Duration::<u64, 1, 1_00>::from_ticks(1);
let d2: Option<Duration::<u64, 1, 1_000>> = d1.const_try_into();

assert_eq!(d2.unwrap().as_ticks(), 10);
Source

pub const fn try_to_rate<const O_NOM: u64, const O_DENOM: u64>( self, ) -> Option<Rate<u64, O_NOM, O_DENOM>>

Convert to a rate. Returns None if this duration is zero.

let d1 = Duration::<u64, 1, 1_000>::from_ticks(2);
let r1: Option<Rate::<u64, 1, 1>> = d1.try_to_rate();

assert_eq!(r1.unwrap().to_raw(), 500);
Source

pub const fn to_rate<const O_NOM: u64, const O_DENOM: u64>( self, ) -> Rate<u64, O_NOM, O_DENOM>

Convert to a rate. Panics if this duration is zero.

Source

pub const fn try_from_rate<const I_NOM: u64, const I_DENOM: u64>( rate: Rate<u64, I_NOM, I_DENOM>, ) -> Option<Duration<u64, NOM, DENOM>>

Convert from a rate. Returns None if the rate is zero.

let r1 = Rate::<u64, 1, 1>::from_raw(1);
let d1 = Duration::<u64, 1, 1_000>::try_from_rate(r1);

assert_eq!(d1.unwrap().as_ticks(), 1_000);
Source

pub const fn from_rate<const I_NOM: u64, const I_DENOM: u64>( rate: Rate<u64, I_NOM, I_DENOM>, ) -> Duration<u64, NOM, DENOM>

Convert from a rate. Panics if the rate is zero.

Source

pub const fn convert<const O_NOM: u64, const O_DENOM: u64>( self, ) -> Duration<u64, O_NOM, O_DENOM>

Convert between bases for a duration, rounds to nearest.

Unfortunately not a From impl due to collision with the std lib.

let d1 = Duration::<u64, 1, 100>::from_ticks(1);
let d2: Duration::<u64, 1, 1_000> = d1.convert();

assert_eq!(d2.as_ticks(), 10);

Can be used in const contexts. Compilation will fail if the conversion causes overflow

const TICKS: u64= u64::MAX - 10;
const D1: Duration::<u64, 1, 100> = Duration::<u64, 1, 100>::from_ticks(TICKS);
// Fails conversion due to tick overflow
const D2: Duration::<u64, 1, 200> = D1.convert();
Source

pub const fn as_picos(&self) -> u64

Convert the Duration to an integer number of picoseconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_picos(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of picoseconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_picos_at_least(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of picoseconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn as_nanos(&self) -> u64

Convert the Duration to an integer number of nanoseconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_nanos(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of nanoseconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_nanos_at_least(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of nanoseconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn as_micros(&self) -> u64

Convert the Duration to an integer number of microseconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_micros(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of microseconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_micros_at_least(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of microseconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn as_millis(&self) -> u64

Convert the Duration to an integer number of milliseconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_millis(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of milliseconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_millis_at_least(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of milliseconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn as_secs(&self) -> u64

Convert the Duration to an integer number of seconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_secs(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of seconds.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_secs_at_least(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of seconds (ceil rounded).

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn as_minutes(&self) -> u64

Convert the Duration to an integer number of minutes.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_minutes(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of minutes.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_minutes_at_least(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of minutes (ceil rounded).

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn as_hours(&self) -> u64

Convert the Duration to an integer number of hours.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_hours(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of hours.

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn from_hours_at_least(val: u64) -> Duration<u64, NOM, DENOM>

Create a duration from a number of hours (ceil rounded).

Compile-time error if the conversion constants don’t fit in u64. Panics if the multiplication overflows u64.

Source

pub const fn as_secs_f32(&self) -> f32

Convert the Duration to a floating point number of seconds.

Source

pub const fn as_secs_f64(&self) -> f64

Convert the Duration to a floating point number of seconds.

Source

pub const fn from_secs_f32(secs: f32) -> Duration<u64, NOM, DENOM>

Create a duration from a floating point number of seconds.

The value is rounded to the nearest tick.

let d = Duration::<u64, 1, 1_000>::from_secs_f32(1.5);

assert_eq!(d.as_ticks(), 1_500);

let d = Duration::<u64, 1, 1_000>::from_secs_f32(1.5005);
assert_eq!(d.as_ticks(), 1_501);
Source

pub const fn from_secs_f64(secs: f64) -> Duration<u64, NOM, DENOM>

Create a duration from a floating point number of seconds.

The value is rounded to the nearest tick.

let d = Duration::<u64, 1, 1_000>::from_secs_f64(1.5);

assert_eq!(d.as_ticks(), 1_500);

let d = Duration::<u64, 1, 1_000>::from_secs_f64(1.5005);
assert_eq!(d.as_ticks(), 1_501);
Source

pub const fn Hz(val: u64) -> Duration<u64, NOM, DENOM>

Period of a hertz rate. Panics if val is zero.

Source

pub const fn kHz(val: u64) -> Duration<u64, NOM, DENOM>

Period of a kilohertz rate. Panics if val is zero.

Source

pub const fn MHz(val: u64) -> Duration<u64, NOM, DENOM>

Period of a megahertz rate. Panics if val is zero.

Trait Implementations§

Source§

impl<const NOM: u64, const DENOM: u64> Add<Duration<u32, NOM, DENOM>> for Duration<u64, NOM, DENOM>

Source§

type Output = Duration<u64, NOM, DENOM>

The resulting type after applying the + operator.
Source§

fn add( self, other: Duration<u32, NOM, DENOM>, ) -> <Duration<u64, NOM, DENOM> as Add<Duration<u32, NOM, DENOM>>>::Output

Performs the + operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Add<Duration<u32, NOM, DENOM>> for Instant<u32, NOM, DENOM>

Source§

type Output = Instant<u32, NOM, DENOM>

The resulting type after applying the + operator.
Source§

fn add( self, other: Duration<u32, NOM, DENOM>, ) -> <Instant<u32, NOM, DENOM> as Add<Duration<u32, NOM, DENOM>>>::Output

Performs the + operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Add<Duration<u32, NOM, DENOM>> for Instant<u64, NOM, DENOM>

Source§

type Output = Instant<u64, NOM, DENOM>

The resulting type after applying the + operator.
Source§

fn add( self, other: Duration<u32, NOM, DENOM>, ) -> <Instant<u64, NOM, DENOM> as Add<Duration<u32, NOM, DENOM>>>::Output

Performs the + operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Add<Duration<u64, NOM, DENOM>> for Instant<u64, NOM, DENOM>

Source§

type Output = Instant<u64, NOM, DENOM>

The resulting type after applying the + operator.
Source§

fn add( self, other: Duration<u64, NOM, DENOM>, ) -> <Instant<u64, NOM, DENOM> as Add<Duration<u64, NOM, DENOM>>>::Output

Performs the + operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Add for Duration<u32, NOM, DENOM>

Source§

type Output = Duration<u32, NOM, DENOM>

The resulting type after applying the + operator.
Source§

fn add( self, other: Duration<u32, NOM, DENOM>, ) -> <Duration<u32, NOM, DENOM> as Add>::Output

Performs the + operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Add for Duration<u64, NOM, DENOM>

Source§

type Output = Duration<u64, NOM, DENOM>

The resulting type after applying the + operator.
Source§

fn add( self, other: Duration<u64, NOM, DENOM>, ) -> <Duration<u64, NOM, DENOM> as Add>::Output

Performs the + operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> AddAssign<Duration<u32, NOM, DENOM>> for Duration<u64, NOM, DENOM>

Source§

fn add_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the += operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> AddAssign<Duration<u32, NOM, DENOM>> for Instant<u32, NOM, DENOM>

Source§

fn add_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the += operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> AddAssign<Duration<u32, NOM, DENOM>> for Instant<u64, NOM, DENOM>

Source§

fn add_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the += operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> AddAssign<Duration<u64, NOM, DENOM>> for Instant<u64, NOM, DENOM>

Source§

fn add_assign(&mut self, other: Duration<u64, NOM, DENOM>)

Performs the += operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> AddAssign for Duration<u32, NOM, DENOM>

Source§

fn add_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the += operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> AddAssign for Duration<u64, NOM, DENOM>

Source§

fn add_assign(&mut self, other: Duration<u64, NOM, DENOM>)

Performs the += operation. Read more
Source§

impl<T, const NOM: u64, const DENOM: u64> Clone for Duration<T, NOM, DENOM>
where T: Clone,

Source§

fn clone(&self) -> Duration<T, NOM, DENOM>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, const NOM: u64, const DENOM: u64> Debug for Duration<T, NOM, DENOM>
where T: Debug,

Source§

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

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

impl<const NOM: u64, const DENOM: u64> Display for Duration<u32, NOM, DENOM>

Source§

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

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

impl<const NOM: u64, const DENOM: u64> Display for Duration<u64, NOM, DENOM>

Source§

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

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

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> Div<Duration<u32, R_NOM, R_DENOM>> for Duration<u32, L_NOM, L_DENOM>

Source§

type Output = u32

The resulting type after applying the / operator.
Source§

fn div( self, other: Duration<u32, R_NOM, R_DENOM>, ) -> <Duration<u32, L_NOM, L_DENOM> as Div<Duration<u32, R_NOM, R_DENOM>>>::Output

Performs the / operation. Read more
Source§

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> Div<Duration<u64, R_NOM, R_DENOM>> for Duration<u64, L_NOM, L_DENOM>

Source§

type Output = u64

The resulting type after applying the / operator.
Source§

fn div( self, other: Duration<u64, R_NOM, R_DENOM>, ) -> <Duration<u64, L_NOM, L_DENOM> as Div<Duration<u64, R_NOM, R_DENOM>>>::Output

Performs the / operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Div<u32> for Duration<u32, NOM, DENOM>

Source§

type Output = Duration<u32, NOM, DENOM>

The resulting type after applying the / operator.
Source§

fn div(self, other: u32) -> <Duration<u32, NOM, DENOM> as Div<u32>>::Output

Performs the / operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Div<u32> for Duration<u64, NOM, DENOM>

Source§

type Output = Duration<u64, NOM, DENOM>

The resulting type after applying the / operator.
Source§

fn div(self, other: u32) -> <Duration<u64, NOM, DENOM> as Div<u32>>::Output

Performs the / operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> DivAssign<u32> for Duration<u32, NOM, DENOM>

Source§

fn div_assign(&mut self, other: u32)

Performs the /= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> DivAssign<u32> for Duration<u64, NOM, DENOM>

Source§

fn div_assign(&mut self, other: u32)

Performs the /= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> From<Duration<u32, NOM, DENOM>> for Duration<u64, NOM, DENOM>

Source§

fn from(val: Duration<u32, NOM, DENOM>) -> Duration<u64, NOM, DENOM>

Converts to this type from the input type.
Source§

impl<const NOM: u64, const DENOM: u64> Mul<u32> for Duration<u32, NOM, DENOM>

Source§

type Output = Duration<u32, NOM, DENOM>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u32) -> <Duration<u32, NOM, DENOM> as Mul<u32>>::Output

Performs the * operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Mul<u32> for Duration<u64, NOM, DENOM>

Source§

type Output = Duration<u64, NOM, DENOM>

The resulting type after applying the * operator.
Source§

fn mul(self, other: u32) -> <Duration<u64, NOM, DENOM> as Mul<u32>>::Output

Performs the * operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> MulAssign<u32> for Duration<u32, NOM, DENOM>

Source§

fn mul_assign(&mut self, other: u32)

Performs the *= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> MulAssign<u32> for Duration<u64, NOM, DENOM>

Source§

fn mul_assign(&mut self, other: u32)

Performs the *= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Ord for Duration<u32, NOM, DENOM>

Source§

fn cmp(&self, other: &Duration<u32, NOM, DENOM>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl<const NOM: u64, const DENOM: u64> Ord for Duration<u64, NOM, DENOM>

Source§

fn cmp(&self, other: &Duration<u64, NOM, DENOM>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> PartialEq<Duration<u32, R_NOM, R_DENOM>> for Duration<u32, L_NOM, L_DENOM>

Source§

fn eq(&self, other: &Duration<u32, R_NOM, R_DENOM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> PartialEq<Duration<u32, R_NOM, R_DENOM>> for Duration<u64, L_NOM, L_DENOM>

Source§

fn eq(&self, other: &Duration<u32, R_NOM, R_DENOM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> PartialEq<Duration<u64, R_NOM, R_DENOM>> for Duration<u32, L_NOM, L_DENOM>

Source§

fn eq(&self, other: &Duration<u64, R_NOM, R_DENOM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> PartialEq<Duration<u64, R_NOM, R_DENOM>> for Duration<u64, L_NOM, L_DENOM>

Source§

fn eq(&self, other: &Duration<u64, R_NOM, R_DENOM>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> PartialOrd<Duration<u32, R_NOM, R_DENOM>> for Duration<u32, L_NOM, L_DENOM>

Source§

fn partial_cmp(&self, other: &Duration<u32, R_NOM, R_DENOM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> PartialOrd<Duration<u32, R_NOM, R_DENOM>> for Duration<u64, L_NOM, L_DENOM>

Source§

fn partial_cmp(&self, other: &Duration<u32, R_NOM, R_DENOM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> PartialOrd<Duration<u64, R_NOM, R_DENOM>> for Duration<u32, L_NOM, L_DENOM>

Source§

fn partial_cmp(&self, other: &Duration<u64, R_NOM, R_DENOM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<const L_NOM: u64, const L_DENOM: u64, const R_NOM: u64, const R_DENOM: u64> PartialOrd<Duration<u64, R_NOM, R_DENOM>> for Duration<u64, L_NOM, L_DENOM>

Source§

fn partial_cmp(&self, other: &Duration<u64, R_NOM, R_DENOM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Rem for Duration<u32, NOM, DENOM>

Source§

type Output = Duration<u32, NOM, DENOM>

The resulting type after applying the % operator.
Source§

fn rem( self, other: Duration<u32, NOM, DENOM>, ) -> <Duration<u32, NOM, DENOM> as Rem>::Output

Performs the % operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Rem for Duration<u64, NOM, DENOM>

Source§

type Output = Duration<u64, NOM, DENOM>

The resulting type after applying the % operator.
Source§

fn rem( self, other: Duration<u64, NOM, DENOM>, ) -> <Duration<u64, NOM, DENOM> as Rem>::Output

Performs the % operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> RemAssign for Duration<u32, NOM, DENOM>

Source§

fn rem_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the %= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> RemAssign for Duration<u64, NOM, DENOM>

Source§

fn rem_assign(&mut self, other: Duration<u64, NOM, DENOM>)

Performs the %= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Sub<Duration<u32, NOM, DENOM>> for Duration<u64, NOM, DENOM>

Source§

type Output = Duration<u64, NOM, DENOM>

The resulting type after applying the - operator.
Source§

fn sub( self, other: Duration<u32, NOM, DENOM>, ) -> <Duration<u64, NOM, DENOM> as Sub<Duration<u32, NOM, DENOM>>>::Output

Performs the - operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Sub<Duration<u32, NOM, DENOM>> for Instant<u32, NOM, DENOM>

Source§

type Output = Instant<u32, NOM, DENOM>

The resulting type after applying the - operator.
Source§

fn sub( self, other: Duration<u32, NOM, DENOM>, ) -> <Instant<u32, NOM, DENOM> as Sub<Duration<u32, NOM, DENOM>>>::Output

Performs the - operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Sub<Duration<u32, NOM, DENOM>> for Instant<u64, NOM, DENOM>

Source§

type Output = Instant<u64, NOM, DENOM>

The resulting type after applying the - operator.
Source§

fn sub( self, other: Duration<u32, NOM, DENOM>, ) -> <Instant<u64, NOM, DENOM> as Sub<Duration<u32, NOM, DENOM>>>::Output

Performs the - operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Sub<Duration<u64, NOM, DENOM>> for Instant<u64, NOM, DENOM>

Source§

type Output = Instant<u64, NOM, DENOM>

The resulting type after applying the - operator.
Source§

fn sub( self, other: Duration<u64, NOM, DENOM>, ) -> <Instant<u64, NOM, DENOM> as Sub<Duration<u64, NOM, DENOM>>>::Output

Performs the - operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Sub for Duration<u32, NOM, DENOM>

Source§

type Output = Duration<u32, NOM, DENOM>

The resulting type after applying the - operator.
Source§

fn sub( self, other: Duration<u32, NOM, DENOM>, ) -> <Duration<u32, NOM, DENOM> as Sub>::Output

Performs the - operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> Sub for Duration<u64, NOM, DENOM>

Source§

type Output = Duration<u64, NOM, DENOM>

The resulting type after applying the - operator.
Source§

fn sub( self, other: Duration<u64, NOM, DENOM>, ) -> <Duration<u64, NOM, DENOM> as Sub>::Output

Performs the - operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> SubAssign<Duration<u32, NOM, DENOM>> for Duration<u64, NOM, DENOM>

Source§

fn sub_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the -= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> SubAssign<Duration<u32, NOM, DENOM>> for Instant<u32, NOM, DENOM>

Source§

fn sub_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the -= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> SubAssign<Duration<u32, NOM, DENOM>> for Instant<u64, NOM, DENOM>

Source§

fn sub_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the -= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> SubAssign<Duration<u64, NOM, DENOM>> for Instant<u64, NOM, DENOM>

Source§

fn sub_assign(&mut self, other: Duration<u64, NOM, DENOM>)

Performs the -= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> SubAssign for Duration<u32, NOM, DENOM>

Source§

fn sub_assign(&mut self, other: Duration<u32, NOM, DENOM>)

Performs the -= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> SubAssign for Duration<u64, NOM, DENOM>

Source§

fn sub_assign(&mut self, other: Duration<u64, NOM, DENOM>)

Performs the -= operation. Read more
Source§

impl<const NOM: u64, const DENOM: u64> TryFrom<Duration<u64, NOM, DENOM>> for Duration<u32, NOM, DENOM>

Source§

type Error = ()

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

fn try_from( val: Duration<u64, NOM, DENOM>, ) -> Result<Duration<u32, NOM, DENOM>, ()>

Performs the conversion.
Source§

impl<const NOM: u64, const DENOM: u64> TryFrom<Duration> for Duration<u32, NOM, DENOM>

Source§

type Error = ()

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

fn try_from( val: Duration, ) -> Result<Duration<u32, NOM, DENOM>, <Duration<u32, NOM, DENOM> as TryFrom<Duration>>::Error>

Performs the conversion.
Source§

impl<const NOM: u64, const DENOM: u64> TryFrom<Duration> for Duration<u64, NOM, DENOM>

Source§

type Error = ()

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

fn try_from( val: Duration, ) -> Result<Duration<u64, NOM, DENOM>, <Duration<u64, NOM, DENOM> as TryFrom<Duration>>::Error>

Performs the conversion.
Source§

impl<T, const NOM: u64, const DENOM: u64> Copy for Duration<T, NOM, DENOM>
where T: Copy,

Source§

impl<const NOM: u64, const DENOM: u64> Eq for Duration<u32, NOM, DENOM>

Source§

impl<const NOM: u64, const DENOM: u64> Eq for Duration<u64, NOM, DENOM>

Auto Trait Implementations§

§

impl<T, const NOM: u64, const DENOM: u64> Freeze for Duration<T, NOM, DENOM>
where T: Freeze,

§

impl<T, const NOM: u64, const DENOM: u64> RefUnwindSafe for Duration<T, NOM, DENOM>
where T: RefUnwindSafe,

§

impl<T, const NOM: u64, const DENOM: u64> Send for Duration<T, NOM, DENOM>
where T: Send,

§

impl<T, const NOM: u64, const DENOM: u64> Sync for Duration<T, NOM, DENOM>
where T: Sync,

§

impl<T, const NOM: u64, const DENOM: u64> Unpin for Duration<T, NOM, DENOM>
where T: Unpin,

§

impl<T, const NOM: u64, const DENOM: u64> UnsafeUnpin for Duration<T, NOM, DENOM>
where T: UnsafeUnpin,

§

impl<T, const NOM: u64, const DENOM: u64> UnwindSafe for Duration<T, NOM, DENOM>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.