pub enum FieldValue {
Str(String),
Int(i64),
Float(f64),
Bool(bool),
List(Vec<Self>),
Variant {
arm_index: usize,
value: Box<Self>,
},
Object(BTreeMap<String, Self>),
Media(MediaValue),
Null,
}Expand description
A typed value extracted from an LM completion or supplied as input.
Mirrors FieldType but holds actual data. Produced by adapter parsing.
§Serde behavior
Uses #[serde(untagged)] — serde tries variants in declaration order during
deserialization. This means JSON 42 deserializes as Int(42) (not Float),
3.14 as Float(3.14), true as Bool(true), etc. This ordering is
intentional and deterministic: whole numbers become Int, decimal numbers
become Float. Do not reorder variants without considering the serde impact.
The Media variant is tagged via its inner MediaValue struct
(which carries an explicit kind discriminator) rather than the
untagged numeric/string variants. Serde tries each untagged variant
in order, and MediaValue’s struct shape is unambiguous against
the scalar variants.
The Variant arm is placed before Object so its specific
{arm_index, value} shape matches first. The narrow consequence: a real
Object whose declared fields are exactly {arm_index: <non-negative int>, value: <any>} (and nothing else) cannot round-trip through serde-untagged
— it would be parsed as Variant. No production schema uses these field
names, so the ambiguity is theoretical, but consumers persisting custom
shapes should avoid this exact field pair.
Variants§
Str(String)
A string value.
Int(i64)
An integer value.
Float(f64)
A floating-point value.
Bool(bool)
A boolean value.
List(Vec<Self>)
A list of values.
Variant
A matched arm of a OneOf or AnyOf
field. arm_index is the zero-based position of the matched arm in the
owning FieldType’s arms vector; consumers can switch on it without
re-running arm validation.
Fields
Object(BTreeMap<String, Self>)
A structured object with named fields.
Media(MediaValue)
A media reference (image / document / audio / video).
Null
A null value (from a nullable field).
Trait Implementations§
Source§impl Clone for FieldValue
impl Clone for FieldValue
Source§fn clone(&self) -> FieldValue
fn clone(&self) -> FieldValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more