pub struct ToolRunner { /* private fields */ }Expand description
Registry that maps tool names to implementations and dispatches calls.
Implementations§
Source§impl ToolRunner
impl ToolRunner
Sourcepub fn register(&self, tool: Arc<dyn Tool>)
pub fn register(&self, tool: Arc<dyn Tool>)
Register a tool by name. Overwrites any existing tool with the same name.
Sourcepub fn set_context(&self, ctx: Arc<ToolContext>)
pub fn set_context(&self, ctx: Arc<ToolContext>)
Set the shared context passed to tools on each execution.
Sourcepub fn clear_context(&self)
pub fn clear_context(&self)
Remove the shared context (tools will receive None).
Sourcepub fn iter_tools(&self) -> Vec<Arc<dyn Tool>>
pub fn iter_tools(&self) -> Vec<Arc<dyn Tool>>
Snapshot every registered tool as Arc<dyn Tool>. Cheap clone —
the Arcs share their backing data.
Sourcepub async fn execute(&self, name: &str, args: Value) -> Result<Value>
pub async fn execute(&self, name: &str, args: Value) -> Result<Value>
Execute a tool by name with the given JSON arguments.
Sourcepub async fn process_tool_calls(&self, calls: Vec<ToolCall>) -> Vec<ToolResult>
pub async fn process_tool_calls(&self, calls: Vec<ToolCall>) -> Vec<ToolResult>
Execute a batch of tool calls and collect their results.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ToolRunner
impl !RefUnwindSafe for ToolRunner
impl !UnwindSafe for ToolRunner
impl Send for ToolRunner
impl Sync for ToolRunner
impl Unpin for ToolRunner
impl UnsafeUnpin for ToolRunner
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