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
use crate::geocoding::reverse::ReverseRequest;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
impl ReverseRequest {
pub fn build(&mut self) -> &mut ReverseRequest {
let mut query = format!(
"key={}&latlng={}",
self.key,
String::from(&self.latlng)
);
if let Some(language) = &self.language {
query.push_str("&language=");
query.push_str(&String::from(language))
}
if let Some(location_type) = &self.location_type {
query.push_str("&location_type=");
query.push_str(&*utf8_percent_encode(
&String::from(location_type.iter().map(|location_type| String::from(location_type) + "|").collect::<String>().trim_end_matches('|')),
NON_ALPHANUMERIC
).to_string())
}
if let Some(result_type) = &self.result_type {
query.push_str("&result_type=");
query.push_str(&*utf8_percent_encode(
&String::from(result_type.iter().map(|result_type| String::from(result_type) + "|").collect::<String>().trim_end_matches('|')),
NON_ALPHANUMERIC
).to_string())
}
self.query = Some(query);
self
}
}