core/: Remove TInEvent and TOutEvent (#2183)

TInEvent and TOutEvent are implied through THandler and thus
superflucious. Both are removed in favor of a derivation through
THandler.
This commit is contained in:
Max Inden
2021-08-11 12:41:28 +02:00
committed by GitHub
parent 7391b6e3f3
commit 008561283e
24 changed files with 356 additions and 244 deletions

View File

@ -27,7 +27,7 @@ use crate::protocols_handler::{
ProtocolsHandlerUpgrErr
};
use libp2p_core::Multiaddr;
use std::{marker::PhantomData, task::Context, task::Poll};
use std::{fmt::Debug, marker::PhantomData, task::Context, task::Poll};
/// Wrapper around a protocol handler that turns the input event into something else.
pub struct MapInEvent<TProtoHandler, TNewIn, TMap> {
@ -51,7 +51,7 @@ impl<TProtoHandler, TMap, TNewIn> ProtocolsHandler for MapInEvent<TProtoHandler,
where
TProtoHandler: ProtocolsHandler,
TMap: Fn(TNewIn) -> Option<TProtoHandler::InEvent>,
TNewIn: Send + 'static,
TNewIn: Debug + Send + 'static,
TMap: Send + 'static,
{
type InEvent = TNewIn;

View File

@ -27,6 +27,7 @@ use crate::protocols_handler::{
ProtocolsHandlerUpgrErr
};
use libp2p_core::Multiaddr;
use std::fmt::Debug;
use std::task::{Context, Poll};
/// Wrapper around a protocol handler that turns the output event into something else.
@ -49,7 +50,7 @@ impl<TProtoHandler, TMap, TNewOut> ProtocolsHandler for MapOutEvent<TProtoHandle
where
TProtoHandler: ProtocolsHandler,
TMap: FnMut(TProtoHandler::OutEvent) -> TNewOut,
TNewOut: Send + 'static,
TNewOut: Debug + Send + 'static,
TMap: Send + 'static,
{
type InEvent = TProtoHandler::InEvent;

View File

@ -43,7 +43,7 @@ use std::{
cmp,
collections::{HashMap, HashSet},
error,
fmt,
fmt::{self, Debug},
hash::Hash,
iter::{self, FromIterator},
task::{Context, Poll},
@ -88,7 +88,7 @@ where
impl<K, H> ProtocolsHandler for MultiHandler<K, H>
where
K: Clone + Hash + Eq + Send + 'static,
K: Clone + Debug + Hash + Eq + Send + 'static,
H: ProtocolsHandler,
H::InboundProtocol: InboundUpgradeSend,
H::OutboundProtocol: OutboundUpgradeSend
@ -312,7 +312,7 @@ where
impl<K, H> IntoProtocolsHandler for IntoMultiHandler<K, H>
where
K: Clone + Eq + Hash + Send + 'static,
K: Debug + Clone + Eq + Hash + Send + 'static,
H: IntoProtocolsHandler
{
type Handler = MultiHandler<K, H::Handler>;

View File

@ -28,7 +28,7 @@ use crate::protocols_handler::{
};
use smallvec::SmallVec;
use std::{error, task::Context, task::Poll, time::Duration};
use std::{error, fmt::Debug, task::Context, task::Poll, time::Duration};
use wasm_timer::Instant;
/// A `ProtocolsHandler` that opens a new substream for each request.
@ -119,12 +119,12 @@ where
impl<TInbound, TOutbound, TEvent> ProtocolsHandler for OneShotHandler<TInbound, TOutbound, TEvent>
where
TInbound: InboundUpgradeSend + Send + 'static,
TOutbound: OutboundUpgradeSend,
TOutbound: Debug + OutboundUpgradeSend,
TInbound::Output: Into<TEvent>,
TOutbound::Output: Into<TEvent>,
TOutbound::Error: error::Error + Send + 'static,
SubstreamProtocol<TInbound, ()>: Clone,
TEvent: Send + 'static,
TEvent: Debug + Send + 'static,
{
type InEvent = TOutbound;
type OutEvent = TEvent;