pub struct OnEvent { /* private fields */ }Expand description
An event handler that triggers a specified action when a certain event occurs.
Implementations§
Source§impl OnEvent
impl OnEvent
Sourcepub fn new<H: 'static>(event: Event, handler: impl HandlerFnOnce<H, ()>) -> Self
pub fn new<H: 'static>(event: Event, handler: impl HandlerFnOnce<H, ()>) -> Self
Creates a new OnEvent handler for the specified event and action.
§Arguments
event- The event to listen for.handler- The action to execute when the event occurs.
Sourcepub fn into_handler(self) -> BoxHandlerOnce<()>
pub fn into_handler(self) -> BoxHandlerOnce<()>
Consumes the OnEvent and returns the boxed handler.
Sourcepub fn handle(self, env: &Environment)
pub fn handle(self, env: &Environment)
Handles the event by invoking the stored handler.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OnEvent
impl !RefUnwindSafe for OnEvent
impl !Send for OnEvent
impl !Sync for OnEvent
impl Unpin for OnEvent
impl !UnwindSafe for OnEvent
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