Skip to main content

DurationCalibration

Trait DurationCalibration 

Source
pub trait DurationCalibration<D> {
    // Required methods
    fn convert_to_ns(&self, d: D) -> u64;
    fn convert_from_ns(&self, ns: u64) -> D;

    // Provided methods
    fn to_std(&self, d: D) -> Duration
       where Self: Sized { ... }
    fn convert_from_std(&self, d: Duration) -> D
       where Self: Sized { ... }
}
Expand description

Converts a clock’s native duration type to and from nanoseconds.

Required Methods§

Source

fn convert_to_ns(&self, d: D) -> u64

Converts a duration to nanoseconds, rounding to the nearest nanosecond.

Source

fn convert_from_ns(&self, ns: u64) -> D

Converts a nanosecond value to this clock’s native duration type.

Provided Methods§

Source

fn to_std(&self, d: D) -> Duration
where Self: Sized,

Source

fn convert_from_std(&self, d: Duration) -> D
where Self: Sized,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§