mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-26 16:21:39 +00:00
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:
@ -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))
|
||||
|
Reference in New Issue
Block a user