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