mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-27 00:47:54 +00:00
Adds serializer format specific field names
Allows different field names to be used for different external formats.
Field names are specified using the `rename` field attribute, e.g:
#[serde(rename(xml= "a4", json="a5"))]
Reverts #62
Addresses #61
This commit is contained in:
@@ -113,6 +113,10 @@ pub trait Deserializer {
|
||||
{
|
||||
self.visit(visitor)
|
||||
}
|
||||
|
||||
fn fmt() -> &'static str {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -463,6 +463,11 @@ impl<Iter> de::Deserializer for Deserializer<Iter>
|
||||
Err(self.error(ErrorCode::ExpectedSomeValue))
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn fmt() -> &'static str {
|
||||
"json"
|
||||
}
|
||||
}
|
||||
|
||||
struct SeqVisitor<'a, Iter: 'a + Iterator<Item=io::Result<u8>>> {
|
||||
|
||||
@@ -256,6 +256,11 @@ impl<W, F> ser::Serializer for Serializer<W, F>
|
||||
try!(self.formatter.colon(&mut self.writer));
|
||||
value.serialize(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn fmt() -> &'static str {
|
||||
"json"
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Formatter {
|
||||
|
||||
@@ -571,6 +571,11 @@ impl ser::Serializer for Serializer {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn fmt() -> &'static str {
|
||||
"value"
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Deserializer {
|
||||
@@ -677,6 +682,11 @@ impl de::Deserializer for Deserializer {
|
||||
None => Ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn fmt() -> &'static str {
|
||||
"value"
|
||||
}
|
||||
}
|
||||
|
||||
struct SeqDeserializer<'a> {
|
||||
|
||||
@@ -179,6 +179,10 @@ pub trait Serializer {
|
||||
fn visit_map_elt<K, V>(&mut self, key: K, value: V) -> Result<(), Self::Error>
|
||||
where K: Serialize,
|
||||
V: Serialize;
|
||||
|
||||
fn fmt() -> &'static str {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SeqVisitor {
|
||||
|
||||
Reference in New Issue
Block a user