Skip to main content

Module types

Module types 

Source
Expand description

Rust types from component schemas (JSON Schema draft 7, as draft7_definitions writes them): a struct per object, an enum per string enumeration, an untagged enum per oneOf or anyOf, an alias per named string, a type of its own per kind of id, a field per property, optional where the schema does not require it. It knows the shapes the spec’s schemas use and refuses any other, so a schema that grows a new shape fails the build rather than generating something wrong.

A union is untagged, and the first member that decodes is the one meant. Its members are told apart by what they are — text, a list, an object — or, between objects, by a single-valued discriminant each carries (status, kind, code) or by one being the empty object. What the schema says that a type cannot — a pattern, a length, a bound — is the validators’ to hold at the boundary, before a value is decoded. A kind of id is the exception: its pattern is written as the check its only constructor makes, and decoding goes through that constructor, so a value of the type has always passed its rule.

Structs§

Generation
What one generation writes.

Functions§

generate
The Rust source of a generation’s types, from definitions (the definitions object of draft7_definitions’ output).
pascal
in-process and subjectClaim as InProcess and SubjectClaim.
snake
subjectClaim as subject_claim; a Rust keyword raw.