Skip to main content

ControlClient

Trait ControlClient 

Source
pub trait ControlClient {
    // Provided methods
    fn build_request<C: ControlCall>(
        &self,
        id: RequestId,
        call: &C,
    ) -> JsonRpcRequest { ... }
    fn parse_response<C: ControlCall>(
        &self,
        response: JsonRpcResponse,
    ) -> Result<C::Output, ControlError> { ... }
}
Expand description

The client-facing half of the contract: turn typed calls into requests and responses back into typed results.

The default implementations cover every client; a consumer implements this trait only to customise request construction (e.g. attaching the control token in a bespoke way). The blanket DefaultControlClient gives callers the standard behaviour for free.

Provided Methods§

Source

fn build_request<C: ControlCall>( &self, id: RequestId, call: &C, ) -> JsonRpcRequest

Build the request envelope for a typed call with the given request id.

Source

fn parse_response<C: ControlCall>( &self, response: JsonRpcResponse, ) -> Result<C::Output, ControlError>

Parse a response envelope into the typed result for call type C.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§