use messagebus::{ derive::{Error as MbError, Message}, error, Bus, Handler, Message, MessageBounds, Module, }; use thiserror::Error; #[derive(Debug, Error, MbError)] enum Error { #[error("Error({0})")] Error(anyhow::Error), } impl From> for Error { fn from(err: error::Error) -> Self { Self::Error(err.into()) } } #[derive(Debug, Clone, Message)] pub struct Msg(pub F); struct TmpReceiver; impl Handler> for TmpReceiver { type Error = Error; type Response = (); fn handle(&self, msg: Msg, _bus: &Bus) -> Result { println!("---> u32 {:?}", msg); Ok(()) } } fn module() -> Module { Module::new() .register(TmpReceiver) .subscribe_sync::>(8, Default::default()) .done() } #[tokio::main] async fn main() { let (b, poller) = Bus::build().add_module(module()).build(); // b. println!("flush"); b.flush().await; println!("close"); b.close().await; println!("closed"); poller.await; println!("[done]"); }