use std::borrow::Cow;
use std::time::Duration;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum NotificationUrgency {
Low,
#[default]
Normal,
Critical,
}
pub struct Notification<'a> {
pub title: Cow<'a, str>,
pub body: Option<Cow<'a, str>>,
pub app_name: Option<Cow<'a, str>>,
pub icon: Option<Cow<'a, str>>,
pub urgency: NotificationUrgency,
pub timeout: Option<Duration>,
}
impl<'a> Notification<'a> {
#[must_use]
pub fn new(title: impl Into<Cow<'a, str>>) -> Self {
Self {
title: title.into(),
body: None,
app_name: None,
icon: None,
urgency: NotificationUrgency::default(),
timeout: None,
}
}
#[must_use]
pub fn body(mut self, body: impl Into<Cow<'a, str>>) -> Self {
self.body = Some(body.into());
self
}
#[must_use]
pub fn app_name(mut self, name: impl Into<Cow<'a, str>>) -> Self {
self.app_name = Some(name.into());
self
}
#[must_use]
pub fn icon(mut self, icon: impl Into<Cow<'a, str>>) -> Self {
self.icon = Some(icon.into());
self
}
#[must_use]
pub fn urgency(mut self, urgency: NotificationUrgency) -> Self {
self.urgency = urgency;
self
}
#[must_use]
pub fn timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
}