diff --git a/core/src/protocols_handler/select.rs b/core/src/protocols_handler/select.rs index 18461656..85a54823 100644 --- a/core/src/protocols_handler/select.rs +++ b/core/src/protocols_handler/select.rs @@ -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; type OutEvent = EitherOutput; type Substream = TSubstream; - type InboundProtocol = OrUpgrade; + type InboundProtocol = SelectUpgrade; type OutboundProtocol = EitherUpgrade; type OutboundOpenInfo = EitherOutput; @@ -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: >::Output, endpoint: Self::OutboundOpenInfo) { diff --git a/core/src/upgrade/mod.rs b/core/src/upgrade/mod.rs index 96ac41ea..5858d867 100644 --- a/core/src/upgrade/mod.rs +++ b/core/src/upgrade/mod.rs @@ -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: InboundUpgrade { { MapInboundUpgradeErr::new(self, f) } - - /// Returns a new object that combines `Self` and another upgrade to support both at the same - /// time. - fn or_inbound(self, upgrade: U) -> OrUpgrade - where - Self: Sized, - U: InboundUpgrade - { - OrUpgrade::new(self, upgrade) - } } impl> InboundUpgradeExt for U {} @@ -176,16 +166,6 @@ pub trait OutboundUpgradeExt: OutboundUpgrade { { MapOutboundUpgradeErr::new(self, f) } - - /// Returns a new object that combines `Self` and another upgrade to support both at the same - /// time. - fn or_outbound(self, upgrade: U) -> OrUpgrade - where - Self: Sized, - U: OutboundUpgrade - { - OrUpgrade::new(self, upgrade) - } } impl> OutboundUpgradeExt for U {} diff --git a/core/src/upgrade/or.rs b/core/src/upgrade/select.rs similarity index 91% rename from core/src/upgrade/or.rs rename to core/src/upgrade/select.rs index e775d80e..4beff531 100644 --- a/core/src/upgrade/or.rs +++ b/core/src/upgrade/select.rs @@ -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); +pub struct SelectUpgrade(A, B); -impl OrUpgrade { - /// Combines two upgrades into an `OrUpgrade`. +impl SelectUpgrade { + /// 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 UpgradeInfo for OrUpgrade +impl UpgradeInfo for SelectUpgrade where A: UpgradeInfo, B: UpgradeInfo @@ -54,7 +54,7 @@ where } } -impl InboundUpgrade for OrUpgrade +impl InboundUpgrade for SelectUpgrade where A: InboundUpgrade, B: InboundUpgrade, @@ -71,7 +71,7 @@ where } } -impl OutboundUpgrade for OrUpgrade +impl OutboundUpgrade for SelectUpgrade where A: OutboundUpgrade, B: OutboundUpgrade,