-
Notifications
You must be signed in to change notification settings - Fork 959
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
Pass the error to inject_listener_closed method #1517
Conversation
If there is an error when the listener closes, found in the `NetworkEvent::ListenerClosed` `reason` field, we would like to pass it on to the `inject_listener_closed()` method so that implementors of this method have access to it. Add an error parameter to `inject_listener_closed`. Convert the `reason` field from a `Result` to an `Option` and if there is an error pass `Some(error)` at the method call site.
swarm/src/behaviour.rs
Outdated
@@ -130,7 +130,7 @@ pub trait NetworkBehaviour: Send + 'static { | |||
} | |||
|
|||
/// A listener closed. | |||
fn inject_listener_closed(&mut self, _id: ListenerId) { | |||
fn inject_listener_closed(&mut self, _id: ListenerId, _err: Option<std::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.
Could you leave the Result
for consistency with the rest of the library?
fn inject_listener_closed(&mut self, _id: ListenerId, _err: Option<std::io::Error>) { | |
fn inject_listener_closed(&mut self, _id: ListenerId, reason: Result<(), 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.
Sure thing, can do.
After the merge conflicts are fixed we get left with this (buggy) code:
The compiler error is that reason (due to the error being |
Please pass the error by reference to |
I took the liberty to finish the change, I hope that's ok. |
Face palm - obviously. Thanks for finishing it. FTR feel free to take, modify, paraphrase, or drop anything I contribute. I'm just here to learn a bit and help out where it helps :) Thanks. |
If there is an error when the listener closes, found in the
NetworkEvent::ListenerClosed
reason
field, we would like to pass it on to theinject_listener_closed()
method so that implementors of this method have access to it.Add an error parameter to
inject_listener_closed
. Convert thereason
field from aResult
to anOption
and if there is an error passSome(error)
at the method call site.Resolves: #1475