use std::fmt;
use crate::prelude::{Interest, Notification};
pub struct BaseNotification<Body>
where
Body: fmt::Debug + 'static,
{
interest: Interest,
body: Option<Body>,
}
impl<Body> BaseNotification<Body>
where
Body: fmt::Debug + 'static,
{
pub fn new(interest: Interest, body: Option<Body>) -> Self {
Self { interest, body }
}
}
impl<Body> Notification<Body> for BaseNotification<Body>
where
Body: fmt::Debug + 'static,
{
fn body(&self) -> Option<&Body> {
self.body.as_ref()
}
fn interest(&self) -> Interest {
self.interest
}
fn set_body(&mut self, body: Option<Body>) {
self.body = body;
}
}
impl<Body> fmt::Debug for BaseNotification<Body>
where
Body: fmt::Debug + 'static,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BaseNotification")
.field("interest", &self.interest)
.field("body", &self.body)
.finish()
}
}