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

Fix serialization of structs #205

Closed
wants to merge 2 commits into from
Closed

Conversation

crusty-dave
Copy link

Attributes were being created as child elements.

This works correctly if the simple types that should be attributes are
kept at the beginning of the struct and the more complex types that
should be children are after all of the simple types.

To solve this correctly, there should probably be two Vecs, one for the
attributes and one for the children.

Attributes were being created as child elements.

This works correctly if the simple types that should be attributes are
kept at the beginning of the struct and the more complex types that
should be children are after all of the simple types.

To solve this correctly, there should probably be two Vecs, one for the
attributes and one for the children.
instead of #[cfg(feature = "failed_test")] to disable failing tests.
@tafia
Copy link
Owner

tafia commented Mar 29, 2020

Thanks for the PR!!
I'm reviewing it, there are some points I don't really like but I don't have better alternative so far. Thank you for the time you spent on that I know serde related code is not the simplest one to look at.

@crusty-dave
Copy link
Author

crusty-dave commented Mar 29, 2020

Note, to solve this correctly, there should probably be two Vecs, one for the attributes and one for the children.

serialize_field() would need to collect the Vecs, then end() would serialize the result.

The problem with that is Serialize cannot be used to create a trait object.

If someone wanted to integrate the erased-serde crate, they could probably make that work.

@spikespaz
Copy link

I wish I had the knowledge to merge this. It's too old.

@Mingun Mingun added the serde Issues related to mapping from Rust types to XML label May 21, 2022
@Mingun
Copy link
Collaborator

Mingun commented Oct 29, 2022

Since merging #490 the attributes should be marked explicitly in structs, by prepending @ character to name of field (this is also work for internally and adjacently tagged enum representations).

@Mingun Mingun closed this Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
serde Issues related to mapping from Rust types to XML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants