JsonRpc

Enum JsonRpc 

Source
pub enum JsonRpc<N, R> {
    Request(Value, R),
    Notification(N),
}

Variants§

§

Request(Value, R)

§

Notification(N)

Trait Implementations§

Source§

impl<N: Debug, R: Debug> Debug for JsonRpc<N, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, N, R> Deserialize<'de> for JsonRpc<N, R>
where N: Deserialize<'de> + Debug, R: Deserialize<'de> + Debug,

This function disentangles the various cases:

  1. If we have an id then it is a request

  2. Otherwise it’s a notification that doesn’t require a response.

Furthermore we distinguish between the built-in types and the custom user notifications/methods:

  1. We either match a built-in type above,

  2. Or it’s a custom one, so we pass it around just as a serde_json::Value

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<N, R> Serialize for JsonRpc<N, R>
where N: Serialize + Debug, R: Serialize + Debug,

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<N, R> Freeze for JsonRpc<N, R>
where R: Freeze, N: Freeze,

§

impl<N, R> RefUnwindSafe for JsonRpc<N, R>

§

impl<N, R> Send for JsonRpc<N, R>
where R: Send, N: Send,

§

impl<N, R> Sync for JsonRpc<N, R>
where R: Sync, N: Sync,

§

impl<N, R> Unpin for JsonRpc<N, R>
where R: Unpin, N: Unpin,

§

impl<N, R> UnwindSafe for JsonRpc<N, R>
where R: UnwindSafe, N: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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