tafia / quick-xml

Rust high performance xml reader and writer
MIT License
1.22k stars 238 forks source link

recommendations for chaining Readers and Writers #828

Closed jokeyrhyme closed 4 weeks ago

jokeyrhyme commented 1 month ago

Howdie

Firstly, thanks so much for sharing this project, it's incredibly useful <3

I have a use case where I have a series of transformations that I'd like to apply to an XML document prior to deserializing it with serde

At the moment, I'm holding the entire document in a String, feeding it into a Reader, looping over read_event(), writing the desired events out into a Writer<Cursor<Vec<u8>>>, and then pulling that out into String/str and feeding that into the next Reader, and so on

I can't help but feel that there's got to be a more pull-based approach where the serde deserializer pulls events from the final transformer, and that transformer pulls events from the transformer before it, and so on, so that I'm holding as few copies of the XML document in memory as possible

Do you have any advice or recommendations or examples for how to accomplish this?

Cheers <3

Mingun commented 4 weeks ago

Currently Deserializer has no API to take a stream of events and deserialize from it. That addition would be welcome. Task in such form is a duplicate of #611, so I close it.