pub trait MapVisitor {
type Error: Error;
// Required methods
fn visit_key<K>(&mut self) -> Result<Option<K>, Self::Error>
where K: Deserialize;
fn visit_value<V>(&mut self) -> Result<V, Self::Error>
where V: Deserialize;
fn end(&mut self) -> Result<(), Self::Error>;
// Provided methods
fn visit<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>
where K: Deserialize,
V: Deserialize { ... }
fn size_hint(&self) -> (usize, Option<usize>) { ... }
fn missing_field<V>(
&mut self,
field: &'static str,
) -> Result<V, Self::Error>
where V: Deserialize { ... }
}Expand description
MapVisitor visits each item in a sequence.
This is a trait that a Deserializer passes to a Visitor implementation.
Required Associated Types§
Required Methods§
Sourcefn visit_key<K>(&mut self) -> Result<Option<K>, Self::Error>where
K: Deserialize,
fn visit_key<K>(&mut self) -> Result<Option<K>, Self::Error>where
K: Deserialize,
This returns a Ok(Some(key)) for the next key in the map, or Ok(None) if there are no
more remaining items.
Sourcefn visit_value<V>(&mut self) -> Result<V, Self::Error>where
V: Deserialize,
fn visit_value<V>(&mut self) -> Result<V, Self::Error>where
V: Deserialize,
This returns a Ok(value) for the next value in the map.
Provided Methods§
Sourcefn visit<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>where
K: Deserialize,
V: Deserialize,
fn visit<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>where
K: Deserialize,
V: Deserialize,
This returns a Ok(Some((key, value))) for the next (key-value) pair in the map, or
Ok(None) if there are no more remaining items.
Sourcefn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
Return the lower and upper bound of items remaining in the sequence.
Sourcefn missing_field<V>(&mut self, field: &'static str) -> Result<V, Self::Error>where
V: Deserialize,
fn missing_field<V>(&mut self, field: &'static str) -> Result<V, Self::Error>where
V: Deserialize,
Report that there
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.