Question: name as attribute with serde

Aperta
#715 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust

Direzione di ricerca

The issue gives a Rust struct and the XML shape it needs, but names no quick-xml files or tests. Read the Serde serialization documentation and examples to find how struct fields map to XML elements and attributes; then check whether the requested mapping is supported. Done means identifying a straightforward representation for the shown XML or documenting the limitation and the needed change.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

question serde

I have a struct like:

struct Foo {
    one: String,
    two: String,
}

and I want XML like:

<foo>
    <item name="one">value of string 1</item>
    <item name="two">value of string 2</item>
</foo>

I don't see a easy way to do this kind of thing with quick-xml's serde option — my experiments have been using PhantomData to create a Item<K, V> type where the K is a PhantomData<K> with a custom trait to hold the name, and then I use the serde with attribute, but that feels quite messy and annoying. Is there a easy way to represent this? (I wouldn't choose to use XML like this, but the API I'm using does, unfortunately...)

Lingua principale
Rust
Stelle
1.6k
Fork
299
Merge medio
2g 4h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tafia/quick-xml

Tutte le issue di tafia/quick-xml

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.