Skip to main content

SnackBarQueue

Struct SnackBarQueue 

Source
pub struct SnackBarQueue<T> { /* private fields */ }
Expand description

A notification queue — pure, application-side (in the spirit of crate::form::Form).

Only one notification is visible at a time; the others wait. The application calls tick on every frame (with the elapsed time) to expire the current notification and present the next — Material-style auto-dismiss with no timer on the widget side. dismiss closes the current one immediately (a click on the action or the cross). Generic over the payload T (at minimum the text; often the kind and the action message too).

Implementations§

Source§

impl<T> SnackBarQueue<T>

Source

pub fn new() -> Self

An empty queue.

Source

pub fn push(&mut self, item: T, seconds: f32)

Adds a notification that will stay visible seconds seconds once at the front.

Source

pub fn current(&self) -> Option<&T>

The notification currently visible (the front of the queue), if there is one.

Source

pub fn tick(&mut self, dt: f32) -> bool

Runs dt seconds down on the notification at the front; if its time is up, it is removed (the next one starts its own countdown). Returns true if the visible notification changed (an expiry) — useful to request another render.

Source

pub fn start_leaving(&mut self)

Marks the current notification as leaving: the host can then play its exit transition (a fade) before the application removes it (via dismiss).

Source

pub fn is_leaving(&self) -> bool

Is the current notification leaving? (a disappearing fade is under way.)

Source

pub fn dismiss(&mut self) -> Option<T>

Closes the current notification at once (action, cross, end of exit); returns its payload.

Source

pub fn is_empty(&self) -> bool

true when no notification is pending.

Source

pub fn len(&self) -> usize

Number of queued notifications (the visible one + those pending).

Trait Implementations§

Source§

impl<T> Default for SnackBarQueue<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SnackBarQueue<T>
where VecDeque<(T, f32, bool)>: Freeze,

§

impl<T> RefUnwindSafe for SnackBarQueue<T>

§

impl<T> Send for SnackBarQueue<T>
where VecDeque<(T, f32, bool)>: Send,

§

impl<T> Sync for SnackBarQueue<T>
where VecDeque<(T, f32, bool)>: Sync,

§

impl<T> Unpin for SnackBarQueue<T>
where VecDeque<(T, f32, bool)>: Unpin,

§

impl<T> UnsafeUnpin for SnackBarQueue<T>
where VecDeque<(T, f32, bool)>: UnsafeUnpin,

§

impl<T> UnwindSafe for SnackBarQueue<T>
where VecDeque<(T, f32, bool)>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.