Skip to content

Commit

Permalink
Cargo.toml: Deprecate executor specific features for sub-crates (#2962)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed Oct 11, 2022
1 parent aba5ccb commit 31a45f2
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 22 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Expand Up @@ -48,6 +48,16 @@
- Remove default features. You need to enable required features explicitly now. As a quick workaround, you may want to use the
new `full` feature which activates all features. See [PR 2918].

- Introduce `tokio` and `async-std` features and deprecate the following ones:
- `tcp-tokio` in favor of `tcp` + `tokio`
- `mdns-tokio` in favor of `mdns` + `tokio`
- `dns-tokio` in favor of `dns` + `tokio`
- `tcp-async-io` in favor of `tcp` + `async-std`
- `mdns-async-io` in favor of `mdns` + `async-std`
- `dns-async-std` in favor of `dns` + `async-std`

See [PR 2962].

- Update individual crates.
- Update to [`libp2p-autonat` `v0.8.0`](protocols/autonat/CHANGELOG.md#0080).
- Update to [`libp2p-core` `v0.37.0`](core/CHANGELOG.md#0370).
Expand Down Expand Up @@ -75,7 +85,8 @@
- Update to [`libp2p-websocket` `v0.39.0`](transports/websocket/CHANGELOG.md#0390).
- Update to [`libp2p-yamux` `v0.41.0`](muxers/mplex/CHANGELOG.md#0410).

- [PR 2918]: https://github.com/libp2p/rust-libp2p/pull/2918
[PR 2918]: https://github.com/libp2p/rust-libp2p/pull/2918
[PR 2962]: https://github.com/libp2p/rust-libp2p/pull/2962

# 0.48.0

Expand Down
14 changes: 12 additions & 2 deletions Cargo.toml
Expand Up @@ -12,16 +12,19 @@ categories = ["network-programming", "asynchronous"]

[features]
full = [
"async-std",
"autonat",
"dcutr",
"deflate",
"dns",
"dns-async-std",
"dns-tokio",
"ecdsa",
"floodsub",
"gossipsub",
"identify",
"kad",
"mdns",
"mdns-async-io",
"mdns-tokio",
"metrics",
Expand All @@ -36,8 +39,10 @@ full = [
"rsa",
"secp256k1",
"serde",
"tcp",
"tcp-async-io",
"tcp-tokio",
"tokio",
"uds",
"wasm-bindgen",
"wasm-ext",
Expand All @@ -48,13 +53,15 @@ full = [
autonat = ["dep:libp2p-autonat"]
dcutr = ["dep:libp2p-dcutr", "libp2p-metrics?/dcutr"]
deflate = ["dep:libp2p-deflate"]
dns = ["dep:libp2p-dns"]
dns-async-std = ["dep:libp2p-dns", "libp2p-dns?/async-std"]
dns-tokio = ["dep:libp2p-dns", "libp2p-dns?/tokio"]
floodsub = ["dep:libp2p-floodsub"]
identify = ["dep:libp2p-identify", "libp2p-metrics?/identify"]
kad = ["dep:libp2p-kad", "libp2p-metrics?/kad"]
gossipsub = ["dep:libp2p-gossipsub", "libp2p-metrics?/gossipsub"]
metrics = ["dep:libp2p-metrics"]
mdns = ["dep:libp2p-mdns"]
mdns-async-io = ["dep:libp2p-mdns", "libp2p-mdns?/async-io"]
mdns-tokio = ["dep:libp2p-mdns", "libp2p-mdns?/tokio"]
mplex = ["dep:libp2p-mplex"]
Expand All @@ -65,6 +72,7 @@ pnet = ["dep:libp2p-pnet"]
relay = ["dep:libp2p-relay", "libp2p-metrics?/relay"]
request-response = ["dep:libp2p-request-response"]
rendezvous = ["dep:libp2p-rendezvous"]
tcp = ["dep:libp2p-tcp"]
tcp-async-io = ["dep:libp2p-tcp", "libp2p-tcp?/async-io"]
tcp-tokio = ["dep:libp2p-tcp", "libp2p-tcp?/tokio"]
uds = ["dep:libp2p-uds"]
Expand All @@ -77,6 +85,8 @@ secp256k1 = ["libp2p-core/secp256k1"]
rsa = ["libp2p-core/rsa"]
ecdsa = ["libp2p-core/ecdsa"]
serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"]
tokio = ["libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio"]
async-std = ["libp2p-mdns?/async-io", "libp2p-tcp?/async-io", "libp2p-dns?/async-std"]

[package.metadata.docs.rs]
all-features = true
Expand All @@ -91,7 +101,7 @@ lazy_static = "1.2"

libp2p-autonat = { version = "0.8.0", path = "protocols/autonat", optional = true }
libp2p-core = { version = "0.37.0", path = "core" }
libp2p-dcutr = { version = "0.7.0", path = "protocols/dcutr", optional = true }
libp2p-dcutr = { version = "0.7.0", path = "protocols/dcutr", optional = true }
libp2p-floodsub = { version = "0.40.1", path = "protocols/floodsub", optional = true }
libp2p-identify = { version = "0.40.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.41.0", path = "protocols/kad", optional = true }
Expand Down Expand Up @@ -128,7 +138,7 @@ libp2p-gossipsub = { version = "0.42.1", path = "protocols/gossipsub", optional
async-std = { version = "1.6.2", features = ["attributes"] }
async-trait = "0.1"
env_logger = "0.9.0"
clap = {version = "3.1.6", features = ["derive"]}
clap = { version = "3.1.6", features = ["derive"] }
tokio = { version = "1.15", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] }

[workspace]
Expand Down
117 changes: 98 additions & 19 deletions src/lib.rs
Expand Up @@ -54,14 +54,31 @@ pub use libp2p_dcutr as dcutr;
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[doc(inline)]
pub use libp2p_deflate as deflate;
#[cfg(any(feature = "dns-async-std", feature = "dns-tokio"))]
#[deprecated(
since = "0.49.0",
note = "The `dns-tokio` and `dns-async-std` features are deprecated. Use the new `dns` feature together with the `tokio` or `async-std` features."
)]
#[cfg(all(
any(feature = "dns-tokio", feature = "dns-async-std"),
not(feature = "dns")
))]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg_attr(
docsrs,
doc(cfg(any(feature = "dns-async-std", feature = "dns-tokio")))
doc(cfg(any(feature = "dns-tokio", feature = "dns-async-std")))
)]
pub mod dns {
#[doc(inline)]
pub use libp2p_dns::*;
}

#[cfg(feature = "dns")]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[doc(inline)]
pub use libp2p_dns as dns;
#[cfg_attr(docsrs, doc(cfg(feature = "dns")))]
pub mod dns {
#[doc(inline)]
pub use libp2p_dns::*;
}
#[cfg(feature = "floodsub")]
#[cfg_attr(docsrs, doc(cfg(feature = "floodsub")))]
#[doc(inline)]
Expand All @@ -79,14 +96,31 @@ pub use libp2p_identify as identify;
#[cfg_attr(docsrs, doc(cfg(feature = "kad")))]
#[doc(inline)]
pub use libp2p_kad as kad;
#[cfg(any(feature = "mdns-async-io", feature = "mdns-tokio"))]
#[deprecated(
since = "0.49.0",
note = "The `mdns-tokio` and `mdns-async-io` features are deprecated. Use the new `mdns` feature together with the `tokio` or `async-std` features."
)]
#[cfg(all(
any(feature = "mdns-async-io", feature = "mdns-tokio"),
not(feature = "mdns")
))]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg_attr(
docsrs,
doc(cfg(any(feature = "mdns-tokio", feature = "mdns-async-io")))
)]
pub mod mdns {
#[doc(inline)]
pub use libp2p_mdns::*;
}

