[][src]Enum jrpc::IdReq

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

String(String)

An String id

Int(i64)

An Number id that must be an integer.

We intentionally do not allow floating point values.

Null

A null id

Notification

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

Methods

impl IdReq[src]

pub fn to_id(self) -> Option<Id>[src]

Attempt to convert to an Id.

Returns None if this Id is a Notification.

Trait Implementations

impl From<Id> for IdReq[src]

impl Clone for IdReq[src]

impl Eq for IdReq[src]

impl PartialEq<IdReq> for IdReq[src]

impl Debug for IdReq[src]

impl Serialize for IdReq[src]

impl<'de> Deserialize<'de> for IdReq[src]

Auto Trait Implementations

impl Send for IdReq

impl Sync for IdReq

impl Unpin for IdReq

impl UnwindSafe for IdReq

impl RefUnwindSafe for IdReq

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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

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