swarm/src/behaviour: Deprecate NetworkBehaviourEventProcess (#2784)

In preparation for https://github.com/libp2p/rust-libp2p/pull/2751.
This commit is contained in:
Max Inden
2022-08-16 06:58:17 +02:00
committed by GitHub
parent 0e5a25dea8
commit 878c49fa14
9 changed files with 267 additions and 164 deletions

View File

@ -85,9 +85,9 @@ pub(crate) type THandlerOutEvent<THandler> =
/// "MyCustomOutEvent")]`. If the user does not specify an `out_event`, the derive macro generates
/// the event definition itself, naming it `<STRUCT_NAME>Event`.
///
/// When setting a custom `out_event`, the aforementioned conversion of each of the event types
/// generated by the struct members to the custom `out_event` is handled by [`From`]
/// implementations the user needs to provide.
/// The aforementioned conversion of each of the event types generated by the struct members to the
/// custom `out_event` is handled by [`From`] implementations which the user needs to define in
/// addition to the event `enum` itself.
///
/// ``` rust
/// # use libp2p::identify::{Identify, IdentifyEvent};
@ -326,6 +326,13 @@ pub trait PollParameters {
///
/// 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.