#[tokio::test]
async fn example() {
use crate::Executor;
#[derive(Debug)]
pub enum Command {
Greet,
Say(String),
}
pub struct Proc {
greeting: String,
}
#[crate::async_trait]
impl crate::Processor for Proc {
type Command = Command;
type Error = ();
async fn handle(&mut self, command: Self::Command) -> Result<(), ()> {
match command {
Command::Greet => println!("{}", self.greeting),
Command::Say(text) => println!("{text}"),
};
Ok(())
}
}
let handle = crate::SimpleExecutor::new(Proc {
greeting: "Hello".into(),
})
.spawn();
let remote = handle.remote();
remote.send(Command::Greet).unwrap();
remote.send(Command::Say("telecomande".into())).unwrap();
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
drop(handle);
}