pub trait GffScalar: Sized {
const GFF_TYPE: GffType;
// Required methods
fn from_gff_value(value: &GffValue) -> Option<Self>;
fn to_gff_value(self) -> GffValue;
}Expand description
How one Rust type maps onto a GFF value.
§Tolerance belongs in the impl
from_gff_value for i16 accepting an Int32 is that type’s business,
stated once, rather than a coercion ladder repeated at every read site. The
engine tolerates more encodings than it writes, and this crate has to read
the files it merely tolerates.
to_gff_value is the other half and is not its inverse: it emits the one
encoding the engine’s own writer produces. A type that reads three widths
and writes one is behaving correctly.
Required Associated Constants§
Required Methods§
Sourcefn from_gff_value(value: &GffValue) -> Option<Self>
fn from_gff_value(value: &GffValue) -> Option<Self>
Reads a value, accepting every encoding this type can hold.
None where the value is a type this cannot represent, which the
caller treats as the field being absent rather than as an error.
Sourcefn to_gff_value(self) -> GffValue
fn to_gff_value(self) -> GffValue
Writes the one encoding the engine’s own writer emits.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl GffScalar for bool
A bool is carried as a UInt8 almost everywhere and as a UInt16 once,
which is why the file’s type is a fact to record rather than to derive from
the Rust type.
impl GffScalar for bool
A bool is carried as a UInt8 almost everywhere and as a UInt16 once,
which is why the file’s type is a fact to record rather than to derive from
the Rust type.