#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum FormatVersion {
V1 = 1,
V2,
V3,
}
impl std::fmt::Display for FormatVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", u8::from(*self))
}
}
impl From<FormatVersion> for u8 {
fn from(value: FormatVersion) -> Self {
match value {
FormatVersion::V1 => 1,
FormatVersion::V2 => 2,
FormatVersion::V3 => 3,
}
}
}
impl TryFrom<u8> for FormatVersion {
type Error = ();
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
1 => Ok(Self::V1),
2 => Ok(Self::V2),
3 => Ok(Self::V3),
_ => Err(()),
}
}
}