pub enum Searcher {
And {
lhs: Box<Searcher>,
rhs: Box<Searcher>,
},
Or {
lhs: Box<Searcher>,
rhs: Box<Searcher>,
},
Not {
lhs: Box<Searcher>,
},
Tag {
regex: Regex,
},
Equal {
tag_regex: Regex,
value_regex: Regex,
},
Less {
tag_regex: Regex,
value: i32,
},
LessEqual {
tag_regex: Regex,
value: i32,
},
Greater {
tag_regex: Regex,
value: i32,
},
GreaterEqual {
tag_regex: Regex,
value: i32,
},
}
Expand description
Searcher variants.
Variants§
And
Logical and.
Or
Logical or.
Not
Logical not.
Tag
Matches tag.
Equal
Matches value.
Less
Matches if integer value is less than value.
LessEqual
Matches if integer value is less or equal than rhs.
Greater
Matches if integer value is greater than rhs.
GreaterEqual
Matches if integer value is greater or equal than rhs.
Implementations§
Source§impl Searcher
impl Searcher
Sourcepub fn new_and(lhs: Searcher, rhs: Searcher) -> Self
pub fn new_and(lhs: Searcher, rhs: Searcher) -> Self
Returns new and Searcher.
Matches when both elements match. Uses short-circuit evaluation. That means that when the left arm is already false, the right arm is not executed.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("foo".to_string(), None);
tags.insert("bar".to_string(), None);
let search = Searcher::new_and(Searcher::new_tag("foo").unwrap(), Searcher::new_tag("bar").unwrap());
assert!(search.is_match(&tags) == true);
Sourcepub fn new_or(lhs: Searcher, rhs: Searcher) -> Self
pub fn new_or(lhs: Searcher, rhs: Searcher) -> Self
Returns new or Searcher.
Matches when at least one element matches. Uses short-circuit evaluation. That means that when the left arm matches already, the right arm is not executed.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("foo".to_string(), None);
let search = Searcher::new_or(Searcher::new_tag("foo").unwrap(), Searcher::new_tag("bar").unwrap());
assert!(search.is_match(&tags) == true);
Sourcepub fn new_not(lhs: Searcher) -> Self
pub fn new_not(lhs: Searcher) -> Self
Returns new not Searcher.
Matches when the contained element doesn’t match.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("bar".to_string(), None);
let search = Searcher::new_not(Searcher::new_tag("foo").unwrap());
assert!(search.is_match(&tags) == true);
Sourcepub fn new_tag(regex: &str) -> Result<Self>
pub fn new_tag(regex: &str) -> Result<Self>
Returns new tag Searcher.
Matches when the regular expression matches. The expression is expanded with anchors to match the whole tag.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("foo".to_string(), None);
let search = Searcher::new_tag("foo").unwrap();
assert!(search.is_match(&tags) == true);
§Errors
- XTagError::Regex if the regex argument is not a valid regular expression
Sourcepub fn new_equal(tag_regex: &str, value_regex: &str) -> Result<Self>
pub fn new_equal(tag_regex: &str, value_regex: &str) -> Result<Self>
Returns new equal Searcher.
tag_regex specifies which tags are checked and value_regex is matched against the associated values. Matches when one value of one matching tag matches. The regular expressions are expanded with anchors to match the whole tag or value.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("bar".to_string(), Some("foo".to_string()));
tags.insert("baz".to_string(), Some("qux".to_string()));
let search = Searcher::new_equal("ba.", "qu.").unwrap();
assert!(search.is_match(&tags) == true);
§Errors
- XTagError::Regex if tag_regex or value_regex are not a valid regular expression
Sourcepub fn new_inequal(tag_regex: &str, value_regex: &str) -> Result<Self>
pub fn new_inequal(tag_regex: &str, value_regex: &str) -> Result<Self>
Returns Searcher for inequality
Combines an equal and a not searcher to test for inequality
§Errors
- XTagError::Regex if tag_regex or value_regex are not a valid regular expression
Sourcepub fn new_less(tag_regex: &str, value: &str) -> Result<Self>
pub fn new_less(tag_regex: &str, value: &str) -> Result<Self>
Returns new less Searcher.
tag_regex specifies which tags are checked and rhs is matched against the integer representation of the associated values. Matches when one value of one matching tag matches. tag_regex is expanded with anchors to match the whole tag. If the value cannot be converted to integer that’s no match.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("bar".to_string(), Some("10".to_string()));
tags.insert("baz".to_string(), Some("100".to_string()));
let search = Searcher::new_less("ba.", "50").unwrap();
assert!(search.is_match(&tags) == true);
§Errors
- XTagError::Regex if tag_regex is not a valid regular expression
- XtagError::IntParse if rhs can’t be parsed into an integer
Sourcepub fn new_less_equal(tag_regex: &str, value: &str) -> Result<Self>
pub fn new_less_equal(tag_regex: &str, value: &str) -> Result<Self>
Returns new less or equal Searcher.
tag_regex specifies which tags are checked and rhs is matched against the integer representation of the associated values. Matches when one value of one matching tag matches. tag_regex is expanded with anchors to match the whole tag. If the value cannot be converted to integer that’s no match.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("bar".to_string(), Some("10".to_string()));
tags.insert("baz".to_string(), Some("100".to_string()));
let search = Searcher::new_less_equal("ba.", "10").unwrap();
assert!(search.is_match(&tags) == true);
Sourcepub fn new_greater(tag_regex: &str, value: &str) -> Result<Self>
pub fn new_greater(tag_regex: &str, value: &str) -> Result<Self>
Returns new greater Searcher.
tag_regex specifies which tags are checked and rhs is matched against the integer representation of the associated values. Matches when one value of one matching tag matches. tag_regex is expanded with anchors to match the whole tag. If the value cannot be converted to integer that’s no match.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("bar".to_string(), Some("10".to_string()));
tags.insert("baz".to_string(), Some("100".to_string()));
let search = Searcher::new_greater("ba.", "50").unwrap();
assert!(search.is_match(&tags) == true);
Sourcepub fn new_greater_equal(tag_regex: &str, value: &str) -> Result<Self>
pub fn new_greater_equal(tag_regex: &str, value: &str) -> Result<Self>
Returns new greater or equal Searcher.
tag_regex specifies which tags are checked and rhs is matched against the integer representation of the associated values. Matches when one value of one matching tag matches. tag_regex is expanded with anchors to match the whole tag. If the value cannot be converted to integer that’s no match.
§Example
let mut tags: XTags = HashMap::new();
tags.insert("bar".to_string(), Some("10".to_string()));
tags.insert("baz".to_string(), Some("100".to_string()));
let search = Searcher::new_greater_equal("ba.", "10").unwrap();
assert!(search.is_match(&tags) == true);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Searcher
impl RefUnwindSafe for Searcher
impl Send for Searcher
impl Sync for Searcher
impl Unpin for Searcher
impl UnwindSafe for Searcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more