pub enum ToolResult {
Done,
Text {
text: String,
},
Tsv {
text: String,
},
Json {
value: Value,
},
Binary {
mime: String,
content: Vec<u8>,
},
Error {
message: String,
},
}Expand description
Final structured result from a tool execution.
This keeps successful content and tool-level failures in distinct variants so UIs and runtimes do not need to infer errors from free-form strings.
§Example
ⓘ
use aither::llm::tool::ToolResult;
fn search_tool() -> ToolResult {
ToolResult::text("Found 3 results...")
}
fn delete_tool() -> ToolResult {
ToolResult::Done
}Variants§
Done
Tool completed with no output to return.
Text
UTF-8 plain text output.
Tsv
Tab-separated tabular output.
Json
Structured JSON output.
Binary
Binary or media payload.
Fields
Error
Tool-level error. This is distinct from transport/runtime failures.
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub const fn json_value(value: Value) -> Self
pub const fn json_value(value: Value) -> Self
Creates a JSON result from an already-materialized JSON value.
Sourcepub fn error_message(&self) -> Option<&str>
pub fn error_message(&self) -> Option<&str>
Returns the error message if this is a typed tool error.
Sourcepub fn render_for_model(&self) -> Result<String>
pub fn render_for_model(&self) -> Result<String>
Projects the result into a textual representation safe to re-inject into model context.
§Errors
Returns an error if JSON serialization fails.
Sourcepub fn render_for_cli(&self) -> Result<String>
pub fn render_for_cli(&self) -> Result<String>
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 (const: unstable) · 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
impl Eq for ToolResult
Source§impl IntoToolResult for ToolResult
impl IntoToolResult for ToolResult
Source§fn into_tool_result(self) -> Result<ToolResult>
fn into_tool_result(self) -> Result<ToolResult>
Converts the value into a final
ToolResult. Read moreSource§impl PartialEq for ToolResult
impl PartialEq for ToolResult
Source§impl Serialize for ToolResult
impl Serialize for ToolResult
impl StructuralPartialEq for ToolResult
Auto Trait Implementations§
impl Freeze for ToolResult
impl RefUnwindSafe for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin for ToolResult
impl UnsafeUnpin 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