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