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)
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 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)
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}
Trait Implementations§
Source§impl<O: Clone + QueryObject> Clone for QueryRequest<O>
impl<O: Clone + QueryObject> Clone for QueryRequest<O>
Source§fn clone(&self) -> QueryRequest<O>
fn clone(&self) -> QueryRequest<O>
Returns a duplicate 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>
impl<O: Debug + QueryObject> Debug for QueryRequest<O>
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> Freeze for QueryRequest<O>
impl<O> RefUnwindSafe for QueryRequest<O>where
<O as QueryObject>::QueryArguments: RefUnwindSafe,
<O as QueryObject>::Filter: RefUnwindSafe,
<O as QueryObject>::Sort: RefUnwindSafe,
impl<O> Send for QueryRequest<O>where
<O as QueryObject>::QueryArguments: Send,
<O as QueryObject>::Filter: Send,
<O as QueryObject>::Sort: Send,
impl<O> Sync for QueryRequest<O>where
<O as QueryObject>::QueryArguments: Sync,
<O as QueryObject>::Filter: Sync,
<O as QueryObject>::Sort: Sync,
impl<O> Unpin for QueryRequest<O>where
<O as QueryObject>::QueryArguments: Unpin,
<O as QueryObject>::Filter: Unpin,
<O as QueryObject>::Sort: Unpin,
impl<O> UnwindSafe for QueryRequest<O>where
<O as QueryObject>::QueryArguments: UnwindSafe,
<O as QueryObject>::Filter: 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