1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use bitcoin::secp256k1::XOnlyPublicKey;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Deserialize, Serialize)]
pub struct Contact {
pub pk: XOnlyPublicKey,
pub relay_url: Option<String>,
pub alias: Option<String>,
}
impl Contact {
pub fn new<S>(pk: XOnlyPublicKey, relay_url: Option<S>, alias: Option<S>) -> Self
where
S: Into<String>,
{
Self {
pk,
relay_url: relay_url.map(|a| a.into()),
alias: alias.map(|a| a.into()),
}
}
}