1#[derive(Copy, Clone, Debug, Eq, PartialEq)]
7#[cfg_attr(test, derive(strum::EnumIter))]
8pub enum ValueType {
9 Value,
11
12 Tombstone,
14
15 WeakTombstone,
17
18 MergeOperand = 3,
23
24 Indirection = 4,
28}
29
30impl ValueType {
31 #[must_use]
33 pub fn is_tombstone(self) -> bool {
34 self == Self::Tombstone || self == Self::WeakTombstone
35 }
36
37 pub(crate) fn is_indirection(self) -> bool {
38 self == Self::Indirection
39 }
40
41 #[must_use]
43 pub fn is_merge_operand(self) -> bool {
44 self == Self::MergeOperand
45 }
46}
47
48impl TryFrom<u8> for ValueType {
49 type Error = ();
50
51 fn try_from(value: u8) -> Result<Self, Self::Error> {
52 match value {
53 0 => Ok(Self::Value),
54 1 => Ok(Self::Tombstone),
55 2 => Ok(Self::WeakTombstone),
56 3 => Ok(Self::MergeOperand),
57 4 => Ok(Self::Indirection),
58 _ => Err(()),
59 }
60 }
61}
62
63impl From<ValueType> for u8 {
64 fn from(value: ValueType) -> Self {
65 match value {
66 ValueType::Value => 0,
67 ValueType::Tombstone => 1,
68 ValueType::WeakTombstone => 2,
69 ValueType::MergeOperand => 3,
70 ValueType::Indirection => 4,
71 }
72 }
73}