Skip to main content

Message

Derive Macro Message 

Source
#[derive(Message)]
{
    // Attributes available to this derive:
    #[msg]
    #[zestors]
}
Expand description

Derives the Message trait.

Without attributes the message is fire-and-forget (Kind = Cast). With #[msg(reply = T)] it expects a reply of type T (Kind = Call): it is sent with a Request<T>, and the sender waits on a Reply<T>. Quote a type with generics: #[msg(reply = "Option<u32>")].

To send the message to other nodes, also derive StableId and serde’s Serialize/Deserialize; the id goes in the same attribute, #[msg(reply = u32, id = "<uuid>")].

§Example

#[derive(Message)]
struct SimpleMessage;

#[derive(Message)]
#[msg(reply = u32)]
struct MessageWithOutput;