Struct Notification

Source
pub struct Notification<'a> { /* private fields */ }
Expand description

Options to further customize the notification

Implementations§

Source§

impl<'a> Notification<'a>

Source

pub fn new() -> Self

Create a Notification to further customize the notification

Source

pub fn title(&mut self, title: &'a str) -> &mut Self

Set title field

Source

pub fn subtitle(&mut self, subtitle: &'a str) -> &mut Self

Set subtitle field

Source

pub fn maybe_subtitle(&mut self, subtitle: Option<&'a str>) -> &mut Self

Set subtitle field

Source

pub fn message(&mut self, message: &'a str) -> &mut Self

Set message field

Source

pub fn main_button(&mut self, main_button: MainButton<'a>) -> &mut Self

Allow actions through a main button

§Example:
let _ = Notification::new().main_button(MainButton::SingleAction("Main button"));
Source

pub fn close_button(&mut self, close_button: &'a str) -> &mut Self

Display a close button with the given name

§Example:
let _ = Notification::new().close_button("Close");
Source

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");
Source

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");
Source

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);
Source

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();
Source

pub fn sound<S>(&mut self, sound: S) -> &mut Self
where S: Into<Sound>,

Play a system sound when the notification is delivered. Use Sound::Default to play the default sound.

§Example:
let _ = Notification::new().sound("Blow");
Source

pub fn maybe_sound<S>(&mut self, sound: Option<S>) -> &mut Self
where S: Into<Sound>,

Play a system sound when the notification is delivered. Use Sound::Default to play the default sound.

§Example:
let _ = Notification::new().sound("Blow");
Source

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);
Source

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>

Source§

fn clone(&self) -> Notification<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Default for Notification<'a>

Source§

fn default() -> Notification<'a>

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

Auto Trait Implementations§

§

impl<'a> Freeze for Notification<'a>

§

impl<'a> RefUnwindSafe for Notification<'a>

§

impl<'a> Send for Notification<'a>

§

impl<'a> Sync for Notification<'a>

§

impl<'a> Unpin for Notification<'a>

§

impl<'a> UnwindSafe for Notification<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,