Add an error associated type to ProtocolsHandler (#795)

This commit is contained in:
Pierre Krieger
2018-12-28 15:11:35 +01:00
committed by GitHub
parent d10cafa804
commit 7798e23e78
13 changed files with 36 additions and 27 deletions

View File

@ -33,7 +33,7 @@ use std::{
time::{Duration, Instant},
};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_timer::Delay;
use tokio_timer::{self, Delay};
use void::{Void, unreachable};
/// Protocol handler that handles pinging the remote at a regular period.
@ -153,6 +153,7 @@ where
{
type InEvent = Void;
type OutEvent = OutEvent;
type Error = io::Error; // TODO: more precise error type
type Substream = TSubstream;
type InboundProtocol = DeniedUpgrade;
type OutboundProtocol = Ping<Instant>;

View File

@ -30,7 +30,6 @@ use libp2p_core::{
upgrade::DeniedUpgrade
};
use log::warn;
use std::io;
use tokio_io::{AsyncRead, AsyncWrite};
use void::{Void, unreachable};
@ -72,6 +71,7 @@ where
{
type InEvent = Void;
type OutEvent = Void;
type Error = Void;
type Substream = TSubstream;
type InboundProtocol = Ping<()>;
type OutboundProtocol = DeniedUpgrade;
@ -118,7 +118,7 @@ where
&mut self,
) -> Poll<
Option<ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>>,
io::Error,
Self::Error,
> {
// Removes each substream one by one, and pushes them back if they're not ready (which
// should be the case 99% of the time).