#[non_exhaustive]pub enum ContentBlock {
CachePoint(CachePointBlock),
CitationsContent(CitationsContentBlock),
Document(DocumentBlock),
GuardContent(GuardrailConverseContentBlock),
Image(ImageBlock),
ReasoningContent(ReasoningContentBlock),
Text(String),
ToolResult(ToolResultBlock),
ToolUse(ToolUseBlock),
Video(VideoBlock),
#[non_exhaustive]
Unknown,
}
Expand description
A block of content for a message that you pass to, or receive from, a model with the Converse or ConverseStream API operations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
CachePoint(CachePointBlock)
CachePoint to include in the message.
CitationsContent(CitationsContentBlock)
A content block that contains both generated text and associated citation information, providing traceability between the response and source documents.
Document(DocumentBlock)
A document to include in the message.
GuardContent(GuardrailConverseContentBlock)
Contains the content to assess with the guardrail. If you don't specify guardContent
in a call to the Converse API, the guardrail (if passed in the Converse API) assesses the entire message.
For more information, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide.
Image(ImageBlock)
Image to include in the message.
This field is only supported by Anthropic Claude 3 models.
ReasoningContent(ReasoningContentBlock)
Contains content regarding the reasoning that is carried out by the model. Reasoning refers to a Chain of Thought (CoT) that the model generates to enhance the accuracy of its final response.
Text(String)
Text to include in the message.
ToolResult(ToolResultBlock)
The result for a tool request that a model makes.
ToolUse(ToolUseBlock)
Information about a tool use request from a model.
Video(VideoBlock)
Video to include in the message.
Unknown
The Unknown
variant represents cases where new union variant was received. Consider upgrading the SDK to the latest available version.
An unknown enum variant
Note: If you encounter this error, consider upgrading your SDK to the latest version.
The Unknown
variant represents cases where the server sent a value that wasn’t recognized
by the client. This can happen when the server adds new functionality, but the client has not been updated.
To investigate this, consider turning on debug logging to print the raw HTTP response.
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn as_cache_point(&self) -> Result<&CachePointBlock, &Self>
pub fn as_cache_point(&self) -> Result<&CachePointBlock, &Self>
Tries to convert the enum instance into CachePoint
, extracting the inner CachePointBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn is_cache_point(&self) -> bool
pub fn is_cache_point(&self) -> bool
Returns true if this is a CachePoint
.
Sourcepub fn as_citations_content(&self) -> Result<&CitationsContentBlock, &Self>
pub fn as_citations_content(&self) -> Result<&CitationsContentBlock, &Self>
Tries to convert the enum instance into CitationsContent
, extracting the inner CitationsContentBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn is_citations_content(&self) -> bool
pub fn is_citations_content(&self) -> bool
Returns true if this is a CitationsContent
.
Sourcepub fn as_document(&self) -> Result<&DocumentBlock, &Self>
pub fn as_document(&self) -> Result<&DocumentBlock, &Self>
Tries to convert the enum instance into Document
, extracting the inner DocumentBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn is_document(&self) -> bool
pub fn is_document(&self) -> bool
Returns true if this is a Document
.
Sourcepub fn as_guard_content(&self) -> Result<&GuardrailConverseContentBlock, &Self>
pub fn as_guard_content(&self) -> Result<&GuardrailConverseContentBlock, &Self>
Tries to convert the enum instance into GuardContent
, extracting the inner GuardrailConverseContentBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn is_guard_content(&self) -> bool
pub fn is_guard_content(&self) -> bool
Returns true if this is a GuardContent
.
Sourcepub fn as_image(&self) -> Result<&ImageBlock, &Self>
pub fn as_image(&self) -> Result<&ImageBlock, &Self>
Tries to convert the enum instance into Image
, extracting the inner ImageBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn as_reasoning_content(&self) -> Result<&ReasoningContentBlock, &Self>
pub fn as_reasoning_content(&self) -> Result<&ReasoningContentBlock, &Self>
Tries to convert the enum instance into ReasoningContent
, extracting the inner ReasoningContentBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn is_reasoning_content(&self) -> bool
pub fn is_reasoning_content(&self) -> bool
Returns true if this is a ReasoningContent
.
Sourcepub fn as_tool_result(&self) -> Result<&ToolResultBlock, &Self>
pub fn as_tool_result(&self) -> Result<&ToolResultBlock, &Self>
Tries to convert the enum instance into ToolResult
, extracting the inner ToolResultBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn is_tool_result(&self) -> bool
pub fn is_tool_result(&self) -> bool
Returns true if this is a ToolResult
.
Sourcepub fn as_tool_use(&self) -> Result<&ToolUseBlock, &Self>
pub fn as_tool_use(&self) -> Result<&ToolUseBlock, &Self>
Tries to convert the enum instance into ToolUse
, extracting the inner ToolUseBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn is_tool_use(&self) -> bool
pub fn is_tool_use(&self) -> bool
Returns true if this is a ToolUse
.
Sourcepub fn as_video(&self) -> Result<&VideoBlock, &Self>
pub fn as_video(&self) -> Result<&VideoBlock, &Self>
Tries to convert the enum instance into Video
, extracting the inner VideoBlock
.
Returns Err(&Self)
if it can’t be converted.
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Returns true if the enum instance is the Unknown
variant.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ContentBlock
impl Debug for ContentBlock
Source§impl PartialEq for ContentBlock
impl PartialEq for ContentBlock
impl StructuralPartialEq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);