mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-18 12:31:22 +00:00
Implement FusedStream for Swarm (#1433)
* Implement FusedStream for Swarm The stream for swarm will never terminate, and therefore does not have to keep track of termination. * Get rid of the wall of complex type constraints ...as they don't seem to be necessary anymore for latest master
This commit is contained in:
@ -85,7 +85,7 @@ pub use protocols_handler::{
|
|||||||
pub type NegotiatedSubstream = Negotiated<Substream<StreamMuxerBox>>;
|
pub type NegotiatedSubstream = Negotiated<Substream<StreamMuxerBox>>;
|
||||||
|
|
||||||
use protocols_handler::{NodeHandlerWrapperBuilder, NodeHandlerWrapperError};
|
use protocols_handler::{NodeHandlerWrapperBuilder, NodeHandlerWrapperError};
|
||||||
use futures::{prelude::*, executor::{ThreadPool, ThreadPoolBuilder}};
|
use futures::{prelude::*, executor::{ThreadPool, ThreadPoolBuilder}, stream::FusedStream};
|
||||||
use libp2p_core::{
|
use libp2p_core::{
|
||||||
Executor, Negotiated, Transport, Multiaddr, PeerId, ProtocolName,
|
Executor, Negotiated, Transport, Multiaddr, PeerId, ProtocolName,
|
||||||
muxing::{StreamMuxer, StreamMuxerBox},
|
muxing::{StreamMuxer, StreamMuxerBox},
|
||||||
@ -502,6 +502,22 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// the stream of behaviour events never terminates, so we can implement fused for it
|
||||||
|
impl<TBehaviour, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo> FusedStream for
|
||||||
|
ExpandedSwarm<TBehaviour, TInEvent, TOutEvent, THandler, THandlerErr, TConnInfo>
|
||||||
|
where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||||
|
THandlerErr: error::Error + Send + 'static,
|
||||||
|
THandler: IntoProtocolsHandler + Send + 'static,
|
||||||
|
TInEvent: Send + 'static,
|
||||||
|
TOutEvent: Send + 'static,
|
||||||
|
THandler::Handler: ProtocolsHandler<InEvent = TInEvent, OutEvent = TOutEvent, Error = THandlerErr>,
|
||||||
|
TConnInfo: ConnectionInfo<PeerId = PeerId> + fmt::Debug + Clone + Send + 'static,
|
||||||
|
{
|
||||||
|
fn is_terminated(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Parameters passed to `poll()`, that the `NetworkBehaviour` has access to.
|
/// Parameters passed to `poll()`, that the `NetworkBehaviour` has access to.
|
||||||
// TODO: #[derive(Debug)]
|
// TODO: #[derive(Debug)]
|
||||||
pub struct SwarmPollParameters<'a> {
|
pub struct SwarmPollParameters<'a> {
|
||||||
|
Reference in New Issue
Block a user