pub enum ContentBlock {
Text {
text: String,
citations: Option<Vec<Citation>>,
cache_control: Option<CacheControl>,
},
Image {
source: ImageSource,
},
Document(DocumentBlock),
SearchResult(SearchResultBlock),
ToolUse(ToolUseBlock),
ToolResult(ToolResultBlock),
Thinking(ThinkingBlock),
RedactedThinking {
data: String,
},
ServerToolUse(ServerToolUseBlock),
WebSearchToolResult(WebSearchToolResultBlock),
WebFetchToolResult(WebFetchToolResultBlock),
}Variants§
Text
Image
Fields
§
source: ImageSourceDocument(DocumentBlock)
SearchResult(SearchResultBlock)
ToolUse(ToolUseBlock)
ToolResult(ToolResultBlock)
Thinking(ThinkingBlock)
RedactedThinking
ServerToolUse(ServerToolUseBlock)
WebSearchToolResult(WebSearchToolResultBlock)
WebFetchToolResult(WebFetchToolResultBlock)
Implementations§
Source§impl ContentBlock
impl ContentBlock
pub fn text(text: impl Into<String>) -> Self
pub fn text_cached(text: impl Into<String>) -> Self
pub fn text_with_cache(text: impl Into<String>, cache: CacheControl) -> Self
pub fn text_with_citations( text: impl Into<String>, citations: Vec<Citation>, ) -> Self
pub fn document(doc: DocumentBlock) -> Self
pub fn search_result(result: SearchResultBlock) -> Self
pub fn image(source: ImageSource) -> Self
pub fn image_base64( media_type: impl Into<String>, data: impl Into<String>, ) -> Self
pub fn image_url(url: impl Into<String>) -> Self
pub fn image_file(file_id: impl Into<String>) -> Self
pub async fn image_from_path(path: impl AsRef<Path>) -> Result<Self>
pub fn as_text(&self) -> Option<&str>
pub fn citations(&self) -> Option<&[Citation]>
pub fn has_citations(&self) -> bool
pub fn cache_control(&self) -> Option<&CacheControl>
pub fn is_cached(&self) -> bool
Sourcepub fn set_cache_control(&mut self, cache: Option<CacheControl>)
pub fn set_cache_control(&mut self, cache: Option<CacheControl>)
Set cache control in-place (only for Text blocks).
pub fn with_cache_control(self, cache: CacheControl) -> Self
pub fn without_cache_control(self) -> Self
pub fn as_document(&self) -> Option<&DocumentBlock>
pub fn as_search_result(&self) -> Option<&SearchResultBlock>
pub fn is_document(&self) -> bool
pub fn is_search_result(&self) -> bool
pub fn is_image(&self) -> bool
pub fn as_image(&self) -> Option<&ImageSource>
pub fn as_thinking(&self) -> Option<&ThinkingBlock>
pub fn is_thinking(&self) -> bool
pub fn is_server_tool_use(&self) -> bool
pub fn as_server_tool_use(&self) -> Option<&ServerToolUseBlock>
pub fn is_web_search_result(&self) -> bool
pub fn as_web_search_result(&self) -> Option<&WebSearchToolResultBlock>
pub fn is_web_fetch_result(&self) -> bool
pub fn as_web_fetch_result(&self) -> Option<&WebFetchToolResultBlock>
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
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 ContentBlock
impl Debug for ContentBlock
Source§impl<'de> Deserialize<'de> for ContentBlock
impl<'de> Deserialize<'de> for ContentBlock
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<&str> for ContentBlock
impl From<&str> for ContentBlock
Source§impl From<DocumentBlock> for ContentBlock
impl From<DocumentBlock> for ContentBlock
Source§fn from(doc: DocumentBlock) -> Self
fn from(doc: DocumentBlock) -> Self
Converts to this type from the input type.
Source§impl From<SearchResultBlock> for ContentBlock
impl From<SearchResultBlock> for ContentBlock
Source§fn from(result: SearchResultBlock) -> Self
fn from(result: SearchResultBlock) -> Self
Converts to this type from the input type.
Source§impl From<String> for ContentBlock
impl From<String> for ContentBlock
Auto Trait Implementations§
impl Freeze for ContentBlock
impl RefUnwindSafe for ContentBlock
impl Send for ContentBlock
impl Sync for ContentBlock
impl Unpin for ContentBlock
impl UnwindSafe for ContentBlock
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,
Source§impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
Source§fn deserialize_with(body: ResponseBody) -> Result<D, Error>
fn deserialize_with(body: ResponseBody) -> Result<D, Error>
Deserialize the response body using the specified format. Read more
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>
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.