pub struct QueryRequest<O: QueryObject> { /* private fields */ }

Implementations§

source§

impl<O: QueryObject> QueryRequest<O>

source

pub fn new(params: RequestParams) -> Self

source

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

source

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

pub fn sort( &mut self, sort: impl IntoIterator<Item = Comparator<O::Sort>> ) -> &mut Self

source

pub fn position(&mut self, position: i32) -> &mut Self

source

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

source

pub fn anchor_offset(&mut self, anchor_offset: i32) -> &mut Self

source

pub fn limit(&mut self, limit: usize) -> &mut Self

source

pub fn calculate_total(&mut self, calculate_total: bool) -> &mut Self

source

pub fn arguments(&mut self) -> &mut O::QueryArguments

source

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,

source§

fn clone(&self) -> QueryRequest<O>

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<O: Debug + QueryObject> Debug for QueryRequest<O>where O::Filter: Debug, O::Sort: Debug, O::QueryArguments: Debug,

source§

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

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

impl<O: QueryObject> Serialize for QueryRequest<O>where O::QueryArguments: Serialize,

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

source§

impl<T> Instrument for T

source§

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

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

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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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