Trait ResponseJsonRpcConvert

Source
pub trait ResponseJsonRpcConvert<Request, Response> {
    // Required methods
    fn from_jsonrpc_message(
        value: JsonRpcMessage,
        original_request: &Request,
    ) -> Result<Option<Response>, ProtocolError>;
    fn into_jsonrpc_message(response: Response, id: Value) -> JsonRpcMessage;
}
Expand description

A response that can convert to and from a JsonRpcResponse or JsonRpcNotification.

Required Methods§

Source

fn from_jsonrpc_message( value: JsonRpcMessage, original_request: &Request, ) -> Result<Option<Response>, ProtocolError>

Deserializes a JsonRpcResponse or JsonRpcNotification into Response. Returns a protocol error if the response conversion fails (i.e. response validation fails, unexpected error, etc.). A reference to the associated request is provided, in case it’s helpful. Returns None if the response type is unknown or unsupported, which is synonymous with a “not found” error.

Source

fn into_jsonrpc_message(response: Response, id: Value) -> JsonRpcMessage

Serializes a Response into a JsonRpcResponse or JsonRpcNotification. Notifications must use the provided id argument as the method value. Returns Value::Null

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§