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(&self)
pub fn send(&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§
Source§impl Drop for Notification
impl Drop for Notification
Source§impl Object for Notification
impl Object for Notification
Source§type NativeType = _NvdNotification
type NativeType = _NvdNotification
The type of the underlying native object, created by
NvDialog. It will be used as a pointer
to provide compatibility with the NvDialog API.Source§type ReturnValue = ()
type ReturnValue = ()
The value that should be returned from
Self::show. It should match the value that the dialog returns when
it is presented to the user.Source§fn get_raw(&self) -> *mut Self::NativeType
fn get_raw(&self) -> *mut Self::NativeType
Returns the raw object created by NvDialog internally. This should never return
null.Source§fn show(&self)
fn show(&self)
Presents the dialog to the user. If
Self::ReturnValue is not () then it will also return that value.
Sometimes this serves as an alias to the type’s implementation of the analogous function. If you cannot afford the overhead,
you can use that instead.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