mirror of
https://github.com/aljazceru/notedeck.git
synced 2026-01-13 05:14:22 +01:00
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 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