Skip to main content

FieldSchema

Struct FieldSchema 

Source
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 str

GFF field label (e.g., "Tag", "Appearance_Type").

§expected_type: GffType

Expected GFF value type.

§life: FieldLife

What 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: bool

Whether 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: AbsentDefault

What 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

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

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> 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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.