-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmod.rs
95 lines (88 loc) · 2.92 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! This module defines the the parsing functions of search query.
//! The grammar of the syntax is the following:
//!
//! ```bnf
//! search-query ::= clause+
//! clause ::= or-expression | limit-clause | from-clause | order-clause
//! or-expression ::= And-expression | and-expression 'or' and-expression
//! and-expression ::= atom | atom 'and' atom
//! term ::= atom | '!' atom
//! atom ::= comparison | filter | '(' expression ')'
//! number-symbol ::= 'offset' | 'partition' | 'size'
//! string-symbol ::= 'topic' | 'key' | 'timestamp' | 'value'
//! symbol ::= number-symbol | string-symbol
//! comparison ::= number-comparison | string-comparison | time-comparison
//! number-comparison ::= number-symbol number-operator number
//! string-comparison ::= string-symbol string-operator string
//! time-comparison ::= 'between' string 'and' string
//! number-operator ::= '==' | '!=' | '>' | '<' | '>=' | '<='
//! string-operator ::= 'starts with' | '==' | '!=' | '=~' | 'contains' | 'contain' | 'includes' | 'include'
//! filter ::= .+ '('filter-parameters')'
//! filter-parameter ::= string | number
//! filter-parameters ::= filter-parameter (',' filter-parameter)*
//! limit-clause ::= 'limit' number
//! order-clause ::= 'order by' symbol order-keyword
//! order-keyword ::= 'asc' | 'desc'
//! from-clause ::= 'from' offset
//! offset ::= 'beginning' | 'begin' | 'end' | 'end' '-' number | string | number
//! number ::= [0-9_]+
//! string ::= '"' [^"]+ '"' | "'" [^']+ "'"
//! ```
//! You can use <https://www.bottlecaps.de/rr/ui> to visualize it.
#[cfg(feature = "native")]
pub mod atom;
#[cfg(feature = "native")]
pub mod clause;
#[cfg(feature = "native")]
pub mod expression;
#[cfg(feature = "native")]
pub mod filter;
#[cfg(feature = "native")]
pub mod number;
#[cfg(feature = "native")]
pub mod offset;
#[cfg(feature = "native")]
pub mod order;
#[cfg(feature = "native")]
pub mod search_query;
#[cfg(feature = "native")]
pub mod string;
#[cfg(feature = "native")]
pub mod symbol;
#[cfg(feature = "native")]
pub mod term;
#[cfg(feature = "native")]
pub mod timestamp;
#[cfg(feature = "native")]
pub mod wsi;
pub mod compare;
#[cfg(feature = "native")]
pub use order::Order;
#[cfg(feature = "native")]
pub use order::OrderBy;
#[cfg(feature = "native")]
pub use search_query::SearchQuery;
#[cfg(feature = "native")]
pub use search_query::parse_search_query;
use serde::Deserialize;
use serde::Serialize;
#[cfg(test)]
pub mod expression_test;
#[cfg(test)]
pub mod number_test;
#[cfg(test)]
pub mod offset_test;
#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
pub struct FilterResult {
pub r#match: bool,
}
impl FilterResult {
pub fn new(r#match: bool) -> Self {
Self { r#match }
}
}
impl From<bool> for FilterResult {
fn from(r#match: bool) -> Self {
Self { r#match }
}
}