pub enum ToolResult {
Text(String),
Json(Value),
Image {
format: ImageFormat,
data: Vec<u8>,
},
Document {
format: DocumentFormat,
data: Vec<u8>,
name: Option<String>,
},
}Expand description
Result types that tools can return.
Tools can return different content types depending on their purpose. All providers support Text and Json. Image and Document support varies by provider (Bedrock supports all types; future providers may fall back to text descriptions).
Variants§
Text(String)
Plain text response
Json(Value)
Structured JSON data - use for complex responses
Image
Image data - supported by Bedrock (Claude, Nova models)
Document
Document data - supported by Bedrock (Claude, Nova models)
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn json<T: Serialize>(value: T) -> Result<Self, Error>
pub fn json<T: Serialize>(value: T) -> Result<Self, Error>
Create a JSON result from any serializable type
Sourcepub fn image(format: ImageFormat, data: Vec<u8>) -> Self
pub fn image(format: ImageFormat, data: Vec<u8>) -> Self
Create an image result from raw bytes
Sourcepub fn document(format: DocumentFormat, data: Vec<u8>) -> Self
pub fn document(format: DocumentFormat, data: Vec<u8>) -> Self
Create a document result from raw bytes
Sourcepub fn document_with_name(
format: DocumentFormat,
data: Vec<u8>,
name: impl Into<String>,
) -> Self
pub fn document_with_name( format: DocumentFormat, data: Vec<u8>, name: impl Into<String>, ) -> Self
Create a document result with a filename
Trait Implementations§
Source§impl Clone for ToolResult
impl Clone for ToolResult
Source§fn clone(&self) -> ToolResult
fn clone(&self) -> ToolResult
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolResult
impl Debug for ToolResult
Source§impl<'de> Deserialize<'de> for ToolResult
impl<'de> Deserialize<'de> for ToolResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&str> for ToolResult
impl From<&str> for ToolResult
Source§impl From<String> for ToolResult
Convert strings directly to ToolResult::Text
impl From<String> for ToolResult
Convert strings directly to ToolResult::Text
Auto Trait Implementations§
impl Freeze for ToolResult
impl RefUnwindSafe for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin for ToolResult
impl UnwindSafe for ToolResult
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