Skip to main content

StableId

Derive Macro StableId 

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

Derives the StableId trait, giving the message a stable, globally unique MessageId that identifies it across nodes.

The id is set with #[msg(id = "<uuid>")]. If it is missing, compilation fails with a freshly generated random id that can be pasted in. Once nodes running different builds may talk to each other, never change an id, and never give two types the same one: registering both on a node panics.

With the auto-register feature of zestors-distr, a type that isn’t generic is also collected for ClusterConfig::auto_register, which registers it if it is a RemoteMessage. #[msg(no_auto_register)] leaves it out.

§Example

#[derive(StableId)]
#[msg(id = "0b0f7e4e-3f3a-4d5b-9d7e-6a1c2b3d4e92")]
struct Ping;

assert_eq!(Ping::Id, MessageId::from_u128(0x0b0f7e4e_3f3a_4d5b_9d7e_6a1c2b3d4e92));