mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-25 15:51:34 +00:00
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:
committed by
Pierre Krieger
parent
0eef1948e5
commit
466385a58a
@ -21,7 +21,7 @@
|
||||
use muxing::StreamMuxer;
|
||||
use nodes::node::{NodeEvent, NodeStream, Substream};
|
||||
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.
|
||||
// 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`.
|
||||
// TODO: impl Debug
|
||||
pub struct HandledNode<TMuxer, THandler>
|
||||
where
|
||||
TMuxer: StreamMuxer,
|
||||
@ -160,6 +159,21 @@ where
|
||||
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>
|
||||
where
|
||||
TMuxer: StreamMuxer,
|
||||
|
Reference in New Issue
Block a user