Use UpgradeError::into_io_error (#709)

* Use UpgradeError::into_io_error

* Update core/src/transport/upgrade.rs

Co-Authored-By: dvdplm <dvdplm@gmail.com>

* Update core/src/transport/upgrade.rs

Co-Authored-By: dvdplm <dvdplm@gmail.com>
This commit is contained in:
David
2018-11-30 08:34:04 +01:00
committed by Pierre Krieger
parent 090ecb88e4
commit b269d6184e

View File

@ -22,7 +22,7 @@ use futures::prelude::*;
use multiaddr::Multiaddr;
use crate::{
transport::Transport,
upgrade::{OutboundUpgrade, InboundUpgrade, UpgradeInfo, apply_inbound, apply_outbound}
upgrade::{OutboundUpgrade, InboundUpgrade, UpgradeInfo, apply_inbound, apply_outbound, UpgradeError}
};
use tokio_io::{AsyncRead, AsyncWrite};
@ -60,9 +60,9 @@ where
match self.inner.dial(addr.clone()) {
Ok(outbound) => {
let future = outbound
.and_then(move |x| apply_outbound(x, upgrade).map_err(|e| {
std::io::Error::new(std::io::ErrorKind::Other, e)
}));
.and_then(move |x| {
apply_outbound(x, upgrade).map_err(UpgradeError::into_io_error)
});
Ok(Box::new(future))
}
Err((dialer, addr)) => Err((Upgrade::new(dialer, upgrade), addr))
@ -77,9 +77,9 @@ where
.map(move |(future, addr)| {
let upgrade = upgrade.clone();
let future = future
.and_then(move |x| apply_inbound(x, upgrade).map_err(|e| {
std::io::Error::new(std::io::ErrorKind::Other, e)
}));
.and_then(move |x| {
apply_inbound(x, upgrade).map_err(UpgradeError::into_io_error)
});
(Box::new(future) as Box<_>, addr)
});
Ok((Box::new(stream), addr))