mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-27 08:41:36 +00:00
Rename OrUpgrade
to SelectUpgrade
. (#751)
Also remove `InboundUpgrade.or_inbound` and `OutboundUpgrade.or_outbound`.
This commit is contained in:
@ -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>,
|
Reference in New Issue
Block a user