Enum near_jsonrpc_primitives::message::Message
source · 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.
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.
Implementations§
source§impl Message
impl Message
sourcepub fn request(method: String, params: Value) -> Self
pub fn request(method: String, params: Value) -> Self
A constructor for a request.
The ID is auto-generated.
sourcepub fn notification(method: String, params: Value) -> Self
pub fn notification(method: String, params: Value) -> Self
A constructor for a notification.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more