Trait serde::de::IntoDeserializer
source · pub trait IntoDeserializer<'de, E: Error = Error> {
type Deserializer: Deserializer<'de, Error = E>;
// Required method
fn into_deserializer(self) -> Self::Deserializer;
}
Expand description
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 std::str::FromStr;
use serde::Deserialize;
use serde::de::{value, IntoDeserializer};
#[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())
}
}
Required Associated Types§
sourcetype Deserializer: Deserializer<'de, Error = E>
type Deserializer: Deserializer<'de, Error = E>
The type of the deserializer being converted into.
Required Methods§
sourcefn into_deserializer(self) -> Self::Deserializer
fn into_deserializer(self) -> Self::Deserializer
Convert this value into a deserializer.