pub struct Notification { /* private fields */ }
Expand description
A notification dialog, which can be used to send a notification to the user through the system’s API.
§Examples
use nvdialog_rs::Notification;
let mut notification = Notification::new("Hello world!", "This is a notification.");
notification.send();
Implementations§
Source§impl Notification
impl Notification
Sourcepub fn new<S: AsRef<str>>(
title: S,
msg: S,
kind: NotificationKind,
) -> Result<Self, Error>
pub fn new<S: AsRef<str>>( title: S, msg: S, kind: NotificationKind, ) -> Result<Self, Error>
Constructs a new Notification
object with the given title, message and kind of notification.
§Arguments
title
: A string for the title / summary of the notification.msg
: The actual body of the notification.kind
: The kind of the notification, seeNotificationKind
.
§Errors
Returns an Error
of type OutOfMemory
if NvDialog’s allocation failed.
§Examples
use nvdialog_rs::{Notification, NotificationKind};
let notification = Notification::new("Hello", "This is a notification", NotificationKind::Simple);
§FFI
Correspons to nvd_notification_new
.
Sourcepub fn add_action<S: AsRef<str>>(&mut self, name: S, val: i32, ptr: &mut i32)
pub fn add_action<S: AsRef<str>>(&mut self, name: S, val: i32, ptr: &mut i32)
The add_action
function in Rust adds a notification action with a specified name, value, and
pointer.
Arguments:
- [
name
]: A string that that represents the name of an action to be added. - [
val
]: The value to save in the address pointed to by [ptr
] - [
ptr
]: A pointer to the variable to save the response to
Sourcepub fn send(&mut self)
pub fn send(&mut self)
Sends the notification to the desktop notification system. If the notification has already been shown or sent, calling this method again will have no effect.
§Examples
use nvdialog_rs::{Notification, NotificationKind};
let mut notification = Notification::new("Title", "Body", NotificationKind::Simple)
.expect("Failed to create notification");
// Send the notification
notification.send();
§FFI
Corresponds to nvd_send_notification
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Notification
impl RefUnwindSafe for Notification
impl !Send for Notification
impl !Sync for Notification
impl Unpin for Notification
impl UnwindSafe for Notification
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more