mirror of
https://github.com/szymon-jozef/libnotify-rs.git
synced 2026-10-28 11:10:43 +01:00
feat: add specific error docs
This commit is contained in:
@@ -15,6 +15,10 @@ pub struct NotificationBuilder<'a> {
|
||||
|
||||
impl<'a> NotificationBuilder<'a> {
|
||||
/// Create new NotificationBuilder, with given context.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// This function can return LibnotifyError::{NewNotificationError, NulError}
|
||||
pub fn new<T, Y>(
|
||||
summary: &str,
|
||||
body: T,
|
||||
@@ -34,6 +38,9 @@ impl<'a> NotificationBuilder<'a> {
|
||||
}
|
||||
|
||||
/// Sets app name for this specific notification.
|
||||
///
|
||||
/// # Errors
|
||||
/// This function can return LibnotifyError::{NulError}
|
||||
pub fn set_app_name<T: Into<Option<&'a str>>>(
|
||||
mut self,
|
||||
app_name: T,
|
||||
@@ -46,6 +53,9 @@ impl<'a> NotificationBuilder<'a> {
|
||||
}
|
||||
|
||||
/// Sets app icon fot this specific notification.
|
||||
///
|
||||
/// # Errors
|
||||
/// This function can return LibnotifyError::{NulError}
|
||||
pub fn set_app_icon<T: Into<Option<&'a str>>>(
|
||||
mut self,
|
||||
app_icon: T,
|
||||
@@ -58,6 +68,9 @@ impl<'a> NotificationBuilder<'a> {
|
||||
}
|
||||
|
||||
/// Sets category for this specific notification
|
||||
///
|
||||
/// # Errors
|
||||
/// This function can return LibnotifyError::{NulError}
|
||||
pub fn set_category<T: Into<Option<&'a str>>>(
|
||||
mut self,
|
||||
category: T,
|
||||
@@ -70,6 +83,8 @@ impl<'a> NotificationBuilder<'a> {
|
||||
}
|
||||
|
||||
/// Set hint for this specific notification
|
||||
/// # Errors
|
||||
/// This function can return LibnotifyError::{NulError, AllocationError}
|
||||
pub fn set_hint(mut self, key: &str, value: HintValue) -> Result<Self, LibnotifyError> {
|
||||
self.notification.set_hint(key, value)?;
|
||||
Ok(self)
|
||||
@@ -94,12 +109,15 @@ impl<'a> NotificationBuilder<'a> {
|
||||
}
|
||||
|
||||
/// Add callback
|
||||
///
|
||||
/// # Errors
|
||||
/// This function can return LibnotifyError::NulError
|
||||
pub fn add_action<F>(
|
||||
mut self,
|
||||
action: &str,
|
||||
label: &str,
|
||||
callback: F,
|
||||
) -> Result<Self, Box<dyn std::error::Error>>
|
||||
) -> Result<Self, LibnotifyError>
|
||||
where
|
||||
F: Fn(&str) + 'static,
|
||||
{
|
||||
@@ -110,13 +128,21 @@ impl<'a> NotificationBuilder<'a> {
|
||||
/// Show notification
|
||||
///
|
||||
/// Uses `&self` borrow, so you can use this object later, after showing.
|
||||
pub fn show(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
///
|
||||
/// # Errors
|
||||
/// This function can return LibnotifyError::{GerrorError, AllocationError}
|
||||
pub fn show(&self) -> Result<(), LibnotifyError> {
|
||||
self.notification.show()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Close notification synchronously.
|
||||
pub fn close(&self) -> Result<(), Box<dyn std::error::Error>> {
|
||||
///
|
||||
/// Uses `&self` borrow, so you can use this object later, after closing.
|
||||
///
|
||||
/// # Errors
|
||||
/// This function can return LibnotifyError::{GerrorError, AllocationError}
|
||||
pub fn close(&self) -> Result<(), LibnotifyError> {
|
||||
self.notification.close()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user