flows_connector_dsi/
gmail.rs1pub struct OutboundData {
2 fields: String,
3 content: String,
4}
5
6impl OutboundData {
7 pub fn content<S: Into<String>>(mut self, content: S) -> OutboundData {
9 self.content = content.into();
10 self
11 }
12
13 pub fn sender<S: Into<String>>(mut self, sender: S) -> OutboundData {
15 self.fields
16 .push_str(&format!("Sender: {}\r\n", sender.into()));
17 self
18 }
19
20 pub fn subject<S: Into<String>>(mut self, subject: S) -> OutboundData {
22 self.fields
23 .push_str(&format!("Subject: {}\r\n", subject.into()));
24 self
25 }
26
27 pub fn build(self) -> Result<String, String> {
29 if self.content.is_empty() {
30 return Err("OutboundData build failed: Content is empty".to_string());
31 }
32
33 Ok(format!(
34 "{}\r\n{}",
35 self.fields,
36 self.content.replace("\n", "\r\n")
37 ))
38 }
39}
40
41pub fn outbound<S: Into<String>>(email: S) -> OutboundData {
51 OutboundData {
52 fields: format!("From: me\r\nTo: {}\r\n", email.into()),
53 content: String::new(),
54 }
55}