Skip to main content

HasStableTypeId

Derive Macro HasStableTypeId 

Source
#[derive(HasStableTypeId)]
Expand description

Derive the HasStableTypeId trait for a type.

The generated STABLE_TYPE_ID is a SHA-256 hash value of the type’s fully-qualified path (module_path!() + "::" + ident).

If the type contains type generic parameters, the generated STABLE_TYPE_ID is combined with each type generic parameter’s STABLE_TYPE_ID with StableTypeId::combine in their declaration order.

If the type contains const generic parameters, the generated STABLE_TYPE_ID is combined with the SHA-256 hash value of the little-endian byte form of each const generic parameter with StableTypeId::combine in their declaration order. Only const generics of integer primitives, bool, and char are supported.

§Example

use acktor_derive::HasStableTypeId;

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