pub struct State<A = ()> { /* private fields */ }toast only.Expand description
The toast queue. The first limit toasts are visible and
counting down; the rest wait until a visible one closes.
A toast with an action goes ahead of every toast without one that is
waiting, and when the visible toasts are full it takes the place of the
newest visible toast without an action, which waits again and restarts
its countdown when it comes back. While the pointer is over the toasts
(Event::Pause) no countdown runs.
A is what action buttons hand back, usually the app’s message, so an
Undo toast can carry the message that undoes. A queue without payloads
is State<()>, made with State::new; one with payloads is made with
State::default.
Implementations§
Source§impl<A> State<A>
impl<A> State<A>
Sourcepub fn with_limit(self, limit: usize) -> Self
pub fn with_limit(self, limit: usize) -> Self
Sets how many toasts are visible at once. At least one is.
pub fn limit(&self) -> usize
Sourcepub fn push_with(&mut self, toast: Toast, payload: A) -> Id
pub fn push_with(&mut self, toast: Toast, payload: A) -> Id
Queues a toast whose action button hands back payload as
Output::Payload, and returns its id.
Sourcepub fn dismiss(&mut self, id: Id) -> Option<Toast>
pub fn dismiss(&mut self, id: Id) -> Option<Toast>
Removes a toast, visible or waiting, dropping any payload.
Sourcepub fn tick(&mut self, now: Instant) -> Vec<Id>
pub fn tick(&mut self, now: Instant) -> Vec<Id>
Closes expired toasts and starts the countdown of newly visible ones. While paused, the time since the last tick is added back to every countdown instead. Returns the ids that closed.
Sourcepub fn is_paused(&self) -> bool
pub fn is_paused(&self) -> bool
Whether the countdowns are stopped because the pointer is over the toasts.
pub fn update(&mut self, event: Event) -> Option<Output<A>>
Sourcepub fn visible(&self) -> impl Iterator<Item = (Id, &Toast)>
pub fn visible(&self) -> impl Iterator<Item = (Id, &Toast)>
The visible toasts, top to bottom in queue order: oldest first, with toasts that have an action moved ahead of waiting ones.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn needs_tick(&self) -> bool
pub fn needs_tick(&self) -> bool
Whether a visible toast still has to count down.
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for State<A>
impl<A> RefUnwindSafe for State<A>where
VecDeque<Entry<A>>: RefUnwindSafe,
impl<A> Send for State<A>
impl<A> Sync for State<A>
impl<A> Unpin for State<A>
impl<A> UnsafeUnpin for State<A>where
VecDeque<Entry<A>>: UnsafeUnpin,
impl<A> UnwindSafe for State<A>where
VecDeque<Entry<A>>: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.