pub struct ScriptToolRegistry { /* private fields */ }Expand description
脚本工具注册表
Implementations§
Source§impl ScriptToolRegistry
impl ScriptToolRegistry
Sourcepub fn new(
engine_config: ScriptEngineConfig,
) -> Result<ScriptToolRegistry, Error>
pub fn new( engine_config: ScriptEngineConfig, ) -> Result<ScriptToolRegistry, Error>
创建工具注册表
Sourcepub fn with_engine(engine: Arc<RhaiScriptEngine>) -> ScriptToolRegistry
pub fn with_engine(engine: Arc<RhaiScriptEngine>) -> ScriptToolRegistry
使用已有引擎创建注册表
Sourcepub async fn register_batch(
&self,
tools: Vec<ScriptToolDefinition>,
) -> Result<Vec<String>, Error>
pub async fn register_batch( &self, tools: Vec<ScriptToolDefinition>, ) -> Result<Vec<String>, Error>
批量注册工具
Sourcepub async fn load_from_directory(
&self,
dir_path: &str,
) -> Result<Vec<String>, Error>
pub async fn load_from_directory( &self, dir_path: &str, ) -> Result<Vec<String>, Error>
从目录加载所有工具
Sourcepub async fn execute(
&self,
tool_id: &str,
input: HashMap<String, Value>,
) -> Result<ToolExecutionResult, Error>
pub async fn execute( &self, tool_id: &str, input: HashMap<String, Value>, ) -> Result<ToolExecutionResult, Error>
执行工具
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
Source§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 moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage