pub struct ToastQueue { /* private fields */ }Expand description
Bounded queue of visible toasts.
When full, pushing a new toast drops the oldest entry to make
room. Expired toasts are dropped by ToastQueue::tick.
Implementations§
Source§impl ToastQueue
impl ToastQueue
Sourcepub const DEFAULT_LIFETIME: Duration
pub const DEFAULT_LIFETIME: Duration
Default visible lifetime used by ToastQueue::push.
Sourcepub fn push(&mut self, message: impl Into<String>, level: ToastLevel)
pub fn push(&mut self, message: impl Into<String>, level: ToastLevel)
Push a new toast with the default 3-second lifetime. Drops the oldest visible toast if the queue is already at capacity.
Sourcepub fn push_with_lifetime(
&mut self,
message: impl Into<String>,
level: ToastLevel,
lifetime: Duration,
)
pub fn push_with_lifetime( &mut self, message: impl Into<String>, level: ToastLevel, lifetime: Duration, )
Push a toast with a caller-supplied lifetime. Mainly useful for
tests that need a short-lived toast to exercise Self::tick.
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Drop expired toasts. Call on each render tick so entries disappear at the advertised lifetime even when no key / bus events arrive.
Sourcepub const fn visible_count(&self) -> usize
pub const fn visible_count(&self) -> usize
Number of currently-visible toasts.
Trait Implementations§
Source§impl Debug for ToastQueue
impl Debug for ToastQueue
Auto Trait Implementations§
impl Freeze for ToastQueue
impl RefUnwindSafe for ToastQueue
impl Send for ToastQueue
impl Sync for ToastQueue
impl Unpin for ToastQueue
impl UnsafeUnpin for ToastQueue
impl UnwindSafe for ToastQueue
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
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>
Converts
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>
Converts
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