Skip to main content

ToastState

Struct ToastState 

Source
pub struct ToastState {
    pub messages: Vec<ToastMessage>,
}
Expand description

State for toast notification display.

Add messages with ToastState::info, ToastState::success, ToastState::warning, or ToastState::error, then pass the state to Context::toast each frame. Expired messages are removed automatically.

Fields§

§messages: Vec<ToastMessage>

Active toast messages, ordered oldest-first.

Implementations§

Source§

impl ToastState

Source

pub fn new() -> Self

Create an empty toast state with no messages.

Source

pub fn info(&mut self, text: impl Into<String>, tick: u64)

Push an informational toast visible for 30 ticks.

Source

pub fn success(&mut self, text: impl Into<String>, tick: u64)

Push a success toast visible for 30 ticks.

Source

pub fn warning(&mut self, text: impl Into<String>, tick: u64)

Push a warning toast visible for 50 ticks.

Source

pub fn error(&mut self, text: impl Into<String>, tick: u64)

Push an error toast visible for 80 ticks.

Source

pub fn push( &mut self, text: impl Into<String>, level: ToastLevel, tick: u64, duration_ticks: u64, )

Push a toast with a custom level and duration.

Source

pub fn cleanup(&mut self, current_tick: u64)

Remove all messages whose display duration has elapsed.

Called automatically by Context::toast before rendering.

Trait Implementations§

Source§

impl Default for ToastState

Source§

fn default() -> Self

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

Auto Trait Implementations§

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.