Skip to main content

RemoteActor

Derive Macro RemoteActor 

Source
#[derive(RemoteActor)]
{
    // Attributes available to this derive:
    #[message]
}
Expand description

Derive the RemoteActor trait for an actor.

Without any attribute, only the marker impl RemoteActor for Self {} is emitted.

With an optional #[message(M1, M2, ...)] attribute, an additional impl Handler<RemoteMessage> for Self is emitted that dispatches inbound messages by matching on their message_id against <Mi as Decode>::ID, invoking <Self as Handler<Mi>>::handle, and sending the encoded result back through the result_tx oneshot.

For each Mi, the actor must implement Handler<Mi> trait and <Self as Handler<Mi>>::Result must implement Encode trait.

§Example

use acktor_derive::RemoteActor;

#[derive(RemoteActor)]
#[message(Ping, Echo)]
pub struct MyActor;