pub enum Filter {
Show 24 variants
InMailbox {
value: String,
},
InMailboxOtherThan {
value: Vec<String>,
},
Before {
value: DateTime<Utc>,
},
After {
value: DateTime<Utc>,
},
MinSize {
value: u32,
},
MaxSize {
value: u32,
},
AllInThreadHaveKeyword {
value: String,
},
SomeInThreadHaveKeyword {
value: String,
},
NoneInThreadHaveKeyword {
value: String,
},
HasKeyword {
value: String,
},
NotKeyword {
value: String,
},
HasAttachment {
value: bool,
},
Text {
value: String,
},
From {
value: String,
},
To {
value: String,
},
Cc {
value: String,
},
Bcc {
value: String,
},
Subject {
value: String,
},
Body {
value: String,
},
Header {
value: Vec<String>,
},
Id {
value: Vec<String>,
},
SentBefore {
value: DateTime<Utc>,
},
SentAfter {
value: DateTime<Utc>,
},
InThread {
value: String,
},
}
Variants§
InMailbox
InMailboxOtherThan
Before
After
MinSize
MaxSize
AllInThreadHaveKeyword
SomeInThreadHaveKeyword
NoneInThreadHaveKeyword
HasKeyword
NotKeyword
HasAttachment
Text
From
To
Cc
Bcc
Subject
Body
Header
Id
SentBefore
SentAfter
InThread
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn in_mailbox(value: impl Into<String>) -> Self
pub fn in_mailbox(value: impl Into<String>) -> Self
Examples found in repository?
examples/messages.rs (line 74)
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 in_mailbox_other_than<U, V>(value: U) -> Self
pub fn before(value: i64) -> Self
pub fn after(value: i64) -> Self
pub fn min_size(value: u32) -> Self
pub fn max_size(value: u32) -> Self
pub fn all_in_thread_have_keyword(value: impl Into<String>) -> Self
pub fn some_in_thread_have_keyword(value: impl Into<String>) -> Self
pub fn none_in_thread_have_keyword(value: impl Into<String>) -> Self
Sourcepub fn has_keyword(value: impl Into<String>) -> Self
pub fn has_keyword(value: impl Into<String>) -> Self
Examples found in repository?
examples/messages.rs (line 75)
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}
More examples
examples/result_reference.rs (line 33)
20async fn result_reference() {
21 // Connect to the JMAP server using Basic authentication
22 let client = Client::new()
23 .credentials(("john@example.org", "secret"))
24 .connect("https://jmap.example.org")
25 .await
26 .unwrap();
27
28 // Delete e-mails matching a filter
29 let mut request = client.build();
30 let result_ref = request
31 .query_email()
32 .filter(query::Filter::and([
33 email::query::Filter::has_keyword("$draft"),
34 email::query::Filter::from("bill"),
35 ]))
36 .result_reference();
37 request.set_email().destroy_ref(result_ref);
38 let _destroyed_ids = request
39 .send()
40 .await
41 .unwrap()
42 .unwrap_method_responses()
43 .pop()
44 .unwrap()
45 .unwrap_set_email()
46 .unwrap()
47 .take_destroyed_ids();
48
49 // Fetch mailboxes matching a filter
50 let mut request = client.build();
51 let query_result = request
52 .query_mailbox()
53 .filter(query::Filter::and([
54 mailbox::query::Filter::has_any_role(false),
55 mailbox::query::Filter::is_subscribed(true),
56 ]))
57 .result_reference();
58 request.get_mailbox().ids_ref(query_result).properties([
59 mailbox::Property::Id,
60 mailbox::Property::Name,
61 mailbox::Property::ParentId,
62 mailbox::Property::TotalEmails,
63 mailbox::Property::UnreadEmails,
64 ]);
65 let _mailboxes = request
66 .send()
67 .await
68 .unwrap()
69 .unwrap_method_responses()
70 .pop()
71 .unwrap()
72 .unwrap_get_mailbox()
73 .unwrap()
74 .take_list();
75
76 // Fetch only the updated properties of all mailboxes that changed
77 // since a state.
78 let mut request = client.build();
79 let changes_request = request.changes_mailbox("n").max_changes(0);
80 let properties_ref = changes_request.updated_properties_reference();
81 let updated_ref = changes_request.updated_reference();
82 request
83 .get_mailbox()
84 .ids_ref(updated_ref)
85 .properties_ref(properties_ref);
86 for mailbox in request
87 .send()
88 .await
89 .unwrap()
90 .unwrap_method_responses()
91 .pop()
92 .unwrap()
93 .unwrap_get_mailbox()
94 .unwrap()
95 .take_list()
96 {
97 println!("Changed mailbox: {:#?}", mailbox);
98 }
99}
pub fn not_keyword(value: impl Into<String>) -> Self
pub fn has_attachment(value: bool) -> Self
pub fn text(value: impl Into<String>) -> Self
Sourcepub fn from(value: impl Into<String>) -> Self
pub fn from(value: impl Into<String>) -> Self
Examples found in repository?
examples/result_reference.rs (line 34)
20async fn result_reference() {
21 // Connect to the JMAP server using Basic authentication
22 let client = Client::new()
23 .credentials(("john@example.org", "secret"))
24 .connect("https://jmap.example.org")
25 .await
26 .unwrap();
27
28 // Delete e-mails matching a filter
29 let mut request = client.build();
30 let result_ref = request
31 .query_email()
32 .filter(query::Filter::and([
33 email::query::Filter::has_keyword("$draft"),
34 email::query::Filter::from("bill"),
35 ]))
36 .result_reference();
37 request.set_email().destroy_ref(result_ref);
38 let _destroyed_ids = request
39 .send()
40 .await
41 .unwrap()
42 .unwrap_method_responses()
43 .pop()
44 .unwrap()
45 .unwrap_set_email()
46 .unwrap()
47 .take_destroyed_ids();
48
49 // Fetch mailboxes matching a filter
50 let mut request = client.build();
51 let query_result = request
52 .query_mailbox()
53 .filter(query::Filter::and([
54 mailbox::query::Filter::has_any_role(false),
55 mailbox::query::Filter::is_subscribed(true),
56 ]))
57 .result_reference();
58 request.get_mailbox().ids_ref(query_result).properties([
59 mailbox::Property::Id,
60 mailbox::Property::Name,
61 mailbox::Property::ParentId,
62 mailbox::Property::TotalEmails,
63 mailbox::Property::UnreadEmails,
64 ]);
65 let _mailboxes = request
66 .send()
67 .await
68 .unwrap()
69 .unwrap_method_responses()
70 .pop()
71 .unwrap()
72 .unwrap_get_mailbox()
73 .unwrap()
74 .take_list();
75
76 // Fetch only the updated properties of all mailboxes that changed
77 // since a state.
78 let mut request = client.build();
79 let changes_request = request.changes_mailbox("n").max_changes(0);
80 let properties_ref = changes_request.updated_properties_reference();
81 let updated_ref = changes_request.updated_reference();
82 request
83 .get_mailbox()
84 .ids_ref(updated_ref)
85 .properties_ref(properties_ref);
86 for mailbox in request
87 .send()
88 .await
89 .unwrap()
90 .unwrap_method_responses()
91 .pop()
92 .unwrap()
93 .unwrap_get_mailbox()
94 .unwrap()
95 .take_list()
96 {
97 println!("Changed mailbox: {:#?}", mailbox);
98 }
99}
pub fn to(value: impl Into<String>) -> Self
pub fn cc(value: impl Into<String>) -> Self
pub fn bcc(value: impl Into<String>) -> Self
Sourcepub fn subject(value: impl Into<String>) -> Self
pub fn subject(value: impl Into<String>) -> Self
Examples found in repository?
examples/messages.rs (line 73)
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 body(value: impl Into<String>) -> Self
pub fn header(header: impl Into<String>, v: Option<impl Into<String>>) -> Self
pub fn id<U, V>(value: U) -> Self
pub fn sent_before(value: i64) -> Self
pub fn sent_after(value: i64) -> Self
pub fn in_thread(value: impl Into<String>) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnwindSafe for Filter
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