pub struct ToolResultBlock {
pub tool_use_id: String,
pub cache_control: Option<CacheControlEphemeral>,
pub content: Option<ToolResultBlockContent>,
pub is_error: Option<bool>,
}anthropic-client only.Expand description
A block containing the result of a tool execution.
ToolResultBlock represents the output from executing a tool that was previously requested via a ToolUseBlock. It contains the tool’s response, which can be either successful output or an error indication.
Fields§
§tool_use_id: StringThe ID of the tool use that this result is for.
This must match the ID from the corresponding ToolUseBlock.
cache_control: Option<CacheControlEphemeral>Create a cache control breakpoint at this content block.
When set, this creates an ephemeral cache point that can be reused in subsequent requests to avoid reprocessing the tool result.
content: Option<ToolResultBlockContent>The content of the tool result, which can be either a string or an array of content items.
This contains the actual output from the tool execution. It can be simple text or structured content including images and formatted text.
is_error: Option<bool>Whether this tool result represents an error.
When true, indicates that the tool execution failed and the content contains error information rather than successful output.
Implementations§
Source§impl ToolResultBlock
impl ToolResultBlock
Sourcepub fn new(tool_use_id: String) -> ToolResultBlock
pub fn new(tool_use_id: String) -> ToolResultBlock
Create a new ToolResultBlock with the given tool use ID.
Sourcepub fn with_cache_control(
self,
cache_control: CacheControlEphemeral,
) -> ToolResultBlock
pub fn with_cache_control( self, cache_control: CacheControlEphemeral, ) -> ToolResultBlock
Add a cache control to this tool result block.
Sourcepub fn with_string_content(self, content: String) -> ToolResultBlock
pub fn with_string_content(self, content: String) -> ToolResultBlock
Add string content to this tool result block.
Sourcepub fn with_array_content(self, content: Vec<Content>) -> ToolResultBlock
pub fn with_array_content(self, content: Vec<Content>) -> ToolResultBlock
Add array content to this tool result block.
Sourcepub fn with_text_content(self, text: TextBlock) -> ToolResultBlock
pub fn with_text_content(self, text: TextBlock) -> ToolResultBlock
Add a single text content item to this tool result block.
Sourcepub fn with_error(self, is_error: bool) -> ToolResultBlock
pub fn with_error(self, is_error: bool) -> ToolResultBlock
Set this tool result block as an error.
Trait Implementations§
Source§impl Clone for ToolResultBlock
impl Clone for ToolResultBlock
Source§fn clone(&self) -> ToolResultBlock
fn clone(&self) -> ToolResultBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolResultBlock
impl Debug for ToolResultBlock
Source§impl<'de> Deserialize<'de> for ToolResultBlock
impl<'de> Deserialize<'de> for ToolResultBlock
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolResultBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolResultBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<ToolResultBlock> for ContentBlock
impl From<ToolResultBlock> for ContentBlock
Source§fn from(block: ToolResultBlock) -> ContentBlock
fn from(block: ToolResultBlock) -> ContentBlock
Source§impl PartialEq for ToolResultBlock
impl PartialEq for ToolResultBlock
Source§impl Serialize for ToolResultBlock
impl Serialize for ToolResultBlock
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ToolResultBlock
Auto Trait Implementations§
impl Freeze for ToolResultBlock
impl RefUnwindSafe for ToolResultBlock
impl Send for ToolResultBlock
impl Sync for ToolResultBlock
impl Unpin for ToolResultBlock
impl UnsafeUnpin for ToolResultBlock
impl UnwindSafe for ToolResultBlock
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request