cat_gateway/db/event/common/
mod.rs

1//! Reusable common database objects
2
3pub(crate) mod query_limits;
4pub(crate) mod uuid_list;
5pub(crate) mod uuid_selector;
6
7/// SQL conditional statement trait
8pub(crate) trait ConditionalStmt {
9    /// Return a sql conditional statement by the provided `table_field`
10    fn conditional_stmt(
11        &self,
12        f: &mut std::fmt::Formatter<'_>,
13        table_field: &str,
14    ) -> std::fmt::Result;
15}
16
17impl<T: ConditionalStmt> ConditionalStmt for Option<T> {
18    fn conditional_stmt(
19        &self,
20        f: &mut std::fmt::Formatter<'_>,
21        table_field: &str,
22    ) -> std::fmt::Result {
23        if let Some(v) = self {
24            v.conditional_stmt(f, table_field)?;
25        }
26        Ok(())
27    }
28}