lsm_tree/
format_version.rs1#[derive(Copy, Clone, Debug, Eq, PartialEq)]
7pub enum FormatVersion {
8 V1,
10
11 V2,
13
14 V3,
16}
17
18#[cfg_attr(test, mutants::skip)]
19impl std::fmt::Display for FormatVersion {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 write!(f, "{}", u8::from(*self))
22 }
23}
24
25impl From<FormatVersion> for u8 {
26 fn from(value: FormatVersion) -> Self {
27 match value {
28 FormatVersion::V1 => 1,
29 FormatVersion::V2 => 2,
30 FormatVersion::V3 => 3,
31 }
32 }
33}
34
35impl TryFrom<u8> for FormatVersion {
36 type Error = ();
37
38 fn try_from(value: u8) -> Result<Self, Self::Error> {
39 match value {
40 1 => Ok(Self::V1),
41 2 => Ok(Self::V2),
42 3 => Ok(Self::V3),
43 _ => Err(()),
44 }
45 }
46}