Skip to main content

Crate ferrin_schema

Crate ferrin_schema 

Source
Expand description

Ferrin JSON Schema support.

  • Schema: a JSON Schema plus a typed validation function, created from a Rust type (schemars derive + serde deserialization), from a raw JSON Schema (validated with jsonschema when the json-schema-validation feature is enabled) or from a custom validator.
  • SchemaDialect: draft-07 (default) or 2020-12 generation settings.
  • SchemaTransform: provider-oriented schema rewrites (additionalProperties: false, OpenAI strict mode).
  • partial_json: repair and parse truncated JSON produced by streaming models.
  • json: JSON parsing with size and depth limits.

Design: docs/01-architecture/08-structured-output.md, ADR 0004.

§Attribution

Portions of this crate are derived from the Vercel AI SDK (Apache-2.0, Copyright 2023 Vercel, Inc.), translated from TypeScript to Rust and modified. See the NOTICE file in the crate root.

Re-exports§

pub use dialect::SchemaDialect;
pub use json::ParseLimits;
pub use partial_json::PartialParse;
pub use partial_json::PartialParseState;
pub use schema::Schema;
pub use transform::SchemaTransform;
pub use validation::ValidationIssue;
pub use validation::ValidationIssues;
pub use schemars;

Modules§

dialect
JSON Schema dialects used for generation.
json
JSON parsing with resource limits.
partial_json
Repair and parse truncated JSON.
schema
The Schema abstraction: a JSON Schema plus a typed validator.
transform
Provider-oriented JSON Schema rewrites.
validation
Dynamic JSON Schema validation.

Structs§

JsonParseError
Text could not be parsed as JSON.
TypeValidationContext
Where a validated value came from, for error messages.
TypeValidationError
A value failed schema or type validation.

Enums§

SchemaError
Errors produced while parsing or validating JSON against a schema.

Traits§

JsonSchema
A type which can be described as a JSON Schema document.

Derive Macros§

JsonSchema
Derive macro for JsonSchema trait.