pub enum Content {
Text(TextContent),
Image(ImageContent),
Audio(AudioContent),
ResourceLink(ResourceLink),
Resource(EmbeddedResource),
}Expand description
Content block in MCP messages (ContentBlock per spec).
Used in CallToolResult.content and PromptMessage.content.
Per MCP 2025-11-25, the union is:
TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource
Variants§
Text(TextContent)
Text content
Image(ImageContent)
Image content (base64 encoded)
Audio(AudioContent)
Audio content (base64 encoded)
ResourceLink(ResourceLink)
Resource link (reference to a resource without embedding)
Resource(EmbeddedResource)
Embedded resource content
Implementations§
Source§impl Content
impl Content
Sourcepub fn image(data: impl Into<String>, mime_type: impl Into<String>) -> Content
pub fn image(data: impl Into<String>, mime_type: impl Into<String>) -> Content
Create image content from base64 data.
Sourcepub fn audio(data: impl Into<String>, mime_type: impl Into<String>) -> Content
pub fn audio(data: impl Into<String>, mime_type: impl Into<String>) -> Content
Create audio content from base64 data.
Sourcepub fn resource_link(resource: Resource) -> Content
pub fn resource_link(resource: Resource) -> Content
Create a resource link.
Sourcepub fn resource(uri: impl Into<String>, text: impl Into<String>) -> Content
pub fn resource(uri: impl Into<String>, text: impl Into<String>) -> Content
Create embedded resource content.
Sourcepub fn is_resource_link(&self) -> bool
pub fn is_resource_link(&self) -> bool
Check if this is a resource link.
Sourcepub fn is_resource(&self) -> bool
pub fn is_resource(&self) -> bool
Check if this is resource content.
Sourcepub fn with_annotations(self, annotations: Annotations) -> Content
pub fn with_annotations(self, annotations: Annotations) -> Content
Add annotations to this content.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Content
impl<'de> Deserialize<'de> for Content
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Content, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Content, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl IntoToolResponse for Content
impl IntoToolResponse for Content
Source§fn into_tool_response(self) -> CallToolResult
fn into_tool_response(self) -> CallToolResult
Convert this type into a
CallToolResultSource§impl Serialize for Content
impl Serialize for Content
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,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Content
Auto Trait Implementations§
impl Freeze for Content
impl RefUnwindSafe for Content
impl Send for Content
impl Sync for Content
impl Unpin for Content
impl UnsafeUnpin for Content
impl UnwindSafe for Content
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