1#[derive(Copy, Clone, Debug, Eq, PartialEq)]
7#[allow(clippy::module_name_repetitions)]
8#[cfg_attr(test, derive(strum::EnumIter))]
9pub enum ValueType {
10 Value,
12
13 Tombstone,
15
16 WeakTombstone,
18
19 Indirection,
23}
24
25impl ValueType {
26 #[must_use]
28 pub fn is_tombstone(self) -> bool {
29 self == Self::Tombstone || self == Self::WeakTombstone
30 }
31
32 pub(crate) fn is_indirection(self) -> bool {
33 self == Self::Indirection
34 }
35}
36
37impl TryFrom<u8> for ValueType {
38 type Error = ();
39
40 fn try_from(value: u8) -> Result<Self, Self::Error> {
41 match value {
42 0 => Ok(Self::Value),
43 0x0000_0001 => Ok(Self::Tombstone),
44 0x0000_0011 => Ok(Self::WeakTombstone),
45 0b0000_0100 => Ok(Self::Indirection),
46 _ => Err(()),
47 }
48 }
49}
50
51impl From<ValueType> for u8 {
52 fn from(value: ValueType) -> Self {
53 match value {
54 ValueType::Value => 0,
55 ValueType::Tombstone => 0x0000_0001,
56 ValueType::WeakTombstone => 0x0000_0011,
57 ValueType::Indirection => 0b0000_0100,
58 }
59 }
60}