pub enum Content {
Show 25 variants
Text(TextContent),
TextReasoning(TextReasoningContent),
Data(DataContent),
Uri(UriContent),
Error(ErrorContent),
FunctionCall(FunctionCallContent),
FunctionResult(FunctionResultContent),
Usage(UsageContent),
HostedFile(HostedFileContent),
HostedVectorStore(HostedVectorStoreContent),
CodeInterpreterToolCall(CodeInterpreterToolCallContent),
CodeInterpreterToolResult(CodeInterpreterToolResultContent),
ImageGenerationToolCall(ImageGenerationToolCallContent),
ImageGenerationToolResult(ImageGenerationToolResultContent),
McpServerToolCall(McpServerToolCallContent),
McpServerToolResult(McpServerToolResultContent),
SearchToolCall(SearchToolCallContent),
SearchToolResult(SearchToolResultContent),
ShellToolCall(ShellToolCallContent),
ShellToolResult(ShellToolResultContent),
ShellCommandOutput(ShellCommandOutputContent),
FunctionApprovalRequest(FunctionApprovalRequestContent),
FunctionApprovalResponse(FunctionApprovalResponseContent),
OauthConsentRequest(OauthConsentRequestContent),
Unknown,
}Expand description
The unified content union, discriminated by the type tag.
This is the Rust equivalent of the Python Contents union.
The Content::Unknown variant makes deserialization forward-compatible:
a content item whose type tag is not one of the known variants
deserializes to Unknown rather than failing the whole message. This
mirrors Python’s parse-and-skip behavior for unknown content
(_types.py:2205-2210), except the item is retained as an inert
placeholder instead of being dropped. Unknown carries no data, so it
re-serializes as {"type":"unknown"} (the original tag/fields are not
preserved) and is treated as inert everywhere: it yields no text, no
function call, and is ignored by aggregation/coalescing.
Variants§
Text(TextContent)
TextReasoning(TextReasoningContent)
Data(DataContent)
Uri(UriContent)
Error(ErrorContent)
FunctionCall(FunctionCallContent)
FunctionResult(FunctionResultContent)
Usage(UsageContent)
HostedFile(HostedFileContent)
HostedVectorStore(HostedVectorStoreContent)
CodeInterpreterToolCall(CodeInterpreterToolCallContent)
CodeInterpreterToolResult(CodeInterpreterToolResultContent)
ImageGenerationToolCall(ImageGenerationToolCallContent)
ImageGenerationToolResult(ImageGenerationToolResultContent)
McpServerToolCall(McpServerToolCallContent)
McpServerToolResult(McpServerToolResultContent)
SearchToolCall(SearchToolCallContent)
SearchToolResult(SearchToolResultContent)
ShellToolCall(ShellToolCallContent)
ShellToolResult(ShellToolResultContent)
ShellCommandOutput(ShellCommandOutputContent)
FunctionApprovalRequest(FunctionApprovalRequestContent)
FunctionApprovalResponse(FunctionApprovalResponseContent)
OauthConsentRequest(OauthConsentRequestContent)
Unknown
A content item whose type tag is unknown to this version of the
library. Deserialization falls back to this inert variant instead of
erroring; see the type-level docs.
Implementations§
Source§impl Content
impl Content
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
The text of this item, if it is text or reasoning content.
Sourcepub fn as_function_call(&self) -> Option<&FunctionCallContent>
pub fn as_function_call(&self) -> Option<&FunctionCallContent>
The function call carried by this item, if any.
Sourcepub fn as_function_result(&self) -> Option<&FunctionResultContent>
pub fn as_function_result(&self) -> Option<&FunctionResultContent>
The function result carried by this item, if any.
Sourcepub fn as_function_approval_request(
&self,
) -> Option<&FunctionApprovalRequestContent>
pub fn as_function_approval_request( &self, ) -> Option<&FunctionApprovalRequestContent>
The function-approval request carried by this item, if any.
Sourcepub fn as_function_approval_response(
&self,
) -> Option<&FunctionApprovalResponseContent>
pub fn as_function_approval_response( &self, ) -> Option<&FunctionApprovalResponseContent>
The function-approval response carried by this item, if any.