pub struct Hertz(pub c_ulong);Expand description
The frequency unit.
Represents a frequency in hertz, wrapping a c_ulong value.
§Examples
use kernel::clk::Hertz;
let hz = 1_000_000_000;
let rate = Hertz(hz);
assert_eq!(rate.as_hz(), hz);
assert_eq!(rate, Hertz(hz));
assert_eq!(rate, Hertz::from_khz(hz / 1_000));
assert_eq!(rate, Hertz::from_mhz(hz / 1_000_000));
assert_eq!(rate, Hertz::from_ghz(hz / 1_000_000_000));Tuple Fields§
§0: c_ulongImplementations§
Source§impl Hertz
impl Hertz
Sourcepub const fn from_khz(khz: c_ulong) -> Self
pub const fn from_khz(khz: c_ulong) -> Self
Create a new instance from kilohertz (kHz)
§Panics
Panics if CONFIG_RUST_OVERFLOW_CHECKS is enabled and khz is greater
than c_ulong::MAX / 1_000.
Sourcepub const fn from_mhz(mhz: c_ulong) -> Self
pub const fn from_mhz(mhz: c_ulong) -> Self
Create a new instance from megahertz (MHz)
§Panics
Panics if CONFIG_RUST_OVERFLOW_CHECKS is enabled and mhz is greater
than c_ulong::MAX / 1_000_000.
Trait Implementations§
impl Copy for Hertz
impl Eq for Hertz
impl StructuralPartialEq for Hertz
Auto Trait Implementations§
impl Freeze for Hertz
impl RefUnwindSafe for Hertz
impl Send for Hertz
impl Sync for Hertz
impl Unpin for Hertz
impl UnsafeUnpin for Hertz
impl UnwindSafe for Hertz
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
Source§fn into_safe_cast(self) -> T
fn into_safe_cast(self) -> T
Convert
self into a T. This operation is guaranteed to be lossless.Source§impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
Source§fn into_safe_cast_arch(self) -> T
fn into_safe_cast_arch(self) -> T
Convert
self into a T. This operation is guaranteed to be lossless.