slawlor / ractor

Rust actor framework
MIT License
1.3k stars 66 forks source link

Handle multiple message types #234

Closed dns2utf8-novaziun closed 1 month ago

dns2utf8-novaziun commented 2 months ago

Hi all

I found this actor framework because actix has no handlers that allow me to use async fn handle(self, msg) { do_stuff().await } This looks pretty good.

I would like to handle multiple message types, which in actix is done like this:

struct MyActor;
impl Handler<MsgA> for MyActor { ... }
impl Handler<MsgB> for MyActor { ... }

How would this be handled in ractor? Do I have to make an enum MyActorMsgs { A(MsgA), B(MsgB) } or am I missing something?

Have a nice day :)

slawlor commented 1 month ago

This has been asked before but we have no plans to support this today. Our model for multiple message types is to use an enum to have subtypes that you switch on internally