use crate::result::Result;
#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct WakeupPeriod(u8);
impl WakeupPeriod {
pub const MASK: u8 = 0x1f;
pub const DEFAULT: u8 = 0;
pub const fn new() -> Self {
Self(Self::DEFAULT)
}
pub const fn from_inner(val: u8) -> Self {
Self(val & Self::MASK)
}
pub const fn try_from_inner(val: u8) -> Result<Self> {
Ok(Self::from_inner(val))
}
pub fn into_inner(self) -> u8 {
self.0
}
}
impl Default for WakeupPeriod {
fn default() -> Self {
Self::new()
}
}
impl From<u8> for WakeupPeriod {
fn from(val: u8) -> Self {
Self::from_inner(val)
}
}
impl From<WakeupPeriod> for u8 {
fn from(val: WakeupPeriod) -> Self {
val.into_inner()
}
}