lucene_query_builder/
lib.rs

1pub use lucene_query_builder_rs_derive::*;
2
3use std::fmt;
4
5pub enum Operator {
6    Or,
7    And,
8    End,
9}
10
11#[derive(Debug, Clone)]
12pub struct QueryString(pub String);
13
14impl fmt::Display for QueryString {
15    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16        if self.0.contains(' ') {
17            write!(f, "\"{}\"", self.0)
18        } else {
19            write!(f, "{}", self.0)
20        }
21    }
22}
23
24impl fmt::Display for Operator {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        match self {
27            Self::Or => write!(f, " OR "),
28            Self::And => write!(f, " AND "),
29            Self::End => write!(f, ""),
30        }
31    }
32}