Enum jrpc::Response [] [src]

pub enum Response<T> {
    Ok(Success<T>),
    Err(Error<Value>),
}

The Result is either:

  • a jsonrpc Response (with a result of a specific type)
  • a Error (with an error of type serde_json::Value).

Example

extern crate serde_json;
use jrpc::{Id, Response};

let data: Vec<u32> = vec![1, 2, 3];
let example = Response::success(Id::from(4), data.clone());
let json = r#"
{
    "jsonrpc": "2.0",
    "result": [1,2,3],
    "id": 4
}
"#;
let json = json.replace("\n", "").replace(" ", "");
let result = serde_json::to_string(&example).unwrap();
assert_eq!(json, result);

Variants

The Response has a result object and not an error object.

The Response has a error object and not an result object.

Methods

impl<T: Serialize + DeserializeOwned> Response<T>
[src]

[src]

Retrieve the id regardless of whether there was an error or not.

[src]

Construct a Success

[src]

Construct an Error

[src]

Helper to serialize the Response as json.

[src]

Helper to deserialize the Response from json.

Trait Implementations

impl<T: Debug> Debug for Response<T>
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T> Send for Response<T> where
    T: Send

impl<T> Sync for Response<T> where
    T: Sync