swarm/src: Remove ConnectionHandler (#2519)

The `ConnectionHandler` trait is not exposed to users. The only
implementor of `ConnectionHandler` is `NodeHandlerWrapper`. Thus
`ConnectionHandler` is a superfluous abstraction. This commit removes
`ConnectionHandler`.

Next to this large change, this commit removes the `Tmuxer` trait
parameter. `Swarm` enforces dynamic dispatching via `StreamMuxerBox`
anyways, thus the trait parameter is useless.

As a follow up to this commit one could rename `ProtocolsHandler` to
`ConnectionHandler` and `NodeHandlerWrapper` to
`ConnectionHandlerWrapper` or just `Wrapper`.
This commit is contained in:
Max Inden
2022-02-16 13:15:52 +01:00
committed by GitHub
parent df4905d798
commit 8ffa84e786
8 changed files with 155 additions and 239 deletions

View File

@ -31,9 +31,12 @@ use libp2p_core::{
use std::{task::Context, task::Poll};
/// Custom event that can be received by the [`ProtocolsHandler`].
type THandlerInEvent<THandler> =
pub(crate) type THandlerInEvent<THandler> =
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent;
pub(crate) type THandlerOutEvent<THandler> =
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::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