Move insert_into_extensions into Notifier trait

This commit is contained in:
imbolc 2024-06-15 13:40:22 +06:00
parent cdbd892f85
commit 535b19fff8

View file

@ -24,6 +24,8 @@ pub trait Notifier {
sender.send(()).ok(); sender.send(()).ok();
} }
} }
fn insert_into_extensions(extensions: &mut Extensions) -> Receiver<()>;
} }
macro_rules! define_notifiers { macro_rules! define_notifiers {
@ -36,9 +38,7 @@ macro_rules! define_notifiers {
fn sender(&mut self) -> Option<Sender<()>> { fn sender(&mut self) -> Option<Sender<()>> {
self.0.take().and_then(Arc::into_inner) self.0.take().and_then(Arc::into_inner)
} }
}
impl $name {
fn insert_into_extensions(extensions: &mut Extensions) -> Receiver<()> { fn insert_into_extensions(extensions: &mut Extensions) -> Receiver<()> {
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
if extensions.insert(Self(Some(Arc::new(tx)))).is_some() { if extensions.insert(Self(Some(Arc::new(tx)))).is_some() {