mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-22 15:41:19 +00:00
Rename OrUpgrade
to SelectUpgrade
. (#751)
Also remove `InboundUpgrade.or_inbound` and `OutboundUpgrade.or_outbound`.
This commit is contained in:
parent
299758c853
commit
dd5fb17a2b
@ -23,10 +23,9 @@ use crate::{
|
||||
protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent},
|
||||
upgrade::{
|
||||
InboundUpgrade,
|
||||
InboundUpgradeExt,
|
||||
OutboundUpgrade,
|
||||
EitherUpgrade,
|
||||
OrUpgrade
|
||||
SelectUpgrade
|
||||
}
|
||||
};
|
||||
use futures::prelude::*;
|
||||
@ -65,7 +64,7 @@ where
|
||||
type InEvent = EitherOutput<TProto1::InEvent, TProto2::InEvent>;
|
||||
type OutEvent = EitherOutput<TProto1::OutEvent, TProto2::OutEvent>;
|
||||
type Substream = TSubstream;
|
||||
type InboundProtocol = OrUpgrade<TProto1::InboundProtocol, TProto2::InboundProtocol>;
|
||||
type InboundProtocol = SelectUpgrade<TProto1::InboundProtocol, TProto2::InboundProtocol>;
|
||||
type OutboundProtocol = EitherUpgrade<TProto1::OutboundProtocol, TProto2::OutboundProtocol>;
|
||||
type OutboundOpenInfo = EitherOutput<TProto1::OutboundOpenInfo, TProto2::OutboundOpenInfo>;
|
||||
|
||||
@ -73,7 +72,7 @@ where
|
||||
fn listen_protocol(&self) -> Self::InboundProtocol {
|
||||
let proto1 = self.proto1.listen_protocol();
|
||||
let proto2 = self.proto2.listen_protocol();
|
||||
proto1.or_inbound(proto2)
|
||||
SelectUpgrade::new(proto1, proto2)
|
||||
}
|
||||
|
||||
fn inject_fully_negotiated_outbound(&mut self, protocol: <Self::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output, endpoint: Self::OutboundOpenInfo) {
|
||||
|
@ -62,7 +62,7 @@ mod denied;
|
||||
mod either;
|
||||
mod error;
|
||||
mod map;
|
||||
mod or;
|
||||
mod select;
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::future::Future;
|
||||
@ -73,7 +73,7 @@ pub use self::{
|
||||
either::EitherUpgrade,
|
||||
error::UpgradeError,
|
||||
map::{MapInboundUpgrade, MapOutboundUpgrade, MapInboundUpgradeErr, MapOutboundUpgradeErr},
|
||||
or::OrUpgrade,
|
||||
select::SelectUpgrade
|
||||
};
|
||||
|
||||
/// Common trait for upgrades that can be applied on inbound substreams, outbound substreams,
|
||||
@ -126,16 +126,6 @@ pub trait InboundUpgradeExt<C>: InboundUpgrade<C> {
|
||||
{
|
||||
MapInboundUpgradeErr::new(self, f)
|
||||
}
|
||||
|
||||
/// Returns a new object that combines `Self` and another upgrade to support both at the same
|
||||
/// time.
|
||||
fn or_inbound<U>(self, upgrade: U) -> OrUpgrade<Self, U>
|
||||
where
|
||||
Self: Sized,
|
||||
U: InboundUpgrade<C>
|
||||
{
|
||||
OrUpgrade::new(self, upgrade)
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, U: InboundUpgrade<C>> InboundUpgradeExt<C> for U {}
|
||||
@ -176,16 +166,6 @@ pub trait OutboundUpgradeExt<C>: OutboundUpgrade<C> {
|
||||
{
|
||||
MapOutboundUpgradeErr::new(self, f)
|
||||
}
|
||||
|
||||
/// Returns a new object that combines `Self` and another upgrade to support both at the same
|
||||
/// time.
|
||||
fn or_outbound<U>(self, upgrade: U) -> OrUpgrade<Self, U>
|
||||
where
|
||||
Self: Sized,
|
||||
U: OutboundUpgrade<C>
|
||||
{
|
||||
OrUpgrade::new(self, upgrade)
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, U: OutboundUpgrade<C>> OutboundUpgradeExt<C> for U {}
|
||||
|
@ -30,18 +30,18 @@ use crate::{
|
||||
///
|
||||
/// The protocols supported by the first element have a higher priority.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OrUpgrade<A, B>(A, B);
|
||||
pub struct SelectUpgrade<A, B>(A, B);
|
||||
|
||||
impl<A, B> OrUpgrade<A, B> {
|
||||
/// Combines two upgrades into an `OrUpgrade`.
|
||||
impl<A, B> SelectUpgrade<A, B> {
|
||||
/// Combines two upgrades into an `SelectUpgrade`.
|
||||
///
|
||||
/// The protocols supported by the first element have a higher priority.
|
||||
pub fn new(a: A, b: B) -> Self {
|
||||
OrUpgrade(a, b)
|
||||
SelectUpgrade(a, b)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B> UpgradeInfo for OrUpgrade<A, B>
|
||||
impl<A, B> UpgradeInfo for SelectUpgrade<A, B>
|
||||
where
|
||||
A: UpgradeInfo,
|
||||
B: UpgradeInfo
|
||||
@ -54,7 +54,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, A, B, TA, TB, EA, EB> InboundUpgrade<C> for OrUpgrade<A, B>
|
||||
impl<C, A, B, TA, TB, EA, EB> InboundUpgrade<C> for SelectUpgrade<A, B>
|
||||
where
|
||||
A: InboundUpgrade<C, Output = TA, Error = EA>,
|
||||
B: InboundUpgrade<C, Output = TB, Error = EB>,
|
||||
@ -71,7 +71,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, A, B, TA, TB, EA, EB> OutboundUpgrade<C> for OrUpgrade<A, B>
|
||||
impl<C, A, B, TA, TB, EA, EB> OutboundUpgrade<C> for SelectUpgrade<A, B>
|
||||
where
|
||||
A: OutboundUpgrade<C, Output = TA, Error = EA>,
|
||||
B: OutboundUpgrade<C, Output = TB, Error = EB>,
|
Loading…
x
Reference in New Issue
Block a user