pub enum SamplingContent {
Text {
text: String,
},
Image {
data: String,
mime_type: String,
},
Audio {
data: String,
mime_type: String,
},
ToolUse {
id: String,
name: String,
input: Value,
},
ToolResult {
tool_use_id: String,
content: Vec<SamplingContent>,
is_error: Option<bool>,
},
}Expand description
Content types for sampling messages
Variants§
Text
Text content
Image
Image content
Audio
Audio content (if supported)
ToolUse
Tool use request from the model (SEP-1577)
Fields
ToolResult
Result of a tool invocation (SEP-1577)
Implementations§
Source§impl SamplingContent
impl SamplingContent
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
Get the text content if this is a text variant.
Returns None if this is an image, audio, tool_use, or tool_result variant.
§Example
use tower_mcp::protocol::SamplingContent;
let text_content = SamplingContent::Text { text: "Hello".into() };
assert_eq!(text_content.as_text(), Some("Hello"));
let image_content = SamplingContent::Image {
data: "base64...".into(),
mime_type: "image/png".into(),
};
assert_eq!(image_content.as_text(), None);Trait Implementations§
Source§impl Clone for SamplingContent
impl Clone for SamplingContent
Source§fn clone(&self) -> SamplingContent
fn clone(&self) -> SamplingContent
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 SamplingContent
impl Debug for SamplingContent
Source§impl<'de> Deserialize<'de> for SamplingContent
impl<'de> Deserialize<'de> for SamplingContent
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 SamplingContent
impl RefUnwindSafe for SamplingContent
impl Send for SamplingContent
impl Sync for SamplingContent
impl Unpin for SamplingContent
impl UnwindSafe for SamplingContent
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