Allow the use of custom context
The main goal of events/reports is to update a context object, which will be used in filters to generate a response. It is now possible to use any object implementing both Clone and Default as a context object. It is also possible to define no context at all.
This commit is contained in:
parent
dd7f4d1a86
commit
4b1f99db7e
6 changed files with 75 additions and 18 deletions
|
@ -65,11 +65,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_eventhandler_build_noctx() {
|
||||
// TODO: Remove the ::<NoContext>
|
||||
EventHandler::new(
|
||||
"Any",
|
||||
Callback::NoCtx::<NoContext>(|_entry: &Entry| {}),
|
||||
);
|
||||
EventHandler::new("Any", Callback::NoCtx::<NoContext>(|_entry: &Entry| {}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -79,16 +79,14 @@ impl<T: Clone + Default + 'static> SmtpIn<T> {
|
|||
let mut evts = Vec::new();
|
||||
for eh in self.event_handlers.iter() {
|
||||
match eh.event {
|
||||
MatchEvent::Evt(ref v) => {
|
||||
for e in v.iter() {
|
||||
evts.push(e);
|
||||
}
|
||||
MatchEvent::Evt(ref v) => for e in v.iter() {
|
||||
evts.push(e);
|
||||
},
|
||||
MatchEvent::All => {
|
||||
println!("register|report|smtp-in|*");
|
||||
evts.clear();
|
||||
break ;
|
||||
},
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
evts.dedup();
|
||||
|
|
Reference in a new issue