Struct notify_rust::Notification [−][src]
#[non_exhaustive]pub struct Notification {
pub appname: String,
pub summary: String,
pub subtitle: Option<String>,
pub body: String,
pub icon: String,
pub hints: HashSet<Hint>,
pub actions: Vec<String>,
pub timeout: Timeout,
// some fields omitted
}Expand description
Desktop notification.
A desktop notification is configured via builder pattern, before it is launched with show().
Example
Notification::new()
.summary("☝️ A notification")
.show()?;Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.appname: StringFilled by default with executable name.
summary: StringSingle line to summarize the content.
subtitle: Option<String>Subtitle for macOS
body: StringMultiple lines possible, may support simple markup,
check out get_capabilities() -> body-markup and body-hyperlinks.
icon: StringUse a file:// URI or a name in an icon theme, must be compliant freedesktop.org.
hints: HashSet<Hint>Check out Hint
warning
this does not hold all hints, Hint::Custom and Hint::CustomInt are held elsewhere,
actions: Vec<String>See Notification::actions() and Notification::action()
timeout: TimeoutLifetime of the Notification in ms. Often not respected by server, sorry.
Implementations
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.
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()
Set the summary.
Often acts as title of the notification. For more elaborate content use the body field.
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 😈🤘.
Wrapper for Hint::ImagePath
Wrapper for Hint::SoundName
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.
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()
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()
Adds a hint.
This method will add a hint to the internal hint HashSet.
Hints must be of type Hint.
Many of these are again wrapped by more convenient functions such as:
sound_name(...)urgency(...)image(...)or
Notification::new().summary("Category:email")
.body("This should not go away until you acknowledge it.")
.icon("thunderbird")
.appname("thunderbird")
.hint(Hint::Category("email".to_owned()))
.hint(Hint::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.
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.
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. In macOS this does not exist
👎 Deprecated: please use .action() only
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)
Add an action.
This adds a single action to the internal list of actions.
(xdg only)
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)
Finalizes a Notification.
Part of the builder pattern, returns a complete copy of the built notification.
Sends Notification to D-Bus.
Returns a handle to a notification
👎 Deprecated: this was never meant to be public API
this was never meant to be public API
Wraps show() but prints notification to stdout.
Trait Implementations
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for Notification
impl Send for Notification
impl Sync for Notification
impl Unpin for Notification
impl UnwindSafe for Notification
Blanket Implementations
Mutably borrows from an owned value. Read more
type NoneType = T
The none-equivalent value.