Skip to main content

EventContextToastExt

Trait EventContextToastExt 

Source
pub trait EventContextToastExt {
    // Required methods
    fn show_toast(&mut self, toast: Toast) -> ToastHandle;
    fn dismiss_toast(&mut self, handle: &ToastHandle);
}
Expand description

Convenience methods on [EventContext] for the toast system. The registry is looked up via [EventContext::app_state] — the install_toast extension trait registers ToastRegistry there at app boot.

All methods are no-ops (returning a dropped ToastHandle where applicable) when install_toast was not called — a one-shot log::warn! fires the first time the missing registration is detected, so missing installs surface in logs without crashing app code that defensively calls show_toast.

Required Methods§

Source

fn show_toast(&mut self, toast: Toast) -> ToastHandle

Present a Toast through the installed ToastHost. Returns a ToastHandle for programmatic control.

Source

fn dismiss_toast(&mut self, handle: &ToastHandle)

Programmatically dismiss a toast by handle, with cause ToastDismissCause::Programmatic. Equivalent to handle.dismiss(ctx). No-op if the toast has already been dismissed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl EventContextToastExt for EventContext<'_>

Source§

fn show_toast(&mut self, toast: Toast) -> ToastHandle

Source§

fn dismiss_toast(&mut self, handle: &ToastHandle)

Implementors§