#[non_exhaustive]pub struct SamplingMessage {
pub role: String,
pub content: SamplingContent,
}Expand description
One message in a SamplingRequest::messages history. The MCP
spec defines role as the free-form string "user" or
"assistant"; richer typing is intentionally deferred to the
transport boundary.
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: StringSpeaker role. Wire values: "user" or "assistant".
content: SamplingContentMessage payload. Only SamplingContent::Text is supported
in this cluster; see the module-level note on unsupported
content variants.
Implementations§
Source§impl SamplingMessage
impl SamplingMessage
Sourcepub fn new(role: impl Into<String>, content: SamplingContent) -> Self
pub fn new(role: impl Into<String>, content: SamplingContent) -> Self
Constructs a new SamplingMessage with the given role and content.
Required for external callers after #[non_exhaustive] prevents
struct-literal construction outside the crate.
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<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 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