diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 224a147e..3eb0b860 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -85,7 +85,7 @@ pub use protocols_handler::{ pub type NegotiatedSubstream = Negotiated>; use protocols_handler::{NodeHandlerWrapperBuilder, NodeHandlerWrapperError}; -use futures::{prelude::*, executor::{ThreadPool, ThreadPoolBuilder}}; +use futures::{prelude::*, executor::{ThreadPool, ThreadPoolBuilder}, stream::FusedStream}; use libp2p_core::{ Executor, Negotiated, Transport, Multiaddr, PeerId, ProtocolName, muxing::{StreamMuxer, StreamMuxerBox}, @@ -502,6 +502,22 @@ where TBehaviour: NetworkBehaviour, } } +/// the stream of behaviour events never terminates, so we can implement fused for it +impl FusedStream for + ExpandedSwarm +where TBehaviour: NetworkBehaviour, + THandlerErr: error::Error + Send + 'static, + THandler: IntoProtocolsHandler + Send + 'static, + TInEvent: Send + 'static, + TOutEvent: Send + 'static, + THandler::Handler: ProtocolsHandler, + TConnInfo: ConnectionInfo + fmt::Debug + Clone + Send + 'static, +{ + fn is_terminated(&self) -> bool { + false + } +} + /// Parameters passed to `poll()`, that the `NetworkBehaviour` has access to. // TODO: #[derive(Debug)] pub struct SwarmPollParameters<'a> {