MapValueAccess

Trait MapValueAccess 

Source
pub trait MapValueAccess<'de>: Sized {
    type Error: Error;
    type Key: MapKeyAccess<'de, Error = Self::Error, Value = Self>;

    // Required method
    fn next_value_seed<S>(
        self,
        seed: S,
    ) -> Result<(S::Value, Option<Self::Key>), Self::Error>
       where S: DeserializeSeed<'de>;

    // Provided methods
    fn next_value<T>(self) -> Result<(T, Option<Self::Key>), Self::Error>
       where T: Deserialize<'de> { ... }
    fn size_hint(&self) -> Option<usize> { ... }
}
Expand description

Move-oriented version of serde::de::MapAccess for getting values associated with keys.

A MapValueAccess object is returned alongside a key from a call to next_key, if the map wasn’t empty. It can be used to retrieve the value associated with that key, and additionally returns a new MapKeyAccess that can be used to retrieve the next entry from the map.

This trait otherwise is identical to its serde counterpart and serves the same purpose; see those docs for details (though note that accessing keys and entries is handled separately through the MapKeyAccess trait.)

Required Associated Types§

Source

type Error: Error

The type that can be returned if an error occurs during deserialization.

Source

type Key: MapKeyAccess<'de, Error = Self::Error, Value = Self>

The value accessor associated with this key accessor. A call to next_value will also return a Key object, which can be used to retrieve the next key from the map.

Required Methods§

Source

fn next_value_seed<S>( self, seed: S, ) -> Result<(S::Value, Option<Self::Key>), Self::Error>
where S: DeserializeSeed<'de>,

This returns the next value from the map, associated with the previously accessed key. It additionally returns an optional key_access object which can be used to retrieve additional keys from the map, if any.

The seed allows for passing data into a Deserialize implementation at runtime; typically it makes more sense to call next_value.

Provided Methods§

Source

fn next_value<T>(self) -> Result<(T, Option<Self::Key>), Self::Error>
where T: Deserialize<'de>,

This returns the next value from the map, associated with the previously accessed key. It additionally returns an optional key_access object which can be used to retrieve additional keys from the map, if any.

Source

fn size_hint(&self) -> Option<usize>

Returns the number of entries remaining in the map, if known. Note that, because this returns the number of entries, the value associated with this particular MapValueAccess should not be included.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'de, K, V> MapValueAccess<'de> for SubordinateValue<V, K>
where V: Deserializer<'de>, K: MapKeyAccess<'de, Value = Self, Error = V::Error>,

Source§

type Error = <V as Deserializer<'de>>::Error

Source§

type Key = K