-
Notifications
You must be signed in to change notification settings - Fork 1
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
Make supplying a serializer the user's responsibility #33
Conversation
@dvdplm This PR is kind of experimental, so I would like to know your opinion on
|
With this option, I'm currently stuck at trying to figure out a way to pass the type-erased deserializer to |
42deda1
to
40384d8
Compare
Pull Request Test Coverage Report for Build 11587348171Details
💛 - Coveralls |
40384d8
to
ddd45da
Compare
ddd45da
to
b486c6e
Compare
Update: implemented dynamic (de)serializers. The downsides are the following:
The performance can be improved if we use static deserialization on the session level, but that requires writing down the scary bound described above in more places. The alternative to all that is parametrizing |
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 tricky. My gut tells me that this shouldn't be this hard and that we're missing something. I'm not saying this as a critique of this PR specifically: it was complex before as well.
Are we applying the wrong abstraction? Are we missing a layer somewhere, something like a super-session
object that orchestrates the protocol, the wire format and session params? Should ser/deser even be a concern for manul
at all?
Besides these philosophical concerns I think this PR improves some code and worsens other parts. Lugging around extra arguments is noisy but we gain some of that back from having a simpler setup and a better isolation in the form of the Format
trait. I think maybe there's some polishing possible here and there, but my biggest concern is that the type erased stuff is complex. Is it too complex though?
Overall I don't think my concerns are blockers for merging – it wasn't pretty before and it isn't pretty now – but I think we should open issues with bincode
and rmp-serde
to check if they would accept PRs.
I personally blame
We have to serialize messages to sign/verify them, so as long as that's a part of
It is complex, but that complexity is mostly hidden from the users. Completely hidden for the protocol writers, somewhat hidden for the session runners - if they fix In any case I think the previous situation, where the format was the choice of the protocol, was unacceptable and had to be fixed in some way.
Certainly, once this PR is in, I'll do that, unless you want to. |
714e94a
to
355c5da
Compare
355c5da
to
3a7b009
Compare
Simplify Deserializer logic Add JSON format Simplify signature serialization/deserialization Adjust generic bounds Fix deps
3a7b009
to
e1cab5e
Compare
So, the new version manages to avoid scary high-ranked bounds, and won't need too much changes in |
Fixes #26
The problem here is somehow bringing the serializer through the object-safe API (of
ObjectSafeRound
) so that the user could call it in the methods ofRound
responsible for handling messages.What we want is for the user to provide two methods
and pass those methods to methods of
Round
somehow.It is possible to do with
serialize
, viaerased-serde
: inRound::make_direct_message()
we wrap someMessage: Serialize
intoBox<dyn erased_serde::Serialize>
and pass to the session level, which can apply the user-providedserialize
to it. But it seems to be impossible to do withdeserialize
, unless the user can instead provide an object implementingserde::Deserializer
, which can then be wrapped inBox<dyn erased_serde::Deserializer>
and passed toRound::receive_message
. Unfortunately, most popular libraries do not expose such an object (a rare example of a library that does isserde_json
).This PR introduces a
Format
trait, and a type of that trait inSessionParameters
. Now it can be either made an additional generic parameter ofRound
- the downside is a more complicated API for both protocol writers and protocol users. Or we could go theBox<dyn erased_serde::Deserializer>
way, make a PR to the libraries we plan to use exposing theDeserializer
, and let users who want other formats deal with format implementors themselves. This PR implements the latter.TODO:
format.rs
, sinceFormat
itself should be exported inmanul::session
, butSerializer
/Deserializer
should be exported inmanul::protocol
.