pub struct SdkTool {
pub def: ToolDef,
/* private fields */
}Expand description
A tool definition plus the async function that runs it.
#[claude_tool] generates <fn>_tool() -> SdkTool.
A call the CLI cancels (notifications/cancelled, e.g. after an
interrupt) drops the handler’s future, so .await points are where a
handler stops.
Fields§
§def: ToolDefName, description and schemas sent to the CLI.
Implementations§
Source§impl SdkTool
impl SdkTool
Sourcepub fn new<F, Fut>(def: ToolDef, handler: F) -> Self
pub fn new<F, Fut>(def: ToolDef, handler: F) -> Self
handler receives the raw arguments object of the tool call.
Sourcepub fn with_context<F, Fut>(def: ToolDef, handler: F) -> Selfwhere
F: Fn(Value, ToolContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ToolResult> + Send + 'static,
pub fn with_context<F, Fut>(def: ToolDef, handler: F) -> Selfwhere
F: Fn(Value, ToolContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ToolResult> + Send + 'static,
Like new, with the call’s ToolContext (tool_use id, session id).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SdkTool
impl !UnwindSafe for SdkTool
impl Forget for SdkTool
impl Freeze for SdkTool
impl Move for SdkTool
impl Send for SdkTool
impl Sync for SdkTool
impl Unpin for SdkTool
impl UnsafeUnpin for SdkTool
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