pub struct Peer { /* private fields */ }Expand description
The client, as seen from inside a handler.
Version 1 reverses direction for exactly one purpose: the endpoint that discovers a value is missing is never the process that can ask a person for it, and a stdio endpoint has no terminal to ask on. A callback is bounded by the deadline and the cancellation of the request that raised it, so it can neither outlive its caller nor keep an in-flight slot after the caller is gone.
Implementations§
Source§impl Peer
impl Peer
Sourcepub fn detached() -> Self
pub fn detached() -> Self
A peer that is not attached to a session: it advertises nothing, so
Self::supports is always false and no callback is ever attempted.
This is what a handler exercised outside a live transport sees, and it is the same answer a real session gives for a client that advertised no callbacks, so a test never accidentally proves behavior a headless consumer would not get.
Sourcepub fn supports(&self, method: &str) -> bool
pub fn supports(&self, method: &str) -> bool
Whether the client advertised one callback method. A handler MUST check this rather than calling and handling the failure: a client that cannot reach a person wants to be told so immediately, not after a deadline.
Sourcepub async fn call<P: Serialize, R: DeserializeOwned>(
&self,
method: &str,
params: &P,
context: &RequestContext,
) -> RpcResult<R>
pub async fn call<P: Serialize, R: DeserializeOwned>( &self, method: &str, params: &P, context: &RequestContext, ) -> RpcResult<R>
Call one advertised method on the client and await its response.
The deadline and cancellation come from the request being served, so an abandoned caller takes its callback down with it and no answer can arrive for a request that is already terminal.