http_types::convert

Trait DeserializeOwned

Source
pub trait DeserializeOwned: for<'de> Deserialize<'de> { }
Expand description

A data structure that can be deserialized without borrowing any data from the deserializer.

This is primarily useful for trait bounds on functions. For example a from_str function may be able to deserialize a data structure that borrows from the input string, but a from_reader function may only deserialize owned data.

fn from_str<'a, T>(s: &'a str) -> Result<T>
where
    T: Deserialize<'a>;

fn from_reader<R, T>(rdr: R) -> Result<T>
where
    R: Read,
    T: DeserializeOwned;

§Lifetime

The relationship between Deserialize and DeserializeOwned in trait bounds is explained in more detail on the page Understanding deserializer lifetimes.

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,