1use std::collections::HashMap;
8use std::iter::IntoIterator;
9use typed_builder::TypedBuilder;
10
11#[derive(Debug, Clone, PartialEq)]
13pub struct TlsSettings {
14 pub cert_path: String,
16
17 pub key_path: String,
19
20 pub ca_path: Option<String>,
22}
23
24#[derive(Debug, Clone, PartialEq)]
26pub struct ProxyConfig {
27 pub proxy_url: String,
29
30 pub username: Option<String>,
32
33 pub password: Option<String>,
35}
36
37#[derive(TypedBuilder, Debug, PartialEq, Default)]
38pub struct EnvelopeData {
39 #[builder(default, setter(strip_option))]
41 pub from: Option<String>,
42
43 #[builder(default)]
45 pub rcpt: Vec<String>,
46
47 #[builder(default, setter(strip_option))]
49 pub ip: Option<String>,
50
51 #[builder(default, setter(strip_option))]
53 pub user: Option<String>,
54
55 #[builder(default, setter(strip_option))]
57 pub helo: Option<String>,
58
59 #[builder(default, setter(strip_option))]
61 pub hostname: Option<String>,
62
63 #[builder(default, setter(strip_option))]
67 pub file_path: Option<String>,
68
69 #[builder(default)]
74 pub body_block: bool,
75
76 #[builder(default)]
78 pub additional_headers: HashMap<String, String>,
79}
80
81impl IntoIterator for EnvelopeData {
82 type Item = (String, String);
83 type IntoIter = std::collections::hash_map::IntoIter<String, String>;
84
85 fn into_iter(mut self) -> Self::IntoIter {
87 if let Some(from) = self.from {
89 self.additional_headers.insert("From".to_string(), from);
90 }
91 if let Some(ip) = self.ip {
92 self.additional_headers.insert("IP".to_string(), ip);
93 }
94 if let Some(user) = self.user {
95 self.additional_headers.insert("User".to_string(), user);
96 }
97 if let Some(helo) = self.helo {
98 self.additional_headers.insert("Helo".to_string(), helo);
99 }
100 if let Some(hostname) = self.hostname {
101 self.additional_headers
102 .insert("Hostname".to_string(), hostname);
103 }
104 if let Some(file_path) = self.file_path {
105 self.additional_headers
106 .insert("File".to_string(), file_path);
107 }
108 if self.body_block {
109 self.additional_headers
110 .insert("Flags".to_string(), "body_block".to_string());
111 }
112 for rcpt in self.rcpt {
113 self.additional_headers.insert("Rcpt".to_string(), rcpt);
114 }
115 self.additional_headers.into_iter()
116 }
117}
118
119#[derive(TypedBuilder, Debug, PartialEq)]
121pub struct Config {
122 pub base_url: String,
124
125 #[builder(default, setter(strip_option))]
127 pub password: Option<String>,
128
129 #[builder(default = 30.0)]
131 pub timeout: f64,
132
133 #[builder(default = 1)]
135 pub retries: u32,
136
137 #[builder(default, setter(strip_option))]
139 pub tls_settings: Option<TlsSettings>,
140
141 #[builder(default, setter(strip_option))]
143 pub proxy_config: Option<ProxyConfig>,
144
145 #[builder(default = true)]
147 pub zstd: bool,
148
149 #[builder(default, setter(strip_option))]
151 pub encryption_key: Option<String>,
152}