Macro bastion::answer [−][src]
macro_rules! answer {
($msg : expr, $answer : expr) => { ... };
}
Expand description
Answers to a given message, with the given answer.
Example
// Create a new child...
Bastion::children(|children| {
children.with_exec(|ctx: BastionContext| {
async move {
let msg = ctx.recv().await?;
answer!(msg, "goodbye").unwrap();
Ok(())
}
})
}).expect("Couldn't create the children group.");
// now you can ask the child, from another children
let answer: Answer = ctx.ask(&child_ref.addr(), "hello").expect("Couldn't send the message.");
msg! { answer.await.expect("Couldn't receive the answer."),
msg: &'static str => {
assert_eq!(msg, "goodbye");
};
_: _ => ();
}