Trait MapAccess
trait MapAccess<'de>
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.
Lifetime
The 'de lifetime of this trait is the lifetime of data that may be
borrowed by deserialized map entries. See the page Understanding
deserializer lifetimes for a more detailed explanation of these lifetimes.
Example implementation
The example data format presented on the website demonstrates an
implementation of MapAccess for a basic JSON data format.
Associated Types
type Error: TraitBound { trait_: Path { path: "Error", id: Id(217), args: None }, generic_params: [], modifier: None }The error type that can be returned if some error occurs during deserialization.
Required Methods
fn next_key_seed<K>(self: &mut Self, seed: K) -> Result<Option<<K as >::Value>, <Self as >::Error> where K: DeserializeSeed<'de>This returns
Ok(Some(key))for the next key in the map, orOk(None)if there are no more remaining entries.Deserializeimplementations should typically useMapAccess::next_keyorMapAccess::next_entryinstead.fn next_value_seed<V>(self: &mut Self, seed: V) -> Result<<V as >::Value, <Self as >::Error> where V: DeserializeSeed<'de>This returns a
Ok(value)for the next value in the map.Deserializeimplementations should typically useMapAccess::next_valueinstead.Panics
Calling
next_value_seedbeforenext_key_seedis incorrect and is allowed to panic or return bogus results.
Provided Methods
fn next_entry_seed<K, V>(self: &mut Self, kseed: K, vseed: V) -> Result<Option<(<K as >::Value, <V as >::Value)>, <Self as >::Error> where K: DeserializeSeed<'de>, V: DeserializeSeed<'de>This returns
Ok(Some((key, value)))for the next (key-value) pair in the map, orOk(None)if there are no more remaining items.MapAccessimplementations should override the default behavior if a more efficient implementation is possible.Deserializeimplementations should typically useMapAccess::next_entryinstead.fn next_key<K>(self: &mut Self) -> Result<Option<K>, <Self as >::Error> where K: Deserialize<'de>This returns
Ok(Some(key))for the next key in the map, orOk(None)if there are no more remaining entries.This method exists as a convenience for
Deserializeimplementations.MapAccessimplementations should not override the default behavior.fn next_value<V>(self: &mut Self) -> Result<V, <Self as >::Error> where V: Deserialize<'de>This returns a
Ok(value)for the next value in the map.This method exists as a convenience for
Deserializeimplementations.MapAccessimplementations should not override the default behavior.Panics
Calling
next_valuebeforenext_keyis incorrect and is allowed to panic or return bogus results.fn next_entry<K, V>(self: &mut Self) -> Result<Option<(K, V)>, <Self as >::Error> where K: Deserialize<'de>, V: Deserialize<'de>This returns
Ok(Some((key, value)))for the next (key-value) pair in the map, orOk(None)if there are no more remaining items.This method exists as a convenience for
Deserializeimplementations.MapAccessimplementations should not override the default behavior.fn size_hint(self: &Self) -> Option<usize>Returns the number of entries remaining in the map, if known.
Implementors
impl<'de, A> MapAccess for &mut Aimpl<'de, I, E> MapAccess for MapDeserializer<'de, I, E>