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
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 Debug for IdReq
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for IdReq
[src]
fn clone(&self) -> IdReq
[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 PartialEq for IdReq
[src]
fn eq(&self, __arg_0: &IdReq) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &IdReq) -> bool
[src]
This method tests for !=
.