pub struct Message { /* private fields */ }Expand description
A sentence to show the user once, with an optional thing to do about it.
ⓘ
Message::new("Task deleted")
.with_action("Undo", move |()| restore())
.with_duration(MessageDuration::Long)
.show();Nothing here says where the message appears or what it looks like. Material calls it a
snackbar, Apple a transient overlay, GNOME a toast: the design system decides, the same
way it decides what a Dialog looks like.
Implementations§
Source§impl Message
impl Message
pub fn new(text: impl Into<String>) -> Self
Sourcepub fn with_action(
self,
label: impl Into<String>,
on_action: impl FnMut(()) + 'static,
) -> Self
pub fn with_action( self, label: impl Into<String>, on_action: impl FnMut(()) + 'static, ) -> Self
Adds the one thing the user can do about the message, such as undoing it.
Call this from a component or an event handler: the callback is owned by the scope it is created in, which is what lets it touch that scope’s signals when it runs.
pub fn with_duration(self, duration: MessageDuration) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for Message
impl !Send for Message
impl !Sync for Message
impl !UnwindSafe for Message
impl Freeze for Message
impl Unpin for Message
impl UnsafeUnpin for Message
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
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.