add register_handler to Client
This commit is contained in:
parent
c326d5b07e
commit
11c99ec387
2 changed files with 13 additions and 11 deletions
|
|
@ -11,7 +11,7 @@ use sasl::common::{Credentials as SaslCredentials, Identity, Secret, ChannelBind
|
|||
use sasl::common::scram::{Sha1, Sha256};
|
||||
use components::sasl_error::SaslError;
|
||||
use util::FromElement;
|
||||
use event::{Dispatcher, Propagation, SendElement, ReceiveElement, Priority};
|
||||
use event::{Event, Dispatcher, Propagation, SendElement, ReceiveElement, Priority};
|
||||
|
||||
use base64;
|
||||
|
||||
|
|
@ -128,6 +128,13 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn register_handler<E, F>(&mut self, pri: Priority, func: F)
|
||||
where
|
||||
E: Event,
|
||||
F: Fn(&E) -> Propagation + 'static {
|
||||
self.dispatcher.lock().unwrap().register(pri, func);
|
||||
}
|
||||
|
||||
/// Returns the plugin given by the type parameter, if it exists, else panics.
|
||||
pub fn plugin<P: Plugin>(&self) -> &P {
|
||||
self.plugins.get(&TypeId::of::<P>())
|
||||
|
|
|
|||
Loading…
Reference in a new issue