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

Rust: serde json encode VecM<u8> for XDR strings as strings #125

Assignees

Comments

@leighmcculloch
Copy link
Member

The Rust generated code stores XDR strings as vectors of u8's because Rust's definition of a string is strictly UTF8, where-as the XDR definition is loose supporting any byte sequences.

However, for the serde JSON encoding of the XDR it would be ideal if the fields designated as strings could be rendered as Strings.

This raises the question: What should the serde serialization do if the vector of u8's contains non-UTF8 sequences? Should it:

  • Panic.
  • Convert lossy.

Alternatively: Is there a way in Rust we could render a string in the serde JSON output that is not UTF8 safe by reverting to displaying \xAB style characters. This would be preferable because it would preserve the encoding, while still allowing us to optimize for human friendly string rendering.

This issue is similar and in the same category of work as #118 and #119.

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