Skip to main content

Module schema_form

Module schema_form 

Source
Expand description

A form generated from a description of the arguments a call takes.

§Why there is a schema type here

For the same reason JsonValue exists: this crate takes no serialization dependency, so it cannot read a schema document. A host converts whatever schema dialect it already parses into Schema, which describes only what a form has to draw — a name, a label, whether the value is required, and which control the value is edited with.

§A field the form cannot draw says so

This is the rule the whole component is built around. A host converting a schema it does not fully understand puts SchemaKind::Unrenderable in place of the field, with the reason in its own words; the form also refuses a few shapes on its own, such as a choice among no choices. Either way the field keeps its place, keeps its label, and states that it cannot be filled in here — and SchemaForm::values still reports it, as FieldValue::Unrenderable, so a caller cannot collect the answers and not notice one is missing.

A form that quietly dropped a required argument it did not understand would produce an invalid call, and the reader would be told they got it wrong.

§Whose error is on screen

Two sources, kept apart. SchemaForm::validate marks required fields nobody filled in, which is all this component can judge on its own; SchemaForm::set_error shows an error the host returned, in the host’s own words. A host error outranks a derived one on the same field, because the host knows something the form does not.

Structs§

NumberBounds
What a number may be, as far as the schema said.
Schema
The arguments a call takes, in the order they should be filled in.
SchemaChoice
One option a closed or open choice offers.
SchemaField
One argument.
SchemaForm
A form built from a schema.
UnrenderableField
A field that has to be filled in somewhere other than this form.

Enums§

FieldValue
What one field currently holds.
SchemaFormEvent
What the form reports.
SchemaKind
What a value is, and therefore which control edits it.