enostr: add Deref trait for Pubkey
This commit is contained in:
1 parent
de8029d60f
commit
bdea3da5f0
1 file changed
+9
@@ -3,6 +3,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use crate::Error;
|
||||
use nostr::bech32::Hrp;
|
||||
use std::fmt;
|
||||
use std::ops::Deref;
|
||||
use tracing::debug;
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Copy, Hash)]
|
||||
@@ -10,6 +11,14 @@ pub struct Pubkey([u8; 32]);
|
||||
|
||||
static HRP_NPUB: Hrp = Hrp::parse_unchecked("npub");
|
||||
|
||||
impl Deref for Pubkey {
|
||||
type Target = [u8; 32];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Pubkey {
|
||||
pub fn new(data: [u8; 32]) -> Self {
|
||||
Self(data)
|
||||
|
||||
Reference in new issue
Block a user