#[derive(RemoteActor)]
{
// Attributes available to this derive:
#[message]
}
ipc only.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 which dispatches inbound messages by
matching their message_id against <Mi as Decode>::ID and invoking the corresponding
message handler <Self as Handler<Mi>>::handle. After handling the message, the response is
encoded and sent back through an oneshot channel to the sender of the RemoteMessage.
For each Mi, the actor must implement Handler<Mi> trait and the result type of the
trait must implement Encode trait.
This also emits the HasStableTypeId impl, so #[derive(RemoteActor)] alone is sufficient
— do not also derive HasStableTypeId separately, as that would produce conflicting
impls. See the HasStableTypeId derive for the hashing scheme and the rules around generic
parameters.
§Example
use acktor_derive::RemoteActor;
#[derive(RemoteActor)]
#[message(Ping, Echo)]
pub struct MyActor;