pub struct ScriptToolRegistry { /* private fields */ }Expand description
脚本工具注册表
Implementations§
Source§impl ScriptToolRegistry
impl ScriptToolRegistry
Sourcepub fn new(engine_config: ScriptEngineConfig) -> Result<Self>
pub fn new(engine_config: ScriptEngineConfig) -> Result<Self>
创建工具注册表
Sourcepub fn with_engine(engine: Arc<RhaiScriptEngine>) -> Self
pub fn with_engine(engine: Arc<RhaiScriptEngine>) -> Self
使用已有引擎创建注册表
Sourcepub async fn register(&self, tool: ScriptToolDefinition) -> Result<()>
pub async fn register(&self, tool: ScriptToolDefinition) -> Result<()>
注册工具
Sourcepub async fn register_batch(
&self,
tools: Vec<ScriptToolDefinition>,
) -> Result<Vec<String>>
pub async fn register_batch( &self, tools: Vec<ScriptToolDefinition>, ) -> Result<Vec<String>>
批量注册工具
Sourcepub async fn load_from_yaml(&self, path: &str) -> Result<String>
pub async fn load_from_yaml(&self, path: &str) -> Result<String>
从 YAML 文件加载工具
Sourcepub async fn load_from_json(&self, path: &str) -> Result<String>
pub async fn load_from_json(&self, path: &str) -> Result<String>
从 JSON 文件加载工具
Sourcepub async fn execute(
&self,
tool_id: &str,
input: HashMap<String, Value>,
) -> Result<ToolExecutionResult>
pub async fn execute( &self, tool_id: &str, input: HashMap<String, Value>, ) -> Result<ToolExecutionResult>
执行工具
Sourcepub async fn get_tool(&self, tool_id: &str) -> Option<ScriptToolDefinition>
pub async fn get_tool(&self, tool_id: &str) -> Option<ScriptToolDefinition>
获取工具定义
Sourcepub async fn list_tools(&self) -> Vec<ScriptToolDefinition>
pub async fn list_tools(&self) -> Vec<ScriptToolDefinition>
列出所有工具
Sourcepub async fn list_tools_by_tag(&self, tag: &str) -> Vec<ScriptToolDefinition>
pub async fn list_tools_by_tag(&self, tag: &str) -> Vec<ScriptToolDefinition>
按标签过滤工具
Sourcepub async fn unregister(&self, tool_id: &str) -> bool
pub async fn unregister(&self, tool_id: &str) -> bool
移除工具
Sourcepub async fn tool_count(&self) -> usize
pub async fn tool_count(&self) -> usize
获取工具数量
Sourcepub async fn generate_tool_schemas(&self) -> Vec<Value>
pub async fn generate_tool_schemas(&self) -> Vec<Value>
生成所有工具的 JSON Schema 描述(用于 LLM function calling)
Auto Trait Implementations§
impl Freeze for ScriptToolRegistry
impl !RefUnwindSafe for ScriptToolRegistry
impl Send for ScriptToolRegistry
impl Sync for ScriptToolRegistry
impl Unpin for ScriptToolRegistry
impl UnsafeUnpin for ScriptToolRegistry
impl !UnwindSafe for ScriptToolRegistry
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