pub fn poll<'a, TMuxer>(
        &'a mut self,
        cx: &mut Context<'_>,
    ) -> Poll<
        NetworkEvent<'a, TTrans, THandlerInEvent<THandler>, THandlerOutEvent<THandler>, THandler>,
    >
    where
        TTrans: Transport<Output = (PeerId, TMuxer)>,
        TTrans::Error: Send + 'static,
        TTrans::Dial: Send + 'static,
        TTrans::ListenerUpgrade: Send + 'static,
        TMuxer: StreamMuxer + Send + Sync + 'static,
        TMuxer::Error: std::fmt::Debug,
        TMuxer::OutboundSubstream: Send,
        THandler: IntoConnectionHandler + Send + 'static,
        <THandler::Handler as ConnectionHandler>::Error: error::Error + Send + 'static,
        <THandler::Handler as ConnectionHandler>::OutboundOpenInfo: Send,
        <THandler::Handler as ConnectionHandler>::Error: error::Error + Send,
        THandler::Handler: ConnectionHandler<Substream = Substream<TMuxer>> + Send,
    {
        // Poll the listener(s) for new connections.
        match ListenersStream::poll(Pin::new(&mut self.listeners), cx) {
            Poll::Pending => (),
            Poll::Ready(ListenersEvent::Incoming {
                listener_id,
                upgrade,
                local_addr,
                send_back_addr,
            }) => {
                return Poll::Ready(NetworkEvent::IncomingConnection {
                    listener_id,
                    connection: IncomingConnection {
                        upgrade,
                        local_addr,
                        send_back_addr,
                    },
                })
            }
            Poll::Ready(ListenersEvent::NewAddress {
                listener_id,
                listen_addr,
            }) => {
                return Poll::Ready(NetworkEvent::NewListenerAddress {
                    listener_id,
                    listen_addr,
                })
            }
            Poll::Ready(ListenersEvent::AddressExpired {
                listener_id,
                listen_addr,
            }) => {
                return Poll::Ready(NetworkEvent::ExpiredListenerAddress {
                    listener_id,
                    listen_addr,
                })
            }
            Poll::Ready(ListenersEvent::Closed {
                listener_id,
                addresses,
                reason,
            }) => {
                return Poll::Ready(NetworkEvent::ListenerClosed {
                    listener_id,
                    addresses,
                    reason,
                })
            }
            Poll::Ready(ListenersEvent::Error { listener_id, error }) => {
                return Poll::Ready(NetworkEvent::ListenerError { listener_id, error })
            }
        }

        // Poll the known peers.
        let event = match self.pool.poll(cx) {
            Poll::Pending => return Poll::Pending,
            Poll::Ready(PoolEvent::ConnectionEstablished {
                connection,
                other_established_connection_ids,
                concurrent_dial_errors,
            }) => NetworkEvent::ConnectionEstablished {
                connection,
                other_established_connection_ids,
                concurrent_dial_errors,
            },
            Poll::Ready(PoolEvent::PendingOutboundConnectionError {
                id: _,
                error,
                handler,
                peer,
            }) => {
                if let Some(peer) = peer {
                    NetworkEvent::DialError {
                        handler,
                        peer_id: peer,
                        error,
                    }
                } else {
                    NetworkEvent::UnknownPeerDialError { error, handler }
                }
            }
            Poll::Ready(PoolEvent::PendingInboundConnectionError {
                id: _,
                send_back_addr,
                local_addr,
                error,
                handler,
            }) => NetworkEvent::IncomingConnectionError {
                error,
                handler,
                send_back_addr,
                local_addr,
            },
            Poll::Ready(PoolEvent::ConnectionClosed {
                id,
                connected,
                error,
                remaining_established_connection_ids,
                handler,
                ..
            }) => NetworkEvent::ConnectionClosed {
                id,
                connected,
                remaining_established_connection_ids,
                error,
                handler,
            },
            Poll::Ready(PoolEvent::ConnectionEvent { connection, event }) => {
                NetworkEvent::ConnectionEvent { connection, event }
            }
            Poll::Ready(PoolEvent::AddressChange {
                connection,
                new_endpoint,
                old_endpoint,
            }) => NetworkEvent::AddressChange {
                connection,
                new_endpoint,
                old_endpoint,
            },
        };

        Poll::Ready(event)
    }
/// Provides an API similar to `Stream`, except that it does not terminate.
Provides an API similar to `Stream`, except that it does not terminate.
Provides an API similar to ` Stream ` except that it does not terminate .
pub fn poll<'a, TMuxer>(
        &'a mut self,
        cx: &mut Context<'_>,
    ) -> Poll<
        NetworkEvent<'a, TTrans, THandlerInEvent<THandler>, THandlerOutEvent<THandler>, THandler>,
    >
    where
        TTrans: Transport<Output = (PeerId, TMuxer)>,
        TTrans::Error: Send + 'static,
        TTrans::Dial: Send + 'static,
        TTrans::ListenerUpgrade: Send + 'static,
        TMuxer: StreamMuxer + Send + Sync + 'static,
        TMuxer::Error: std::fmt::Debug,
        TMuxer::OutboundSubstream: Send,
        THandler: IntoConnectionHandler + Send + 'static,
        <THandler::Handler as ConnectionHandler>::Error: error::Error + Send + 'static,
        <THandler::Handler as ConnectionHandler>::OutboundOpenInfo: Send,
        <THandler::Handler as ConnectionHandler>::Error: error::Error + Send,
        THandler::Handler: ConnectionHandler<Substream = Substream<TMuxer>> + Send,
    {
        // Poll the listener(s) for new connections.
        match ListenersStream::poll(Pin::new(&mut self.listeners), cx) {
            Poll::Pending => (),
            Poll::Ready(ListenersEvent::Incoming {
                listener_id,
                upgrade,
                local_addr,
                send_back_addr,
            }) => {
                return Poll::Ready(NetworkEvent::IncomingConnection {
                    listener_id,
                    connection: IncomingConnection {
                        upgrade,
                        local_addr,
                        send_back_addr,
                    },
                })
            }
            Poll::Ready(ListenersEvent::NewAddress {
                listener_id,
                listen_addr,
            }) => {
                return Poll::Ready(NetworkEvent::NewListenerAddress {
                    listener_id,
                    listen_addr,
                })
            }
            Poll::Ready(ListenersEvent::AddressExpired {
                listener_id,
                listen_addr,
            }) => {
                return Poll::Ready(NetworkEvent::ExpiredListenerAddress {
                    listener_id,
                    listen_addr,
                })
            }
            Poll::Ready(ListenersEvent::Closed {
                listener_id,
                addresses,
                reason,
            }) => {
                return Poll::Ready(NetworkEvent::ListenerClosed {
                    listener_id,
                    addresses,
                    reason,
                })
            }
            Poll::Ready(ListenersEvent::Error { listener_id, error }) => {
                return Poll::Ready(NetworkEvent::ListenerError { listener_id, error })
            }
        }
        // Poll the known peers.
        let event = match self.pool.poll(cx) {
            Poll::Pending => return Poll::Pending,
            Poll::Ready(PoolEvent::ConnectionEstablished {
                connection,
                other_established_connection_ids,
                concurrent_dial_errors,
            }) => NetworkEvent::ConnectionEstablished {
                connection,
                other_established_connection_ids,
                concurrent_dial_errors,
            },
            Poll::Ready(PoolEvent::PendingOutboundConnectionError {
                id: _,
                error,
                handler,
                peer,
            }) => {
                if let Some(peer) = peer {
                    NetworkEvent::DialError {
                        handler,
                        peer_id: peer,
                        error,
                    }
                } else {
                    NetworkEvent::UnknownPeerDialError { error, handler }
                }
            }
            Poll::Ready(PoolEvent::PendingInboundConnectionError {
                id: _,
                send_back_addr,
                local_addr,
                error,
                handler,
            }) => NetworkEvent::IncomingConnectionError {
                error,
                handler,
                send_back_addr,
                local_addr,
            },
            Poll::Ready(PoolEvent::ConnectionClosed {
                id,
                connected,
                error,
                remaining_established_connection_ids,
                handler,
                ..
            }) => NetworkEvent::ConnectionClosed {
                id,
                connected,
                remaining_established_connection_ids,
                error,
                handler,
            },
            Poll::Ready(PoolEvent::ConnectionEvent { connection, event }) => {
                NetworkEvent::ConnectionEvent { connection, event }
            }
            Poll::Ready(PoolEvent::AddressChange {
                connection,
                new_endpoint,
                old_endpoint,
            }) => NetworkEvent::AddressChange {
                connection,
                new_endpoint,
                old_endpoint,
            },
        };
        Poll::Ready(event)
    }
