pub struct Notification<'a> {
pub app_id: &'a str,
pub title: &'a str,
pub message: &'a str,
pub icon: MessageIcon,
pub timeout: i32,
}Expand description
Notification.
Shows a brief message to the user without blocking their interaction with the application.
// Define a unique application identifier for the notification system.
const APP_ID: &str = "com.example.myapp";
// Invoke setup at application initialization to ensure the application
// is registered and ready to show notifications later.
rustydialogs::Notification::setup(APP_ID);
rustydialogs::Notification {
app_id: APP_ID,
title: "Task Complete",
message: "All files were processed successfully.",
icon: rustydialogs::MessageIcon::Info,
timeout: rustydialogs::Notification::SHORT_TIMEOUT,
}.show();Fields§
§app_id: &'a strApplication identifier used by notification backends.
This is a best-effort hint: some backends may ignore it, and some only honor the first value seen by the process/session.
title: &'a strThe title of the notification.
message: &'a strThe message to display in the notification.
icon: MessageIconThe icon to show in the notification.
timeout: i32Timeout in milliseconds after which the notification should automatically close.
A value less than or equal to 0 means that the notification will not automatically close.
This is a best-effort hint: some backends may ignore it and use their own default timeout, or may not support timeouts at all.
Implementations§
Source§impl<'a> Notification<'a>
impl<'a> Notification<'a>
Sourcepub const SHORT_TIMEOUT: i32 = 5000
pub const SHORT_TIMEOUT: i32 = 5000
Short timeout duration in milliseconds for notification popups.
Sourcepub const LONG_TIMEOUT: i32 = 10000
pub const LONG_TIMEOUT: i32 = 10000
Long timeout duration in milliseconds for notification popups.
Sourcepub fn setup(app_id: &str)
pub fn setup(app_id: &str)
Perform any necessary setup for notifications, such as registering the application with the notification system.
This step is optional, when skipped the library will attempt to perform any necessary setup automatically when showing the first notification, but this method can be used to ensure that the setup is done at a specific time in the application lifecycle.
§Windows
By default, this initializes a process-wide tray icon used for balloon notifications.
When using the winrt-toast backend, this creates a Start Menu shortcut for the application with the provided application identifier, which is required for showing toast notifications on Windows.
It is recommended to call this method during application initialization before showing any notifications or the first notification may be skipped due to delays in the shortcut creation process.
§Linux
When using the libnotify backend, this registers the application with the notification system using the provided application identifier.
Trait Implementations§
Source§impl<'a> Clone for Notification<'a>
impl<'a> Clone for Notification<'a>
Source§fn clone(&self) -> Notification<'a>
fn clone(&self) -> Notification<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more