pub struct Frequency { /* private fields */ }
Expand description
Represents a frequency in Hz
Clocks are usually given as a frequency, but durations are needed when dealing with clocks
and clock durations. This type makes it easier to create a clock of a given frequency and
convert it to a Duration
Implementations§
source§impl Frequency
impl Frequency
sourcepub const fn from_hz(hertz: u32) -> Self
pub const fn from_hz(hertz: u32) -> Self
Creates a new Frequency
from the specified number of hertz
§Examples
use femtos::Frequency;
Frequency::from_hz(123);
sourcepub const fn from_khz(khz: u32) -> Self
pub const fn from_khz(khz: u32) -> Self
Creates a new Frequency
from the specified number of kilohertz
§Examples
use femtos::Frequency;
Frequency::from_khz(123);
sourcepub const fn from_mhz(mhz: u32) -> Self
pub const fn from_mhz(mhz: u32) -> Self
Creates a new Frequency
from the specified number of megahertz
§Examples
use femtos::Frequency;
Frequency::from_mhz(123);
sourcepub const fn period_duration(self) -> Duration
pub const fn period_duration(self) -> Duration
Returns the Duration
equivalent to the time period between cycles of
the given Frequency
§Examples
use femtos::{Duration, Frequency};
assert_eq!(Frequency::from_hz(1).period_duration(), Duration::from_secs(1));
Trait Implementations§
source§impl DivAssign<u32> for Frequency
impl DivAssign<u32> for Frequency
source§fn div_assign(&mut self, rhs: u32)
fn div_assign(&mut self, rhs: u32)
Performs the
/=
operation. Read moresource§impl MulAssign<u32> for Frequency
impl MulAssign<u32> for Frequency
source§fn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
Performs the
*=
operation. Read moresource§impl Ord for Frequency
impl Ord for Frequency
source§impl PartialEq for Frequency
impl PartialEq for Frequency
source§impl PartialOrd for Frequency
impl PartialOrd for Frequency
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Frequency
impl Eq for Frequency
impl StructuralPartialEq for Frequency
Auto Trait Implementations§
impl Freeze for Frequency
impl RefUnwindSafe for Frequency
impl Send for Frequency
impl Sync for Frequency
impl Unpin for Frequency
impl UnwindSafe for Frequency
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