os_query_builder_rs/full_text/intervals/rules/
any_of.rs1use serde::Serialize;
2use crate::full_text::intervals::{
3 rules::filter::FilterRule,
4 interval_rule::IntervalRule
5};
6
7#[derive(Debug, Default, Clone, Serialize)]
8pub struct AnyOfRule {
9 interval: Vec<IntervalRule>,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 filter: Option<Box<FilterRule>>
12}
13
14impl AnyOfRule{
15
16 pub fn new() -> Self {
17 Self::default()
18 }
19
20 pub fn intervals<T, F>(self, intervals: F) -> Self
21 where T: Into<IntervalRule>,
22 F: IntoIterator<Item=T>
23 {
24 Self {
25 interval: intervals.into_iter().map(|x| x.into()).collect(),
26 ..self
27 }
28 }
29
30 pub fn filter<T:Into<FilterRule>>(self, filter: T) -> Self {
31 Self {
32 filter: Some(Box::new(filter.into())),
33 ..self
34 }
35 }
36
37}