pub struct ToolUseBlock {
pub id: String,
pub name: String,
pub input: Value,
}Expand description
Tool use content block
Fields§
§id: String§name: String§input: ValueImplementations§
Source§impl ToolUseBlock
impl ToolUseBlock
Sourcepub fn typed_input(&self) -> Option<ToolInput>
pub fn typed_input(&self) -> Option<ToolInput>
Try to parse the input as a typed ToolInput.
This attempts to deserialize the raw JSON input into a strongly-typed
ToolInput enum variant. Returns None if parsing fails.
§Example
use claude_codes::{ToolUseBlock, ToolInput};
use serde_json::json;
let block = ToolUseBlock {
id: "toolu_123".to_string(),
name: "Bash".to_string(),
input: json!({"command": "ls -la"}),
};
if let Some(ToolInput::Bash(bash)) = block.typed_input() {
assert_eq!(bash.command, "ls -la");
}Sourcepub fn try_typed_input(&self) -> Result<ToolInput, Error>
pub fn try_typed_input(&self) -> Result<ToolInput, Error>
Parse the input as a typed ToolInput, returning an error on failure.
Unlike typed_input(), this method returns the parsing error for debugging.
Trait Implementations§
Source§impl Clone for ToolUseBlock
impl Clone for ToolUseBlock
Source§fn clone(&self) -> ToolUseBlock
fn clone(&self) -> ToolUseBlock
Returns a duplicate of the value. Read more
1.0.0 · 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 ToolUseBlock
impl Debug for ToolUseBlock
Source§impl<'de> Deserialize<'de> for ToolUseBlock
impl<'de> Deserialize<'de> for ToolUseBlock
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
Auto Trait Implementations§
impl Freeze for ToolUseBlock
impl RefUnwindSafe for ToolUseBlock
impl Send for ToolUseBlock
impl Sync for ToolUseBlock
impl Unpin for ToolUseBlock
impl UnsafeUnpin for ToolUseBlock
impl UnwindSafe for ToolUseBlock
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