debug: implemented fmt::Debug for Pubkey

This commit is contained in:
Ken Sedgwick
2024-08-13 12:25:02 -07:00
committed by William Casarin
parent dbb164970c
commit f00b301e88

View File

@@ -5,7 +5,7 @@ use nostr::bech32::Hrp;
use std::fmt; use std::fmt;
use tracing::debug; use tracing::debug;
#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash)] #[derive(Eq, PartialEq, Clone, Copy, Hash)]
pub struct Pubkey([u8; 32]); pub struct Pubkey([u8; 32]);
static HRP_NPUB: Hrp = Hrp::parse_unchecked("npub"); static HRP_NPUB: Hrp = Hrp::parse_unchecked("npub");
@@ -80,6 +80,12 @@ impl fmt::Display for Pubkey {
} }
} }
impl fmt::Debug for Pubkey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.hex())
}
}
impl From<Pubkey> for String { impl From<Pubkey> for String {
fn from(pk: Pubkey) -> Self { fn from(pk: Pubkey) -> Self {
pk.hex() pk.hex()