#[cfg(feature = "mdns")]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[doc(inline)]
pub use libp2p_mdns as mdns;
#[cfg_attr(docsrs, doc(cfg(feature = "mdns")))]
pub mod mdns {
#[doc(inline)]
pub use libp2p_mdns::*;
}
#[cfg(feature = "metrics")]
#[cfg_attr(docsrs, doc(cfg(feature = "metrics")))]
#[doc(inline)]
Expand Down Expand Up @@ -125,11 +159,28 @@ pub use libp2p_rendezvous as rendezvous;
pub use libp2p_request_response as request_response;
#[doc(inline)]
pub use libp2p_swarm as swarm;
#[cfg(any(feature = "tcp-async-io", feature = "tcp-tokio"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "tcp-async-io", feature = "tcp-tokio"))))]
#[deprecated(
since = "0.49.0",
note = "The `tcp-tokio` and `tcp-async-io` features are deprecated. Use the new `tcp` feature together with the `tokio` or `async-std` features."
)]
#[cfg(all(
any(feature = "tcp-tokio", feature = "tcp-async-io"),
not(feature = "tcp")
))]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[doc(inline)]
pub use libp2p_tcp as tcp;
#[cfg_attr(docsrs, doc(cfg(any(feature = "tcp-tokio", feature = "tcp-async-io"))))]
pub mod tcp {
#[doc(inline)]
pub use libp2p_tcp::*;
}

