pub struct ToasterState<T> { /* private fields */ }Expand description
A retained stack of notifications, each with its own ToastState.
Applications push their own message values; the stack owns ordering,
lifetimes and removal. Only the newest Self::visible_limit entries are
mounted, so older ones wait without spending time and appear as newer ones
close. Each visible toast keeps the single-toast pause, focus and dismissal
contract.
Implementations§
Source§impl<T: 'static> ToasterState<T>
impl<T: 'static> ToasterState<T>
Sourcepub fn visible_limit(self, visible: usize) -> Self
pub fn visible_limit(self, visible: usize) -> Self
The number of newest notifications mounted at once.
Sourcepub fn with_duration(self, duration: Duration) -> Self
pub fn with_duration(self, duration: Duration) -> Self
The nonzero lifetime given to each notification pushed afterward.
Sourcepub fn push(
&mut self,
value: T,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> ToastKey
pub fn push( &mut self, value: T, window: &mut Window, cx: &mut Context<'_, Self>, ) -> ToastKey
Adds a notification without moving focus and returns its key.
Sourcepub fn replace(
&mut self,
key: ToastKey,
value: T,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> bool
pub fn replace( &mut self, key: ToastKey, value: T, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
Replaces a notification’s value in place and restarts its lifetime, for example when a pending operation completes. Returns false when the notification has already closed.
pub fn dismiss( &mut self, key: ToastKey, window: &mut Window, cx: &mut Context<'_, Self>, )
pub fn dismiss_all(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The number of open notifications, including those waiting to appear.
pub fn is_empty(&self) -> bool
Sourcepub fn visible(
&self,
) -> impl Iterator<Item = (ToastKey, &T, &Entity<ToastState>)>
pub fn visible( &self, ) -> impl Iterator<Item = (ToastKey, &T, &Entity<ToastState>)>
Mounted notifications, newest first.
Sourcepub fn focus_latest(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn focus_latest(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Moves focus into the newest notification on an explicit user request, such as an application shortcut. Dismissing it restores prior focus.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ToasterState<T>
impl<T> !Send for ToasterState<T>
impl<T> !Sync for ToasterState<T>
impl<T> !UnwindSafe for ToasterState<T>
impl<T> Forget for ToasterState<T>
impl<T> Freeze for ToasterState<T>
impl<T> Move for ToasterState<T>
impl<T> Unpin for ToasterState<T>
impl<T> UnsafeUnpin for ToasterState<T>where
Vec<ToasterEntry<T>>: 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().