How to deserializes into generic struct that includes element name

Abierto
#778 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
rust
Área
backend

Línea de trabajo

Start by reading the deserialization code and tests for mapping XML elements into structs; the issue does not name specific files or tests. Check whether the element name can be exposed as a field while preserving generic deserialization, then add a focused test using a MaterialX style node graph. Done means the deserialized node retains its element name and the test passes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

serde

I'm trying to parse MaterialX files like this one. They include "node graphs" which are a list of different elements with quite similar attributes and child elements.

As I don't know what elements to expect up front (they can be defined by external definition files), my idea was to have a generic Node struct and deserialize into that and then process it at a later stage. This works -- but I lose access to the element name. Is there a way to add it in as a field, e.g. using #[serde(rename = "$element-name")]?

If you can point me at the right place I'd be happy to make a PR.

Lenguaje dominante
Rust
Estrellas
1.6k
Forks
299
Merge medio
2 d 4 h
PR fusionados (30 d)
9

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tafia/quick-xml

Todos los issues de tafia/quick-xml

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.