serde-deprecated / xml

No longer maintained
35 stars 9 forks source link

enum deserialization #4

Open oli-obk opened 9 years ago

oli-obk commented 9 years ago

not as easy as i expected.

initial implementation at https://github.com/serde-rs/xml/blob/master/src/de/mod.rs#L302-343

messy with tuple like enums since arrays of those are totally weird in xml.

RReverser commented 7 years ago

@oli-obk Could you elaborate a bit more on how they're weird?

E.g. I have following snippet:

<action id="1" name="IsMatchingQuote" line="8" col="28"><text> </text><char></char><text> == state-&gt;quote </text></action>

And I want Action(Vec<ActionBodyItem>) to parse each element as enum variant (ActionBodyItem::Text(" "), ActionBodyItem::Char, ActionBodyItem::Text(" == state->quote ")). This seems to be quite straightforward, but perhaps I'm missing some edge cases.

oli-obk commented 7 years ago

@RReverser I'm not sure right now. I need to update to serde 0.9 and see if I can simplify the code. It's probably overly complex.

RReverser commented 7 years ago

@oli-obk Yeah, that's another issue I've got hit with, but downgraded my code to be compatible with 0.8 for now, and then found out that enums don't work.

RReverser commented 7 years ago

@oli-obk So, as said in another thread, implemented this in serde-xml-rs as it was easier than to migrate existing code to Serde 0.9 and then add missing features. Please let me know if you would like to merge efforts or something.