pub use crate::{
error::*,
notification::Notification,
};
use std::ops::{Deref, DerefMut};
#[derive(Debug)]
pub struct NotificationHandle {
notification: Notification,
}
impl NotificationHandle {
#[allow(missing_docs)]
pub fn new(notification: Notification) -> NotificationHandle {
NotificationHandle { notification }
}
}
impl Deref for NotificationHandle {
type Target = Notification;
fn deref(&self) -> &Notification {
&self.notification
}
}
impl DerefMut for NotificationHandle {
fn deref_mut(&mut self) -> &mut Notification {
&mut self.notification
}
}
pub(crate) fn show_notification(notification: &Notification) -> Result<NotificationHandle> {
mac_notification_sys::send_notification(
¬ification.summary, ¬ification.subtitle.as_ref().map(AsRef::as_ref), ¬ification.body, ¬ification.sound_name.as_ref().map(AsRef::as_ref), )?;
Ok(NotificationHandle::new(notification.clone()))
}