pub struct Snackbar { /* private fields */ }Expand description
A message for a window’s snackbar queue. The default timeout is four seconds.
Implementations§
Source§impl Snackbar
impl Snackbar
Sourcepub fn new(message: impl Into<SharedString>) -> Snackbar
pub fn new(message: impl Into<SharedString>) -> Snackbar
Creates a snackbar with the given message text and a default four-second timeout.
Sourcepub fn timeout(self, timeout: Option<Duration>) -> Snackbar
pub fn timeout(self, timeout: Option<Duration>) -> Snackbar
Sets how long the message is visible. None waits for explicit dismissal.
Sourcepub fn action(
self,
label: impl Into<SharedString>,
action: impl Fn(&mut Window, &mut App) + 'static,
) -> Snackbar
pub fn action( self, label: impl Into<SharedString>, action: impl Fn(&mut Window, &mut App) + 'static, ) -> Snackbar
Adds a keyboard-accessible action. By default, messages with an action
persist. Call timeout after this method to set a duration explicitly.
Sourcepub fn message(&self) -> &SharedString
pub fn message(&self) -> &SharedString
Returns the plain message used as the status announcement.
Sourcepub fn action_label(&self) -> Option<&SharedString>
pub fn action_label(&self) -> Option<&SharedString>
Returns the accessible name of the optional action.
Sourcepub fn message_content<E>(
self,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Snackbarwhere
E: IntoElement,
pub fn message_content<E>(
self,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Snackbarwhere
E: IntoElement,
Replaces the visible message with repeatable decorative content.
Sourcepub fn action_content<E>(
self,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Snackbarwhere
E: IntoElement,
pub fn action_content<E>(
self,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Snackbarwhere
E: IntoElement,
Replaces the visible content of the named action supplied by Self::action.
Sourcepub fn dismiss_label(self, label: impl Into<SharedString>) -> Snackbar
pub fn dismiss_label(self, label: impl Into<SharedString>) -> Snackbar
Overrides the accessible name of the default dismiss button (default "Dismiss message").
Sourcepub fn dismiss_content<E>(
self,
label: impl Into<SharedString>,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Snackbarwhere
E: IntoElement,
pub fn dismiss_content<E>(
self,
label: impl Into<SharedString>,
content: impl Fn(&mut Window, &mut App) -> E + 'static,
) -> Snackbarwhere
E: IntoElement,
Supplies the accessible name and decorative content of the close affordance.
Sourcepub fn show_dismiss(self, show: bool) -> Snackbar
pub fn show_dismiss(self, show: bool) -> Snackbar
Shows or hides the explicit dismiss button. It is shown by default.
Sourcepub fn action_on_new_line(self, enabled: bool) -> Snackbar
pub fn action_on_new_line(self, enabled: bool) -> Snackbar
Places the action below the message for a long action label.
Sourcepub fn shape(self, shape: CornerShape) -> Snackbar
pub fn shape(self, shape: CornerShape) -> Snackbar
Overrides the corner shape of the snackbar container.
Sourcepub fn tone(self, tone: SemanticTone) -> Snackbar
pub fn tone(self, tone: SemanticTone) -> Snackbar
Applies a Material 3 semantic tone shortcut.
SemanticTone::Default keeps the M3 inverse palette; semantic tones
use (Container, OnContainer, Role) while explicit Self::colors
overrides still take precedence.
Sourcepub fn colors(self, colors: SnackbarColors) -> Snackbar
pub fn colors(self, colors: SnackbarColors) -> Snackbar
Overrides the snackbar’s container, content, action, and dismiss colors.
Auto Trait Implementations§
impl !RefUnwindSafe for Snackbar
impl !Send for Snackbar
impl !Sync for Snackbar
impl !UnwindSafe for Snackbar
impl Forget for Snackbar
impl Freeze for Snackbar
impl Move for Snackbar
impl Unpin for Snackbar
impl UnsafeUnpin for Snackbar
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more