use crate::icon::Icon;
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct ActionId(pub u32);
#[derive(Clone, Debug)]
pub struct Notification {
pub(crate) title: String,
pub(crate) body: String,
pub(crate) icon: Option<Icon>,
pub(crate) actions: Vec<(ActionId, String)>,
}
impl Notification {
pub fn new(title: impl Into<String>, body: impl Into<String>) -> Notification {
Notification {
title: title.into(),
body: body.into(),
icon: None,
actions: Vec::new(),
}
}
pub fn with_icon(mut self, icon: Icon) -> Notification {
self.icon = Some(icon);
self
}
pub fn action(mut self, id: u32, label: impl Into<String>) -> Notification {
self.actions.push((ActionId(id), label.into()));
self
}
pub fn actions(&self) -> &[(ActionId, String)] {
&self.actions
}
pub fn title(&self) -> &str {
&self.title
}
pub fn body(&self) -> &str {
&self.body
}
pub fn icon(&self) -> Option<&Icon> {
self.icon.as_ref()
}
}