Temporary commit to try fix halting

This commit is contained in:
2025-09-14 13:29:35 +02:00
parent ee45dbd28e
commit cd1d640174
59 changed files with 1091 additions and 778 deletions

View File

@@ -0,0 +1,23 @@
#![cfg(any(feature = "mocks", test))]
use std::future::ready;
use std::pin::Pin;
use std::rc::Rc;
pub struct AsyncMonitor<E: 'static>(Rc<dyn Fn(E) -> Pin<Box<dyn Future<Output = ()>>>>);
impl<E: 'static> AsyncMonitor<E> {
pub fn new<F: AsyncFn(E) -> () + 'static>(f: F) -> Self {
let f_rc = Rc::new(f);
AsyncMonitor(Rc::new(move |e| {
let f_rc = f_rc.clone();
Box::pin(async move { f_rc(e).await })
}))
}
pub async fn notify(&self, e: E) -> () { (self.0)(e).await }
}
impl<E: 'static> Default for AsyncMonitor<E> {
fn default() -> Self { Self(Rc::new(|_| Box::pin(ready(())))) }
}
impl<E: 'static> Clone for AsyncMonitor<E> {
fn clone(&self) -> Self { Self(self.0.clone()) }
}