docs

You are reading the docs for v0.1.0. Nabi 0.1.0 is no longer supported. Latest release: v0.1.3 →

core::time

On this page

Duration / Instant. The wall and boot clocks are std::time. Every span between two readings is an exact signed Duration: an earlier minus a later one is negative, never an error or zero.

Structs

DurationSource

pub struct Duration

A span of time: i64 nanoseconds (about +/-292 years).

  • pub const fn ns<N>(n: N) -> Duration where i64: From<N>§

    Source

    n nanoseconds.

  • pub const fn us<N>(n: N) -> Duration where i64: From<N>§

    Source

    n microseconds; overflow panics where i64 * does, else saturates.

  • pub const fn ms<N>(n: N) -> Duration where i64: From<N>§

    Source

    n milliseconds; overflow panics where i64 * does, else saturates.

  • pub const fn secs<N>(n: N) -> Duration where i64: From<N>§

    Source

    n seconds; overflow panics where i64 * does, else saturates.

  • pub const fn mins<N>(n: N) -> Duration where i64: From<N>§

    Source

    n minutes; overflow panics where i64 * does, else saturates.

  • pub const fn hours<N>(n: N) -> Duration where i64: From<N>§

    Source

    n hours; overflow panics where i64 * does, else saturates.

  • pub const fn days<N>(n: N) -> Duration where i64: From<N>§

    Source

    n days of 24 hours; overflow panics where i64 * does, else saturates.

  • pub const ZERO: Duration = Duration { ns: 0 }§

    Source

    No time.

  • pub const MAX: Duration = Duration { ns: 9223372036854775807 }§

    Source

    The longest duration.

  • pub const fn secs_f64(s: f64) -> Duration§

    Source

    s seconds, truncated to whole nanoseconds. A non-finite or out-of-range result panics; with overflow checks off it saturates (NaN to zero).

  • pub const fn as_ns(self) -> i64§

    Source

    Whole nanoseconds.

  • pub const fn as_us(self) -> i64§

    Source

    Whole microseconds, truncated toward zero.

  • pub const fn as_ms(self) -> i64§

    Source

    Whole milliseconds, truncated toward zero.

  • pub const fn as_secs(self) -> i64§

    Source

    Whole seconds, truncated toward zero.

  • pub const fn as_secs_f64(self) -> f64§

    Source

    Seconds as an f64, fraction included.

  • pub const fn subsec_ns(self) -> u32§

    Source

    The part below one second (of the magnitude for a negative span).

  • pub const fn subsec_us(self) -> u32§

    Source

    subsec_ns in whole microseconds.

  • pub const fn subsec_ms(self) -> u32§

    Source

    subsec_ns in whole milliseconds.

  • pub const fn checked_add(self, rhs: Duration) -> Duration | none§

    Source

    self + rhs; none on overflow.

  • pub const fn checked_sub(self, rhs: Duration) -> Duration | none§

    Source

    self - rhs; none on overflow.

  • pub const fn checked_mul(self, factor: i64) -> Duration | none§

    Source

    self * factor; none on overflow.

  • pub const fn checked_div(self, divisor: i64) -> Duration | none§

    Source

    self / divisor; none when divisor is 0 or on overflow.

  • pub const fn saturating_add(self, rhs: Duration) -> Duration§

    Source

    self + rhs, clamped to the i64 nanosecond range.

  • pub const fn saturating_sub(self, rhs: Duration) -> Duration§

    Source

    self - rhs, clamped to the i64 nanosecond range.

  • pub const fn saturating_mul(self, factor: i64) -> Duration§

    Source

    self * factor, clamped to the i64 nanosecond range.

Trait implementations 7
  • impl Mul<i64> for Duration
  • impl Div<i64> for Duration
  • impl Default for Duration
  • impl Display for Duration
  • impl Debug for Duration
  • impl Add for Duration
  • impl Sub for Duration

InstantSource

pub struct Instant

A point on the monotonic clock; only meaningful within one process.

  • pub fn now() -> Instant§

    Source

    The current monotonic time.

  • pub fn elapsed(self) -> Duration§

    Source

    The time passed since self.

  • pub const fn duration_since(self, earlier: Instant) -> Duration§

    Source

    self - earlier, negative when earlier is later.

  • pub const fn checked_add(self, d: Duration) -> Instant | none§

    Source

    self + d; none on overflow.

  • pub const fn checked_sub(self, d: Duration) -> Instant | none§

    Source

    self - d; none on overflow.

Trait implementations 3