pub struct ToastState { /* private fields */ }Expand description
One retained notification. Applications own its message, actions and stacking.
Showing a toast never takes focus. Its countdown starts when mounted and pauses while hovered, while it or a descendant owns focus, and while the window is inactive. Resuming spends only the remaining duration. Explicitly dismissing a focused toast restores the focus captured when it was shown; closing an unfocused toast never moves another control’s focus.
Implementations§
Source§impl ToastState
impl ToastState
Sourcepub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self
pub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self
Uses a five-second lifetime; configure it before mounting with
Self::with_duration. Keep the matching Toast mounted even when closed.
Sourcepub fn with_duration(self, duration: Duration) -> Self
pub fn with_duration(self, duration: Duration) -> Self
A nonzero amount of active, unattended time before dismissal.
pub fn is_open(&self) -> bool
Sourcepub fn focus_handle(&self) -> &FocusHandle
pub fn focus_handle(&self) -> &FocusHandle
The non-Tab-stop notification scope. Its action buttons keep their own ordinary Tab stops; applications may use this handle to announce/focus the notification on an explicit user request.
Sourcepub fn show(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn show(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Shows or replaces the notification and restarts its full lifetime.
pub fn dismiss(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Trait Implementations§
impl EventEmitter<ToastEvent> for ToastState
Auto Trait Implementations§
impl !RefUnwindSafe for ToastState
impl !Send for ToastState
impl !Sync for ToastState
impl !UnwindSafe for ToastState
impl Forget for ToastState
impl Freeze for ToastStatewhere
NonZero<u32>: Freeze,
*const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: Freeze,
PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: Freeze,
*const () is !null: Freeze,
PhantomData<((), RunnableMeta)>: Freeze,
*const Task<Box<dyn Any + Sync + Send>> is !null: Freeze,
PhantomData<Task<Box<dyn Any + Sync + Send>>>: Freeze,
PhantomData<fn()>: Freeze,
*const ArcInner<Mutex<RawMutex, RendezvousState<()>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<RawMutex, RendezvousState<()>>>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Subscription>: Freeze,
impl Move for ToastState
impl Unpin for ToastStatewhere
NonZero<u32>: Unpin,
Arc<RwLock<RawRwLock, FocusMap>>: Unpin,
*const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: Unpin,
Task<(), RunnableMeta>: Unpin,
Box<Task<Box<dyn Any + Sync + Send>>>: Unpin,
Arc<Mutex<RawMutex, RendezvousState<()>>>: Unpin,
*const u8 is !null: Unpin,
Box<dyn FnOnce()>: Unpin,
impl UnsafeUnpin for ToastStatewhere
NonZeroU32Inner: UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, FocusMap>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<RawRwLock, FocusMap>>>: UnsafeUnpin,
*const () is !null: UnsafeUnpin,
PhantomData<((), RunnableMeta)>: UnsafeUnpin,
*const Task<Box<dyn Any + Sync + Send>> is !null: UnsafeUnpin,
PhantomData<Task<Box<dyn Any + Sync + Send>>>: UnsafeUnpin,
PhantomData<fn()>: UnsafeUnpin,
*const ArcInner<Mutex<RawMutex, RendezvousState<()>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<RawMutex, RendezvousState<()>>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Subscription>: UnsafeUnpin,
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