[][src]Struct json_rpc_types::Response

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

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

impl<R, E> Response<R, E>[src]

pub const fn result(jsonrpc: Version, result: R, id: Option<Id>) -> Self[src]

Creates successful response.

pub const fn error(jsonrpc: Version, error: Error<E>, id: Option<Id>) -> Self[src]

Creates error response.

Trait Implementations

impl<R: Clone, E: Clone> Clone for Response<R, E>[src]

impl<R: Debug, E: Debug> Debug for Response<R, E>[src]

impl<'de, R: Deserialize<'de>, E: Deserialize<'de>> Deserialize<'de> for Response<R, E>[src]

impl<R: PartialEq, E: PartialEq> PartialEq<Response<R, E>> for Response<R, E>[src]

impl<R: Serialize, E: Serialize> Serialize for Response<R, E>[src]

impl<R, E> StructuralPartialEq for Response<R, E>[src]

Auto Trait Implementations

impl<R, E> RefUnwindSafe for Response<R, E> where
    E: RefUnwindSafe,
    R: RefUnwindSafe

impl<R, E> Send for Response<R, E> where
    E: Send,
    R: Send

impl<R, E> Sync for Response<R, E> where
    E: Sync,
    R: Sync

impl<R, E> Unpin for Response<R, E> where
    E: Unpin,
    R: Unpin

impl<R, E> UnwindSafe for Response<R, E> where
    E: UnwindSafe,
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.