#[non_exhaustive]pub enum SamplingContent {
Text {
text: String,
annotations: Option<ContentAnnotations>,
meta: Option<Value>,
},
Image {
data: String,
mime_type: String,
annotations: Option<ContentAnnotations>,
meta: Option<Value>,
},
Audio {
data: String,
mime_type: String,
annotations: Option<ContentAnnotations>,
meta: Option<Value>,
},
ToolUse {
id: String,
name: String,
input: Value,
meta: Option<Value>,
},
ToolResult {
tool_use_id: String,
content: Vec<SamplingContent>,
structured_content: Option<Value>,
is_error: Option<bool>,
meta: Option<Value>,
},
}Expand description
Content types for sampling messages
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Text
Text content
Fields
§
annotations: Option<ContentAnnotations>Optional annotations for this content
Image
Image content
Fields
§
annotations: Option<ContentAnnotations>Optional annotations for this content
Audio
Audio content (if supported)
Fields
§
annotations: Option<ContentAnnotations>Optional annotations for this content
ToolUse
Tool use request from the model (SEP-1577)
Fields
ToolResult
Result of a tool invocation (SEP-1577)
Fields
§
content: Vec<SamplingContent>The tool result content
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_types::protocol::SamplingContent;
let text_content = SamplingContent::Text { text: "Hello".into(), annotations: None, meta: None };
assert_eq!(text_content.as_text(), Some("Hello"));
let image_content = SamplingContent::Image {
data: "base64...".into(),
mime_type: "image/png".into(),
annotations: None,
meta: None,
};
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<SamplingContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SamplingContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for SamplingContent
impl Serialize for SamplingContent
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 SamplingContent
impl RefUnwindSafe for SamplingContent
impl Send for SamplingContent
impl Sync for SamplingContent
impl Unpin for SamplingContent
impl UnsafeUnpin 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