Skip to content

Commit 9527a8d

Browse files
committed
Manually impl Debug for PartialMessage
1 parent 31e80b4 commit 9527a8d

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

protocols/gossipsub/src/extensions/partial_messages.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use std::{
2222
cmp::max,
2323
collections::{BTreeSet, HashMap, HashSet},
24-
fmt::Debug,
24+
fmt::{self, Debug},
2525
};
2626

2727
use libp2p_core::PeerId;
@@ -655,7 +655,7 @@ pub(crate) enum ReceivedAction {
655655
}
656656

657657
/// A Partial message sent and received from remote peers.
658-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
658+
#[derive(Clone, PartialEq, Eq, Hash)]
659659
pub struct PartialMessage {
660660
/// The group ID that identifies the complete logical message.
661661
pub group_id: Vec<u8>,
@@ -667,6 +667,20 @@ pub struct PartialMessage {
667667
pub metadata: Option<Vec<u8>>,
668668
}
669669

670+
impl Debug for PartialMessage {
671+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
672+
f.debug_struct("PartialMessage")
673+
.field("group_id", &self.group_id)
674+
.field("topic_hash", &self.topic_hash)
675+
.field(
676+
"body length",
677+
&self.body.as_ref().map(|body| body.len()).unwrap_or(0),
678+
)
679+
.field("metadata", &self.metadata)
680+
.finish()
681+
}
682+
}
683+
670684
/// Stored `Metadata` for a peer,
671685
/// `Remote` or `Local` depends on who last updated it.
672686
#[derive(Debug)]

0 commit comments

Comments
 (0)