mirror of
https://github.com/szymon-jozef/libnotify-rs.git
synced 2026-10-27 19:20:43 +01:00
docs: add example to init
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user