pub trait SamplingClient: Send + Sync {
// Required method
fn create_message<'life0, 'async_trait>(
&'life0 self,
params: CreateMessageRequestParams,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult, SamplingError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Trait abstracting the sampling/createMessage RPC. The production
impl wraps Arc<Peer<RoleServer>>; the test impl is
[super::super::test_support::fake_mcp_client::FakeMcpClient].
Separating the trait from the concrete Peer<RoleServer> is the
way around rmcp’s Peer having private constructors — we can’t
build a fake Peer for tests, so we inject behind a trait.
Required Methods§
fn create_message<'life0, 'async_trait>(
&'life0 self,
params: CreateMessageRequestParams,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult, SamplingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".