Commit
Author: Mauro D [mauro@stalw.art]
Hash: bfe77abd698c63887a8645a1453c066fa4430df8
Timestamp: Sun, 15 Jan 2023 17:40:51 +0000 (1 year ago)

+38 -1 +/-2 browse
Display impl for DKIM and DMARC results.
1diff --git a/src/common/base32.rs b/src/common/base32.rs
2index a53b2c9..cb0e5ea 100644
3--- a/src/common/base32.rs
4+++ b/src/common/base32.rs
5 @@ -50,7 +50,7 @@ impl Base32Writer {
6 }
7 }
8
9- fn push_byte(&mut self, byte: u8, is_remainder: bool) {
10+ pub fn push_byte(&mut self, byte: u8, is_remainder: bool) {
11 let (ch1, ch2) = match self.pos % 5 {
12 0 => ((byte & 0xF8) >> 3, u8::MAX),
13 1 => (
14 diff --git a/src/lib.rs b/src/lib.rs
15index 9f54172..aff4e34 100644
16--- a/src/lib.rs
17+++ b/src/lib.rs
18 @@ -513,6 +513,43 @@ impl Display for SpfResult {
19 }
20 }
21
22+ impl Display for IprevResult {
23+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24+ match self {
25+ IprevResult::Pass => f.write_str("pass"),
26+ IprevResult::Fail(err) => write!(f, "fail; {}", err),
27+ IprevResult::TempError(err) => write!(f, "temp error; {}", err),
28+ IprevResult::PermError(err) => write!(f, "perm error; {}", err),
29+ IprevResult::None => f.write_str("none"),
30+ }
31+ }
32+ }
33+
34+ impl Display for DkimResult {
35+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36+ match self {
37+ DkimResult::Pass => f.write_str("pass"),
38+ DkimResult::Fail(err) => write!(f, "fail; {}", err),
39+ DkimResult::Neutral(err) => write!(f, "neutral; {}", err),
40+ DkimResult::TempError(err) => write!(f, "temp error; {}", err),
41+ DkimResult::PermError(err) => write!(f, "perm error; {}", err),
42+ DkimResult::None => f.write_str("none"),
43+ }
44+ }
45+ }
46+
47+ impl Display for DmarcResult {
48+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49+ match self {
50+ DmarcResult::Pass => f.write_str("pass"),
51+ DmarcResult::Fail(err) => write!(f, "fail; {}", err),
52+ DmarcResult::TempError(err) => write!(f, "temp error; {}", err),
53+ DmarcResult::PermError(err) => write!(f, "perm error; {}", err),
54+ DmarcResult::None => f.write_str("none"),
55+ }
56+ }
57+ }
58+
59 impl From<io::Error> for Error {
60 fn from(err: io::Error) -> Self {
61 Error::Io(err.to_string())