pub struct Trigger { /* private fields */ }
Expand description
Processes data from input and triggers handlers
Implementations§
Source§impl Trigger
impl Trigger
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Trigger
It collects matched data and triggers handlers when entire data are read.
Sourcepub fn add_matcher(
&mut self,
matcher: Box<dyn Matcher>,
handler: Arc<Mutex<dyn Handler>>,
)
pub fn add_matcher( &mut self, matcher: Box<dyn Matcher>, handler: Arc<Mutex<dyn Handler>>, )
Adds a mathcher and a handler to Trigger
§Arguments
matcher
- matcher which matches the pathhandler
- handler to be triggers when path matches
§Example
use streamson_lib::{strategy, matcher, handler};
use std::{io, sync::{Arc, Mutex}};
let mut trigger = strategy::Trigger::new();
let handler = handler::Output::new(io::stdout());
let matcher = matcher::Simple::new(r#"{"list"}[]"#).unwrap();
trigger.add_matcher(
Box::new(matcher),
Arc::new(Mutex::new(handler))
);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Trigger
impl !RefUnwindSafe for Trigger
impl Send for Trigger
impl !Sync for Trigger
impl Unpin for Trigger
impl !UnwindSafe for Trigger
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
Mutably borrows from an owned value. Read more