pub struct ToolKit { /* private fields */ }Expand description
Local tool registry backed by tool-name-to-closure mappings.
Implementations§
Source§impl ToolKit
impl ToolKit
Sourcepub fn with_tool<F, Fut>(
tool: ToolDefinition,
handler: F,
) -> Result<Self, ToolCallError>
pub fn with_tool<F, Fut>( tool: ToolDefinition, handler: F, ) -> Result<Self, ToolCallError>
Creates a new ToolKit containing one registered local tool.
Sourcepub fn register_tool<F, Fut>(
&self,
tool: ToolDefinition,
handler: F,
) -> Result<(), ToolCallError>
pub fn register_tool<F, Fut>( &self, tool: ToolDefinition, handler: F, ) -> Result<(), ToolCallError>
Registers a local tool and the closure that executes it.
Sourcepub fn get_tool(&self, tool_name: &str) -> Option<ToolDefinition>
pub fn get_tool(&self, tool_name: &str) -> Option<ToolDefinition>
Gets a tool by its local name.
Sourcepub fn lookup_tools(&self, tool_names: &[&str]) -> Vec<Option<ToolDefinition>>
pub fn lookup_tools(&self, tool_names: &[&str]) -> Vec<Option<ToolDefinition>>
Looks up multiple tools by local name, preserving missing entries as None.
Sourcepub fn tool_names(&self) -> Vec<String>
pub fn tool_names(&self) -> Vec<String>
Gets all registered local tool names.
Sourcepub fn tools(&self) -> Vec<ToolDefinition>
pub fn tools(&self) -> Vec<ToolDefinition>
Gets all registered local tool definitions.
Sourcepub fn unregister_tool(&self, tool_name: &str) -> Result<(), ToolCallError>
pub fn unregister_tool(&self, tool_name: &str) -> Result<(), ToolCallError>
Removes a local tool by name.
Sourcepub fn tool_count(&self) -> usize
pub fn tool_count(&self) -> usize
Returns the number of registered local tools.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ToolKit
impl !UnwindSafe for ToolKit
impl Freeze for ToolKit
impl Send for ToolKit
impl Sync for ToolKit
impl Unpin for ToolKit
impl UnsafeUnpin for ToolKit
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