pub enum ConfigValue {
Float(f32),
Integer(u64),
String(String),
Boolean(bool),
FloatArray(Vec<f32>),
}Expand description
Configuration value types.
Serialize uses #[serde(untagged)] so plain JSON numbers/strings/arrays/booleans
are emitted inside ConfigPayload::config.
JSON number behavior (intentional, pre-existing):
JSON numbers (e.g. 42 or 1.5) always deserialize as Float. Integer
is only reached for values that were originally ConfigValue::Integer in
Rust (in-memory), not from JSON. Deserialize is a deserialize_any
visitor rather than #[serde(untagged)] so JSON decimals still decode
when a consumer unifies serde_json arbitrary_precision (that feature
presents non-integer numbers to deserialize_any as a private Number
map, which untagged + deserialize_with = f32 does not accept). The
visit_map arm deserializes the map into a serde_json::Value and
preserves the JSON value type: only Value::Number is accepted (its
decimal token is parsed directly to f32); any other value type -
including a user object spoofing the magic key - is rejected. See the
visit_map arm for the one residual, arbitrary_precision-only edge case
that serde_json makes indistinguishable from a genuine number.
Round-tripping Integer(42) through JSON yields Float(42.0).
Large integers (> ~2^24) may lose precision in f32.
Consumers relying on exact integer identity should be aware.
Variants§
Float(f32)
Floating-point value.
JSON numbers (integers and floats) deserialize as Float.
Integer(u64)
Integer value (u64).
Typically only produced when a Rust ConfigValue::Integer is
constructed in memory. Plain JSON numbers land in Float.
String(String)
String value.
Allows string-valued config (e.g. mode names, paths) in ConfigPayload::config.
Boolean(bool)
Boolean value.
FloatArray(Vec<f32>)
Trait Implementations§
Source§impl Clone for ConfigValue
impl Clone for ConfigValue
Source§impl Debug for ConfigValue
impl Debug for ConfigValue
Source§impl<'de> Deserialize<'de> for ConfigValue
impl<'de> Deserialize<'de> for ConfigValue
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl PartialEq for ConfigValue
impl PartialEq for ConfigValue
Source§impl Serialize for ConfigValue
impl Serialize for ConfigValue
impl StructuralPartialEq for ConfigValue
Source§impl Validate for ConfigValue
impl Validate for ConfigValue
Source§fn validate_with(&self, limits: ProtocolLimits) -> Result<(), ValidationError>
fn validate_with(&self, limits: ProtocolLimits) -> Result<(), ValidationError>
Source§fn validate(&self) -> Result<(), ValidationError>
fn validate(&self) -> Result<(), ValidationError>
ProtocolLimits::DEFAULT.