Skip to main content

Notification

Struct Notification 

Source
pub struct Notification {
Show 23 fields pub id: u32, pub app_name: Property<Option<String>>, pub replaces_id: Property<Option<u32>>, pub app_icon: Property<Option<String>>, pub summary: Property<String>, pub body: Property<Option<String>>, pub actions: Property<Vec<Action>>, pub default_action: Property<Option<Action>>, pub hints: Property<Option<NotificationHints>>, pub expire_timeout: Property<Option<u32>>, pub urgency: Property<Urgency>, pub category: Property<Option<Category>>, pub timestamp: Property<DateTime<Utc>>, pub image_path: Property<Option<String>>, pub desktop_entry: Property<Option<String>>, pub is_transient: Property<bool>, pub is_resident: Property<bool>, pub sound_file: Property<Option<String>>, pub sound_name: Property<Option<String>>, pub suppress_sound: Property<bool>, pub x: Property<Option<i32>>, pub y: Property<Option<i32>>, pub action_icons: Property<bool>, /* private fields */
}
Expand description

A desktop notification.

Each notification displayed is allocated a unique ID by the server. This is unique within the session. While the notification server is running, the ID will not be recycled unless the capacity of a uint32 is exceeded.

Fields§

§id: u32

The ID of the notification

§app_name: Property<Option<String>>

The optional name of the application sending the notification. This should be the application’s formal name, rather than some sort of ID. An example would be “FredApp E-Mail Client,” rather than “fredapp-email-client.”

§replaces_id: Property<Option<u32>>

An optional ID of an existing notification that this notification is intended to replace.

§app_icon: Property<Option<String>>

The notification icon.

§summary: Property<String>

This is a single line overview of the notification. For instance, “You have mail” or “A friend has come online”. It should generally not be longer than 40 characters, though this is not a requirement, and server implementations should word wrap if necessary. The summary must be encoded using UTF-8.

§body: Property<Option<String>>

This is a multi-line body of text. Each line is a paragraph, server implementations are free to word wrap them as they see fit.

The body may contain simple markup as specified in Markup. It must be encoded using UTF-8.

If the body is omitted, just the summary is displayed.

§actions: Property<Vec<Action>>

Available actions for this notification.

Each action has an identifier and a human-readable label. The “default” action is typically invoked when clicking the notification body.

§default_action: Property<Option<Action>>

The default action, triggered when clicking the notification body.

§hints: Property<Option<NotificationHints>>

Hints are a way to provide extra data to a notification server that the server may be able to make use of.

Neither clients nor notification servers are required to support any hints. Both sides should assume that hints are not passed, and should ignore any hints they do not understand.

§expire_timeout: Property<Option<u32>>

The timeout time in milliseconds since the display of the notification at which the notification should automatically close.

None = server decides, Some(0) = never expires, Some(ms) = timeout in milliseconds.

§urgency: Property<Urgency>

The urgency level.

§category: Property<Option<Category>>

The type of notification this is.

§timestamp: Property<DateTime<Utc>>

When the notification was created.

§image_path: Property<Option<String>>

Path to an image file from hints.

§desktop_entry: Property<Option<String>>

Desktop entry name of the application.

§is_transient: Property<bool>

Whether the notification should be transient (not persisted).

§is_resident: Property<bool>

Whether the notification stays after action invocation.

§sound_file: Property<Option<String>>

Path to a sound file to play when the notification pops up.

§sound_name: Property<Option<String>>

A themeable named sound to play when the notification pops up.

§suppress_sound: Property<bool>

Whether to suppress playing sounds for this notification.

§x: Property<Option<i32>>

X position hint for notification placement.

§y: Property<Option<i32>>

Y position hint for notification placement.

§action_icons: Property<bool>

Whether action IDs should be interpreted as icon names.

Implementations§

Source§

impl Notification

Source

pub fn dismiss(&self)

Dismisses the notification, removing it from history and emitting the D-Bus NotificationClosed signal.

Source

pub async fn invoke(&self, action_key: &str) -> Result<(), Error>

Invoke an action on the notification.

The notification is dismissed if it is not a resident.

§Errors

Returns error if the D-Bus signal emission fails.

Trait Implementations§

Source§

impl Clone for Notification

Source§

fn clone(&self) -> Notification

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Notification

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Notification

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more