JrResponsePayload

Trait JrResponsePayload 

Source
pub trait JrResponsePayload:
    'static
    + Debug
    + Sized
    + Send {
    // Required methods
    fn into_json(self, method: &str) -> Result<Value, Error>;
    fn from_value(method: &str, value: Value) -> Result<Self, Error>;
}
Expand description

Defines the “payload” of a successful response to a JSON-RPC request.

§Derive Macro

Use #[derive(JrResponsePayload)] to automatically implement this trait:

use sacp::JrResponsePayload;
use serde::{Serialize, Deserialize};

#[derive(Debug, Serialize, Deserialize, JrResponsePayload)]
struct HelloResponse {
    greeting: String,
}

Required Methods§

Source

fn into_json(self, method: &str) -> Result<Value, Error>

Convert this message into a JSON value.

Source

fn from_value(method: &str, value: Value) -> Result<Self, Error>

Parse a JSON value into the response type.

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.

Implementations on Foreign Types§

Source§

impl JrResponsePayload for Value

Source§

fn from_value(_method: &str, value: Value) -> Result<Self, Error>

Source§

fn into_json(self, _method: &str) -> Result<Value, Error>

Implementors§