pub trait EventExt:
Event
+ Sized
+ 'static {
// Provided methods
fn take_handler() -> Box<Handler<Self>> { ... }
fn replace_handler<F: FnMut(&Self) + Sync + Send + 'static>(
f: F,
) -> Box<Handler<Self>> { ... }
fn update_handler<F: FnMut(&Self) + Sync + Send + 'static>(f: F) { ... }
}Available on crate feature
unstable only.Expand description
Extension trait for setting handlers for an event.
Register a new event handler like:
event::ApStaConnected::update_handler(|_cs, event| {
new_handler(event);
})§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Provided Methods§
Sourcefn take_handler() -> Box<Handler<Self>>
fn take_handler() -> Box<Handler<Self>>
Get the handler for this event, replacing it with the default handler.
Sourcefn replace_handler<F: FnMut(&Self) + Sync + Send + 'static>(
f: F,
) -> Box<Handler<Self>>
fn replace_handler<F: FnMut(&Self) + Sync + Send + 'static>( f: F, ) -> Box<Handler<Self>>
Set the handler for this event, returning the old handler.
Sourcefn update_handler<F: FnMut(&Self) + Sync + Send + 'static>(f: F)
fn update_handler<F: FnMut(&Self) + Sync + Send + 'static>(f: F)
Atomic combination of Self::take_handler and
Self::replace_handler. Use this to add a new handler which runs
after the previously registered handlers.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.