Skip to main content

FrequencyExt

Trait FrequencyExt 

Source
pub trait FrequencyExt: Sized + Copy {
    const ZERO: Self;

    // Required methods
    fn from_per_sec(rate: f64) -> Self;
    fn from_per_sec_u64(rate: u64) -> Self;
    fn per_sec_f64(self) -> f64;
    fn per_sec_u64(self) -> u64;
    fn period(self) -> Time;
}
Expand description

Event rates: construction from raw numbers, and extraction back to them.

Required Associated Constants§

Source

const ZERO: Self

No events.

Required Methods§

Source

fn from_per_sec(rate: f64) -> Self

A raw events-per-second rate.

Source

fn from_per_sec_u64(rate: u64) -> Self

A whole-events-per-second rate, as a counter-based limiter configures one.

Source

fn per_sec_f64(self) -> f64

The rate in events per second.

Source

fn per_sec_u64(self) -> u64

The rate as whole events per second, for a limiter that counts in integers. Rounds to nearest; negatives and NaN become zero.

Source

fn period(self) -> Time

The interval between events at this rate.

A zero or negative rate gives TimeExt::ZERO and not an infinity.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§