What the kernel's digest encodes for a struct (spec/01 §7): its canonical term.
A struct whose fields are its contents (a schema, a DateTime) needs nothing: it is
encoded as its map, __struct__ and all, as it always was. A struct whose fields are a
layout of its contents implements this protocol and answers the term its identity is,
so two equal values laid out differently get one digest:
defimpl Macaw.Layers.Digest, for: MyApp.Chunked do
def canonical(t), do: {"my_app.chunked", MyApp.Chunked.rows(t)}
endMacaw.Layers.Document.digest/1 and Macaw.Layers.Document.encode/1 encode a struct as
its canonical term wherever it appears, nested in maps, lists and tuples too. The term
answered must be data, and is itself encoded as any term is, a struct in it by its own
canonical term.
Summary
Functions
The term a struct's digest encodes in its place.
Types
@type t() :: term()
All the types that implement this protocol.