Struct SchemaCleanr
pub struct SchemaCleanr;Expand description
JSON Schema cleaner optimized for LLM tool calling.
Implementations§
Source§impl SchemaCleanr
impl SchemaCleanr
Sourcepub fn clean_for_gemini(schema: Value) -> Value
pub fn clean_for_gemini(schema: Value) -> Value
Clean schema for Gemini compatibility (strictest).
This is the most aggressive cleaning strategy, removing all keywords that Gemini’s API rejects.
Sourcepub fn clean_for_anthropic(schema: Value) -> Value
pub fn clean_for_anthropic(schema: Value) -> Value
Clean schema for Anthropic compatibility.
Sourcepub fn clean_for_openai(schema: Value) -> Value
pub fn clean_for_openai(schema: Value) -> Value
Clean schema for OpenAI compatibility (most permissive).
Zero-copy wrapper around Self::clean for Arc-shared tool schemas:
returns the same Arc when the pre-scan proves cleaning is a
no-op, deep-copying the tree only when a rewrite is actually needed.
Sourcepub fn needs_cleaning(schema: &Value, strategy: CleaningStrategy) -> bool
pub fn needs_cleaning(schema: &Value, strategy: CleaningStrategy) -> bool
Conservative read-only pre-scan: true when Self::clean with
strategy could change schema.
False positives are allowed (a flagged schema may clean to an equal
value); false negatives are not — !needs_cleaning(s) must imply
clean(s) == s. The triggers mirror every rewrite path in
clean_object: strategy-specific keyword removal, plus the
strategy-independent rewrites ($ref resolution, const → enum,
anyOf/oneOf simplification and sibling-type skipping, and
null-stripping in type arrays).
Sourcepub fn clean(schema: Value, strategy: CleaningStrategy) -> Value
pub fn clean(schema: Value, strategy: CleaningStrategy) -> Value
Clean schema with specified strategy.
Auto Trait Implementations§
impl Freeze for SchemaCleanr
impl RefUnwindSafe for SchemaCleanr
impl Send for SchemaCleanr
impl Sync for SchemaCleanr
impl Unpin for SchemaCleanr
impl UnsafeUnpin for SchemaCleanr
impl UnwindSafe for SchemaCleanr
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more