pub struct ToolExecutor { /* private fields */ }Expand description
Routes tool calls to the appropriate backend.
Implementations§
Source§impl ToolExecutor
impl ToolExecutor
pub fn new() -> Self
Sourcepub fn with_mcp_registry(self, registry: Arc<RwLock<McpToolRegistry>>) -> Self
pub fn with_mcp_registry(self, registry: Arc<RwLock<McpToolRegistry>>) -> Self
Set the MCP tool registry for routing MCP tool calls.
Sourcepub fn register_builtin(
&mut self,
name: impl Into<String>,
tool: Arc<dyn BuiltinTool>,
)
pub fn register_builtin( &mut self, name: impl Into<String>, tool: Arc<dyn BuiltinTool>, )
Register a built-in tool.
Sourcepub fn register_mcp(
&mut self,
name: impl Into<String>,
server_name: impl Into<String>,
)
pub fn register_mcp( &mut self, name: impl Into<String>, server_name: impl Into<String>, )
Register an MCP tool (from a connected server).
Sourcepub fn register_wasm(
&mut self,
name: impl Into<String>,
module_name: impl Into<String>,
)
pub fn register_wasm( &mut self, name: impl Into<String>, module_name: impl Into<String>, )
Register a WASM tool.
Sourcepub async fn execute(
&self,
tool_name: &str,
arguments: Value,
) -> Result<Value, ToolError>
pub async fn execute( &self, tool_name: &str, arguments: Value, ) -> Result<Value, ToolError>
Execute a tool by name.
Sourcepub fn tool_names(&self) -> Vec<String>
pub fn tool_names(&self) -> Vec<String>
List all registered tool names.
Sourcepub fn get_concurrency_policy(
&self,
tool_name: &str,
) -> Option<ConcurrencyPolicy>
pub fn get_concurrency_policy( &self, tool_name: &str, ) -> Option<ConcurrencyPolicy>
Get the concurrency policy for a tool by name.
Sourcepub fn as_llm_tools(&self) -> Vec<ToolDefinition>
pub fn as_llm_tools(&self) -> Vec<ToolDefinition>
Convert registered tools to LLM-compatible tool definitions.
Source§impl ToolExecutor
Convenience: execute a batch of tool calls concurrently.
This is a thin wrapper around ConcurrentToolDispatcher::dispatch.
impl ToolExecutor
Convenience: execute a batch of tool calls concurrently. This is a thin wrapper around ConcurrentToolDispatcher::dispatch.
pub async fn execute_concurrent( self: &Arc<Self>, tool_calls: &[ToolCall], policy_lookup: impl Fn(&str) -> ConcurrencyPolicy, ) -> Vec<ToolResult>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ToolExecutor
impl !UnwindSafe for ToolExecutor
impl Freeze for ToolExecutor
impl Send for ToolExecutor
impl Sync for ToolExecutor
impl Unpin for ToolExecutor
impl UnsafeUnpin for ToolExecutor
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
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more