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 HasStableTypeId impl and sets MessageId::ID = STABLE_TYPE_ID.as_u64(). In that case, 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.

An optional #[custom_id(<u64 value>)] attribute lets the user supply the id directly. When present, no HasStableTypeId 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;