pub struct PendingServerRequest {
pub request: ServerRequest,
/* private fields */
}Expand description
A server->client request the app-server sent us (approvals, elicitation,
etc.), paired with a one-shot reply channel. Obtain these from
EventStream::recv as an Event::Request.
Every PendingServerRequest gets exactly one reply, no matter what
happens to it: call Self::respond or Self::respond_error to send
your own, or just let it drop - deliberately, via cancellation, or via a
panic unwinding through it - and its Drop impl sends a generic
fallback error on your behalf. The app-server is never left permanently
unanswered either way. Prefer responding explicitly and promptly when you
can; the fallback exists so a bug, an unhandled case, or a task
abandoning this value doesn’t turn into a silent hang.
Fields§
§request: ServerRequestImplementations§
Source§impl PendingServerRequest
impl PendingServerRequest
Sourcepub fn method_name(&self) -> &'static str
pub fn method_name(&self) -> &'static str
The wire method name, e.g. "execCommandApproval".
Sourcepub fn expected_response_type_name(&self) -> &'static str
pub fn expected_response_type_name(&self) -> &'static str
The name of the crate::protocol type Self::respond’s result
must serialize to for this specific request, e.g.
"ExecCommandApprovalResponse". Prefer this over guessing from
Self::method_name - the naming convention (PascalCase(method) + "Response") doesn’t hold for every method (e.g.
"item/tool/call" expects DynamicToolCallResponse, not
ItemToolCallResponse).
Sourcepub fn reply_deadline(&self) -> Instant
pub fn reply_deadline(&self) -> Instant
Absolute deadline after which the internal forwarding task no longer accepts a reply for this request.
Sourcepub fn respond(self, result: impl Serialize) -> Result<()>
pub fn respond(self, result: impl Serialize) -> Result<()>
Send a successful reply. result must serialize to the response
shape the app-server expects for this specific method - see
Self::expected_response_type_name for exactly which
crate::protocol type that is. Err only means result failed to
serialize or the forwarding task already stopped accepting replies.