pub struct ToolOutput {
pub output: ToolOutputBody,
pub success: bool,
pub metadata: Option<Box<RawValue>>,
/* private fields */
}Expand description
Complete output of one tool invocation.
Use Self::text, Self::json, or Self::content for successful
results. Self::error creates a structured model-visible failure without
turning the handler invocation itself into an error.
Fields§
§output: ToolOutputBodyModel-visible output body.
success: boolWhether the remote or local operation succeeded.
metadata: Option<Box<RawValue>>Optional validated opaque metadata for events and adapters.
Implementations§
Source§impl ToolOutput
impl ToolOutput
Sourcepub fn text(output: impl Into<String>) -> ToolOutput
pub fn text(output: impl Into<String>) -> ToolOutput
Creates a successful plain-text output.
Sourcepub fn error(error: impl Into<String>) -> ToolOutput
pub fn error(error: impl Into<String>) -> ToolOutput
Creates a model-visible failed output.
Sourcepub fn json(output: &impl Serialize) -> ToolOutput
pub fn json(output: &impl Serialize) -> ToolOutput
Serializes one successful function result as JSON text.
Sourcepub fn from_json(output: Value, success: bool) -> ToolOutput
pub fn from_json(output: Value, success: bool) -> ToolOutput
Creates a JSON result with an explicit success state.
Code Mode receives the typed JSON value while the Responses API receives its serialized text representation.
Sourcepub const fn content(output: Vec<ToolOutputContent>) -> ToolOutput
pub const fn content(output: Vec<ToolOutputContent>) -> ToolOutput
Creates a successful multimodal output.
Sourcepub fn with_metadata(self, metadata: impl Serialize) -> ToolOutput
pub fn with_metadata(self, metadata: impl Serialize) -> ToolOutput
Attaches validated opaque metadata.
An encoding failure converts this output into a model-visible failure.
Auto Trait Implementations§
impl Freeze for ToolOutput
impl RefUnwindSafe for ToolOutput
impl Send for ToolOutput
impl Sync for ToolOutput
impl Unpin for ToolOutput
impl UnsafeUnpin for ToolOutput
impl UnwindSafe for ToolOutput
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.