Struct jmap_client::email::Email
source · 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)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
async fn messages() {
// Connect to the JMAP server using Basic authentication
let client = Client::new()
.credentials(("john@example.org", "secret"))
.connect("https://jmap.example.org")
.await
.unwrap();
// Query mailboxes to obtain Inbox and Trash folder id
let inbox_id = client
.mailbox_query(
mailbox::query::Filter::role(Role::Inbox).into(),
None::<Vec<_>>,
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
let trash_id = client
.mailbox_query(
mailbox::query::Filter::role(Role::Trash).into(),
None::<Vec<_>>,
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
// Import message into inbox
client
.email_import(TEST_MESSAGE.to_vec(), [&inbox_id], ["$draft"].into(), None)
.await
.unwrap();
// Query mailbox
let email_id = client
.email_query(
Filter::and([
email::query::Filter::subject("test"),
email::query::Filter::in_mailbox(&inbox_id),
email::query::Filter::has_keyword("$draft"),
])
.into(),
[email::query::Comparator::from()].into(),
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
// Fetch message
let email = client
.email_get(
&email_id,
[Property::Subject, Property::Preview, Property::Keywords].into(),
)
.await
.unwrap()
.unwrap();
assert_eq!(email.preview().unwrap(), "This is a test.");
assert_eq!(email.subject().unwrap(), "Testing JMAP client");
assert_eq!(email.keywords(), ["$draft"]);
// Remove the $draft keyword
client
.email_set_keyword(&email_id, "$draft", false)
.await
.unwrap();
// Replace all keywords
client
.email_set_keywords(&email_id, ["$seen", "$important"])
.await
.unwrap();
// Move the message to the Trash folder
client
.email_set_mailboxes(&email_id, [&trash_id])
.await
.unwrap();
// Destroy the e-mail
client.email_destroy(&email_id).await.unwrap();
}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)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
async fn messages() {
// Connect to the JMAP server using Basic authentication
let client = Client::new()
.credentials(("john@example.org", "secret"))
.connect("https://jmap.example.org")
.await
.unwrap();
// Query mailboxes to obtain Inbox and Trash folder id
let inbox_id = client
.mailbox_query(
mailbox::query::Filter::role(Role::Inbox).into(),
None::<Vec<_>>,
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
let trash_id = client
.mailbox_query(
mailbox::query::Filter::role(Role::Trash).into(),
None::<Vec<_>>,
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
// Import message into inbox
client
.email_import(TEST_MESSAGE.to_vec(), [&inbox_id], ["$draft"].into(), None)
.await
.unwrap();
// Query mailbox
let email_id = client
.email_query(
Filter::and([
email::query::Filter::subject("test"),
email::query::Filter::in_mailbox(&inbox_id),
email::query::Filter::has_keyword("$draft"),
])
.into(),
[email::query::Comparator::from()].into(),
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
// Fetch message
let email = client
.email_get(
&email_id,
[Property::Subject, Property::Preview, Property::Keywords].into(),
)
.await
.unwrap()
.unwrap();
assert_eq!(email.preview().unwrap(), "This is a test.");
assert_eq!(email.subject().unwrap(), "Testing JMAP client");
assert_eq!(email.keywords(), ["$draft"]);
// Remove the $draft keyword
client
.email_set_keyword(&email_id, "$draft", false)
.await
.unwrap();
// Replace all keywords
client
.email_set_keywords(&email_id, ["$seen", "$important"])
.await
.unwrap();
// Move the message to the Trash folder
client
.email_set_mailboxes(&email_id, [&trash_id])
.await
.unwrap();
// Destroy the e-mail
client.email_destroy(&email_id).await.unwrap();
}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)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
async fn messages() {
// Connect to the JMAP server using Basic authentication
let client = Client::new()
.credentials(("john@example.org", "secret"))
.connect("https://jmap.example.org")
.await
.unwrap();
// Query mailboxes to obtain Inbox and Trash folder id
let inbox_id = client
.mailbox_query(
mailbox::query::Filter::role(Role::Inbox).into(),
None::<Vec<_>>,
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
let trash_id = client
.mailbox_query(
mailbox::query::Filter::role(Role::Trash).into(),
None::<Vec<_>>,
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
// Import message into inbox
client
.email_import(TEST_MESSAGE.to_vec(), [&inbox_id], ["$draft"].into(), None)
.await
.unwrap();
// Query mailbox
let email_id = client
.email_query(
Filter::and([
email::query::Filter::subject("test"),
email::query::Filter::in_mailbox(&inbox_id),
email::query::Filter::has_keyword("$draft"),
])
.into(),
[email::query::Comparator::from()].into(),
)
.await
.unwrap()
.take_ids()
.pop()
.unwrap();
// Fetch message
let email = client
.email_get(
&email_id,
[Property::Subject, Property::Preview, Property::Keywords].into(),
)
.await
.unwrap()
.unwrap();
assert_eq!(email.preview().unwrap(), "This is a test.");
assert_eq!(email.subject().unwrap(), "Testing JMAP client");
assert_eq!(email.keywords(), ["$draft"]);
// Remove the $draft keyword
client
.email_set_keyword(&email_id, "$draft", false)
.await
.unwrap();
// Replace all keywords
client
.email_set_keywords(&email_id, ["$seen", "$important"])
.await
.unwrap();
// Move the message to the Trash folder
client
.email_set_mailboxes(&email_id, [&trash_id])
.await
.unwrap();
// Destroy the e-mail
client.email_destroy(&email_id).await.unwrap();
}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 Selfwhere T: IntoIterator<Item = U>, U: Into<String>,
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 Selfwhere T: IntoIterator<Item = U>, U: Into<String>,
pub fn keyword(&mut self, keyword: &str, set: bool) -> &mut Self
pub fn message_id<T, U>(&mut self, message_id: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<String>,
pub fn in_reply_to<T, U>(&mut self, in_reply_to: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<String>,
pub fn references<T, U>(&mut self, references: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<String>,
pub fn sender<T, U>(&mut self, sender: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<EmailAddress>,
pub fn from<T, U>(&mut self, from: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<EmailAddress>,
pub fn to<T, U>(&mut self, to: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<EmailAddress>,
pub fn cc<T, U>(&mut self, cc: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<EmailAddress>,
pub fn bcc<T, U>(&mut self, bcc: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<EmailAddress>,
pub fn reply_to<T, U>(&mut self, reply_to: T) -> &mut Selfwhere T: IntoIterator<Item = U>, U: Into<EmailAddress>,
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: EmailBodyPart) -> &mut Self
pub fn html_body(&mut self, html_body: EmailBodyPart) -> &mut Self
pub fn attachment(&mut self, attachment: EmailBodyPart) -> &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> 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