Skip to main content

init

Function init 

Source
pub fn init<'a, T>(app_name: T) -> Result<(), LibnotifyError>
where T: Into<Option<&'a str>>,
Expand description

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.

§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

This function can return LibnotifyError::{InitError, NulError}