quick-xml icon indicating copy to clipboard operation
quick-xml copied to clipboard

quick-xml requires implicitly enabled `serde/derive`

Open loyd opened this issue 1 year ago • 6 comments

It's impossible to depend on quick-xml/serialize without depending on serde/derive

Details: #472

loyd avatar Sep 08 '22 05:09 loyd

@loyd , could you please describe, how you faced with this problem? You tried to use quick-xml in a crate with resolver="2" field?

Mingun avatar Sep 08 '22 08:09 Mingun

I've fixed fixnum to support <tag>42.42</tag> parsing (by implementing visit_map). fixnum doesn't use serde/derive.

So, now it's fixed by enabling serde/derive.

But it also requires serde/derive in dev-dependencies, but it's inconvenient and allows to fail in the future (because not all feature combinations are checked by clippy, a lot of them).

loyd avatar Sep 08 '22 09:09 loyd

Btw, next_key() cannot parse into &str (and next_value() too until v0.24 version). But it's a subject of another issue.

loyd avatar Sep 08 '22 09:09 loyd

I've almost done with rewriting

Btw, next_key() cannot parse into &str (and next_value() too until v0.24 version). But it's a subject of another issue.

Yes, that is known problem

I've fixed fixnum to support <tag>42.42</tag> parsing (by implementing visit_map).

The problem with map is that deserialization performed using deserialize_any. It have many drawbacks for non-self-describing deserializers and deserializers with weak type systems. XML has only two types: string and map, and <tag>42.42</tag> is mapped to map!["$value" -> "42.42"].

Unfortunately, your code will break in one of next quick-xml release, because I plan to rename $value key to #text (actually split it into #text and #content as described in https://github.com/tafia/quick-xml/issues/383#issuecomment-1120244201).

Mingun avatar Sep 08 '22 10:09 Mingun

@loyd, can you please post exact instruction, what I should do to reproduce that? I didn't see a resolver="2" field in the fixnum Cargo.toml

Mingun avatar Sep 08 '22 15:09 Mingun

The problem with map is that deserialization performed using deserialize_any. It have many drawbacks for non-self-describing deserializers and deserializers with weak type systems.

Yep, a previous version uses deserialize_str for human-readable formats. But I need to support both parsing from str and from f64, so I've changed to deserialize_any.

Unfortunately, your code will break in one of next quick-xml release, because I plan to rename $value key to #text

It's ok, just specify it in the changelog explicitly.

@loyd, can you please post exact instruction, what I should do to reproduce that? I didn't see a resolver="2" field in the fixnum Cargo.toml

resolver="2" is for facing the problem in quick-xml. So, steps (in quick-xml repo):

  • Add resolver = "2" to quick-xml (or edition = "2021").
  • Run cargo clippy --features serde

It works fine with v1 because there is serde/derive dev-dep

loyd avatar Sep 09 '22 05:09 loyd