Skip to main content

FieldSchema

Struct FieldSchema 

Source
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: String

The 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

Source

pub fn new(name: String, type: FieldType, description: Option<String>) -> Self

Source

pub fn from_quill_value(key: String, value: &QuillValue) -> Result<Self, String>

Trait Implementations§

Source§

impl Clone for FieldSchema

Source§

fn clone(&self) -> FieldSchema

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FieldSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FieldSchema

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for FieldSchema

Source§

fn eq(&self, other: &FieldSchema) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for FieldSchema

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for FieldSchema

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.