Skip to main content

ConfigValue

Enum ConfigValue 

Source
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

Source§

fn clone(&self) -> Self

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 ConfigValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ConfigValue

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ConfigValue

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ConfigValue

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ConfigValue

Source§

impl Validate for ConfigValue

Source§

fn validate_with(&self, limits: ProtocolLimits) -> Result<(), ValidationError>

Validate against an explicit policy.
Source§

fn validate(&self) -> Result<(), ValidationError>

Validate against ProtocolLimits::DEFAULT.

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> 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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.