pub struct Notification<'a> { /* private fields */ }
Expand description
Options to further customize the notification
Implementations§
Source§impl<'a> Notification<'a>
impl<'a> Notification<'a>
Sourcepub fn maybe_subtitle(&mut self, subtitle: Option<&'a str>) -> &mut Self
pub fn maybe_subtitle(&mut self, subtitle: Option<&'a str>) -> &mut Self
Set subtitle
field
Allow actions through a main button
§Example:
let _ = Notification::new().main_button(MainButton::SingleAction("Main button"));
Display a close button with the given name
§Example:
let _ = Notification::new().close_button("Close");
Sourcepub fn app_icon(&mut self, app_icon: &'a str) -> &mut Self
pub fn app_icon(&mut self, app_icon: &'a str) -> &mut Self
Display an icon on the left side of the notification
NOTE: The icon of the app associated to the bundle will be displayed next to the notification title
§Example:
let _ = Notification::new().app_icon("/path/to/icon.icns");
Sourcepub fn content_image(&mut self, content_image: &'a str) -> &mut Self
pub fn content_image(&mut self, content_image: &'a str) -> &mut Self
Display an image on the right side of the notification
§Example:
let _ = Notification::new().content_image("/path/to/image.png");
Sourcepub fn delivery_date(&mut self, delivery_date: f64) -> &mut Self
pub fn delivery_date(&mut self, delivery_date: f64) -> &mut Self
Schedule the notification to be delivered at a later time
§Example:
let stamp = time::OffsetDateTime::now_utc().unix_timestamp() as f64 + 5.;
let _ = Notification::new().delivery_date(stamp);
Sourcepub fn default_sound(&mut self) -> &mut Self
pub fn default_sound(&mut self) -> &mut Self
Play the default sound "NSUserNotificationDefaultSoundName"
system sound when the notification is delivered.
§Example:
let _ = Notification::new().default_sound();
Sourcepub fn sound<S>(&mut self, sound: S) -> &mut Self
pub fn sound<S>(&mut self, sound: S) -> &mut Self
Play a system sound when the notification is delivered. Use Sound::Default
to play the default sound.
§Example:
let _ = Notification::new().sound("Blow");
Sourcepub fn maybe_sound<S>(&mut self, sound: Option<S>) -> &mut Self
pub fn maybe_sound<S>(&mut self, sound: Option<S>) -> &mut Self
Play a system sound when the notification is delivered. Use Sound::Default
to play the default sound.
§Example:
let _ = Notification::new().sound("Blow");
Sourcepub fn asynchronous(&mut self, asynchronous: bool) -> &mut Self
pub fn asynchronous(&mut self, asynchronous: bool) -> &mut Self
Deliver the notification asynchronously (without waiting for an interaction).
Note: Setting this to true is equivalent to a fire-and-forget.
§Example:
let _ = Notification::new().asynchronous(true);
Sourcepub fn send(&self) -> NotificationResult<NotificationResponse>
pub fn send(&self) -> NotificationResult<NotificationResponse>
Delivers a new notification
Returns a NotificationError
if a notification could not be delivered
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