pub struct QueryResponse { /* private fields */ }
Implementations§
Source§impl QueryResponse
impl QueryResponse
pub fn account_id(&self) -> &str
pub fn ids(&self) -> &[String]
pub fn id(&self, pos: usize) -> &str
Sourcepub fn take_ids(&mut self) -> Vec<String>
pub fn take_ids(&mut self) -> Vec<String>
Examples found in repository?
examples/mailboxes.rs (line 49)
23async fn mailboxes() {
24 // Connect to the JMAP server using Basic authentication
25 let client = Client::new()
26 .credentials(("john@example.org", "secret"))
27 .connect("https://jmap.example.org")
28 .await
29 .unwrap();
30
31 // Create a mailbox
32 let mailbox_id = client
33 .mailbox_create("My Mailbox", None::<String>, Role::None)
34 .await
35 .unwrap()
36 .take_id();
37
38 // Rename a mailbox
39 client
40 .mailbox_rename(&mailbox_id, "My Renamed Mailbox")
41 .await
42 .unwrap();
43
44 // Query mailboxes to obtain Inbox's id
45 let inbox_id = client
46 .mailbox_query(Filter::role(Role::Inbox).into(), None::<Vec<_>>)
47 .await
48 .unwrap()
49 .take_ids()
50 .pop()
51 .unwrap();
52
53 // Print Inbox's details
54 println!(
55 "{:?}",
56 client.mailbox_get(&inbox_id, None::<Vec<_>>).await.unwrap()
57 );
58
59 // Move the newly created mailbox under Inbox
60 client
61 .mailbox_move(&mailbox_id, inbox_id.into())
62 .await
63 .unwrap();
64
65 // Delete the mailbox including any messages
66 client.mailbox_destroy(&mailbox_id, true).await.unwrap();
67}
More examples
examples/messages.rs (line 49)
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 total(&self) -> Option<usize>
pub fn limit(&self) -> Option<usize>
pub fn position(&self) -> i32
pub fn take_query_state(&mut self) -> String
pub fn query_state(&self) -> &str
pub fn can_calculate_changes(&self) -> bool
Trait Implementations§
Source§impl Clone for QueryResponse
impl Clone for QueryResponse
Source§fn clone(&self) -> QueryResponse
fn clone(&self) -> QueryResponse
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 Debug for QueryResponse
impl Debug for QueryResponse
Source§impl<'de> Deserialize<'de> for QueryResponse
impl<'de> Deserialize<'de> for QueryResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for QueryResponse
impl RefUnwindSafe for QueryResponse
impl Send for QueryResponse
impl Sync for QueryResponse
impl Unpin for QueryResponse
impl UnwindSafe for QueryResponse
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