#[puppet_actor]Expand description
Create an actor for the given struct Impl.
This allows you to mark methods as message handlers with the #[puppet] attribute.
Once marked, the first parameter after one of &self or &mut self will be the message to
receive.
Once the actor has been derived, you can spawn it any of the following:
§Helper Methods (requires helper-methods feature)
spawn_actor()spawn_actor_with_name(name)spawn_actor_with_queue_size(size)spawn_actor_with_name_and_size(name, size)
§Custom Executor (requires custom-executor feature)
spawn_actor_with(name, size, <T as puppet::Executor>)
§Base Methods
run_actor(puppet::Reply<<Msg as Message>::Output>)
§Example
ⓘ
use puppet::puppet_actor;
pub struct MyActor;
#[puppet_actor]
impl MyActor {
#[puppet]
async fn on_say_hello(&self, msg: SayHello) -> String {
format!("Hello, {}!", msg.name)
}
}
let actor = MyActor {};
let mailbox = actor.spawn_actor().await;