jmap_client/email_submission/
get.rs1use super::{Address, Delivered, DeliveryStatus, Displayed, EmailSubmission, UndoStatus};
13use crate::{core::get::GetObject, Get, Set};
14use ahash::AHashMap;
15
16impl EmailSubmission<Get> {
17 pub fn id(&self) -> Option<&str> {
18 self.id.as_deref()
19 }
20
21 pub fn take_id(&mut self) -> String {
22 self.id.take().unwrap_or_default()
23 }
24
25 pub fn identity_id(&self) -> Option<&str> {
26 self.identity_id.as_deref()
27 }
28
29 pub fn email_id(&self) -> Option<&str> {
30 self.email_id.as_deref()
31 }
32
33 pub fn thread_id(&self) -> Option<&str> {
34 self.thread_id.as_deref()
35 }
36
37 pub fn mail_from(&self) -> Option<&Address> {
38 self.envelope.as_ref().map(|e| &e.mail_from)
39 }
40
41 pub fn rcpt_to(&self) -> Option<&[Address]> {
42 self.envelope.as_ref().map(|e| e.rcpt_to.as_ref())
43 }
44
45 pub fn send_at(&self) -> Option<i64> {
46 self.send_at.as_ref().map(|t| t.timestamp())
47 }
48
49 pub fn undo_status(&self) -> Option<&UndoStatus> {
50 self.undo_status.as_ref()
51 }
52
53 pub fn delivery_status_email(&self, email: &str) -> Option<&DeliveryStatus> {
54 self.delivery_status.as_ref().and_then(|ds| ds.get(email))
55 }
56
57 pub fn delivery_status(&self) -> Option<&AHashMap<String, DeliveryStatus>> {
58 self.delivery_status.as_ref()
59 }
60
61 pub fn dsn_blob_ids(&self) -> Option<&[String]> {
62 self.dsn_blob_ids.as_deref()
63 }
64
65 pub fn mdn_blob_ids(&self) -> Option<&[String]> {
66 self.mdn_blob_ids.as_deref()
67 }
68}
69
70impl Address<Get> {
71 pub fn email(&self) -> &str {
72 &self.email
73 }
74
75 pub fn parameter(&self, param: &str) -> Option<&str> {
76 self.parameters.as_ref()?.get(param)?.as_deref()
77 }
78
79 pub fn has_parameter(&self, param: &str) -> bool {
80 self.parameters
81 .as_ref()
82 .map(|ps| ps.contains_key(param))
83 .unwrap_or(false)
84 }
85}
86
87impl DeliveryStatus {
88 #[cfg(feature = "debug")]
89 pub fn new(smtp_reply: impl Into<String>, delivered: Delivered, displayed: Displayed) -> Self {
90 Self {
91 smtp_reply: smtp_reply.into(),
92 delivered,
93 displayed,
94 }
95 }
96
97 pub fn smtp_reply(&self) -> &str {
98 &self.smtp_reply
99 }
100
101 pub fn delivered(&self) -> &Delivered {
102 &self.delivered
103 }
104
105 pub fn displayed(&self) -> &Displayed {
106 &self.displayed
107 }
108}
109
110impl GetObject for EmailSubmission<Set> {
111 type GetArguments = ();
112}
113
114impl GetObject for EmailSubmission<Get> {
115 type GetArguments = ();
116}