pub enum ToolOutput {
Content(Vec<Box<dyn Content>>),
Structured(Value),
}Expand description
Tool execution output - either content OR structured, never both.
MCP spec allows tools to return either:
content: Array of content items (text, images, etc.) for displaystructuredContent: JSON object conforming to the tool’soutputSchema
This enum enforces exclusivity at the type level.
Variants§
Content(Vec<Box<dyn Content>>)
Traditional content array (text, images, etc.)
Structured(Value)
Structured JSON output (must conform to outputSchema if defined)
Implementations§
Source§impl ToolOutput
impl ToolOutput
Sourcepub fn content(items: Vec<Box<dyn Content>>) -> Self
pub fn content(items: Vec<Box<dyn Content>>) -> Self
Create content output from a vec of content items
Sourcepub fn structured<T: Serialize>(value: T) -> Result<Self, Error>
pub fn structured<T: Serialize>(value: T) -> Result<Self, Error>
Create structured output from a serializable value
Sourcepub fn is_content(&self) -> bool
pub fn is_content(&self) -> bool
Check if this is content output
Sourcepub fn is_structured(&self) -> bool
pub fn is_structured(&self) -> bool
Check if this is structured output
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolOutput
impl !RefUnwindSafe for ToolOutput
impl Send for ToolOutput
impl Sync for ToolOutput
impl Unpin 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
Mutably borrows from an owned value. Read more