google_maps/places/place_autocomplete/request/mod.rs
1//! **Look in this module for documentation on building your _Places API_
2//! _Place Autocomplete_ query**. In particular, look at the _Request_ struct
3//! for examples of the builder pattern. This module contains the tools (enums,
4//! structs, methods) for building your Google Maps Platform request.
5
6pub mod autocomplete_type;
7mod build;
8mod end_point;
9mod new;
10mod query_string;
11mod validatable;
12mod with_components;
13mod with_language;
14mod with_location;
15mod with_offset;
16mod with_origin;
17mod with_region;
18mod with_sessiontoken;
19mod with_types;
20
21#[cfg(feature = "reqwest")]
22mod execute;
23
24#[cfg(feature = "reqwest")]
25mod get;
26
27// -----------------------------------------------------------------------------
28//
29/// **Look at this `Request` struct for documentation on how to build your
30/// _Place Autocomplete_ query**. The methods implemented for this struct are
31/// what's used to build your request.
32#[derive(Debug)]
33pub struct Request<'r> {
34 // Required parameters:
35 // --------------------
36 /// This structure contains the application's API key and other
37 /// user-definable settings such as "maximum retries."
38 client: &'r crate::client::Client,
39
40 /// The text string on which to search. The Place Autocomplete service will
41 /// return candidate matches based on this string and order results based on
42 /// their perceived relevance.
43 input: String,
44
45 // Optional parameters:
46 // --------------------
47 /// A grouping of places to which you would like to restrict your results.
48 /// Currently, you can use components to filter by up to 5 countries.
49 ///
50 /// * **Note**: If you receive unexpected results with a country code,
51 /// verify that you are using a code which includes the countries,
52 /// dependent territories, and special areas of geographical interest you
53 /// intend. You can find code information at [Wikipedia: List of ISO 3166
54 /// country
55 /// codes](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
56 /// or the
57 /// [ISO Online Browsing Platform](https://www.iso.org/obp/ui/#search).
58 components: Vec<crate::types::Country>,
59
60 /// The language in which to return results.
61 ///
62 /// * See the list of supported languages. Google often updates the
63 /// supported languages, so this list may not be exhaustive.
64 ///
65 /// * If `language` is not supplied, the API attempts to use the preferred
66 /// language as specified in the `Accept-Language` header.
67 ///
68 /// * The API does its best to provide a street address that is readable for
69 /// both the user and locals. To achieve that goal, it returns street
70 /// addresses in the local language, transliterated to a script readable
71 /// by the user if necessary, observing the preferred language. All other
72 /// addresses are returned in the preferred language. Address components
73 /// are all returned in the same language, which is chosen from the first
74 /// component.
75 ///
76 /// * If a name is not available in the preferred language, the API uses the
77 /// closest match.
78 ///
79 /// * The preferred language has a small influence on the set of results
80 /// that the API chooses to return, and the order in which they are
81 /// returned. The geocoder interprets abbreviations differently depending
82 /// on language, such as the abbreviations for street types, or synonyms
83 /// that may be valid in one language but not in another. For example,
84 /// _utca_ and _tér_ are synonyms for street in Hungarian.
85 language: Option<crate::types::Language>,
86
87 /// The point around which to retrieve place information.
88 ///
89 /// * When using the Text Search API, the 'location' parameter may be
90 /// overriden if the 'query' contains an explicit location such as
91 /// 'Market in Barcelona'.
92 location: Option<crate::types::LatLng>,
93
94 /// The position, in the input term, of the last character that the service
95 /// uses to match predictions. For example, if the input is `Google` and the
96 /// offset is 3, the service will match on `Goo`. The string determined by
97 /// the offset is matched against the first word in the input term only.
98 /// For example, if the input term is `Google abc` and the offset is 3, the
99 /// service will attempt to match against `Goo abc`. If no offset is
100 /// supplied, the service will use the whole term. The offset should
101 /// generally be set to the position of the text caret.
102 offset: Option<u8>,
103
104 /// The origin point from which to calculate straight-line distance to the
105 /// destination (returned as `distance_meters`). If this value is omitted,
106 /// straight-line distance will not be returned.
107 origin: Option<crate::types::LatLng>,
108
109 /// Defines the distance (in meters) within which to return place results.
110 /// You may bias results to a specified circle by passing a location and a
111 /// radius parameter. Doing so instructs the Places service to prefer
112 /// showing results within that circle; results outside of the defined area
113 /// may still be displayed.
114 ///
115 /// The radius will automatically be clamped to a maximum value depending on
116 /// the type of search and other parameters.
117 ///
118 /// * Autocomplete: 50,000 meters
119 /// * Nearby Search:
120 /// * with `keyword` or `name`: 50,000 meters
121 /// * without `keyword` or `name`
122 /// * Up to 50,000 meters, adjusted dynamically based on area
123 /// density, independent of `rankby` parameter.
124 /// * When using `rankby=distance`, the radius parameter will not be
125 /// accepted, and will result in an `INVALID_REQUEST`.
126 /// * Query Autocomplete: 50,000 meters
127 /// * Text Search: 50,000 meters
128 radius: Option<u32>,
129
130 /// The region code, specified as a [ccTLD ("top-level
131 /// domain")](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains)
132 /// two-character value. Most ccTLD codes are identical to ISO 3166-1 codes,
133 /// with some notable exceptions. For example, the United Kingdom's ccTLD is
134 /// "uk" (.co.uk) while its ISO 3166-1 code is "gb" (technically for the
135 /// entity of "The United Kingdom of Great Britain and Northern Ireland").
136 region: Option<crate::types::Region>,
137
138 /// A random string which identifies an autocomplete
139 /// [session](https://developers.google.com/maps/documentation/places/web-service/details#session_tokens)
140 /// for billing purposes.
141 ///
142 /// The session begins when the user starts typing a query, and concludes
143 /// when they select a place and a call to Place Details is made. Each
144 /// session can have multiple queries, followed by one place selection. The
145 /// API key(s) used for each request within a session must belong to the
146 /// same Google Cloud Console project. Once a session has concluded, the
147 /// token is no longer valid; your app must generate a fresh token for each
148 /// session. If the `sessiontoken` parameter is omitted, or if you reuse a
149 /// session token, the session is charged as if no session token was
150 /// provided (each request is billed separately).
151 ///
152 /// We recommend the following guidelines:
153 ///
154 /// * Use session tokens for all autocomplete sessions.
155 ///
156 /// * Generate a fresh token for each session. Using a version 4 UUID is
157 /// recommended.
158 ///
159 /// * Ensure that the API key(s) used for all Place Autocomplete and Place
160 /// Details requests within a session belong to the same Cloud Console
161 /// project.
162 ///
163 /// * Be sure to pass a unique session token for each new session. Using the
164 /// same token for more than one session will result in each request being
165 /// billed individually.
166 sessiontoken: Option<String>,
167
168 /// Returns only those places that are strictly within the region defined by
169 /// `location` and `radius`. This is a restriction, rather than a bias,
170 /// meaning that results outside this region will not be returned even if
171 /// they match the user input.
172 strictbounds: Option<bool>,
173
174 /// You may restrict results from a Place Autocomplete request to be of a
175 /// certain type by passing a types parameter. The parameter specifies a
176 /// type or a type collection, as listed in the supported types below. If
177 /// nothing is specified, all types are returned. In general only a single
178 /// type is allowed. The exception is that you can safely mix the geocode
179 /// and establishment types, but note that this will have the same effect as
180 /// specifying no types.
181 types: Vec<crate::places::place_autocomplete::request::autocomplete_type::AutocompleteType>,
182} // struct