qail_core/ast/cmd/
constructors.rs1use 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
129 pub fn redis_get(key: impl Into<String>) -> Self {
138 Self {
139 action: Action::RedisGet,
140 table: key.into(),
141 ..Default::default()
142 }
143 }
144
145 pub fn redis_set(key: impl Into<String>, value: impl Into<Vec<u8>>) -> Self {
152 Self {
153 action: Action::RedisSet,
154 table: key.into(),
155 raw_value: Some(value.into()),
156 ..Default::default()
157 }
158 }
159
160 pub fn redis_del(key: impl Into<String>) -> Self {
162 Self {
163 action: Action::RedisDel,
164 table: key.into(),
165 ..Default::default()
166 }
167 }
168
169 pub fn redis_incr(key: impl Into<String>) -> Self {
171 Self {
172 action: Action::RedisIncr,
173 table: key.into(),
174 ..Default::default()
175 }
176 }
177
178 pub fn redis_decr(key: impl Into<String>) -> Self {
180 Self {
181 action: Action::RedisDecr,
182 table: key.into(),
183 ..Default::default()
184 }
185 }
186
187 pub fn redis_ttl(key: impl Into<String>) -> Self {
189 Self {
190 action: Action::RedisTtl,
191 table: key.into(),
192 ..Default::default()
193 }
194 }
195
196 pub fn redis_expire(key: impl Into<String>, seconds: i64) -> Self {
198 Self {
199 action: Action::RedisExpire,
200 table: key.into(),
201 redis_ttl: Some(seconds),
202 ..Default::default()
203 }
204 }
205
206 pub fn redis_exists(key: impl Into<String>) -> Self {
208 Self {
209 action: Action::RedisExists,
210 table: key.into(),
211 ..Default::default()
212 }
213 }
214
215 pub fn redis_ping() -> Self {
217 Self {
218 action: Action::RedisPing,
219 ..Default::default()
220 }
221 }
222}