Add ability to get spans of deserialized values

Open
#695 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
backend

Research direction

Start with the deserialization documentation at https://docs.rs/quick-xml/latest/quick_xml/de/ and trace how deserialized values are produced to determine where input offsets could be exposed. The issue gives no file or test entry point, so first locate the deserialization implementation and its tests. Done means deserialization provides precise input locations for values through an accessible API; the issue does not specify the API shape.

Written by the indexing model from the issue text.

Description

enhancement help wanted serde

In one of my projects I have to parse and strictly validate XML input coming from other programs and humans, and the latter (understandably) insist on getting decent error messages (e.g. "at 'position' attribute X references an object called 'Y' which is not defined anywhere", "unexpected child Z at 'position', allowed child items are A,B and C").

As of now I use roxmltree and codespan-reporting, but I'd love to switch to an xml library with derivation support - you can imagine a lot of code could be substituted with just using quick-xml.

To satisfy the "nice error messages" requirement I need the precise locations of everything, though. I have scrolled through the deserialization docs, but could not find any mention of access to positions when using deserialization. Did I miss anything or is this not possible right now? Could you expose the offset in the input through e.g. generated getters?

Dominant language
Rust
Stars
1.6k
Forks
299
Avg merge
2d 4h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tafia/quick-xml

All issues in tafia/quick-xml

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.