#[derive(Actor)]Expand description
Derive macro for automatically implementing the Actor trait.
This macro generates a default implementation of the Actor trait where:
Argstype is set toSelfErrortype is set tostd::convert::Infallibleon_startmethod returns the args as the actor instance
§Examples
§Struct Actor
use rsactor::Actor;
#[derive(Actor)]
struct MyActor {
name: String,
}§Enum Actor
use rsactor::Actor;
#[derive(Actor)]
enum StateActor {
Idle,
Processing(String),
Completed(i32),
}This generates an implementation equivalent to:
impl rsactor::Actor for MyActor {
type Args = Self;
type Error = std::convert::Infallible;
async fn on_start(
args: Self::Args,
_actor_ref: &rsactor::ActorRef<Self>,
) -> std::result::Result<Self, Self::Error> {
Ok(args)
}
}§Limitations
- Only works on structs and enums (not unions)
- Generates a very basic implementation - for complex initialization logic, implement the Actor trait manually