Struct jmap_client::core::query::QueryRequest
source · pub struct QueryRequest<O: QueryObject> { /* private fields */ }Implementations§
source§impl<O: QueryObject> QueryRequest<O>
impl<O: QueryObject> QueryRequest<O>
pub fn new(params: RequestParams) -> Self
pub fn account_id(&mut self, account_id: impl Into<String>) -> &mut Self
sourcepub fn filter(&mut self, filter: impl Into<Filter<O::Filter>>) -> &mut Self
pub fn filter(&mut self, filter: impl Into<Filter<O::Filter>>) -> &mut Self
Examples found in repository?
examples/result_reference.rs (lines 32-35)
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 sort( &mut self, sort: impl IntoIterator<Item = Comparator<O::Sort>> ) -> &mut Self
pub fn position(&mut self, position: i32) -> &mut Self
pub fn anchor(&mut self, anchor: impl Into<String>) -> &mut Self
pub fn anchor_offset(&mut self, anchor_offset: i32) -> &mut Self
pub fn limit(&mut self, limit: usize) -> &mut Self
pub fn calculate_total(&mut self, calculate_total: bool) -> &mut Self
pub fn arguments(&mut self) -> &mut O::QueryArguments
sourcepub fn result_reference(&self) -> ResultReference
pub fn result_reference(&self) -> ResultReference
Examples found in repository?
examples/result_reference.rs (line 36)
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);
}
}Trait Implementations§
source§impl<O: Clone + QueryObject> Clone for QueryRequest<O>where
O::Filter: Clone,
O::Sort: Clone,
O::QueryArguments: Clone,
impl<O: Clone + QueryObject> Clone for QueryRequest<O>where O::Filter: Clone, O::Sort: Clone, O::QueryArguments: Clone,
source§fn clone(&self) -> QueryRequest<O>
fn clone(&self) -> QueryRequest<O>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<O: Debug + QueryObject> Debug for QueryRequest<O>where
O::Filter: Debug,
O::Sort: Debug,
O::QueryArguments: Debug,
impl<O: Debug + QueryObject> Debug for QueryRequest<O>where O::Filter: Debug, O::Sort: Debug, O::QueryArguments: Debug,
source§impl<O: QueryObject> Serialize for QueryRequest<O>where
O::QueryArguments: Serialize,
impl<O: QueryObject> Serialize for QueryRequest<O>where O::QueryArguments: Serialize,
Auto Trait Implementations§
impl<O> RefUnwindSafe for QueryRequest<O>where <O as QueryObject>::Filter: RefUnwindSafe, <O as QueryObject>::QueryArguments: RefUnwindSafe, <O as QueryObject>::Sort: RefUnwindSafe,
impl<O> Send for QueryRequest<O>where <O as QueryObject>::Filter: Send, <O as QueryObject>::QueryArguments: Send, <O as QueryObject>::Sort: Send,
impl<O> Sync for QueryRequest<O>where <O as QueryObject>::Filter: Sync, <O as QueryObject>::QueryArguments: Sync, <O as QueryObject>::Sort: Sync,
impl<O> Unpin for QueryRequest<O>where <O as QueryObject>::Filter: Unpin, <O as QueryObject>::QueryArguments: Unpin, <O as QueryObject>::Sort: Unpin,
impl<O> UnwindSafe for QueryRequest<O>where <O as QueryObject>::Filter: UnwindSafe, <O as QueryObject>::QueryArguments: UnwindSafe, <O as QueryObject>::Sort: 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