RReverser / serde-xml-rs

xml-rs based deserializer for Serde (compatible with 1.0+)
https://crates.io/crates/serde-xml-rs
MIT License
270 stars 90 forks source link

Cannot round trip through serde #130

Open Plecra opened 4 years ago

Plecra commented 4 years ago

Here's a minimal example:

#[derive(Debug, Serialize, Deserialize)]
struct Foo;
#[derive(Debug, Serialize, Deserialize)]
struct Bar {
    foo: Foo,
}
serde_xml_rs::from_str::<Bar>(
    &serde_xml_rs::to_string(&Bar {
        foo: Foo
    }).unwrap())
.unwrap();
punkstarman commented 4 years ago

Yeah, I think that this is not the only example.

@dtolnay, once told me that round-tripping wasn't all that useful in practice.

@Plecra, what is your motivation for requiring this?

Plecra commented 4 years ago

Any communication between users of this crate would require the data to properly round trip through the serialised format. That might be saving a collection to disk, or sending a packet over the network.

It's also a big factor in usability - the user might be interacting with some API that has a Bar type in their data model, and if you can't rely on serialisation and deserialisation behaving the same way, you'd need to write two definitions of the same type.

...is what I would've said, but it seems so obvious to me that there might be some reason it doesn't apply here?

punkstarman commented 4 years ago

@Plecra, I agree with you.