Introduce type-based linking of requests and replies#86
Merged
Conversation
This ensures that `PollClient::request` always matches the correct Request and Reply This patch also fixes #84 and replaces the `From` that used `unreachable_unchecked` with `TryFrom`.
Contributor
Author
|
I wonder if this checking could also be used on the backend side. |
Member
|
What do you think about dropping the |
Contributor
Author
|
It gets confusing to have multiple types named I removed it in 79ccc04 |
Member
|
I generally agree, but for associated types I think re-using existing names is fine (e. g. |
Member
|
This is super cool, it always bugged me that these types were not matched on a type level. |
robin-nitrokey
approved these changes
Feb 1, 2023
nickray
reviewed
Feb 1, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This ensures that
PollClient::requestalways matches the correct Request and ReplyThis patch also fixes #84 and replaces the
Fromthat usedunreachable_uncheckedwithTryFrom.The main additions are the traits:
And PollClient's
requestbecomesThis also showed that the reply type for the
RemoveDirwas incorrect (it returnedRemoveDirAll) which actually triggered UB is mentionned in #84