pub struct FieldSchema {
pub name: String,
pub type: FieldType,
pub description: Option<String>,
pub default: Option<QuillValue>,
pub example: Option<QuillValue>,
pub ui: Option<UiFieldSchema>,
pub enum_values: Option<Vec<String>>,
pub properties: Option<IndexMap<String, Box<FieldSchema>>>,
pub items: Option<Box<FieldSchema>>,
pub default_content: Option<QuillValue>,
pub example_content: Option<QuillValue>,
}Expand description
Schema definition for a template field.
default and example are both type-valid values with opposite intent:
default is the value most authors want (interpolated when the field is
omitted), while example matches the desired type and shape but is not
the value most authors want (it documents shape only, never rendering).
A field’s cell is determined by default: a field with a default:
is Endorsed (the rendered value is shippable as-is), while a field
without a default: is Unendorsed (the author endorsed no value, so
the blueprint carries a !must_fill placeholder to ask for one). Absence is
not a requirement: a missing or null Unendorsed field zero-fills at
render. A surviving !must_fill placeholder is surfaced as the non-fatal
validation::must_fill warning. There is no separate required: axis.
The richtext single-line constraint has one carrier — the
FieldType::RichText { inline } enum. The wire’s sibling inline: key folds
into that enum at deserialize (via from_quill_value,
which the custom Deserialize below routes through), and the custom
Serialize re-emits it from the enum, so the flag can never live in two
places that disagree.
Serialize/Deserialize are hand-written (below) rather than derived: the
wire folds a sibling inline: key into the FieldType enum, name rides
the map key, and the *_content caches never serialize.
Fields§
§name: StringThe map key carries this on the wire; not serialized, to avoid duplication.
type: FieldType§description: Option<String>§default: Option<QuillValue>The value most authors want; interpolated when the field is omitted. Its presence makes the field Endorsed.
example: Option<QuillValue>A value matching the desired type and shape but not the value most authors want; documents shape only and never renders as the value.
ui: Option<UiFieldSchema>§enum_values: Option<Vec<String>>Restricts valid values on string fields. Serializes as enum.
properties: Option<IndexMap<String, Box<FieldSchema>>>Nested field schemas for object types (the typed dictionary’s
properties). Ordered: declaration order is display order at every
nesting level, carried by the map itself.
items: Option<Box<FieldSchema>>Element schema for array types. Required on every array field:
the element type gives the array a concrete element type (string[],
integer[], richtext[], …). For a typed table the element is an
object carrying its own properties.
default_content: Option<QuillValue>Canonical-content form of default for a richtext-bearing
field, imported once at quill load and cached — never serialized. The
render floor (resolve_fields) commits this for an absent field, so a
richtext default crosses the seam as content, not a re-imported string.
None for a non-richtext field, a null/absent default, or a schema built
outside the loader.
example_content: Option<QuillValue>Canonical-content form of example for a richtext-bearing
field, imported once at quill load and cached — never serialized. Seeding
commits this so a seeded field is content from birth. None under the same
conditions as default_content.
Implementations§
Source§impl FieldSchema
impl FieldSchema
Trait Implementations§
Source§impl Clone for FieldSchema
impl Clone for FieldSchema
Source§fn clone(&self) -> FieldSchema
fn clone(&self) -> FieldSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more