Closed fschutt closed 7 years ago
This code is in a way redundant because all the interfaces that load
and save
are using right now are public. One doesn’t have to work with files. If the content to parse is already in memory, one can instantiate Parser
directly. Similarly, if the content is to be stored in memory, one can just rely on Display
to that end. However, these two new functions, read
and write
, might be useful in order to make it more obvious. They can be handy shortcuts just as load
and save
are.
Should have fixed the styling issues. No idea how to test the save method, there's no documentation on how to actually get "Node" elements. Somehow I need a Node, which is only implemented for Element, but I can't get any elements from the read document, only "Events" - it's a convoluted mess.
If you could fix that, that'd be great, because I don't know how to read a document and then immediately save it again, the documentation isn't clear enough.
Thanks for your work!
Regarding save
, I’m not sure why you wanted to test it as technically you hadn’t touched it. Did you mean write
? In any case, Node
is implemented for a bunch of structs, and you can create an Element
yourself as it is shown in the first example given in the documentation. Or have I misunderstood you?
Added
open_from()
andsave_to
methods to load anything that implementsstd::io::Read
. Does not break existing code. Needed for streaming SVG / being generic over the input method.