pub struct FunctionTool<Input, Output, Handler> { /* private fields */ }Expand description
A typed asynchronous Rust function exposed through the canonical Tool boundary.
Implementations§
Source§impl<Input, Output, Handler> FunctionTool<Input, Output, Handler>where
Input: JsonSchema,
Output: JsonSchema,
impl<Input, Output, Handler> FunctionTool<Input, Output, Handler>where
Input: JsonSchema,
Output: JsonSchema,
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
handler: Handler,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, handler: Handler, ) -> Self
Creates a typed Tool with generated input and output JSON Schemas.
The default effect is EffectClass::Pure and the default risk is
RiskLevel::Low. Callers must explicitly override these values for
functions that read or modify external state.
Sourcepub const fn capability_id(self, id: CapabilityId) -> Self
pub const fn capability_id(self, id: CapabilityId) -> Self
Replaces the stable capability identity.
Sourcepub fn version(self, version: impl Into<String>) -> Self
pub fn version(self, version: impl Into<String>) -> Self
Sets the semantic Tool contract version.
Sourcepub const fn effect(self, effect: EffectClass) -> Self
pub const fn effect(self, effect: EffectClass) -> Self
Declares external-effect behavior.
Trait Implementations§
Source§impl<Input, Output, Handler> Debug for FunctionTool<Input, Output, Handler>
impl<Input, Output, Handler> Debug for FunctionTool<Input, Output, Handler>
Source§impl<Input, Output, Handler, HandlerFuture> Tool for FunctionTool<Input, Output, Handler>where
Input: DeserializeOwned + JsonSchema + Send + 'static,
Output: JsonSchema + Serialize + Send + 'static,
Handler: Fn(Input, ToolContext) -> HandlerFuture + Send + Sync,
HandlerFuture: Future<Output = Result<Output, ToolError>> + Send + 'static,
impl<Input, Output, Handler, HandlerFuture> Tool for FunctionTool<Input, Output, Handler>where
Input: DeserializeOwned + JsonSchema + Send + 'static,
Output: JsonSchema + Serialize + Send + 'static,
Handler: Fn(Input, ToolContext) -> HandlerFuture + Send + Sync,
HandlerFuture: Future<Output = Result<Output, ToolError>> + Send + 'static,
Source§fn descriptor(&self) -> &ToolDescriptor
fn descriptor(&self) -> &ToolDescriptor
Returns the tool’s immutable semantic contract.
Source§fn invoke(
&self,
input: Value,
context: ToolContext,
) -> ToolFuture<'_, Result<ToolOutput, ToolError>>
fn invoke( &self, input: Value, context: ToolContext, ) -> ToolFuture<'_, Result<ToolOutput, ToolError>>
Executes one invocation.
Auto Trait Implementations§
impl<Input, Output, Handler> Freeze for FunctionTool<Input, Output, Handler>where
Handler: Freeze,
impl<Input, Output, Handler> RefUnwindSafe for FunctionTool<Input, Output, Handler>where
Handler: RefUnwindSafe,
impl<Input, Output, Handler> Send for FunctionTool<Input, Output, Handler>where
Handler: Send,
impl<Input, Output, Handler> Sync for FunctionTool<Input, Output, Handler>where
Handler: Sync,
impl<Input, Output, Handler> Unpin for FunctionTool<Input, Output, Handler>where
Handler: Unpin,
impl<Input, Output, Handler> UnsafeUnpin for FunctionTool<Input, Output, Handler>where
Handler: UnsafeUnpin,
impl<Input, Output, Handler> UnwindSafe for FunctionTool<Input, Output, Handler>where
Handler: UnwindSafe,
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