identity_iota::core

Trait ToJson

Source
pub trait ToJson: Sized + Serialize {
    // 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.

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.

Implementors§

Source§

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