Enum jrpc::IdReq [] [src]

pub enum IdReq {
    String(String),
    Int(i64),
    Null,
    Notification,
}

Identical to Id except has the Notification type. Typically you should use Id since all functions that would accept IdReq accept Into<IdReq>.

Notification

A Notification is a Request object without an "id" member. A Request object that is a Notification signifies the Client's lack of interest in the corresponding Response object, and as such no Response object needs to be returned to the client. The Server MUST NOT reply to a Notification, including those that are within a batch request.

Notifications are not confirmable by definition, since they do not have a Response object to be returned. As such, the Client would not be aware of any errors (like e.g. "Invalid params","Internal error").

https://github.com/serde-rs/serde/issues/984

Examples

This just demonstrates what happens if id is absent vs null.

extern crate serde_json;
use jrpc::{Id, IdReq, Request, Value};

// id == null
let json = r#"
{
    "jsonrpc": "2.0",
    "method": "CreateFoo",
    "id": null
}
"#;
let request: Request<String, Value> = serde_json::from_str(json).unwrap();
assert_eq!(request.id, Id::Null.into());

// id does not exist
let json = r#"
{
    "jsonrpc": "2.0",
    "method": "NotifyFoo"
}
"#;
let request: Request<String, Value> = serde_json::from_str(json).unwrap();
assert_eq!(request.id, IdReq::Notification);

Variants

An String id

An Number id that must be an integer.

We intentionally do not allow floating point values.

A null id

The notification id, i.e. the id is absent.

Methods

impl IdReq
[src]

[src]

Attempt to convert to an Id.

Returns None if this Id is a Notification.

Trait Implementations

impl Debug for IdReq
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for IdReq
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for IdReq
[src]

[src]

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

[src]

This method tests for !=.

impl Eq for IdReq
[src]

impl From<Id> for IdReq
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl Send for IdReq

impl Sync for IdReq