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.
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 generic trait to combine UnixListener and TcpListener #4385
Add generic trait to combine UnixListener and TcpListener #4385
Changes from 12 commits
4305804
69b0379
cd1ddf9
9bda024
d0dba7a
c2ec467
8afdc3e
75dcc76
4a46da1
fe231ec
812dfa5
a538f0b
e194407
b639d98
27912b7
316f015
61bd0fa
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Hmm. It's unfortunate that the types here allow it return stuff like
(Left(io), Right(addr))
even though it wont in practice. Ideas?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.
Wow I'm so blind I didn't even notice.
Yes you're right in practice this will never happen. If someones use
match
on the Result, they will need to make unreachable branches just for that. It's stupid..... 🤔 I will think about it... but I don't see a solution right now.
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.
Probably making yet another
Either
specialized for Listener could solve the issue.I noticed the
Either
type is something not universal anyway: tokio-util has one but tower also has its own: https://docs.rs/tower/latest/tower/util/enum.Either.htmlI assume we could have a "
EitherListener
" with apoll_accept
method that would returnResult<Either<(IoLeft, AddrLeft), (IoRight, AddrRight)>>
. The enum itself would look like this I guess:I don't think the user absolutely "needs" to use tokio-util's
Either
, it could definitely be something more specialized. wdyt?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'm not convinced that adding an
EitherListener
enum changes anything here?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.
EitherListener
would not implementListener
, it would have its own method with their own signaturesThere 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.
That would work too but not super elegant I guess...
Good point
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.
Ok I replaced the Listener impl on Either by custom methods here: b55b62c3
Unfortunately the accept Future struct is slightly different so I had to duplicate some code.
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 just make it an async fn and drop the poll function? We don't need these tricks when it's not a trait method.
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.
🤯
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.
Done in 316f015