Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialize enums by attribute (similar to SerDe tag attribute) #195

Open
gtemkin opened this issue Oct 14, 2024 · 0 comments
Open

Deserialize enums by attribute (similar to SerDe tag attribute) #195

gtemkin opened this issue Oct 14, 2024 · 0 comments

Comments

@gtemkin
Copy link

gtemkin commented Oct 14, 2024

Is it possible to deserialize enums by an attribute, not by name, similar to what SerDe tag attribute does?

<parent>
  <child type="A" attr1="" attr2=""/>
  <child type="B" attr3="" attr4=""/>
</parent>
struct Parent {
  children: Vec<Child>
}

enum Child {
  A { attr1: String, attr2: String },
  B { attr3: String, attr4: String }
}

I have a lot of those Child elements, they all share about 3 attributes, but have all other attributes and inner elements are different, so it is hard to create a common structure that cover them all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant