feat(core): deprecate {In,Out}boundUpgradeExt

These functions were only used for some code in the interop-tests which is easily mitigated and perhaps even easier to understand now. We can thus deprecate these functions and their related types and thereby reduce the API surface of `libp2p-core` and the maintenance burden.

This change is motivated by the work around making protocols always strings which requires/required updates to all these upgrades.

Related #3806.
Related #3271.
Related #3745.

Pull-Request: #3807.
This commit is contained in:
Thomas Eizinger
2023-04-25 14:26:16 +02:00
committed by GitHub
parent 5657f5c9aa
commit 585a84e182
5 changed files with 62 additions and 52 deletions

View File

@ -77,7 +77,6 @@ pub use self::{
apply::{apply, apply_inbound, apply_outbound, InboundUpgradeApply, OutboundUpgradeApply},
denied::DeniedUpgrade,
error::UpgradeError,
map::{MapInboundUpgrade, MapInboundUpgradeErr, MapOutboundUpgrade, MapOutboundUpgradeErr},
optional::OptionalUpgrade,
pending::PendingUpgrade,
ready::ReadyUpgrade,
@ -87,6 +86,9 @@ pub use self::{
pub use crate::Negotiated;
pub use multistream_select::{NegotiatedComplete, NegotiationError, ProtocolError, Version};
#[allow(deprecated)]
pub use map::{MapInboundUpgrade, MapInboundUpgradeErr, MapOutboundUpgrade, MapOutboundUpgradeErr};
/// Types serving as protocol names.
///
/// # Context
@ -164,6 +166,10 @@ pub trait InboundUpgrade<C>: UpgradeInfo {
/// Extension trait for `InboundUpgrade`. Automatically implemented on all types that implement
/// `InboundUpgrade`.
#[deprecated(
note = "Will be removed without replacement because it is not used within rust-libp2p."
)]
#[allow(deprecated)]
pub trait InboundUpgradeExt<C>: InboundUpgrade<C> {
/// Returns a new object that wraps around `Self` and applies a closure to the `Output`.
fn map_inbound<F, T>(self, f: F) -> MapInboundUpgrade<Self, F>
@ -184,6 +190,7 @@ pub trait InboundUpgradeExt<C>: InboundUpgrade<C> {
}
}
#[allow(deprecated)]
impl<C, U: InboundUpgrade<C>> InboundUpgradeExt<C> for U {}
/// Possible upgrade on an outbound connection or substream.
@ -204,6 +211,10 @@ pub trait OutboundUpgrade<C>: UpgradeInfo {
/// Extention trait for `OutboundUpgrade`. Automatically implemented on all types that implement
/// `OutboundUpgrade`.
#[deprecated(
note = "Will be removed without replacement because it is not used within rust-libp2p."
)]
#[allow(deprecated)]
pub trait OutboundUpgradeExt<C>: OutboundUpgrade<C> {
/// Returns a new object that wraps around `Self` and applies a closure to the `Output`.
fn map_outbound<F, T>(self, f: F) -> MapOutboundUpgrade<Self, F>
@ -224,4 +235,5 @@ pub trait OutboundUpgradeExt<C>: OutboundUpgrade<C> {
}
}
#[allow(deprecated)]
impl<C, U: OutboundUpgrade<C>> OutboundUpgradeExt<C> for U {}

View File

@ -18,12 +18,15 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#![allow(deprecated)]
use crate::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
use futures::prelude::*;
use std::{pin::Pin, task::Context, task::Poll};
/// Wraps around an upgrade and applies a closure to the output.
#[derive(Debug, Clone)]
#[deprecated(note = "Deprecated without replacement because it is not used within rust-libp2p.")]
pub struct MapInboundUpgrade<U, F> {
upgrade: U,
fun: F,
@ -79,6 +82,7 @@ where
/// Wraps around an upgrade and applies a closure to the output.
#[derive(Debug, Clone)]
#[deprecated(note = "Deprecated without replacement because it is not used within rust-libp2p.")]
pub struct MapOutboundUpgrade<U, F> {
upgrade: U,
fun: F,
@ -134,6 +138,7 @@ where
/// Wraps around an upgrade and applies a closure to the error.
#[derive(Debug, Clone)]
#[deprecated(note = "Deprecated without replacement because it is not used within rust-libp2p.")]
pub struct MapInboundUpgradeErr<U, F> {
upgrade: U,
fun: F,
@ -189,6 +194,7 @@ where
/// Wraps around an upgrade and applies a closure to the error.
#[derive(Debug, Clone)]
#[deprecated(note = "Deprecated without replacement because it is not used within rust-libp2p.")]
pub struct MapOutboundUpgradeErr<U, F> {
upgrade: U,
fun: F,