-
Notifications
You must be signed in to change notification settings - Fork 123
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
Rusty byte strings in RON, deprecate base64 (byte) strings #438
Conversation
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #438 +/- ##
==========================================
+ Coverage 95.33% 96.10% +0.76%
==========================================
Files 75 77 +2
Lines 9054 9868 +814
==========================================
+ Hits 8632 9484 +852
+ Misses 422 384 -38
☔ View full report in Codecov by Sentry. |
This comment was marked as outdated.
This comment was marked as outdated.
5a4b2c7
to
bfcb50c
Compare
I don't think you should ever remove the base64 deserialization code. Some people probably have RON files stored somewhere that they can't easily modify, and they need them to work. |
Thank you for your feedback @bestouff! Do you think the one of the above-described workarounds of moving the base64 encoding to the data type definition would work in your case? If not, I hope we can figure out a solution for your case. |
Since no additional concerns have been voiced so far, I will merge this PR over the coming days. @bestouff I would like to ensure that your concern about backwards compatibility is sufficiently resolved before base64 deserialisation is fully disabled (in v0.10 or later if necessary). Do you think that one of the above-described workarounds of moving the base64 encoding to the data type definition would work in your case? |
Co-authored-by: Sebastian Dröge <[email protected]>
… user-side types
fb31cef
to
a073fe4
Compare
Breaking: Rusty byte strings in RON, deprecate base64 (byte) strings
ron has for now encoded byte-slices and byte-bufs as base64-encoded strings. While this works perfectly fine when ron deserialises a document using type hints (i.e. when
Deserializer::deserialize_byte_buf
orDeserializer::deserialize_bytes
are called), #436 has shown that it breaks down when ron is asked to deserialise bytes in a self-describing document. This issue occurs whenDeserializer::deserialize_any
is called, for instance, if the byte string is inside a#[serde(untagged)]
enum.This issue presents an opportunity to transition ron from using ambiguous base64 (byte) strings to using Rusty byte strings. For instance, the Rust value
b"Hello ron!"
is now encoded as the equivalent ron valueb"Hello ron!"
(instead of"SGVsbG8gcm9uIQ=="
as before). ron's new Rusty byte strings follow the updated escape rules for Rust's byte strings from rust-lang/rfcs#3349 (assuming that the RFC will be accepted).Request for Comment
As this is a breaking change in ron's format, that will affect user's of ron over a transition from v0.9 to v0.10 (see below), we would like to hear your thoughts on the transition and how to make it easier on you before we merge this PR.
What changes in v0.9?
Serialising
In the next breaking release of ron, v0.9, all calls to
Serializer::serialize_bytes
will output Rusty byte strings instead of base64-encoded strings.Deserialising
In the next breaking release of ron, v0.9, all calls to
Deserializer::deserialize_byte_buf
andDeserializer::deserialize_bytes
will accept both Rusty byte strings and base64-encoded (byte) strings. ron'sError::Base64Error
variant will be deprecated, and will be removed in v0.10.Value
ron's
Value
type gains a newValue::Bytes(Vec<u8>)
variant to store an owned byte buffer.What changes in v0.10?
One breaking release after the introduction of Rusty byte strings, base64-encoded (byte) strings will no longer be accepted during deserialising. The
Error::Base64Error
variant will be removed. However, ron may still produce non-generic error messages when deserialising a byte string and coming across a normal string that looks like it may be base64-encoded.How can I continue using base64-encoded (byte) strings?
If you would like to retain the original behaviour and continue to use (now strongly typed) base64 strings, you will need to change the
Serialize
implementation of your byte value, e.g. using one of the following crates (non-exhaustive and without endorsement from ron):serde_with
:base64
module contains several helper types, which can be used in a, e.g.,#[serde_as(as = "Base64")] v: Vec<u8>
annotation, uses a custom base64 implementationbase64-serde
:base64_serde_type
macro generates a new wrapper type, usesbase64
serde_bytes_base64
:Bytes
wrapper type, usesbase64
With this PR, we have also provided a new example (
examples/base64.rs
) of continuing to use base64-encoded bytes with ron. In this example, twoserde
helpers are implemented which showcaseFinal notes
Fixes #436
TODOs
Value
behaviourCHANGELOG.md
parse.rs
,error.rs
coverage can be handled separately