aboutsummaryrefslogtreecommitdiff
path: root/src/data_structures.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/data_structures.rs')
-rw-r--r--src/data_structures.rs125
1 files changed, 106 insertions, 19 deletions
diff --git a/src/data_structures.rs b/src/data_structures.rs
index a90b7b0..ef1bcc2 100644
--- a/src/data_structures.rs
+++ b/src/data_structures.rs
@@ -1,35 +1,122 @@
-enum DMARCPolicy {
+use serde::Deserialize;
+
+// Raw DS to deserialize XML report
+
+#[derive(Debug, Deserialize)]
+pub struct Feedback {
+ pub version: String,
+ pub report_metadata: ReportMetadata,
+ pub policy_published: PolicyPublished,
+ pub record: Record,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct ReportMetadata {
+ pub org_name: String,
+ pub email: String,
+ pub report_id: String,
+ pub date_range: DateRange,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct DateRange {
+ pub begin: String,
+ pub end: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct PolicyPublished {
+ pub domain: String,
+ pub adkim: String,
+ pub aspf: String,
+ pub p: String,
+ pub sp: String,
+ pub pct: String,
+ pub fo: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct Record {
+ pub row: Row,
+ pub identifiers: Identifiers,
+ pub auth_results: AuthResults,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct Row {
+ pub source_ip: String,
+ pub count: String,
+ pub policy_evaluated: PolicyEvaluated,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct PolicyEvaluated {
+ pub disposition: String,
+ pub dkim: String,
+ pub spf: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct Identifiers {
+ pub envelope_to: String,
+ pub envelope_from: String,
+ pub header_from: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct AuthResults {
+ pub dkim: DKIM,
+ pub spf: SPF,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct DKIM {
+ pub domain: String,
+ pub selector: String,
+ pub result: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct SPF {
+ pub domain: String,
+ pub scope: String,
+ pub result: String,
+}
+
+// Rust interface DS for HTML generation
+
+pub enum DMARCPolicy {
None,
Quarantine,
- Reject
+ Reject,
}
-enum DMARCAlignment {
+pub enum DMARCAlignment {
Relaxed,
- Strict
+ Strict,
}
-enum DMARCFailureOption {
+pub enum DMARCFailureOption {
AlignedPassFailure,
OtherAlignedPassFailure,
SignatureAlignmentFailure,
- SPFFailure
+ SPFFailure,
}
-struct DMARCRecord {
- domain: String,
- adkim: DMARCAlignment,
- aspf: DMARCAlignment,
- policy: DMARCPolicy,
- subdomain_policy: DMARCPolicy,
- percentage: u64,
- failure_opt: DMARCFailureOption
+pub struct DMARCRecord {
+ pub domain: String,
+ pub adkim: DMARCAlignment,
+ pub aspf: DMARCAlignment,
+ pub policy: DMARCPolicy,
+ pub subdomain_policy: DMARCPolicy,
+ pub percentage: u64,
+ pub failure_opt: DMARCFailureOption,
}
pub struct DMARCReport {
- id: String,
- org: String,
- record: DMARCRecord,
- dkim_pass: bool,
- spf_pass: bool
+ pub id: String,
+ pub org: String,
+ pub record: DMARCRecord,
+ pub dkim_pass: bool,
+ pub spf_pass: bool,
}