[−][src]Enum jrpc::IdReq
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.
A null id
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]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for IdReq
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,