use std::fmt;
use crate::{
foundation::patterns::facade::BaseFacade,
prelude::{Facade, Interest, Notifier, Proxy, Singleton},
};
pub struct BaseProxy<Body>
where
Body: fmt::Debug + 'static,
{
pub data: Option<Body>,
}
impl<Body> BaseProxy<Body>
where
Body: fmt::Debug + 'static,
{
pub fn new(data: Option<Body>) -> Self {
Self { data }
}
}
impl<Body> Proxy for BaseProxy<Body>
where
Body: fmt::Debug + 'static,
{
fn on_register(&self) {}
fn on_remove(&self) {}
}
impl<Body> Notifier<Body> for BaseProxy<Body>
where
Body: fmt::Debug + 'static,
{
fn send(&self, interest: Interest, body: Option<Body>) {
log::error!("You should implement yourself Proxy");
BaseFacade::<Body>::global().send(interest, body);
}
}
impl<Body> fmt::Debug for BaseProxy<Body>
where
Body: fmt::Debug + 'static,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Proxy<Body>")
.finish()
}
}