mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-11-12 02:37:06 +00:00
Pass struct field names to deserializer
This commit is contained in:
1 parent
affa9382be
commit
5dae700aec
6 files changed
+120
-46
No files matched your search
+11
-4
@@ -229,7 +229,10 @@ pub trait Deserializer {
|
||||
/// This method hints that the `Deserialize` type is expecting a struct. This allows
|
||||
/// deserializers to parse sequences that aren't tagged as maps.
|
||||
#[inline]
|
||||
fn visit_struct<V>(&mut self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
|
||||
fn visit_struct<V>(&mut self,
|
||||
_name: &str,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit_map(visitor)
|
||||
@@ -576,7 +579,9 @@ pub trait VariantVisitor {
|
||||
}
|
||||
|
||||
/// `visit_map` is called when deserializing a struct-like variant.
|
||||
fn visit_map<V>(&mut self, _visitor: V) -> Result<V::Value, Self::Error>
|
||||
fn visit_map<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
_visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor
|
||||
{
|
||||
Err(Error::syntax_error())
|
||||
@@ -602,10 +607,12 @@ impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
|
||||
(**self).visit_seq(visitor)
|
||||
}
|
||||
|
||||
fn visit_map<V>(&mut self, visitor: V) -> Result<V::Value, T::Error>
|
||||
fn visit_map<V>(&mut self,
|
||||
fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, T::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
(**self).visit_map(visitor)
|
||||
(**self).visit_map(fields, visitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -649,7 +649,9 @@ impl<Iter> de::VariantVisitor for Deserializer<Iter>
|
||||
de::Deserializer::visit(self, visitor)
|
||||
}
|
||||
|
||||
fn visit_map<V>(&mut self, visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_map<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
try!(self.parse_object_colon());
|
||||
|
||||
@@ -792,7 +792,9 @@ impl<'a> de::VariantVisitor for SeqDeserializer<'a> {
|
||||
de::Deserializer::visit(self, visitor)
|
||||
}
|
||||
|
||||
fn visit_map<V>(&mut self, visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_map<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
de::Deserializer::visit(self, visitor)
|
||||
@@ -901,7 +903,9 @@ impl<'a> de::VariantVisitor for MapDeserializer<'a> {
|
||||
de::Deserializer::visit(self, visitor)
|
||||
}
|
||||
|
||||
fn visit_map<V>(&mut self, visitor: V) -> Result<V::Value, Error>
|
||||
fn visit_map<V>(&mut self,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
de::Deserializer::visit(self, visitor)
|
||||
|
||||
Reference in new issue
Block a user