pub enum DefaultValue {
UInt8(u8),
Int8(i8),
UInt16(u16),
Int16(i16),
UInt32(u32),
Int32(i32),
Single(f32),
Text(&'static str),
EmptyLocalizedString,
Vector3([f32; 3]),
Vector4([f32; 4]),
}Expand description
A constant the engine resolves an absent field to.
Const-constructible so it can sit in the static schema tables, which is
why it does not reuse GffValue (whose string variants own a String).
Deliberately narrower than GffType: there is no UInt64, Int64,
Double or Binary variant because no audited page reports a default for
one. Add the variant when a page does, rather than picking an encoding for
a case nobody has traced.
Variants§
UInt8(u8)
BYTE, and the usual home for a documented boolean default.
Int8(i8)
CHAR.
UInt16(u16)
WORD.
Int16(i16)
SHORT.
UInt32(u32)
DWORD. Also carries sentinels such as OBJECT_INVALID.
Int32(i32)
INT.
Single(f32)
FLOAT.
Text(&'static str)
The text a CExoString or CResRef resolves to.
Usually "", but not always: a door’s fifteen script slots are seeded
with the literal "default" before any read runs, which is the
mechanism behind the traps.2da hook fallback.
EmptyLocalizedString
A CExoLocString with no strref and no substrings.
Vector3([f32; 3])
Vector.
Vector4([f32; 4])
Quaternion.
Implementations§
Source§impl DefaultValue
impl DefaultValue
Sourcepub fn gff_type(&self) -> GffType
pub fn gff_type(&self) -> GffType
The GFF type this default is a value of.
Lets a guard check a declared default against its entry’s
expected_type. A default written at the wrong width never matches
anything, so without this check it reports as a reader mismatch
forever and looks exactly like a real finding.
Self::Text answers String; a resref default carries the same
literal and is accepted against either by Self::matches.
Sourcepub fn matches(&self, value: &GffValue) -> bool
pub fn matches(&self, value: &GffValue) -> bool
Returns whether value is what this default describes.
Text compares against strings and resrefs alike, since the engine’s seeded value is the same literal either way. Floats compare bitwise rather than by tolerance: both sides originate as a literal from an audited page, so a mismatch is a wrong constant rather than drift.
Trait Implementations§
Source§impl Clone for DefaultValue
impl Clone for DefaultValue
Source§fn clone(&self) -> DefaultValue
fn clone(&self) -> DefaultValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DefaultValue
impl Debug for DefaultValue
Source§impl PartialEq for DefaultValue
impl PartialEq for DefaultValue
Source§fn eq(&self, other: &DefaultValue) -> bool
fn eq(&self, other: &DefaultValue) -> bool
self and other values to be equal, and is used by ==.