-
Notifications
You must be signed in to change notification settings - Fork 27
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
Adding serde support feature for Mpz #30
base: master
Are you sure you want to change the base?
Conversation
I’m not sure it makes sense as a global default to serialize to hexadecimal. |
Yes I agree. In my use case it ends up being serialized to JSON and propagated to an upper layer. Hex is good for readability. What would you suggest? |
At least Python and Java will happily serialize a big integer to JSON as an unquoted decimal number: 808017424794512875886459904961710757005754368000000000 which is perfectly fine as far as the JSON grammar is concerned, even though such values will not (yet?) round-trip through JavaScript. There is also a de facto convention of sending quoted decimal numbers where JavaScript interoperability is important: "808017424794512875886459904961710757005754368000000000" Twitter notably decided screw it, we’ll do both. You can of course override the default behavior to whatever you want with a newtype wrapper, so the question here is what makes sense as a default. I think unquoted decimal makes the most sense for Rust, which doesn’t have to worry about confusing big integers as approximate floats. Quoted decimal would be an understandable compromise if there are good reasons for it. But I don’t know of any widespread convention involving hexadecimal, and I’d find it especially strange to see hexadecimal without a |
Serde support + zeroizing Mpz on drop
You made this PR from your |
This breaks existing projects that are dependent on this crate via git
We needed serde for Mpz in one of our upper layer (dependency). Here is a PR if you are interested, I added it as a feature.
Thanks,