Skip to main content

Fingerprint

Derive Macro Fingerprint 

Source
#[derive(Fingerprint)]
Expand description

Derives Fingerprint, a stable content hash used to check that a delta is being applied to the state it was computed against.

Walks a struct’s fields in declaration order, or an enum’s variant index followed by that variant’s fields. Every field type has to implement Fingerprint too, and every type parameter picks up a Fingerprint bound.

Unlike the Delta derive this needs nothing in scope — the generated code names ::delta_struct::Fingerprint in full — and it accepts enums, which have a perfectly good content hash even though they have no obvious delta.

use delta_struct::Fingerprint;

#[derive(Fingerprint)]
struct Device {
    services: std::collections::HashSet<String>,
    online: bool,
}