pub trait JrMessage:
'static
+ Debug
+ Sized
+ Send
+ Clone {
// Required methods
fn method(&self) -> &str;
fn to_untyped_message(&self) -> Result<UntypedMessage, Error>;
fn parse_message(
method: &str,
params: &impl Serialize,
) -> Option<Result<Self, Error>>;
}Expand description
Common bounds for any JSON-RPC message.
§Derive Macro
For simple message types, you can use the JrRequest or JrNotification derive macros
which will implement both JrMessage and the respective trait. See JrRequest and
JrNotification for examples.
Required Methods§
Sourcefn to_untyped_message(&self) -> Result<UntypedMessage, Error>
fn to_untyped_message(&self) -> Result<UntypedMessage, Error>
Convert this message into an untyped message.
Sourcefn parse_message(
method: &str,
params: &impl Serialize,
) -> Option<Result<Self, Error>>
fn parse_message( method: &str, params: &impl Serialize, ) -> Option<Result<Self, Error>>
Attempt to parse this type from a method name and parameters.
Returns:
Noneif this type does not recognize the method nameSome(Ok(value))if the method is recognized and deserialization succeedsSome(Err(error))if the method is recognized but deserialization fails
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.