-
Notifications
You must be signed in to change notification settings - Fork 120
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
Add serde feature. #87
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.
This is a great PR!
I'm a little bit worried when I see Vec<_>
anywhere in this serialization code and I don't have time to review thoroughly right now. All of our buffers should be fixed length and should fit nicely on the stack. Will revisit this later.
Cargo.toml
Outdated
@@ -15,9 +15,14 @@ repository = "https://github.com/ebfull/pairing" | |||
rand = "0.4" | |||
byteorder = "1" | |||
clippy = { version = "0.0.200", optional = true } | |||
serde = { version = "1.0.66", optional = true } |
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.
Why not 1.0
?
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'll change it.
("1.0.66
" has the same meaning as "1.0
", except that it excludes versions earlier than 1.0.66
. I usually write it that way because I haven't tried it with versions earlier than when I introduced the dependency, and I don't know how any of the bugs fixed since then would affect the crate.)
Cargo.toml
Outdated
|
||
[features] | ||
unstable-features = ["expose-arith"] | ||
expose-arith = [] | ||
serialization-serde = ["serde"] |
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.
Can the feature be called serde
without violating recommended practices?
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.
Then Cargo complains:
Features and dependencies cannot have the same name: `serde`
Maybe use-serde
? serde-support
? Not sure whether those are much better.
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.
You don't need to have an explicit feature; when a crate is declared as an optional dependency it becomes an implicit feature: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
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.
Thank you! I changed it to "serde
".
I tried to write generic group and field [de]serialization code, and then reuse it for the specific But I found a better solution for the fields, at least, since the bytes in For the groups it's not that easy, though, since |
I'd also like to require e.g. |
I've been busy travelling but this PR is on my TODO list. |
Two things:
|
It seems like it would be better to implement a wrapper around the types |
I agree, the conditionally compiled trait bounds were a bad idea. Yes, we're currently using a wrapper. Another option is providing a serialization module for I still think the most convenient and straightforward way to provide serialization is to implement the serde traits directly for the types themselves. But feel free to close this PR if you'd prefer one of the other approaches. I'm happy to try and implement them. |
The Rust API guidelines also recommend to just implement |
☔ The latest upstream changes (presumably #90) made this pull request unmergeable. Please resolve the merge conflicts. |
I resolved the merge conflict. Please let me know if you want me to make any other changes. |
Can you add Serialize and Deserialize to |
For that it would be really convenient to use
|
Serde has a feature "derive" which exposes the serde_derive macro from within serde itself; maybe that can help? |
You're right, thanks! I added it. |
Closes #86