pub enum Content {
Text {
text: String,
_meta: Option<Meta>,
},
Image {
data: String,
mime_type: String,
_meta: Option<Meta>,
},
Resource {
resource: String,
text: Option<String>,
_meta: Option<Meta>,
},
}Expand description
Content types for tool responses
Variants§
Implementations§
Source§impl Content
impl Content
pub fn text(text: impl Into<String>) -> Self
pub fn image(data: impl Into<String>, mime_type: impl Into<String>) -> Self
pub fn resource(resource: impl Into<String>, text: Option<String>) -> Self
Sourcepub fn ui_html(uri: impl Into<String>, html: impl Into<String>) -> Self
pub fn ui_html(uri: impl Into<String>, html: impl Into<String>) -> Self
Create a UI HTML resource content (for MCP Apps Extension / MCP-UI)
This helper simplifies creating HTML UI resources by automatically formatting the resource JSON according to the MCP-UI specification.
§Example
use pulseengine_mcp_protocol::Content;
let html = r#"<html><body><h1>Hello!</h1></body></html>"#;
let content = Content::ui_html("ui://greetings/interactive", html);This is equivalent to but much more concise than:
ⓘ
let resource_json = serde_json::json!({
"uri": "ui://greetings/interactive",
"mimeType": "text/html",
"text": html
});
Content::Resource {
resource: resource_json.to_string(),
text: None,
_meta: None,
}Sourcepub fn ui_resource(
uri: impl Into<String>,
mime_type: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn ui_resource( uri: impl Into<String>, mime_type: impl Into<String>, content: impl Into<String>, ) -> Self
Create a UI resource content with custom MIME type (for MCP Apps Extension / MCP-UI)
This helper allows you to create UI resources with any MIME type and content.
§Example
use pulseengine_mcp_protocol::Content;
let json_data = r#"{"message": "Hello, World!"}"#;
let content = Content::ui_resource(
"ui://data/greeting",
"application/json",
json_data
);Source§impl Content
impl Content
Sourcepub fn as_text_content(&self) -> Option<TextContent>
pub fn as_text_content(&self) -> Option<TextContent>
Get text content as TextContent struct for compatibility
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 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