Skip to content

Commit e3e9d28

Browse files
committed
feat: Add Debug impl to PeerId and move raw ID string there
1 parent a3ea1d4 commit e3e9d28

File tree

1 file changed

+13
-8
lines changed
  • crates/libtortillas/src/peer

1 file changed

+13
-8
lines changed

crates/libtortillas/src/peer/id.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,19 +409,24 @@ impl From<Hash<20>> for PeerId {
409409
impl fmt::Display for PeerId {
410410
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
411411
if let Some(version) = self.version() {
412-
write!(
413-
f,
414-
"{} {} ({})",
415-
self.client_name(),
416-
version,
417-
String::from_utf8_lossy(self.id())
418-
)
412+
write!(f, "{} {}", self.client_name(), version)
419413
} else {
420-
write!(f, "{} ({})", self.client_name(), hex::encode(self.id()))
414+
write!(f, "{}", self.client_name())
421415
}
422416
}
423417
}
424418

419+
impl fmt::Debug for PeerId {
420+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
421+
write!(
422+
f,
423+
"{} ({})",
424+
self.client_name(),
425+
String::from_utf8_lossy(self.id())
426+
)
427+
}
428+
}
429+
425430
impl FromStr for PeerId {
426431
type Err = std::array::TryFromSliceError;
427432

0 commit comments

Comments
 (0)