From d658d1aa0439f94a144116fe2b45d52109826c93 Mon Sep 17 00:00:00 2001 From: szymon Date: Wed, 30 Sep 2026 14:25:06 +0200 Subject: [PATCH] feat: implement update --- src/notification.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/notification.rs b/src/notification.rs index 2f57781..204afe9 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -277,12 +277,38 @@ impl<'a> Notification { /// Updates the notification text and icon. /// /// This won’t send the update out and display it on the screen. For that, you will need to call `show()`. - pub fn update<'b, F, I>(&mut self, summary: &str, body: F, icon: I) + pub fn update<'b, F, I>( + &mut self, + summary: &str, + body: F, + icon: I, + ) -> Result<(), std::ffi::NulError> where F: Into>, I: Into>, { - todo!(); + let summary = std::ffi::CString::new(summary)?; + + let body = body + .into() + .map(|body| std::ffi::CString::new(body)) + .transpose()?; + + let icon = icon + .into() + .map(|icon| std::ffi::CString::new(icon)) + .transpose()?; + + unsafe { + notify_notification_update( + self.inner, + summary.as_ptr(), + body.as_ref().map_or(std::ptr::null(), |body| body.as_ptr()), + icon.as_ref().map_or(std::ptr::null(), |icon| icon.as_ptr()), + ); + } + + Ok(()) } }