Trait ToJson

Source
pub trait ToJson {
Show 16 methods // Provided methods fn try_to_json_value(&self) -> Result<JsonValue> where Self: Serialize { ... } fn try_from_json_value(value: JsonValue) -> Result<Self> where Self: DeserializeOwned { ... } fn to_json_value(&self) -> JsonValue where Self: Serialize { ... } fn from_json_value(value: JsonValue) -> Self where Self: DeserializeOwned { ... } fn try_to_json(&self) -> Result<String> where Self: Serialize { ... } fn try_to_json_into(&self, writer: impl Write) -> Result<()> where Self: Serialize { ... } fn try_from_json(json: impl AsBytes) -> Result<Self> where Self: DeserializeOwned { ... } fn try_from_json_from(reader: impl Read) -> Result<Self> where Self: DeserializeOwned { ... } fn to_json(&self) -> String where Self: Serialize { ... } fn to_json_into(&self, writer: impl Write) where Self: Serialize { ... } fn from_json(json: impl AsBytes) -> Self where Self: DeserializeOwned { ... } fn from_json_from(reader: impl Read) -> Self where Self: DeserializeOwned { ... } fn try_to_json_pretty(&self) -> Result<String> where Self: Serialize { ... } fn try_to_json_pretty_into(&self, writer: impl Write) -> Result<()> where Self: Serialize { ... } fn to_json_pretty(&self) -> String where Self: Serialize { ... } fn to_json_pretty_into(&self, writer: impl Write) where Self: Serialize { ... }
}
Expand description

§A trait that can de/encode to/from json.

Provided Methods§

Source

fn try_to_json_value(&self) -> Result<JsonValue>
where Self: Serialize,

Source

fn try_from_json_value(value: JsonValue) -> Result<Self>
where Self: DeserializeOwned,

Source

fn to_json_value(&self) -> JsonValue
where Self: Serialize,

Source

fn from_json_value(value: JsonValue) -> Self
where Self: DeserializeOwned,

Source

fn try_to_json(&self) -> Result<String>
where Self: Serialize,

Source

fn try_to_json_into(&self, writer: impl Write) -> Result<()>
where Self: Serialize,

Source

fn try_from_json(json: impl AsBytes) -> Result<Self>
where Self: DeserializeOwned,

Source

fn try_from_json_from(reader: impl Read) -> Result<Self>
where Self: DeserializeOwned,

Source

fn to_json(&self) -> String
where Self: Serialize,

Source

fn to_json_into(&self, writer: impl Write)
where Self: Serialize,

Source

fn from_json(json: impl AsBytes) -> Self
where Self: DeserializeOwned,

Source

fn from_json_from(reader: impl Read) -> Self
where Self: DeserializeOwned,

Source

fn try_to_json_pretty(&self) -> Result<String>
where Self: Serialize,

Source

fn try_to_json_pretty_into(&self, writer: impl Write) -> Result<()>
where Self: Serialize,

Source

fn to_json_pretty(&self) -> String
where Self: Serialize,

Source

fn to_json_pretty_into(&self, writer: impl Write)
where Self: Serialize,

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§