nyx_space::cosmic

Trait Frequencies

pub trait Frequencies: Copy + Mul<Freq, Output = Duration> {
    // Provided methods
    fn GHz(self) -> Duration { ... }
    fn MHz(self) -> Duration { ... }
    fn kHz(self) -> Duration { ... }
    fn Hz(self) -> Duration { ... }
}
Expand description

A trait to automatically convert some primitives to an approximate frequency as a duration, rounded to the closest nanosecond Does not support more than 1 GHz (because max precision of a duration is 1 nanosecond)

use hifitime::prelude::*;

assert_eq!(1.Hz(), 1.seconds());
assert_eq!(10.Hz(), 0.1.seconds());
assert_eq!(100.Hz(), 0.01.seconds());
assert_eq!(1.MHz(), 1.microseconds());
assert_eq!(250.MHz(), 4.nanoseconds());
assert_eq!(1.GHz(), 1.nanoseconds());
// LIMITATIONS
assert_eq!(240.MHz(), 4.nanoseconds()); // 240 MHz is actually 4.1666.. nanoseconds, not 4 exactly!
assert_eq!(10.GHz(), 0.nanoseconds()); // NOTE: anything greater than 1 GHz is NOT supported

Provided Methods§

fn GHz(self) -> Duration

fn MHz(self) -> Duration

fn kHz(self) -> Duration

fn Hz(self) -> Duration

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl Frequencies for f64

§

impl Frequencies for i64

Implementors§