actix-derive
actix-derive copied to clipboard
#[derive(Actor)]
Should we add a custom derive for the Actor
trait?
#[derive(Actor)]
struct SumActor;
Which expands to:
impl Actor for SumActor {
type Context = Context<Self>;
}
main problem is we can have many different contexts. we can use something like #[actor]
for default context or #[actor(HttpContext)]
in case of custom context. it requires nightly but i think that's fine
@callym are you planing to work on any of the issues?
I think we can do
#[derive(Actor)]
#[derive(Actor)]
#[ActorContext(HttpContext)]
This wouldn't require Nightly as it can be done in custom derive (the same way #[Message(result, error)]
is done)
What is the point? Even without macro actor definition takes only 3 lines. I don’t think it worse introducing macro
@fafhrd91 I would really appreciate if we could implement this. "To answer What's the point?" -> The same as for #[ derive( Message )]
. It only saves 3 lines per Actor, so in serious project it saves like 300 lines.
As for the context. It seems the same situation as Message
with Result, and I would stick to consistent implementation with message, in the lines of: #[ctype=HttpContext]
. It doesn't cost anything, but it might shave a few hundred lines of a project. And to be honest, I have alot of actors, but never used another context than default.