mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-27 16:51:34 +00:00
refactor(core)!: remove EitherUpgrade
(#3339)
We don't need to define our own type here, we can simply implement `UpgradeInfo`, `InboundUpgrade` and `OutboundUpgrade` on `either::Either`.
This commit is contained in:
@ -29,7 +29,7 @@ use crate::upgrade::SendWrapper;
|
||||
use either::Either;
|
||||
use libp2p_core::{
|
||||
either::EitherOutput,
|
||||
upgrade::{EitherUpgrade, NegotiationError, ProtocolError, SelectUpgrade, UpgradeError},
|
||||
upgrade::{NegotiationError, ProtocolError, SelectUpgrade, UpgradeError},
|
||||
ConnectedPoint, PeerId,
|
||||
};
|
||||
use std::{cmp, task::Context, task::Poll};
|
||||
@ -102,7 +102,7 @@ impl<TProto1, TProto2> ConnectionHandlerSelect<TProto1, TProto2> {
|
||||
|
||||
impl<S1OOI, S2OOI, S1OP, S2OP>
|
||||
FullyNegotiatedOutbound<
|
||||
EitherUpgrade<SendWrapper<S1OP>, SendWrapper<S2OP>>,
|
||||
Either<SendWrapper<S1OP>, SendWrapper<S2OP>>,
|
||||
EitherOutput<S1OOI, S2OOI>,
|
||||
>
|
||||
where
|
||||
@ -151,10 +151,7 @@ where
|
||||
}
|
||||
|
||||
impl<S1OOI, S2OOI, S1OP, S2OP>
|
||||
DialUpgradeError<
|
||||
EitherOutput<S1OOI, S2OOI>,
|
||||
EitherUpgrade<SendWrapper<S1OP>, SendWrapper<S2OP>>,
|
||||
>
|
||||
DialUpgradeError<EitherOutput<S1OOI, S2OOI>, Either<SendWrapper<S1OP>, SendWrapper<S2OP>>>
|
||||
where
|
||||
S1OP: OutboundUpgradeSend,
|
||||
S2OP: OutboundUpgradeSend,
|
||||
@ -348,10 +345,8 @@ where
|
||||
SendWrapper<<TProto1 as ConnectionHandler>::InboundProtocol>,
|
||||
SendWrapper<<TProto2 as ConnectionHandler>::InboundProtocol>,
|
||||
>;
|
||||
type OutboundProtocol = EitherUpgrade<
|
||||
SendWrapper<TProto1::OutboundProtocol>,
|
||||
SendWrapper<TProto2::OutboundProtocol>,
|
||||
>;
|
||||
type OutboundProtocol =
|
||||
Either<SendWrapper<TProto1::OutboundProtocol>, SendWrapper<TProto2::OutboundProtocol>>;
|
||||
type OutboundOpenInfo = EitherOutput<TProto1::OutboundOpenInfo, TProto2::OutboundOpenInfo>;
|
||||
type InboundOpenInfo = (TProto1::InboundOpenInfo, TProto2::InboundOpenInfo);
|
||||
|
||||
@ -400,7 +395,7 @@ where
|
||||
Poll::Ready(ConnectionHandlerEvent::OutboundSubstreamRequest { protocol }) => {
|
||||
return Poll::Ready(ConnectionHandlerEvent::OutboundSubstreamRequest {
|
||||
protocol: protocol
|
||||
.map_upgrade(|u| EitherUpgrade::A(SendWrapper(u)))
|
||||
.map_upgrade(|u| Either::Left(SendWrapper(u)))
|
||||
.map_info(EitherOutput::First),
|
||||
});
|
||||
}
|
||||
@ -417,7 +412,7 @@ where
|
||||
Poll::Ready(ConnectionHandlerEvent::OutboundSubstreamRequest { protocol }) => {
|
||||
return Poll::Ready(ConnectionHandlerEvent::OutboundSubstreamRequest {
|
||||
protocol: protocol
|
||||
.map_upgrade(|u| EitherUpgrade::B(SendWrapper(u)))
|
||||
.map_upgrade(|u| Either::Right(SendWrapper(u)))
|
||||
.map_info(EitherOutput::Second),
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user