#[cfg(feature = "tcp")]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[cfg_attr(docsrs, doc(cfg(feature = "tcp")))]
pub mod tcp {
#[doc(inline)]
pub use libp2p_tcp::*;
}
#[cfg(feature = "uds")]
#[cfg_attr(docsrs, doc(cfg(feature = "uds")))]
#[doc(inline)]
Expand Down Expand Up @@ -181,8 +232,10 @@ pub use libp2p_swarm_derive::NetworkBehaviour;
/// > reserves the right to support additional protocols or remove deprecated protocols.
#[cfg(all(
not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")),
feature = "tcp-async-io",
feature = "dns-async-std",
any(
all(feature = "tcp-async-io", feature = "dns-async-std"),
all(feature = "tcp", feature = "dns", feature = "async-std")
),
feature = "websocket",
feature = "noise",
feature = "mplex",
Expand All @@ -192,14 +245,26 @@ pub use libp2p_swarm_derive::NetworkBehaviour;
docsrs,
doc(cfg(all(
not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")),
feature = "tcp-async-io",
feature = "dns-async-std",
any(
all(feature = "tcp-async-io", feature = "dns-async-std"),
all(feature = "tcp", feature = "dns", feature = "async-std")
),
feature = "websocket",
feature = "noise",
feature = "mplex",
feature = "yamux"
)))
)]
#[cfg_attr(
all(
any(feature = "tcp-async-io", feature = "dns-async-std"),
not(feature = "async-std")
),
deprecated(
since = "0.49.0",
note = "The `tcp-async-io` and `dns-async-std` features are deprecated. Use the new `tcp` and `dns` features together with the `async-std` feature."
)
)]
pub async fn development_transport(
keypair: identity::Keypair,
) -> std::io::Result<core::transport::Boxed<(PeerId, core::muxing::StreamMuxerBox)>> {
Expand Down Expand Up @@ -241,8 +306,10 @@ pub async fn development_transport(
/// > reserves the right to support additional protocols or remove deprecated protocols.
#[cfg(all(
not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")),
feature = "tcp-tokio",
feature = "dns-tokio",
any(
all(feature = "tcp-tokio", feature = "dns-tokio"),
all(feature = "tcp", feature = "dns", feature = "tokio")
),
feature = "websocket",
feature = "noise",
feature = "mplex",
Expand All @@ -252,14 +319,26 @@ pub async fn development_transport(
docsrs,
doc(cfg(all(
not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")),
feature = "tcp-tokio",
feature = "dns-tokio",
any(
all(feature = "tcp-tokio", feature = "dns-tokio"),
all(feature = "tcp", feature = "dns", feature = "tokio")
),
feature = "websocket",
feature = "noise",
feature = "mplex",
feature = "yamux"
)))
)]
#[cfg_attr(
all(
any(feature = "tcp-tokio", feature = "dns-tokio"),
not(feature = "tokio")
),
deprecated(
since = "0.49.0",
note = "The `tcp-tokio` and `dns-tokio` features are deprecated. Use the new `tcp` and `dns` feature together with the `tokio` feature."
)
)]
pub fn tokio_development_transport(
keypair: identity::Keypair,
) -> std::io::Result<core::transport::Boxed<(PeerId, core::muxing::StreamMuxerBox)>> {
Expand Down

0 comments on commit 31a45f2

Please sign in to comment.