Enum near_jsonrpc_primitives::message::Message[][src]

pub enum Message {
    Request(Request),
    Response(Response),
    Notification(Notification),
    Batch(Vec<Message>),
    UnmatchedSub(Value),
}
Expand description

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.

Tuple Fields of Request

0: Request
Response(Response)

A response to a Request.

Tuple Fields of Response

0: Response
Notification(Notification)

A notification.

Tuple Fields of Notification

0: 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.

Tuple Fields of Batch

0: Vec<Message>
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.

Tuple Fields of UnmatchedSub

0: Value

Implementations

A constructor for a request.

The ID is auto-generated.

Create a top-level error (without an ID).

A constructor for a notification.

A constructor for a response.

Returns id or Null if there is no id.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more