mail_auth/report/arf/
mod.rs1use super::{AuthFailureType, DeliveryResult, Feedback, FeedbackType, IdentityAlignment};
8use std::{borrow::Cow, net::IpAddr};
9
10pub mod generate;
11pub mod parse;
12
13impl<'x> Feedback<'x> {
14 pub fn new(feedback_type: FeedbackType) -> Self {
15 Feedback {
16 feedback_type,
17 version: 1,
18 incidents: 1,
19 ..Default::default()
20 }
21 }
22
23 pub fn original_envelope_id(&self) -> Option<&str> {
24 self.original_envelope_id.as_deref()
25 }
26
27 pub fn feedback_type(&self) -> FeedbackType {
28 self.feedback_type
29 }
30
31 pub fn with_original_envelope_id(mut self, value: impl Into<Cow<'x, str>>) -> Self {
32 self.original_envelope_id = Some(value.into());
33 self
34 }
35
36 pub fn original_mail_from(&self) -> Option<&str> {
37 self.original_mail_from.as_deref()
38 }
39
40 pub fn with_original_mail_from(mut self, value: impl Into<Cow<'x, str>>) -> Self {
41 self.original_mail_from = Some(value.into());
42 self
43 }
44
45 pub fn original_rcpt_to(&self) -> Option<&str> {
46 self.original_rcpt_to.as_deref()
47 }
48
49 pub fn with_original_rcpt_to(mut self, value: impl Into<Cow<'x, str>>) -> Self {
50 self.original_rcpt_to = Some(value.into());
51 self
52 }
53
54 pub fn reporting_mta(&self) -> Option<&str> {
55 self.reporting_mta.as_deref()
56 }
57
58 pub fn with_reporting_mta(mut self, value: impl Into<Cow<'x, str>>) -> Self {
59 self.reporting_mta = Some(value.into());
60 self
61 }
62
63 pub fn user_agent(&self) -> Option<&str> {
64 self.user_agent.as_deref()
65 }
66
67 pub fn with_user_agent(mut self, value: impl Into<Cow<'x, str>>) -> Self {
68 self.user_agent = Some(value.into());
69 self
70 }
71
72 pub fn source_ip(&self) -> Option<IpAddr> {
73 self.source_ip
74 }
75
76 pub fn with_source_ip(mut self, value: IpAddr) -> Self {
77 self.source_ip = Some(value);
78 self
79 }
80
81 pub fn dkim_adsp_dns(&self) -> Option<&str> {
82 self.dkim_adsp_dns.as_deref()
83 }
84
85 pub fn with_dkim_adsp_dns(mut self, value: impl Into<Cow<'x, str>>) -> Self {
86 self.dkim_adsp_dns = Some(value.into());
87 self
88 }
89
90 pub fn dkim_canonicalized_body(&self) -> Option<&str> {
91 self.dkim_canonicalized_body.as_deref()
92 }
93
94 pub fn with_dkim_canonicalized_body(mut self, value: impl Into<Cow<'x, str>>) -> Self {
95 self.dkim_canonicalized_body = Some(value.into());
96 self
97 }
98
99 pub fn dkim_canonicalized_header(&self) -> Option<&str> {
100 self.dkim_canonicalized_header.as_deref()
101 }
102
103 pub fn with_dkim_canonicalized_header(mut self, value: impl Into<Cow<'x, str>>) -> Self {
104 self.dkim_canonicalized_header = Some(value.into());
105 self
106 }
107
108 pub fn dkim_domain(&self) -> Option<&str> {
109 self.dkim_domain.as_deref()
110 }
111
112 pub fn with_dkim_domain(mut self, value: impl Into<Cow<'x, str>>) -> Self {
113 self.dkim_domain = Some(value.into());
114 self
115 }
116
117 pub fn dkim_identity(&self) -> Option<&str> {
118 self.dkim_identity.as_deref()
119 }
120
121 pub fn with_dkim_identity(mut self, value: impl Into<Cow<'x, str>>) -> Self {
122 self.dkim_identity = Some(value.into());
123 self
124 }
125
126 pub fn dkim_selector(&self) -> Option<&str> {
127 self.dkim_selector.as_deref()
128 }
129
130 pub fn with_dkim_selector(mut self, value: impl Into<Cow<'x, str>>) -> Self {
131 self.dkim_selector = Some(value.into());
132 self
133 }
134
135 pub fn dkim_selector_dns(&self) -> Option<&str> {
136 self.dkim_selector_dns.as_deref()
137 }
138
139 pub fn with_dkim_selector_dns(mut self, value: impl Into<Cow<'x, str>>) -> Self {
140 self.dkim_selector_dns = Some(value.into());
141 self
142 }
143
144 pub fn spf_dns(&self) -> Option<&str> {
145 self.spf_dns.as_deref()
146 }
147
148 pub fn with_spf_dns(mut self, value: impl Into<Cow<'x, str>>) -> Self {
149 self.spf_dns = Some(value.into());
150 self
151 }
152
153 pub fn message(&self) -> Option<&str> {
154 self.message.as_deref()
155 }
156
157 pub fn with_message(mut self, value: impl Into<Cow<'x, str>>) -> Self {
158 self.message = Some(value.into());
159 self
160 }
161
162 pub fn headers(&self) -> Option<&str> {
163 self.message.as_deref()
164 }
165
166 pub fn with_headers(mut self, value: impl Into<Cow<'x, str>>) -> Self {
167 self.headers = Some(value.into());
168 self
169 }
170
171 pub fn arrival_date(&self) -> Option<i64> {
172 self.arrival_date
173 }
174
175 pub fn with_arrival_date(mut self, value: i64) -> Self {
176 self.arrival_date = Some(value);
177 self
178 }
179
180 pub fn incidents(&self) -> u32 {
181 self.incidents
182 }
183
184 pub fn with_incidents(mut self, value: u32) -> Self {
185 self.incidents = value;
186 self
187 }
188
189 pub fn version(&self) -> u32 {
190 self.version
191 }
192
193 pub fn with_version(mut self, value: u32) -> Self {
194 self.version = value;
195 self
196 }
197
198 pub fn source_port(&self) -> u32 {
199 self.source_port
200 }
201
202 pub fn with_source_port(mut self, value: u32) -> Self {
203 self.source_port = value;
204 self
205 }
206
207 pub fn authentication_results(&self) -> &[Cow<'x, str>] {
208 &self.authentication_results
209 }
210
211 pub fn with_authentication_results(mut self, value: impl Into<Cow<'x, str>>) -> Self {
212 self.authentication_results.push(value.into());
213 self
214 }
215
216 pub fn reported_domain(&self) -> &[Cow<'x, str>] {
217 &self.reported_domain
218 }
219
220 pub fn with_reported_domain(mut self, value: impl Into<Cow<'x, str>>) -> Self {
221 self.reported_domain.push(value.into());
222 self
223 }
224
225 pub fn reported_uri(&self) -> &[Cow<'x, str>] {
226 &self.reported_uri
227 }
228
229 pub fn with_reported_uri(mut self, value: impl Into<Cow<'x, str>>) -> Self {
230 self.reported_uri.push(value.into());
231 self
232 }
233
234 pub fn auth_failure(&self) -> AuthFailureType {
235 self.auth_failure
236 }
237
238 pub fn with_auth_failure(mut self, value: AuthFailureType) -> Self {
239 self.auth_failure = value;
240 self
241 }
242
243 pub fn delivery_result(&self) -> DeliveryResult {
244 self.delivery_result
245 }
246
247 pub fn with_delivery_result(mut self, value: DeliveryResult) -> Self {
248 self.delivery_result = value;
249 self
250 }
251
252 pub fn identity_alignment(&self) -> IdentityAlignment {
253 self.identity_alignment
254 }
255
256 pub fn with_identity_alignment(mut self, value: IdentityAlignment) -> Self {
257 self.identity_alignment = value;
258 self
259 }
260
261 pub fn into_owned<'y>(self) -> Feedback<'y> {
262 Feedback {
263 feedback_type: self.feedback_type,
264 arrival_date: self.arrival_date,
265 authentication_results: self
266 .authentication_results
267 .into_iter()
268 .map(|ar| ar.into_owned().into())
269 .collect(),
270 incidents: self.incidents,
271 original_envelope_id: self.original_envelope_id.map(|v| v.into_owned().into()),
272 original_mail_from: self.original_mail_from.map(|v| v.into_owned().into()),
273 original_rcpt_to: self.original_rcpt_to.map(|v| v.into_owned().into()),
274 reported_domain: self
275 .reported_domain
276 .into_iter()
277 .map(|ar| ar.into_owned().into())
278 .collect(),
279 reported_uri: self
280 .reported_uri
281 .into_iter()
282 .map(|ar| ar.into_owned().into())
283 .collect(),
284 reporting_mta: self.reporting_mta.map(|v| v.into_owned().into()),
285 source_ip: self.source_ip,
286 user_agent: self.user_agent.map(|v| v.into_owned().into()),
287 version: self.version,
288 source_port: self.source_port,
289 auth_failure: self.auth_failure,
290 delivery_result: self.delivery_result,
291 dkim_adsp_dns: self.dkim_adsp_dns.map(|v| v.into_owned().into()),
292 dkim_canonicalized_body: self.dkim_canonicalized_body.map(|v| v.into_owned().into()),
293 dkim_canonicalized_header: self
294 .dkim_canonicalized_header
295 .map(|v| v.into_owned().into()),
296 dkim_domain: self.dkim_domain.map(|v| v.into_owned().into()),
297 dkim_identity: self.dkim_identity.map(|v| v.into_owned().into()),
298 dkim_selector: self.dkim_selector.map(|v| v.into_owned().into()),
299 dkim_selector_dns: self.dkim_selector_dns.map(|v| v.into_owned().into()),
300 spf_dns: self.spf_dns.map(|v| v.into_owned().into()),
301 identity_alignment: self.identity_alignment,
302 message: self.message.map(|v| v.into_owned().into()),
303 headers: self.headers.map(|v| v.into_owned().into()),
304 }
305 }
306}