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
Shorthand for creating a rate which represents hertz.
§Example
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
Shorthand for creating a rate which represents kilohertz.
§Example
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
Shorthand for creating a rate which represents megahertz.
§Example
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
Convert the Rate
to an interger number of Hz.
§Example
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
Convert the Rate
to an interger number of kHz.
§Example
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
Convert the Rate
to an interger number of MHz.
§Example
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
Convert the Rate
to a Duration
.
§Example
use esp_hal::time::Rate;
let rate = Rate::from_hz(1000);
let duration = rate.as_duration();
Trait Implementations§
Source§impl Ord for Rate
impl Ord for Rate
Source§impl PartialOrd for Rate
impl PartialOrd for Rate
impl Copy for Rate
impl Eq 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 UnwindSafe for Rate
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)