muxing: adds an error type to streammuxer (#1083)

* muxing: adds an error type to streammuxer

* Update examples/chat.rs

Co-Authored-By: montekki <fedor.sakharov@gmail.com>

* make the trait error type bound to io error
This commit is contained in:
Fedor Sakharov
2019-04-28 14:42:18 +03:00
committed by Pierre Krieger
parent 47a775dbce
commit 68df8c07cf
11 changed files with 91 additions and 78 deletions

View File

@ -150,7 +150,7 @@ where TMuxer: muxing::StreamMuxer + Send + Sync + 'static,
self.state = IdRetrieverState::OpeningSubstream(muxer, opening, config);
return Ok(Async::NotReady);
},
Err(err) => return Err(UpgradeError::Apply(err))
Err(err) => return Err(UpgradeError::Apply(err.into()))
}
},
IdRetrieverState::NegotiatingIdentify(muxer, mut nego) => {

View File

@ -238,7 +238,7 @@ mod tests {
use tokio::runtime::current_thread;
fn transport() -> (identity::PublicKey, impl Transport<
Output = (PeerId, impl StreamMuxer<Substream = impl Send, OutboundSubstream = impl Send>),
Output = (PeerId, impl StreamMuxer<Substream = impl Send, OutboundSubstream = impl Send, Error = impl Into<io::Error>>),
Listener = impl Send,
ListenerUpgrade = impl Send,
Dial = impl Send,

View File

@ -34,7 +34,7 @@ use libp2p_yamux as yamux;
use libp2p_secio::SecioConfig;
use libp2p_tcp::TcpConfig;
use futures::{future, prelude::*};
use std::{fmt, time::Duration, sync::mpsc::sync_channel};
use std::{fmt, io, time::Duration, sync::mpsc::sync_channel};
use tokio::runtime::Runtime;
#[test]
@ -102,7 +102,7 @@ fn ping() {
}
fn mk_transport() -> (PeerId, impl Transport<
Output = (PeerId, impl StreamMuxer<Substream = impl Send, OutboundSubstream = impl Send>),
Output = (PeerId, impl StreamMuxer<Substream = impl Send, OutboundSubstream = impl Send, Error = impl Into<io::Error>>),
Listener = impl Send,
ListenerUpgrade = impl Send,
Dial = impl Send,