pub struct ToastEngine<A>{ /* private fields */ }Expand description
A toast engine for displaying temporary messages in a terminal UI.
The ToastEngine manages the display of toasts, which are temporary messages that appear on the screen for a short duration. It supports different types of toasts (info, success, warning, error) and allows customization of their position and duration.
You can call show_toast to display a toast, and hide_toast to hide the toast. To animate,
you can get the area of the toast using toast_area and implement your animation logic based on that area. #[derive(Debug)]
Caveat: If you’re not using the tokio feature, create a ToastEngine<()>. There is a (hacky) impl to make it work without the tokio feature.
Implementations§
Source§impl<A> ToastEngine<A>
impl<A> ToastEngine<A>
Sourcepub fn new(_: Self) -> Self
pub fn new(_: Self) -> Self
Creates a new ToastEngine. Consider using the ToastEngineBuilder instead.
Sourcepub fn from_builder(_: ToastEngineBuilder<A>) -> Self
pub fn from_builder(_: ToastEngineBuilder<A>) -> Self
Creates a new ToastEngine from a ToastEngineBuilder. This method takes the configuration from the builder and initializes the ToastEngine accordingly. It sets up the area for displaying toasts, the default duration for toasts, and any channel sender if provided (when using the tokio feature).
Sourcepub fn show_toast(&mut self, toast: ToastBuilder)
pub fn show_toast(&mut self, toast: ToastBuilder)
Shows a toast message using the provided ToastBuilder. This method calculates the area for the toast based on the message content and the specified position, creates a new Toast instance, and sets it as the current toast to be rendered. If the tokio feature is enabled and a channel sender is configured, it also spawns a task to automatically hide the toast after the default duration.
Sourcepub fn toast_area(&self) -> Rect
pub fn toast_area(&self) -> Rect
Get the area where the toast will be rendered.
Sourcepub fn hide_toast(&mut self)
pub fn hide_toast(&mut self)
Hides the currently displayed toast, if any. This method sets the current toast to None, which will cause it to no longer be rendered on the screen.
Trait Implementations§
Source§impl<A> Widget for &ToastEngine<A>
impl<A> Widget for &ToastEngine<A>
Source§impl<A> WidgetRef for ToastEngine<A>
impl<A> WidgetRef for ToastEngine<A>
Source§fn render_ref(&self, _area: Rect, buf: &mut Buffer)
fn render_ref(&self, _area: Rect, buf: &mut Buffer)
Auto Trait Implementations§
impl<A> Freeze for ToastEngine<A>
impl<A> RefUnwindSafe for ToastEngine<A>where
A: RefUnwindSafe,
impl<A> Send for ToastEngine<A>
impl<A> Sync for ToastEngine<A>where
A: Sync,
impl<A> Unpin for ToastEngine<A>where
A: Unpin,
impl<A> UnsafeUnpin for ToastEngine<A>
impl<A> UnwindSafe for ToastEngine<A>where
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
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 more