One version of one schema, compiled from a %schema(N){...} entry of a
.dxns document (Dextrin.Schema.Compiler.compile/2) -- enough to both
validate a decoded value and convert it both directions between
.dxnb's always-positional wire shape and a named field map.
fields is ordered, and that order is the canonical position <-> name
mapping .dxnb's positional struct encoding needs: the order the
fields are written in the schema's body. version is the schema's
version, 1 when its entry has no header (DXN.md §4.8).
Summary
Functions
Reads application_struct's fields (an arbitrary Elixir struct — not
a Dextrin.Struct) out in this schema's own canonical field order —
the same order .dxnb's positional wire encoding needs. A field this
schema declares but application_struct doesn't have is nil, same
as any other absent field; extra struct fields the schema doesn't
know about are simply not included.
Types
@type t() :: %Dextrin.Schema.Compiled{ fields: [Dextrin.Schema.Field.t()], name: String.t(), version: pos_integer() }
Functions
Reads application_struct's fields (an arbitrary Elixir struct — not
a Dextrin.Struct) out in this schema's own canonical field order —
the same order .dxnb's positional wire encoding needs. A field this
schema declares but application_struct doesn't have is nil, same
as any other absent field; extra struct fields the schema doesn't
know about are simply not included.
What lets Dextrin.Text.Printer/Dextrin.Binary.Encoder serialize a
struct registered via Dextrin.Registry.put_struct_module/3 directly
— without a caller needing to hand-build a Dextrin.Struct
themselves first, closing the loop Dextrin.Schema.Validator.materialize/4
already closes on the way in.