streamson_lib/matcher.rs
1//! Collections of path matchers (matches the path).
2
3use crate::streamer::ParsedKind;
4use std::fmt;
5
6pub mod combinator;
7pub mod depth;
8#[cfg(feature = "with_regex")]
9pub mod regex;
10pub mod simple;
11
12pub use self::combinator::Combinator;
13pub use self::depth::Depth;
14#[cfg(feature = "with_regex")]
15pub use self::regex::Regex;
16pub use self::simple::Simple;
17
18use crate::path::Path;
19
20/// Common Matcher trait
21pub trait Matcher: fmt::Debug + Send {
22 /// Check whether the path matches
23 /// # Arguments
24 /// * `path` - path to be matched (has to be a valid path)
25 /// * `kind` - what kind (object, array, boolean, ...) are matched data
26 ///
27 /// # Returns
28 /// * `true` if path matches, `false` otherwise
29 fn match_path(&self, path: &Path, kind: ParsedKind) -> bool;
30}