prs_lib/crypto/proto/
gpg.rs1#[derive(Clone)]
5pub struct Key {
6 pub fingerprint: String,
8
9 pub user_ids: Vec<String>,
11}
12
13impl Key {
14 pub fn fingerprint(&self, short: bool) -> String {
16 if short {
17 &self.fingerprint[self.fingerprint.len() - 16..]
18 } else {
19 &self.fingerprint
20 }
21 .trim()
22 .to_uppercase()
23 }
24
25 pub fn display_user(&self) -> String {
27 self.user_ids.join("; ")
28 }
29
30 pub fn into_key(self) -> crate::crypto::Key {
32 crate::crypto::Key::Gpg(self)
33 }
34}
35
36impl PartialEq for Key {
37 fn eq(&self, other: &Self) -> bool {
38 self.fingerprint.trim().to_uppercase() == other.fingerprint.trim().to_uppercase()
39 }
40}