Commit graph

21 commits

Author SHA1 Message Date
lumi
c5c8dee20a Get rid of IntoElements, replace it with Into<Node> and <T: Into<Node> IntoIterator<Item = T>. This is a backwards-incompatible change, but should require minimal changes.
Doing this splits the `append` method in `ElementBuilder` into two methods. `append` now appends exactly one node, while `append_all` appends an iterator of nodes.

Add `remove_child`, which removes the first child that has a specific name and namespace, then returns it if it exists.

Add a lot of convenience methods on `Node`: `as_text_mut`, `as_element_mut`, `into_text`, `into_element`.
2018-12-23 15:42:50 +01:00
Valentin Lorentz
f1f5f5df11 Fix doc to reflect the switch from xml-rs to quick-xml. 2018-06-23 12:06:18 +00:00
Emmanuel Gil Peyrot
236582b24e update quick_xml and migrate from error-chain to failure 2018-02-18 20:45:09 +01:00
Astro
b141559081 rename namespaces mod to namespace_set 2017-08-13 17:29:38 +02:00
Astro
0148790a01 move NamespaceSet to namespaces mod 2017-08-13 02:35:24 +02:00
Bastien Orivel
9cec9fce9b Replace xml-rs by quick_xml
quick_xml is way faster than xml-rs

Here is an example with a quick atom parser:
    With xml-rs:
        test parse_factorio_atom ... bench:   3,295,678 ns/iter (+/- 165,851)
    With quick_xml:
        test parse_factorio_atom ... bench:     203,215 ns/iter (+/- 13,485)

Unfortunately I had to break the API for this change to happen.
* Element::from_reader now takes `R: BufRead` instead of `R: Read`
* Element::write_to now takes `W: io::Write` instead of `EventWriter<W: Write>`

This migration also allow us to have a write_to function which assumes
we're already in a given namespace (see `write_to_in_namespace`).
2017-06-10 17:17:19 +02:00
lumi
9d45230c17 should re-export more things under the error module 2017-05-22 19:30:52 +02:00
lumi
508c971416 port error.rs to error_chain, bump version to 0.4.0 2017-05-22 19:20:01 +02:00
Emmanuel Gil Peyrot
875b95bdc9 Reexport ElementEmitter from the lib. 2017-04-30 23:46:29 +01:00
Bastien Orivel
f87e2442d4 Use a BTreeMap<String, String> instead of a Vec<Attribute> to store attributes
This way we don't need to reimplement PartialEq for Element. It's also
way easier to get an attribute by name as we don't need to iterate over
every attribute to see if it exists.

The only side effect is that now, in the Debug output, attributes are
automatically sorted by names instead of being sorted by insertion
order.

Fixes #4
2017-04-26 23:44:58 +02:00
lumi
7c04aff416 overhauling the library, made tests pass 2017-03-08 20:34:17 +01:00
lumi
112b3fa0c8 added documentation url and fixed a dumb mistake 2017-02-25 15:43:56 +01:00
lumi
9a00c998ae add a test for an issue with namespace propagation 2017-02-25 00:10:18 +01:00
lumi
0a45a6993e document all the things! 2017-02-21 15:46:06 +01:00
lumi
e0b35477cd add ElementBuilder::text 2017-02-20 23:58:44 +01:00
lumi
41e1cf2654 added has_child, fixed some warnings 2017-02-20 02:04:45 +01:00
lumi
663eba6754 implemented text, get_child and get_child_mut; added and updated some tests 2017-02-19 23:42:31 +01:00
lumi
2d97e2d5d9 put Attribute into its own module, take into account prefixes when determining namespaces 2017-02-19 23:29:19 +01:00
lumi
8663a14040 lots of fixes and simplifications of the API 2017-02-19 23:15:43 +01:00
lumi
fda38ff242 add child iterators and fix up some of the tests, which still do not pass (yet) 2017-02-19 21:45:51 +01:00
lumi
28045361f3 initial commit 2017-02-19 20:46:44 +01:00