Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): deprecate upgrade::from_fn #3747

Merged
merged 4 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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].
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
3 changes: 2 additions & 1 deletion core/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions core/src/upgrade/from_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Channel<Vec<u8>>>, endpoint| async move {
Expand All @@ -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<P, F, C, Fut, Out, Err>(protocol_name: P, fun: F) -> FromFnUpgrade<P, F>
where
// Note: these bounds are there in order to help the compiler infer types
Expand All @@ -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<P, F> {
protocol_name: P,
fun: F,
}

#[allow(deprecated)]
impl<P, F> UpgradeInfo for FromFnUpgrade<P, F>
where
P: ProtocolName + Clone,
Expand All @@ -83,6 +88,7 @@ where
}
}

#[allow(deprecated)]
impl<C, P, F, Fut, Err, Out> InboundUpgrade<C> for FromFnUpgrade<P, F>
where
P: ProtocolName + Clone,
Expand All @@ -98,6 +104,7 @@ where
}
}

#[allow(deprecated)]
impl<C, P, F, Fut, Err, Out> OutboundUpgrade<C> for FromFnUpgrade<P, F>
where
P: ProtocolName + Clone,
Expand Down