schema_sql_generator/common/
output_mode.rs1use std::str::FromStr;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum OutputMode {
5 All,
6 IndexesOnly,
7 TriggersOnly,
8}
9
10impl OutputMode {
11 pub fn includes_indexes(self) -> bool {
12 matches!(self, OutputMode::All | OutputMode::IndexesOnly)
13 }
14 pub fn includes_triggers(self) -> bool {
15 matches!(self, OutputMode::All | OutputMode::TriggersOnly)
16 }
17 pub fn includes_tables(self) -> bool {
18 matches!(self, OutputMode::All)
19 }
20 pub fn includes_views(self) -> bool {
21 matches!(self, OutputMode::All)
22 }
23 pub fn includes_routines(self) -> bool {
24 matches!(self, OutputMode::All)
25 }
26 pub fn includes_other_sql(self) -> bool {
27 matches!(self, OutputMode::All)
28 }
29}
30
31impl FromStr for OutputMode {
32 type Err = String;
33
34 fn from_str(s: &str) -> Result<Self, Self::Err> {
35 match s.to_lowercase().as_str() {
36 "all" => Ok(OutputMode::All),
37 "indexes-only" => Ok(OutputMode::IndexesOnly),
38 "triggers-only" => Ok(OutputMode::TriggersOnly),
39 _ => Err(format!("Unknown output mode: {}", s)),
40 }
41 }
42}