-
Notifications
You must be signed in to change notification settings - Fork 960
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: Fix StreamMuxer::Error
to io::Error
#2664
core/muxing: Fix StreamMuxer::Error
to io::Error
#2664
Conversation
StreamMuxer::Error
to io::ErrorStreamMuxer::Error
to io::Error
799dbdb
to
a402553
Compare
We are already enforcing that the associated type must convert to `io::Error`. We might as well just make all functions return an `io::Error` directly.
a402553
to
e865d40
Compare
yamux::ConnectionError::Io(e) => e, | ||
e => io::Error::new(io::ErrorKind::Other, e), | ||
} | ||
fn to_io_error(e: yamux::ConnectionError) -> io::Error { |
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.
fn to_io_error(e: yamux::ConnectionError) -> io::Error { | |
fn into_io_error(e: yamux::ConnectionError) -> io::Error { |
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.
Good thinking! Will include in libp2p/rust-yamux#135.
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.
Replaced with upstreaming an API change: libp2p/rust-yamux#135 |
Re-opening because there was a misunderstanding in what will be upstreamed. |
I'd like to merge #2703 before I start fixing the conflicts here, also because this depends on libp2p/rust-yamux#136. |
Technically it doesn't depend on it actually but it would make sense to only touch this code once and use the upstream |
Sorry for only commenting now. I am undecided whether I agree with the reasoning. I don't expect many people to implement I am guessing the argument here is that the concrete error would not bubble up all the way to the user anyways? |
The argument is that we are already forcing the associated In |
Third option would be to not have a trait bound, but instead in rust-libp2p/core/src/transport/boxed.rs Line 85 in 04f31cd
rust-libp2p/core/src/transport/boxed.rs Lines 137 to 139 in 04f31cd
Not saying that this is the best solution (if the inner error also has a io::Error variant it would still wap it in an |
I think this is actually my favourite out of all the proposed ideas. What do you think @mxinden? This would also improve consistency within the codebase. Thanks for the pointer @elenaf9, I should have really looked at |
I like #2710 the best.
Would it be worth including this in #2710 as well? In other words, would it be worth it delegating into-io-error-conversion to the error itself by requiring |
Closing this in favor of #2710. |
I am not a fan. |
But what if the inner error is already an |
Then it will effectively behave as that |
👍 Sounds good. Thanks for explaining @thomaseizinger! |
Description
We are already enforcing that the associated type must convert to
io::Error
. We might as well just make all functions return anio::Error
directly.Links to any relevant issues
Open Questions
Change checklist