pub struct Rate(/* private fields */);Expand description
Represents a rate or frequency of events.
Implementations§
Source§impl Rate
impl Rate
Sourcepub const fn from_hz(val: u32) -> Self
pub const fn from_hz(val: u32) -> Self
Creates a new rate that represents hertz.
§Examples
use esp_hal::time::Rate;
let rate = Rate::from_hz(1000);Sourcepub const fn from_khz(val: u32) -> Self
pub const fn from_khz(val: u32) -> Self
Creates a new rate that represents kilohertz.
§Examples
use esp_hal::time::Rate;
let rate = Rate::from_khz(1000);Sourcepub const fn from_mhz(val: u32) -> Self
pub const fn from_mhz(val: u32) -> Self
Creates a new rate that represents megahertz.
§Examples
use esp_hal::time::Rate;
let rate = Rate::from_mhz(1000);Sourcepub const fn as_hz(&self) -> u32
pub const fn as_hz(&self) -> u32
Converts the Rate to an integer number of Hz.
§Examples
use esp_hal::time::Rate;
let rate = Rate::from_hz(1000);
let hz = rate.as_hz();Sourcepub const fn as_khz(&self) -> u32
pub const fn as_khz(&self) -> u32
Converts the Rate to an integer number of kHz.
§Examples
use esp_hal::time::Rate;
let rate = Rate::from_khz(1000);
let khz = rate.as_khz();Sourcepub const fn as_mhz(&self) -> u32
pub const fn as_mhz(&self) -> u32
Converts the Rate to an integer number of MHz.
§Examples
use esp_hal::time::Rate;
let rate = Rate::from_mhz(1000);
let mhz = rate.as_mhz();Sourcepub const fn as_duration(&self) -> Duration
pub const fn as_duration(&self) -> Duration
Converts the Rate to a Duration.
§Examples
use esp_hal::time::Rate;
let rate = Rate::from_hz(1000);
let duration = rate.as_duration();Trait Implementations§
impl Copy for Rate
impl Eq for Rate
Source§impl Ord for Rate
impl Ord for Rate
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Rate
impl PartialOrd for Rate
impl StructuralPartialEq for Rate
Auto Trait Implementations§
impl Freeze for Rate
impl RefUnwindSafe for Rate
impl Send for Rate
impl Sync for Rate
impl Unpin for Rate
impl UnsafeUnpin for Rate
impl UnwindSafe for Rate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more