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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
/// Request and client builders for [Routes][crate::client::Routes].
pub mod routes {
use crate::Result;
/// A builder for [Routes][crate::client::Routes].
///
/// ```
/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
/// # use google_maps_routing_v2::*;
/// # use builder::routes::ClientBuilder;
/// # use client::Routes;
/// let builder : ClientBuilder = Routes::builder();
/// let client = builder
/// .with_endpoint("https://routes.googleapis.com")
/// .build().await?;
/// # Ok(()) }
/// ```
pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
pub(crate) mod client {
use super::super::super::client::Routes;
pub struct Factory;
impl crate::ClientFactory for Factory {
type Client = Routes;
type Credentials = gaxi::options::Credentials;
async fn build(
self,
config: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<Self::Client> {
Self::Client::new(config).await
}
}
}
/// Common implementation for [crate::client::Routes] request builders.
#[derive(Clone, Debug)]
pub(crate) struct RequestBuilder<R: std::default::Default> {
stub: std::sync::Arc<dyn super::super::stub::dynamic::Routes>,
request: R,
options: crate::RequestOptions,
}
impl<R> RequestBuilder<R>
where
R: std::default::Default,
{
pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Routes>) -> Self {
Self {
stub,
request: R::default(),
options: crate::RequestOptions::default(),
}
}
}
/// The request builder for [Routes::compute_routes][crate::client::Routes::compute_routes] calls.
///
/// # Example
/// ```
/// # use google_maps_routing_v2::builder::routes::ComputeRoutes;
/// # async fn sample() -> google_maps_routing_v2::Result<()> {
///
/// let builder = prepare_request_builder();
/// let response = builder.send().await?;
/// # Ok(()) }
///
/// fn prepare_request_builder() -> ComputeRoutes {
/// # panic!();
/// // ... details omitted ...
/// }
/// ```
#[derive(Clone, Debug)]
pub struct ComputeRoutes(RequestBuilder<crate::model::ComputeRoutesRequest>);
impl ComputeRoutes {
pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Routes>) -> Self {
Self(RequestBuilder::new(stub))
}
/// Sets the full request, replacing any prior values.
pub fn with_request<V: Into<crate::model::ComputeRoutesRequest>>(mut self, v: V) -> Self {
self.0.request = v.into();
self
}
/// Sets all the options, replacing any prior values.
pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
self.0.options = v.into();
self
}
/// Sends the request.
pub async fn send(self) -> Result<crate::model::ComputeRoutesResponse> {
(*self.0.stub)
.compute_routes(self.0.request, self.0.options)
.await
.map(crate::Response::into_body)
}
/// Sets the value of [origin][crate::model::ComputeRoutesRequest::origin].
///
/// This is a **required** field for requests.
pub fn set_origin<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Waypoint>,
{
self.0.request.origin = std::option::Option::Some(v.into());
self
}
/// Sets or clears the value of [origin][crate::model::ComputeRoutesRequest::origin].
///
/// This is a **required** field for requests.
pub fn set_or_clear_origin<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Waypoint>,
{
self.0.request.origin = v.map(|x| x.into());
self
}
/// Sets the value of [destination][crate::model::ComputeRoutesRequest::destination].
///
/// This is a **required** field for requests.
pub fn set_destination<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Waypoint>,
{
self.0.request.destination = std::option::Option::Some(v.into());
self
}
/// Sets or clears the value of [destination][crate::model::ComputeRoutesRequest::destination].
///
/// This is a **required** field for requests.
pub fn set_or_clear_destination<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Waypoint>,
{
self.0.request.destination = v.map(|x| x.into());
self
}
/// Sets the value of [intermediates][crate::model::ComputeRoutesRequest::intermediates].
pub fn set_intermediates<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::Waypoint>,
{
use std::iter::Iterator;
self.0.request.intermediates = v.into_iter().map(|i| i.into()).collect();
self
}
/// Sets the value of [travel_mode][crate::model::ComputeRoutesRequest::travel_mode].
pub fn set_travel_mode<T: Into<crate::model::RouteTravelMode>>(mut self, v: T) -> Self {
self.0.request.travel_mode = v.into();
self
}
/// Sets the value of [routing_preference][crate::model::ComputeRoutesRequest::routing_preference].
pub fn set_routing_preference<T: Into<crate::model::RoutingPreference>>(
mut self,
v: T,
) -> Self {
self.0.request.routing_preference = v.into();
self
}
/// Sets the value of [polyline_quality][crate::model::ComputeRoutesRequest::polyline_quality].
pub fn set_polyline_quality<T: Into<crate::model::PolylineQuality>>(
mut self,
v: T,
) -> Self {
self.0.request.polyline_quality = v.into();
self
}
/// Sets the value of [polyline_encoding][crate::model::ComputeRoutesRequest::polyline_encoding].
pub fn set_polyline_encoding<T: Into<crate::model::PolylineEncoding>>(
mut self,
v: T,
) -> Self {
self.0.request.polyline_encoding = v.into();
self
}
/// Sets the value of [departure_time][crate::model::ComputeRoutesRequest::departure_time].
pub fn set_departure_time<T>(mut self, v: T) -> Self
where
T: std::convert::Into<wkt::Timestamp>,
{
self.0.request.departure_time = std::option::Option::Some(v.into());
self
}
/// Sets or clears the value of [departure_time][crate::model::ComputeRoutesRequest::departure_time].
pub fn set_or_clear_departure_time<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<wkt::Timestamp>,
{
self.0.request.departure_time = v.map(|x| x.into());
self
}
/// Sets the value of [arrival_time][crate::model::ComputeRoutesRequest::arrival_time].
pub fn set_arrival_time<T>(mut self, v: T) -> Self
where
T: std::convert::Into<wkt::Timestamp>,
{
self.0.request.arrival_time = std::option::Option::Some(v.into());
self
}
/// Sets or clears the value of [arrival_time][crate::model::ComputeRoutesRequest::arrival_time].
pub fn set_or_clear_arrival_time<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<wkt::Timestamp>,
{
self.0.request.arrival_time = v.map(|x| x.into());
self
}
/// Sets the value of [compute_alternative_routes][crate::model::ComputeRoutesRequest::compute_alternative_routes].
pub fn set_compute_alternative_routes<T: Into<bool>>(mut self, v: T) -> Self {
self.0.request.compute_alternative_routes = v.into();
self
}
/// Sets the value of [route_modifiers][crate::model::ComputeRoutesRequest::route_modifiers].
pub fn set_route_modifiers<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::RouteModifiers>,
{
self.0.request.route_modifiers = std::option::Option::Some(v.into());
self
}
/// Sets or clears the value of [route_modifiers][crate::model::ComputeRoutesRequest::route_modifiers].
pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::RouteModifiers>,
{
self.0.request.route_modifiers = v.map(|x| x.into());
self
}
/// Sets the value of [language_code][crate::model::ComputeRoutesRequest::language_code].
pub fn set_language_code<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.language_code = v.into();
self
}
/// Sets the value of [region_code][crate::model::ComputeRoutesRequest::region_code].
pub fn set_region_code<T: Into<std::string::String>>(mut self, v: T) -> Self {
self.0.request.region_code = v.into();
self
}
/// Sets the value of [units][crate::model::ComputeRoutesRequest::units].
pub fn set_units<T: Into<crate::model::Units>>(mut self, v: T) -> Self {
self.0.request.units = v.into();
self
}
/// Sets the value of [optimize_waypoint_order][crate::model::ComputeRoutesRequest::optimize_waypoint_order].
pub fn set_optimize_waypoint_order<T: Into<bool>>(mut self, v: T) -> Self {
self.0.request.optimize_waypoint_order = v.into();
self
}
/// Sets the value of [requested_reference_routes][crate::model::ComputeRoutesRequest::requested_reference_routes].
pub fn set_requested_reference_routes<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::compute_routes_request::ReferenceRoute>,
{
use std::iter::Iterator;
self.0.request.requested_reference_routes = v.into_iter().map(|i| i.into()).collect();
self
}
/// Sets the value of [extra_computations][crate::model::ComputeRoutesRequest::extra_computations].
pub fn set_extra_computations<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::compute_routes_request::ExtraComputation>,
{
use std::iter::Iterator;
self.0.request.extra_computations = v.into_iter().map(|i| i.into()).collect();
self
}
/// Sets the value of [traffic_model][crate::model::ComputeRoutesRequest::traffic_model].
pub fn set_traffic_model<T: Into<crate::model::TrafficModel>>(mut self, v: T) -> Self {
self.0.request.traffic_model = v.into();
self
}
/// Sets the value of [transit_preferences][crate::model::ComputeRoutesRequest::transit_preferences].
pub fn set_transit_preferences<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::TransitPreferences>,
{
self.0.request.transit_preferences = std::option::Option::Some(v.into());
self
}
/// Sets or clears the value of [transit_preferences][crate::model::ComputeRoutesRequest::transit_preferences].
pub fn set_or_clear_transit_preferences<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::TransitPreferences>,
{
self.0.request.transit_preferences = v.map(|x| x.into());
self
}
}
#[doc(hidden)]
impl crate::RequestBuilder for ComputeRoutes {
fn request_options(&mut self) -> &mut crate::RequestOptions {
&mut self.0.options
}
}
}