1use crate::{BindExpr, BuiltinFilter};
3#[derive(
5 Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
6)]
7pub enum BindingKind {
8 Term,
10 Add,
12 Sub,
14 Mul,
16 Div,
18 Neg,
20 Abs,
22 Ceil,
24 Floor,
26 Round,
28 Str,
30 StrLen,
32 UCase,
34 LCase,
36 Concat,
38 SubStr,
40 StrBefore,
42 StrAfter,
44 Replace,
46 EncodeForUri,
48 Md5,
50 Sha1,
52 Sha256,
54 Sha384,
56 Sha512,
58 CastInteger,
60 CastDecimal,
62 CastDouble,
64 CastFloat,
66 CastString,
68 Year,
70 Month,
72 Day,
74 Hours,
76 Minutes,
78 Seconds,
80 Timezone,
82 Tz,
84 Now,
86 Lang,
88 Iri,
90 BNode,
92}
93impl BindingKind {
94 pub const ALL: &'static [Self] = &[
96 Self::Term,
97 Self::Add,
98 Self::Sub,
99 Self::Mul,
100 Self::Div,
101 Self::Neg,
102 Self::Abs,
103 Self::Ceil,
104 Self::Floor,
105 Self::Round,
106 Self::Str,
107 Self::StrLen,
108 Self::UCase,
109 Self::LCase,
110 Self::Concat,
111 Self::SubStr,
112 Self::StrBefore,
113 Self::StrAfter,
114 Self::Replace,
115 Self::EncodeForUri,
116 Self::Md5,
117 Self::Sha1,
118 Self::Sha256,
119 Self::Sha384,
120 Self::Sha512,
121 Self::CastInteger,
122 Self::CastDecimal,
123 Self::CastDouble,
124 Self::CastFloat,
125 Self::CastString,
126 Self::Year,
127 Self::Month,
128 Self::Day,
129 Self::Hours,
130 Self::Minutes,
131 Self::Seconds,
132 Self::Timezone,
133 Self::Tz,
134 Self::Now,
135 Self::Lang,
136 Self::Iri,
137 Self::BNode,
138 ];
139}
140impl BindExpr {
141 #[must_use]
143 pub fn kind(&self) -> BindingKind {
144 match self {
145 Self::Term(..) => BindingKind::Term,
146 Self::Add(..) => BindingKind::Add,
147 Self::Sub(..) => BindingKind::Sub,
148 Self::Mul(..) => BindingKind::Mul,
149 Self::Div(..) => BindingKind::Div,
150 Self::Neg(..) => BindingKind::Neg,
151 Self::Abs(..) => BindingKind::Abs,
152 Self::Ceil(..) => BindingKind::Ceil,
153 Self::Floor(..) => BindingKind::Floor,
154 Self::Round(..) => BindingKind::Round,
155 Self::Str(..) => BindingKind::Str,
156 Self::StrLen(..) => BindingKind::StrLen,
157 Self::UCase(..) => BindingKind::UCase,
158 Self::LCase(..) => BindingKind::LCase,
159 Self::Concat(..) => BindingKind::Concat,
160 Self::SubStr { .. } => BindingKind::SubStr,
161 Self::StrBefore(..) => BindingKind::StrBefore,
162 Self::StrAfter(..) => BindingKind::StrAfter,
163 Self::Replace { .. } => BindingKind::Replace,
164 Self::EncodeForUri(..) => BindingKind::EncodeForUri,
165 Self::Md5(..) => BindingKind::Md5,
166 Self::Sha1(..) => BindingKind::Sha1,
167 Self::Sha256(..) => BindingKind::Sha256,
168 Self::Sha384(..) => BindingKind::Sha384,
169 Self::Sha512(..) => BindingKind::Sha512,
170 Self::CastInteger(..) => BindingKind::CastInteger,
171 Self::CastDecimal(..) => BindingKind::CastDecimal,
172 Self::CastDouble(..) => BindingKind::CastDouble,
173 Self::CastFloat(..) => BindingKind::CastFloat,
174 Self::CastString(..) => BindingKind::CastString,
175 Self::Year(..) => BindingKind::Year,
176 Self::Month(..) => BindingKind::Month,
177 Self::Day(..) => BindingKind::Day,
178 Self::Hours(..) => BindingKind::Hours,
179 Self::Minutes(..) => BindingKind::Minutes,
180 Self::Seconds(..) => BindingKind::Seconds,
181 Self::Timezone(..) => BindingKind::Timezone,
182 Self::Tz(..) => BindingKind::Tz,
183 Self::Now => BindingKind::Now,
184 Self::Lang(..) => BindingKind::Lang,
185 Self::Iri(..) => BindingKind::Iri,
186 Self::BNode(..) => BindingKind::BNode,
187 }
188 }
189}
190#[derive(
192 Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
193)]
194pub enum FilterKind {
195 Eq,
197 Ne,
199 Lt,
201 Le,
203 Gt,
205 Ge,
207 StrStarts,
209 StrEnds,
211 Contains,
213 RegexMatch,
215 IsIri,
217 IsLiteral,
219 IsBlank,
221 IsNumeric,
223 LangMatches,
225 And,
227 Or,
229 Not,
231}
232impl FilterKind {
233 pub const ALL: &'static [Self] = &[
235 Self::Eq,
236 Self::Ne,
237 Self::Lt,
238 Self::Le,
239 Self::Gt,
240 Self::Ge,
241 Self::StrStarts,
242 Self::StrEnds,
243 Self::Contains,
244 Self::RegexMatch,
245 Self::IsIri,
246 Self::IsLiteral,
247 Self::IsBlank,
248 Self::IsNumeric,
249 Self::LangMatches,
250 Self::And,
251 Self::Or,
252 Self::Not,
253 ];
254}
255impl BuiltinFilter {
256 #[must_use]
258 pub fn kind(&self) -> FilterKind {
259 match self {
260 Self::Eq(..) => FilterKind::Eq,
261 Self::Ne(..) => FilterKind::Ne,
262 Self::Lt(..) => FilterKind::Lt,
263 Self::Le(..) => FilterKind::Le,
264 Self::Gt(..) => FilterKind::Gt,
265 Self::Ge(..) => FilterKind::Ge,
266 Self::StrStarts(..) => FilterKind::StrStarts,
267 Self::StrEnds(..) => FilterKind::StrEnds,
268 Self::Contains(..) => FilterKind::Contains,
269 Self::RegexMatch { .. } => FilterKind::RegexMatch,
270 Self::IsIri(..) => FilterKind::IsIri,
271 Self::IsLiteral(..) => FilterKind::IsLiteral,
272 Self::IsBlank(..) => FilterKind::IsBlank,
273 Self::IsNumeric(..) => FilterKind::IsNumeric,
274 Self::LangMatches(..) => FilterKind::LangMatches,
275 Self::And(..) => FilterKind::And,
276 Self::Or(..) => FilterKind::Or,
277 Self::Not(..) => FilterKind::Not,
278 }
279 }
280}