pub trait JsonRpcSerializer {
type Value: Clone;
// Required methods
fn null() -> Self::Value;
fn string(value: &str) -> Self::Value;
fn number(value: i64) -> Self::Value;
fn object(entries: Vec<(&'static str, Self::Value)>) -> Self::Value;
fn to_compact_string(value: &Self::Value) -> String;
}Expand description
Abstraction over a JSON serializer so the JSON-RPC envelope builders do not depend on a concrete JSON value type.
The caller binds this to its own JSON value type. The envelope builders only
require constructing nulls, strings, integer numbers, and objects, plus
compact serialization. Object key ordering in the emitted bytes is entirely
determined by the implementor’s object and
to_compact_string.
Required Associated Types§
Required Methods§
Sourcefn object(entries: Vec<(&'static str, Self::Value)>) -> Self::Value
fn object(entries: Vec<(&'static str, Self::Value)>) -> Self::Value
A JSON object built from the given key/value entries, in order.
Sourcefn to_compact_string(value: &Self::Value) -> String
fn to_compact_string(value: &Self::Value) -> String
Serialize a value to a compact (whitespace-free) JSON string.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".