cat_gateway/db/event/common/
uuid_selector.rs1use crate::db::event::common::{ConditionalStmt, uuid_list::UuidList};
4
5#[derive(Clone, Debug, PartialEq)]
7pub(crate) enum UuidSelector {
8 Eq(uuid::Uuid),
10 Range {
12 min: uuid::Uuid,
14 max: uuid::Uuid,
16 },
17 In(UuidList),
19}
20
21impl ConditionalStmt for UuidSelector {
22 fn conditional_stmt(
23 &self,
24 f: &mut std::fmt::Formatter<'_>,
25 table_field: &str,
26 ) -> std::fmt::Result {
27 match self {
28 Self::Eq(id) => write!(f, "{table_field} = '{id}'"),
29 Self::Range { min, max } => {
30 write!(f, "{table_field} >= '{min}' AND {table_field} <= '{max}'")
31 },
32 Self::In(ids) => ids.conditional_stmt(f, table_field),
33 }
34 }
35}