pub struct Response<R, E> {
    pub jsonrpc: Version,
    pub payload: Result<R, Error<E>>,
    pub id: Option<Id>,
}
Expand description

Response representation.

When omitting id, it shall be serialized as null and means you’re unable to identify id of Request. Note that JSON-RPCv2 specifies that id must be always present, therefore you’re encouraged to treat missing id as error, unless response is error itself, in which case it might be indication that server treats request as invalid (e.g. unable to parse request’s id).

jsonrpc may be omitted during deserialization and defaults to v2.

Type parameters:

  • R - Type of payload for successful response
  • E - Type of optional data for Error.

Fields

jsonrpc: Version

A String specifying the version of the JSON-RPC protocol.

payload: Result<R, Error<E>>

Content of response, depending on whether it is success or failure.

id: Option<Id>

An identifier established by the Client.

If not present, it is sent in response to invalid request (e.g. unable to recognize id).

Must be present always, so None is serialized as null

Implementations

Creates successful response.

Creates error response.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.