pub struct Notification {
pub message: String,
pub notification_type: NotificationType,
pub created_at: Instant,
pub duration_secs: u64,
}Expand description
A toast notification
Fields§
§message: StringThe notification message
notification_type: NotificationTypeType of notification
created_at: InstantTime when notification was created (for auto-dismiss)
duration_secs: u64Duration to display (in seconds)
Implementations§
Source§impl Notification
impl Notification
Sourcepub fn new(
message: impl Into<String>,
notification_type: NotificationType,
) -> Self
pub fn new( message: impl Into<String>, notification_type: NotificationType, ) -> Self
Create a new notification
Sourcepub fn with_duration(self, seconds: u64) -> Self
pub fn with_duration(self, seconds: u64) -> Self
Set the duration for this notification
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the notification has expired
Sourcepub fn remaining_fraction(&self) -> f64
pub fn remaining_fraction(&self) -> f64
Get remaining time as a fraction (0.0 to 1.0)
Trait Implementations§
Source§impl Clone for Notification
impl Clone for Notification
Source§fn clone(&self) -> Notification
fn clone(&self) -> Notification
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Notification
impl RefUnwindSafe for Notification
impl Send for Notification
impl Sync for Notification
impl Unpin for Notification
impl UnwindSafe for Notification
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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