pub struct RequestSender { /* private fields */ }Expand description
Sends server-to-client requests through the transport.
This struct provides a way to send requests to the client and await responses.
It works in conjunction with PendingRequests to track in-flight requests.
Implementations§
Source§impl RequestSender
impl RequestSender
Sourcepub fn new(pending: Arc<PendingRequests>, send_fn: TransportSendFn) -> Self
pub fn new(pending: Arc<PendingRequests>, send_fn: TransportSendFn) -> Self
Creates an exact MCP 2024-11-05 request sender.
Use Self::new_for_era when the negotiated era is available.
Sourcepub fn new_for_era(
era: ProtocolEra,
pending: Arc<PendingRequests>,
send_fn: TransportSendFn,
) -> Self
pub fn new_for_era( era: ProtocolEra, pending: Arc<PendingRequests>, send_fn: TransportSendFn, ) -> Self
Creates a request sender bound to one negotiated protocol era.
Dropped reverse requests emit notifications/cancelled only for exact
MCP 2024-11-05. MCP 2026-07-28 retains local cleanup but emits no
server cancellation notification.
Sourcepub async fn send_request<T: DeserializeOwned>(
&self,
cx: &Cx,
method: &str,
params: Value,
) -> McpResult<T>
pub async fn send_request<T: DeserializeOwned>( &self, cx: &Cx, method: &str, params: Value, ) -> McpResult<T>
Sends a request to the client and waits for a response.
§Errors
Returns an error if:
- The finite in-flight request limit is reached
- The transport send fails
- The request times out (based on budget)
- The client returns an error response
- The response envelope or typed payload is invalid
- The connection is closed
Trait Implementations§
Source§impl Clone for RequestSender
impl Clone for RequestSender
Source§fn clone(&self) -> RequestSender
fn clone(&self) -> RequestSender
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 moreAuto Trait Implementations§
impl !RefUnwindSafe for RequestSender
impl !UnwindSafe for RequestSender
impl Freeze for RequestSender
impl Send for RequestSender
impl Sync for RequestSender
impl Unpin for RequestSender
impl UnsafeUnpin for RequestSender
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).