diff --git a/core/src/lib.rs b/core/src/lib.rs
index 1da254b7..288053c1 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -222,9 +222,9 @@ extern crate tokio_io;
pub extern crate multiaddr;
mod connection_reuse;
-mod either;
mod peer_id;
+pub mod either;
pub mod muxing;
pub mod swarm;
pub mod transport;
diff --git a/core/src/upgrade/choice.rs b/core/src/upgrade/choice.rs
index b1a163d3..de87f6a8 100644
--- a/core/src/upgrade/choice.rs
+++ b/core/src/upgrade/choice.rs
@@ -19,7 +19,6 @@
// DEALINGS IN THE SOFTWARE.
use bytes::Bytes;
-use either::EitherOutput;
use futures::prelude::*;
use multiaddr::Multiaddr;
use std::io::Error as IoError;
@@ -39,11 +38,11 @@ pub fn or(me: A, other: B) -> OrUpgrade {
#[derive(Debug, Copy, Clone)]
pub struct OrUpgrade(A, B);
-impl ConnectionUpgrade for OrUpgrade
+impl ConnectionUpgrade for OrUpgrade
where
C: AsyncRead + AsyncWrite,
- A: ConnectionUpgrade,
- B: ConnectionUpgrade,
+ A: ConnectionUpgrade,
+ B: ConnectionUpgrade,
{
type NamesIter = NamesIterChain;
type UpgradeIdentifier = EitherUpgradeIdentifier;
@@ -56,7 +55,7 @@ where
}
}
- type Output = EitherOutput;
+ type Output = O;
type Future = EitherConnUpgrFuture;
#[inline]
@@ -98,12 +97,12 @@ pub enum EitherConnUpgrFuture {
Second(B),
}
-impl Future for EitherConnUpgrFuture
+impl Future for EitherConnUpgrFuture
where
- A: Future,
- B: Future,
+ A: Future,
+ B: Future,
{
- type Item = EitherOutput;
+ type Item = O;
type Error = IoError;
#[inline]
@@ -111,11 +110,11 @@ where
match self {
&mut EitherConnUpgrFuture::First(ref mut a) => {
let item = try_ready!(a.poll());
- Ok(Async::Ready(EitherOutput::First(item)))
+ Ok(Async::Ready(item))
}
&mut EitherConnUpgrFuture::Second(ref mut b) => {
let item = try_ready!(b.poll());
- Ok(Async::Ready(EitherOutput::Second(item)))
+ Ok(Async::Ready(item))
}
}
}
diff --git a/libp2p/examples/echo-dialer.rs b/libp2p/examples/echo-dialer.rs
index 88eb53a0..696eb33b 100644
--- a/libp2p/examples/echo-dialer.rs
+++ b/libp2p/examples/echo-dialer.rs
@@ -30,7 +30,7 @@ use futures::{Future, Sink, Stream};
use std::env;
use libp2p::SimpleProtocol;
use libp2p::core::Transport;
-use libp2p::core::upgrade;
+use libp2p::core::{upgrade, either::EitherOutput};
use libp2p::tcp::TcpConfig;
use tokio_core::reactor::Core;
use tokio_io::AsyncRead;
@@ -70,7 +70,10 @@ fn main() {
}
};
- upgrade::or(plain_text, upgrade::map(secio, |(socket, _)| socket))
+ upgrade::or(
+ upgrade::map(plain_text, |pt| EitherOutput::First(pt)),
+ upgrade::map(secio, |(socket, _)| EitherOutput::Second(socket))
+ )
})
// On top of plaintext or secio, we will use the multiplex protocol.
diff --git a/libp2p/examples/echo-server.rs b/libp2p/examples/echo-server.rs
index c6dea4bb..307100fb 100644
--- a/libp2p/examples/echo-server.rs
+++ b/libp2p/examples/echo-server.rs
@@ -30,7 +30,7 @@ use futures::{Sink, Stream};
use std::env;
use libp2p::SimpleProtocol;
use libp2p::core::Transport;
-use libp2p::core::upgrade;
+use libp2p::core::{upgrade, either::EitherOutput};
use libp2p::tcp::TcpConfig;
use tokio_core::reactor::Core;
use tokio_io::AsyncRead;
@@ -69,7 +69,10 @@ fn main() {
}
};
- upgrade::or(plain_text, upgrade::map(secio, |(socket, _)| socket))
+ upgrade::or(
+ upgrade::map(plain_text, |pt| EitherOutput::First(pt)),
+ upgrade::map(secio, |(socket, _)| EitherOutput::Second(socket))
+ )
})
// On top of plaintext or secio, we will use the multiplex protocol.
diff --git a/libp2p/examples/floodsub.rs b/libp2p/examples/floodsub.rs
index 8eb30e4f..cd2164c8 100644
--- a/libp2p/examples/floodsub.rs
+++ b/libp2p/examples/floodsub.rs
@@ -30,7 +30,7 @@ extern crate tokio_stdin;
use futures::Stream;
use futures::future::Future;
use std::{env, mem};
-use libp2p::core::upgrade;
+use libp2p::core::{either::EitherOutput, upgrade};
use libp2p::core::{Multiaddr, Transport};
use libp2p::peerstore::PeerId;
use libp2p::tcp::TcpConfig;
@@ -69,7 +69,10 @@ fn main() {
}
};
- upgrade::or(plain_text, upgrade::map(secio, |(socket, _)| socket))
+ upgrade::or(
+ upgrade::map(plain_text, |pt| EitherOutput::First(pt)),
+ upgrade::map(secio, |(socket, _)| EitherOutput::Second(socket))
+ )
})
// On top of plaintext or secio, we will use the multiplex protocol.
diff --git a/libp2p/examples/kademlia.rs b/libp2p/examples/kademlia.rs
index 1a51f24e..78e3ffe0 100644
--- a/libp2p/examples/kademlia.rs
+++ b/libp2p/examples/kademlia.rs
@@ -34,7 +34,7 @@ use std::env;
use std::sync::Arc;
use std::time::Duration;
use libp2p::core::Transport;
-use libp2p::core::upgrade;
+use libp2p::core::{upgrade, either::EitherOutput};
use libp2p::tcp::TcpConfig;
use tokio_core::reactor::Core;
@@ -73,7 +73,10 @@ fn main() {
}
};
- upgrade::or(plain_text, upgrade::map(secio, |(socket, _)| socket))
+ upgrade::or(
+ upgrade::map(plain_text, |pt| EitherOutput::First(pt)),
+ upgrade::map(secio, |(socket, _)| EitherOutput::Second(socket))
+ )
})
// On top of plaintext or secio, we will use the multiplex protocol.
diff --git a/libp2p/examples/ping-client.rs b/libp2p/examples/ping-client.rs
index 7056f5e3..2574344e 100644
--- a/libp2p/examples/ping-client.rs
+++ b/libp2p/examples/ping-client.rs
@@ -29,7 +29,7 @@ use futures::Future;
use futures::sync::oneshot;
use std::env;
use libp2p::core::Transport;
-use libp2p::core::upgrade;
+use libp2p::core::{upgrade, either::EitherOutput};
use libp2p::tcp::TcpConfig;
use tokio_core::reactor::Core;
@@ -61,7 +61,10 @@ fn main() {
}
};
- upgrade::or(plain_text, upgrade::map(secio, |(socket, _)| socket))
+ upgrade::or(
+ upgrade::map(plain_text, |pt| EitherOutput::First(pt)),
+ upgrade::map(secio, |(socket, _)| EitherOutput::Second(socket))
+ )
})
// On top of plaintext or secio, we will use the multiplex protocol.