From 5f0b2f199a9d5dd479d32c0b43edda3a3966b44d Mon Sep 17 00:00:00 2001 From: szymon Date: Thu, 1 Oct 2026 21:00:23 +0200 Subject: [PATCH] feat: add example for builder --- examples/builder.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/builder.rs diff --git a/examples/builder.rs b/examples/builder.rs new file mode 100644 index 0000000..75add19 --- /dev/null +++ b/examples/builder.rs @@ -0,0 +1,23 @@ +use libnotify_rs::{builder::NotificationBuilder, context::LibnotifyContext}; + +/// Builder is recommended way to interact with libnotify notifications + +fn main() -> Result<(), Box> { + let ctx = LibnotifyContext::new("Coffee addicted reminder")?; // builder requires context + + let notification_builder = NotificationBuilder::new( + "Remember about your coffee!", + "Only idiots forget about coffee!", + None, + &ctx, + )? + .set_urgency(libnotify_rs::notification::Urgency::Critical) + .set_timeout(libnotify_rs::notification::Timeout::Never) + .set_category("Coffee")?; + + notification_builder.show()?; + + // you don't need to uninitialize libnotify, cause context already does that! + + Ok(()) +}