pub enum ContentBlock {
Text {
text: String,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
Image {
data: String,
mime_type: String,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
Audio {
data: String,
mime_type: String,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
ResourceLink {
resource: ResourceReference,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
Resource {
resource: ResourceContents,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
}
Expand description
Content block union type matching MCP 2025-06-18 specification exactly
Variants§
Text
Text content
Image
Image content
Fields
§
annotations: Option<Annotations>
Audio
Audio content
Fields
§
annotations: Option<Annotations>
ResourceLink
Resource link (ResourceLink from MCP spec)
Resource
Embedded resource (EmbeddedResource from MCP spec)
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn text(text: impl Into<String>) -> ContentBlock
pub fn text(text: impl Into<String>) -> ContentBlock
Create text content
Sourcepub fn text_with_annotations(
text: impl Into<String>,
annotations: Annotations,
) -> ContentBlock
pub fn text_with_annotations( text: impl Into<String>, annotations: Annotations, ) -> ContentBlock
Create text content with annotations
Sourcepub fn image(
data: impl Into<String>,
mime_type: impl Into<String>,
) -> ContentBlock
pub fn image( data: impl Into<String>, mime_type: impl Into<String>, ) -> ContentBlock
Create image content
Sourcepub fn audio(
data: impl Into<String>,
mime_type: impl Into<String>,
) -> ContentBlock
pub fn audio( data: impl Into<String>, mime_type: impl Into<String>, ) -> ContentBlock
Create audio content
Sourcepub fn resource_link(resource: ResourceReference) -> ContentBlock
pub fn resource_link(resource: ResourceReference) -> ContentBlock
Create resource link
Sourcepub fn resource(resource: ResourceContents) -> ContentBlock
pub fn resource(resource: ResourceContents) -> ContentBlock
Create embedded resource
Sourcepub fn with_annotations(self, annotations: Annotations) -> ContentBlock
pub fn with_annotations(self, annotations: Annotations) -> ContentBlock
Add annotations to any content block
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<ContentBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContentBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ContentBlock
impl Serialize for ContentBlock
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
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