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 Indirection,
22}
23
24impl ValueType {
25 #[must_use]
27 pub fn is_tombstone(self) -> bool {
28 self == Self::Tombstone || self == Self::WeakTombstone
29 }
30
31 pub(crate) fn is_indirection(self) -> bool {
32 self == Self::Indirection
33 }
34}
35
36impl TryFrom<u8> for ValueType {
37 type Error = ();
38
39 fn try_from(value: u8) -> Result<Self, Self::Error> {
40 match value {
41 0 => Ok(Self::Value),
42 0x0000_0001 => Ok(Self::Tombstone),
43 0x0000_0011 => Ok(Self::WeakTombstone),
44 0b0000_0100 => Ok(Self::Indirection),
45 _ => Err(()),
46 }
47 }
48}
49
50impl From<ValueType> for u8 {
51 fn from(value: ValueType) -> Self {
52 match value {
53 ValueType::Value => 0,
54 ValueType::Tombstone => 0x0000_0001,
55 ValueType::WeakTombstone => 0x0000_0011,
56 ValueType::Indirection => 0b0000_0100,
57 }
58 }
59}