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