Skip to content
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

Implement ser/der for QueuePairEndpoint #7

Merged
merged 5 commits into from
Apr 10, 2021

Conversation

iwahbe
Copy link
Contributor

@iwahbe iwahbe commented Mar 31, 2021

Make QueuePairEndpoint serializable.

I use the same essential strategy (and some of the code) as @kuenishi. The reason we can't just slap a #[derive(Serialize, Deserialize)] is that QueuePairEndpoint contains a C style union, which serde does not want to mess with. I get around this by providing idiomatic conversions from/to PortableQPEndpoint, and telling serde to use PortableQPEndpoint as an intermediary for serialization and deserialization.

For a larger struct, you could implement custom serializers and deserializers, but this copy strategy works well for small structs.

I also implement fmt::Debug and PartialEq for QueuePairEndpoint.

Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm a little worried about forcing the interpretation of ibv_gid as a globalraw is there for a reason. Is there maybe a way we can expose this in a way where the user has to assert that their QueuePairEndpoint is in fact using global before they can use it with PortableQPEndpoint?

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@iwahbe iwahbe requested a review from jonhoo April 1, 2021 05:31
Encode that `Gid` is really just a `[u8;16]`. We also just apply
`serde` directly to `QueuePairEndpoint` without exposing any
implementation types. We can do this because `serde` can be applied to
`Gid`.
src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@iwahbe iwahbe requested a review from jonhoo April 8, 2021 01:27
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Make some recommended changes for conversion traits.
@iwahbe iwahbe requested a review from jonhoo April 8, 2021 06:54
Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sticking with all my requests for changes. Looks great now! 👍

@jonhoo jonhoo merged commit 5aeb58f into jonhoo:master Apr 10, 2021
@jonhoo
Copy link
Owner

jonhoo commented Apr 10, 2021

Released in 0.4.5 and 0.5.0!

@iwahbe iwahbe deleted the serialize-qpendpoint-try2 branch April 10, 2021 05:26
@jonhoo jonhoo mentioned this pull request Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants