Skip to content

How to deserializes into generic struct that includes element name #778

Open
@killercup

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    serdeIssues related to mapping from Rust types to XML

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions