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§
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) -> JsonValuewhere
Self: Serialize,
fn from_json_value(value: JsonValue) -> Selfwhere
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) -> Stringwhere
Self: Serialize,
fn to_json_into(&self, writer: impl Write)where
Self: Serialize,
fn from_json(json: impl AsBytes) -> Selfwhere
Self: DeserializeOwned,
fn from_json_from(reader: impl Read) -> Selfwhere
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) -> Stringwhere
Self: Serialize,
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.