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.
The action runs on the UI thread, inside the runtime the application launched, so it can change the same state an event handler can.
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