diff options
author | sommerfeld <sommerfeld@sommerfeld.dev> | 2024-04-21 16:04:38 +0100 |
---|---|---|
committer | sommerfeld <sommerfeld@sommerfeld.dev> | 2024-04-21 16:04:38 +0100 |
commit | 1ab6ecba6f509b7b76865d65c77ecebc51efd2d3 (patch) | |
tree | a9b92e15769d483560d5799569b14c985b9c3ea5 /src/actions/desktop_notification.rs | |
download | sentrum-0.1.0.tar.gz sentrum-0.1.0.tar.bz2 sentrum-0.1.0.zip |
Initial commitv0.1.0
Diffstat (limited to 'src/actions/desktop_notification.rs')
-rw-r--r-- | src/actions/desktop_notification.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/actions/desktop_notification.rs b/src/actions/desktop_notification.rs new file mode 100644 index 0000000..d831a59 --- /dev/null +++ b/src/actions/desktop_notification.rs @@ -0,0 +1,28 @@ +use super::Action; +use crate::message::MessageConfig; +use crate::message::MessageParams; +use anyhow::Result; +use async_trait::async_trait; + +#[derive(Debug)] +pub struct DesktopNotificationAction<'a> { + message_config: &'a MessageConfig, +} + +impl<'a> DesktopNotificationAction<'a> { + pub fn new(message_config: &'a MessageConfig) -> Self { + Self { message_config } + } +} + +#[async_trait] +impl Action<'_> for DesktopNotificationAction<'_> { + async fn run(&self, params: Option<&MessageParams<'_, '_>>) -> Result<()> { + use notify_rust::Notification; + Notification::new() + .summary(&self.message_config.subject(params)?) + .body(&self.message_config.body(params)?) + .show()?; + Ok(()) + } +} |