-
Notifications
You must be signed in to change notification settings - Fork 993
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
core/muxing: Have functions on StreamMuxer
take Pin<&mut Self>
#2765
Conversation
This is the idiomatic way of defining `poll`-based interfaces in Rust despite introducing a bit of inconvenience. To work around this inconvenience, we also introduce a `StreamMuxerExt` trait allows for better integration with async-await style code and adds a `_unpin` variant to for each `poll` function of the `StreamMuxer`.
Now that the `StreamMuxer` interface has `Pin<&mut Self>` receivers, we can drop the `Mutex` from the yamux implementation.
StreamMuxer
take Pin<&mut Self>
Co-authored-by: Elena Frank <[email protected]>
The muxer is useless after polling `poll_close` to completion, thus we can consume `self` in the extension trait method which allows us to use the function within `libp2p_swarm::Connection`.
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.
🙏 thanks for the patch using Pin
.
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.
Wonderful to see this happening! 🙏
@elenaf9 any objections to me merging here with the discussion on #2722 (comment) in mind? I think we want to take |
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.
👍
Description
This is the idiomatic way of doing
poll
interface in Rust.Links to any relevant issues
#2722
Depends on #2763.
Depends on #2764.
Depends on #2775.
Depends on #2776.
Open Questions
Change checklist