swarm/behaviour: Remove deprecated NetworkBehaviourEventProcess (#2840)

Removes the `NetworkBehaviourEventProcess` and all its associated logic.

See deprecation pull request https://github.com/libp2p/rust-libp2p/pull/2784.

Find rational in https://github.com/libp2p/rust-libp2p/pull/2751.
This commit is contained in:
Max Inden
2022-08-26 07:08:33 +02:00
committed by GitHub
parent d92cab8581
commit ca07ce4d64
36 changed files with 145 additions and 183 deletions

View File

@ -43,6 +43,28 @@
# `libp2p` facade crate
# 0.48.0 [unreleased]
- Update to [`libp2p-dcutr` `v0.6.0`](protocols/dcutr/CHANGELOG.md#060).
- Update to [`libp2p-rendezvous` `v0.9.0`](protocols/rendezvous/CHANGELOG.md#090).
- Update to [`libp2p-ping` `v0.39.0`](protocols/ping/CHANGELOG.md#0390).
- Update to [`libp2p-identify` `v0.39.0`](protocols/identify/CHANGELOG.md#0390).
- Update to [`libp2p-floodsub` `v0.39.0`](protocols/floodsub/CHANGELOG.md#0390).
- Update to [`libp2p-relay` `v0.12.0`](protocols/relay/CHANGELOG.md#0120).
- Update to [`libp2p-metrics` `v0.9.0`](misc/metrics/CHANGELOG.md#090).
- Update to [`libp2p-kad` `v0.40.0`](protocols/kad/CHANGELOG.md#0400).
- Update to [`libp2p-autonat` `v0.7.0`](protocols/autonat/CHANGELOG.md#070).
- Update to [`libp2p-request-response` `v0.21.0`](protocols/request-response/CHANGELOG.md#0210).
# 0.47.0
- Update to [`libp2p-dcutr` `v0.5.0`](protocols/dcutr/CHANGELOG.md#050).

View File

@ -3,7 +3,7 @@ name = "libp2p"
edition = "2021"
rust-version = "1.60.0"
description = "Peer-to-peer networking library"
version = "0.47.0"
version = "0.48.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -77,23 +77,23 @@ getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
lazy_static = "1.2"
libp2p-autonat = { version = "0.6.0", path = "protocols/autonat", optional = true }
libp2p-autonat = { version = "0.7.0", path = "protocols/autonat", optional = true }
libp2p-core = { version = "0.35.0", path = "core", default-features = false }
libp2p-dcutr = { version = "0.5.0", path = "protocols/dcutr", optional = true }
libp2p-floodsub = { version = "0.38.0", path = "protocols/floodsub", optional = true }
libp2p-identify = { version = "0.38.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.39.0", path = "protocols/kad", optional = true }
libp2p-metrics = { version = "0.8.0", path = "misc/metrics", optional = true }
libp2p-dcutr = { version = "0.6.0", path = "protocols/dcutr", optional = true }
libp2p-floodsub = { version = "0.39.0", path = "protocols/floodsub", optional = true }
libp2p-identify = { version = "0.39.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.40.0", path = "protocols/kad", optional = true }
libp2p-metrics = { version = "0.9.0", path = "misc/metrics", optional = true }
libp2p-mplex = { version = "0.35.0", path = "muxers/mplex", optional = true }
libp2p-noise = { version = "0.38.0", path = "transports/noise", optional = true }
libp2p-ping = { version = "0.38.0", path = "protocols/ping", optional = true }
libp2p-ping = { version = "0.39.0", path = "protocols/ping", optional = true }
libp2p-plaintext = { version = "0.35.0", path = "transports/plaintext", optional = true }
libp2p-pnet = { version = "0.22.0", path = "transports/pnet", optional = true }
libp2p-relay = { version = "0.11.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.8.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.20.0", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.38.0", path = "swarm" }
libp2p-swarm-derive = { version = "0.29.0", path = "swarm-derive" }
libp2p-relay = { version = "0.12.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.9.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.21.0", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.39.0", path = "swarm" }
libp2p-swarm-derive = { version = "0.30.0", path = "swarm-derive" }
libp2p-uds = { version = "0.34.0", path = "transports/uds", optional = true }
libp2p-wasm-ext = { version = "0.35.0", path = "transports/wasm-ext", default-features = false, optional = true }
libp2p-yamux = { version = "0.39.0", path = "muxers/yamux", optional = true }
@ -106,12 +106,12 @@ smallvec = "1.6.1"
[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies]
libp2p-deflate = { version = "0.35.0", path = "transports/deflate", optional = true }
libp2p-dns = { version = "0.35.0", path = "transports/dns", optional = true, default-features = false }
libp2p-mdns = { version = "0.39.0", path = "protocols/mdns", optional = true }
libp2p-mdns = { version = "0.40.0", path = "protocols/mdns", optional = true }
libp2p-tcp = { version = "0.35.0", path = "transports/tcp", default-features = false, optional = true }
libp2p-websocket = { version = "0.37.0", path = "transports/websocket", optional = true }
[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { version = "0.40.0", path = "protocols/gossipsub", optional = true }
libp2p-gossipsub = { version = "0.41.0", path = "protocols/gossipsub", optional = true }
[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }

View File

@ -1,3 +1,17 @@
# 0.9.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
- Update to `libp2p-dcutr` `v0.6.0`.
- Update to `libp2p-ping` `v0.39.0`.
- Update to `libp2p-identify` `v0.39.0`.
- Update to `libp2p-relay` `v0.12.0`.
- Update to `libp2p-kad` `v0.40.0`.
# 0.8.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-metrics"
edition = "2021"
rust-version = "1.56.1"
description = "Metrics for libp2p"
version = "0.8.0"
version = "0.9.0"
authors = ["Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -20,16 +20,16 @@ dcutr = ["libp2p-dcutr"]
[dependencies]
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-dcutr = { version = "0.5.0", path = "../../protocols/dcutr", optional = true }
libp2p-identify = { version = "0.38.0", path = "../../protocols/identify", optional = true }
libp2p-kad = { version = "0.39.0", path = "../../protocols/kad", optional = true }
libp2p-ping = { version = "0.38.0", path = "../../protocols/ping", optional = true }
libp2p-relay = { version = "0.11.0", path = "../../protocols/relay", optional = true }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-dcutr = { version = "0.6.0", path = "../../protocols/dcutr", optional = true }
libp2p-identify = { version = "0.39.0", path = "../../protocols/identify", optional = true }
libp2p-kad = { version = "0.40.0", path = "../../protocols/kad", optional = true }
libp2p-ping = { version = "0.39.0", path = "../../protocols/ping", optional = true }
libp2p-relay = { version = "0.12.0", path = "../../protocols/relay", optional = true }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
prometheus-client = "0.18.0"
[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { version = "0.40.0", path = "../../protocols/gossipsub", optional = true }
libp2p-gossipsub = { version = "0.41.0", path = "../../protocols/gossipsub", optional = true }
[dev-dependencies]
log = "0.4.0"

View File

@ -1,3 +1,9 @@
# 0.7.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
- Update to `libp2p-request-response` `v0.21.0`.
# 0.6.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-autonat"
edition = "2021"
rust-version = "1.56.1"
description = "NAT and firewall detection for libp2p"
version = "0.6.0"
version = "0.7.0"
authors = ["David Craven <david@craven.ch>", "Elena Frank <elena.frank@protonmail.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -19,8 +19,8 @@ futures = "0.3"
futures-timer = "3.0"
instant = "0.1"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-request-response = { version = "0.20.0", path = "../request-response" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
libp2p-request-response = { version = "0.21.0", path = "../request-response" }
log = "0.4"
rand = "0.8"
prost = "0.11"

View File

@ -1,3 +1,7 @@
# 0.6.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.5.1
- Make default features of `libp2p-core` optional. See [PR 2836].

View File

@ -3,7 +3,7 @@ name = "libp2p-dcutr"
edition = "2021"
rust-version = "1.56.1"
description = "Direct connection upgrade through relay"
version = "0.5.1"
version = "0.6.0"
authors = ["Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -18,7 +18,7 @@ futures = "0.3.1"
futures-timer = "3.0"
instant = "0.1.11"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4"
prost-codec = { version = "0.2", path = "../../misc/prost-codec" }
prost = "0.11"

View File

@ -1,3 +1,7 @@
# 0.39.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.38.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-floodsub"
edition = "2021"
rust-version = "1.56.1"
description = "Floodsub protocol for libp2p"
version = "0.38.0"
version = "0.39.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -15,7 +15,7 @@ cuckoofilter = "0.5.0"
fnv = "1.0"
futures = "0.3.1"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4"
prost = "0.11"
rand = "0.7"

View File

@ -1,3 +1,7 @@
# 0.41.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.40.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-gossipsub"
edition = "2021"
rust-version = "1.56.1"
description = "Gossipsub protocol for libp2p"
version = "0.40.0"
version = "0.41.0"
authors = ["Age Manning <Age@AgeManning.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
bytes = "1.0"
byteorder = "1.3.4"

View File

@ -1,3 +1,7 @@
# 0.39.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.38.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-identify"
edition = "2021"
rust-version = "1.56.1"
description = "Nodes identifcation protocol for libp2p"
version = "0.38.0"
version = "0.39.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -15,7 +15,7 @@ asynchronous-codec = "0.6"
futures = "0.3.1"
futures-timer = "3.0.2"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4.1"
lru = "0.7.2"
prost-codec = { version = "0.2", path = "../../misc/prost-codec" }

View File

@ -1,3 +1,7 @@
# 0.40.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.39.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-kad"
edition = "2021"
rust-version = "1.56.1"
description = "Kademlia protocol for libp2p"
version = "0.39.0"
version = "0.40.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -19,7 +19,7 @@ asynchronous-codec = "0.6"
futures = "0.3.1"
log = "0.4"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
prost = "0.11"
rand = "0.7.2"
sha2 = "0.10.0"

View File

@ -1,3 +1,7 @@
# 0.40.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.39.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -2,7 +2,7 @@
name = "libp2p-mdns"
edition = "2021"
rust-version = "1.56.1"
version = "0.39.0"
version = "0.40.0"
description = "Implementation of the libp2p mDNS discovery method"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
@ -18,7 +18,7 @@ futures = "0.3.13"
if-watch = "1.1.1"
lazy_static = "1.4.0"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4.14"
rand = "0.8.3"
smallvec = "1.6.1"

View File

@ -1,3 +1,7 @@
# 0.39.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.38.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-ping"
edition = "2021"
rust-version = "1.56.1"
description = "Ping protocol for libp2p"
version = "0.38.0"
version = "0.39.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -15,7 +15,7 @@ futures = "0.3.1"
futures-timer = "3.0.2"
instant = "0.1.11"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4.1"
rand = "0.7.2"
void = "1.0"

View File

@ -1,3 +1,7 @@
# 0.12.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.11.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-relay"
edition = "2021"
rust-version = "1.56.1"
description = "Communications relaying for libp2p"
version = "0.11.0"
version = "0.12.0"
authors = ["Parity Technologies <admin@parity.io>", "Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -18,7 +18,7 @@ futures = "0.3.1"
futures-timer = "3"
instant = "0.1.11"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4"
pin-project = "1"
prost-codec = { version = "0.2", path = "../../misc/prost-codec" }

View File

@ -1,3 +1,7 @@
# 0.9.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.8.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-rendezvous"
edition = "2021"
rust-version = "1.56.1"
description = "Rendezvous protocol for libp2p"
version = "0.8.0"
version = "0.9.0"
authors = ["The COMIT guys <hello@comit.network>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
asynchronous-codec = "0.6"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
prost = "0.11"
void = "1"
log = "0.4"

View File

@ -1,3 +1,7 @@
# 0.21.0 [unreleased]
- Update to `libp2p-swarm` `v0.39.0`.
# 0.20.0
- Update to `libp2p-swarm` `v0.38.0`.

View File

@ -3,7 +3,7 @@ name = "libp2p-request-response"
edition = "2021"
rust-version = "1.56.1"
description = "Generic Request/Response Protocols"
version = "0.20.0"
version = "0.21.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -16,7 +16,7 @@ bytes = "1"
futures = "0.3.1"
instant = "0.1.11"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4.11"
rand = "0.7"
smallvec = "1.6.1"

View File

@ -1,3 +1,7 @@
# 0.30.0 - [unreleased]
- Remove support for removed `NetworkBehaviourEventProcess`.
# 0.29.0
- Generate `NetworkBehaviour::OutEvent` if not provided through `#[behaviour(out_event =

View File

@ -3,7 +3,7 @@ name = "libp2p-swarm-derive"
edition = "2021"
rust-version = "1.56.1"
description = "Procedural macros of libp2p-core"
version = "0.29.0"
version = "0.30.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -48,7 +48,6 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
let (_, ty_generics, where_clause) = ast.generics.split_for_impl();
let multiaddr = quote! {::libp2p::core::Multiaddr};
let trait_to_impl = quote! {::libp2p::swarm::NetworkBehaviour};
let net_behv_event_proc = quote! {::libp2p::swarm::NetworkBehaviourEventProcess};
let either_ident = quote! {::libp2p::core::either::EitherOutput};
let network_behaviour_action = quote! {::libp2p::swarm::NetworkBehaviourAction};
let into_connection_handler = quote! {::libp2p::swarm::IntoConnectionHandler};
@ -71,28 +70,6 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
quote! {<#(#lf,)* #(#tp,)* #(#cst,)*>}
};
// Whether or not we require the `NetworkBehaviourEventProcess` trait to be implemented.
let event_process = {
let mut event_process = false;
for meta_items in ast.attrs.iter().filter_map(get_meta_items) {
for meta_item in meta_items {
match meta_item {
syn::NestedMeta::Meta(syn::Meta::NameValue(ref m))
if m.path.is_ident("event_process") =>
{
if let syn::Lit::Bool(ref b) = m.lit {
event_process = b.value
}
}
_ => (),
}
}
}
event_process
};
// The fields of the struct we are interested in (no ignored fields).
let data_struct_fields = data_struct
.fields
@ -121,9 +98,9 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
})
.next();
match (user_provided_out_event_name, event_process) {
match user_provided_out_event_name {
// User provided `OutEvent`.
(Some(name), false) => {
Some(name) => {
let definition = None;
let from_clauses = data_struct_fields
.iter()
@ -135,7 +112,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
(name, definition, from_clauses)
}
// User did not provide `OutEvent`. Generate it.
(None, false) => {
None => {
let name: syn::Type = syn::parse_str(&(ast.ident.to_string() + "Event")).unwrap();
let definition = {
let fields = data_struct_fields
@ -170,22 +147,6 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
let from_clauses = vec![];
(name, definition, from_clauses)
}
// User uses `NetworkBehaviourEventProcess`.
(name, true) => {
let definition = None;
let from_clauses = data_struct_fields
.iter()
.map(|field| {
let ty = &field.ty;
quote! {Self: #net_behv_event_proc<<#ty as #trait_to_impl>::OutEvent>}
})
.collect::<Vec<_>>();
(
name.unwrap_or_else(|| syn::parse_str("()").unwrap()),
definition,
from_clauses,
)
}
}
};
@ -545,13 +506,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
out_handler.unwrap_or(quote! {()}) // TODO: See test `empty`.
};
let generate_event_match_arm = if event_process {
quote! {
std::task::Poll::Ready(#network_behaviour_action::GenerateEvent(event)) => {
#net_behv_event_proc::inject_event(self, event)
}
}
} else {
let generate_event_match_arm = {
// If the `NetworkBehaviour`'s `OutEvent` is generated by the derive macro, wrap the sub
// `NetworkBehaviour` `OutEvent` in the variant of the generated `OutEvent`. If the
// `NetworkBehaviour`'s `OutEvent` is provided by the user, use the corresponding `From`

View File

@ -460,41 +460,6 @@ fn mixed_field_order() {
}
}
#[test]
fn event_process() {
#[allow(dead_code)]
#[derive(NetworkBehaviour)]
#[behaviour(event_process = true)]
struct Foo {
ping: libp2p::ping::Ping,
identify: libp2p::identify::Identify,
}
impl libp2p::swarm::NetworkBehaviourEventProcess<libp2p::identify::IdentifyEvent> for Foo {
fn inject_event(&mut self, _: libp2p::identify::IdentifyEvent) {}
}
impl libp2p::swarm::NetworkBehaviourEventProcess<libp2p::ping::PingEvent> for Foo {
fn inject_event(&mut self, _: libp2p::ping::PingEvent) {}
}
#[allow(dead_code, unreachable_code)]
fn bar() {
require_net_behaviour::<Foo>();
let mut _swarm: libp2p::Swarm<Foo> = unimplemented!();
let _ = async {
loop {
match _swarm.select_next_some().await {
SwarmEvent::Behaviour(()) => break,
_ => {}
}
}
};
}
}
#[test]
fn generated_out_event_derive_debug() {
#[allow(dead_code)]

View File

@ -1,3 +1,10 @@
# 0.39.0 - [unreleased]
- Remove deprecated `NetworkBehaviourEventProcess`. See [libp2p-swarm v0.38.0 changelog entry] for
migration path.
[libp2p-swarm v0.38.0 changelog entry]: https://github.com/libp2p/rust-libp2p/blob/master/swarm/CHANGELOG.md#0380
# 0.38.0
- Deprecate `NetworkBehaviourEventProcess`. When deriving `NetworkBehaviour` on a custom `struct` users

View File

@ -3,7 +3,7 @@ name = "libp2p-swarm"
edition = "2021"
rust-version = "1.56.1"
description = "The libp2p swarm"
version = "0.38.0"
version = "0.39.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -321,24 +321,6 @@ pub trait PollParameters {
fn local_peer_id(&self) -> &PeerId;
}
/// When deriving [`NetworkBehaviour`] this trait must by default be implemented for all the
/// possible event types generated by the inner behaviours.
///
/// You can opt out of this behaviour through `#[behaviour(event_process = false)]`. See the
/// documentation of [`NetworkBehaviour`] for details.
#[deprecated(
since = "0.38.0",
note = "Use `#[behaviour(out_event = \"MyBehaviourEvent\")]` instead. See \
https://github.com/libp2p/rust-libp2p/blob/master/swarm/CHANGELOG.md#0380 \
for instructions on how to migrate. Will be removed with \
https://github.com/libp2p/rust-libp2p/pull/2751."
)]
pub trait NetworkBehaviourEventProcess<TEvent> {
/// Called when one of the fields of the type you're deriving `NetworkBehaviour` on generates
/// an event.
fn inject_event(&mut self, event: TEvent);
}
/// An action that a [`NetworkBehaviour`] can trigger in the [`Swarm`]
/// in whose context it is executing.
///

View File

@ -19,8 +19,6 @@
// DEALINGS IN THE SOFTWARE.
use crate::handler::{either::IntoEitherHandler, ConnectionHandler, IntoConnectionHandler};
#[allow(deprecated)]
pub use crate::NetworkBehaviourEventProcess;
use crate::{DialError, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use either::Either;
use libp2p_core::{
@ -235,18 +233,3 @@ where
Poll::Ready(event)
}
}
#[allow(deprecated)]
impl<TEvent, TBehaviourLeft, TBehaviourRight> NetworkBehaviourEventProcess<TEvent>
for Either<TBehaviourLeft, TBehaviourRight>
where
TBehaviourLeft: NetworkBehaviourEventProcess<TEvent>,
TBehaviourRight: NetworkBehaviourEventProcess<TEvent>,
{
fn inject_event(&mut self, event: TEvent) {
match self {
Either::Left(a) => a.inject_event(event),
Either::Right(b) => b.inject_event(event),
}
}
}

View File

@ -23,8 +23,6 @@ use crate::handler::{
KeepAlive, SubstreamProtocol,
};
use crate::upgrade::{InboundUpgradeSend, OutboundUpgradeSend, SendWrapper};
#[allow(deprecated)]
pub use crate::NetworkBehaviourEventProcess;
use crate::{DialError, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use either::Either;
use libp2p_core::{
@ -232,18 +230,6 @@ where
}
}
#[allow(deprecated)]
impl<TEvent, TBehaviour> NetworkBehaviourEventProcess<TEvent> for Toggle<TBehaviour>
where
TBehaviour: NetworkBehaviourEventProcess<TEvent>,
{
fn inject_event(&mut self, event: TEvent) {
if let Some(inner) = self.inner.as_mut() {
inner.inject_event(event);
}
}
}
/// Implementation of `IntoConnectionHandler` that can be in the disabled state.
pub struct ToggleIntoConnectionHandler<TInner> {
inner: Option<TInner>,

View File

@ -63,8 +63,6 @@ pub mod behaviour;
pub mod dial_opts;
pub mod handler;
#[allow(deprecated)]
pub use behaviour::NetworkBehaviourEventProcess;
pub use behaviour::{
CloseConnection, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
};