pub trait JsonRpcMessage:
'static
+ Debug
+ Sized
+ Send
+ Clone {
// Required methods
fn matches_method(method: &str) -> bool;
fn method(&self) -> &str;
fn to_untyped_message(&self) -> Result<UntypedMessage, Error>;
fn parse_message(
method: &str,
params: &impl Serialize,
) -> Result<Self, Error>;
}Expand description
Common bounds for any JSON-RPC message.
§Derive Macro
For simple message types, you can use the JsonRpcRequest or JsonRpcNotification derive macros
which will implement both JsonRpcMessage and the respective trait. See JsonRpcRequest and
JsonRpcNotification for examples.
Required Methods§
Sourcefn matches_method(method: &str) -> bool
fn matches_method(method: &str) -> bool
Check if this message type matches the given method name.
Sourcefn to_untyped_message(&self) -> Result<UntypedMessage, Error>
fn to_untyped_message(&self) -> Result<UntypedMessage, Error>
Convert this message into an untyped message.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.