pub enum Schema {
String,
Int,
UInt,
Float,
Bool,
Null,
Array(Box<Schema>),
Object(ObjectSchema),
Union(Vec<Schema>),
Any,
}Expand description
Describes the expected structure and types for parsed JSON.
§Examples
use simple_agents_healing::schema::Schema;
// Simple string schema
let name_schema = Schema::String;
// Integer with range
let age_schema = Schema::Int;
// Object with fields
let person_schema = Schema::object(vec![
("name".into(), Schema::String, true),
("age".into(), Schema::Int, true),
("email".into(), Schema::String, false), // optional
]);Variants§
String
String type
Int
Signed integer (i64)
UInt
Unsigned integer (u64)
Float
Floating point number (f64)
Bool
Boolean
Null
Null value
Array(Box<Schema>)
Array of elements (homogeneous)
Object(ObjectSchema)
Object with named fields
Union(Vec<Schema>)
Union of multiple possible types (tagged or untagged)
Any
Any valid JSON value (no validation)
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn array(element_schema: Schema) -> Self
pub fn array(element_schema: Schema) -> Self
Create an array schema with element type.
§Examples
use simple_agents_healing::schema::Schema;
let string_array = Schema::array(Schema::String);
let int_array = Schema::array(Schema::Int);Sourcepub fn union(variants: Vec<Schema>) -> Self
pub fn union(variants: Vec<Schema>) -> Self
Create a union schema (sum type).
§Examples
use simple_agents_healing::schema::Schema;
// String or Int
let schema = Schema::union(vec![Schema::String, Schema::Int]);Sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
Check if this schema represents a primitive type.
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Check if this schema is nullable (includes Null in a union).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more