Skip to main content

RemoteAddressable

Derive Macro RemoteAddressable 

Source
#[derive(RemoteAddressable)]
{
    // Attributes available to this derive:
    #[message]
}
Available on crate feature ipc only.
Expand description

Derive the RemoteAddressable trait for an actor.

A #[message(M1, M2, ...)] attribute must be present to specify the list of messages the actor can handle remotely. For each message Mi, the actor must have implemented the Handler trait; Mi itself must have implemented the MessageId trait, the Encode trait and the Decode trait; Mi::Result must also have implemented the Encode trait and the Decode trait.

The macro emits a Codec impl and a Handler<BinaryMessage> impl for the actor based on the message list specified in the #[message(..)] attribute. The Codec impl provides a codec table which defines how to encode the message and decode the message response for each message type Mi. The Handler<BinaryMessage> impl dispatches inbound messages by matching the message id and invoking the corresponding message handler.

§Example

use acktor_derive::RemoteAddressable;

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