pub enum ValueSchema {
Number {
kind: NumberKind,
},
Bool,
Text {
max_len: Option<usize>,
},
Enum {
variants: Vec<String>,
},
Array {
items: Box<ValueSchema>,
min_len: Option<usize>,
max_len: Option<usize>,
},
Record {
fields: Vec<FieldSchema>,
allow_extra: bool,
},
Quantity {
dimension: Option<Dimension>,
allow_delta: bool,
},
Money,
Matrix {
max_elems: Option<usize>,
square: bool,
},
Expression {
variables: Vec<String>,
},
Bound,
Any,
}Expand description
The schema of a single value.
Variants§
Number
Fields
§
kind: NumberKindBool
Text
Enum
Array
Record
Quantity
Fields
Money
Matrix
Expression
A restricted expression string, parsed by the engine before invocation.
Bound
Any
Implementations§
Source§impl ValueSchema
impl ValueSchema
pub fn number(kind: NumberKind) -> ValueSchema
pub fn exact() -> ValueSchema
pub fn float64() -> ValueSchema
pub fn text() -> ValueSchema
pub fn array(items: ValueSchema) -> ValueSchema
pub fn array_with_len( items: ValueSchema, min_len: usize, max_len: Option<usize>, ) -> ValueSchema
Sourcepub fn validate(
&self,
value: &Value,
path: &str,
limits: &Limits,
) -> Result<(), EngineError>
pub fn validate( &self, value: &Value, path: &str, limits: &Limits, ) -> Result<(), EngineError>
Validate an already-typed value.
Sourcepub fn coerce(
&self,
raw: &Value,
path: &str,
limits: &Limits,
numeric_shorthand: bool,
) -> Result<Value, EngineError>
pub fn coerce( &self, raw: &Value, path: &str, limits: &Limits, numeric_shorthand: bool, ) -> Result<Value, EngineError>
Coerce raw JSON into a typed value, applying the documented shorthand
rules: JSON integers/decimals are exact, and when numeric_shorthand is
true a string is parsed as a numeric literal for numeric schemas.
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
True when this schema accepts exact numeric payloads and therefore may receive string shorthand in expressions/requests.
Sourcepub fn summary(&self) -> String
pub fn summary(&self) -> String
A short human-readable description, used in generated documentation.
Sourcepub fn to_json_schema(&self) -> Value
pub fn to_json_schema(&self) -> Value
Convert to a JSON-schema-like description used in MCP tool definitions.
Trait Implementations§
Source§impl Clone for ValueSchema
impl Clone for ValueSchema
Source§fn clone(&self) -> ValueSchema
fn clone(&self) -> ValueSchema
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValueSchema
impl Debug for ValueSchema
Source§impl<'de> Deserialize<'de> for ValueSchema
impl<'de> Deserialize<'de> for ValueSchema
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
Source§impl PartialEq for ValueSchema
impl PartialEq for ValueSchema
Source§impl Serialize for ValueSchema
impl Serialize for ValueSchema
impl StructuralPartialEq for ValueSchema
Auto Trait Implementations§
impl Freeze for ValueSchema
impl RefUnwindSafe for ValueSchema
impl Send for ValueSchema
impl Sync for ValueSchema
impl Unpin for ValueSchema
impl UnsafeUnpin for ValueSchema
impl UnwindSafe for ValueSchema
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