Struct jmap_client::email::Email

source ·
pub struct Email<State = Get> { /* private fields */ }

Implementations§

source§

impl Email<Get>

source

pub fn id(&self) -> Option<&str>

source

pub fn take_id(&mut self) -> String

source

pub fn blob_id(&self) -> Option<&str>

source

pub fn take_blob_id(&mut self) -> String

source

pub fn thread_id(&self) -> Option<&str>

source

pub fn take_thread_id(&mut self) -> Option<String>

source

pub fn mailbox_ids(&self) -> Vec<&str>

source

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();
}
source

pub fn size(&self) -> usize

source

pub fn received_at(&self) -> Option<i64>

source

pub fn message_id(&self) -> Option<&[String]>

source

pub fn in_reply_to(&self) -> Option<&[String]>

source

pub fn references(&self) -> Option<&[String]>

source

pub fn sender(&self) -> Option<&[EmailAddress]>

source

pub fn take_sender(&mut self) -> Option<Vec<EmailAddress>>

source

pub fn from(&self) -> Option<&[EmailAddress]>

source

pub fn take_from(&mut self) -> Option<Vec<EmailAddress>>

source

pub fn reply_to(&self) -> Option<&[EmailAddress]>

source

pub fn take_reply_to(&mut self) -> Option<Vec<EmailAddress>>

source

pub fn to(&self) -> Option<&[EmailAddress]>

source

pub fn take_to(&mut self) -> Option<Vec<EmailAddress>>

source

pub fn cc(&self) -> Option<&[EmailAddress]>

source

pub fn take_cc(&mut self) -> Option<Vec<EmailAddress>>

source

pub fn bcc(&self) -> Option<&[EmailAddress]>

source

pub fn take_bcc(&mut self) -> Option<Vec<EmailAddress>>

source

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();
}
source

pub fn take_subject(&mut self) -> Option<String>

source

pub fn sent_at(&self) -> Option<i64>

source

pub fn body_structure(&self) -> Option<&EmailBodyPart>

source

pub fn body_value(&self, id: &str) -> Option<&EmailBodyValue>

source

pub fn text_body(&self) -> Option<&[EmailBodyPart]>

source

pub fn html_body(&self) -> Option<&[EmailBodyPart]>

source

pub fn attachments(&self) -> Option<&[EmailBodyPart]>

source

pub fn has_attachment(&self) -> bool

source

pub fn header(&self, id: &Header) -> Option<&HeaderValue>

source

pub fn has_header(&self, id: &Header) -> bool

source

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();
}
source

pub fn take_preview(&mut self) -> Option<String>

source§

impl Email<Set>

source

pub fn mailbox_ids<T, U>(&mut self, mailbox_ids: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<String>,

source

pub fn mailbox_ids_ref(&mut self, reference: ResultReference) -> &mut Self

source

pub fn mailbox_id(&mut self, mailbox_id: &str, set: bool) -> &mut Self

source

pub fn keywords<T, U>(&mut self, keywords: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<String>,

source

pub fn keyword(&mut self, keyword: &str, set: bool) -> &mut Self

source

pub fn message_id<T, U>(&mut self, message_id: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<String>,

source

pub fn in_reply_to<T, U>(&mut self, in_reply_to: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<String>,

source

pub fn references<T, U>(&mut self, references: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<String>,

source

pub fn sender<T, U>(&mut self, sender: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<EmailAddress>,

source

pub fn from<T, U>(&mut self, from: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<EmailAddress>,

source

pub fn to<T, U>(&mut self, to: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<EmailAddress>,

source

pub fn cc<T, U>(&mut self, cc: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<EmailAddress>,

source

pub fn bcc<T, U>(&mut self, bcc: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<EmailAddress>,

source

pub fn reply_to<T, U>(&mut self, reply_to: T) -> &mut Self
where T: IntoIterator<Item = U>, U: Into<EmailAddress>,

source

pub fn subject(&mut self, subject: impl Into<String>) -> &mut Self

source

pub fn sent_at(&mut self, sent_at: i64) -> &mut Self

source

pub fn body_structure(&mut self, body_structure: EmailBodyPart) -> &mut Self

source

pub fn body_value( &mut self, id: String, body_value: impl Into<EmailBodyValue> ) -> &mut Self

source

pub fn text_body( &mut self, text_body: impl Into<EmailBodyPart<Get>> ) -> &mut Self

source

pub fn html_body( &mut self, html_body: impl Into<EmailBodyPart<Get>> ) -> &mut Self

source

pub fn attachment( &mut self, attachment: impl Into<EmailBodyPart<Get>> ) -> &mut Self

source

pub fn header( &mut self, header: Header, value: impl Into<HeaderValue> ) -> &mut Self

source

pub fn received_at(&mut self, received_at: i64) -> &mut Self

Trait Implementations§

source§

impl ChangesObject for Email<Get>

source§

impl ChangesObject for Email<Set>

source§

impl<State: Clone> Clone for Email<State>

source§

fn clone(&self) -> Email<State>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<State: Debug> Debug for Email<State>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<State: Default> Default for Email<State>

source§

fn default() -> Email<State>

Returns the “default value” for a type. Read more
source§

impl<'de, State> Deserialize<'de> for Email<State>

source§

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>

source§

impl GetObject for Email<Set>

source§

impl Object for Email<Get>

source§

impl Object for Email<Set>

source§

impl QueryObject for Email<Set>

source§

impl<State> Serialize for Email<State>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl SetObject for Email<Get>

source§

impl SetObject 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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,