reifydb_store_multi/hot/
result.rs1use reifydb_core::{
5 common::CommitVersion,
6 encoded::key::EncodedKey,
7 interface::store::{MultiVersionRow, SingleVersionRow},
8};
9
10#[derive(Debug, Clone)]
11pub enum MultiVersionGetResult {
12 Value(MultiVersionRow),
13 Tombstone {
14 key: EncodedKey,
15 version: CommitVersion,
16 },
17 NotFound,
18}
19
20impl MultiVersionGetResult {
21 pub fn is_tombstone(&self) -> bool {
22 matches!(self, Self::Tombstone { .. })
23 }
24
25 pub fn is_value(&self) -> bool {
26 matches!(self, Self::Value(_))
27 }
28
29 pub fn into_option(self) -> Option<MultiVersionRow> {
30 match self {
31 Self::Value(v) => Some(v),
32 _ => None,
33 }
34 }
35}
36
37impl From<MultiVersionGetResult> for Option<MultiVersionRow> {
38 fn from(val: MultiVersionGetResult) -> Self {
39 val.into_option()
40 }
41}
42
43#[derive(Debug, Clone)]
44pub enum SingleVersionGetResult {
45 Value(SingleVersionRow),
46 Tombstone {
47 key: EncodedKey,
48 },
49 NotFound,
50}
51
52impl SingleVersionGetResult {
53 pub fn is_tombstone(&self) -> bool {
54 matches!(self, Self::Tombstone { .. })
55 }
56
57 pub fn is_value(&self) -> bool {
58 matches!(self, Self::Value(_))
59 }
60
61 pub fn into_option(self) -> Option<SingleVersionRow> {
62 match self {
63 Self::Value(v) => Some(v),
64 _ => None,
65 }
66 }
67}
68
69impl From<SingleVersionGetResult> for Option<SingleVersionRow> {
70 fn from(val: SingleVersionGetResult) -> Self {
71 val.into_option()
72 }
73}
74
75#[derive(Debug, Clone)]
76pub enum MultiVersionIterResult {
77 Value(MultiVersionRow),
78 Tombstone {
79 key: EncodedKey,
80 version: CommitVersion,
81 },
82}
83
84#[derive(Debug, Clone)]
85pub enum SingleVersionIterResult {
86 Value(SingleVersionRow),
87 Tombstone {
88 key: EncodedKey,
89 },
90}
91
92impl SingleVersionIterResult {
93 pub fn into_option(self) -> Option<SingleVersionRow> {
94 match self {
95 Self::Value(v) => Some(v),
96 Self::Tombstone {
97 ..
98 } => None,
99 }
100 }
101
102 pub fn key(&self) -> &EncodedKey {
103 match self {
104 Self::Value(v) => &v.key,
105 Self::Tombstone {
106 key,
107 } => key,
108 }
109 }
110}