Skip to content

Commit

Permalink
fix: make matchers clonable
Browse files Browse the repository at this point in the history
  • Loading branch information
shenek committed Jun 28, 2020
1 parent 3b8fcee commit d0bd6c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions streamson-lib/src/matcher/combinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use super::MatchMaker;
use std::ops;
use std::sync::Arc;

#[derive(Debug)]

#[derive(Debug, Clone)]
/// Combines several matches together
///
/// It implements normal boolean algebra
Expand All @@ -13,7 +13,7 @@ use std::ops;
/// * `comb1 | comb2` at least one should pass
pub enum Combinator {
/// Represents the actual underlying matcher
Matcher(Box<dyn MatchMaker>),
Matcher(Arc<dyn MatchMaker + Sync>),
/// Negates the expression
Not(Box<Combinator>),
/// Both expressions should be valid
Expand All @@ -38,8 +38,8 @@ impl Combinator {
///
/// # Arguments
/// * `matcher` - matcher to be wrapped
pub fn new(matcher: impl MatchMaker + 'static) -> Self {
Self::Matcher(Box::new(matcher))
pub fn new(matcher: impl MatchMaker + 'static + Sync) -> Self {
Self::Matcher(Arc::new(matcher))
}
}

Expand Down
2 changes: 1 addition & 1 deletion streamson-lib/src/matcher/depth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::MatchMaker;
/// Based on actual path depth
///
/// Path is matched when path depth is higher or equal min and lower or equal max (optional)
#[derive(Default, Debug)]
#[derive(Default, Debug, Clone)]
pub struct Depth {
min: usize,
max: Option<usize>,
Expand Down
2 changes: 1 addition & 1 deletion streamson-lib/src/matcher/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::str::FromStr;
/// It matches {"People"}[0]{"Height"} - height of the first person
/// It matches {"People"}[]{"Height"} - matches the height of all people
/// It matches {"People"}[0]{} - matches all attributes of the first person
#[derive(Default, Debug)]
#[derive(Default, Debug, Clone)]
pub struct Simple {
path_expr: String,
}
Expand Down

0 comments on commit d0bd6c8

Please sign in to comment.