Add an impl Debug for HandledNode (#628)

* Add an impl Debug for HandledNode

* Update core/src/nodes/handled_node.rs

Co-Authored-By: jamesray1 <16969914+jamesray1@users.noreply.github.com>

* Update core/src/nodes/handled_node.rs

Co-Authored-By: jamesray1 <16969914+jamesray1@users.noreply.github.com>

* Update core/src/nodes/handled_node.rs

Co-Authored-By: jamesray1 <16969914+jamesray1@users.noreply.github.com>

* Update core/src/nodes/handled_node.rs

Co-Authored-By: jamesray1 <16969914+jamesray1@users.noreply.github.com>
This commit is contained in:
James Ray
2018-11-15 10:22:45 +00:00
committed by Pierre Krieger
parent 0eef1948e5
commit 466385a58a

View File

@ -21,7 +21,7 @@
use muxing::StreamMuxer; use muxing::StreamMuxer;
use nodes::node::{NodeEvent, NodeStream, Substream}; use nodes::node::{NodeEvent, NodeStream, Substream};
use futures::{prelude::*, stream::Fuse}; use futures::{prelude::*, stream::Fuse};
use std::io::Error as IoError; use std::{io::Error as IoError, fmt};
/// Handler for the substreams of a node. /// Handler for the substreams of a node.
// TODO: right now it is possible for a node handler to be built, then shut down right after if we // TODO: right now it is possible for a node handler to be built, then shut down right after if we
@ -144,7 +144,6 @@ impl<TOutboundOpenInfo, TCustom> NodeHandlerEvent<TOutboundOpenInfo, TCustom> {
} }
/// A node combined with an implementation of `NodeHandler`. /// A node combined with an implementation of `NodeHandler`.
// TODO: impl Debug
pub struct HandledNode<TMuxer, THandler> pub struct HandledNode<TMuxer, THandler>
where where
TMuxer: StreamMuxer, TMuxer: StreamMuxer,
@ -160,6 +159,21 @@ where
is_shutting_down: bool is_shutting_down: bool
} }
impl<TMuxer, THandler> fmt::Debug for HandledNode<TMuxer, THandler>
where
TMuxer: StreamMuxer,
THandler: NodeHandler<Substream = Substream<TMuxer>> + fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("HandledNode")
.field("node", &self.node)
.field("handler", &self.handler)
.field("handler_is_done", &self.handler_is_done)
.field("is_shutting_down", &self.is_shutting_down)
.finish()
}
}
impl<TMuxer, THandler> HandledNode<TMuxer, THandler> impl<TMuxer, THandler> HandledNode<TMuxer, THandler>
where where
TMuxer: StreamMuxer, TMuxer: StreamMuxer,