Struct json_rpc_types::Response[][src]

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

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]

fn clone(&self) -> Response<R, E>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

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

fn deserialize<D: Deserializer<'de>>(der: D) -> Result<Self, D::Error>[src]

Deserialize this value from the given Serde deserializer. Read more

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

fn eq(&self, other: &Response<R, E>) -> bool[src]

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

fn ne(&self, other: &Response<R, E>) -> bool[src]

This method tests for !=.

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

fn serialize<S: Serializer>(&self, ser: S) -> Result<S::Ok, S::Error>[src]

Serialize this value into the given Serde serializer. Read more

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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