#[non_exhaustive]pub enum SchemaTransform {
AdditionalPropertiesFalse,
RemovePropertyNames,
OpenAiStrict,
}Expand description
A rewrite applied to a JSON Schema before it is sent to a provider.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AdditionalPropertiesFalse
Set additionalProperties: false on every object schema.
Applied by default to schemas derived from Rust types, so that models cannot invent properties the type does not declare.
RemovePropertyNames
Remove propertyNames keywords everywhere.
OpenAiStrict
OpenAI strict mode: additionalProperties: false, no propertyNames,
every property required, previously optional properties nullable.
Implementations§
Source§impl SchemaTransform
impl SchemaTransform
Sourcepub fn openai_strict() -> Self
pub fn openai_strict() -> Self
The OpenAI strict-mode transform.
Sourcepub fn additional_properties_false() -> Self
pub fn additional_properties_false() -> Self
The additionalProperties: false transform.
Sourcepub fn apply(self, schema: &mut Value) -> Result<(), SchemaError>
pub fn apply(self, schema: &mut Value) -> Result<(), SchemaError>
Applies the transform in place, leaving the input unchanged on error.
§Errors
Returns SchemaError::UnsupportedTransform for dictionaries that
OpenAI strict mode cannot represent.
Sourcepub fn applied(self, schema: Value) -> Result<Value, SchemaError>
pub fn applied(self, schema: Value) -> Result<Value, SchemaError>
Applies the transform to an owned schema and returns it.
§Errors
Returns SchemaError::UnsupportedTransform for dictionaries that
OpenAI strict mode cannot represent.
Trait Implementations§
Source§impl Clone for SchemaTransform
impl Clone for SchemaTransform
Source§fn clone(&self) -> SchemaTransform
fn clone(&self) -> SchemaTransform
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SchemaTransform
Source§impl Debug for SchemaTransform
impl Debug for SchemaTransform
impl Eq for SchemaTransform
Source§impl Hash for SchemaTransform
impl Hash for SchemaTransform
Source§impl PartialEq for SchemaTransform
impl PartialEq for SchemaTransform
impl StructuralPartialEq for SchemaTransform
Auto Trait Implementations§
impl Freeze for SchemaTransform
impl RefUnwindSafe for SchemaTransform
impl Send for SchemaTransform
impl Sync for SchemaTransform
impl Unpin for SchemaTransform
impl UnsafeUnpin for SchemaTransform
impl UnwindSafe for SchemaTransform
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.