Skip to main content

Crate sails_reflect_hash

Crate sails_reflect_hash 

Source
Expand description

Structural compile-time hashing for Sails types.

This crate provides the ReflectHash trait which computes a deterministic, name-independent structural hash for types at compile time using const evaluation. This enables unique interface IDs for services based purely on their structure.

§Deriving ReflectHash

The easiest way to implement ReflectHash is to derive it:

use sails_reflect_hash::ReflectHash;

#[derive(ReflectHash)]
struct Transfer {
    from: ActorId,
    to: ActorId,
    amount: u128,
}

#[derive(ReflectHash)]
enum Event {
    Transferred { from: ActorId, to: ActorId },
    Approved(ActorId, u128),
    Paused,
}

Traits§

ReflectHash
Core trait for computing structural compile-time hashes.

Derive Macros§

ReflectHash
Derives the ReflectHash trait for structs and enums.