pub struct ToastAction { /* private fields */ }Expand description
One actionable element inside a Toast — a button or hyperlink
the user can click to drive a domain action.
Implementations§
Source§impl ToastAction
impl ToastAction
Sourcepub fn new(
label: impl Into<LocalizedString>,
on_invoke: impl Fn(&mut EventContext<'_>) + 'static,
) -> Self
pub fn new( label: impl Into<LocalizedString>, on_invoke: impl Fn(&mut EventContext<'_>) + 'static, ) -> Self
Build an action with the default Link style and
closes_toast = true (IntelliJ “expiring action” semantics).
Sourcepub fn primary(
label: impl Into<LocalizedString>,
on_invoke: impl Fn(&mut EventContext<'_>) + 'static,
) -> Self
pub fn primary( label: impl Into<LocalizedString>, on_invoke: impl Fn(&mut EventContext<'_>) + 'static, ) -> Self
Shorthand for ToastAction::new(label, on_invoke).style(Button { Filled }).
The visual-weight default for primary calls-to-action.
Sourcepub fn destructive(
label: impl Into<LocalizedString>,
on_invoke: impl Fn(&mut EventContext<'_>) + 'static,
) -> Self
pub fn destructive( label: impl Into<LocalizedString>, on_invoke: impl Fn(&mut EventContext<'_>) + 'static, ) -> Self
Shorthand for the destructive button variant — red-tinted for confirm-style “Delete” / “Discard” actions.
Sourcepub fn style(self, style: ToastActionStyle) -> Self
pub fn style(self, style: ToastActionStyle) -> Self
Override the action’s visual style. Default is Link.
Sourcepub fn closes_toast(self, closes: bool) -> Self
pub fn closes_toast(self, closes: bool) -> Self
Whether invoking this action also dismisses the toast. Default
is true — matches IntelliJ’s “expiring action” semantics.
Set to false for actions that toggle state without closing
(e.g. “Show details” disclosure inside a sticky toast).
Sourcepub fn shortcut_id(self, id: impl Into<String>) -> Self
pub fn shortcut_id(self, id: impl Into<String>) -> Self
Associate the action with a registered Shortcut id. Two
effects: the keystroke label is shown as a chip on the action,
and the archived form of this action (in
NotificationLog)
is re-invokable by name through the existing Intent
dispatcher.
Sourcepub fn tooltip(self, text: impl Into<LocalizedString>) -> Self
pub fn tooltip(self, text: impl Into<LocalizedString>) -> Self
Optional tooltip text shown when the pointer hovers the action.
Sourcepub fn label(&self) -> String
pub fn label(&self) -> String
Resolve the action label to a plain string using the current locale.
Sourcepub fn style_ref(&self) -> &ToastActionStyle
pub fn style_ref(&self) -> &ToastActionStyle
Return the action’s rendering style (link vs button variant).
Sourcepub fn closes_toast_flag(&self) -> bool
pub fn closes_toast_flag(&self) -> bool
Return true when invoking this action also dismisses the toast.
Sourcepub fn shortcut_id_ref(&self) -> Option<&str>
pub fn shortcut_id_ref(&self) -> Option<&str>
Return the associated Shortcut id, if any.
Sourcepub fn tooltip_ref(&self) -> Option<&LocalizedString>
pub fn tooltip_ref(&self) -> Option<&LocalizedString>
Return the optional tooltip text, if one was set via tooltip.
Sourcepub fn callback(&self) -> ToastActionCallback
pub fn callback(&self) -> ToastActionCallback
Clone the invocation callback — cheap because the underlying closure is Rc-wrapped.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ToastAction
impl !Send for ToastAction
impl !Sync for ToastAction
impl !UnwindSafe for ToastAction
impl Freeze for ToastAction
impl Unpin for ToastAction
impl UnsafeUnpin for ToastAction
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§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>
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