pub enum FieldType {
String,
Int,
Float,
Bool,
List(Box<Self>),
Object(Vec<ObjectField>),
Map(Box<Self>),
Enum(Vec<String>),
Nullable(Box<Self>),
OneOf {
arms: Vec<VariantArm>,
discriminator: Option<OneOfDiscriminator>,
},
AnyOf {
arms: Vec<VariantArm>,
},
Media {
kind: MediaKind,
accepted_sources: EnumSet<SourceKind>,
},
}Expand description
The type of a field in a signature.
Exhaustive by design — adding a new variant causes compiler errors at all
unhandled match arms. There is no Any or Custom escape hatch.
Sum-type variants (OneOf, AnyOf) model
JSON Schema’s oneOf / anyOf composition primitives. JSON Schema’s other
composition keywords (allOf, const, $ref, dependentSchemas,
if/then/else) are folded or transformed at schema-conversion time into
the existing variants — they have no runtime representation here.
Variants§
String
A UTF-8 string.
Int
A 64-bit signed integer.
Float
A 64-bit floating-point number.
Bool
A boolean value.
List(Box<Self>)
A homogeneous list of values.
Object(Vec<ObjectField>)
A structured object with named fields.
Map(Box<Self>)
A string-keyed map with homogeneous values.
Enum(Vec<String>)
One of a fixed set of string variants.
Nullable(Box<Self>)
A nullable wrapper around another type.
OneOf
Exactly one arm matches. Models JSON Schema’s oneOf.
When discriminator is Some, parsing is deterministic via tag
dispatch — the inbound JSON’s property field selects the arm by its
tags[i] value. When discriminator is None, parsing tries every
arm and demands exactly one succeed; zero matches and multiple matches
both surface specific errors.
Fields
arms: Vec<VariantArm>Alternatives, in declaration order.
discriminator: Option<OneOfDiscriminator>Discriminator hint for deterministic dispatch when the arms share
a const-valued property. Inferred at schema-conversion time.
AnyOf
At least one arm matches; first match wins. Models JSON Schema’s
anyOf. Parsing tries arms in declared order; the first arm whose
deserializer succeeds wins, and the rest are not attempted. Suitable
when arms may legitimately overlap and the consumer is content with
declared-order priority.
Fields
arms: Vec<VariantArm>Alternatives, in declared order.
Media
A media reference (image / document / audio / video).
accepted_sources constrains which SourceKinds a caller may
pass at value-construction time — the application preflight uses
this to reject application configurations whose declared sources
the model doesn’t support.
Fields
accepted_sources: EnumSet<SourceKind>Source kinds the slot accepts. Default is “all” when the schema doesn’t specify; preflight narrows it against the model’s capability table.
Implementations§
Source§impl FieldType
impl FieldType
Sourcepub fn type_label(&self) -> String
pub fn type_label(&self) -> String
Returns a human-readable type label for use in system prompts.
Sourcepub fn output_format_hint(&self) -> Option<String>
pub fn output_format_hint(&self) -> Option<String>
Concrete serialization guidance for an output field of this type,
for the system prompt and the live output-format reminder. None
means no note is needed — a bare string, or a media slot that’s
emitted as an out-of-band content part rather than text.
The type label alone (list[str]) doesn’t tell a model the wire
format, so well-behaved prompts still emit code fences, single-key
wrappers, or markdown lists. Stating the exact shape makes formatting
the adapter’s responsibility, not the caller’s. Mirrors DSPy’s
translate_field_type.