pub struct FieldSchema {
pub label: &'static str,
pub expected_type: GffType,
pub life: FieldLife,
pub required: bool,
pub absent: AbsentDefault,
pub children: Option<&'static [FieldSchema]>,
pub constraint: Option<FieldConstraint>,
}Expand description
Schema definition for a single GFF field.
Describes a field that can legitimately appear in a particular GFF
resource type. Whether the engine reads it is FieldSchema::life, not a
condition of being here.
Fields§
§label: &'static strGFF field label (e.g., "Tag", "Appearance_Type").
expected_type: GffTypeExpected GFF value type.
life: FieldLifeWhat the engine does with this label, in each direction.
FieldLife::Live for anything the engine reads, which is nearly
everything here. The dead variants exist so a diagnostic can name what
actually happens instead of reporting the label as unrecognized.
required: boolWhether the engine misbehaves when this field is absent.
Set this only where an audit says the loader does something worse than substitute a default. The one traced case aborts the containing structure outright, dropping a whole gun bank rather than loading it with a zero rate of fire, so “absent” and “absent and defaulted” are not the same outcome.
An earlier version of this comment said the engine “typically falls
back to a default” and treated the flag as a hint that the author
probably meant to set the field. That was never audited, and the case
we have since traced does the opposite. A field the loader defaults
harmlessly is not required, however much an author might have meant to
fill it in; leave it false.
Consumed by rakata-lint’s SCHEMA-002, which warns on absence. The
severity of that warning is the same for every required field, so this
stays a bool: one audited failure mode is not two, and until there
are more the type costs nothing to widen later.
absent: AbsentDefaultWhat the engine holds when a file omits this label.
Populated from the audited format pages only. The point of sourcing it from documentation rather than from the reader is that it can then disagree with the reader, which is the whole value of the guard built on it: a round-trip check compares a reader against a writer that shares its constants, so both being wrong together looks green.
Per view, so the same label can resolve differently for different
consumers. It does: an absent TrapDetectable is 1 on a door and 0
on a trigger, because a door carries its constructed value over while
a trigger’s read stamps a literal.
children: Option<&'static [FieldSchema]>Sub-schema for List elements or Struct children. None for leaf fields.
When present, validation recurses into each list element or the inner struct, checking fields against this child schema.
constraint: Option<FieldConstraint>Optional bounds check for numeric types.
Defines min/max constraints that the engine actually honors before truncating.
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