pub trait DeserializeWith<F>: Sizedwhere
F: Format,{
// Required method
fn deserialize_with(body: ResponseBody) -> Result<Self, Error>;
}Expand description
A trait used to describe a type that can be deserialized using the specified Format.
This trait defines the deserialize_with method, which takes a ResponseBody and returns the deserialized value.
The F type parameter allows for different implementations of the deserialize_with method based on the specific Format marker type used.
Defining our own trait allows us to implement it on foreign types and better customize deserialization for different scenarios.
§Notes
This trait does not define a default implementation using Format::deserialize;
otherwise, NoFormat would inadvertently implement Response::into_body for non-deserializable types.
Required Methods§
Sourcefn deserialize_with(body: ResponseBody) -> Result<Self, Error>
fn deserialize_with(body: ResponseBody) -> Result<Self, Error>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
json only.Implements DeserializeWith<JsonFormat> for an arbitrary type D
that implements serde::de::DeserializeOwned by deserializing the response body to the specified type using serde_json.
impl<D> DeserializeWith<XmlFormat> for Dwhere
D: DeserializeOwned,
xml only.