pub struct ToolRegistration { /* private fields */ }Expand description
工具注册信息 — Schema、安全分级、执行函数合一。
用户通过 ToolRegistration::safe() 等工厂方法构造。
字段 pub(crate) — 外部通过工厂方法访问,内部通过 ToolSnapshot 消费。
Implementations§
Source§impl ToolRegistration
impl ToolRegistration
Sourcepub fn definition(&self) -> &ToolDefinition
pub fn definition(&self) -> &ToolDefinition
获取工具定义的引用。
Sourcepub fn safety(&self) -> &ParallelSafety
pub fn safety(&self) -> &ParallelSafety
获取并行安全级别。
Sourcepub fn category(&self) -> Option<&ToolCategory>
pub fn category(&self) -> Option<&ToolCategory>
获取工具类别(如果有)。
pub fn safe<F, Fut>(def: ToolDefinition, f: F) -> Self
Sourcepub fn safe_fn<T, F, Fut>(def: ToolDefinition, f: F) -> Selfwhere
T: for<'de> Deserialize<'de> + Send + 'static,
F: Fn(T) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ToolResult> + Send + 'static,
pub fn safe_fn<T, F, Fut>(def: ToolDefinition, f: F) -> Selfwhere
T: for<'de> Deserialize<'de> + Send + 'static,
F: Fn(T) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ToolResult> + Send + 'static,
强类型便捷构造 — 自动反序列化参数。
与 safe() 的区别:闭包接收反序列化后的 T,而非原始 serde_json::Value。
反序列化失败时返回 ToolErrorKind::InvalidInput。
pub fn category_exclusive<F, Fut>( def: ToolDefinition, category: ToolCategory, f: F, ) -> Self
pub fn exclusive<F, Fut>(def: ToolDefinition, f: F) -> Self
Trait Implementations§
Source§impl Clone for ToolRegistration
impl Clone for ToolRegistration
Source§fn clone(&self) -> ToolRegistration
fn clone(&self) -> ToolRegistration
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolRegistration
impl !UnwindSafe for ToolRegistration
impl Freeze for ToolRegistration
impl Send for ToolRegistration
impl Sync for ToolRegistration
impl Unpin for ToolRegistration
impl UnsafeUnpin for ToolRegistration
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