mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-24 16:58:00 +00:00
Access traits
This commit is contained in:
+13
-13
@@ -8,7 +8,7 @@
|
||||
|
||||
use lib::*;
|
||||
|
||||
use de::{Deserialize, Deserializer, Visitor, SeqVisitor, MapVisitor, Error};
|
||||
use de::{Deserialize, Deserializer, Visitor, SeqAccess, MapAccess, Error};
|
||||
|
||||
/// An efficient way of discarding data from a deserializer.
|
||||
///
|
||||
@@ -20,7 +20,7 @@ use de::{Deserialize, Deserializer, Visitor, SeqVisitor, MapVisitor, Error};
|
||||
/// use std::fmt;
|
||||
/// use std::marker::PhantomData;
|
||||
///
|
||||
/// use serde::de::{self, Deserialize, DeserializeSeed, Deserializer, Visitor, SeqVisitor, IgnoredAny};
|
||||
/// use serde::de::{self, Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess, IgnoredAny};
|
||||
///
|
||||
/// /// A seed that can be used to deserialize only the `n`th element of a sequence
|
||||
/// /// while efficiently discarding elements of any type before or after index `n`.
|
||||
@@ -53,19 +53,19 @@ use de::{Deserialize, Deserializer, Visitor, SeqVisitor, MapVisitor, Error};
|
||||
/// write!(formatter, "a sequence in which we care about element {}", self.n)
|
||||
/// }
|
||||
///
|
||||
/// fn visit_seq<V>(self, mut seq: V) -> Result<Self::Value, V::Error>
|
||||
/// where V: SeqVisitor<'de>
|
||||
/// fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
|
||||
/// where A: SeqAccess<'de>
|
||||
/// {
|
||||
/// // Skip over the first `n` elements.
|
||||
/// for i in 0..self.n {
|
||||
/// // It is an error if the sequence ends before we get to element `n`.
|
||||
/// if seq.visit::<IgnoredAny>()?.is_none() {
|
||||
/// if seq.next_element::<IgnoredAny>()?.is_none() {
|
||||
/// return Err(de::Error::invalid_length(i, &self));
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// // Deserialize the one we care about.
|
||||
/// let nth = match seq.visit()? {
|
||||
/// let nth = match seq.next_element()? {
|
||||
/// Some(nth) => nth,
|
||||
/// None => {
|
||||
/// return Err(de::Error::invalid_length(self.n, &self));
|
||||
@@ -73,7 +73,7 @@ use de::{Deserialize, Deserializer, Visitor, SeqVisitor, MapVisitor, Error};
|
||||
/// };
|
||||
///
|
||||
/// // Skip over any remaining elements in the sequence after `n`.
|
||||
/// while let Some(IgnoredAny) = seq.visit()? {
|
||||
/// while let Some(IgnoredAny) = seq.next_element()? {
|
||||
/// // ignore
|
||||
/// }
|
||||
///
|
||||
@@ -173,22 +173,22 @@ impl<'de> Visitor<'de> for IgnoredAny {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
||||
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
while let Some(IgnoredAny) = try!(visitor.visit()) {
|
||||
while let Some(IgnoredAny) = try!(seq.next_element()) {
|
||||
// Gobble
|
||||
}
|
||||
Ok(IgnoredAny)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
||||
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
V: MapVisitor<'de>,
|
||||
A: MapAccess<'de>,
|
||||
{
|
||||
while let Some((IgnoredAny, IgnoredAny)) = try!(visitor.visit()) {
|
||||
while let Some((IgnoredAny, IgnoredAny)) = try!(map.next_entry()) {
|
||||
// Gobble
|
||||
}
|
||||
Ok(IgnoredAny)
|
||||
|
||||
+61
-61
@@ -8,11 +8,11 @@
|
||||
|
||||
use lib::*;
|
||||
|
||||
use de::{Deserialize, Deserializer, EnumVisitor, Error, SeqVisitor, Unexpected, VariantVisitor,
|
||||
use de::{Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess,
|
||||
Visitor};
|
||||
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
use de::MapVisitor;
|
||||
use de::MapAccess;
|
||||
|
||||
use de::from_primitive::FromPrimitive;
|
||||
|
||||
@@ -340,14 +340,14 @@ impl<'de> Visitor<'de> for CStringVisitor {
|
||||
formatter.write_str("byte array")
|
||||
}
|
||||
|
||||
fn visit_seq<V>(self, mut visitor: V) -> Result<CString, V::Error>
|
||||
fn visit_seq<A>(self, mut seq: A) -> Result<CString, A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
let len = cmp::min(visitor.size_hint().0, 4096);
|
||||
let len = cmp::min(seq.size_hint().0, 4096);
|
||||
let mut values = Vec::with_capacity(len);
|
||||
|
||||
while let Some(value) = try!(visitor.visit()) {
|
||||
while let Some(value) = try!(seq.next_element()) {
|
||||
values.push(value);
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ macro_rules! seq_impl {
|
||||
(
|
||||
$ty:ident < T $(, $typaram:ident)* >,
|
||||
$visitor_ty:ident $( < $($boundparam:ident : $bound1:ident $(+ $bound2:ident)*),* > )*,
|
||||
$visitor:ident,
|
||||
$access:ident,
|
||||
$ctor:expr,
|
||||
$with_capacity:expr,
|
||||
$insert:expr
|
||||
@@ -524,13 +524,13 @@ macro_rules! seq_impl {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_seq<V>(self, mut $visitor: V) -> Result<Self::Value, V::Error>
|
||||
fn visit_seq<A>(self, mut $access: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
let mut values = $with_capacity;
|
||||
|
||||
while let Some(value) = try!($visitor.visit()) {
|
||||
while let Some(value) = try!($access.next_element()) {
|
||||
$insert(&mut values, value);
|
||||
}
|
||||
|
||||
@@ -628,9 +628,9 @@ impl<'de, T> Visitor<'de> for ArrayVisitor<[T; 0]> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_seq<V>(self, _: V) -> Result<[T; 0], V::Error>
|
||||
fn visit_seq<A>(self, _: A) -> Result<[T; 0], A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
Ok([])
|
||||
}
|
||||
@@ -660,12 +660,12 @@ macro_rules! array_impls {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_seq<V>(self, mut visitor: V) -> Result<[T; $len], V::Error>
|
||||
fn visit_seq<A>(self, mut seq: A) -> Result<[T; $len], A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
$(
|
||||
let $name = match try!(visitor.visit()) {
|
||||
let $name = match try!(seq.next_element()) {
|
||||
Some(val) => val,
|
||||
None => return Err(Error::invalid_length($n, &self)),
|
||||
};
|
||||
@@ -749,12 +749,12 @@ macro_rules! tuple_impls {
|
||||
|
||||
#[inline]
|
||||
#[allow(non_snake_case)]
|
||||
fn visit_seq<V>(self, mut visitor: V) -> Result<($($name,)+), V::Error>
|
||||
fn visit_seq<A>(self, mut seq: A) -> Result<($($name,)+), A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
$(
|
||||
let $name = match try!(visitor.visit()) {
|
||||
let $name = match try!(seq.next_element()) {
|
||||
Some(value) => value,
|
||||
None => return Err(Error::invalid_length($n, &self)),
|
||||
};
|
||||
@@ -802,7 +802,7 @@ macro_rules! map_impl {
|
||||
(
|
||||
$ty:ident < K, V $(, $typaram:ident)* >,
|
||||
$visitor_ty:ident < $($boundparam:ident : $bound1:ident $(+ $bound2:ident)*),* >,
|
||||
$visitor:ident,
|
||||
$access:ident,
|
||||
$ctor:expr,
|
||||
$with_capacity:expr
|
||||
) => {
|
||||
@@ -831,13 +831,13 @@ macro_rules! map_impl {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_map<Visitor>(self, mut $visitor: Visitor) -> Result<Self::Value, Visitor::Error>
|
||||
fn visit_map<A>(self, mut $access: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
Visitor: MapVisitor<'de>,
|
||||
A: MapAccess<'de>,
|
||||
{
|
||||
let mut values = $with_capacity;
|
||||
|
||||
while let Some((key, value)) = try!($visitor.visit()) {
|
||||
while let Some((key, value)) = try!($access.next_entry()) {
|
||||
values.insert(key, value);
|
||||
}
|
||||
|
||||
@@ -1086,29 +1086,29 @@ impl<'de> Visitor<'de> for OsStringVisitor {
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn visit_enum<V>(self, visitor: V) -> Result<OsString, V::Error>
|
||||
fn visit_enum<A>(self, data: A) -> Result<OsString, A::Error>
|
||||
where
|
||||
V: EnumVisitor<'de>,
|
||||
A: EnumAccess<'de>,
|
||||
{
|
||||
use std::os::unix::ffi::OsStringExt;
|
||||
|
||||
match try!(visitor.visit_variant()) {
|
||||
(OsStringKind::Unix, variant) => variant.visit_newtype().map(OsString::from_vec),
|
||||
match try!(data.variant()) {
|
||||
(OsStringKind::Unix, variant) => variant.deserialize_newtype().map(OsString::from_vec),
|
||||
(OsStringKind::Windows, _) => Err(Error::custom("cannot deserialize Windows OS string on Unix",),),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn visit_enum<V>(self, visitor: V) -> Result<OsString, V::Error>
|
||||
fn visit_enum<A>(self, data: A) -> Result<OsString, A::Error>
|
||||
where
|
||||
V: EnumVisitor<'de>,
|
||||
A: EnumAccess<'de>,
|
||||
{
|
||||
use std::os::windows::ffi::OsStringExt;
|
||||
|
||||
match try!(visitor.visit_variant()) {
|
||||
match try!(data.variant()) {
|
||||
(OsStringKind::Windows, variant) => {
|
||||
variant
|
||||
.visit_newtype::<Vec<u16>>()
|
||||
.deserialize_newtype::<Vec<u16>>()
|
||||
.map(|vec| OsString::from_wide(&vec))
|
||||
}
|
||||
(OsStringKind::Unix, _) => Err(Error::custom("cannot deserialize Unix OS string on Windows",),),
|
||||
@@ -1285,17 +1285,17 @@ impl<'de> Deserialize<'de> for Duration {
|
||||
formatter.write_str("struct Duration")
|
||||
}
|
||||
|
||||
fn visit_seq<V>(self, mut visitor: V) -> Result<Duration, V::Error>
|
||||
fn visit_seq<A>(self, mut seq: A) -> Result<Duration, A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
let secs: u64 = match try!(visitor.visit()) {
|
||||
let secs: u64 = match try!(seq.next_element()) {
|
||||
Some(value) => value,
|
||||
None => {
|
||||
return Err(Error::invalid_length(0, &self));
|
||||
}
|
||||
};
|
||||
let nanos: u32 = match try!(visitor.visit()) {
|
||||
let nanos: u32 = match try!(seq.next_element()) {
|
||||
Some(value) => value,
|
||||
None => {
|
||||
return Err(Error::invalid_length(1, &self));
|
||||
@@ -1304,35 +1304,35 @@ impl<'de> Deserialize<'de> for Duration {
|
||||
Ok(Duration::new(secs, nanos))
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, mut visitor: V) -> Result<Duration, V::Error>
|
||||
fn visit_map<A>(self, mut map: A) -> Result<Duration, A::Error>
|
||||
where
|
||||
V: MapVisitor<'de>,
|
||||
A: MapAccess<'de>,
|
||||
{
|
||||
let mut secs: Option<u64> = None;
|
||||
let mut nanos: Option<u32> = None;
|
||||
while let Some(key) = try!(visitor.visit_key::<Field>()) {
|
||||
while let Some(key) = try!(map.next_key()) {
|
||||
match key {
|
||||
Field::Secs => {
|
||||
if secs.is_some() {
|
||||
return Err(<V::Error as Error>::duplicate_field("secs"));
|
||||
return Err(<A::Error as Error>::duplicate_field("secs"));
|
||||
}
|
||||
secs = Some(try!(visitor.visit_value()));
|
||||
secs = Some(try!(map.next_value()));
|
||||
}
|
||||
Field::Nanos => {
|
||||
if nanos.is_some() {
|
||||
return Err(<V::Error as Error>::duplicate_field("nanos"));
|
||||
return Err(<A::Error as Error>::duplicate_field("nanos"));
|
||||
}
|
||||
nanos = Some(try!(visitor.visit_value()));
|
||||
nanos = Some(try!(map.next_value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
let secs = match secs {
|
||||
Some(secs) => secs,
|
||||
None => return Err(<V::Error as Error>::missing_field("secs")),
|
||||
None => return Err(<A::Error as Error>::missing_field("secs")),
|
||||
};
|
||||
let nanos = match nanos {
|
||||
Some(nanos) => nanos,
|
||||
None => return Err(<V::Error as Error>::missing_field("nanos")),
|
||||
None => return Err(<A::Error as Error>::missing_field("nanos")),
|
||||
};
|
||||
Ok(Duration::new(secs, nanos))
|
||||
}
|
||||
@@ -1425,17 +1425,17 @@ where
|
||||
formatter.write_str("struct Range")
|
||||
}
|
||||
|
||||
fn visit_seq<V>(self, mut visitor: V) -> Result<ops::Range<Idx>, V::Error>
|
||||
fn visit_seq<A>(self, mut seq: A) -> Result<ops::Range<Idx>, A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
let start: Idx = match try!(visitor.visit()) {
|
||||
let start: Idx = match try!(seq.next_element()) {
|
||||
Some(value) => value,
|
||||
None => {
|
||||
return Err(Error::invalid_length(0, &self));
|
||||
}
|
||||
};
|
||||
let end: Idx = match try!(visitor.visit()) {
|
||||
let end: Idx = match try!(seq.next_element()) {
|
||||
Some(value) => value,
|
||||
None => {
|
||||
return Err(Error::invalid_length(1, &self));
|
||||
@@ -1444,35 +1444,35 @@ where
|
||||
Ok(start..end)
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, mut visitor: V) -> Result<ops::Range<Idx>, V::Error>
|
||||
fn visit_map<A>(self, mut map: A) -> Result<ops::Range<Idx>, A::Error>
|
||||
where
|
||||
V: MapVisitor<'de>,
|
||||
A: MapAccess<'de>,
|
||||
{
|
||||
let mut start: Option<Idx> = None;
|
||||
let mut end: Option<Idx> = None;
|
||||
while let Some(key) = try!(visitor.visit_key::<Field>()) {
|
||||
while let Some(key) = try!(map.next_key()) {
|
||||
match key {
|
||||
Field::Start => {
|
||||
if start.is_some() {
|
||||
return Err(<V::Error as Error>::duplicate_field("start"));
|
||||
return Err(<A::Error as Error>::duplicate_field("start"));
|
||||
}
|
||||
start = Some(try!(visitor.visit_value()));
|
||||
start = Some(try!(map.next_value()));
|
||||
}
|
||||
Field::End => {
|
||||
if end.is_some() {
|
||||
return Err(<V::Error as Error>::duplicate_field("end"));
|
||||
return Err(<A::Error as Error>::duplicate_field("end"));
|
||||
}
|
||||
end = Some(try!(visitor.visit_value()));
|
||||
end = Some(try!(map.next_value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
let start = match start {
|
||||
Some(start) => start,
|
||||
None => return Err(<V::Error as Error>::missing_field("start")),
|
||||
None => return Err(<A::Error as Error>::missing_field("start")),
|
||||
};
|
||||
let end = match end {
|
||||
Some(end) => end,
|
||||
None => return Err(<V::Error as Error>::missing_field("end")),
|
||||
None => return Err(<A::Error as Error>::missing_field("end")),
|
||||
};
|
||||
Ok(start..end)
|
||||
}
|
||||
@@ -1598,13 +1598,13 @@ where
|
||||
formatter.write_str("enum Result")
|
||||
}
|
||||
|
||||
fn visit_enum<V>(self, visitor: V) -> Result<Result<T, E>, V::Error>
|
||||
fn visit_enum<A>(self, data: A) -> Result<Result<T, E>, A::Error>
|
||||
where
|
||||
V: EnumVisitor<'de>,
|
||||
A: EnumAccess<'de>,
|
||||
{
|
||||
match try!(visitor.visit_variant()) {
|
||||
(Field::Ok, variant) => variant.visit_newtype().map(Ok),
|
||||
(Field::Err, variant) => variant.visit_newtype().map(Err),
|
||||
match try!(data.variant()) {
|
||||
(Field::Ok, variant) => variant.deserialize_newtype().map(Ok),
|
||||
(Field::Err, variant) => variant.deserialize_newtype().map(Err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+118
-117
@@ -585,7 +585,7 @@ where
|
||||
/// use std::fmt;
|
||||
/// use std::marker::PhantomData;
|
||||
///
|
||||
/// use serde::de::{Deserialize, DeserializeSeed, Deserializer, Visitor, SeqVisitor};
|
||||
/// use serde::de::{Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess};
|
||||
///
|
||||
/// // A DeserializeSeed implementation that uses stateful deserialization to
|
||||
/// // append array elements onto the end of an existing vector. The preexisting
|
||||
@@ -618,12 +618,12 @@ where
|
||||
/// write!(formatter, "an array of integers")
|
||||
/// }
|
||||
///
|
||||
/// fn visit_seq<V>(self, mut visitor: V) -> Result<(), V::Error>
|
||||
/// where V: SeqVisitor<'de>
|
||||
/// fn visit_seq<A>(self, mut seq: A) -> Result<(), A::Error>
|
||||
/// where A: SeqAccess<'de>
|
||||
/// {
|
||||
/// // Visit each element in the inner array and push it onto
|
||||
/// // the existing vector.
|
||||
/// while let Some(elem) = visitor.visit()? {
|
||||
/// while let Some(elem) = seq.next_element()? {
|
||||
/// self.0.push(elem);
|
||||
/// }
|
||||
/// Ok(())
|
||||
@@ -648,14 +648,14 @@ where
|
||||
/// write!(formatter, "an array of arrays")
|
||||
/// }
|
||||
///
|
||||
/// fn visit_seq<V>(self, mut visitor: V) -> Result<Vec<T>, V::Error>
|
||||
/// where V: SeqVisitor<'de>
|
||||
/// fn visit_seq<A>(self, mut seq: A) -> Result<Vec<T>, A::Error>
|
||||
/// where A: SeqAccess<'de>
|
||||
/// {
|
||||
/// // Create a single Vec to hold the flattened contents.
|
||||
/// let mut vec = Vec::new();
|
||||
///
|
||||
/// // Each iteration through this loop is one inner array.
|
||||
/// while let Some(()) = visitor.visit_seed(ExtendVec(&mut vec))? {
|
||||
/// while let Some(()) = seq.next_element_seed(ExtendVec(&mut vec))? {
|
||||
/// // Nothing to do; inner array has been appended into `vec`.
|
||||
/// }
|
||||
///
|
||||
@@ -1260,29 +1260,29 @@ pub trait Visitor<'de>: Sized {
|
||||
}
|
||||
|
||||
/// Deserialize `Value` as a sequence of elements.
|
||||
fn visit_seq<V>(self, visitor: V) -> Result<Self::Value, V::Error>
|
||||
fn visit_seq<A>(self, seq: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
let _ = visitor;
|
||||
let _ = seq;
|
||||
Err(Error::invalid_type(Unexpected::Seq, &self))
|
||||
}
|
||||
|
||||
/// Deserialize `Value` as a key-value map.
|
||||
fn visit_map<V>(self, visitor: V) -> Result<Self::Value, V::Error>
|
||||
fn visit_map<A>(self, map: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
V: MapVisitor<'de>,
|
||||
A: MapAccess<'de>,
|
||||
{
|
||||
let _ = visitor;
|
||||
let _ = map;
|
||||
Err(Error::invalid_type(Unexpected::Map, &self))
|
||||
}
|
||||
|
||||
/// Deserialize `Value` as an enum.
|
||||
fn visit_enum<V>(self, visitor: V) -> Result<Self::Value, V::Error>
|
||||
fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
V: EnumVisitor<'de>,
|
||||
A: EnumAccess<'de>,
|
||||
{
|
||||
let _ = visitor;
|
||||
let _ = data;
|
||||
Err(Error::invalid_type(Unexpected::Enum, &self))
|
||||
}
|
||||
|
||||
@@ -1345,11 +1345,11 @@ pub trait Visitor<'de>: Sized {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// `SeqVisitor` visits each item in a sequence.
|
||||
/// Provides a `Visitor` access to each element of a sequence in the input.
|
||||
///
|
||||
/// This is a trait that a `Deserializer` passes to a `Visitor` implementation,
|
||||
/// which deserializes each item in a sequence.
|
||||
pub trait SeqVisitor<'de> {
|
||||
pub trait SeqAccess<'de> {
|
||||
/// The error type that can be returned if some error occurs during
|
||||
/// deserialization.
|
||||
type Error: Error;
|
||||
@@ -1357,9 +1357,9 @@ pub trait SeqVisitor<'de> {
|
||||
/// This returns `Ok(Some(value))` for the next value in the sequence, or
|
||||
/// `Ok(None)` if there are no more remaining items.
|
||||
///
|
||||
/// `Deserialize` implementations should typically use `SeqVisitor::visit`
|
||||
/// instead.
|
||||
fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
/// `Deserialize` implementations should typically use
|
||||
/// `SeqAcccess::next_element` instead.
|
||||
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
where
|
||||
T: DeserializeSeed<'de>;
|
||||
|
||||
@@ -1367,13 +1367,13 @@ pub trait SeqVisitor<'de> {
|
||||
/// `Ok(None)` if there are no more remaining items.
|
||||
///
|
||||
/// This method exists as a convenience for `Deserialize` implementations.
|
||||
/// `SeqVisitor` implementations should not override the default behavior.
|
||||
/// `SeqAccess` implementations should not override the default behavior.
|
||||
#[inline]
|
||||
fn visit<T>(&mut self) -> Result<Option<T>, Self::Error>
|
||||
fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
|
||||
where
|
||||
T: Deserialize<'de>,
|
||||
{
|
||||
self.visit_seed(PhantomData)
|
||||
self.next_element_seed(PhantomData)
|
||||
}
|
||||
|
||||
/// Return the lower and upper bound of items remaining in the sequence.
|
||||
@@ -1383,26 +1383,26 @@ pub trait SeqVisitor<'de> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a, V> SeqVisitor<'de> for &'a mut V
|
||||
impl<'de, 'a, V> SeqAccess<'de> for &'a mut V
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
V: SeqAccess<'de>,
|
||||
{
|
||||
type Error = V::Error;
|
||||
|
||||
#[inline]
|
||||
fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, V::Error>
|
||||
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, V::Error>
|
||||
where
|
||||
T: DeserializeSeed<'de>,
|
||||
{
|
||||
(**self).visit_seed(seed)
|
||||
(**self).next_element_seed(seed)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit<T>(&mut self) -> Result<Option<T>, V::Error>
|
||||
fn next_element<T>(&mut self) -> Result<Option<T>, V::Error>
|
||||
where
|
||||
T: Deserialize<'de>,
|
||||
{
|
||||
(**self).visit()
|
||||
(**self).next_element()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -1413,10 +1413,10 @@ where
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// `MapVisitor` visits each item in a sequence.
|
||||
/// Provides a `Visitor` access to each entry of a map in the input.
|
||||
///
|
||||
/// This is a trait that a `Deserializer` passes to a `Visitor` implementation.
|
||||
pub trait MapVisitor<'de> {
|
||||
pub trait MapAccess<'de> {
|
||||
/// The error type that can be returned if some error occurs during
|
||||
/// deserialization.
|
||||
type Error: Error;
|
||||
@@ -1425,29 +1425,29 @@ pub trait MapVisitor<'de> {
|
||||
/// if there are no more remaining entries.
|
||||
///
|
||||
/// `Deserialize` implementations should typically use
|
||||
/// `MapVisitor::visit_key` or `MapVisitor::visit` instead.
|
||||
fn visit_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
|
||||
/// `MapAccess::next_key` or `MapAccess::next_entry` instead.
|
||||
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
|
||||
where
|
||||
K: DeserializeSeed<'de>;
|
||||
|
||||
/// This returns a `Ok(value)` for the next value in the map.
|
||||
///
|
||||
/// `Deserialize` implementations should typically use
|
||||
/// `MapVisitor::visit_value` instead.
|
||||
fn visit_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
|
||||
/// `MapAccess::next_value` instead.
|
||||
fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
V: DeserializeSeed<'de>;
|
||||
|
||||
/// This returns `Ok(Some((key, value)))` for the next (key-value) pair in
|
||||
/// the map, or `Ok(None)` if there are no more remaining items.
|
||||
///
|
||||
/// `MapVisitor` implementations should override the default behavior if a
|
||||
/// `MapAccess` implementations should override the default behavior if a
|
||||
/// more efficient implementation is possible.
|
||||
///
|
||||
/// `Deserialize` implementations should typically use `MapVisitor::visit`
|
||||
/// instead.
|
||||
/// `Deserialize` implementations should typically use
|
||||
/// `MapAccess::next_entry` instead.
|
||||
#[inline]
|
||||
fn visit_seed<K, V>(
|
||||
fn next_entry_seed<K, V>(
|
||||
&mut self,
|
||||
kseed: K,
|
||||
vseed: V,
|
||||
@@ -1456,9 +1456,9 @@ pub trait MapVisitor<'de> {
|
||||
K: DeserializeSeed<'de>,
|
||||
V: DeserializeSeed<'de>,
|
||||
{
|
||||
match try!(self.visit_key_seed(kseed)) {
|
||||
match try!(self.next_key_seed(kseed)) {
|
||||
Some(key) => {
|
||||
let value = try!(self.visit_value_seed(vseed));
|
||||
let value = try!(self.next_value_seed(vseed));
|
||||
Ok(Some((key, value)))
|
||||
}
|
||||
None => Ok(None),
|
||||
@@ -1469,39 +1469,39 @@ pub trait MapVisitor<'de> {
|
||||
/// if there are no more remaining entries.
|
||||
///
|
||||
/// This method exists as a convenience for `Deserialize` implementations.
|
||||
/// `MapVisitor` implementations should not override the default behavior.
|
||||
/// `MapAccess` implementations should not override the default behavior.
|
||||
#[inline]
|
||||
fn visit_key<K>(&mut self) -> Result<Option<K>, Self::Error>
|
||||
fn next_key<K>(&mut self) -> Result<Option<K>, Self::Error>
|
||||
where
|
||||
K: Deserialize<'de>,
|
||||
{
|
||||
self.visit_key_seed(PhantomData)
|
||||
self.next_key_seed(PhantomData)
|
||||
}
|
||||
|
||||
/// This returns a `Ok(value)` for the next value in the map.
|
||||
///
|
||||
/// This method exists as a convenience for `Deserialize` implementations.
|
||||
/// `MapVisitor` implementations should not override the default behavior.
|
||||
/// `MapAccess` implementations should not override the default behavior.
|
||||
#[inline]
|
||||
fn visit_value<V>(&mut self) -> Result<V, Self::Error>
|
||||
fn next_value<V>(&mut self) -> Result<V, Self::Error>
|
||||
where
|
||||
V: Deserialize<'de>,
|
||||
{
|
||||
self.visit_value_seed(PhantomData)
|
||||
self.next_value_seed(PhantomData)
|
||||
}
|
||||
|
||||
/// This returns `Ok(Some((key, value)))` for the next (key-value) pair in
|
||||
/// the map, or `Ok(None)` if there are no more remaining items.
|
||||
///
|
||||
/// This method exists as a convenience for `Deserialize` implementations.
|
||||
/// `MapVisitor` implementations should not override the default behavior.
|
||||
/// `MapAccess` implementations should not override the default behavior.
|
||||
#[inline]
|
||||
fn visit<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>
|
||||
fn next_entry<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>
|
||||
where
|
||||
K: Deserialize<'de>,
|
||||
V: Deserialize<'de>,
|
||||
{
|
||||
self.visit_seed(PhantomData, PhantomData)
|
||||
self.next_entry_seed(PhantomData, PhantomData)
|
||||
}
|
||||
|
||||
/// Return the lower and upper bound of items remaining in the sequence.
|
||||
@@ -1511,30 +1511,30 @@ pub trait MapVisitor<'de> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a, V_> MapVisitor<'de> for &'a mut V_
|
||||
impl<'de, 'a, V_> MapAccess<'de> for &'a mut V_
|
||||
where
|
||||
V_: MapVisitor<'de>,
|
||||
V_: MapAccess<'de>,
|
||||
{
|
||||
type Error = V_::Error;
|
||||
|
||||
#[inline]
|
||||
fn visit_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
|
||||
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
|
||||
where
|
||||
K: DeserializeSeed<'de>,
|
||||
{
|
||||
(**self).visit_key_seed(seed)
|
||||
(**self).next_key_seed(seed)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
|
||||
fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
V: DeserializeSeed<'de>,
|
||||
{
|
||||
(**self).visit_value_seed(seed)
|
||||
(**self).next_value_seed(seed)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_seed<K, V>(
|
||||
fn next_entry_seed<K, V>(
|
||||
&mut self,
|
||||
kseed: K,
|
||||
vseed: V,
|
||||
@@ -1543,32 +1543,32 @@ where
|
||||
K: DeserializeSeed<'de>,
|
||||
V: DeserializeSeed<'de>,
|
||||
{
|
||||
(**self).visit_seed(kseed, vseed)
|
||||
(**self).next_entry_seed(kseed, vseed)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit<K, V>(&mut self) -> Result<Option<(K, V)>, V_::Error>
|
||||
fn next_entry<K, V>(&mut self) -> Result<Option<(K, V)>, V_::Error>
|
||||
where
|
||||
K: Deserialize<'de>,
|
||||
V: Deserialize<'de>,
|
||||
{
|
||||
(**self).visit()
|
||||
(**self).next_entry()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_key<K>(&mut self) -> Result<Option<K>, V_::Error>
|
||||
fn next_key<K>(&mut self) -> Result<Option<K>, V_::Error>
|
||||
where
|
||||
K: Deserialize<'de>,
|
||||
{
|
||||
(**self).visit_key()
|
||||
(**self).next_key()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_value<V>(&mut self) -> Result<V, V_::Error>
|
||||
fn next_value<V>(&mut self) -> Result<V, V_::Error>
|
||||
where
|
||||
V: Deserialize<'de>,
|
||||
{
|
||||
(**self).visit_value()
|
||||
(**self).next_value()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -1579,44 +1579,45 @@ where
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// `EnumVisitor` is a visitor that is created by the `Deserializer` and passed
|
||||
/// to the `Deserialize` in order to identify which variant of an enum to
|
||||
/// deserialize.
|
||||
pub trait EnumVisitor<'de>: Sized {
|
||||
/// Provides a `Visitor` access to the data of an enum in the input.
|
||||
///
|
||||
/// `EnumAccess` is created by the `Deserializer` and passed to the
|
||||
/// `Visitor` in order to identify which variant of an enum to deserialize.
|
||||
pub trait EnumAccess<'de>: Sized {
|
||||
/// The error type that can be returned if some error occurs during
|
||||
/// deserialization.
|
||||
type Error: Error;
|
||||
/// The `Visitor` that will be used to deserialize the content of the enum
|
||||
/// variant.
|
||||
type Variant: VariantVisitor<'de, Error = Self::Error>;
|
||||
type Variant: VariantAccess<'de, Error = Self::Error>;
|
||||
|
||||
/// `visit_variant` is called to identify which variant to deserialize.
|
||||
/// `variant` is called to identify which variant to deserialize.
|
||||
///
|
||||
/// `Deserialize` implementations should typically use
|
||||
/// `EnumVisitor::visit_variant` instead.
|
||||
fn visit_variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error>
|
||||
/// `Deserialize` implementations should typically use `EnumAccess::variant`
|
||||
/// instead.
|
||||
fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error>
|
||||
where
|
||||
V: DeserializeSeed<'de>;
|
||||
|
||||
/// `visit_variant` is called to identify which variant to deserialize.
|
||||
/// `variant` is called to identify which variant to deserialize.
|
||||
///
|
||||
/// This method exists as a convenience for `Deserialize` implementations.
|
||||
/// `EnumVisitor` implementations should not override the default behavior.
|
||||
/// `EnumAccess` implementations should not override the default behavior.
|
||||
#[inline]
|
||||
fn visit_variant<V>(self) -> Result<(V, Self::Variant), Self::Error>
|
||||
fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error>
|
||||
where
|
||||
V: Deserialize<'de>,
|
||||
{
|
||||
self.visit_variant_seed(PhantomData)
|
||||
self.variant_seed(PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
/// `VariantVisitor` is a visitor that is created by the `Deserializer` and
|
||||
/// `VariantAccess` is a visitor that is created by the `Deserializer` and
|
||||
/// passed to the `Deserialize` to deserialize the content of a particular enum
|
||||
/// variant.
|
||||
pub trait VariantVisitor<'de>: Sized {
|
||||
pub trait VariantAccess<'de>: Sized {
|
||||
/// The error type that can be returned if some error occurs during
|
||||
/// deserialization. Must match the error type of our `EnumVisitor`.
|
||||
/// deserialization. Must match the error type of our `EnumAccess`.
|
||||
type Error: Error;
|
||||
|
||||
/// Called when deserializing a variant with no values.
|
||||
@@ -1625,55 +1626,55 @@ pub trait VariantVisitor<'de>: Sized {
|
||||
/// `invalid_type` error should be constructed:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantVisitor, Unexpected};
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||
/// #
|
||||
/// # struct X;
|
||||
/// #
|
||||
/// # impl<'de> VariantVisitor<'de> for X {
|
||||
/// # impl<'de> VariantAccess<'de> for X {
|
||||
/// # type Error = value::Error;
|
||||
/// #
|
||||
/// fn visit_unit(self) -> Result<(), Self::Error> {
|
||||
/// fn deserialize_unit(self) -> Result<(), Self::Error> {
|
||||
/// // What the data actually contained; suppose it is a tuple variant.
|
||||
/// let unexp = Unexpected::TupleVariant;
|
||||
/// Err(de::Error::invalid_type(unexp, &"unit variant"))
|
||||
/// }
|
||||
/// #
|
||||
/// # fn visit_newtype_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
|
||||
/// # fn deserialize_newtype_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
|
||||
/// # where T: DeserializeSeed<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// #
|
||||
/// # fn visit_tuple<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
|
||||
/// # fn deserialize_tuple<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
|
||||
/// # where V: Visitor<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// #
|
||||
/// # fn visit_struct<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
|
||||
/// # fn deserialize_struct<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
|
||||
/// # where V: Visitor<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// # }
|
||||
/// ```
|
||||
fn visit_unit(self) -> Result<(), Self::Error>;
|
||||
fn deserialize_unit(self) -> Result<(), Self::Error>;
|
||||
|
||||
/// Called when deserializing a variant with a single value.
|
||||
///
|
||||
/// `Deserialize` implementations should typically use
|
||||
/// `VariantVisitor::visit_newtype` instead.
|
||||
/// `VariantAccess::deserialize_newtype` instead.
|
||||
///
|
||||
/// If the data contains a different type of variant, the following
|
||||
/// `invalid_type` error should be constructed:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantVisitor, Unexpected};
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||
/// #
|
||||
/// # struct X;
|
||||
/// #
|
||||
/// # impl<'de> VariantVisitor<'de> for X {
|
||||
/// # impl<'de> VariantAccess<'de> for X {
|
||||
/// # type Error = value::Error;
|
||||
/// #
|
||||
/// # fn visit_unit(self) -> Result<(), Self::Error> {
|
||||
/// # fn deserialize_unit(self) -> Result<(), Self::Error> {
|
||||
/// # unimplemented!()
|
||||
/// # }
|
||||
/// #
|
||||
/// fn visit_newtype_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
|
||||
/// fn deserialize_newtype_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
|
||||
/// where T: DeserializeSeed<'de>
|
||||
/// {
|
||||
/// // What the data actually contained; suppose it is a unit variant.
|
||||
@@ -1681,30 +1682,30 @@ pub trait VariantVisitor<'de>: Sized {
|
||||
/// Err(de::Error::invalid_type(unexp, &"newtype variant"))
|
||||
/// }
|
||||
/// #
|
||||
/// # fn visit_tuple<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
|
||||
/// # fn deserialize_tuple<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
|
||||
/// # where V: Visitor<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// #
|
||||
/// # fn visit_struct<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
|
||||
/// # fn deserialize_struct<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
|
||||
/// # where V: Visitor<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// # }
|
||||
/// ```
|
||||
fn visit_newtype_seed<T>(self, seed: T) -> Result<T::Value, Self::Error>
|
||||
fn deserialize_newtype_seed<T>(self, seed: T) -> Result<T::Value, Self::Error>
|
||||
where
|
||||
T: DeserializeSeed<'de>;
|
||||
|
||||
/// Called when deserializing a variant with a single value.
|
||||
///
|
||||
/// This method exists as a convenience for `Deserialize` implementations.
|
||||
/// `VariantVisitor` implementations should not override the default
|
||||
/// `VariantAccess` implementations should not override the default
|
||||
/// behavior.
|
||||
#[inline]
|
||||
fn visit_newtype<T>(self) -> Result<T, Self::Error>
|
||||
fn deserialize_newtype<T>(self) -> Result<T, Self::Error>
|
||||
where
|
||||
T: Deserialize<'de>,
|
||||
{
|
||||
self.visit_newtype_seed(PhantomData)
|
||||
self.deserialize_newtype_seed(PhantomData)
|
||||
}
|
||||
|
||||
/// Called when deserializing a tuple-like variant.
|
||||
@@ -1715,24 +1716,24 @@ pub trait VariantVisitor<'de>: Sized {
|
||||
/// `invalid_type` error should be constructed:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantVisitor, Unexpected};
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||
/// #
|
||||
/// # struct X;
|
||||
/// #
|
||||
/// # impl<'de> VariantVisitor<'de> for X {
|
||||
/// # impl<'de> VariantAccess<'de> for X {
|
||||
/// # type Error = value::Error;
|
||||
/// #
|
||||
/// # fn visit_unit(self) -> Result<(), Self::Error> {
|
||||
/// # fn deserialize_unit(self) -> Result<(), Self::Error> {
|
||||
/// # unimplemented!()
|
||||
/// # }
|
||||
/// #
|
||||
/// # fn visit_newtype_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
|
||||
/// # fn deserialize_newtype_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
|
||||
/// # where T: DeserializeSeed<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// #
|
||||
/// fn visit_tuple<V>(self,
|
||||
/// _len: usize,
|
||||
/// _visitor: V) -> Result<V::Value, Self::Error>
|
||||
/// fn deserialize_tuple<V>(self,
|
||||
/// _len: usize,
|
||||
/// _visitor: V) -> Result<V::Value, Self::Error>
|
||||
/// where V: Visitor<'de>
|
||||
/// {
|
||||
/// // What the data actually contained; suppose it is a unit variant.
|
||||
@@ -1740,12 +1741,12 @@ pub trait VariantVisitor<'de>: Sized {
|
||||
/// Err(de::Error::invalid_type(unexp, &"tuple variant"))
|
||||
/// }
|
||||
/// #
|
||||
/// # fn visit_struct<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
|
||||
/// # fn deserialize_struct<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
|
||||
/// # where V: Visitor<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// # }
|
||||
/// ```
|
||||
fn visit_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
|
||||
fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
V: Visitor<'de>;
|
||||
|
||||
@@ -1757,28 +1758,28 @@ pub trait VariantVisitor<'de>: Sized {
|
||||
/// `invalid_type` error should be constructed:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantVisitor, Unexpected};
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||
/// #
|
||||
/// # struct X;
|
||||
/// #
|
||||
/// # impl<'de> VariantVisitor<'de> for X {
|
||||
/// # impl<'de> VariantAccess<'de> for X {
|
||||
/// # type Error = value::Error;
|
||||
/// #
|
||||
/// # fn visit_unit(self) -> Result<(), Self::Error> {
|
||||
/// # fn deserialize_unit(self) -> Result<(), Self::Error> {
|
||||
/// # unimplemented!()
|
||||
/// # }
|
||||
/// #
|
||||
/// # fn visit_newtype_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
|
||||
/// # fn deserialize_newtype_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
|
||||
/// # where T: DeserializeSeed<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// #
|
||||
/// # fn visit_tuple<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
|
||||
/// # fn deserialize_tuple<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
|
||||
/// # where V: Visitor<'de>
|
||||
/// # { unimplemented!() }
|
||||
/// #
|
||||
/// fn visit_struct<V>(self,
|
||||
/// _fields: &'static [&'static str],
|
||||
/// _visitor: V) -> Result<V::Value, Self::Error>
|
||||
/// fn deserialize_struct<V>(self,
|
||||
/// _fields: &'static [&'static str],
|
||||
/// _visitor: V) -> Result<V::Value, Self::Error>
|
||||
/// where V: Visitor<'de>
|
||||
/// {
|
||||
/// // What the data actually contained; suppose it is a unit variant.
|
||||
@@ -1787,7 +1788,7 @@ pub trait VariantVisitor<'de>: Sized {
|
||||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
fn visit_struct<V>(
|
||||
fn deserialize_struct<V>(
|
||||
self,
|
||||
fields: &'static [&'static str],
|
||||
visitor: V,
|
||||
|
||||
+30
-30
@@ -10,7 +10,7 @@
|
||||
|
||||
use lib::*;
|
||||
|
||||
use de::{self, IntoDeserializer, Expected, SeqVisitor};
|
||||
use de::{self, IntoDeserializer, Expected, SeqAccess};
|
||||
use self::private::{First, Second};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -223,14 +223,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, E> de::EnumVisitor<'de> for U32Deserializer<E>
|
||||
impl<'de, E> de::EnumAccess<'de> for U32Deserializer<E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
type Variant = private::UnitOnly<E>;
|
||||
|
||||
fn visit_variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
|
||||
fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -293,14 +293,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a, E> de::EnumVisitor<'de> for StrDeserializer<'a, E>
|
||||
impl<'de, 'a, E> de::EnumAccess<'de> for StrDeserializer<'a, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
type Variant = private::UnitOnly<E>;
|
||||
|
||||
fn visit_variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
|
||||
fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -367,14 +367,14 @@ where
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
impl<'de, 'a, E> de::EnumVisitor<'de> for StringDeserializer<E>
|
||||
impl<'de, 'a, E> de::EnumAccess<'de> for StringDeserializer<E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
type Variant = private::UnitOnly<E>;
|
||||
|
||||
fn visit_variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
|
||||
fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -444,14 +444,14 @@ where
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
impl<'de, 'a, E> de::EnumVisitor<'de> for CowStrDeserializer<'a, E>
|
||||
impl<'de, 'a, E> de::EnumAccess<'de> for CowStrDeserializer<'a, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
type Variant = private::UnitOnly<E>;
|
||||
|
||||
fn visit_variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
|
||||
fn variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -524,7 +524,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, I, T, E> de::SeqVisitor<'de> for SeqDeserializer<I, E>
|
||||
impl<'de, I, T, E> de::SeqAccess<'de> for SeqDeserializer<I, E>
|
||||
where
|
||||
I: Iterator<Item = T>,
|
||||
T: IntoDeserializer<'de, E>,
|
||||
@@ -532,7 +532,7 @@ where
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_seed<V>(&mut self, seed: V) -> Result<Option<V::Value>, Self::Error>
|
||||
fn next_element_seed<V>(&mut self, seed: V) -> Result<Option<V::Value>, Self::Error>
|
||||
where
|
||||
V: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -605,7 +605,7 @@ where
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// A helper deserializer that deserializes a sequence using a `SeqVisitor`.
|
||||
/// A helper deserializer that deserializes a sequence using a `SeqAccess`.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SeqVisitorDeserializer<V_> {
|
||||
visitor: V_,
|
||||
@@ -620,7 +620,7 @@ impl<V_> SeqVisitorDeserializer<V_> {
|
||||
|
||||
impl<'de, V_> de::Deserializer<'de> for SeqVisitorDeserializer<V_>
|
||||
where
|
||||
V_: de::SeqVisitor<'de>,
|
||||
V_: de::SeqAccess<'de>,
|
||||
{
|
||||
type Error = V_::Error;
|
||||
|
||||
@@ -747,7 +747,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, I, E> de::MapVisitor<'de> for MapDeserializer<'de, I, E>
|
||||
impl<'de, I, E> de::MapAccess<'de> for MapDeserializer<'de, I, E>
|
||||
where
|
||||
I: Iterator,
|
||||
I::Item: private::Pair,
|
||||
@@ -757,7 +757,7 @@ where
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -770,18 +770,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
|
||||
fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
let value = self.value.take();
|
||||
// Panic because this indicates a bug in the program rather than an
|
||||
// expected failure.
|
||||
let value = value.expect("MapVisitor::visit_value called before visit_key");
|
||||
let value = value.expect("MapAccess::visit_value called before visit_key");
|
||||
seed.deserialize(value.into_deserializer())
|
||||
}
|
||||
|
||||
fn visit_seed<TK, TV>(&mut self,
|
||||
fn next_entry_seed<TK, TV>(&mut self,
|
||||
kseed: TK,
|
||||
vseed: TV)
|
||||
-> Result<Option<(TK::Value, TV::Value)>, Self::Error>
|
||||
@@ -804,7 +804,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, I, E> de::SeqVisitor<'de> for MapDeserializer<'de, I, E>
|
||||
impl<'de, I, E> de::SeqAccess<'de> for MapDeserializer<'de, I, E>
|
||||
where
|
||||
I: Iterator,
|
||||
I::Item: private::Pair,
|
||||
@@ -814,7 +814,7 @@ where
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -876,7 +876,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// Used in the `impl SeqVisitor for MapDeserializer` to visit the map as a
|
||||
// Used in the `impl SeqAccess for MapDeserializer` to visit the map as a
|
||||
// sequence of pairs.
|
||||
struct PairDeserializer<A, B, E>(A, B, PhantomData<E>);
|
||||
|
||||
@@ -933,7 +933,7 @@ where
|
||||
|
||||
struct PairVisitor<A, B, E>(Option<A>, Option<B>, PhantomData<E>);
|
||||
|
||||
impl<'de, A, B, E> de::SeqVisitor<'de> for PairVisitor<A, B, E>
|
||||
impl<'de, A, B, E> de::SeqAccess<'de> for PairVisitor<A, B, E>
|
||||
where
|
||||
A: IntoDeserializer<'de, E>,
|
||||
B: IntoDeserializer<'de, E>,
|
||||
@@ -941,7 +941,7 @@ where
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1010,7 +1010,7 @@ where
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// A helper deserializer that deserializes a map using a `MapVisitor`.
|
||||
/// A helper deserializer that deserializes a map using a `MapAccess`.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MapVisitorDeserializer<V_> {
|
||||
visitor: V_,
|
||||
@@ -1025,7 +1025,7 @@ impl<V_> MapVisitorDeserializer<V_> {
|
||||
|
||||
impl<'de, V_> de::Deserializer<'de> for MapVisitorDeserializer<V_>
|
||||
where
|
||||
V_: de::MapVisitor<'de>,
|
||||
V_: de::MapAccess<'de>,
|
||||
{
|
||||
type Error = V_::Error;
|
||||
|
||||
@@ -1059,31 +1059,31 @@ mod private {
|
||||
(t, UnitOnly { marker: PhantomData })
|
||||
}
|
||||
|
||||
impl<'de, E> de::VariantVisitor<'de> for UnitOnly<E>
|
||||
impl<'de, E> de::VariantAccess<'de> for UnitOnly<E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_unit(self) -> Result<(), Self::Error> {
|
||||
fn deserialize_unit(self) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn visit_newtype_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
|
||||
fn deserialize_newtype_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
Err(de::Error::invalid_type(Unexpected::UnitVariant, &"newtype variant"),)
|
||||
}
|
||||
|
||||
fn visit_tuple<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
|
||||
fn deserialize_tuple<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
V: de::Visitor<'de>,
|
||||
{
|
||||
Err(de::Error::invalid_type(Unexpected::UnitVariant, &"tuple variant"),)
|
||||
}
|
||||
|
||||
fn visit_struct<V>(
|
||||
fn deserialize_struct<V>(
|
||||
self,
|
||||
_fields: &'static [&'static str],
|
||||
_visitor: V,
|
||||
|
||||
+39
-39
@@ -201,8 +201,8 @@ mod content {
|
||||
|
||||
use lib::*;
|
||||
|
||||
use de::{self, Deserialize, DeserializeSeed, Deserializer, Visitor, SeqVisitor, MapVisitor,
|
||||
EnumVisitor, Unexpected};
|
||||
use de::{self, Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess, MapAccess,
|
||||
EnumAccess, Unexpected};
|
||||
|
||||
/// Used from generated code to buffer the contents of the Deserializer when
|
||||
/// deserializing untagged enums and internally tagged enums.
|
||||
@@ -426,10 +426,10 @@ mod content {
|
||||
|
||||
fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
V: SeqAccess<'de>,
|
||||
{
|
||||
let mut vec = Vec::with_capacity(cmp::min(visitor.size_hint().0, 4096));
|
||||
while let Some(e) = try!(visitor.visit()) {
|
||||
while let Some(e) = try!(visitor.next_element()) {
|
||||
vec.push(e);
|
||||
}
|
||||
Ok(Content::Seq(vec))
|
||||
@@ -437,10 +437,10 @@ mod content {
|
||||
|
||||
fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
||||
where
|
||||
V: MapVisitor<'de>,
|
||||
V: MapAccess<'de>,
|
||||
{
|
||||
let mut vec = Vec::with_capacity(cmp::min(visitor.size_hint().0, 4096));
|
||||
while let Some(kv) = try!(visitor.visit()) {
|
||||
while let Some(kv) = try!(visitor.next_entry()) {
|
||||
vec.push(kv);
|
||||
}
|
||||
Ok(Content::Map(vec))
|
||||
@@ -448,7 +448,7 @@ mod content {
|
||||
|
||||
fn visit_enum<V>(self, _visitor: V) -> Result<Self::Value, V::Error>
|
||||
where
|
||||
V: EnumVisitor<'de>,
|
||||
V: EnumAccess<'de>,
|
||||
{
|
||||
Err(de::Error::custom("untagged and internally tagged enums do not support enum input",),)
|
||||
}
|
||||
@@ -682,7 +682,7 @@ mod content {
|
||||
|
||||
fn visit_seq<V>(self, visitor: V) -> Result<Self::Value, V::Error>
|
||||
where
|
||||
V: SeqVisitor<'de>,
|
||||
V: SeqAccess<'de>,
|
||||
{
|
||||
ContentVisitor
|
||||
.visit_seq(visitor)
|
||||
@@ -691,7 +691,7 @@ mod content {
|
||||
|
||||
fn visit_map<V>(self, visitor: V) -> Result<Self::Value, V::Error>
|
||||
where
|
||||
V: MapVisitor<'de>,
|
||||
V: MapAccess<'de>,
|
||||
{
|
||||
ContentVisitor
|
||||
.visit_map(visitor)
|
||||
@@ -700,7 +700,7 @@ mod content {
|
||||
|
||||
fn visit_enum<V>(self, visitor: V) -> Result<Self::Value, V::Error>
|
||||
where
|
||||
V: EnumVisitor<'de>,
|
||||
V: EnumAccess<'de>,
|
||||
{
|
||||
ContentVisitor
|
||||
.visit_enum(visitor)
|
||||
@@ -761,21 +761,21 @@ mod content {
|
||||
|
||||
fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
||||
where
|
||||
V: MapVisitor<'de>,
|
||||
V: MapAccess<'de>,
|
||||
{
|
||||
let mut tag = None;
|
||||
let mut vec = Vec::with_capacity(cmp::min(visitor.size_hint().0, 4096));
|
||||
while let Some(k) =
|
||||
try!(visitor.visit_key_seed(TagOrContentVisitor::new(self.tag_name))) {
|
||||
try!(visitor.next_key_seed(TagOrContentVisitor::new(self.tag_name))) {
|
||||
match k {
|
||||
TagOrContent::Tag => {
|
||||
if tag.is_some() {
|
||||
return Err(de::Error::duplicate_field(self.tag_name));
|
||||
}
|
||||
tag = Some(try!(visitor.visit_value()));
|
||||
tag = Some(try!(visitor.next_value()));
|
||||
}
|
||||
TagOrContent::Content(k) => {
|
||||
let v = try!(visitor.visit_value());
|
||||
let v = try!(visitor.next_value());
|
||||
vec.push((k, v));
|
||||
}
|
||||
}
|
||||
@@ -995,14 +995,14 @@ mod content {
|
||||
err: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<'de, E> de::EnumVisitor<'de> for EnumDeserializer<E>
|
||||
impl<'de, E> de::EnumAccess<'de> for EnumDeserializer<E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
type Variant = VariantDeserializer<Self::Error>;
|
||||
|
||||
fn visit_variant_seed<V>(
|
||||
fn variant_seed<V>(
|
||||
self,
|
||||
seed: V,
|
||||
) -> Result<(V::Value, VariantDeserializer<E>), Self::Error>
|
||||
@@ -1026,20 +1026,20 @@ mod content {
|
||||
err: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<'de, E> de::VariantVisitor<'de> for VariantDeserializer<E>
|
||||
impl<'de, E> de::VariantAccess<'de> for VariantDeserializer<E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_unit(self) -> Result<(), E> {
|
||||
fn deserialize_unit(self) -> Result<(), E> {
|
||||
match self.value {
|
||||
Some(value) => de::Deserialize::deserialize(ContentDeserializer::new(value)),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_newtype_seed<T>(self, seed: T) -> Result<T::Value, E>
|
||||
fn deserialize_newtype_seed<T>(self, seed: T) -> Result<T::Value, E>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1051,7 +1051,7 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
|
||||
fn deserialize_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
V: de::Visitor<'de>,
|
||||
{
|
||||
@@ -1064,7 +1064,7 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_struct<V>(
|
||||
fn deserialize_struct<V>(
|
||||
self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V,
|
||||
@@ -1134,13 +1134,13 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, E> de::SeqVisitor<'de> for SeqDeserializer<E>
|
||||
impl<'de, E> de::SeqAccess<'de> for SeqDeserializer<E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1180,13 +1180,13 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, E> de::MapVisitor<'de> for MapDeserializer<E>
|
||||
impl<'de, E> de::MapAccess<'de> for MapDeserializer<E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1199,7 +1199,7 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
|
||||
fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1391,14 +1391,14 @@ mod content {
|
||||
err: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<'de, 'a, E> de::EnumVisitor<'de> for EnumRefDeserializer<'a, E>
|
||||
impl<'de, 'a, E> de::EnumAccess<'de> for EnumRefDeserializer<'a, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
type Variant = VariantRefDeserializer<'a, Self::Error>;
|
||||
|
||||
fn visit_variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error>
|
||||
fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error>
|
||||
where
|
||||
V: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1419,20 +1419,20 @@ mod content {
|
||||
err: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<'de, 'a, E> de::VariantVisitor<'de> for VariantRefDeserializer<'a, E>
|
||||
impl<'de, 'a, E> de::VariantAccess<'de> for VariantRefDeserializer<'a, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_unit(self) -> Result<(), E> {
|
||||
fn deserialize_unit(self) -> Result<(), E> {
|
||||
match self.value {
|
||||
Some(value) => de::Deserialize::deserialize(ContentRefDeserializer::new(value)),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_newtype_seed<T>(self, seed: T) -> Result<T::Value, E>
|
||||
fn deserialize_newtype_seed<T>(self, seed: T) -> Result<T::Value, E>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1444,7 +1444,7 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
|
||||
fn deserialize_tuple<V>(self, _len: usize, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
V: de::Visitor<'de>,
|
||||
{
|
||||
@@ -1457,7 +1457,7 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_struct<V>(
|
||||
fn deserialize_struct<V>(
|
||||
self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V,
|
||||
@@ -1527,13 +1527,13 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a, E> de::SeqVisitor<'de> for SeqRefDeserializer<'a, E>
|
||||
impl<'de, 'a, E> de::SeqAccess<'de> for SeqRefDeserializer<'a, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1573,13 +1573,13 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a, E> de::MapVisitor<'de> for MapRefDeserializer<'a, E>
|
||||
impl<'de, 'a, E> de::MapAccess<'de> for MapRefDeserializer<'a, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
type Error = E;
|
||||
|
||||
fn visit_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1593,7 +1593,7 @@ mod content {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
|
||||
fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
|
||||
where
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -1678,7 +1678,7 @@ mod content {
|
||||
|
||||
fn visit_map<V>(self, _: V) -> Result<(), V::Error>
|
||||
where
|
||||
V: MapVisitor<'de>,
|
||||
V: MapAccess<'de>,
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+51
-51
@@ -292,7 +292,7 @@ fn deserialize_tuple(
|
||||
let dispatch = if let Some(deserializer) = deserializer {
|
||||
quote!(_serde::Deserializer::deserialize_tuple(#deserializer, #nfields, #visitor_expr))
|
||||
} else if is_enum {
|
||||
quote!(_serde::de::VariantVisitor::visit_tuple(__visitor, #nfields, #visitor_expr))
|
||||
quote!(_serde::de::VariantAccess::deserialize_tuple(__variant, #nfields, #visitor_expr))
|
||||
} else if nfields == 1 {
|
||||
let type_name = item_attrs.name().deserialize_name();
|
||||
quote!(_serde::Deserializer::deserialize_newtype_struct(__deserializer, #type_name, #visitor_expr))
|
||||
@@ -307,7 +307,7 @@ fn deserialize_tuple(
|
||||
let visitor_var = if all_skipped {
|
||||
quote!(_)
|
||||
} else {
|
||||
quote!(mut __visitor)
|
||||
quote!(mut __seq)
|
||||
};
|
||||
|
||||
quote_block! {
|
||||
@@ -326,8 +326,8 @@ fn deserialize_tuple(
|
||||
#visit_newtype_struct
|
||||
|
||||
#[inline]
|
||||
fn visit_seq<__V>(self, #visitor_var: __V) -> _serde::export::Result<Self::Value, __V::Error>
|
||||
where __V: _serde::de::SeqVisitor<'de>
|
||||
fn visit_seq<__A>(self, #visitor_var: __A) -> _serde::export::Result<Self::Value, __A::Error>
|
||||
where __A: _serde::de::SeqAccess<'de>
|
||||
{
|
||||
#visit_seq
|
||||
}
|
||||
@@ -364,7 +364,7 @@ fn deserialize_seq(
|
||||
let visit = match field.attrs.deserialize_with() {
|
||||
None => {
|
||||
let field_ty = &field.ty;
|
||||
quote!(try!(_serde::de::SeqVisitor::visit::<#field_ty>(&mut __visitor)))
|
||||
quote!(try!(_serde::de::SeqAccess::next_element::<#field_ty>(&mut __seq)))
|
||||
}
|
||||
Some(path) => {
|
||||
let (wrapper, wrapper_ty) = wrap_deserialize_with(
|
||||
@@ -372,7 +372,7 @@ fn deserialize_seq(
|
||||
quote!({
|
||||
#wrapper
|
||||
_serde::export::Option::map(
|
||||
try!(_serde::de::SeqVisitor::visit::<#wrapper_ty>(&mut __visitor)),
|
||||
try!(_serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq)),
|
||||
|__wrap| __wrap.value)
|
||||
})
|
||||
}
|
||||
@@ -501,7 +501,7 @@ fn deserialize_struct(
|
||||
}
|
||||
} else if is_enum {
|
||||
quote! {
|
||||
_serde::de::VariantVisitor::visit_struct(__visitor, FIELDS, #visitor_expr)
|
||||
_serde::de::VariantAccess::deserialize_struct(__variant, FIELDS, #visitor_expr)
|
||||
}
|
||||
} else {
|
||||
let type_name = item_attrs.name().deserialize_name();
|
||||
@@ -516,7 +516,7 @@ fn deserialize_struct(
|
||||
let visitor_var = if all_skipped {
|
||||
quote!(_)
|
||||
} else {
|
||||
quote!(mut __visitor)
|
||||
quote!(mut __seq)
|
||||
};
|
||||
|
||||
let visit_seq = if is_untagged {
|
||||
@@ -525,8 +525,8 @@ fn deserialize_struct(
|
||||
} else {
|
||||
Some(quote! {
|
||||
#[inline]
|
||||
fn visit_seq<__V>(self, #visitor_var: __V) -> _serde::export::Result<Self::Value, __V::Error>
|
||||
where __V: _serde::de::SeqVisitor<'de>
|
||||
fn visit_seq<__A>(self, #visitor_var: __A) -> _serde::export::Result<Self::Value, __A::Error>
|
||||
where __A: _serde::de::SeqAccess<'de>
|
||||
{
|
||||
#visit_seq
|
||||
}
|
||||
@@ -551,8 +551,8 @@ fn deserialize_struct(
|
||||
#visit_seq
|
||||
|
||||
#[inline]
|
||||
fn visit_map<__V>(self, mut __visitor: __V) -> _serde::export::Result<Self::Value, __V::Error>
|
||||
where __V: _serde::de::MapVisitor<'de>
|
||||
fn visit_map<__A>(self, mut __map: __A) -> _serde::export::Result<Self::Value, __A::Error>
|
||||
where __A: _serde::de::MapAccess<'de>
|
||||
{
|
||||
#visit_map
|
||||
}
|
||||
@@ -624,7 +624,7 @@ fn deserialize_externally_tagged_enum(
|
||||
Match(deserialize_externally_tagged_variant(params, variant, item_attrs),);
|
||||
|
||||
quote! {
|
||||
(__Field::#variant_name, __visitor) => #block
|
||||
(__Field::#variant_name, __variant) => #block
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -637,15 +637,15 @@ fn deserialize_externally_tagged_enum(
|
||||
// all variants have `#[serde(skip_deserializing)]`.
|
||||
quote! {
|
||||
// FIXME: Once we drop support for Rust 1.15:
|
||||
// let _serde::export::Err(__err) = _serde::de::EnumVisitor::visit_variant::<__Field>(__visitor);
|
||||
// let _serde::export::Err(__err) = _serde::de::EnumAccess::variant::<__Field>(__data);
|
||||
// _serde::export::Err(__err)
|
||||
_serde::export::Result::map(
|
||||
_serde::de::EnumVisitor::visit_variant::<__Field>(__visitor),
|
||||
_serde::de::EnumAccess::variant::<__Field>(__data),
|
||||
|(__impossible, _)| match __impossible {})
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
match try!(_serde::de::EnumVisitor::visit_variant(__visitor)) {
|
||||
match try!(_serde::de::EnumAccess::variant(__data)) {
|
||||
#(#variant_arms)*
|
||||
}
|
||||
}
|
||||
@@ -666,8 +666,8 @@ fn deserialize_externally_tagged_enum(
|
||||
_serde::export::Formatter::write_str(formatter, #expecting)
|
||||
}
|
||||
|
||||
fn visit_enum<__V>(self, __visitor: __V) -> _serde::export::Result<Self::Value, __V::Error>
|
||||
where __V: _serde::de::EnumVisitor<'de>
|
||||
fn visit_enum<__A>(self, __data: __A) -> _serde::export::Result<Self::Value, __A::Error>
|
||||
where __A: _serde::de::EnumAccess<'de>
|
||||
{
|
||||
#match_variant
|
||||
}
|
||||
@@ -807,7 +807,7 @@ fn deserialize_adjacently_tagged_enum(
|
||||
}
|
||||
|
||||
let mut missing_content = quote! {
|
||||
_serde::export::Err(<__V::Error as _serde::de::Error>::missing_field(#content))
|
||||
_serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#content))
|
||||
};
|
||||
if variants.iter().any(is_unit) {
|
||||
let fallthrough = if variants.iter().all(is_unit) {
|
||||
@@ -842,12 +842,12 @@ fn deserialize_adjacently_tagged_enum(
|
||||
|
||||
let visit_third_key = quote! {
|
||||
// Visit the third key in the map, hopefully there isn't one.
|
||||
match try!(_serde::de::MapVisitor::visit_key_seed(&mut __visitor, #tag_or_content)) {
|
||||
match try!(_serde::de::MapAccess::next_key_seed(&mut __map, #tag_or_content)) {
|
||||
_serde::export::Some(_serde::private::de::TagOrContentField::Tag) => {
|
||||
_serde::export::Err(<__V::Error as _serde::de::Error>::duplicate_field(#tag))
|
||||
_serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#tag))
|
||||
}
|
||||
_serde::export::Some(_serde::private::de::TagOrContentField::Content) => {
|
||||
_serde::export::Err(<__V::Error as _serde::de::Error>::duplicate_field(#content))
|
||||
_serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#content))
|
||||
}
|
||||
_serde::export::None => _serde::export::Ok(__ret),
|
||||
}
|
||||
@@ -888,24 +888,24 @@ fn deserialize_adjacently_tagged_enum(
|
||||
_serde::export::Formatter::write_str(formatter, #expecting)
|
||||
}
|
||||
|
||||
fn visit_map<__V>(self, mut __visitor: __V) -> _serde::export::Result<Self::Value, __V::Error>
|
||||
where __V: _serde::de::MapVisitor<'de>
|
||||
fn visit_map<__A>(self, mut __map: __A) -> _serde::export::Result<Self::Value, __A::Error>
|
||||
where __A: _serde::de::MapAccess<'de>
|
||||
{
|
||||
// Visit the first key.
|
||||
match try!(_serde::de::MapVisitor::visit_key_seed(&mut __visitor, #tag_or_content)) {
|
||||
match try!(_serde::de::MapAccess::next_key_seed(&mut __map, #tag_or_content)) {
|
||||
// First key is the tag.
|
||||
_serde::export::Some(_serde::private::de::TagOrContentField::Tag) => {
|
||||
// Parse the tag.
|
||||
let __field = try!(_serde::de::MapVisitor::visit_value(&mut __visitor));
|
||||
let __field = try!(_serde::de::MapAccess::next_value(&mut __map));
|
||||
// Visit the second key.
|
||||
match try!(_serde::de::MapVisitor::visit_key_seed(&mut __visitor, #tag_or_content)) {
|
||||
match try!(_serde::de::MapAccess::next_key_seed(&mut __map, #tag_or_content)) {
|
||||
// Second key is a duplicate of the tag.
|
||||
_serde::export::Some(_serde::private::de::TagOrContentField::Tag) => {
|
||||
_serde::export::Err(<__V::Error as _serde::de::Error>::duplicate_field(#tag))
|
||||
_serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#tag))
|
||||
}
|
||||
// Second key is the content.
|
||||
_serde::export::Some(_serde::private::de::TagOrContentField::Content) => {
|
||||
let __ret = try!(_serde::de::MapVisitor::visit_value_seed(&mut __visitor,
|
||||
let __ret = try!(_serde::de::MapAccess::next_value_seed(&mut __map,
|
||||
__Seed {
|
||||
field: __field,
|
||||
marker: _serde::export::PhantomData,
|
||||
@@ -921,14 +921,14 @@ fn deserialize_adjacently_tagged_enum(
|
||||
// First key is the content.
|
||||
_serde::export::Some(_serde::private::de::TagOrContentField::Content) => {
|
||||
// Buffer up the content.
|
||||
let __content = try!(_serde::de::MapVisitor::visit_value::<_serde::private::de::Content>(&mut __visitor));
|
||||
let __content = try!(_serde::de::MapAccess::next_value::<_serde::private::de::Content>(&mut __map));
|
||||
// Visit the second key.
|
||||
match try!(_serde::de::MapVisitor::visit_key_seed(&mut __visitor, #tag_or_content)) {
|
||||
match try!(_serde::de::MapAccess::next_key_seed(&mut __map, #tag_or_content)) {
|
||||
// Second key is the tag.
|
||||
_serde::export::Some(_serde::private::de::TagOrContentField::Tag) => {
|
||||
let __deserializer = _serde::private::de::ContentDeserializer::<__V::Error>::new(__content);
|
||||
let __deserializer = _serde::private::de::ContentDeserializer::<__A::Error>::new(__content);
|
||||
// Parse the tag.
|
||||
let __ret = try!(match try!(_serde::de::MapVisitor::visit_value(&mut __visitor)) {
|
||||
let __ret = try!(match try!(_serde::de::MapAccess::next_value(&mut __map)) {
|
||||
// Deserialize the buffered content now that we know the variant.
|
||||
#(#variant_arms)*
|
||||
});
|
||||
@@ -937,29 +937,29 @@ fn deserialize_adjacently_tagged_enum(
|
||||
}
|
||||
// Second key is a duplicate of the content.
|
||||
_serde::export::Some(_serde::private::de::TagOrContentField::Content) => {
|
||||
_serde::export::Err(<__V::Error as _serde::de::Error>::duplicate_field(#content))
|
||||
_serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#content))
|
||||
}
|
||||
// There is no second key.
|
||||
_serde::export::None => {
|
||||
_serde::export::Err(<__V::Error as _serde::de::Error>::missing_field(#tag))
|
||||
_serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#tag))
|
||||
}
|
||||
}
|
||||
}
|
||||
// There is no first key.
|
||||
_serde::export::None => {
|
||||
_serde::export::Err(<__V::Error as _serde::de::Error>::missing_field(#tag))
|
||||
_serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#tag))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_seq<__V>(self, mut __visitor: __V) -> _serde::export::Result<Self::Value, __V::Error>
|
||||
where __V: _serde::de::SeqVisitor<'de>
|
||||
fn visit_seq<__A>(self, mut __seq: __A) -> _serde::export::Result<Self::Value, __A::Error>
|
||||
where __A: _serde::de::SeqAccess<'de>
|
||||
{
|
||||
// Visit the first element - the tag.
|
||||
match try!(_serde::de::SeqVisitor::visit(&mut __visitor)) {
|
||||
match try!(_serde::de::SeqAccess::next_element(&mut __seq)) {
|
||||
_serde::export::Some(__field) => {
|
||||
// Visit the second element - the content.
|
||||
match try!(_serde::de::SeqVisitor::visit_seed(&mut __visitor,
|
||||
match try!(_serde::de::SeqAccess::next_element_seed(&mut __seq,
|
||||
__Seed {
|
||||
field: __field,
|
||||
marker: _serde::export::PhantomData,
|
||||
@@ -1041,7 +1041,7 @@ fn deserialize_externally_tagged_variant(
|
||||
Style::Unit => {
|
||||
let this = ¶ms.this;
|
||||
quote_block! {
|
||||
try!(_serde::de::VariantVisitor::visit_unit(__visitor));
|
||||
try!(_serde::de::VariantAccess::deserialize_unit(__variant));
|
||||
_serde::export::Ok(#this::#variant_ident)
|
||||
}
|
||||
}
|
||||
@@ -1156,7 +1156,7 @@ fn deserialize_externally_tagged_newtype_variant(
|
||||
let field_ty = &field.ty;
|
||||
quote_expr! {
|
||||
_serde::export::Result::map(
|
||||
_serde::de::VariantVisitor::visit_newtype::<#field_ty>(__visitor),
|
||||
_serde::de::VariantAccess::deserialize_newtype::<#field_ty>(__variant),
|
||||
#this::#variant_ident)
|
||||
}
|
||||
}
|
||||
@@ -1165,7 +1165,7 @@ fn deserialize_externally_tagged_newtype_variant(
|
||||
quote_block! {
|
||||
#wrapper
|
||||
_serde::export::Result::map(
|
||||
_serde::de::VariantVisitor::visit_newtype::<#wrapper_ty>(__visitor),
|
||||
_serde::de::VariantAccess::deserialize_newtype::<#wrapper_ty>(__variant),
|
||||
|__wrapper| #this::#variant_ident(__wrapper.value))
|
||||
}
|
||||
}
|
||||
@@ -1380,7 +1380,7 @@ fn deserialize_map(
|
||||
None => {
|
||||
let field_ty = &field.ty;
|
||||
quote! {
|
||||
try!(_serde::de::MapVisitor::visit_value::<#field_ty>(&mut __visitor))
|
||||
try!(_serde::de::MapAccess::next_value::<#field_ty>(&mut __map))
|
||||
}
|
||||
}
|
||||
Some(path) => {
|
||||
@@ -1388,14 +1388,14 @@ fn deserialize_map(
|
||||
params, field.ty, path);
|
||||
quote!({
|
||||
#wrapper
|
||||
try!(_serde::de::MapVisitor::visit_value::<#wrapper_ty>(&mut __visitor)).value
|
||||
try!(_serde::de::MapAccess::next_value::<#wrapper_ty>(&mut __map)).value
|
||||
})
|
||||
}
|
||||
};
|
||||
quote! {
|
||||
__Field::#name => {
|
||||
if _serde::export::Option::is_some(&#name) {
|
||||
return _serde::export::Err(<__V::Error as _serde::de::Error>::duplicate_field(#deser_name));
|
||||
return _serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#deser_name));
|
||||
}
|
||||
#name = _serde::export::Some(#visit);
|
||||
}
|
||||
@@ -1407,7 +1407,7 @@ fn deserialize_map(
|
||||
None
|
||||
} else {
|
||||
Some(quote! {
|
||||
_ => { let _ = try!(_serde::de::MapVisitor::visit_value::<_serde::de::IgnoredAny>(&mut __visitor)); }
|
||||
_ => { let _ = try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map)); }
|
||||
})
|
||||
};
|
||||
|
||||
@@ -1417,14 +1417,14 @@ fn deserialize_map(
|
||||
let match_keys = if item_attrs.deny_unknown_fields() && all_skipped {
|
||||
quote! {
|
||||
// FIXME: Once we drop support for Rust 1.15:
|
||||
// let _serde::export::None::<__Field> = try!(_serde::de::MapVisitor::visit_key(&mut __visitor));
|
||||
// let _serde::export::None::<__Field> = try!(_serde::de::MapAccess::next_key(&mut __map));
|
||||
_serde::export::Option::map(
|
||||
try!(_serde::de::MapVisitor::visit_key::<__Field>(&mut __visitor)),
|
||||
try!(_serde::de::MapAccess::next_key::<__Field>(&mut __map)),
|
||||
|__impossible| match __impossible {});
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
while let _serde::export::Some(__key) = try!(_serde::de::MapVisitor::visit_key::<__Field>(&mut __visitor)) {
|
||||
while let _serde::export::Some(__key) = try!(_serde::de::MapAccess::next_key::<__Field>(&mut __map)) {
|
||||
match __key {
|
||||
#(#value_arms)*
|
||||
#ignored_arm
|
||||
@@ -1577,7 +1577,7 @@ fn expr_is_missing(field: &Field, item_attrs: &attr::Item) -> Fragment {
|
||||
}
|
||||
Some(_) => {
|
||||
quote_expr! {
|
||||
return _serde::export::Err(<__V::Error as _serde::de::Error>::missing_field(#name))
|
||||
return _serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -6,8 +6,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use serde::de::{self, Deserialize, DeserializeSeed, EnumVisitor, IntoDeserializer, MapVisitor,
|
||||
SeqVisitor, VariantVisitor, Visitor};
|
||||
use serde::de::{self, Deserialize, DeserializeSeed, EnumAccess, IntoDeserializer, MapAccess,
|
||||
SeqAccess, VariantAccess, Visitor};
|
||||
use serde::de::value::{MapVisitorDeserializer, SeqVisitorDeserializer};
|
||||
|
||||
use error::Error;
|
||||
@@ -390,10 +390,10 @@ struct DeserializerSeqVisitor<'a, 'de: 'a> {
|
||||
end: Token,
|
||||
}
|
||||
|
||||
impl<'de, 'a> SeqVisitor<'de> for DeserializerSeqVisitor<'a, 'de> {
|
||||
impl<'de, 'a> SeqAccess<'de> for DeserializerSeqVisitor<'a, 'de> {
|
||||
type Error = Error;
|
||||
|
||||
fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Error>
|
||||
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Error>
|
||||
where
|
||||
T: DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -418,10 +418,10 @@ struct DeserializerMapVisitor<'a, 'de: 'a> {
|
||||
end: Token,
|
||||
}
|
||||
|
||||
impl<'de, 'a> MapVisitor<'de> for DeserializerMapVisitor<'a, 'de> {
|
||||
impl<'de, 'a> MapAccess<'de> for DeserializerMapVisitor<'a, 'de> {
|
||||
type Error = Error;
|
||||
|
||||
fn visit_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Error>
|
||||
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Error>
|
||||
where
|
||||
K: DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -432,7 +432,7 @@ impl<'de, 'a> MapVisitor<'de> for DeserializerMapVisitor<'a, 'de> {
|
||||
seed.deserialize(&mut *self.de).map(Some)
|
||||
}
|
||||
|
||||
fn visit_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Error>
|
||||
fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Error>
|
||||
where
|
||||
V: DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -451,11 +451,11 @@ struct DeserializerEnumVisitor<'a, 'de: 'a> {
|
||||
de: &'a mut Deserializer<'de>,
|
||||
}
|
||||
|
||||
impl<'de, 'a> EnumVisitor<'de> for DeserializerEnumVisitor<'a, 'de> {
|
||||
impl<'de, 'a> EnumAccess<'de> for DeserializerEnumVisitor<'a, 'de> {
|
||||
type Error = Error;
|
||||
type Variant = Self;
|
||||
|
||||
fn visit_variant_seed<V>(self, seed: V) -> Result<(V::Value, Self), Error>
|
||||
fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self), Error>
|
||||
where
|
||||
V: DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -477,10 +477,10 @@ impl<'de, 'a> EnumVisitor<'de> for DeserializerEnumVisitor<'a, 'de> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a> VariantVisitor<'de> for DeserializerEnumVisitor<'a, 'de> {
|
||||
impl<'de, 'a> VariantAccess<'de> for DeserializerEnumVisitor<'a, 'de> {
|
||||
type Error = Error;
|
||||
|
||||
fn visit_unit(self) -> Result<(), Error> {
|
||||
fn deserialize_unit(self) -> Result<(), Error> {
|
||||
match self.de.tokens.first() {
|
||||
Some(&Token::UnitVariant(_, _)) => {
|
||||
self.de.next_token();
|
||||
@@ -491,7 +491,7 @@ impl<'de, 'a> VariantVisitor<'de> for DeserializerEnumVisitor<'a, 'de> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_newtype_seed<T>(self, seed: T) -> Result<T::Value, Self::Error>
|
||||
fn deserialize_newtype_seed<T>(self, seed: T) -> Result<T::Value, Self::Error>
|
||||
where
|
||||
T: DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -505,7 +505,7 @@ impl<'de, 'a> VariantVisitor<'de> for DeserializerEnumVisitor<'a, 'de> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Error>
|
||||
fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Error>
|
||||
where
|
||||
V: Visitor<'de>,
|
||||
{
|
||||
@@ -534,7 +534,7 @@ impl<'de, 'a> VariantVisitor<'de> for DeserializerEnumVisitor<'a, 'de> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_struct<V>(self, fields: &'static [&'static str], visitor: V) -> Result<V::Value, Error>
|
||||
fn deserialize_struct<V>(self, fields: &'static [&'static str], visitor: V) -> Result<V::Value, Error>
|
||||
where
|
||||
V: Visitor<'de>,
|
||||
{
|
||||
@@ -589,10 +589,10 @@ impl<'a, 'de> EnumMapVisitor<'a, 'de> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a> MapVisitor<'de> for EnumMapVisitor<'a, 'de> {
|
||||
impl<'de, 'a> MapAccess<'de> for EnumMapVisitor<'a, 'de> {
|
||||
type Error = Error;
|
||||
|
||||
fn visit_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Error>
|
||||
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Error>
|
||||
where
|
||||
K: DeserializeSeed<'de>,
|
||||
{
|
||||
@@ -608,7 +608,7 @@ impl<'de, 'a> MapVisitor<'de> for EnumMapVisitor<'a, 'de> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Error>
|
||||
fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Error>
|
||||
where
|
||||
V: DeserializeSeed<'de>,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user