1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2024-present, fjall-rs
// This source code is licensed under both the Apache 2.0 and MIT License
// (found in the LICENSE-* files in the repository)
/// Disk format version
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum FormatVersion {
/// Version for 1.x.x releases
V1 = 1,
/// Version for 2.x.x releases
V2,
/// Version for 3.x.x releases
V3,
/// Version for range-tombstone SST semantics
V4,
}
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,
FormatVersion::V4 => 4,
}
}
}
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),
4 => Ok(Self::V4),
_ => Err(()),
}
}
}