Skip to main content

MessageId

Derive Macro MessageId 

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

Derive the MessageId trait for a Message.

By default, the derive also emits a StableId impl and sets MessageId::ID = StableId::TYPE_ID.as_u64(). In this case, do not also derive StableId separately, as that would produce conflicting impls. See derive macro StableId for the hashing scheme and the rules around generic parameters.

An optional #[custom_id(<u64 value>)] attribute lets the user supply the id directly. When present, no StableId impl is emitted, and it is the user’s responsibility to ensure the id is unique across all messages an actor can handle.

§Example

use acktor_derive::MessageId;

#[derive(MessageId)]
struct Ping(u64);

#[derive(MessageId)]
#[custom_id(0xdead_beef)]
struct Pong;