Trait serde::de::MapAccess
[−]
[src]
pub trait MapAccess<'de> { type Error: Error; fn next_key_seed<K>(&mut self,
seed: K)
-> Result<Option<K::Value>, Self::Error> where K: DeserializeSeed<'de>; fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error> where V: DeserializeSeed<'de>; fn next_entry_seed<K, V>(&mut self,
kseed: K,
vseed: V)
-> Result<Option<(K::Value, V::Value)>, Self::Error> where K: DeserializeSeed<'de>, V: DeserializeSeed<'de> { ... } fn next_key<K>(&mut self) -> Result<Option<K>, Self::Error> where K: Deserialize<'de> { ... } fn next_value<V>(&mut self) -> Result<V, Self::Error> where V: Deserialize<'de> { ... } fn next_entry<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error> where K: Deserialize<'de>, V: Deserialize<'de> { ... } fn size_hint(&self) -> Option<usize> { ... } }
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.
Associated Types
Required Methods
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error> where K: DeserializeSeed<'de>
This returns Ok(Some(key))
for the next key in the map, or Ok(None)
if there are no more remaining entries.
Deserialize
implementations should typically use
MapAccess::next_key
or MapAccess::next_entry
instead.
fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error> where V: DeserializeSeed<'de>
This returns a Ok(value)
for the next value in the map.
Deserialize
implementations should typically use
MapAccess::next_value
instead.
Panics
Calling next_value_seed
before next_key_seed
is incorrect and is
allowed to panic or return bogus results.
Provided Methods
fn next_entry_seed<K, V>(&mut self,
kseed: K,
vseed: V)
-> Result<Option<(K::Value, V::Value)>, Self::Error> where K: DeserializeSeed<'de>, V: DeserializeSeed<'de>
kseed: K,
vseed: V)
-> Result<Option<(K::Value, V::Value)>, Self::Error> where K: DeserializeSeed<'de>, 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.
MapAccess
implementations should override the default behavior if a
more efficient implementation is possible.
Deserialize
implementations should typically use
MapAccess::next_entry
instead.
fn next_key<K>(&mut self) -> Result<Option<K>, Self::Error> where K: Deserialize<'de>
This returns Ok(Some(key))
for the next key in the map, or Ok(None)
if there are no more remaining entries.
This method exists as a convenience for Deserialize
implementations.
MapAccess
implementations should not override the default behavior.
fn next_value<V>(&mut self) -> Result<V, Self::Error> where V: Deserialize<'de>
This returns a Ok(value)
for the next value in the map.
This method exists as a convenience for Deserialize
implementations.
MapAccess
implementations should not override the default behavior.
Panics
Calling next_value
before next_key
is incorrect and is allowed to
panic or return bogus results.
fn next_entry<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error> where K: Deserialize<'de>, V: Deserialize<'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.
This method exists as a convenience for Deserialize
implementations.
MapAccess
implementations should not override the default behavior.
fn size_hint(&self) -> Option<usize>
Returns the number of entries remaining in the map, if known.
Implementors
impl<'de, I, E> MapAccess<'de> for MapDeserializer<'de, I, E> where I: Iterator,
I::Item: Pair,
I::Item::First: IntoDeserializer<'de, E>,
I::Item::Second: IntoDeserializer<'de, E>,
E: Errorimpl<'de, 'a, A> MapAccess<'de> for &'a mut A where A: MapAccess<'de>