pub struct Toast { /* private fields */ }Expand description
Owned data for one overlay notification.
IDs route dismissal and should be unique. Duplicate IDs are accepted; a
bound-host dismissal removes every matching value while invoking its callback
once. Some("") description still selects the taller 72-pixel layout.
§Examples
use ailloli_ui_widgets::controls::{Toast, ToastTone};
let toast = Toast::new("saved", "Saved").tone(ToastTone::Success);
assert_eq!(toast.id(), "saved");Implementations§
Source§impl Toast
impl Toast
Sourcepub fn new(id: impl Into<String>, title: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, title: impl Into<String>) -> Self
Creates a neutral, closable toast with no description or icon.
Empty and duplicate IDs are accepted but unique stable IDs are recommended.
§Examples
use ailloli_ui_widgets::controls::Toast;
let toast = Toast::new("connected", "Connected");
assert_eq!(toast.title(), "Connected");Sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
Borrows the exact dismissal identity.
§Examples
use ailloli_ui_widgets::controls::Toast;
let toast = Toast::new("job-1", "Started");
assert_eq!(toast.id(), "job-1");Sourcepub fn title(&self) -> &str
pub fn title(&self) -> &str
Borrows the exact primary title.
§Examples
use ailloli_ui_widgets::controls::Toast;
let toast = Toast::new("job-1", "Started");
assert_eq!(toast.title(), "Started");Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Sets the secondary line, replacing any previous description.
An empty string remains Some and selects the taller toast layout.
§Examples
use ailloli_ui_widgets::controls::Toast;
let toast = Toast::new("saved", "Saved").description("All changes are on disk");
let _ = toast;Sourcepub fn tone(self, tone: ToastTone) -> Self
pub fn tone(self, tone: ToastTone) -> Self
Sets the semantic accent tone.
§Examples
use ailloli_ui_widgets::controls::{Toast, ToastTone};
let toast = Toast::new("failed", "Failed").tone(ToastTone::Danger);
let _ = toast;Sourcepub fn leading_icon(self, icon: IconId) -> Self
pub fn leading_icon(self, icon: IconId) -> Self
Sets a tone-tinted leading icon, replacing any prior icon.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::controls::Toast;
let toast = Toast::new("done", "Done").leading_icon(IconId::Check);
let _ = toast;Sourcepub fn closable(self, closable: bool) -> Self
pub fn closable(self, closable: bool) -> Self
Controls whether the close icon, hit bound, and dismiss path are present.
Non-closable toasts can still be removed by changing the host’s source.
§Examples
use ailloli_ui_widgets::controls::Toast;
let toast = Toast::new("sync", "Syncing").closable(false);
let _ = toast;Trait Implementations§
impl StructuralPartialEq for Toast
Auto Trait Implementations§
impl Freeze for Toast
impl RefUnwindSafe for Toast
impl Send for Toast
impl Sync for Toast
impl Unpin for Toast
impl UnwindSafe for Toast
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.