mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-14 18:41:22 +00:00
refactor: expose and use THandlerOutEvent
type alias (#3368)
Previously, we used the full reference to the `OutEvent` of the `ConnectionHandler` in all implementations of `NetworkBehaviour`. Not only is this very verbose, it is also more brittle to changes. With the current implementation plan for #2824, we will be removing the `IntoConnectionHandler` abstraction. Using a type-alias to refer to the `OutEvent` makes the migration much easier.
This commit is contained in:
@ -29,7 +29,7 @@ pub use listen_addresses::ListenAddresses;
|
||||
use crate::connection::ConnectionId;
|
||||
use crate::dial_opts::DialOpts;
|
||||
use crate::handler::{ConnectionHandler, IntoConnectionHandler};
|
||||
use crate::{AddressRecord, AddressScore, DialError};
|
||||
use crate::{AddressRecord, AddressScore, DialError, THandlerOutEvent};
|
||||
use libp2p_core::{transport::ListenerId, ConnectedPoint, Multiaddr, PeerId};
|
||||
use std::{task::Context, task::Poll};
|
||||
|
||||
@ -37,9 +37,6 @@ use std::{task::Context, task::Poll};
|
||||
pub(crate) type THandlerInEvent<THandler> =
|
||||
<<THandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent;
|
||||
|
||||
pub(crate) type THandlerOutEvent<THandler> =
|
||||
<<THandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent;
|
||||
|
||||
/// A [`NetworkBehaviour`] defines the behaviour of the local node on the network.
|
||||
///
|
||||
/// In contrast to [`Transport`](libp2p_core::Transport) which defines **how** to send bytes on the
|
||||
@ -170,8 +167,7 @@ pub trait NetworkBehaviour: 'static {
|
||||
&mut self,
|
||||
_peer_id: PeerId,
|
||||
_connection_id: ConnectionId,
|
||||
_event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as
|
||||
ConnectionHandler>::OutEvent,
|
||||
_event: THandlerOutEvent<Self>,
|
||||
);
|
||||
|
||||
/// Polls for things that swarm should do.
|
||||
@ -264,7 +260,7 @@ pub enum NetworkBehaviourAction<
|
||||
/// # use libp2p_plaintext::PlainText2Config;
|
||||
/// # use libp2p_swarm::{
|
||||
/// # ConnectionId, DialError, IntoConnectionHandler, KeepAlive, NegotiatedSubstream,
|
||||
/// # FromSwarm, DialFailure,
|
||||
/// # FromSwarm, DialFailure, THandlerOutEvent,
|
||||
/// # NetworkBehaviour, NetworkBehaviourAction, PollParameters, ConnectionHandler,
|
||||
/// # ConnectionHandlerEvent, ConnectionHandlerUpgrErr, SubstreamProtocol, Swarm, SwarmEvent,
|
||||
/// # };
|
||||
@ -334,7 +330,7 @@ pub enum NetworkBehaviourAction<
|
||||
/// # &mut self,
|
||||
/// # _: PeerId,
|
||||
/// # _: ConnectionId,
|
||||
/// # _: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent,
|
||||
/// # _: THandlerOutEvent<Self>,
|
||||
/// # ) {
|
||||
/// # unreachable!();
|
||||
/// # }
|
||||
|
Reference in New Issue
Block a user