qail_core/ast/cmd/
constructors.rs1use crate::ast::{Action, Qail};
6
7impl Qail {
8 pub fn get(table: impl Into<String>) -> Self {
10 Self {
11 action: Action::Get,
12 table: table.into(),
13 ..Default::default()
14 }
15 }
16
17 pub fn set(table: impl Into<String>) -> Self {
19 Self {
20 action: Action::Set,
21 table: table.into(),
22 ..Default::default()
23 }
24 }
25
26 pub fn del(table: impl Into<String>) -> Self {
28 Self {
29 action: Action::Del,
30 table: table.into(),
31 ..Default::default()
32 }
33 }
34
35 pub fn add(table: impl Into<String>) -> Self {
37 Self {
38 action: Action::Add,
39 table: table.into(),
40 ..Default::default()
41 }
42 }
43
44 pub fn put(table: impl Into<String>) -> Self {
46 Self {
47 action: Action::Put,
48 table: table.into(),
49 ..Default::default()
50 }
51 }
52
53 pub fn merge_into(table: impl Into<String>) -> Self {
55 Self {
56 action: Action::Merge,
57 table: table.into(),
58 ..Default::default()
59 }
60 }
61
62 pub fn export(table: impl Into<String>) -> Self {
64 Self {
65 action: Action::Export,
66 table: table.into(),
67 ..Default::default()
68 }
69 }
70
71 pub fn make(table: impl Into<String>) -> Self {
73 Self {
74 action: Action::Make,
75 table: table.into(),
76 ..Default::default()
77 }
78 }
79
80 pub fn truncate(table: impl Into<String>) -> Self {
82 Self {
83 action: Action::Truncate,
84 table: table.into(),
85 ..Default::default()
86 }
87 }
88
89 pub fn explain(table: impl Into<String>) -> Self {
91 Self {
92 action: Action::Explain,
93 table: table.into(),
94 ..Default::default()
95 }
96 }
97
98 pub fn explain_analyze(table: impl Into<String>) -> Self {
100 Self {
101 action: Action::ExplainAnalyze,
102 table: table.into(),
103 ..Default::default()
104 }
105 }
106
107 pub fn lock(table: impl Into<String>) -> Self {
109 Self {
110 action: Action::Lock,
111 table: table.into(),
112 ..Default::default()
113 }
114 }
115
116 pub fn create_materialized_view(name: impl Into<String>, query: Qail) -> Self {
118 Self {
119 action: Action::CreateMaterializedView,
120 table: name.into(),
121 source_query: Some(Box::new(query)),
122 ..Default::default()
123 }
124 }
125
126 pub fn refresh_materialized_view(name: impl Into<String>) -> Self {
128 Self {
129 action: Action::RefreshMaterializedView,
130 table: name.into(),
131 ..Default::default()
132 }
133 }
134
135 pub fn drop_materialized_view(name: impl Into<String>) -> Self {
137 Self {
138 action: Action::DropMaterializedView,
139 table: name.into(),
140 ..Default::default()
141 }
142 }
143
144 pub fn listen(channel: impl Into<String>) -> Self {
154 Self {
155 action: Action::Listen,
156 channel: Some(channel.into()),
157 ..Default::default()
158 }
159 }
160
161 pub fn unlisten(channel: impl Into<String>) -> Self {
169 Self {
170 action: Action::Unlisten,
171 channel: Some(channel.into()),
172 ..Default::default()
173 }
174 }
175
176 pub fn notify(channel: impl Into<String>, payload: impl Into<String>) -> Self {
184 Self {
185 action: Action::Notify,
186 channel: Some(channel.into()),
187 payload: Some(payload.into()),
188 ..Default::default()
189 }
190 }
191
192 pub fn call(procedure: impl Into<String>) -> Self {
202 Self {
203 action: Action::Call,
204 table: procedure.into(),
205 ..Default::default()
206 }
207 }
208
209 pub fn do_block(body: impl Into<String>, language: impl Into<String>) -> Self {
217 Self {
218 action: Action::Do,
219 payload: Some(body.into()),
220 table: language.into(),
221 ..Default::default()
222 }
223 }
224
225 pub fn session_set(key: impl Into<String>, value: impl Into<String>) -> Self {
235 Self {
236 action: Action::SessionSet,
237 table: key.into(),
238 payload: Some(value.into()),
239 ..Default::default()
240 }
241 }
242
243 pub fn session_show(key: impl Into<String>) -> Self {
251 Self {
252 action: Action::SessionShow,
253 table: key.into(),
254 ..Default::default()
255 }
256 }
257
258 pub fn session_reset(key: impl Into<String>) -> Self {
266 Self {
267 action: Action::SessionReset,
268 table: key.into(),
269 ..Default::default()
270 }
271 }
272
273 pub fn create_database(name: impl Into<String>) -> Self {
275 Self {
276 action: Action::CreateDatabase,
277 table: name.into(),
278 ..Default::default()
279 }
280 }
281
282 pub fn drop_database(name: impl Into<String>) -> Self {
284 Self {
285 action: Action::DropDatabase,
286 table: name.into(),
287 ..Default::default()
288 }
289 }
290}