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

Serde support for serializing and deserializing binary blobs in XML files #788

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

elrnv
Copy link
Contributor

@elrnv elrnv commented Jul 21, 2024

This is another attempt to support binary blobs in serde, needed for vtkio.

This attempts to address #623
While initial support was added #783 this adds it for the serde api.

This PR also adjusts how trimming is handled in the serde API since this is important when dealing with binary. I tried to be consistent with the event based Reader/Writer APIs.

Please inspect the test failures to evaluate if this makes sense.

@Mingun Mingun added enhancement serde Issues related to mapping from Rust types to XML labels Jul 22, 2024
src/de/mod.rs Outdated
Comment on lines 2247 to 2256
match e
.unescape_with(|entity| self.entity_resolver.resolve(entity))
.map(|res| self.drain_text(res))
{
Ok(x) => x,
// failed to escape treat as binary blob.
Err(_) => Ok(DeEvent::Binary(Binary {
text: e.into_inner(),
})),
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely shouldn't rely on luck here. Binary should be explicitly requested for the field via flag in field name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the best way/mechanism to maintain context in the code to keep track of flags like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement serde Issues related to mapping from Rust types to XML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants