Enum jmap_client::email::query::Filter
source · 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)
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 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)
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();
}More examples
examples/result_reference.rs (line 33)
20 21 22 23 24 25 26 27 28 29 30 31 32 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
async fn result_reference() {
// Connect to the JMAP server using Basic authentication
let client = Client::new()
.credentials(("john@example.org", "secret"))
.connect("https://jmap.example.org")
.await
.unwrap();
// Delete e-mails matching a filter
let mut request = client.build();
let result_ref = request
.query_email()
.filter(query::Filter::and([
email::query::Filter::has_keyword("$draft"),
email::query::Filter::from("bill"),
]))
.result_reference();
request.set_email().destroy_ref(result_ref);
let _destroyed_ids = request
.send()
.await
.unwrap()
.unwrap_method_responses()
.pop()
.unwrap()
.unwrap_set_email()
.unwrap()
.take_destroyed_ids();
// Fetch mailboxes matching a filter
let mut request = client.build();
let query_result = request
.query_mailbox()
.filter(query::Filter::and([
mailbox::query::Filter::has_any_role(false),
mailbox::query::Filter::is_subscribed(true),
]))
.result_reference();
request.get_mailbox().ids_ref(query_result).properties([
mailbox::Property::Id,
mailbox::Property::Name,
mailbox::Property::ParentId,
mailbox::Property::TotalEmails,
mailbox::Property::UnreadEmails,
]);
let _mailboxes = request
.send()
.await
.unwrap()
.unwrap_method_responses()
.pop()
.unwrap()
.unwrap_get_mailbox()
.unwrap()
.take_list();
// Fetch only the updated properties of all mailboxes that changed
// since a state.
let mut request = client.build();
let changes_request = request.changes_mailbox("n").max_changes(0);
let properties_ref = changes_request.updated_properties_reference();
let updated_ref = changes_request.updated_reference();
request
.get_mailbox()
.ids_ref(updated_ref)
.properties_ref(properties_ref);
for mailbox in request
.send()
.await
.unwrap()
.unwrap_method_responses()
.pop()
.unwrap()
.unwrap_get_mailbox()
.unwrap()
.take_list()
{
println!("Changed mailbox: {:#?}", mailbox);
}
}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)
20 21 22 23 24 25 26 27 28 29 30 31 32 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
async fn result_reference() {
// Connect to the JMAP server using Basic authentication
let client = Client::new()
.credentials(("john@example.org", "secret"))
.connect("https://jmap.example.org")
.await
.unwrap();
// Delete e-mails matching a filter
let mut request = client.build();
let result_ref = request
.query_email()
.filter(query::Filter::and([
email::query::Filter::has_keyword("$draft"),
email::query::Filter::from("bill"),
]))
.result_reference();
request.set_email().destroy_ref(result_ref);
let _destroyed_ids = request
.send()
.await
.unwrap()
.unwrap_method_responses()
.pop()
.unwrap()
.unwrap_set_email()
.unwrap()
.take_destroyed_ids();
// Fetch mailboxes matching a filter
let mut request = client.build();
let query_result = request
.query_mailbox()
.filter(query::Filter::and([
mailbox::query::Filter::has_any_role(false),
mailbox::query::Filter::is_subscribed(true),
]))
.result_reference();
request.get_mailbox().ids_ref(query_result).properties([
mailbox::Property::Id,
mailbox::Property::Name,
mailbox::Property::ParentId,
mailbox::Property::TotalEmails,
mailbox::Property::UnreadEmails,
]);
let _mailboxes = request
.send()
.await
.unwrap()
.unwrap_method_responses()
.pop()
.unwrap()
.unwrap_get_mailbox()
.unwrap()
.take_list();
// Fetch only the updated properties of all mailboxes that changed
// since a state.
let mut request = client.build();
let changes_request = request.changes_mailbox("n").max_changes(0);
let properties_ref = changes_request.updated_properties_reference();
let updated_ref = changes_request.updated_reference();
request
.get_mailbox()
.ids_ref(updated_ref)
.properties_ref(properties_ref);
for mailbox in request
.send()
.await
.unwrap()
.unwrap_method_responses()
.pop()
.unwrap()
.unwrap_get_mailbox()
.unwrap()
.take_list()
{
println!("Changed mailbox: {:#?}", mailbox);
}
}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)
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 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 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