-
Notifications
You must be signed in to change notification settings - Fork 116
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
Use base64 for serde_bytes
annotated fields
#109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a great improvement. Thank you for the PR!
We should bump the minor version of the crate for this is a breaking change, technically.
@torkleyy do you want to review as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very active currently. Let's bump the version and merge this :)
I'm glad you find this PR interesting! Is there anything I could do to help push this forward? |
6834ddc
to
82c7550
Compare
@kvark no problem, I was just checking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last concern, how can we recognize a bytes value in deserialize_any
?
@torkleyy I'm not quite sure about this. I think |
The problem is that even though there's a `Value::Bytes` variant, it will
never be the result of a deserialization.
…On Fri, Jun 8, 2018, 11:00 François Laignel ***@***.***> wrote:
@torjkleyy I'm not quite sure about this. I think base64 handling should
only be selected when user explicitly uses Bytes/_buf. I'll take a deeper
look at this tomorrow.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#109 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AWFFuT1J_fo7nj5hiLDaWhuYMUFPwG0pks5t6j0QgaJpZM4UVOFQ>
.
|
ac9d0c5
to
e4f4b4b
Compare
I marked the |
e4f4b4b
to
d34b86d
Compare
The problem is that this violates the following assumption: (value -> serialization -> deserialization) == value |
AFAIU, you will get the same value if the origin and target |
Yes, with fields this holds, but not with |
With the following `struct`, `small` will be represented as an array of `u8` and `large` as a base64 `String`. ``` rust extern crate serde_derive; extern crate serde; extern crate serde_bytes; struct BytesStruct { small: Vec<u8>, #[serde(with = "serde_bytes")] large: Vec<u8>, } ```
d34b86d
to
c106c76
Compare
I think I got it:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good solution to me! Thanks!
@kvark Do you still approve the PR with the new changes? |
109: Use base64 for `serde_bytes` annotated fields r=torkleyy a=fengalin With the following `struct`, `small` will be represented as an array of `u8` and `large` as a base64 `String`. ``` rust extern crate serde_derive; extern crate serde; extern crate serde_bytes; #[derive(Serialize, Deserialize)] struct BytesStruct { small: Vec<u8>, #[serde(with = "serde_bytes")] large: Vec<u8>, } ``` Co-authored-by: François Laignel <fengalin@free.fr>
Build succeeded |
With the following
struct
,small
will be represented as an array ofu8
andlarge
as a base64String
.