From 0fe9791829150f0c6036b06f3357959d9845cd18 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 20 Apr 2023 00:07:42 +0200 Subject: [PATCH] feat(core): deprecate `upgrade::from_fn` This functionality isn't needed anywhere in `rust-libp2p` so we can deprecate and later remove it and thus reduce our API surface. Users relying on this function can vendor it. Pull-Request: #3747. --- Cargo.lock | 2 +- core/CHANGELOG.md | 8 ++++++++ core/Cargo.toml | 2 +- core/src/upgrade.rs | 3 ++- core/src/upgrade/from_fn.rs | 11 +++++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 690fb17998b..ea9b4943d24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2319,7 +2319,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.39.1" +version = "0.39.2" dependencies = [ "async-std", "either", diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 5aefe3dda27..99dc371b595 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.39.2 - unreleased + +- Deprecate `upgrade::from_fn` without replacement as it is not used within `rust-libp2p`. + If you depend on it, we suggest you vendor it. + See [PR 3747]. + +[PR 3747]: https://github.com/libp2p/rust-libp2p/pull/3747 + ## 0.39.1 - Migrate from `prost` to `quick-protobuf`. This removes `protoc` dependency. See [PR 3312]. diff --git a/core/Cargo.toml b/core/Cargo.toml index 210f7c3569c..60fa51c904b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-core" edition = "2021" rust-version = "1.60.0" description = "Core traits and structs of libp2p" -version = "0.39.1" +version = "0.39.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/core/src/upgrade.rs b/core/src/upgrade.rs index 62b3e278cf1..003590fd00c 100644 --- a/core/src/upgrade.rs +++ b/core/src/upgrade.rs @@ -71,11 +71,12 @@ mod transfer; use futures::future::Future; +#[allow(deprecated)] +pub use self::from_fn::{from_fn, FromFnUpgrade}; pub use self::{ apply::{apply, apply_inbound, apply_outbound, InboundUpgradeApply, OutboundUpgradeApply}, denied::DeniedUpgrade, error::UpgradeError, - from_fn::{from_fn, FromFnUpgrade}, map::{MapInboundUpgrade, MapInboundUpgradeErr, MapOutboundUpgrade, MapOutboundUpgradeErr}, optional::OptionalUpgrade, pending::PendingUpgrade, diff --git a/core/src/upgrade/from_fn.rs b/core/src/upgrade/from_fn.rs index 97bbc2eb292..d6da7b6ed5a 100644 --- a/core/src/upgrade/from_fn.rs +++ b/core/src/upgrade/from_fn.rs @@ -35,6 +35,7 @@ use std::iter; /// # use libp2p_core::{upgrade, Negotiated}; /// # use std::io; /// # use futures::AsyncWriteExt; +/// # #[allow(deprecated)] /// let _transport = MemoryTransport::default() /// .and_then(move |out, cp| { /// upgrade::apply(out, upgrade::from_fn("/foo/1", move |mut sock: Negotiated>>, endpoint| async move { @@ -52,6 +53,10 @@ use std::iter; /// }); /// ``` /// +#[deprecated( + note = "`from_fn` upgrade will be removed without replacement as it is not used within `rust-libp2p`." +)] +#[allow(deprecated)] pub fn from_fn(protocol_name: P, fun: F) -> FromFnUpgrade where // Note: these bounds are there in order to help the compiler infer types @@ -66,11 +71,15 @@ where /// /// The upgrade consists in calling the function passed when creating this struct. #[derive(Debug, Clone)] +#[deprecated( + note = "`from_fn` upgrade will be removed without replacement as it is not used within `rust-libp2p`." +)] pub struct FromFnUpgrade { protocol_name: P, fun: F, } +#[allow(deprecated)] impl UpgradeInfo for FromFnUpgrade where P: ProtocolName + Clone, @@ -83,6 +92,7 @@ where } } +#[allow(deprecated)] impl InboundUpgrade for FromFnUpgrade where P: ProtocolName + Clone, @@ -98,6 +108,7 @@ where } } +#[allow(deprecated)] impl OutboundUpgrade for FromFnUpgrade where P: ProtocolName + Clone,