pub trait FromJson: Sized + for<'de> Deserialize<'de> {
// Provided methods
fn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self, Error> { ... }
fn from_json_slice(
json: &(impl AsRef<[u8]> + ?Sized),
) -> Result<Self, Error> { ... }
fn from_json_value(json: Value) -> Result<Self, Error> { ... }
}
Expand description
A convenience-trait for types that can be deserialized from JSON.
Provided Methods§
Sourcefn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self, Error>
fn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self, Error>
Deserialize Self
from a string of JSON text.
Sourcefn from_json_slice(json: &(impl AsRef<[u8]> + ?Sized)) -> Result<Self, Error>
fn from_json_slice(json: &(impl AsRef<[u8]> + ?Sized)) -> Result<Self, Error>
Deserialize Self
from bytes of JSON text.
Sourcefn from_json_value(json: Value) -> Result<Self, Error>
fn from_json_value(json: Value) -> Result<Self, Error>
Deserialize Self
from a serde_json::Value
.
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.