pub fn poll < ' a , TMuxer > ( & ' a mut self , cx : & mut Context < ' _ > , ) -> Poll < NetworkEvent < ' a , TTrans , THandlerInEvent < THandler > , THandlerOutEvent < THandler > , THandler > , > where TTrans : Transport < Output = ( PeerId , TMuxer ) > , TTrans :: Error : Send + ' static , TTrans :: Dial : Send + ' static , TTrans :: ListenerUpgrade : Send + ' static , TMuxer : StreamMuxer + Send + Sync + ' static , TMuxer :: Error : std :: fmt :: Debug , TMuxer :: OutboundSubstream : Send , THandler : IntoConnectionHandler + Send + ' static , < THandler :: Handler as ConnectionHandler > :: Error : error :: Error + Send + ' static , < THandler :: Handler as ConnectionHandler > :: OutboundOpenInfo : Send , < THandler :: Handler as ConnectionHandler > :: Error : error :: Error + Send , THandler :: Handler : ConnectionHandler < Substream = Substream < TMuxer > > + Send , { // Poll the listener(s) for new connections. match ListenersStream :: poll ( Pin :: new ( & mut self . listeners ) , cx ) { Poll :: Pending => ( ) , Poll :: Ready ( ListenersEvent :: Incoming { listener_id , upgrade , local_addr , send_back_addr , } ) => { return Poll :: Ready ( NetworkEvent :: IncomingConnection { listener_id , connection : IncomingConnection { upgrade , local_addr , send_back_addr , } , } ) } Poll :: Ready ( ListenersEvent :: NewAddress { listener_id , listen_addr , } ) => { return Poll :: Ready ( NetworkEvent :: NewListenerAddress { listener_id , listen_addr , } ) } Poll :: Ready ( ListenersEvent :: AddressExpired { listener_id , listen_addr , } ) => { return Poll :: Ready ( NetworkEvent :: ExpiredListenerAddress { listener_id , listen_addr , } ) } Poll :: Ready ( ListenersEvent :: Closed { listener_id , addresses , reason , } ) => { return Poll :: Ready ( NetworkEvent :: ListenerClosed { listener_id , addresses , reason , } ) } Poll :: Ready ( ListenersEvent :: Error { listener_id , error } ) => { return Poll :: Ready ( NetworkEvent :: ListenerError { listener_id , error } ) } } // Poll the known peers. let event = match self . pool . poll ( cx ) { Poll :: Pending => return Poll :: Pending , Poll :: Ready ( PoolEvent :: ConnectionEstablished { connection , other_established_connection_ids , concurrent_dial_errors , } ) => NetworkEvent :: ConnectionEstablished { connection , other_established_connection_ids , concurrent_dial_errors , } , Poll :: Ready ( PoolEvent :: PendingOutboundConnectionError { id : _ , error , handler , peer , } ) => { if let Some ( peer ) = peer { NetworkEvent :: DialError { handler , peer_id : peer , error , } } else { NetworkEvent :: UnknownPeerDialError { error , handler } } } Poll :: Ready ( PoolEvent :: PendingInboundConnectionError { id : _ , send_back_addr , local_addr , error , handler , } ) => NetworkEvent :: IncomingConnectionError { error , handler , send_back_addr , local_addr , } , Poll :: Ready ( PoolEvent :: ConnectionClosed { id , connected , error , remaining_established_connection_ids , handler , .. } ) => NetworkEvent :: ConnectionClosed { id , connected , remaining_established_connection_ids , error , handler , } , Poll :: Ready ( PoolEvent :: ConnectionEvent { connection , event } ) => { NetworkEvent :: ConnectionEvent { connection , event } } Poll :: Ready ( PoolEvent :: AddressChange { connection , new_endpoint , old_endpoint , } ) => NetworkEvent :: AddressChange { connection , new_endpoint , old_endpoint , } , } ; Poll :: Ready ( event ) }
Provides an API similar to `Stream`, except that it does not terminate.
Provides an API similar to ` Stream ` except that it does not terminate .
&'a mut self
cx
&mut Context<'_>