xml icon indicating copy to clipboard operation
xml copied to clipboard

enum deserialization

Open oli-obk opened this issue 10 years ago • 4 comments

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.

oli-obk avatar May 26 '15 19:05 oli-obk

@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.

RReverser avatar Feb 13 '17 15:02 RReverser

@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.

oli-obk avatar Feb 13 '17 15:02 oli-obk

@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 avatar Feb 13 '17 15:02 RReverser

@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.

RReverser avatar Feb 17 '17 17:02 RReverser