pub trait Reacting: Sized + 'static {
type Kept: 'static;
// Required methods
async fn hear(&mut self, said: Message) -> Result<(), Failure>;
async fn answer(&mut self, asked: Message) -> Result<Answer, Failure>;
async fn finish(self) -> Result<Self::Kept, Failure>;
}Expand description
One shell’s reaction, for as long as that shell can speak.
It runs as a task of its own, so it owns what it holds ('static) and is
never sent to another thread. Awaiting inside a method yields to the other
shells’ tasks; synchronous work blocks them for its duration.
hear | a Message nobody is waiting on |
answer | one the shell blocks on; the task writes the Answer back to it |
finish | what is left, which lands in Attended::kept |
No method has a default body. The two implementations below are the templates to copy.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Reacting for Vec<Message>
A reaction that keeps every message, and has no answer to any of them.
impl Reacting for Vec<Message>
A reaction that keeps every message, and has no answer to any of them.