docs: add doctest to notification::close

This commit is contained in:
2026-10-04 14:57:55 +02:00
parent 0503fa8e28
commit d50bac9e0e

View File

@@ -227,6 +227,22 @@ impl<'a> Notification {
/// ///
/// # Errors /// # Errors
/// This function can return LibnotifyError::{AllocationError, GerrorError} /// This function can return LibnotifyError::{AllocationError, GerrorError}
///
/// # Example
/// ```no_run(Not notification deamon on CI)
/// use libnotify_rs::api::{functions::init, notification::Notification};
///
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// init("Test app")?;
/// let notification = Notification::new("My notification", "Yap yap", None)?;
/// notification.show()?;
/// std::thread::sleep(std::time::Duration::from_secs(5)); // To do this you can just set duration,
/// // but this is an example
/// notification.close()?; // After 5 seconds no notification
///
/// Ok(())
/// }
/// ```
pub fn close(&self) -> Result<(), LibnotifyError> { pub fn close(&self) -> Result<(), LibnotifyError> {
let mut gerror = std::ptr::null_mut() as *mut GError; let mut gerror = std::ptr::null_mut() as *mut GError;