1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
//! Query and search calls for the SOAP Partner API: `query`, `queryMore`,
//! `queryAll`, and `search`.
use super::{QueryResult, SearchResult, SoapHandler, envelope, parse};
use crate::error::Result;
impl<A: crate::auth::Authenticator> SoapHandler<A> {
/// Executes a SOQL query, returning the first page of results.
///
/// When [`QueryResult::done`] is `false`, pass
/// [`QueryResult::query_locator`] to [`query_more`](Self::query_more) to
/// fetch subsequent pages.
///
/// # Errors
///
/// Returns [`ForceError`](crate::error::ForceError) on a transport failure,
/// a SOAP fault (for example a malformed query), or an XML parse error.
pub async fn query(&self, soql: &str) -> Result<QueryResult> {
let mut body = String::with_capacity(256);
body.push_str("<urn:query><urn:queryString>");
body.push_str(envelope::escape_text(soql).as_ref());
body.push_str("</urn:queryString></urn:query>");
let xml = self.send(&body).await?;
parse::parse_query_result(&xml)
}
/// Fetches the next page of a query using a locator from a prior result.
///
/// # Errors
///
/// Returns [`ForceError`](crate::error::ForceError) on a transport failure,
/// a SOAP fault, or an XML parse error.
pub async fn query_more(&self, query_locator: &str) -> Result<QueryResult> {
let mut body = String::with_capacity(256);
body.push_str("<urn:queryMore><urn:queryLocator>");
body.push_str(envelope::escape_text(query_locator).as_ref());
body.push_str("</urn:queryLocator></urn:queryMore>");
let xml = self.send(&body).await?;
parse::parse_query_result(&xml)
}
/// Executes a SOQL query including soft-deleted and archived records.
///
/// # Errors
///
/// Returns [`ForceError`](crate::error::ForceError) on a transport failure,
/// a SOAP fault, or an XML parse error.
pub async fn query_all(&self, soql: &str) -> Result<QueryResult> {
let mut body = String::with_capacity(256);
body.push_str("<urn:queryAll><urn:queryString>");
body.push_str(envelope::escape_text(soql).as_ref());
body.push_str("</urn:queryString></urn:queryAll>");
let xml = self.send(&body).await?;
parse::parse_query_result(&xml)
}
/// Executes a SOSL search.
///
/// # Errors
///
/// Returns [`ForceError`](crate::error::ForceError) on a transport failure,
/// a SOAP fault, or an XML parse error.
pub async fn search(&self, sosl: &str) -> Result<SearchResult> {
let mut body = String::with_capacity(256);
body.push_str("<urn:search><urn:searchString>");
body.push_str(envelope::escape_text(sosl).as_ref());
body.push_str("</urn:searchString></urn:search>");
let xml = self.send(&body).await?;
parse::parse_search_result(&xml)
}
}