#[handles]
Expand description
Impls Handle
traits for the type, making it available for handling requests based on the serde system.
You can only use this once per type, for it must covert all request types that it handles.
Every handle functions have to be async
, not pub
, named handle
, with &self
receiver, otherwise it would be normal associated functions of such type.
Examples
struct Actor;
#[handles]
impl Actor {
async fn handle(&self, _: Activate) -> Result<_> {
println!("Activate!");
Ok(())
}
async fn handle(&self, GreetingsRequest(name): _) -> Result<_> {
println!("Hello {name}.");
Ok(())
}
}