pub struct HandlerMap(/* private fields */);
Expand description
Struct that maps types with functions or closures that can receive them.
See the module-level documentation for more information.
Implementations§
Source§impl HandlerMap
impl HandlerMap
Sourcepub fn new() -> HandlerMap
pub fn new() -> HandlerMap
Creates a new map with no handlers.
Sourcepub fn insert<T: Any, F: Fn(T) + 'static>(&mut self, handler: F)
pub fn insert<T: Any, F: Fn(T) + 'static>(&mut self, handler: F)
Registers a new handler into the map.
Sourcepub fn is_registered<T: Any>(&self) -> bool
pub fn is_registered<T: Any>(&self) -> bool
Returns true if the given message type has a handler registered in the map.
Sourcepub fn val_is_registered<T: Any>(&self, _msg: &T) -> bool
pub fn val_is_registered<T: Any>(&self, _msg: &T) -> bool
Returns true if the given message has a handler registered in this map.
This is the same operation as is_registered
, but allows you to call it with a value
rather than having to supply the type.
Trait Implementations§
Source§impl Default for HandlerMap
impl Default for HandlerMap
Source§fn default() -> HandlerMap
fn default() -> HandlerMap
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for HandlerMap
impl RefUnwindSafe for HandlerMap
impl Send for HandlerMap
impl Sync for HandlerMap
impl Unpin for HandlerMap
impl !UnwindSafe for HandlerMap
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