mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-22 14:21:33 +00:00
Fix stack overflow when printing a SubstreamRef (#599)
* Fix stack overflow when printing a SubstreamRef * Fix concern * More problems
This commit is contained in:
@ -268,9 +268,10 @@ impl<P> fmt::Debug for SubstreamRef<P>
|
||||
where
|
||||
P: Deref,
|
||||
P::Target: StreamMuxer,
|
||||
<P::Target as StreamMuxer>::Substream: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
write!(f, "Substream({:?})", self)
|
||||
write!(f, "Substream({:?})", self.substream)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,6 @@ enum StreamState {
|
||||
}
|
||||
|
||||
/// Event that can happen on the `NodeStream`.
|
||||
#[derive(Debug)]
|
||||
pub enum NodeEvent<TMuxer, TUserData>
|
||||
where
|
||||
TMuxer: muxing::StreamMuxer,
|
||||
@ -346,32 +345,37 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
/*impl<TTrans> fmt::Debug for NodeEvent<TTrans>
|
||||
where TTrans: Transport,
|
||||
<TTrans::Listener as Stream>::Error: fmt::Debug,
|
||||
impl<TMuxer, TUserData> fmt::Debug for NodeEvent<TMuxer, TUserData>
|
||||
where
|
||||
TMuxer: muxing::StreamMuxer,
|
||||
TMuxer::Substream: fmt::Debug,
|
||||
TUserData: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
NodeEvent::Incoming { ref listen_addr, .. } => {
|
||||
f.debug_struct("NodeEvent::Incoming")
|
||||
.field("listen_addr", listen_addr)
|
||||
NodeEvent::InboundSubstream { substream } => {
|
||||
f.debug_struct("NodeEvent::OutboundClosed")
|
||||
.field("substream", substream)
|
||||
.finish()
|
||||
},
|
||||
NodeEvent::Closed { ref listen_addr, .. } => {
|
||||
f.debug_struct("NodeEvent::Closed")
|
||||
.field("listen_addr", listen_addr)
|
||||
NodeEvent::OutboundSubstream { user_data, substream } => {
|
||||
f.debug_struct("NodeEvent::OutboundSubstream")
|
||||
.field("user_data", user_data)
|
||||
.field("substream", substream)
|
||||
.finish()
|
||||
},
|
||||
NodeEvent::Error { ref listen_addr, ref error, .. } => {
|
||||
f.debug_struct("NodeEvent::Error")
|
||||
.field("listen_addr", listen_addr)
|
||||
.field("error", error)
|
||||
NodeEvent::OutboundClosed { user_data } => {
|
||||
f.debug_struct("NodeEvent::OutboundClosed")
|
||||
.field("user_data", user_data)
|
||||
.finish()
|
||||
},
|
||||
NodeEvent::InboundClosed => {
|
||||
f.debug_struct("NodeEvent::InboundClosed")
|
||||
.finish()
|
||||
},
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod node_stream {
|
||||
|
@ -27,9 +27,11 @@ use muxing::{StreamMuxer, Shutdown};
|
||||
use futures::prelude::*;
|
||||
|
||||
/// Substream type
|
||||
#[derive(Debug)]
|
||||
pub struct DummySubstream {}
|
||||
|
||||
/// OutboundSubstream type
|
||||
#[derive(Debug)]
|
||||
pub struct DummyOutboundSubstream {}
|
||||
|
||||
/// Control the muxer state by setting the "connection" state as to set up a mock
|
||||
|
Reference in New Issue
Block a user