pub enum IdReq {
String(String),
Int(i64),
Null,
Notification,
}Expand description
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.