pub enum ToolDefinition {
Custom(CustomTool),
Server(Value),
}Expand description
Tool definition – either a custom client tool or a built-in server tool.
Use this type in MessagesRequest::tools.
§Variants
ToolDefinition::Custom- A client-side tool with name, description, and JSON schemaToolDefinition::Server- Any server-managed tool (web search, code execution, etc.)
§Example
use claude_sdk::{CustomTool, ToolDefinition};
use serde_json::json;
// Custom tool
let custom = ToolDefinition::Custom(
CustomTool::new("my_tool", "A custom tool", json!({"type": "object"}))
);
// Server tool (raw JSON)
let server = ToolDefinition::Server(json!({
"type": "web_search_20250305",
"name": "web_search",
"max_uses": 5
}));Variants§
Custom(CustomTool)
Custom client-side tool with name, description, and JSON schema
Server(Value)
Any server tool – uses raw JSON since server tool types vary
Trait Implementations§
Source§impl Clone for ToolDefinition
impl Clone for ToolDefinition
Source§fn clone(&self) -> ToolDefinition
fn clone(&self) -> ToolDefinition
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 moreSource§impl Debug for ToolDefinition
impl Debug for ToolDefinition
Source§impl<'de> Deserialize<'de> for ToolDefinition
impl<'de> Deserialize<'de> for ToolDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<BashTool> for ToolDefinition
impl From<BashTool> for ToolDefinition
Source§fn from(tool: BashTool) -> ToolDefinition
fn from(tool: BashTool) -> ToolDefinition
Converts to this type from the input type.
Source§impl From<CodeExecutionTool> for ToolDefinition
impl From<CodeExecutionTool> for ToolDefinition
Source§fn from(tool: CodeExecutionTool) -> ToolDefinition
fn from(tool: CodeExecutionTool) -> ToolDefinition
Converts to this type from the input type.
Source§impl From<CustomTool> for ToolDefinition
impl From<CustomTool> for ToolDefinition
Source§fn from(tool: CustomTool) -> Self
fn from(tool: CustomTool) -> Self
Converts to this type from the input type.
Source§impl From<MemoryTool> for ToolDefinition
impl From<MemoryTool> for ToolDefinition
Source§fn from(tool: MemoryTool) -> ToolDefinition
fn from(tool: MemoryTool) -> ToolDefinition
Converts to this type from the input type.
Source§impl From<TextEditorTool> for ToolDefinition
impl From<TextEditorTool> for ToolDefinition
Source§fn from(tool: TextEditorTool) -> ToolDefinition
fn from(tool: TextEditorTool) -> ToolDefinition
Converts to this type from the input type.
Source§impl From<ToolSearchBm25> for ToolDefinition
impl From<ToolSearchBm25> for ToolDefinition
Source§fn from(tool: ToolSearchBm25) -> ToolDefinition
fn from(tool: ToolSearchBm25) -> ToolDefinition
Converts to this type from the input type.
Source§impl From<ToolSearchRegex> for ToolDefinition
impl From<ToolSearchRegex> for ToolDefinition
Source§fn from(tool: ToolSearchRegex) -> ToolDefinition
fn from(tool: ToolSearchRegex) -> ToolDefinition
Converts to this type from the input type.
Source§impl From<WebFetchTool> for ToolDefinition
impl From<WebFetchTool> for ToolDefinition
Source§fn from(tool: WebFetchTool) -> ToolDefinition
fn from(tool: WebFetchTool) -> ToolDefinition
Converts to this type from the input type.
Source§impl From<WebSearchTool> for ToolDefinition
impl From<WebSearchTool> for ToolDefinition
Source§fn from(tool: WebSearchTool) -> ToolDefinition
fn from(tool: WebSearchTool) -> ToolDefinition
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ToolDefinition
impl RefUnwindSafe for ToolDefinition
impl Send for ToolDefinition
impl Sync for ToolDefinition
impl Unpin for ToolDefinition
impl UnsafeUnpin for ToolDefinition
impl UnwindSafe for ToolDefinition
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 moreCreates a shared type from an unshared type.