#[non_exhaustive]pub struct McpSamplingMessage {
pub role: Role,
pub content: SamplingContent<SamplingMessageContent>,
pub meta: Option<Meta>,
}Expand description
Re-exports of the rmcp wire-protocol types this crate now surfaces directly instead of wrapping. Pull these in to pattern-match on tool annotations, content blocks, structured tool output, embedded resources, sampling / elicitation requests, progress and log notifications, etc. A message in a sampling conversation, containing a role and content.
This represents a single message in a conversation flow, used primarily in LLM sampling requests where the conversation history is important for generating appropriate responses.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.role: RoleThe role of the message sender (User or Assistant)
content: SamplingContent<SamplingMessageContent>The actual content of the message (text, image, audio, tool use, or tool result)
meta: Option<Meta>Implementations§
Source§impl SamplingMessage
impl SamplingMessage
pub fn new( role: Role, content: impl Into<SamplingMessageContent>, ) -> SamplingMessage
pub fn new_multiple( role: Role, contents: Vec<SamplingMessageContent>, ) -> SamplingMessage
pub fn user_text(text: impl Into<String>) -> SamplingMessage
pub fn assistant_text(text: impl Into<String>) -> SamplingMessage
pub fn user_tool_result( tool_use_id: impl Into<String>, content: Vec<Annotated<RawContent>>, ) -> SamplingMessage
pub fn assistant_tool_use( id: impl Into<String>, name: impl Into<String>, input: Map<String, Value>, ) -> SamplingMessage
Trait Implementations§
Source§impl Clone for SamplingMessage
impl Clone for SamplingMessage
Source§fn clone(&self) -> SamplingMessage
fn clone(&self) -> SamplingMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 SamplingMessage
impl Debug for SamplingMessage
Source§impl<'de> Deserialize<'de> for SamplingMessage
impl<'de> Deserialize<'de> for SamplingMessage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SamplingMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SamplingMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for SamplingMessage
impl PartialEq for SamplingMessage
Source§fn eq(&self, other: &SamplingMessage) -> bool
fn eq(&self, other: &SamplingMessage) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for SamplingMessage
impl Serialize for SamplingMessage
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
impl StructuralPartialEq for SamplingMessage
Auto Trait Implementations§
impl Freeze for SamplingMessage
impl RefUnwindSafe for SamplingMessage
impl Send for SamplingMessage
impl Sync for SamplingMessage
impl Unpin for SamplingMessage
impl UnsafeUnpin for SamplingMessage
impl UnwindSafe for SamplingMessage
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