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