mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-29 17:51:35 +00:00
refactor(core)!: remove EitherOutput
(#3341)
The trick with this one is to use `futures::Either` everywhere where we may wrap something that implements any of the `futures` traits. This includes the output of `EitherFuture` itself. We also need to implement `StreamMuxer` on `future::Either` because `StreamMuxer`s may be the the `Output` of `InboundUpgrade`.
This commit is contained in:
@ -22,9 +22,9 @@
|
||||
|
||||
use crate::protocol;
|
||||
use either::Either;
|
||||
use futures::future;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
use instant::Instant;
|
||||
use libp2p_core::either::EitherOutput;
|
||||
use libp2p_core::multiaddr::Multiaddr;
|
||||
use libp2p_core::upgrade::{DeniedUpgrade, NegotiationError, UpgradeError};
|
||||
use libp2p_core::ConnectedPoint;
|
||||
@ -174,7 +174,7 @@ impl Handler {
|
||||
>,
|
||||
) {
|
||||
match output {
|
||||
EitherOutput::First(inbound_connect) => {
|
||||
future::Either::Left(inbound_connect) => {
|
||||
let remote_addr = match &self.endpoint {
|
||||
ConnectedPoint::Dialer { address, role_override: _ } => address.clone(),
|
||||
ConnectedPoint::Listener { ..} => unreachable!("`<Handler as ConnectionHandler>::listen_protocol` denies all incoming substreams as a listener."),
|
||||
@ -187,7 +187,7 @@ impl Handler {
|
||||
));
|
||||
}
|
||||
// A connection listener denies all incoming substreams, thus none can ever be fully negotiated.
|
||||
EitherOutput::Second(output) => void::unreachable(output),
|
||||
future::Either::Right(output) => void::unreachable(output),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user