Enum tokio_jsonrpc::message::Message
[−]
[src]
pub enum Message { Request(Request), Response(Response), Notification(Notification), Batch(Vec<Message>), UnmatchedSub(Value), }
One message of the JSON RPC protocol.
One message, directly mapped from the structures of the protocol. See the specification for more details.
Since the protocol allows one endpoint to be both client and server at the same time, the message can decode and encode both directions of the protocol.
The Batch
variant is supposed to be created directly, without a constructor.
The UnmatchedSub
variant is used when a request is an array and some of the subrequests
aren't recognized as valid json rpc 2.0 messages. This is never returned as a top-level
element, it is returned as Err(Broken::Unmatched)
.
Variants
Request(Request)
An RPC request.
Response(Response)
A response to a Request.
Notification(Notification)
A notification.
Batch(Vec<Message>)
A batch of more requests or responses.
The protocol allows bundling multiple requests, notifications or responses to a single message.
This variant has no direct constructor and is expected to be constructed manually.
UnmatchedSub(Value)
An unmatched sub entry in a Batch
.
When there's a Batch
and an element doesn't comform to the JSONRPC 2.0 format, that one
is represented by this. This is never produced as a top-level value when parsing, the
Err(Broken::Unmatched)
is used instead. It is not possible to serialize.
Methods
impl Message
[src]
fn request(method: String, params: Option<Value>) -> Self
A constructor for a request.
The ID is auto-generated.
fn error(error: RpcError) -> Self
Create a top-level error (without an ID).
fn notification(method: String, params: Option<Value>) -> Self
A constructor for a notification.
Trait Implementations
impl Debug for Message
[src]
impl Clone for Message
[src]
fn clone(&self) -> Message
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Message
[src]
fn eq(&self, __arg_0: &Message) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Message) -> bool
This method tests for !=
.