1use crate::{Error, Result};
4
5#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
7#[repr(u32)]
8pub enum Version {
9 V0x10 = 0x10,
13
14 #[default]
18 V0x13 = 0x13,
19}
20
21impl Version {
22 pub(crate) const fn to_le_bytes(self) -> [u8; 4] {
24 (self as u32).to_le_bytes()
25 }
26}
27
28impl From<Version> for u32 {
29 fn from(version: Version) -> u32 {
30 version as u32
31 }
32}
33
34impl TryFrom<u32> for Version {
35 type Error = Error;
36
37 fn try_from(version_id: u32) -> Result<Version> {
38 match version_id {
39 0x10 => Ok(Version::V0x10),
40 0x13 => Ok(Version::V0x13),
41 _ => Err(Error::VersionInvalid),
42 }
43 }
44}