From 8a1ca64233c402a942486279954bfcbfc346ebdc Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 6 Apr 2023 20:07:11 +0100 Subject: [PATCH 1/3] Deprecate `upgrade::from_fn` --- Cargo.lock | 2 +- core/CHANGELOG.md | 8 ++++++++ core/Cargo.toml | 2 +- core/src/upgrade.rs | 3 ++- core/src/upgrade/from_fn.rs | 7 +++++++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7baeaf5a902..ebce62c9c6b 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..bdd5b4b4132 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 XXXX]. + +[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX + ## 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..c99192fbb4a 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,8 @@ 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 +69,13 @@ 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 +88,7 @@ where } } +#[allow(deprecated)] impl InboundUpgrade for FromFnUpgrade where P: ProtocolName + Clone, @@ -98,6 +104,7 @@ where } } +#[allow(deprecated)] impl OutboundUpgrade for FromFnUpgrade where P: ProtocolName + Clone, From 1906ac22f02be441b82b73c8a40d2edefaebbd8a Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 6 Apr 2023 20:25:12 +0100 Subject: [PATCH 2/3] Fix changelog --- core/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index bdd5b4b4132..99dc371b595 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -2,9 +2,9 @@ - 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 XXXX]. + See [PR 3747]. -[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX +[PR 3747]: https://github.com/libp2p/rust-libp2p/pull/3747 ## 0.39.1 From 5bc9e329e86c4c321965a52f65123faa6e4a40a2 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 19 Apr 2023 19:31:24 +0200 Subject: [PATCH 3/3] Fix formatting --- core/src/upgrade/from_fn.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/upgrade/from_fn.rs b/core/src/upgrade/from_fn.rs index c99192fbb4a..d6da7b6ed5a 100644 --- a/core/src/upgrade/from_fn.rs +++ b/core/src/upgrade/from_fn.rs @@ -53,7 +53,9 @@ use std::iter; /// }); /// ``` /// -#[deprecated(note = "`from_fn` upgrade will be removed without replacement as it is not used within `rust-libp2p`.")] +#[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 @@ -69,7 +71,9 @@ 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`.")] +#[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,