Skip to main content

FieldType

Enum FieldType 

Source
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

§kind: MediaKind

Which modality this field carries (Image, Document, …).

§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

Source

pub fn type_label(&self) -> String

Returns a human-readable type label for use in system prompts.

Source

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.

Trait Implementations§

Source§

impl Clone for FieldType

Source§

fn clone(&self) -> FieldType

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 FieldType

Source§

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

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

impl<'de> Deserialize<'de> for FieldType

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl Display for FieldType

Source§

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

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

impl PartialEq for FieldType

Source§

fn eq(&self, other: &FieldType) -> 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 FieldType

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 FieldType

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more