mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-26 16:21:39 +00:00
swarm/src/behaviour: Deprecate NetworkBehaviourEventProcess (#2784)
In preparation for https://github.com/libp2p/rust-libp2p/pull/2751.
This commit is contained in:
@ -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.
|
||||
|
@ -19,10 +19,9 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use crate::handler::{either::IntoEitherHandler, ConnectionHandler, IntoConnectionHandler};
|
||||
use crate::{
|
||||
DialError, NetworkBehaviour, NetworkBehaviourAction, NetworkBehaviourEventProcess,
|
||||
PollParameters,
|
||||
};
|
||||
#[allow(deprecated)]
|
||||
pub use crate::NetworkBehaviourEventProcess;
|
||||
use crate::{DialError, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
|
||||
use either::Either;
|
||||
use libp2p_core::{
|
||||
connection::ConnectionId, transport::ListenerId, ConnectedPoint, Multiaddr, PeerId,
|
||||
@ -237,6 +236,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl<TEvent, TBehaviourLeft, TBehaviourRight> NetworkBehaviourEventProcess<TEvent>
|
||||
for Either<TBehaviourLeft, TBehaviourRight>
|
||||
where
|
||||
|
@ -23,10 +23,9 @@ use crate::handler::{
|
||||
KeepAlive, SubstreamProtocol,
|
||||
};
|
||||
use crate::upgrade::{InboundUpgradeSend, OutboundUpgradeSend, SendWrapper};
|
||||
use crate::{
|
||||
DialError, NetworkBehaviour, NetworkBehaviourAction, NetworkBehaviourEventProcess,
|
||||
PollParameters,
|
||||
};
|
||||
#[allow(deprecated)]
|
||||
pub use crate::NetworkBehaviourEventProcess;
|
||||
use crate::{DialError, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
|
||||
use either::Either;
|
||||
use libp2p_core::{
|
||||
connection::ConnectionId,
|
||||
@ -233,6 +232,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl<TEvent, TBehaviour> NetworkBehaviourEventProcess<TEvent> for Toggle<TBehaviour>
|
||||
where
|
||||
TBehaviour: NetworkBehaviourEventProcess<TEvent>,
|
||||
|
@ -63,9 +63,10 @@ pub mod behaviour;
|
||||
pub mod dial_opts;
|
||||
pub mod handler;
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub use behaviour::NetworkBehaviourEventProcess;
|
||||
pub use behaviour::{
|
||||
CloseConnection, NetworkBehaviour, NetworkBehaviourAction, NetworkBehaviourEventProcess,
|
||||
NotifyHandler, PollParameters,
|
||||
CloseConnection, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
|
||||
};
|
||||
pub use connection::{
|
||||
ConnectionCounters, ConnectionError, ConnectionLimit, ConnectionLimits, PendingConnectionError,
|
||||
|
Reference in New Issue
Block a user