pub enum ContentBlock {
TextContent(TextContent),
ImageContent(ImageContent),
AudioContent(AudioContent),
ResourceLink(ResourceLink),
EmbeddedResource(EmbeddedResource),
}Expand description
Latest MCP Protocol 2026_07_28 ContentBlock
JSON schema
{
"anyOf": [
{
"$ref": "#/$defs/TextContent"
},
{
"$ref": "#/$defs/ImageContent"
},
{
"$ref": "#/$defs/AudioContent"
},
{
"$ref": "#/$defs/ResourceLink"
},
{
"$ref": "#/$defs/EmbeddedResource"
}
]
}Variants§
TextContent(TextContent)
ImageContent(ImageContent)
AudioContent(AudioContent)
ResourceLink(ResourceLink)
EmbeddedResource(EmbeddedResource)
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn text_content(text: String) -> Self
pub fn text_content(text: String) -> Self
Create a ContentBlock::TextContent
Sourcepub fn image_content(data: String, mime_type: String) -> Self
pub fn image_content(data: String, mime_type: String) -> Self
Create a ContentBlock::ImageContent
Sourcepub fn audio_content(data: String, mime_type: String) -> Self
pub fn audio_content(data: String, mime_type: String) -> Self
Create a ContentBlock::AudioContent
Sourcepub fn resource_link(value: ResourceLink) -> Self
pub fn resource_link(value: ResourceLink) -> Self
Create a ContentBlock::ResourceLink
Sourcepub fn embedded_resource(resource: EmbeddedResourceResource) -> Self
pub fn embedded_resource(resource: EmbeddedResourceResource) -> Self
Create a ContentBlock::EmbeddedResource
Sourcepub fn content_type(&self) -> &str
pub fn content_type(&self) -> &str
Returns the content type as a string based on the variant of ContentBlock
pub fn as_text_content(&self) -> Result<&TextContent, RpcError>
pub fn as_image_content(&self) -> Result<&ImageContent, RpcError>
pub fn as_audio_content(&self) -> Result<&AudioContent, RpcError>
pub fn as_resource_link(&self) -> Result<&ResourceLink, RpcError>
pub fn as_embedded_resource(&self) -> Result<&EmbeddedResource, RpcError>
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 (const: unstable) · 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<AudioContent> for ContentBlock
impl From<AudioContent> for ContentBlock
Source§fn from(value: AudioContent) -> Self
fn from(value: AudioContent) -> Self
Converts to this type from the input type.
Source§impl From<EmbeddedResource> for ContentBlock
impl From<EmbeddedResource> for ContentBlock
Source§fn from(value: EmbeddedResource) -> Self
fn from(value: EmbeddedResource) -> Self
Converts to this type from the input type.
Source§impl From<ImageContent> for ContentBlock
impl From<ImageContent> for ContentBlock
Source§fn from(value: ImageContent) -> Self
fn from(value: ImageContent) -> Self
Converts to this type from the input type.
Source§impl From<ResourceLink> for ContentBlock
impl From<ResourceLink> for ContentBlock
Source§fn from(value: ResourceLink) -> Self
fn from(value: ResourceLink) -> Self
Converts to this type from the input type.
Source§impl From<TextContent> for ContentBlock
impl From<TextContent> for ContentBlock
Source§fn from(value: TextContent) -> Self
fn from(value: TextContent) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ContentBlock
impl RefUnwindSafe for ContentBlock
impl Send for ContentBlock
impl Sync for ContentBlock
impl Unpin for ContentBlock
impl UnsafeUnpin 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