Enum jrpc::Id [] [src]

pub enum Id {
    String(String),
    Int(i64),
    Null,
}

An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null and Numbers SHOULD NOT contain fractional parts

The Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.

Examples

extern crate serde_json;
use jrpc::Id;

assert_eq!(Id::from(4), Id::Int(4));
assert_eq!(
    serde_json::from_str::<Id>("4").unwrap(),
    Id::Int(4),
);
assert_eq!(
    serde_json::from_str::<Id>("\"foo\"").unwrap(),
    Id::String("foo".into()),
);
assert_eq!(
    serde_json::from_str::<Id>("null").unwrap(),
    Id::Null,
);

Variants

An String id

An Number id that must be an integer.

We intentionally do not allow floating point values.

A null id

Trait Implementations

impl Debug for Id
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for Id
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for Id
[src]

impl PartialEq for Id
[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 Hash for Id
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl From<String> for Id
[src]

[src]

Performs the conversion.

impl<'a> From<&'a str> for Id
[src]

[src]

Performs the conversion.

impl From<i64> for Id
[src]

[src]

Performs the conversion.

impl From<Id> for IdReq
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl Send for Id

impl Sync for Id