[][src]Struct notify_rust::Notification

pub struct Notification {
    pub appname: String,
    pub summary: String,
    pub subtitle: Option<String>,
    pub body: String,
    pub icon: String,
    pub hints: HashSet<NotificationHint>,
    pub actions: Vec<String>,
    pub timeout: Timeout,
    // some fields omitted
}

Desktop notification.

A desktop notification is configured via builder pattern, before it is launched with show().

Fields

appname: String

Filled by default with executable name.

summary: String

Single line to summarize the content.

subtitle: Option<String>

Subtitle for macOS

body: String

Multiple lines possible, may support simple markup, check out get_capabilities() -> body-markup and body-hyperlinks.

icon: String

Use a file:// URI or a name in an icon theme, must be compliant freedesktop.org.

hints: HashSet<NotificationHint>

Check out NotificationHint

actions: Vec<String>

See Notification::actions() and Notification::action()

timeout: Timeout

Lifetime of the Notification in ms. Often not respected by server, sorry.

Methods

impl Notification[src]

pub fn new() -> Notification[src]

Constructs a new Notification.

Most fields are empty by default, only appname is initialized with the name of the current executable. The appname is used by some desktop environments to group notifications.

pub fn appname(&mut self, appname: &str) -> &mut Notification[src]

Overwrite the appname field used for Notification.

Platform Support

Please note that this method has no effect on macOS. Here you can only set the application via set_application()

pub fn summary(&mut self, summary: &str) -> &mut Notification[src]

Set the summary.

Often acts as title of the notification. For more elaborate content use the body field.

pub fn subtitle(&mut self, subtitle: &str) -> &mut Notification[src]

Set the subtitle.

This is only useful on macOS, it's not part of the XDG specification and will therefore be eaten by gremlins under your CPU 😈🤘.

pub fn sound_name(&mut self, name: &str) -> &mut Notification[src]

Set the sound_name for the NSUserNotification

pub fn body(&mut self, body: &str) -> &mut Notification[src]

Set the content of the body field.

Multiline textual content of the notification. Each line should be treated as a paragraph. Simple html markup should be supported, depending on the server implementation.

pub fn icon(&mut self, icon: &str) -> &mut Notification[src]

Set the icon field.

You can use common icon names here, usually those in /usr/share/icons can all be used. You can also use an absolute path to file.

Platform support

macOS does not have support manually setting the icon. However you can pretend to be another app using set_application()

pub fn auto_icon(&mut self) -> &mut Notification[src]

Set the icon field automatically.

This looks at your binary's name and uses it to set the icon.

Platform support

macOS does not support manually setting the icon. However you can pretend to be another app using set_application()

pub fn hint(&mut self, hint: NotificationHint) -> &mut Notification[src]

Adds a hint.

This method will add a hint to the internal hint hashset. Hints must be of type NotificationHint.

Many of these are again wrapped by more convenient functions such as:

Notification::new().summary("Category:email")
                   .body("This should not go away until you acknoledge it.")
                   .icon("thunderbird")
                   .appname("thunderbird")
                   .hint(NotificationHint::Category("email".to_owned()))
                   .hint(NotificationHint::Resident(true))
                   .show();

Platform support

Most of these hints don't even have an effect on the big XDG Desktops, they are completely tossed on macOS.

pub fn timeout<T: Into<Timeout>>(&mut self, timeout: T) -> &mut Notification[src]

Set the timeout.

This sets the time (in milliseconds) from the time the notification is displayed until it is closed again by the Notification Server. According to specification -1 will leave the timeout to be set by the server and 0 will cause the notification never to expire.

Platform support

This only works on XDG Desktops, macOS does not support manually setting the timeout.

pub fn urgency(&mut self, urgency: NotificationUrgency) -> &mut Notification[src]

Set the urgency.

Pick between Medium, Low and High.

Platform support

Most Desktops on linux and bsd are far too relaxed to pay any attention to this. macOS is too cool to even have something like this in its spec 😊.

pub fn actions(&mut self, actions: Vec<String>) -> &mut Notification[src]

Deprecated:

please use .action() only

Set actions.

To quote http://www.galago-project.org/specs/notification/0.9/x408.html#command-notify

Actions are sent over as a list of pairs. Each even element in the list (starting at index 0) represents the identifier for the action. Each odd element in the list is the localized string that will be displayed to the user.

There is nothing fancy going on here yet. Careful! This replaces the internal list of actions!

(xdg only)

pub fn action(&mut self, identifier: &str, label: &str) -> &mut Notification[src]

Add an action.

This adds a single action to the internal list of actions.

(xdg only)

pub fn id(&mut self, id: u32) -> &mut Notification[src]

Set an Id ahead of time

Setting the id ahead of time allows overriding a known other notification. Though if you want to update a notification, it is easier to use the update() method of the NotificationHandle object that show() returns.

(xdg only)

pub fn finalize(&self) -> Notification[src]

Finalizes a Notification.

Part of the builder pattern, returns a complete copy of the built notification.

pub fn show(&self) -> Result<NotificationHandle>[src]

Sends Notification to NSUserNotificationCenter.

Returns an Ok no matter what, since there is currently no way of telling the success of the notification.

Trait Implementations

impl Clone for Notification[src]

impl Default for Notification[src]

impl Debug for Notification[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]