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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use chrono::{DateTime, Utc};
use gpgme::{Subkey, UserIdSignature};
pub fn get_subkey_flags(subkey: Subkey) -> String {
format!(
"{}{}{}{}",
if subkey.can_sign() { "s" } else { "-" },
if subkey.can_certify() { "c" } else { "-" },
if subkey.can_encrypt() { "e" } else { "-" },
if subkey.can_authenticate() { "a" } else { "-" },
)
}
pub fn get_subkey_time(subkey: Subkey, format: &str) -> String {
format!(
"({}){}{}{}{}{}{}",
if let Some(date) = subkey.creation_time() {
DateTime::<Utc>::from(date).format(format).to_string()
} else {
String::from("[?]")
},
if let Some(date) = subkey.expiration_time() {
DateTime::<Utc>::from(date)
.format(&format!(" ─> ({})", format))
.to_string()
} else {
String::new()
},
if subkey.is_expired() { " [exp]" } else { "" },
if subkey.is_revoked() { " [rev]" } else { "" },
if subkey.is_disabled() { " [d]" } else { "" },
if subkey.is_invalid() { " [i]" } else { "" },
if subkey.is_qualified() { " [q]" } else { "" }
)
}
pub fn get_signature_time(signature: UserIdSignature, format: &str) -> String {
format!(
"({}){}{}{}{}{}",
if let Some(date) = signature.creation_time() {
DateTime::<Utc>::from(date).format(format).to_string()
} else {
String::from("[?]")
},
if let Some(date) = signature.expiration_time() {
DateTime::<Utc>::from(date)
.format(&format!(" ─> ({})", format))
.to_string()
} else {
String::new()
},
if signature.is_expired() { " [exp]" } else { "" },
if signature.is_revocation() {
" [rev]"
} else {
""
},
if signature.is_invalid() { " [i]" } else { "" },
if !signature.is_exportable() {
" [!x]"
} else {
""
},
)
}