qail_core/ast/cmd/
constructors.rs

1//! Static constructor methods for Qail.
2//!
3//! Methods like get(), set(), add(), del(), make(), etc.
4
5use crate::ast::{Action, Qail};
6
7impl Qail {
8    pub fn get(table: impl Into<String>) -> Self {
9        Self {
10            action: Action::Get,
11            table: table.into(),
12            ..Default::default()
13        }
14    }
15
16    pub fn raw_sql(sql: impl Into<String>) -> Self {
17        Self {
18            action: Action::Get,
19            table: sql.into(),
20            ..Default::default()
21        }
22    }
23
24    pub fn set(table: impl Into<String>) -> Self {
25        Self {
26            action: Action::Set,
27            table: table.into(),
28            ..Default::default()
29        }
30    }
31
32    pub fn del(table: impl Into<String>) -> Self {
33        Self {
34            action: Action::Del,
35            table: table.into(),
36            ..Default::default()
37        }
38    }
39
40    pub fn add(table: impl Into<String>) -> Self {
41        Self {
42            action: Action::Add,
43            table: table.into(),
44            ..Default::default()
45        }
46    }
47
48    pub fn put(table: impl Into<String>) -> Self {
49        Self {
50            action: Action::Put,
51            table: table.into(),
52            ..Default::default()
53        }
54    }
55
56    pub fn export(table: impl Into<String>) -> Self {
57        Self {
58            action: Action::Export,
59            table: table.into(),
60            ..Default::default()
61        }
62    }
63
64    pub fn make(table: impl Into<String>) -> Self {
65        Self {
66            action: Action::Make,
67            table: table.into(),
68            ..Default::default()
69        }
70    }
71
72    pub fn truncate(table: impl Into<String>) -> Self {
73        Self {
74            action: Action::Truncate,
75            table: table.into(),
76            ..Default::default()
77        }
78    }
79
80    pub fn explain(table: impl Into<String>) -> Self {
81        Self {
82            action: Action::Explain,
83            table: table.into(),
84            ..Default::default()
85        }
86    }
87
88    pub fn explain_analyze(table: impl Into<String>) -> Self {
89        Self {
90            action: Action::ExplainAnalyze,
91            table: table.into(),
92            ..Default::default()
93        }
94    }
95
96    pub fn lock(table: impl Into<String>) -> Self {
97        Self {
98            action: Action::Lock,
99            table: table.into(),
100            ..Default::default()
101        }
102    }
103
104    pub fn create_materialized_view(name: impl Into<String>, query: Qail) -> Self {
105        Self {
106            action: Action::CreateMaterializedView,
107            table: name.into(),
108            source_query: Some(Box::new(query)),
109            ..Default::default()
110        }
111    }
112
113    pub fn refresh_materialized_view(name: impl Into<String>) -> Self {
114        Self {
115            action: Action::RefreshMaterializedView,
116            table: name.into(),
117            ..Default::default()
118        }
119    }
120
121    pub fn drop_materialized_view(name: impl Into<String>) -> Self {
122        Self {
123            action: Action::DropMaterializedView,
124            table: name.into(),
125            ..Default::default()
126        }
127    }
128}