use libc::c_longlong as c_ll;
use super::Cycles;
impl Cycles {
#[must_use]
pub const fn from_hz(h: c_ll) -> Self {
Self { raw: h }
}
#[must_use]
pub const fn from_khz(k: c_ll) -> Self {
Self { raw: k * 1000 }
}
#[must_use]
pub const fn from_mhz(m: c_ll) -> Self {
Self { raw: m * 1_000_000 }
}
#[must_use]
pub const fn from_ghz(g: c_ll) -> Self {
Self {
raw: g * 1_000_000_000,
}
}
#[must_use]
pub const fn as_hz(&self) -> c_ll {
self.raw
}
#[must_use]
pub const fn as_khz(&self) -> c_ll {
self.raw / 1000
}
#[must_use]
pub const fn as_mhz(&self) -> c_ll {
self.raw / 1_000_000
}
#[must_use]
pub const fn as_ghz(&self) -> c_ll {
self.raw / 1_000_000_000
}
}