pub enum PropertyValue {
Null,
Bool(bool),
Integer(i64),
Unsigned(u64),
Number(f64),
Text(String),
Array(Vec<Self>),
Container(BTreeMap<String, Self>),
}Expand description
One value from a PropertyObject tree, in a form serde can handle.
The representation is untagged, so the serialized form is ordinary data, a container becomes an object, an array becomes a list, a scalar becomes a scalar, rather than something carrying wrapper keys.
The engine distinguishes three numeric storages and matches them strictly,
so they are separate variants here: collapsing them to one would lose the
exactness that Integer and Unsigned
exist to provide.
Variant order matters for deserialization: serde tries untagged variants top
to bottom, so an integral JSON number is read as Integer
and only a value too large for i64 falls through to
Unsigned, with fractional values reaching
Number.
§Representation is not round-trip stable through plain JSON
JSON has one number type, so a value that fits both signed and unsigned, /// 0, or anything up to i64::MAX, comes back as Integer
even if it left as Unsigned. The number is preserved
exactly; only the engine’s choice of storage is not.
This is a property of the wire format, not a defect here, and it is the
price of emitting ordinary JSON instead of tagged objects. It matters only
when rebuilding a property whose representation must be unsigned: read the
representation from the live
PropertyObjectType rather than inferring it
from deserialized JSON. Values above i64::MAX are unambiguous and do
survive.
Variants§
Null
No value.
Produced for any non-finite number. The engine names three of these:
NAN (not a number), IND (indeterminate, a special quiet NaN, from
operations such as Sqrt(-1), which the engine treats as equivalent to
NAN in comparisons), and INF.
JSON cannot write any of them, and inventing an encoding would force
every consumer to learn it, so they all serialize as null, which any
language already understands. An empty object reference is not null
here: it round-trips as the string "Nothing", so a reference stays
distinguishable from a missing number.
Bool(bool)
A boolean.
Integer(i64)
A number stored as a signed 64-bit integer.
Unsigned(u64)
A number stored as an unsigned 64-bit integer.
Number(f64)
A number stored as a double.
Text(String)
A string.
Array(Vec<Self>)
An array. TestStand arrays are homogeneous.
Container(BTreeMap<String, Self>)
A container, keyed by sub-property name.
Ordered rather than hashed so a serialized tree is stable between runs and diffable.
Trait Implementations§
Source§impl Clone for PropertyValue
impl Clone for PropertyValue
Source§fn clone(&self) -> PropertyValue
fn clone(&self) -> PropertyValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more