pub struct SyncTool<F>{ /* private fields */ }Available on non-WebAssembly only.
Expand description
A simpler tool for synchronous handlers.
Implementations§
Source§impl<F> SyncTool<F>
impl<F> SyncTool<F>
Sourcepub fn new(name: impl Into<String>, handler: F) -> Self
pub fn new(name: impl Into<String>, handler: F) -> Self
Create a new synchronous tool with a name and handler.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the description for this tool.
Sourcepub fn with_schema(self, schema: Value) -> Self
pub fn with_schema(self, schema: Value) -> Self
Set the input schema for this tool.
Trait Implementations§
Source§impl<F> SyncToolExt for SyncTool<F>
impl<F> SyncToolExt for SyncTool<F>
Source§fn with_schema_from<T: JsonSchema>(self) -> Self
fn with_schema_from<T: JsonSchema>(self) -> Self
Available on crate feature
schema-generation only.Create a
SyncTool with schema generated from a type.Source§impl<F> ToolHandler for SyncTool<F>
impl<F> ToolHandler for SyncTool<F>
Source§fn handle<'life0, 'async_trait>(
&'life0 self,
args: Value,
_extra: RequestHandlerExtra,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
args: Value,
_extra: RequestHandlerExtra,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a tool call with the given arguments.
Source§fn metadata(&self) -> Option<ToolInfo>
fn metadata(&self) -> Option<ToolInfo>
Get tool metadata including description and schema.
Returns None to use default empty metadata.
Source§fn handle_output<'life0, 'async_trait>(
&'life0 self,
args: Value,
extra: RequestHandlerExtra,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_output<'life0, 'async_trait>(
&'life0 self,
args: Value,
extra: RequestHandlerExtra,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Produce the tool’s
ToolOutput for a call. Read moreAuto Trait Implementations§
impl<F> Freeze for SyncTool<F>where
F: Freeze,
impl<F> RefUnwindSafe for SyncTool<F>where
F: RefUnwindSafe,
impl<F> Send for SyncTool<F>
impl<F> Sync for SyncTool<F>
impl<F> Unpin for SyncTool<F>where
F: Unpin,
impl<F> UnsafeUnpin for SyncTool<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for SyncTool<F>where
F: 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