pub struct Email<State = Get> { /* private fields */ }
Implementations§
Source§impl Email<Get>
impl Email<Get>
pub fn id(&self) -> Option<&str>
pub fn take_id(&mut self) -> String
pub fn blob_id(&self) -> Option<&str>
pub fn take_blob_id(&mut self) -> String
pub fn thread_id(&self) -> Option<&str>
pub fn take_thread_id(&mut self) -> Option<String>
pub fn mailbox_ids(&self) -> Vec<&str>
Sourcepub fn keywords(&self) -> Vec<&str>
pub fn keywords(&self) -> Vec<&str>
Examples found in repository?
examples/messages.rs (line 97)
33async fn messages() {
34 // Connect to the JMAP server using Basic authentication
35 let client = Client::new()
36 .credentials(("john@example.org", "secret"))
37 .connect("https://jmap.example.org")
38 .await
39 .unwrap();
40
41 // Query mailboxes to obtain Inbox and Trash folder id
42 let inbox_id = client
43 .mailbox_query(
44 mailbox::query::Filter::role(Role::Inbox).into(),
45 None::<Vec<_>>,
46 )
47 .await
48 .unwrap()
49 .take_ids()
50 .pop()
51 .unwrap();
52 let trash_id = client
53 .mailbox_query(
54 mailbox::query::Filter::role(Role::Trash).into(),
55 None::<Vec<_>>,
56 )
57 .await
58 .unwrap()
59 .take_ids()
60 .pop()
61 .unwrap();
62
63 // Import message into inbox
64 client
65 .email_import(TEST_MESSAGE.to_vec(), [&inbox_id], ["$draft"].into(), None)
66 .await
67 .unwrap();
68
69 // Query mailbox
70 let email_id = client
71 .email_query(
72 Filter::and([
73 email::query::Filter::subject("test"),
74 email::query::Filter::in_mailbox(&inbox_id),
75 email::query::Filter::has_keyword("$draft"),
76 ])
77 .into(),
78 [email::query::Comparator::from()].into(),
79 )
80 .await
81 .unwrap()
82 .take_ids()
83 .pop()
84 .unwrap();
85
86 // Fetch message
87 let email = client
88 .email_get(
89 &email_id,
90 [Property::Subject, Property::Preview, Property::Keywords].into(),
91 )
92 .await
93 .unwrap()
94 .unwrap();
95 assert_eq!(email.preview().unwrap(), "This is a test.");
96 assert_eq!(email.subject().unwrap(), "Testing JMAP client");
97 assert_eq!(email.keywords(), ["$draft"]);
98
99 // Remove the $draft keyword
100 client
101 .email_set_keyword(&email_id, "$draft", false)
102 .await
103 .unwrap();
104
105 // Replace all keywords
106 client
107 .email_set_keywords(&email_id, ["$seen", "$important"])
108 .await
109 .unwrap();
110
111 // Move the message to the Trash folder
112 client
113 .email_set_mailboxes(&email_id, [&trash_id])
114 .await
115 .unwrap();
116
117 // Destroy the e-mail
118 client.email_destroy(&email_id).await.unwrap();
119}
pub fn size(&self) -> usize
pub fn received_at(&self) -> Option<i64>
pub fn message_id(&self) -> Option<&[String]>
pub fn in_reply_to(&self) -> Option<&[String]>
pub fn references(&self) -> Option<&[String]>
pub fn sender(&self) -> Option<&[EmailAddress]>
pub fn take_sender(&mut self) -> Option<Vec<EmailAddress>>
pub fn from(&self) -> Option<&[EmailAddress]>
pub fn take_from(&mut self) -> Option<Vec<EmailAddress>>
pub fn reply_to(&self) -> Option<&[EmailAddress]>
pub fn take_reply_to(&mut self) -> Option<Vec<EmailAddress>>
pub fn to(&self) -> Option<&[EmailAddress]>
pub fn take_to(&mut self) -> Option<Vec<EmailAddress>>
pub fn cc(&self) -> Option<&[EmailAddress]>
pub fn take_cc(&mut self) -> Option<Vec<EmailAddress>>
pub fn bcc(&self) -> Option<&[EmailAddress]>
pub fn take_bcc(&mut self) -> Option<Vec<EmailAddress>>
Sourcepub fn subject(&self) -> Option<&str>
pub fn subject(&self) -> Option<&str>
Examples found in repository?
examples/messages.rs (line 96)
33async fn messages() {
34 // Connect to the JMAP server using Basic authentication
35 let client = Client::new()
36 .credentials(("john@example.org", "secret"))
37 .connect("https://jmap.example.org")
38 .await
39 .unwrap();
40
41 // Query mailboxes to obtain Inbox and Trash folder id
42 let inbox_id = client
43 .mailbox_query(
44 mailbox::query::Filter::role(Role::Inbox).into(),
45 None::<Vec<_>>,
46 )
47 .await
48 .unwrap()
49 .take_ids()
50 .pop()
51 .unwrap();
52 let trash_id = client
53 .mailbox_query(
54 mailbox::query::Filter::role(Role::Trash).into(),
55 None::<Vec<_>>,
56 )
57 .await
58 .unwrap()
59 .take_ids()
60 .pop()
61 .unwrap();
62
63 // Import message into inbox
64 client
65 .email_import(TEST_MESSAGE.to_vec(), [&inbox_id], ["$draft"].into(), None)
66 .await
67 .unwrap();
68
69 // Query mailbox
70 let email_id = client
71 .email_query(
72 Filter::and([
73 email::query::Filter::subject("test"),
74 email::query::Filter::in_mailbox(&inbox_id),
75 email::query::Filter::has_keyword("$draft"),
76 ])
77 .into(),
78 [email::query::Comparator::from()].into(),
79 )
80 .await
81 .unwrap()
82 .take_ids()
83 .pop()
84 .unwrap();
85
86 // Fetch message
87 let email = client
88 .email_get(
89 &email_id,
90 [Property::Subject, Property::Preview, Property::Keywords].into(),
91 )
92 .await
93 .unwrap()
94 .unwrap();
95 assert_eq!(email.preview().unwrap(), "This is a test.");
96 assert_eq!(email.subject().unwrap(), "Testing JMAP client");
97 assert_eq!(email.keywords(), ["$draft"]);
98
99 // Remove the $draft keyword
100 client
101 .email_set_keyword(&email_id, "$draft", false)
102 .await
103 .unwrap();
104
105 // Replace all keywords
106 client
107 .email_set_keywords(&email_id, ["$seen", "$important"])
108 .await
109 .unwrap();
110
111 // Move the message to the Trash folder
112 client
113 .email_set_mailboxes(&email_id, [&trash_id])
114 .await
115 .unwrap();
116
117 // Destroy the e-mail
118 client.email_destroy(&email_id).await.unwrap();
119}
pub fn take_subject(&mut self) -> Option<String>
pub fn sent_at(&self) -> Option<i64>
pub fn body_structure(&self) -> Option<&EmailBodyPart>
pub fn body_value(&self, id: &str) -> Option<&EmailBodyValue>
pub fn text_body(&self) -> Option<&[EmailBodyPart]>
pub fn html_body(&self) -> Option<&[EmailBodyPart]>
pub fn attachments(&self) -> Option<&[EmailBodyPart]>
pub fn has_attachment(&self) -> bool
pub fn header(&self, id: &Header) -> Option<&HeaderValue>
pub fn has_header(&self, id: &Header) -> bool
Sourcepub fn preview(&self) -> Option<&str>
pub fn preview(&self) -> Option<&str>
Examples found in repository?
examples/messages.rs (line 95)
33async fn messages() {
34 // Connect to the JMAP server using Basic authentication
35 let client = Client::new()
36 .credentials(("john@example.org", "secret"))
37 .connect("https://jmap.example.org")
38 .await
39 .unwrap();
40
41 // Query mailboxes to obtain Inbox and Trash folder id
42 let inbox_id = client
43 .mailbox_query(
44 mailbox::query::Filter::role(Role::Inbox).into(),
45 None::<Vec<_>>,
46 )
47 .await
48 .unwrap()
49 .take_ids()
50 .pop()
51 .unwrap();
52 let trash_id = client
53 .mailbox_query(
54 mailbox::query::Filter::role(Role::Trash).into(),
55 None::<Vec<_>>,
56 )
57 .await
58 .unwrap()
59 .take_ids()
60 .pop()
61 .unwrap();
62
63 // Import message into inbox
64 client
65 .email_import(TEST_MESSAGE.to_vec(), [&inbox_id], ["$draft"].into(), None)
66 .await
67 .unwrap();
68
69 // Query mailbox
70 let email_id = client
71 .email_query(
72 Filter::and([
73 email::query::Filter::subject("test"),
74 email::query::Filter::in_mailbox(&inbox_id),
75 email::query::Filter::has_keyword("$draft"),
76 ])
77 .into(),
78 [email::query::Comparator::from()].into(),
79 )
80 .await
81 .unwrap()
82 .take_ids()
83 .pop()
84 .unwrap();
85
86 // Fetch message
87 let email = client
88 .email_get(
89 &email_id,
90 [Property::Subject, Property::Preview, Property::Keywords].into(),
91 )
92 .await
93 .unwrap()
94 .unwrap();
95 assert_eq!(email.preview().unwrap(), "This is a test.");
96 assert_eq!(email.subject().unwrap(), "Testing JMAP client");
97 assert_eq!(email.keywords(), ["$draft"]);
98
99 // Remove the $draft keyword
100 client
101 .email_set_keyword(&email_id, "$draft", false)
102 .await
103 .unwrap();
104
105 // Replace all keywords
106 client
107 .email_set_keywords(&email_id, ["$seen", "$important"])
108 .await
109 .unwrap();
110
111 // Move the message to the Trash folder
112 client
113 .email_set_mailboxes(&email_id, [&trash_id])
114 .await
115 .unwrap();
116
117 // Destroy the e-mail
118 client.email_destroy(&email_id).await.unwrap();
119}
pub fn take_preview(&mut self) -> Option<String>
Source§impl Email<Set>
impl Email<Set>
pub fn mailbox_ids<T, U>(&mut self, mailbox_ids: T) -> &mut Self
pub fn mailbox_ids_ref(&mut self, reference: ResultReference) -> &mut Self
pub fn mailbox_id(&mut self, mailbox_id: &str, set: bool) -> &mut Self
pub fn keywords<T, U>(&mut self, keywords: T) -> &mut Self
pub fn keyword(&mut self, keyword: &str, set: bool) -> &mut Self
pub fn message_id<T, U>(&mut self, message_id: T) -> &mut Self
pub fn in_reply_to<T, U>(&mut self, in_reply_to: T) -> &mut Self
pub fn references<T, U>(&mut self, references: T) -> &mut Self
pub fn sender<T, U>(&mut self, sender: T) -> &mut Self
pub fn from<T, U>(&mut self, from: T) -> &mut Self
pub fn to<T, U>(&mut self, to: T) -> &mut Self
pub fn cc<T, U>(&mut self, cc: T) -> &mut Self
pub fn bcc<T, U>(&mut self, bcc: T) -> &mut Self
pub fn reply_to<T, U>(&mut self, reply_to: T) -> &mut Self
pub fn subject(&mut self, subject: impl Into<String>) -> &mut Self
pub fn sent_at(&mut self, sent_at: i64) -> &mut Self
pub fn body_structure(&mut self, body_structure: EmailBodyPart) -> &mut Self
pub fn body_value( &mut self, id: String, body_value: impl Into<EmailBodyValue>, ) -> &mut Self
pub fn text_body( &mut self, text_body: impl Into<EmailBodyPart<Get>>, ) -> &mut Self
pub fn html_body( &mut self, html_body: impl Into<EmailBodyPart<Get>>, ) -> &mut Self
pub fn attachment( &mut self, attachment: impl Into<EmailBodyPart<Get>>, ) -> &mut Self
pub fn header( &mut self, header: Header, value: impl Into<HeaderValue>, ) -> &mut Self
pub fn received_at(&mut self, received_at: i64) -> &mut Self
Trait Implementations§
Source§impl ChangesObject for Email<Get>
impl ChangesObject for Email<Get>
type ChangesResponse = ()
Source§impl ChangesObject for Email<Set>
impl ChangesObject for Email<Set>
type ChangesResponse = ()
Source§impl<'de, State> Deserialize<'de> for Email<State>
impl<'de, State> Deserialize<'de> for Email<State>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl GetObject for Email<Get>
impl GetObject for Email<Get>
type GetArguments = GetArguments
Source§impl GetObject for Email<Set>
impl GetObject for Email<Set>
type GetArguments = GetArguments
Source§impl QueryObject for Email<Set>
impl QueryObject for Email<Set>
Auto Trait Implementations§
impl<State> Freeze for Email<State>
impl<State> RefUnwindSafe for Email<State>where
State: RefUnwindSafe,
impl<State> Send for Email<State>where
State: Send,
impl<State> Sync for Email<State>where
State: Sync,
impl<State> Unpin for Email<State>where
State: Unpin,
impl<State> UnwindSafe for Email<State>where
State: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more