#![feature(arbitrary_self_types)] use bottle::{Receiver, Remote, Handler, EventQueue}; struct Foo { value: i32 } struct Reflect; impl bottle::Event for Reflect { type Response = Remote>; } enum Event { Foo } impl bottle::Event for Event { type Response = (); } impl Handler for Foo { fn handle(self: Receiver, _event: Reflect) -> Remote> { let remote = self.as_remote(); remote as Remote> } } impl Handler for Foo { fn handle(self: Receiver, _event: Event) { println!("my value is {}", self.value) } } #[async_std::main] async fn main() { let queue = EventQueue::new(); let foo = Remote::new(queue.reference(), Foo { value: 42 }); std::thread::spawn(move || { async_std::task::block_on(queue.process()) }); let remote = foo.send(Reflect).await; remote.send(Event::Foo).await; }