Don't allow handlers::poll() to return None (#811)

This commit is contained in:
Pierre Krieger
2019-01-02 14:22:23 +01:00
committed by GitHub
parent f903e2b744
commit 2c2fc8bfd3
14 changed files with 97 additions and 82 deletions

View File

@ -497,9 +497,7 @@ where
fn poll(
&mut self,
) -> Poll<
Option<
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>,
>,
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>,
io::Error,
> {
// Special case if shutting down.
@ -512,7 +510,7 @@ where
}
if self.substreams.is_empty() {
return Ok(Async::Ready(None));
return Ok(Async::Ready(ProtocolsHandlerEvent::Shutdown));
} else {
return Ok(Async::NotReady);
}
@ -526,10 +524,10 @@ where
match advance_substream(substream, self.config) {
(Some(new_state), Some(event), _) => {
self.substreams.push(new_state);
return Ok(Async::Ready(Some(event)));
return Ok(Async::Ready(event));
}
(None, Some(event), _) => {
return Ok(Async::Ready(Some(event)));
return Ok(Async::Ready(event));
}
(Some(new_state), None, false) => {
self.substreams.push(new_state);