enostr: add Deref trait for Pubkey
This commit is contained in:
@@ -3,6 +3,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|||||||
use crate::Error;
|
use crate::Error;
|
||||||
use nostr::bech32::Hrp;
|
use nostr::bech32::Hrp;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::ops::Deref;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Clone, Copy, Hash)]
|
#[derive(Eq, PartialEq, Clone, Copy, Hash)]
|
||||||
@@ -10,6 +11,14 @@ pub struct Pubkey([u8; 32]);
|
|||||||
|
|
||||||
static HRP_NPUB: Hrp = Hrp::parse_unchecked("npub");
|
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 {
|
impl Pubkey {
|
||||||
pub fn new(data: [u8; 32]) -> Self {
|
pub fn new(data: [u8; 32]) -> Self {
|
||||||
Self(data)
|
Self(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user