-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Generate and use structs to serialize requests. #439
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0e5f89f
Give explicit lifetimes to non-Connection object request parameters.
khuey af24c57
Generate and use Request structs to do serialization of X requests.
khuey b0f9467
Use Self::opcode().
khuey 07be126
Please clippy.
khuey 86af536
Fix more clippy warnings.
khuey fd094b9
Consume `conn` in xproto serialize methods and remove allow-unused an…
khuey 37385b9
Introduce some type aliases to please clippy.
khuey 5272f24
Revert to the previous behavior for opcode constants.
khuey 8e158fa
Fix clippy's complaints about lifetimes in send_event.
khuey d863fb6
Fix spelling.
khuey 6885036
Fix clippy warning on extension trait method.
khuey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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 could do both: Have a
pub const
and then have anopcode()
method (that just returnsENABLE_REQUEST
instead of0
in this case).Would that make sense? (I came up with this proposal when I saw the diff for
multithread_test
which changes amatch
into a series ofif
)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.
Yeah I think it can make sense (see my comment at the top of the thread). Want me to do 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.
Yup, please do.
It just occurred to me: This also makes sense for symmetry with errors and events. They also have this constant.
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.
What about using associated constants?
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.
Google finds https://doc.rust-lang.org/edition-guide/rust-2018/trait-system/associated-constants.html which says that associated constants needs Rust 1.20
Edit: Which is great, since that's less than 1.37 and so we can use that.
Follow-up question would be: Should the existing opcodes be turned into associated constants as well?
Follow-follow-up question would be: Should that be done in this PR or shall we just open an issue about 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.
If we want this, we will have to revert #391
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've reverted to the previous way of having a global unassociated constant.
If you wanted to do associated constants I think it makes sense to do it for requests, events, and replies all at the same time.