pub enum Content {
Text {
text: String,
},
Image {
data: String,
mime_type: String,
},
Resource {
uri: String,
text: Option<String>,
mime_type: Option<String>,
meta: Option<Map<String, Value>>,
},
Audio {
data: String,
mime_type: String,
annotations: Option<Annotations>,
meta: Option<Map<String, Value>>,
},
ResourceLink(Box<ResourceLinkContent>),
}Expand description
Content item in responses.
Variants§
Text
Text content
Image
Image content
Resource
Resource reference
Fields
Audio
Audio content (MCP 2025-11-25)
Fields
§
annotations: Option<Annotations>Optional content annotations
ResourceLink(Box<ResourceLinkContent>)
Resource link content (MCP 2025-11-25).
Boxed to avoid inflating the Content enum size — ResourceLink has ~264 bytes
of fields while Text has ~24 bytes.
Implementations§
Source§impl Content
impl Content
Sourcepub fn text(text: impl Into<String>) -> Self
pub fn text(text: impl Into<String>) -> Self
Create text content.
use pmcp::types::Content;
let c = Content::text("Hello, world!");Sourcepub fn image(data: impl Into<String>, mime_type: impl Into<String>) -> Self
pub fn image(data: impl Into<String>, mime_type: impl Into<String>) -> Self
Create image content from base64-encoded data.
use pmcp::types::Content;
let c = Content::image("iVBORw0KGgo=", "image/png");Sourcepub fn resource(uri: impl Into<String>) -> Self
pub fn resource(uri: impl Into<String>) -> Self
Create a minimal resource reference (URI only).
Use Content::resource_with_text when you have content to include.
Sourcepub fn resource_with_text(
uri: impl Into<String>,
text: impl Into<String>,
mime_type: impl Into<String>,
) -> Self
pub fn resource_with_text( uri: impl Into<String>, text: impl Into<String>, mime_type: impl Into<String>, ) -> Self
Create a resource reference with text content and MIME type.
use pmcp::types::Content;
let c = Content::resource_with_text("file://test.txt", "hello", "text/plain");Sourcepub fn audio(data: impl Into<String>, mime_type: impl Into<String>) -> Self
pub fn audio(data: impl Into<String>, mime_type: impl Into<String>) -> Self
Create audio content from base64-encoded data.
use pmcp::types::Content;
let c = Content::audio("base64data==", "audio/wav");Sourcepub fn resource_link(name: impl Into<String>, uri: impl Into<String>) -> Self
pub fn resource_link(name: impl Into<String>, uri: impl Into<String>) -> Self
Create a resource link.
Delegates to ResourceLinkContent::new and wraps in a Box.
use pmcp::types::Content;
let c = Content::resource_link("my-file", "file:///path/to/file.txt");Trait Implementations§
Source§impl<'de> Deserialize<'de> for Content
impl<'de> Deserialize<'de> for Content
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
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