Skip to content

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.

@elrnv elrnv force-pushed the binary-support4 branch from 81936c3 to d66f823 Compare July 21, 2024 23:47
@Mingun Mingun added enhancement serde Issues related to mapping from Rust types to XML labels Jul 22, 2024
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