docs: add example to init

This commit is contained in:
2026-10-04 14:17:10 +02:00
parent b6e19b5313
commit 2832dff7f1

View File

@@ -9,10 +9,26 @@ use super::libnotify::*;
*(what a cool section comment) *(what a cool section comment)
*/ */
/// Initialized libnotify. This must be called before any other functions. /// Initializes libnotify. This must be called before any other functions.
/// ///
/// Starting from 0.8, if the provided app_name is NULL, libnotify will try to figure it out from the running application. Before it was not allowed, and was causing libnotify not to be initialized. /// Starting from 0.8, if the provided app_name is NULL, libnotify will try to figure it out from the running application. Before it was not allowed, and was causing libnotify not to be initialized.
/// ///
/// # Example
///
/// ```
/// use libnotify_rs::api::{
/// functions::init,
/// notification:: Notification,
/// };
///
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// init("Test app")?; // we need to init libnotify __before__ any other libnotify code
/// let notification = Notification::new("Test", None, None)?; // Some libnotify call
/// Ok(())
/// }
///
/// ```
///
/// # Errors /// # Errors
/// This function can return LibnotifyError::{InitError, NulError} /// This function can return LibnotifyError::{InitError, NulError}
pub fn init<'a, T>(app_name: T) -> Result<(), LibnotifyError> pub fn init<'a, T>(app_name: T) -> Result<(), LibnotifyError>