use crate::Error;
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum Tsf {
#[default]
None,
SampleCount,
RealTime,
FreeRunning,
}
impl TryFrom<u8> for Tsf {
type Error = Error;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0 => Ok(Tsf::None),
1 => Ok(Tsf::SampleCount),
2 => Ok(Tsf::RealTime),
3 => Ok(Tsf::FreeRunning),
_ => Err(Error::Tsf(value)),
}
}
}
impl From<Tsf> for u8 {
fn from(tsf: Tsf) -> u8 {
match tsf {
Tsf::None => 0,
Tsf::SampleCount => 1,
Tsf::RealTime => 2,
Tsf::FreeRunning => 3,
}
}
}