pub struct StructuredOutputContext {
pub forced_mode: bool,
pub force_attempted: bool,
pub stop_loop: bool,
/* private fields */
}Expand description
Per-invocation context for structured output execution.
Fields§
§forced_mode: boolWhether forced mode is active.
force_attempted: boolWhether force was attempted.
stop_loop: boolWhether to stop the event loop.
Implementations§
Source§impl StructuredOutputContext
impl StructuredOutputContext
Sourcepub fn with_type<T: JsonSchema + DeserializeOwned>() -> Self
pub fn with_type<T: JsonSchema + DeserializeOwned>() -> Self
Creates a new structured output context with a specific output type.
Sourcepub fn with_tool_name(name: impl Into<String>, spec: Option<ToolSpec>) -> Self
pub fn with_tool_name(name: impl Into<String>, spec: Option<ToolSpec>) -> Self
Creates a new structured output context with a specific tool name and spec.
Sourcepub fn get_tool_spec(&self) -> Option<&ToolSpec>
pub fn get_tool_spec(&self) -> Option<&ToolSpec>
Returns the tool specification if available.
Sourcepub fn register_tool(&self, registry: &mut ToolRegistry) -> bool
pub fn register_tool(&self, registry: &mut ToolRegistry) -> bool
Registers the structured output tool with the given registry.
Returns true if a tool was registered, false otherwise.
Sourcepub fn cleanup(&self, registry: &mut ToolRegistry)
pub fn cleanup(&self, registry: &mut ToolRegistry)
Removes the structured output tool from the given registry.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if structured output is enabled for this context.
Sourcepub fn expected_tool_name(&self) -> Option<&str>
pub fn expected_tool_name(&self) -> Option<&str>
Get the expected tool name.
Sourcepub fn store_result(&mut self, tool_use_id: &str, result: Value)
pub fn store_result(&mut self, tool_use_id: &str, result: Value)
Store a validated structured output result.
Sourcepub fn get_result(&self, tool_use_id: &str) -> Option<&Value>
pub fn get_result(&self, tool_use_id: &str) -> Option<&Value>
Retrieve a stored structured output result.
Sourcepub fn set_forced_mode(&mut self)
pub fn set_forced_mode(&mut self)
Mark this context as being in forced structured output mode.
Sourcepub fn has_structured_output_tool(&self, tool_names: &[String]) -> bool
pub fn has_structured_output_tool(&self, tool_names: &[String]) -> bool
Check if any tool uses are for the structured output tool.
Sourcepub fn extract_result(&mut self, tool_use_ids: &[String]) -> Option<Value>
pub fn extract_result(&mut self, tool_use_ids: &[String]) -> Option<Value>
Extract and remove structured output result from stored results.
Trait Implementations§
Source§impl Clone for StructuredOutputContext
impl Clone for StructuredOutputContext
Source§fn clone(&self) -> StructuredOutputContext
fn clone(&self) -> StructuredOutputContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StructuredOutputContext
impl Debug for StructuredOutputContext
Source§impl Default for StructuredOutputContext
impl Default for StructuredOutputContext
Source§fn default() -> StructuredOutputContext
fn default() -> StructuredOutputContext
Auto Trait Implementations§
impl Freeze for StructuredOutputContext
impl RefUnwindSafe for StructuredOutputContext
impl Send for StructuredOutputContext
impl Sync for StructuredOutputContext
impl Unpin for StructuredOutputContext
impl UnwindSafe for StructuredOutputContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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