Trait IntoDeserializer

trait IntoDeserializer<'de, E: Error = value::Error>

Converts an existing value into a Deserializer from which other values can be deserialized.

Lifetime

The 'de lifetime of this trait is the lifetime of data that may be borrowed from the resulting Deserializer. See the page Understanding deserializer lifetimes for a more detailed explanation of these lifetimes.

Example

use serde::de::{value, Deserialize, IntoDeserializer};
use serde_derive::Deserialize;
use std::str::FromStr;

#[derive(Deserialize)]
enum Setting {
    On,
    Off,
}

impl FromStr for Setting {
    type Err = value::Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Self::deserialize(s.into_deserializer())
    }
}

Associated Types

type Deserializer: TraitBound { trait_: Path { path: "Deserializer", id: Id(257), args: Some(AngleBracketed { args: [Lifetime("'de")], constraints: [AssocItemConstraint { name: "Error", args: None, binding: Equality(Type(Generic("E"))) }] }) }, generic_params: [], modifier: None }

The type of the deserializer being converted into.

Required Methods

fn into_deserializer(self: Self) -> <Self as >::Deserializer

Convert this value into a deserializer.

Implementors