os_query_builder_rs/full_text/intervals/
interval_rule.rs1use serde::Serialize;
2use crate::full_text::intervals::rules::{
3 r#match::MatchRule,
4 prefix::PrefixRule,
5 wildcard::WildcardRule,
6 fuzzy::FuzzyRule,
7 all_of::AllOfRule,
8 any_of::AnyOfRule
9};
10
11#[derive(Debug, Clone, Serialize)]
12#[serde(rename_all="snake_case")]
13pub enum IntervalRule {
14 Match(MatchRule),
15 Prefix(PrefixRule),
16 Wildcard(WildcardRule),
17 Fuzzy(FuzzyRule),
18 AllOf(AllOfRule),
19 AnyOf(AnyOfRule)
20}
21
22macro_rules! from_types_enum {
23
24 ($(($rule:ty, $enum_value:ident)),*)=> {
25 $(
26 impl From<$rule> for IntervalRule {
27 fn from(val: $rule) -> Self {
28 Self::$enum_value(val.into())
29 }
30 }
31 )*
32 };
33
34}
35
36
37from_types_enum! {
38 (MatchRule, Match),
39 (PrefixRule, Prefix),
40 (WildcardRule, Wildcard),
41 (FuzzyRule, Fuzzy),
42 (AllOfRule, AllOf),
43 (AnyOfRule, AnyOf)
44}