pub trait ToJson: Serialize + Sized {
    // Provided methods
    fn to_json(&self) -> Result<String, Error> { ... }
    fn to_json_vec(&self) -> Result<Vec<u8>, Error> { ... }
    fn to_json_value(&self) -> Result<Value, Error> { ... }
    fn to_json_pretty(&self) -> Result<String, Error> { ... }
}
Expand description

A convenience-trait for types that can be serialized as JSON.

Provided Methods§

source

fn to_json(&self) -> Result<String, Error>

Serialize self as a string of JSON.

source

fn to_json_vec(&self) -> Result<Vec<u8>, Error>

Serialize self as a JSON byte vector.

source

fn to_json_value(&self) -> Result<Value, Error>

Serialize self as a serde_json::Value.

source

fn to_json_pretty(&self) -> Result<String, Error>

Serialize self as a pretty-printed string of JSON.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> ToJson for T
where T: Serialize,