google_maps_routeoptimization_v1/model.rs
1// Copyright 2026 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21#![no_implicit_prelude]
22extern crate async_trait;
23extern crate bytes;
24extern crate gaxi;
25extern crate google_cloud_gax;
26extern crate google_cloud_longrunning;
27extern crate google_cloud_lro;
28extern crate google_cloud_type;
29extern crate serde;
30extern crate serde_json;
31extern crate serde_with;
32extern crate std;
33extern crate tracing;
34extern crate wkt;
35
36mod debug;
37mod deserialize;
38mod serialize;
39
40/// A Universal Resource Identifier that points to a resource that can be read
41/// and written by the Route Optimization API.
42#[derive(Clone, Default, PartialEq)]
43#[non_exhaustive]
44pub struct Uri {
45 /// The URI of the resource. The resource may not yet exist.
46 ///
47 /// The contents of the resource are encoded as either JSON
48 /// or textproto. Only Google Cloud Storage resources are supported. If the
49 /// resource is encoded as JSON, the resource name must be suffixed with
50 /// `.json`. If the resource is encoded as textproto, the resource name must
51 /// be suffixed with `.txtpb`. For example, a Google Cloud Storage URI to
52 /// a JSON encoded file might look like: `gs://bucket/path/input/object.json`.
53 pub uri: std::string::String,
54
55 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
56}
57
58impl Uri {
59 /// Creates a new default instance.
60 pub fn new() -> Self {
61 std::default::Default::default()
62 }
63
64 /// Sets the value of [uri][crate::model::Uri::uri].
65 ///
66 /// # Example
67 /// ```ignore,no_run
68 /// # use google_maps_routeoptimization_v1::model::Uri;
69 /// let x = Uri::new().set_uri("example");
70 /// ```
71 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
72 self.uri = v.into();
73 self
74 }
75}
76
77impl wkt::message::Message for Uri {
78 fn typename() -> &'static str {
79 "type.googleapis.com/google.maps.routeoptimization.v1.Uri"
80 }
81}
82
83/// A request used by the `OptimizeToursUri` method.
84#[derive(Clone, Default, PartialEq)]
85#[non_exhaustive]
86pub struct OptimizeToursUriRequest {
87 /// Required. Target project or location to make a call.
88 ///
89 /// Format:
90 ///
91 /// * `projects/{project-id}`
92 /// * `projects/{project-id}/locations/{location-id}`
93 ///
94 /// If no location is specified, a region will be chosen automatically.
95 pub parent: std::string::String,
96
97 /// Required. The URI of the Cloud Storage object containing the
98 /// `OptimizeToursRequest`.
99 pub input: std::option::Option<crate::model::Uri>,
100
101 /// Required. The URI of the Cloud Storage object that will contain the
102 /// `OptimizeToursResponse`.
103 pub output: std::option::Option<crate::model::Uri>,
104
105 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
106}
107
108impl OptimizeToursUriRequest {
109 /// Creates a new default instance.
110 pub fn new() -> Self {
111 std::default::Default::default()
112 }
113
114 /// Sets the value of [parent][crate::model::OptimizeToursUriRequest::parent].
115 ///
116 /// # Example
117 /// ```ignore,no_run
118 /// # use google_maps_routeoptimization_v1::model::OptimizeToursUriRequest;
119 /// let x = OptimizeToursUriRequest::new().set_parent("example");
120 /// ```
121 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
122 self.parent = v.into();
123 self
124 }
125
126 /// Sets the value of [input][crate::model::OptimizeToursUriRequest::input].
127 ///
128 /// # Example
129 /// ```ignore,no_run
130 /// # use google_maps_routeoptimization_v1::model::OptimizeToursUriRequest;
131 /// use google_maps_routeoptimization_v1::model::Uri;
132 /// let x = OptimizeToursUriRequest::new().set_input(Uri::default()/* use setters */);
133 /// ```
134 pub fn set_input<T>(mut self, v: T) -> Self
135 where
136 T: std::convert::Into<crate::model::Uri>,
137 {
138 self.input = std::option::Option::Some(v.into());
139 self
140 }
141
142 /// Sets or clears the value of [input][crate::model::OptimizeToursUriRequest::input].
143 ///
144 /// # Example
145 /// ```ignore,no_run
146 /// # use google_maps_routeoptimization_v1::model::OptimizeToursUriRequest;
147 /// use google_maps_routeoptimization_v1::model::Uri;
148 /// let x = OptimizeToursUriRequest::new().set_or_clear_input(Some(Uri::default()/* use setters */));
149 /// let x = OptimizeToursUriRequest::new().set_or_clear_input(None::<Uri>);
150 /// ```
151 pub fn set_or_clear_input<T>(mut self, v: std::option::Option<T>) -> Self
152 where
153 T: std::convert::Into<crate::model::Uri>,
154 {
155 self.input = v.map(|x| x.into());
156 self
157 }
158
159 /// Sets the value of [output][crate::model::OptimizeToursUriRequest::output].
160 ///
161 /// # Example
162 /// ```ignore,no_run
163 /// # use google_maps_routeoptimization_v1::model::OptimizeToursUriRequest;
164 /// use google_maps_routeoptimization_v1::model::Uri;
165 /// let x = OptimizeToursUriRequest::new().set_output(Uri::default()/* use setters */);
166 /// ```
167 pub fn set_output<T>(mut self, v: T) -> Self
168 where
169 T: std::convert::Into<crate::model::Uri>,
170 {
171 self.output = std::option::Option::Some(v.into());
172 self
173 }
174
175 /// Sets or clears the value of [output][crate::model::OptimizeToursUriRequest::output].
176 ///
177 /// # Example
178 /// ```ignore,no_run
179 /// # use google_maps_routeoptimization_v1::model::OptimizeToursUriRequest;
180 /// use google_maps_routeoptimization_v1::model::Uri;
181 /// let x = OptimizeToursUriRequest::new().set_or_clear_output(Some(Uri::default()/* use setters */));
182 /// let x = OptimizeToursUriRequest::new().set_or_clear_output(None::<Uri>);
183 /// ```
184 pub fn set_or_clear_output<T>(mut self, v: std::option::Option<T>) -> Self
185 where
186 T: std::convert::Into<crate::model::Uri>,
187 {
188 self.output = v.map(|x| x.into());
189 self
190 }
191}
192
193impl wkt::message::Message for OptimizeToursUriRequest {
194 fn typename() -> &'static str {
195 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursUriRequest"
196 }
197}
198
199/// A response returned by the `OptimizeToursUri` method.
200#[derive(Clone, Default, PartialEq)]
201#[non_exhaustive]
202pub struct OptimizeToursUriResponse {
203 /// Optional. The URI of the Cloud Storage object containing the
204 /// `OptimizeToursResponse` encoded as either JSON or textproto. If the object
205 /// was encoded as JSON, the extension of the object name will be
206 /// `.json`. If the object was encoded as textproto, the extension of the
207 /// object name will be `.txtpb`.
208 ///
209 /// The `crc32_checksum` of the resource can be used to verify the contents of
210 /// the resource have not been modified.
211 pub output: std::option::Option<crate::model::Uri>,
212
213 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
214}
215
216impl OptimizeToursUriResponse {
217 /// Creates a new default instance.
218 pub fn new() -> Self {
219 std::default::Default::default()
220 }
221
222 /// Sets the value of [output][crate::model::OptimizeToursUriResponse::output].
223 ///
224 /// # Example
225 /// ```ignore,no_run
226 /// # use google_maps_routeoptimization_v1::model::OptimizeToursUriResponse;
227 /// use google_maps_routeoptimization_v1::model::Uri;
228 /// let x = OptimizeToursUriResponse::new().set_output(Uri::default()/* use setters */);
229 /// ```
230 pub fn set_output<T>(mut self, v: T) -> Self
231 where
232 T: std::convert::Into<crate::model::Uri>,
233 {
234 self.output = std::option::Option::Some(v.into());
235 self
236 }
237
238 /// Sets or clears the value of [output][crate::model::OptimizeToursUriResponse::output].
239 ///
240 /// # Example
241 /// ```ignore,no_run
242 /// # use google_maps_routeoptimization_v1::model::OptimizeToursUriResponse;
243 /// use google_maps_routeoptimization_v1::model::Uri;
244 /// let x = OptimizeToursUriResponse::new().set_or_clear_output(Some(Uri::default()/* use setters */));
245 /// let x = OptimizeToursUriResponse::new().set_or_clear_output(None::<Uri>);
246 /// ```
247 pub fn set_or_clear_output<T>(mut self, v: std::option::Option<T>) -> Self
248 where
249 T: std::convert::Into<crate::model::Uri>,
250 {
251 self.output = v.map(|x| x.into());
252 self
253 }
254}
255
256impl wkt::message::Message for OptimizeToursUriResponse {
257 fn typename() -> &'static str {
258 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursUriResponse"
259 }
260}
261
262/// Operation metadata for `OptimizeToursUri` calls.
263#[derive(Clone, Default, PartialEq)]
264#[non_exhaustive]
265pub struct OptimizeToursUriMetadata {
266 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
267}
268
269impl OptimizeToursUriMetadata {
270 /// Creates a new default instance.
271 pub fn new() -> Self {
272 std::default::Default::default()
273 }
274}
275
276impl wkt::message::Message for OptimizeToursUriMetadata {
277 fn typename() -> &'static str {
278 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursUriMetadata"
279 }
280}
281
282/// Request to batch optimize tours as an asynchronous operation.
283/// Each input file should contain one `OptimizeToursRequest`, and each output
284/// file will contain one `OptimizeToursResponse`. The request contains
285/// information to read/write and parse the files. All the input and output files
286/// should be under the same project.
287#[derive(Clone, Default, PartialEq)]
288#[non_exhaustive]
289pub struct BatchOptimizeToursRequest {
290 /// Required. Target project and location to make a call.
291 ///
292 /// Format:
293 ///
294 /// * `projects/{project-id}`
295 /// * `projects/{project-id}/locations/{location-id}`
296 ///
297 /// If no location is specified, a region will be chosen automatically.
298 pub parent: std::string::String,
299
300 /// Required. Input/Output information each purchase model, such as file paths
301 /// and data formats.
302 pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
303
304 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
305}
306
307impl BatchOptimizeToursRequest {
308 /// Creates a new default instance.
309 pub fn new() -> Self {
310 std::default::Default::default()
311 }
312
313 /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
314 ///
315 /// # Example
316 /// ```ignore,no_run
317 /// # use google_maps_routeoptimization_v1::model::BatchOptimizeToursRequest;
318 /// let x = BatchOptimizeToursRequest::new().set_parent("example");
319 /// ```
320 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
321 self.parent = v.into();
322 self
323 }
324
325 /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
326 ///
327 /// # Example
328 /// ```ignore,no_run
329 /// # use google_maps_routeoptimization_v1::model::BatchOptimizeToursRequest;
330 /// use google_maps_routeoptimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
331 /// let x = BatchOptimizeToursRequest::new()
332 /// .set_model_configs([
333 /// AsyncModelConfig::default()/* use setters */,
334 /// AsyncModelConfig::default()/* use (different) setters */,
335 /// ]);
336 /// ```
337 pub fn set_model_configs<T, V>(mut self, v: T) -> Self
338 where
339 T: std::iter::IntoIterator<Item = V>,
340 V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
341 {
342 use std::iter::Iterator;
343 self.model_configs = v.into_iter().map(|i| i.into()).collect();
344 self
345 }
346}
347
348impl wkt::message::Message for BatchOptimizeToursRequest {
349 fn typename() -> &'static str {
350 "type.googleapis.com/google.maps.routeoptimization.v1.BatchOptimizeToursRequest"
351 }
352}
353
354/// Defines additional types related to [BatchOptimizeToursRequest].
355pub mod batch_optimize_tours_request {
356 #[allow(unused_imports)]
357 use super::*;
358
359 /// Information for solving one optimization model asynchronously.
360 #[derive(Clone, Default, PartialEq)]
361 #[non_exhaustive]
362 pub struct AsyncModelConfig {
363 /// Optional. User defined model name, can be used as alias by users to keep
364 /// track of models.
365 pub display_name: std::string::String,
366
367 /// Required. Information about the input model.
368 pub input_config: std::option::Option<crate::model::InputConfig>,
369
370 /// Required. The desired output location information.
371 pub output_config: std::option::Option<crate::model::OutputConfig>,
372
373 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
374 }
375
376 impl AsyncModelConfig {
377 /// Creates a new default instance.
378 pub fn new() -> Self {
379 std::default::Default::default()
380 }
381
382 /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
383 ///
384 /// # Example
385 /// ```ignore,no_run
386 /// # use google_maps_routeoptimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
387 /// let x = AsyncModelConfig::new().set_display_name("example");
388 /// ```
389 pub fn set_display_name<T: std::convert::Into<std::string::String>>(
390 mut self,
391 v: T,
392 ) -> Self {
393 self.display_name = v.into();
394 self
395 }
396
397 /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
398 ///
399 /// # Example
400 /// ```ignore,no_run
401 /// # use google_maps_routeoptimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
402 /// use google_maps_routeoptimization_v1::model::InputConfig;
403 /// let x = AsyncModelConfig::new().set_input_config(InputConfig::default()/* use setters */);
404 /// ```
405 pub fn set_input_config<T>(mut self, v: T) -> Self
406 where
407 T: std::convert::Into<crate::model::InputConfig>,
408 {
409 self.input_config = std::option::Option::Some(v.into());
410 self
411 }
412
413 /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
414 ///
415 /// # Example
416 /// ```ignore,no_run
417 /// # use google_maps_routeoptimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
418 /// use google_maps_routeoptimization_v1::model::InputConfig;
419 /// let x = AsyncModelConfig::new().set_or_clear_input_config(Some(InputConfig::default()/* use setters */));
420 /// let x = AsyncModelConfig::new().set_or_clear_input_config(None::<InputConfig>);
421 /// ```
422 pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
423 where
424 T: std::convert::Into<crate::model::InputConfig>,
425 {
426 self.input_config = v.map(|x| x.into());
427 self
428 }
429
430 /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
431 ///
432 /// # Example
433 /// ```ignore,no_run
434 /// # use google_maps_routeoptimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
435 /// use google_maps_routeoptimization_v1::model::OutputConfig;
436 /// let x = AsyncModelConfig::new().set_output_config(OutputConfig::default()/* use setters */);
437 /// ```
438 pub fn set_output_config<T>(mut self, v: T) -> Self
439 where
440 T: std::convert::Into<crate::model::OutputConfig>,
441 {
442 self.output_config = std::option::Option::Some(v.into());
443 self
444 }
445
446 /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
447 ///
448 /// # Example
449 /// ```ignore,no_run
450 /// # use google_maps_routeoptimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
451 /// use google_maps_routeoptimization_v1::model::OutputConfig;
452 /// let x = AsyncModelConfig::new().set_or_clear_output_config(Some(OutputConfig::default()/* use setters */));
453 /// let x = AsyncModelConfig::new().set_or_clear_output_config(None::<OutputConfig>);
454 /// ```
455 pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
456 where
457 T: std::convert::Into<crate::model::OutputConfig>,
458 {
459 self.output_config = v.map(|x| x.into());
460 self
461 }
462 }
463
464 impl wkt::message::Message for AsyncModelConfig {
465 fn typename() -> &'static str {
466 "type.googleapis.com/google.maps.routeoptimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
467 }
468 }
469}
470
471/// Response to a `BatchOptimizeToursRequest`. This is returned in
472/// the Long Running Operation after the operation is complete.
473#[derive(Clone, Default, PartialEq)]
474#[non_exhaustive]
475pub struct BatchOptimizeToursResponse {
476 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
477}
478
479impl BatchOptimizeToursResponse {
480 /// Creates a new default instance.
481 pub fn new() -> Self {
482 std::default::Default::default()
483 }
484}
485
486impl wkt::message::Message for BatchOptimizeToursResponse {
487 fn typename() -> &'static str {
488 "type.googleapis.com/google.maps.routeoptimization.v1.BatchOptimizeToursResponse"
489 }
490}
491
492/// Operation metadata for `BatchOptimizeToursRequest` calls.
493#[derive(Clone, Default, PartialEq)]
494#[non_exhaustive]
495pub struct BatchOptimizeToursMetadata {
496 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
497}
498
499impl BatchOptimizeToursMetadata {
500 /// Creates a new default instance.
501 pub fn new() -> Self {
502 std::default::Default::default()
503 }
504}
505
506impl wkt::message::Message for BatchOptimizeToursMetadata {
507 fn typename() -> &'static str {
508 "type.googleapis.com/google.maps.routeoptimization.v1.BatchOptimizeToursMetadata"
509 }
510}
511
512/// Operation metadata for `OptimizeToursLongRunning` calls.
513#[derive(Clone, Default, PartialEq)]
514#[non_exhaustive]
515pub struct OptimizeToursLongRunningMetadata {
516 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
517}
518
519impl OptimizeToursLongRunningMetadata {
520 /// Creates a new default instance.
521 pub fn new() -> Self {
522 std::default::Default::default()
523 }
524}
525
526impl wkt::message::Message for OptimizeToursLongRunningMetadata {
527 fn typename() -> &'static str {
528 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursLongRunningMetadata"
529 }
530}
531
532/// Request to be given to a tour optimization solver which defines the
533/// shipment model to solve as well as optimization parameters.
534#[derive(Clone, Default, PartialEq)]
535#[non_exhaustive]
536pub struct OptimizeToursRequest {
537 /// Required. Target project or location to make a call.
538 ///
539 /// Format:
540 ///
541 /// * `projects/{project-id}`
542 /// * `projects/{project-id}/locations/{location-id}`
543 ///
544 /// If no location is specified, a region will be chosen automatically.
545 pub parent: std::string::String,
546
547 /// If this timeout is set, the server returns a response before the timeout
548 /// period has elapsed or the server deadline for synchronous requests is
549 /// reached, whichever is sooner.
550 ///
551 /// For asynchronous requests, the server will generate a solution (if
552 /// possible) before the timeout has elapsed.
553 pub timeout: std::option::Option<wkt::Duration>,
554
555 /// Shipment model to solve.
556 pub model: std::option::Option<crate::model::ShipmentModel>,
557
558 /// By default, the solving mode is `DEFAULT_SOLVE` (0).
559 pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
560
561 /// Search mode used to solve the request.
562 pub search_mode: crate::model::optimize_tours_request::SearchMode,
563
564 /// Guide the optimization algorithm in finding a first solution that is
565 /// similar to a previous solution.
566 ///
567 /// The model is constrained when the first solution is built.
568 /// Any shipments not performed on a route are implicitly skipped in the first
569 /// solution, but they may be performed in successive solutions.
570 ///
571 /// The solution must satisfy some basic validity assumptions:
572 ///
573 /// * for all routes, `vehicle_index` must be in range and not be duplicated.
574 /// * for all visits, `shipment_index` and `visit_request_index` must be
575 /// in range.
576 /// * a shipment may only be referenced on one route.
577 /// * the pickup of a pickup-delivery shipment must be performed before
578 /// the delivery.
579 /// * no more than one pickup alternative or delivery alternative of
580 /// a shipment may be performed.
581 /// * for all routes, times are increasing (i.e., `vehicle_start_time
582 /// <= visits[0].start_time <= visits[1].start_time ...
583 /// <= vehicle_end_time`).
584 /// * a shipment may only be performed on a vehicle that is allowed. A
585 /// vehicle is allowed if
586 /// [Shipment.allowed_vehicle_indices][google.maps.routeoptimization.v1.Shipment.allowed_vehicle_indices]
587 /// is empty or its `vehicle_index` is included in
588 /// [Shipment.allowed_vehicle_indices][google.maps.routeoptimization.v1.Shipment.allowed_vehicle_indices].
589 ///
590 /// If the injected solution is not feasible, a validation error is not
591 /// necessarily returned and an error indicating infeasibility may be returned
592 /// instead.
593 ///
594 /// [google.maps.routeoptimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
595 pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
596
597 /// Constrain the optimization algorithm to find a final solution that is
598 /// similar to a previous solution. For example, this may be used to freeze
599 /// portions of routes which have already been completed or which are to be
600 /// completed but must not be modified.
601 ///
602 /// If the injected solution is not feasible, a validation error is not
603 /// necessarily returned and an error indicating infeasibility may be returned
604 /// instead.
605 pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
606
607 /// If non-empty, the given routes will be refreshed, without modifying their
608 /// underlying sequence of visits or travel times: only other details will be
609 /// updated. This does not solve the model.
610 ///
611 /// As of 2020/11, this only populates the polylines of non-empty routes and
612 /// requires that `populate_polylines` is true.
613 ///
614 /// The `route_polyline` fields of the passed-in routes may be inconsistent
615 /// with route `transitions`.
616 ///
617 /// This field must not be used together with `injected_first_solution_routes`
618 /// or `injected_solution_constraint`.
619 ///
620 /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
621 /// Polylines are still populated between all visits in all non-empty routes
622 /// regardless of whether the related shipments or vehicles are ignored.
623 pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
624
625 /// If true:
626 ///
627 /// * uses
628 /// [ShipmentRoute.vehicle_label][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_label]
629 /// instead of `vehicle_index` to
630 /// match routes in an injected solution with vehicles in the request;
631 /// reuses the mapping of original
632 /// [ShipmentRoute.vehicle_index][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_index]
633 /// to new
634 /// [ShipmentRoute.vehicle_index][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_index]
635 /// to update
636 /// [ConstraintRelaxation.vehicle_indices][google.maps.routeoptimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
637 /// if non-empty, but the mapping must be unambiguous (i.e., multiple
638 /// `ShipmentRoute`s must not share the same original `vehicle_index`).
639 /// * uses
640 /// [ShipmentRoute.Visit.shipment_label][google.maps.routeoptimization.v1.ShipmentRoute.Visit.shipment_label]
641 /// instead of `shipment_index`
642 /// to match visits in an injected solution with shipments in the request;
643 /// * uses
644 /// [SkippedShipment.label][google.maps.routeoptimization.v1.SkippedShipment.label]
645 /// instead of
646 /// [SkippedShipment.index][google.maps.routeoptimization.v1.SkippedShipment.index]
647 /// to
648 /// match skipped shipments in the injected solution with request
649 /// shipments.
650 ///
651 /// This interpretation applies to the `injected_first_solution_routes`,
652 /// `injected_solution_constraint`, and `refresh_details_routes` fields.
653 /// It can be used when shipment or vehicle indices in the request have
654 /// changed since the solution was created, perhaps because shipments or
655 /// vehicles have been removed from or added to the request.
656 ///
657 /// If true, labels in the following categories must appear at most once in
658 /// their category:
659 ///
660 /// * [Vehicle.label][google.maps.routeoptimization.v1.Vehicle.label] in the
661 /// request;
662 /// * [Shipment.label][google.maps.routeoptimization.v1.Shipment.label] in
663 /// the request;
664 /// * [ShipmentRoute.vehicle_label][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
665 /// * [SkippedShipment.label][google.maps.routeoptimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.maps.routeoptimization.v1.ShipmentRoute.Visit.shipment_label] in
666 /// the injected solution (except pickup/delivery visit pairs, whose
667 /// `shipment_label` must appear twice).
668 ///
669 /// If a `vehicle_label` in the injected solution does not correspond to a
670 /// request vehicle, the corresponding route is removed from the solution
671 /// along with its visits. If a `shipment_label` in the injected solution does
672 /// not correspond to a request shipment, the corresponding visit is removed
673 /// from the solution. If a
674 /// [SkippedShipment.label][google.maps.routeoptimization.v1.SkippedShipment.label]
675 /// in the injected solution does not correspond to a request shipment, the
676 /// `SkippedShipment` is removed from the solution.
677 ///
678 /// Removing route visits or entire routes from an injected solution may
679 /// have an effect on the implied constraints, which may lead to change in
680 /// solution, validation errors, or infeasibility.
681 ///
682 /// NOTE: The caller must ensure that each
683 /// [Vehicle.label][google.maps.routeoptimization.v1.Vehicle.label] (resp.
684 /// [Shipment.label][google.maps.routeoptimization.v1.Shipment.label]) uniquely
685 /// identifies a vehicle (resp. shipment) entity used across the two relevant
686 /// requests: the past request that produced the `OptimizeToursResponse` used
687 /// in the injected solution and the current request that includes the injected
688 /// solution. The uniqueness checks described above are not enough to guarantee
689 /// this requirement.
690 ///
691 /// [google.maps.routeoptimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
692 /// [google.maps.routeoptimization.v1.Shipment.label]: crate::model::Shipment::label
693 /// [google.maps.routeoptimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
694 /// [google.maps.routeoptimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
695 /// [google.maps.routeoptimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
696 /// [google.maps.routeoptimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
697 /// [google.maps.routeoptimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
698 /// [google.maps.routeoptimization.v1.Vehicle.label]: crate::model::Vehicle::label
699 pub interpret_injected_solutions_using_labels: bool,
700
701 /// Consider traffic estimation in calculating `ShipmentRoute` fields
702 /// [Transition.travel_duration][google.maps.routeoptimization.v1.ShipmentRoute.Transition.travel_duration],
703 /// [Visit.start_time][google.maps.routeoptimization.v1.ShipmentRoute.Visit.start_time],
704 /// and `vehicle_end_time`; in setting the
705 /// [ShipmentRoute.has_traffic_infeasibilities][google.maps.routeoptimization.v1.ShipmentRoute.has_traffic_infeasibilities]
706 /// field, and in calculating the
707 /// [OptimizeToursResponse.total_cost][google.maps.routeoptimization.v1.OptimizeToursResponse.total_cost]
708 /// field.
709 ///
710 /// [google.maps.routeoptimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
711 /// [google.maps.routeoptimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
712 /// [google.maps.routeoptimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
713 pub consider_road_traffic: bool,
714
715 /// If true, polylines will be populated in response `ShipmentRoute`s.
716 pub populate_polylines: bool,
717
718 /// If true, polylines and route tokens will be populated in response
719 /// [ShipmentRoute.transitions][google.maps.routeoptimization.v1.ShipmentRoute.transitions].
720 ///
721 /// [google.maps.routeoptimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
722 pub populate_transition_polylines: bool,
723
724 /// If this is set, then the request can have a deadline
725 /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
726 /// Otherwise, the maximum deadline is only 30 minutes.
727 /// Note that long-lived requests have a significantly larger (but still small)
728 /// risk of interruption.
729 pub allow_large_deadline_despite_interruption_risk: bool,
730
731 /// If true, travel distances will be computed using geodesic distances instead
732 /// of Google Maps distances, and travel times will be computed using geodesic
733 /// distances with a speed defined by `geodesic_meters_per_second`.
734 pub use_geodesic_distances: bool,
735
736 /// When `use_geodesic_distances` is true, this field must be set and defines
737 /// the speed applied to compute travel times. Its value must be at least 1.0
738 /// meters/seconds.
739 pub geodesic_meters_per_second: std::option::Option<f64>,
740
741 /// Truncates the number of validation errors returned. These errors are
742 /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
743 /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
744 /// unless solving_mode=VALIDATE_ONLY: see the
745 /// [OptimizeToursResponse.validation_errors][google.maps.routeoptimization.v1.OptimizeToursResponse.validation_errors]
746 /// field.
747 /// This defaults to 100 and is capped at 10,000.
748 ///
749 /// [google.maps.routeoptimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
750 pub max_validation_errors: std::option::Option<i32>,
751
752 /// Label that may be used to identify this request, reported back in the
753 /// [OptimizeToursResponse.request_label][google.maps.routeoptimization.v1.OptimizeToursResponse.request_label].
754 ///
755 /// [google.maps.routeoptimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
756 pub label: std::string::String,
757
758 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
759}
760
761impl OptimizeToursRequest {
762 /// Creates a new default instance.
763 pub fn new() -> Self {
764 std::default::Default::default()
765 }
766
767 /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
768 ///
769 /// # Example
770 /// ```ignore,no_run
771 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
772 /// let x = OptimizeToursRequest::new().set_parent("example");
773 /// ```
774 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
775 self.parent = v.into();
776 self
777 }
778
779 /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
780 ///
781 /// # Example
782 /// ```ignore,no_run
783 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
784 /// use wkt::Duration;
785 /// let x = OptimizeToursRequest::new().set_timeout(Duration::default()/* use setters */);
786 /// ```
787 pub fn set_timeout<T>(mut self, v: T) -> Self
788 where
789 T: std::convert::Into<wkt::Duration>,
790 {
791 self.timeout = std::option::Option::Some(v.into());
792 self
793 }
794
795 /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
796 ///
797 /// # Example
798 /// ```ignore,no_run
799 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
800 /// use wkt::Duration;
801 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(Some(Duration::default()/* use setters */));
802 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(None::<Duration>);
803 /// ```
804 pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
805 where
806 T: std::convert::Into<wkt::Duration>,
807 {
808 self.timeout = v.map(|x| x.into());
809 self
810 }
811
812 /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
813 ///
814 /// # Example
815 /// ```ignore,no_run
816 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
817 /// use google_maps_routeoptimization_v1::model::ShipmentModel;
818 /// let x = OptimizeToursRequest::new().set_model(ShipmentModel::default()/* use setters */);
819 /// ```
820 pub fn set_model<T>(mut self, v: T) -> Self
821 where
822 T: std::convert::Into<crate::model::ShipmentModel>,
823 {
824 self.model = std::option::Option::Some(v.into());
825 self
826 }
827
828 /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
829 ///
830 /// # Example
831 /// ```ignore,no_run
832 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
833 /// use google_maps_routeoptimization_v1::model::ShipmentModel;
834 /// let x = OptimizeToursRequest::new().set_or_clear_model(Some(ShipmentModel::default()/* use setters */));
835 /// let x = OptimizeToursRequest::new().set_or_clear_model(None::<ShipmentModel>);
836 /// ```
837 pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
838 where
839 T: std::convert::Into<crate::model::ShipmentModel>,
840 {
841 self.model = v.map(|x| x.into());
842 self
843 }
844
845 /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
846 ///
847 /// # Example
848 /// ```ignore,no_run
849 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
850 /// use google_maps_routeoptimization_v1::model::optimize_tours_request::SolvingMode;
851 /// let x0 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::ValidateOnly);
852 /// let x1 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::DetectSomeInfeasibleShipments);
853 /// let x2 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::TransformAndReturnRequest);
854 /// ```
855 pub fn set_solving_mode<
856 T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
857 >(
858 mut self,
859 v: T,
860 ) -> Self {
861 self.solving_mode = v.into();
862 self
863 }
864
865 /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
866 ///
867 /// # Example
868 /// ```ignore,no_run
869 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
870 /// use google_maps_routeoptimization_v1::model::optimize_tours_request::SearchMode;
871 /// let x0 = OptimizeToursRequest::new().set_search_mode(SearchMode::ReturnFast);
872 /// let x1 = OptimizeToursRequest::new().set_search_mode(SearchMode::ConsumeAllAvailableTime);
873 /// ```
874 pub fn set_search_mode<
875 T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
876 >(
877 mut self,
878 v: T,
879 ) -> Self {
880 self.search_mode = v.into();
881 self
882 }
883
884 /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
885 ///
886 /// # Example
887 /// ```ignore,no_run
888 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
889 /// use google_maps_routeoptimization_v1::model::ShipmentRoute;
890 /// let x = OptimizeToursRequest::new()
891 /// .set_injected_first_solution_routes([
892 /// ShipmentRoute::default()/* use setters */,
893 /// ShipmentRoute::default()/* use (different) setters */,
894 /// ]);
895 /// ```
896 pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
897 where
898 T: std::iter::IntoIterator<Item = V>,
899 V: std::convert::Into<crate::model::ShipmentRoute>,
900 {
901 use std::iter::Iterator;
902 self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
903 self
904 }
905
906 /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
907 ///
908 /// # Example
909 /// ```ignore,no_run
910 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
911 /// use google_maps_routeoptimization_v1::model::InjectedSolutionConstraint;
912 /// let x = OptimizeToursRequest::new().set_injected_solution_constraint(InjectedSolutionConstraint::default()/* use setters */);
913 /// ```
914 pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
915 where
916 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
917 {
918 self.injected_solution_constraint = std::option::Option::Some(v.into());
919 self
920 }
921
922 /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
923 ///
924 /// # Example
925 /// ```ignore,no_run
926 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
927 /// use google_maps_routeoptimization_v1::model::InjectedSolutionConstraint;
928 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(Some(InjectedSolutionConstraint::default()/* use setters */));
929 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(None::<InjectedSolutionConstraint>);
930 /// ```
931 pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
932 where
933 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
934 {
935 self.injected_solution_constraint = v.map(|x| x.into());
936 self
937 }
938
939 /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
940 ///
941 /// # Example
942 /// ```ignore,no_run
943 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
944 /// use google_maps_routeoptimization_v1::model::ShipmentRoute;
945 /// let x = OptimizeToursRequest::new()
946 /// .set_refresh_details_routes([
947 /// ShipmentRoute::default()/* use setters */,
948 /// ShipmentRoute::default()/* use (different) setters */,
949 /// ]);
950 /// ```
951 pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
952 where
953 T: std::iter::IntoIterator<Item = V>,
954 V: std::convert::Into<crate::model::ShipmentRoute>,
955 {
956 use std::iter::Iterator;
957 self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
958 self
959 }
960
961 /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
962 ///
963 /// # Example
964 /// ```ignore,no_run
965 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
966 /// let x = OptimizeToursRequest::new().set_interpret_injected_solutions_using_labels(true);
967 /// ```
968 pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
969 mut self,
970 v: T,
971 ) -> Self {
972 self.interpret_injected_solutions_using_labels = v.into();
973 self
974 }
975
976 /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
977 ///
978 /// # Example
979 /// ```ignore,no_run
980 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
981 /// let x = OptimizeToursRequest::new().set_consider_road_traffic(true);
982 /// ```
983 pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
984 self.consider_road_traffic = v.into();
985 self
986 }
987
988 /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
989 ///
990 /// # Example
991 /// ```ignore,no_run
992 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
993 /// let x = OptimizeToursRequest::new().set_populate_polylines(true);
994 /// ```
995 pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
996 self.populate_polylines = v.into();
997 self
998 }
999
1000 /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
1001 ///
1002 /// # Example
1003 /// ```ignore,no_run
1004 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1005 /// let x = OptimizeToursRequest::new().set_populate_transition_polylines(true);
1006 /// ```
1007 pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1008 self.populate_transition_polylines = v.into();
1009 self
1010 }
1011
1012 /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
1013 ///
1014 /// # Example
1015 /// ```ignore,no_run
1016 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1017 /// let x = OptimizeToursRequest::new().set_allow_large_deadline_despite_interruption_risk(true);
1018 /// ```
1019 pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1020 mut self,
1021 v: T,
1022 ) -> Self {
1023 self.allow_large_deadline_despite_interruption_risk = v.into();
1024 self
1025 }
1026
1027 /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
1028 ///
1029 /// # Example
1030 /// ```ignore,no_run
1031 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1032 /// let x = OptimizeToursRequest::new().set_use_geodesic_distances(true);
1033 /// ```
1034 pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1035 self.use_geodesic_distances = v.into();
1036 self
1037 }
1038
1039 /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1040 ///
1041 /// # Example
1042 /// ```ignore,no_run
1043 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1044 /// let x = OptimizeToursRequest::new().set_geodesic_meters_per_second(42.0);
1045 /// ```
1046 pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1047 where
1048 T: std::convert::Into<f64>,
1049 {
1050 self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1051 self
1052 }
1053
1054 /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1055 ///
1056 /// # Example
1057 /// ```ignore,no_run
1058 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1059 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(Some(42.0));
1060 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(None::<f32>);
1061 /// ```
1062 pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1063 where
1064 T: std::convert::Into<f64>,
1065 {
1066 self.geodesic_meters_per_second = v.map(|x| x.into());
1067 self
1068 }
1069
1070 /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1071 ///
1072 /// # Example
1073 /// ```ignore,no_run
1074 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1075 /// let x = OptimizeToursRequest::new().set_max_validation_errors(42);
1076 /// ```
1077 pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1078 where
1079 T: std::convert::Into<i32>,
1080 {
1081 self.max_validation_errors = std::option::Option::Some(v.into());
1082 self
1083 }
1084
1085 /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1086 ///
1087 /// # Example
1088 /// ```ignore,no_run
1089 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1090 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(Some(42));
1091 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(None::<i32>);
1092 /// ```
1093 pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1094 where
1095 T: std::convert::Into<i32>,
1096 {
1097 self.max_validation_errors = v.map(|x| x.into());
1098 self
1099 }
1100
1101 /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
1102 ///
1103 /// # Example
1104 /// ```ignore,no_run
1105 /// # use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1106 /// let x = OptimizeToursRequest::new().set_label("example");
1107 /// ```
1108 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1109 self.label = v.into();
1110 self
1111 }
1112}
1113
1114impl wkt::message::Message for OptimizeToursRequest {
1115 fn typename() -> &'static str {
1116 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursRequest"
1117 }
1118}
1119
1120/// Defines additional types related to [OptimizeToursRequest].
1121pub mod optimize_tours_request {
1122 #[allow(unused_imports)]
1123 use super::*;
1124
1125 /// Defines how the solver should handle the request. In all modes but
1126 /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
1127 /// `INVALID_REQUEST` error. See
1128 /// [max_validation_errors][google.maps.routeoptimization.v1.OptimizeToursRequest.max_validation_errors]
1129 /// to cap the number of errors returned.
1130 ///
1131 /// [google.maps.routeoptimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
1132 ///
1133 /// # Working with unknown values
1134 ///
1135 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1136 /// additional enum variants at any time. Adding new variants is not considered
1137 /// a breaking change. Applications should write their code in anticipation of:
1138 ///
1139 /// - New values appearing in future releases of the client library, **and**
1140 /// - New values received dynamically, without application changes.
1141 ///
1142 /// Please consult the [Working with enums] section in the user guide for some
1143 /// guidelines.
1144 ///
1145 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1146 #[derive(Clone, Debug, PartialEq)]
1147 #[non_exhaustive]
1148 pub enum SolvingMode {
1149 /// Solve the model. Warnings may be issued in
1150 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors].
1151 DefaultSolve,
1152 /// Only validates the model without solving it: populates as many
1153 /// [OptimizeToursResponse.validation_errors][google.maps.routeoptimization.v1.OptimizeToursResponse.validation_errors]
1154 /// as possible.
1155 ///
1156 /// [google.maps.routeoptimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1157 ValidateOnly,
1158 /// Only populates
1159 /// [OptimizeToursResponse.validation_errors][google.maps.routeoptimization.v1.OptimizeToursResponse.validation_errors]
1160 /// or
1161 /// [OptimizeToursResponse.skipped_shipments][google.maps.routeoptimization.v1.OptimizeToursResponse.skipped_shipments],
1162 /// and doesn't actually solve the rest of the request (`status` and `routes`
1163 /// are unset in the response).
1164 /// If infeasibilities in `injected_solution_constraint` routes are detected
1165 /// they are populated in the
1166 /// [OptimizeToursResponse.validation_errors][google.maps.routeoptimization.v1.OptimizeToursResponse.validation_errors]
1167 /// field and
1168 /// [OptimizeToursResponse.skipped_shipments][google.maps.routeoptimization.v1.OptimizeToursResponse.skipped_shipments]
1169 /// is left empty.
1170 ///
1171 /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
1172 /// ones that are detected as infeasible during preprocessing.
1173 ///
1174 /// [google.maps.routeoptimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
1175 /// [google.maps.routeoptimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1176 DetectSomeInfeasibleShipments,
1177 /// This mode only works if `ShipmentModel.objectives` is not empty. The
1178 /// request is not solved. It is only validated and filled with costs
1179 /// corresponding to the given objectives. Also see the documentation of
1180 /// `ShipmentModel.objectives`. The resulting request is returned as
1181 /// `OptimizeToursResponse.processed_request`.
1182 ///
1183 /// Experimental: See
1184 /// <https://developers.google.com/maps/tt/route-optimization/experimental/objectives/make-request>
1185 /// for more details.
1186 TransformAndReturnRequest,
1187 /// If set, the enum was initialized with an unknown value.
1188 ///
1189 /// Applications can examine the value using [SolvingMode::value] or
1190 /// [SolvingMode::name].
1191 UnknownValue(solving_mode::UnknownValue),
1192 }
1193
1194 #[doc(hidden)]
1195 pub mod solving_mode {
1196 #[allow(unused_imports)]
1197 use super::*;
1198 #[derive(Clone, Debug, PartialEq)]
1199 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1200 }
1201
1202 impl SolvingMode {
1203 /// Gets the enum value.
1204 ///
1205 /// Returns `None` if the enum contains an unknown value deserialized from
1206 /// the string representation of enums.
1207 pub fn value(&self) -> std::option::Option<i32> {
1208 match self {
1209 Self::DefaultSolve => std::option::Option::Some(0),
1210 Self::ValidateOnly => std::option::Option::Some(1),
1211 Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
1212 Self::TransformAndReturnRequest => std::option::Option::Some(3),
1213 Self::UnknownValue(u) => u.0.value(),
1214 }
1215 }
1216
1217 /// Gets the enum value as a string.
1218 ///
1219 /// Returns `None` if the enum contains an unknown value deserialized from
1220 /// the integer representation of enums.
1221 pub fn name(&self) -> std::option::Option<&str> {
1222 match self {
1223 Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
1224 Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
1225 Self::DetectSomeInfeasibleShipments => {
1226 std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
1227 }
1228 Self::TransformAndReturnRequest => {
1229 std::option::Option::Some("TRANSFORM_AND_RETURN_REQUEST")
1230 }
1231 Self::UnknownValue(u) => u.0.name(),
1232 }
1233 }
1234 }
1235
1236 impl std::default::Default for SolvingMode {
1237 fn default() -> Self {
1238 use std::convert::From;
1239 Self::from(0)
1240 }
1241 }
1242
1243 impl std::fmt::Display for SolvingMode {
1244 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1245 wkt::internal::display_enum(f, self.name(), self.value())
1246 }
1247 }
1248
1249 impl std::convert::From<i32> for SolvingMode {
1250 fn from(value: i32) -> Self {
1251 match value {
1252 0 => Self::DefaultSolve,
1253 1 => Self::ValidateOnly,
1254 2 => Self::DetectSomeInfeasibleShipments,
1255 3 => Self::TransformAndReturnRequest,
1256 _ => Self::UnknownValue(solving_mode::UnknownValue(
1257 wkt::internal::UnknownEnumValue::Integer(value),
1258 )),
1259 }
1260 }
1261 }
1262
1263 impl std::convert::From<&str> for SolvingMode {
1264 fn from(value: &str) -> Self {
1265 use std::string::ToString;
1266 match value {
1267 "DEFAULT_SOLVE" => Self::DefaultSolve,
1268 "VALIDATE_ONLY" => Self::ValidateOnly,
1269 "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
1270 "TRANSFORM_AND_RETURN_REQUEST" => Self::TransformAndReturnRequest,
1271 _ => Self::UnknownValue(solving_mode::UnknownValue(
1272 wkt::internal::UnknownEnumValue::String(value.to_string()),
1273 )),
1274 }
1275 }
1276 }
1277
1278 impl serde::ser::Serialize for SolvingMode {
1279 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1280 where
1281 S: serde::Serializer,
1282 {
1283 match self {
1284 Self::DefaultSolve => serializer.serialize_i32(0),
1285 Self::ValidateOnly => serializer.serialize_i32(1),
1286 Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
1287 Self::TransformAndReturnRequest => serializer.serialize_i32(3),
1288 Self::UnknownValue(u) => u.0.serialize(serializer),
1289 }
1290 }
1291 }
1292
1293 impl<'de> serde::de::Deserialize<'de> for SolvingMode {
1294 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1295 where
1296 D: serde::Deserializer<'de>,
1297 {
1298 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
1299 ".google.maps.routeoptimization.v1.OptimizeToursRequest.SolvingMode",
1300 ))
1301 }
1302 }
1303
1304 /// Mode defining the behavior of the search, trading off latency versus
1305 /// solution quality. In all modes, the global request deadline is enforced.
1306 ///
1307 /// # Working with unknown values
1308 ///
1309 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1310 /// additional enum variants at any time. Adding new variants is not considered
1311 /// a breaking change. Applications should write their code in anticipation of:
1312 ///
1313 /// - New values appearing in future releases of the client library, **and**
1314 /// - New values received dynamically, without application changes.
1315 ///
1316 /// Please consult the [Working with enums] section in the user guide for some
1317 /// guidelines.
1318 ///
1319 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1320 #[derive(Clone, Debug, PartialEq)]
1321 #[non_exhaustive]
1322 pub enum SearchMode {
1323 /// Unspecified search mode, equivalent to `RETURN_FAST`.
1324 Unspecified,
1325 /// Stop the search after finding the first good solution.
1326 ReturnFast,
1327 /// Spend all the available time to search for better solutions.
1328 ConsumeAllAvailableTime,
1329 /// If set, the enum was initialized with an unknown value.
1330 ///
1331 /// Applications can examine the value using [SearchMode::value] or
1332 /// [SearchMode::name].
1333 UnknownValue(search_mode::UnknownValue),
1334 }
1335
1336 #[doc(hidden)]
1337 pub mod search_mode {
1338 #[allow(unused_imports)]
1339 use super::*;
1340 #[derive(Clone, Debug, PartialEq)]
1341 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1342 }
1343
1344 impl SearchMode {
1345 /// Gets the enum value.
1346 ///
1347 /// Returns `None` if the enum contains an unknown value deserialized from
1348 /// the string representation of enums.
1349 pub fn value(&self) -> std::option::Option<i32> {
1350 match self {
1351 Self::Unspecified => std::option::Option::Some(0),
1352 Self::ReturnFast => std::option::Option::Some(1),
1353 Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
1354 Self::UnknownValue(u) => u.0.value(),
1355 }
1356 }
1357
1358 /// Gets the enum value as a string.
1359 ///
1360 /// Returns `None` if the enum contains an unknown value deserialized from
1361 /// the integer representation of enums.
1362 pub fn name(&self) -> std::option::Option<&str> {
1363 match self {
1364 Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
1365 Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
1366 Self::ConsumeAllAvailableTime => {
1367 std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
1368 }
1369 Self::UnknownValue(u) => u.0.name(),
1370 }
1371 }
1372 }
1373
1374 impl std::default::Default for SearchMode {
1375 fn default() -> Self {
1376 use std::convert::From;
1377 Self::from(0)
1378 }
1379 }
1380
1381 impl std::fmt::Display for SearchMode {
1382 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1383 wkt::internal::display_enum(f, self.name(), self.value())
1384 }
1385 }
1386
1387 impl std::convert::From<i32> for SearchMode {
1388 fn from(value: i32) -> Self {
1389 match value {
1390 0 => Self::Unspecified,
1391 1 => Self::ReturnFast,
1392 2 => Self::ConsumeAllAvailableTime,
1393 _ => Self::UnknownValue(search_mode::UnknownValue(
1394 wkt::internal::UnknownEnumValue::Integer(value),
1395 )),
1396 }
1397 }
1398 }
1399
1400 impl std::convert::From<&str> for SearchMode {
1401 fn from(value: &str) -> Self {
1402 use std::string::ToString;
1403 match value {
1404 "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
1405 "RETURN_FAST" => Self::ReturnFast,
1406 "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
1407 _ => Self::UnknownValue(search_mode::UnknownValue(
1408 wkt::internal::UnknownEnumValue::String(value.to_string()),
1409 )),
1410 }
1411 }
1412 }
1413
1414 impl serde::ser::Serialize for SearchMode {
1415 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1416 where
1417 S: serde::Serializer,
1418 {
1419 match self {
1420 Self::Unspecified => serializer.serialize_i32(0),
1421 Self::ReturnFast => serializer.serialize_i32(1),
1422 Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
1423 Self::UnknownValue(u) => u.0.serialize(serializer),
1424 }
1425 }
1426 }
1427
1428 impl<'de> serde::de::Deserialize<'de> for SearchMode {
1429 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1430 where
1431 D: serde::Deserializer<'de>,
1432 {
1433 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
1434 ".google.maps.routeoptimization.v1.OptimizeToursRequest.SearchMode",
1435 ))
1436 }
1437 }
1438}
1439
1440/// Response after solving a tour optimization problem containing the routes
1441/// followed by each vehicle, the shipments which have been skipped and the
1442/// overall cost of the solution.
1443#[derive(Clone, Default, PartialEq)]
1444#[non_exhaustive]
1445pub struct OptimizeToursResponse {
1446 /// Routes computed for each vehicle; the i-th route corresponds to the i-th
1447 /// vehicle in the model.
1448 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
1449
1450 /// Copy of the
1451 /// [OptimizeToursRequest.label][google.maps.routeoptimization.v1.OptimizeToursRequest.label],
1452 /// if a label was specified in the request.
1453 ///
1454 /// [google.maps.routeoptimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
1455 pub request_label: std::string::String,
1456
1457 /// The list of all shipments skipped.
1458 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
1459
1460 /// List of all the validation errors that we were able to detect
1461 /// independently. See the "MULTIPLE ERRORS" explanation for the
1462 /// [OptimizeToursValidationError][google.maps.routeoptimization.v1.OptimizeToursValidationError]
1463 /// message. Instead of errors, this will include warnings in the case
1464 /// `solving_mode` is `DEFAULT_SOLVE`.
1465 ///
1466 /// [google.maps.routeoptimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
1467 pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
1468
1469 /// In some cases we modify the incoming request before solving it, i.e. adding
1470 /// costs. If solving_mode == TRANSFORM_AND_RETURN_REQUEST, the
1471 /// modified request is returned here.
1472 ///
1473 /// Experimental: See
1474 /// <https://developers.google.com/maps/tt/route-optimization/experimental/objectives/make-request>
1475 /// for more details.
1476 pub processed_request: std::option::Option<crate::model::OptimizeToursRequest>,
1477
1478 /// Duration, distance and usage metrics for this solution.
1479 pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
1480
1481 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1482}
1483
1484impl OptimizeToursResponse {
1485 /// Creates a new default instance.
1486 pub fn new() -> Self {
1487 std::default::Default::default()
1488 }
1489
1490 /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
1491 ///
1492 /// # Example
1493 /// ```ignore,no_run
1494 /// # use google_maps_routeoptimization_v1::model::OptimizeToursResponse;
1495 /// use google_maps_routeoptimization_v1::model::ShipmentRoute;
1496 /// let x = OptimizeToursResponse::new()
1497 /// .set_routes([
1498 /// ShipmentRoute::default()/* use setters */,
1499 /// ShipmentRoute::default()/* use (different) setters */,
1500 /// ]);
1501 /// ```
1502 pub fn set_routes<T, V>(mut self, v: T) -> Self
1503 where
1504 T: std::iter::IntoIterator<Item = V>,
1505 V: std::convert::Into<crate::model::ShipmentRoute>,
1506 {
1507 use std::iter::Iterator;
1508 self.routes = v.into_iter().map(|i| i.into()).collect();
1509 self
1510 }
1511
1512 /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
1513 ///
1514 /// # Example
1515 /// ```ignore,no_run
1516 /// # use google_maps_routeoptimization_v1::model::OptimizeToursResponse;
1517 /// let x = OptimizeToursResponse::new().set_request_label("example");
1518 /// ```
1519 pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1520 self.request_label = v.into();
1521 self
1522 }
1523
1524 /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
1525 ///
1526 /// # Example
1527 /// ```ignore,no_run
1528 /// # use google_maps_routeoptimization_v1::model::OptimizeToursResponse;
1529 /// use google_maps_routeoptimization_v1::model::SkippedShipment;
1530 /// let x = OptimizeToursResponse::new()
1531 /// .set_skipped_shipments([
1532 /// SkippedShipment::default()/* use setters */,
1533 /// SkippedShipment::default()/* use (different) setters */,
1534 /// ]);
1535 /// ```
1536 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
1537 where
1538 T: std::iter::IntoIterator<Item = V>,
1539 V: std::convert::Into<crate::model::SkippedShipment>,
1540 {
1541 use std::iter::Iterator;
1542 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
1543 self
1544 }
1545
1546 /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
1547 ///
1548 /// # Example
1549 /// ```ignore,no_run
1550 /// # use google_maps_routeoptimization_v1::model::OptimizeToursResponse;
1551 /// use google_maps_routeoptimization_v1::model::OptimizeToursValidationError;
1552 /// let x = OptimizeToursResponse::new()
1553 /// .set_validation_errors([
1554 /// OptimizeToursValidationError::default()/* use setters */,
1555 /// OptimizeToursValidationError::default()/* use (different) setters */,
1556 /// ]);
1557 /// ```
1558 pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
1559 where
1560 T: std::iter::IntoIterator<Item = V>,
1561 V: std::convert::Into<crate::model::OptimizeToursValidationError>,
1562 {
1563 use std::iter::Iterator;
1564 self.validation_errors = v.into_iter().map(|i| i.into()).collect();
1565 self
1566 }
1567
1568 /// Sets the value of [processed_request][crate::model::OptimizeToursResponse::processed_request].
1569 ///
1570 /// # Example
1571 /// ```ignore,no_run
1572 /// # use google_maps_routeoptimization_v1::model::OptimizeToursResponse;
1573 /// use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1574 /// let x = OptimizeToursResponse::new().set_processed_request(OptimizeToursRequest::default()/* use setters */);
1575 /// ```
1576 pub fn set_processed_request<T>(mut self, v: T) -> Self
1577 where
1578 T: std::convert::Into<crate::model::OptimizeToursRequest>,
1579 {
1580 self.processed_request = std::option::Option::Some(v.into());
1581 self
1582 }
1583
1584 /// Sets or clears the value of [processed_request][crate::model::OptimizeToursResponse::processed_request].
1585 ///
1586 /// # Example
1587 /// ```ignore,no_run
1588 /// # use google_maps_routeoptimization_v1::model::OptimizeToursResponse;
1589 /// use google_maps_routeoptimization_v1::model::OptimizeToursRequest;
1590 /// let x = OptimizeToursResponse::new().set_or_clear_processed_request(Some(OptimizeToursRequest::default()/* use setters */));
1591 /// let x = OptimizeToursResponse::new().set_or_clear_processed_request(None::<OptimizeToursRequest>);
1592 /// ```
1593 pub fn set_or_clear_processed_request<T>(mut self, v: std::option::Option<T>) -> Self
1594 where
1595 T: std::convert::Into<crate::model::OptimizeToursRequest>,
1596 {
1597 self.processed_request = v.map(|x| x.into());
1598 self
1599 }
1600
1601 /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1602 ///
1603 /// # Example
1604 /// ```ignore,no_run
1605 /// # use google_maps_routeoptimization_v1::model::OptimizeToursResponse;
1606 /// use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1607 /// let x = OptimizeToursResponse::new().set_metrics(Metrics::default()/* use setters */);
1608 /// ```
1609 pub fn set_metrics<T>(mut self, v: T) -> Self
1610 where
1611 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1612 {
1613 self.metrics = std::option::Option::Some(v.into());
1614 self
1615 }
1616
1617 /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1618 ///
1619 /// # Example
1620 /// ```ignore,no_run
1621 /// # use google_maps_routeoptimization_v1::model::OptimizeToursResponse;
1622 /// use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1623 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(Some(Metrics::default()/* use setters */));
1624 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(None::<Metrics>);
1625 /// ```
1626 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1627 where
1628 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1629 {
1630 self.metrics = v.map(|x| x.into());
1631 self
1632 }
1633}
1634
1635impl wkt::message::Message for OptimizeToursResponse {
1636 fn typename() -> &'static str {
1637 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursResponse"
1638 }
1639}
1640
1641/// Defines additional types related to [OptimizeToursResponse].
1642pub mod optimize_tours_response {
1643 #[allow(unused_imports)]
1644 use super::*;
1645
1646 /// Overall metrics, aggregated over all routes.
1647 #[derive(Clone, Default, PartialEq)]
1648 #[non_exhaustive]
1649 pub struct Metrics {
1650 /// Aggregated over the routes. Each metric is the sum (or max, for loads)
1651 /// over all
1652 /// [ShipmentRoute.metrics][google.maps.routeoptimization.v1.ShipmentRoute.metrics]
1653 /// fields of the same name.
1654 ///
1655 /// [google.maps.routeoptimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
1656 pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
1657
1658 /// Number of mandatory shipments skipped.
1659 pub skipped_mandatory_shipment_count: i32,
1660
1661 /// Number of vehicles used. Note: if a vehicle route is empty and
1662 /// [Vehicle.used_if_route_is_empty][google.maps.routeoptimization.v1.Vehicle.used_if_route_is_empty]
1663 /// is true, the vehicle is considered used.
1664 ///
1665 /// [google.maps.routeoptimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
1666 pub used_vehicle_count: i32,
1667
1668 /// The earliest start time for a used vehicle, computed as the minimum over
1669 /// all used vehicles of
1670 /// [ShipmentRoute.vehicle_start_time][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_start_time].
1671 ///
1672 /// [google.maps.routeoptimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
1673 pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
1674
1675 /// The latest end time for a used vehicle, computed as the maximum over all
1676 /// used vehicles of
1677 /// [ShipmentRoute.vehicle_end_time][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_end_time].
1678 ///
1679 /// [google.maps.routeoptimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
1680 pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
1681
1682 /// Cost of the solution, broken down by cost-related request fields.
1683 /// The keys are proto paths, relative to the input OptimizeToursRequest,
1684 /// e.g. "model.shipments.pickups.cost", and the values are the total cost
1685 /// generated by the corresponding cost field, aggregated over the whole
1686 /// solution. In other words, costs["model.shipments.pickups.cost"] is the
1687 /// sum of all pickup costs over the solution. All costs defined in the model
1688 /// are reported in detail here with the exception of costs related to
1689 /// TransitionAttributes that are only reported in an aggregated way as of
1690 /// 2022/01.
1691 pub costs: std::collections::HashMap<std::string::String, f64>,
1692
1693 /// Total cost of the solution. The sum of all values in the costs map.
1694 pub total_cost: f64,
1695
1696 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1697 }
1698
1699 impl Metrics {
1700 /// Creates a new default instance.
1701 pub fn new() -> Self {
1702 std::default::Default::default()
1703 }
1704
1705 /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1706 ///
1707 /// # Example
1708 /// ```ignore,no_run
1709 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1710 /// use google_maps_routeoptimization_v1::model::AggregatedMetrics;
1711 /// let x = Metrics::new().set_aggregated_route_metrics(AggregatedMetrics::default()/* use setters */);
1712 /// ```
1713 pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
1714 where
1715 T: std::convert::Into<crate::model::AggregatedMetrics>,
1716 {
1717 self.aggregated_route_metrics = std::option::Option::Some(v.into());
1718 self
1719 }
1720
1721 /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1722 ///
1723 /// # Example
1724 /// ```ignore,no_run
1725 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1726 /// use google_maps_routeoptimization_v1::model::AggregatedMetrics;
1727 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(Some(AggregatedMetrics::default()/* use setters */));
1728 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(None::<AggregatedMetrics>);
1729 /// ```
1730 pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1731 where
1732 T: std::convert::Into<crate::model::AggregatedMetrics>,
1733 {
1734 self.aggregated_route_metrics = v.map(|x| x.into());
1735 self
1736 }
1737
1738 /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
1739 ///
1740 /// # Example
1741 /// ```ignore,no_run
1742 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1743 /// let x = Metrics::new().set_skipped_mandatory_shipment_count(42);
1744 /// ```
1745 pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
1746 mut self,
1747 v: T,
1748 ) -> Self {
1749 self.skipped_mandatory_shipment_count = v.into();
1750 self
1751 }
1752
1753 /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
1754 ///
1755 /// # Example
1756 /// ```ignore,no_run
1757 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1758 /// let x = Metrics::new().set_used_vehicle_count(42);
1759 /// ```
1760 pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1761 self.used_vehicle_count = v.into();
1762 self
1763 }
1764
1765 /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1766 ///
1767 /// # Example
1768 /// ```ignore,no_run
1769 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1770 /// use wkt::Timestamp;
1771 /// let x = Metrics::new().set_earliest_vehicle_start_time(Timestamp::default()/* use setters */);
1772 /// ```
1773 pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
1774 where
1775 T: std::convert::Into<wkt::Timestamp>,
1776 {
1777 self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
1778 self
1779 }
1780
1781 /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1782 ///
1783 /// # Example
1784 /// ```ignore,no_run
1785 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1786 /// use wkt::Timestamp;
1787 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(Some(Timestamp::default()/* use setters */));
1788 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(None::<Timestamp>);
1789 /// ```
1790 pub fn set_or_clear_earliest_vehicle_start_time<T>(
1791 mut self,
1792 v: std::option::Option<T>,
1793 ) -> Self
1794 where
1795 T: std::convert::Into<wkt::Timestamp>,
1796 {
1797 self.earliest_vehicle_start_time = v.map(|x| x.into());
1798 self
1799 }
1800
1801 /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1802 ///
1803 /// # Example
1804 /// ```ignore,no_run
1805 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1806 /// use wkt::Timestamp;
1807 /// let x = Metrics::new().set_latest_vehicle_end_time(Timestamp::default()/* use setters */);
1808 /// ```
1809 pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
1810 where
1811 T: std::convert::Into<wkt::Timestamp>,
1812 {
1813 self.latest_vehicle_end_time = std::option::Option::Some(v.into());
1814 self
1815 }
1816
1817 /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1818 ///
1819 /// # Example
1820 /// ```ignore,no_run
1821 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1822 /// use wkt::Timestamp;
1823 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(Some(Timestamp::default()/* use setters */));
1824 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(None::<Timestamp>);
1825 /// ```
1826 pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1827 where
1828 T: std::convert::Into<wkt::Timestamp>,
1829 {
1830 self.latest_vehicle_end_time = v.map(|x| x.into());
1831 self
1832 }
1833
1834 /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
1835 ///
1836 /// # Example
1837 /// ```ignore,no_run
1838 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1839 /// let x = Metrics::new().set_costs([
1840 /// ("key0", 123.5),
1841 /// ("key1", 456.5),
1842 /// ]);
1843 /// ```
1844 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
1845 where
1846 T: std::iter::IntoIterator<Item = (K, V)>,
1847 K: std::convert::Into<std::string::String>,
1848 V: std::convert::Into<f64>,
1849 {
1850 use std::iter::Iterator;
1851 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1852 self
1853 }
1854
1855 /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
1856 ///
1857 /// # Example
1858 /// ```ignore,no_run
1859 /// # use google_maps_routeoptimization_v1::model::optimize_tours_response::Metrics;
1860 /// let x = Metrics::new().set_total_cost(42.0);
1861 /// ```
1862 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1863 self.total_cost = v.into();
1864 self
1865 }
1866 }
1867
1868 impl wkt::message::Message for Metrics {
1869 fn typename() -> &'static str {
1870 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursResponse.Metrics"
1871 }
1872 }
1873}
1874
1875/// A shipment model contains a set of shipments which must be performed by a
1876/// set of vehicles, while minimizing the overall cost, which is the sum of:
1877///
1878/// * the cost of routing the vehicles (sum of cost per total time, cost per
1879/// travel time, and fixed cost over all vehicles).
1880/// * the unperformed shipment penalties.
1881/// * the cost of the global duration of the shipments
1882#[derive(Clone, Default, PartialEq)]
1883#[non_exhaustive]
1884pub struct ShipmentModel {
1885 /// Set of shipments which must be performed in the model.
1886 pub shipments: std::vec::Vec<crate::model::Shipment>,
1887
1888 /// Set of vehicles which can be used to perform visits.
1889 pub vehicles: std::vec::Vec<crate::model::Vehicle>,
1890
1891 /// The set of objectives for this model, that we will transform into costs.
1892 /// If not empty, the input model has to be costless.
1893 /// To obtain the modified request, please use `solving_mode` =
1894 /// TRANSFORM_AND_RETURN_REQUEST. Note that the request will not
1895 /// be solved in this case. See corresponding documentation.
1896 ///
1897 /// Experimental: See
1898 /// <https://developers.google.com/maps/tt/route-optimization/experimental/objectives/make-request>
1899 /// for more details.
1900 pub objectives: std::vec::Vec<crate::model::shipment_model::Objective>,
1901
1902 /// Constrains the maximum number of active vehicles. A vehicle is active if
1903 /// its route performs at least one shipment. This can be used to limit the
1904 /// number of routes in the case where there are fewer drivers than
1905 /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
1906 /// will then select the best subset of vehicles to use.
1907 /// Must be strictly positive.
1908 pub max_active_vehicles: std::option::Option<i32>,
1909
1910 /// Global start and end time of the model: no times outside of this range
1911 /// can be considered valid.
1912 ///
1913 /// The model's time span must be less than a year, i.e. the `global_end_time`
1914 /// and the `global_start_time` must be within 31536000 seconds of each other.
1915 ///
1916 /// When using `cost_per_*hour` fields, you might want to set this window to a
1917 /// smaller interval to increase performance (eg. if you model a single day,
1918 /// you should set the global time limits to that day).
1919 /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
1920 /// as default.
1921 pub global_start_time: std::option::Option<wkt::Timestamp>,
1922
1923 /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
1924 /// is used as default.
1925 pub global_end_time: std::option::Option<wkt::Timestamp>,
1926
1927 /// The "global duration" of the overall plan is the difference between the
1928 /// earliest effective start time and the latest effective end time of
1929 /// all vehicles. Users can assign a cost per hour to that quantity to try
1930 /// and optimize for earliest job completion, for example. This cost must be in
1931 /// the same unit as
1932 /// [Shipment.penalty_cost][google.maps.routeoptimization.v1.Shipment.penalty_cost].
1933 ///
1934 /// [google.maps.routeoptimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
1935 pub global_duration_cost_per_hour: f64,
1936
1937 /// Specifies duration and distance matrices used in the model. If this field
1938 /// is empty, Google Maps or geodesic distances will be used instead, depending
1939 /// on the value of the `use_geodesic_distances` field. If it is not empty,
1940 /// `use_geodesic_distances` cannot be true and neither
1941 /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
1942 /// can be empty.
1943 ///
1944 /// Usage examples:
1945 ///
1946 /// * There are two locations: locA and locB.
1947 /// * 1 vehicle starting its route at locA and ending it at locA.
1948 /// * 1 pickup visit request at locB.
1949 ///
1950 /// ```norust
1951 /// model {
1952 /// vehicles { start_tags: "locA" end_tags: "locA" }
1953 /// shipments { pickups { tags: "locB" } }
1954 /// duration_distance_matrix_src_tags: "locA"
1955 /// duration_distance_matrix_src_tags: "locB"
1956 /// duration_distance_matrix_dst_tags: "locA"
1957 /// duration_distance_matrix_dst_tags: "locB"
1958 /// duration_distance_matrices {
1959 /// rows { # from: locA
1960 /// durations { seconds: 0 } meters: 0 # to: locA
1961 /// durations { seconds: 100 } meters: 1000 # to: locB
1962 /// }
1963 /// rows { # from: locB
1964 /// durations { seconds: 102 } meters: 990 # to: locA
1965 /// durations { seconds: 0 } meters: 0 # to: locB
1966 /// }
1967 /// }
1968 /// }
1969 /// ```
1970 ///
1971 /// * There are three locations: locA, locB and locC.
1972 /// * 1 vehicle starting its route at locA and ending it at locB, using
1973 /// matrix "fast".
1974 /// * 1 vehicle starting its route at locB and ending it at locB, using
1975 /// matrix "slow".
1976 /// * 1 vehicle starting its route at locB and ending it at locB, using
1977 /// matrix "fast".
1978 /// * 1 pickup visit request at locC.
1979 ///
1980 /// ```norust
1981 /// model {
1982 /// vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
1983 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
1984 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
1985 /// shipments { pickups { tags: "locC" } }
1986 /// duration_distance_matrix_src_tags: "locA"
1987 /// duration_distance_matrix_src_tags: "locB"
1988 /// duration_distance_matrix_src_tags: "locC"
1989 /// duration_distance_matrix_dst_tags: "locB"
1990 /// duration_distance_matrix_dst_tags: "locC"
1991 /// duration_distance_matrices {
1992 /// vehicle_start_tag: "fast"
1993 /// rows { # from: locA
1994 /// durations { seconds: 1000 } meters: 2000 # to: locB
1995 /// durations { seconds: 600 } meters: 1000 # to: locC
1996 /// }
1997 /// rows { # from: locB
1998 /// durations { seconds: 0 } meters: 0 # to: locB
1999 /// durations { seconds: 700 } meters: 1200 # to: locC
2000 /// }
2001 /// rows { # from: locC
2002 /// durations { seconds: 702 } meters: 1190 # to: locB
2003 /// durations { seconds: 0 } meters: 0 # to: locC
2004 /// }
2005 /// }
2006 /// duration_distance_matrices {
2007 /// vehicle_start_tag: "slow"
2008 /// rows { # from: locA
2009 /// durations { seconds: 1800 } meters: 2001 # to: locB
2010 /// durations { seconds: 900 } meters: 1002 # to: locC
2011 /// }
2012 /// rows { # from: locB
2013 /// durations { seconds: 0 } meters: 0 # to: locB
2014 /// durations { seconds: 1000 } meters: 1202 # to: locC
2015 /// }
2016 /// rows { # from: locC
2017 /// durations { seconds: 1001 } meters: 1195 # to: locB
2018 /// durations { seconds: 0 } meters: 0 # to: locC
2019 /// }
2020 /// }
2021 /// }
2022 /// ```
2023 pub duration_distance_matrices:
2024 std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
2025
2026 /// Tags defining the sources of the duration and distance matrices;
2027 /// `duration_distance_matrices(i).rows(j)` defines durations and distances
2028 /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
2029 /// in matrix i.
2030 ///
2031 /// Tags correspond to
2032 /// [VisitRequest.tags][google.maps.routeoptimization.v1.Shipment.VisitRequest.tags]
2033 /// or
2034 /// [Vehicle.start_tags][google.maps.routeoptimization.v1.Vehicle.start_tags].
2035 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2036 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2037 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2038 /// the same. All tags must be different and cannot be empty strings. If this
2039 /// field is not empty, then `duration_distance_matrices` must not be empty.
2040 ///
2041 /// [google.maps.routeoptimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2042 /// [google.maps.routeoptimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2043 pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
2044
2045 /// Tags defining the destinations of the duration and distance matrices;
2046 /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
2047 /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
2048 /// (resp. the distance) of the travel from visits with tag
2049 /// `duration_distance_matrix_src_tags(j)` to visits with tag
2050 /// `duration_distance_matrix_dst_tags(k)` in matrix i.
2051 ///
2052 /// Tags correspond to
2053 /// [VisitRequest.tags][google.maps.routeoptimization.v1.Shipment.VisitRequest.tags]
2054 /// or
2055 /// [Vehicle.start_tags][google.maps.routeoptimization.v1.Vehicle.start_tags].
2056 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2057 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2058 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2059 /// the same. All tags must be different and cannot be empty strings. If this
2060 /// field is not empty, then `duration_distance_matrices` must not be empty.
2061 ///
2062 /// [google.maps.routeoptimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2063 /// [google.maps.routeoptimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2064 pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
2065
2066 /// Transition attributes added to the model.
2067 pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
2068
2069 /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
2070 pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
2071
2072 /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
2073 pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
2074
2075 /// Set of precedence rules which must be enforced in the model.
2076 ///
2077 /// *IMPORTANT*: Use of precedence rules limits the size of problem that can be
2078 /// optimized. Requests using precedence rules that include many shipments may
2079 /// be rejected.
2080 pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
2081
2082 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2083}
2084
2085impl ShipmentModel {
2086 /// Creates a new default instance.
2087 pub fn new() -> Self {
2088 std::default::Default::default()
2089 }
2090
2091 /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
2092 ///
2093 /// # Example
2094 /// ```ignore,no_run
2095 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2096 /// use google_maps_routeoptimization_v1::model::Shipment;
2097 /// let x = ShipmentModel::new()
2098 /// .set_shipments([
2099 /// Shipment::default()/* use setters */,
2100 /// Shipment::default()/* use (different) setters */,
2101 /// ]);
2102 /// ```
2103 pub fn set_shipments<T, V>(mut self, v: T) -> Self
2104 where
2105 T: std::iter::IntoIterator<Item = V>,
2106 V: std::convert::Into<crate::model::Shipment>,
2107 {
2108 use std::iter::Iterator;
2109 self.shipments = v.into_iter().map(|i| i.into()).collect();
2110 self
2111 }
2112
2113 /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
2114 ///
2115 /// # Example
2116 /// ```ignore,no_run
2117 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2118 /// use google_maps_routeoptimization_v1::model::Vehicle;
2119 /// let x = ShipmentModel::new()
2120 /// .set_vehicles([
2121 /// Vehicle::default()/* use setters */,
2122 /// Vehicle::default()/* use (different) setters */,
2123 /// ]);
2124 /// ```
2125 pub fn set_vehicles<T, V>(mut self, v: T) -> Self
2126 where
2127 T: std::iter::IntoIterator<Item = V>,
2128 V: std::convert::Into<crate::model::Vehicle>,
2129 {
2130 use std::iter::Iterator;
2131 self.vehicles = v.into_iter().map(|i| i.into()).collect();
2132 self
2133 }
2134
2135 /// Sets the value of [objectives][crate::model::ShipmentModel::objectives].
2136 ///
2137 /// # Example
2138 /// ```ignore,no_run
2139 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2140 /// use google_maps_routeoptimization_v1::model::shipment_model::Objective;
2141 /// let x = ShipmentModel::new()
2142 /// .set_objectives([
2143 /// Objective::default()/* use setters */,
2144 /// Objective::default()/* use (different) setters */,
2145 /// ]);
2146 /// ```
2147 pub fn set_objectives<T, V>(mut self, v: T) -> Self
2148 where
2149 T: std::iter::IntoIterator<Item = V>,
2150 V: std::convert::Into<crate::model::shipment_model::Objective>,
2151 {
2152 use std::iter::Iterator;
2153 self.objectives = v.into_iter().map(|i| i.into()).collect();
2154 self
2155 }
2156
2157 /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2158 ///
2159 /// # Example
2160 /// ```ignore,no_run
2161 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2162 /// let x = ShipmentModel::new().set_max_active_vehicles(42);
2163 /// ```
2164 pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
2165 where
2166 T: std::convert::Into<i32>,
2167 {
2168 self.max_active_vehicles = std::option::Option::Some(v.into());
2169 self
2170 }
2171
2172 /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2173 ///
2174 /// # Example
2175 /// ```ignore,no_run
2176 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2177 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(Some(42));
2178 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(None::<i32>);
2179 /// ```
2180 pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
2181 where
2182 T: std::convert::Into<i32>,
2183 {
2184 self.max_active_vehicles = v.map(|x| x.into());
2185 self
2186 }
2187
2188 /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2189 ///
2190 /// # Example
2191 /// ```ignore,no_run
2192 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2193 /// use wkt::Timestamp;
2194 /// let x = ShipmentModel::new().set_global_start_time(Timestamp::default()/* use setters */);
2195 /// ```
2196 pub fn set_global_start_time<T>(mut self, v: T) -> Self
2197 where
2198 T: std::convert::Into<wkt::Timestamp>,
2199 {
2200 self.global_start_time = std::option::Option::Some(v.into());
2201 self
2202 }
2203
2204 /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2205 ///
2206 /// # Example
2207 /// ```ignore,no_run
2208 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2209 /// use wkt::Timestamp;
2210 /// let x = ShipmentModel::new().set_or_clear_global_start_time(Some(Timestamp::default()/* use setters */));
2211 /// let x = ShipmentModel::new().set_or_clear_global_start_time(None::<Timestamp>);
2212 /// ```
2213 pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2214 where
2215 T: std::convert::Into<wkt::Timestamp>,
2216 {
2217 self.global_start_time = v.map(|x| x.into());
2218 self
2219 }
2220
2221 /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2222 ///
2223 /// # Example
2224 /// ```ignore,no_run
2225 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2226 /// use wkt::Timestamp;
2227 /// let x = ShipmentModel::new().set_global_end_time(Timestamp::default()/* use setters */);
2228 /// ```
2229 pub fn set_global_end_time<T>(mut self, v: T) -> Self
2230 where
2231 T: std::convert::Into<wkt::Timestamp>,
2232 {
2233 self.global_end_time = std::option::Option::Some(v.into());
2234 self
2235 }
2236
2237 /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2238 ///
2239 /// # Example
2240 /// ```ignore,no_run
2241 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2242 /// use wkt::Timestamp;
2243 /// let x = ShipmentModel::new().set_or_clear_global_end_time(Some(Timestamp::default()/* use setters */));
2244 /// let x = ShipmentModel::new().set_or_clear_global_end_time(None::<Timestamp>);
2245 /// ```
2246 pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2247 where
2248 T: std::convert::Into<wkt::Timestamp>,
2249 {
2250 self.global_end_time = v.map(|x| x.into());
2251 self
2252 }
2253
2254 /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
2255 ///
2256 /// # Example
2257 /// ```ignore,no_run
2258 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2259 /// let x = ShipmentModel::new().set_global_duration_cost_per_hour(42.0);
2260 /// ```
2261 pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2262 self.global_duration_cost_per_hour = v.into();
2263 self
2264 }
2265
2266 /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
2267 ///
2268 /// # Example
2269 /// ```ignore,no_run
2270 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2271 /// use google_maps_routeoptimization_v1::model::shipment_model::DurationDistanceMatrix;
2272 /// let x = ShipmentModel::new()
2273 /// .set_duration_distance_matrices([
2274 /// DurationDistanceMatrix::default()/* use setters */,
2275 /// DurationDistanceMatrix::default()/* use (different) setters */,
2276 /// ]);
2277 /// ```
2278 pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
2279 where
2280 T: std::iter::IntoIterator<Item = V>,
2281 V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
2282 {
2283 use std::iter::Iterator;
2284 self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
2285 self
2286 }
2287
2288 /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
2289 ///
2290 /// # Example
2291 /// ```ignore,no_run
2292 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2293 /// let x = ShipmentModel::new().set_duration_distance_matrix_src_tags(["a", "b", "c"]);
2294 /// ```
2295 pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
2296 where
2297 T: std::iter::IntoIterator<Item = V>,
2298 V: std::convert::Into<std::string::String>,
2299 {
2300 use std::iter::Iterator;
2301 self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
2302 self
2303 }
2304
2305 /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
2306 ///
2307 /// # Example
2308 /// ```ignore,no_run
2309 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2310 /// let x = ShipmentModel::new().set_duration_distance_matrix_dst_tags(["a", "b", "c"]);
2311 /// ```
2312 pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
2313 where
2314 T: std::iter::IntoIterator<Item = V>,
2315 V: std::convert::Into<std::string::String>,
2316 {
2317 use std::iter::Iterator;
2318 self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
2319 self
2320 }
2321
2322 /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
2323 ///
2324 /// # Example
2325 /// ```ignore,no_run
2326 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2327 /// use google_maps_routeoptimization_v1::model::TransitionAttributes;
2328 /// let x = ShipmentModel::new()
2329 /// .set_transition_attributes([
2330 /// TransitionAttributes::default()/* use setters */,
2331 /// TransitionAttributes::default()/* use (different) setters */,
2332 /// ]);
2333 /// ```
2334 pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
2335 where
2336 T: std::iter::IntoIterator<Item = V>,
2337 V: std::convert::Into<crate::model::TransitionAttributes>,
2338 {
2339 use std::iter::Iterator;
2340 self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
2341 self
2342 }
2343
2344 /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
2345 ///
2346 /// # Example
2347 /// ```ignore,no_run
2348 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2349 /// use google_maps_routeoptimization_v1::model::ShipmentTypeIncompatibility;
2350 /// let x = ShipmentModel::new()
2351 /// .set_shipment_type_incompatibilities([
2352 /// ShipmentTypeIncompatibility::default()/* use setters */,
2353 /// ShipmentTypeIncompatibility::default()/* use (different) setters */,
2354 /// ]);
2355 /// ```
2356 pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
2357 where
2358 T: std::iter::IntoIterator<Item = V>,
2359 V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
2360 {
2361 use std::iter::Iterator;
2362 self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
2363 self
2364 }
2365
2366 /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
2367 ///
2368 /// # Example
2369 /// ```ignore,no_run
2370 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2371 /// use google_maps_routeoptimization_v1::model::ShipmentTypeRequirement;
2372 /// let x = ShipmentModel::new()
2373 /// .set_shipment_type_requirements([
2374 /// ShipmentTypeRequirement::default()/* use setters */,
2375 /// ShipmentTypeRequirement::default()/* use (different) setters */,
2376 /// ]);
2377 /// ```
2378 pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
2379 where
2380 T: std::iter::IntoIterator<Item = V>,
2381 V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
2382 {
2383 use std::iter::Iterator;
2384 self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
2385 self
2386 }
2387
2388 /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
2389 ///
2390 /// # Example
2391 /// ```ignore,no_run
2392 /// # use google_maps_routeoptimization_v1::model::ShipmentModel;
2393 /// use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2394 /// let x = ShipmentModel::new()
2395 /// .set_precedence_rules([
2396 /// PrecedenceRule::default()/* use setters */,
2397 /// PrecedenceRule::default()/* use (different) setters */,
2398 /// ]);
2399 /// ```
2400 pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
2401 where
2402 T: std::iter::IntoIterator<Item = V>,
2403 V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
2404 {
2405 use std::iter::Iterator;
2406 self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
2407 self
2408 }
2409}
2410
2411impl wkt::message::Message for ShipmentModel {
2412 fn typename() -> &'static str {
2413 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentModel"
2414 }
2415}
2416
2417/// Defines additional types related to [ShipmentModel].
2418pub mod shipment_model {
2419 #[allow(unused_imports)]
2420 use super::*;
2421
2422 /// Objectives replace the cost model completely, and are therefore
2423 /// incompatible with pre-existing costs. Each objective maps to a number of
2424 /// pre-defined costs for, e.g., vehicles, shipments or transition attributes.
2425 ///
2426 /// Experimental: See
2427 /// <https://developers.google.com/maps/tt/route-optimization/experimental/objectives/make-request>
2428 /// for more details.
2429 #[derive(Clone, Default, PartialEq)]
2430 #[non_exhaustive]
2431 pub struct Objective {
2432 /// The type of the objective.
2433 pub r#type: std::option::Option<crate::model::shipment_model::objective::Type>,
2434
2435 /// How much this objective should count relatively to the others. This can
2436 /// be any non-negative number, weights do not have to sum to 1. Weights
2437 /// default to 1.0.
2438 pub weight: std::option::Option<f64>,
2439
2440 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2441 }
2442
2443 impl Objective {
2444 /// Creates a new default instance.
2445 pub fn new() -> Self {
2446 std::default::Default::default()
2447 }
2448
2449 /// Sets the value of [r#type][crate::model::shipment_model::Objective::type].
2450 ///
2451 /// # Example
2452 /// ```ignore,no_run
2453 /// # use google_maps_routeoptimization_v1::model::shipment_model::Objective;
2454 /// use google_maps_routeoptimization_v1::model::shipment_model::objective::Type;
2455 /// let x0 = Objective::new().set_type(Type::MinDistance);
2456 /// let x1 = Objective::new().set_type(Type::MinWorkingTime);
2457 /// let x2 = Objective::new().set_type(Type::MinTravelTime);
2458 /// ```
2459 pub fn set_type<T>(mut self, v: T) -> Self
2460 where
2461 T: std::convert::Into<crate::model::shipment_model::objective::Type>,
2462 {
2463 self.r#type = std::option::Option::Some(v.into());
2464 self
2465 }
2466
2467 /// Sets or clears the value of [r#type][crate::model::shipment_model::Objective::type].
2468 ///
2469 /// # Example
2470 /// ```ignore,no_run
2471 /// # use google_maps_routeoptimization_v1::model::shipment_model::Objective;
2472 /// use google_maps_routeoptimization_v1::model::shipment_model::objective::Type;
2473 /// let x0 = Objective::new().set_or_clear_type(Some(Type::MinDistance));
2474 /// let x1 = Objective::new().set_or_clear_type(Some(Type::MinWorkingTime));
2475 /// let x2 = Objective::new().set_or_clear_type(Some(Type::MinTravelTime));
2476 /// let x_none = Objective::new().set_or_clear_type(None::<Type>);
2477 /// ```
2478 pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
2479 where
2480 T: std::convert::Into<crate::model::shipment_model::objective::Type>,
2481 {
2482 self.r#type = v.map(|x| x.into());
2483 self
2484 }
2485
2486 /// Sets the value of [weight][crate::model::shipment_model::Objective::weight].
2487 ///
2488 /// # Example
2489 /// ```ignore,no_run
2490 /// # use google_maps_routeoptimization_v1::model::shipment_model::Objective;
2491 /// let x = Objective::new().set_weight(42.0);
2492 /// ```
2493 pub fn set_weight<T>(mut self, v: T) -> Self
2494 where
2495 T: std::convert::Into<f64>,
2496 {
2497 self.weight = std::option::Option::Some(v.into());
2498 self
2499 }
2500
2501 /// Sets or clears the value of [weight][crate::model::shipment_model::Objective::weight].
2502 ///
2503 /// # Example
2504 /// ```ignore,no_run
2505 /// # use google_maps_routeoptimization_v1::model::shipment_model::Objective;
2506 /// let x = Objective::new().set_or_clear_weight(Some(42.0));
2507 /// let x = Objective::new().set_or_clear_weight(None::<f32>);
2508 /// ```
2509 pub fn set_or_clear_weight<T>(mut self, v: std::option::Option<T>) -> Self
2510 where
2511 T: std::convert::Into<f64>,
2512 {
2513 self.weight = v.map(|x| x.into());
2514 self
2515 }
2516 }
2517
2518 impl wkt::message::Message for Objective {
2519 fn typename() -> &'static str {
2520 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentModel.Objective"
2521 }
2522 }
2523
2524 /// Defines additional types related to [Objective].
2525 pub mod objective {
2526 #[allow(unused_imports)]
2527 use super::*;
2528
2529 /// The objective type that will be mapped to a set of costs.
2530 ///
2531 /// # Working with unknown values
2532 ///
2533 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2534 /// additional enum variants at any time. Adding new variants is not considered
2535 /// a breaking change. Applications should write their code in anticipation of:
2536 ///
2537 /// - New values appearing in future releases of the client library, **and**
2538 /// - New values received dynamically, without application changes.
2539 ///
2540 /// Please consult the [Working with enums] section in the user guide for some
2541 /// guidelines.
2542 ///
2543 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2544 #[derive(Clone, Debug, PartialEq)]
2545 #[non_exhaustive]
2546 pub enum Type {
2547 /// A default set of costs will be used, to ensure a reasonable solution.
2548 /// Note: this objective can be used on its own, but will also always be
2549 /// added with weight 1.0, as a baseline, to the objectives specified by
2550 /// the user, if it's not already present.
2551 Default,
2552 /// "MIN" objectives.
2553 /// Minimize the total distance traveled.
2554 MinDistance,
2555 /// Minimize the total working time, summed over all vehicles.
2556 MinWorkingTime,
2557 /// Same as above but focusing on travel time only.
2558 MinTravelTime,
2559 /// Minimize the number of vehicles used.
2560 MinNumVehicles,
2561 /// If set, the enum was initialized with an unknown value.
2562 ///
2563 /// Applications can examine the value using [Type::value] or
2564 /// [Type::name].
2565 UnknownValue(r#type::UnknownValue),
2566 }
2567
2568 #[doc(hidden)]
2569 pub mod r#type {
2570 #[allow(unused_imports)]
2571 use super::*;
2572 #[derive(Clone, Debug, PartialEq)]
2573 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2574 }
2575
2576 impl Type {
2577 /// Gets the enum value.
2578 ///
2579 /// Returns `None` if the enum contains an unknown value deserialized from
2580 /// the string representation of enums.
2581 pub fn value(&self) -> std::option::Option<i32> {
2582 match self {
2583 Self::Default => std::option::Option::Some(0),
2584 Self::MinDistance => std::option::Option::Some(10),
2585 Self::MinWorkingTime => std::option::Option::Some(11),
2586 Self::MinTravelTime => std::option::Option::Some(12),
2587 Self::MinNumVehicles => std::option::Option::Some(13),
2588 Self::UnknownValue(u) => u.0.value(),
2589 }
2590 }
2591
2592 /// Gets the enum value as a string.
2593 ///
2594 /// Returns `None` if the enum contains an unknown value deserialized from
2595 /// the integer representation of enums.
2596 pub fn name(&self) -> std::option::Option<&str> {
2597 match self {
2598 Self::Default => std::option::Option::Some("DEFAULT"),
2599 Self::MinDistance => std::option::Option::Some("MIN_DISTANCE"),
2600 Self::MinWorkingTime => std::option::Option::Some("MIN_WORKING_TIME"),
2601 Self::MinTravelTime => std::option::Option::Some("MIN_TRAVEL_TIME"),
2602 Self::MinNumVehicles => std::option::Option::Some("MIN_NUM_VEHICLES"),
2603 Self::UnknownValue(u) => u.0.name(),
2604 }
2605 }
2606 }
2607
2608 impl std::default::Default for Type {
2609 fn default() -> Self {
2610 use std::convert::From;
2611 Self::from(0)
2612 }
2613 }
2614
2615 impl std::fmt::Display for Type {
2616 fn fmt(
2617 &self,
2618 f: &mut std::fmt::Formatter<'_>,
2619 ) -> std::result::Result<(), std::fmt::Error> {
2620 wkt::internal::display_enum(f, self.name(), self.value())
2621 }
2622 }
2623
2624 impl std::convert::From<i32> for Type {
2625 fn from(value: i32) -> Self {
2626 match value {
2627 0 => Self::Default,
2628 10 => Self::MinDistance,
2629 11 => Self::MinWorkingTime,
2630 12 => Self::MinTravelTime,
2631 13 => Self::MinNumVehicles,
2632 _ => Self::UnknownValue(r#type::UnknownValue(
2633 wkt::internal::UnknownEnumValue::Integer(value),
2634 )),
2635 }
2636 }
2637 }
2638
2639 impl std::convert::From<&str> for Type {
2640 fn from(value: &str) -> Self {
2641 use std::string::ToString;
2642 match value {
2643 "DEFAULT" => Self::Default,
2644 "MIN_DISTANCE" => Self::MinDistance,
2645 "MIN_WORKING_TIME" => Self::MinWorkingTime,
2646 "MIN_TRAVEL_TIME" => Self::MinTravelTime,
2647 "MIN_NUM_VEHICLES" => Self::MinNumVehicles,
2648 _ => Self::UnknownValue(r#type::UnknownValue(
2649 wkt::internal::UnknownEnumValue::String(value.to_string()),
2650 )),
2651 }
2652 }
2653 }
2654
2655 impl serde::ser::Serialize for Type {
2656 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2657 where
2658 S: serde::Serializer,
2659 {
2660 match self {
2661 Self::Default => serializer.serialize_i32(0),
2662 Self::MinDistance => serializer.serialize_i32(10),
2663 Self::MinWorkingTime => serializer.serialize_i32(11),
2664 Self::MinTravelTime => serializer.serialize_i32(12),
2665 Self::MinNumVehicles => serializer.serialize_i32(13),
2666 Self::UnknownValue(u) => u.0.serialize(serializer),
2667 }
2668 }
2669 }
2670
2671 impl<'de> serde::de::Deserialize<'de> for Type {
2672 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2673 where
2674 D: serde::Deserializer<'de>,
2675 {
2676 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
2677 ".google.maps.routeoptimization.v1.ShipmentModel.Objective.Type",
2678 ))
2679 }
2680 }
2681 }
2682
2683 /// Specifies a duration and distance matrix from visit and vehicle start
2684 /// locations to visit and vehicle end locations.
2685 #[derive(Clone, Default, PartialEq)]
2686 #[non_exhaustive]
2687 pub struct DurationDistanceMatrix {
2688 /// Specifies the rows of the duration and distance matrix. It must have as
2689 /// many elements as
2690 /// [ShipmentModel.duration_distance_matrix_src_tags][google.maps.routeoptimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
2691 ///
2692 /// [google.maps.routeoptimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
2693 pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
2694
2695 /// Tag defining to which vehicles this duration and distance matrix applies.
2696 /// If empty, this applies to all vehicles, and there can only be a single
2697 /// matrix.
2698 ///
2699 /// Each vehicle start must match exactly one matrix, i.e. exactly one of
2700 /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
2701 /// (and of that matrix only).
2702 ///
2703 /// All matrices must have a different `vehicle_start_tag`.
2704 pub vehicle_start_tag: std::string::String,
2705
2706 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2707 }
2708
2709 impl DurationDistanceMatrix {
2710 /// Creates a new default instance.
2711 pub fn new() -> Self {
2712 std::default::Default::default()
2713 }
2714
2715 /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
2716 ///
2717 /// # Example
2718 /// ```ignore,no_run
2719 /// # use google_maps_routeoptimization_v1::model::shipment_model::DurationDistanceMatrix;
2720 /// use google_maps_routeoptimization_v1::model::shipment_model::duration_distance_matrix::Row;
2721 /// let x = DurationDistanceMatrix::new()
2722 /// .set_rows([
2723 /// Row::default()/* use setters */,
2724 /// Row::default()/* use (different) setters */,
2725 /// ]);
2726 /// ```
2727 pub fn set_rows<T, V>(mut self, v: T) -> Self
2728 where
2729 T: std::iter::IntoIterator<Item = V>,
2730 V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
2731 {
2732 use std::iter::Iterator;
2733 self.rows = v.into_iter().map(|i| i.into()).collect();
2734 self
2735 }
2736
2737 /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
2738 ///
2739 /// # Example
2740 /// ```ignore,no_run
2741 /// # use google_maps_routeoptimization_v1::model::shipment_model::DurationDistanceMatrix;
2742 /// let x = DurationDistanceMatrix::new().set_vehicle_start_tag("example");
2743 /// ```
2744 pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
2745 mut self,
2746 v: T,
2747 ) -> Self {
2748 self.vehicle_start_tag = v.into();
2749 self
2750 }
2751 }
2752
2753 impl wkt::message::Message for DurationDistanceMatrix {
2754 fn typename() -> &'static str {
2755 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentModel.DurationDistanceMatrix"
2756 }
2757 }
2758
2759 /// Defines additional types related to [DurationDistanceMatrix].
2760 pub mod duration_distance_matrix {
2761 #[allow(unused_imports)]
2762 use super::*;
2763
2764 /// Specifies a row of the duration and distance matrix.
2765 #[derive(Clone, Default, PartialEq)]
2766 #[non_exhaustive]
2767 pub struct Row {
2768 /// Duration values for a given row. It must have as many elements as
2769 /// [ShipmentModel.duration_distance_matrix_dst_tags][google.maps.routeoptimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
2770 ///
2771 /// [google.maps.routeoptimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
2772 pub durations: std::vec::Vec<wkt::Duration>,
2773
2774 /// Distance values for a given row. If no costs or constraints refer to
2775 /// distances in the model, this can be left empty; otherwise it must have
2776 /// as many elements as `durations`.
2777 pub meters: std::vec::Vec<f64>,
2778
2779 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2780 }
2781
2782 impl Row {
2783 /// Creates a new default instance.
2784 pub fn new() -> Self {
2785 std::default::Default::default()
2786 }
2787
2788 /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
2789 ///
2790 /// # Example
2791 /// ```ignore,no_run
2792 /// # use google_maps_routeoptimization_v1::model::shipment_model::duration_distance_matrix::Row;
2793 /// use wkt::Duration;
2794 /// let x = Row::new()
2795 /// .set_durations([
2796 /// Duration::default()/* use setters */,
2797 /// Duration::default()/* use (different) setters */,
2798 /// ]);
2799 /// ```
2800 pub fn set_durations<T, V>(mut self, v: T) -> Self
2801 where
2802 T: std::iter::IntoIterator<Item = V>,
2803 V: std::convert::Into<wkt::Duration>,
2804 {
2805 use std::iter::Iterator;
2806 self.durations = v.into_iter().map(|i| i.into()).collect();
2807 self
2808 }
2809
2810 /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
2811 ///
2812 /// # Example
2813 /// ```ignore,no_run
2814 /// # use google_maps_routeoptimization_v1::model::shipment_model::duration_distance_matrix::Row;
2815 /// let x = Row::new().set_meters([1.0, 2.0, 3.0]);
2816 /// ```
2817 pub fn set_meters<T, V>(mut self, v: T) -> Self
2818 where
2819 T: std::iter::IntoIterator<Item = V>,
2820 V: std::convert::Into<f64>,
2821 {
2822 use std::iter::Iterator;
2823 self.meters = v.into_iter().map(|i| i.into()).collect();
2824 self
2825 }
2826 }
2827
2828 impl wkt::message::Message for Row {
2829 fn typename() -> &'static str {
2830 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
2831 }
2832 }
2833 }
2834
2835 /// A precedence rule between two events (each event is the pickup or the
2836 /// delivery of a shipment): the "second" event has to start at least
2837 /// `offset_duration` after "first" has started.
2838 ///
2839 /// Several precedences can refer to the same (or related) events, e.g.,
2840 /// "pickup of B happens after delivery of A" and "pickup of C happens after
2841 /// pickup of B".
2842 ///
2843 /// Furthermore, precedences only apply when both shipments are performed and
2844 /// are otherwise ignored.
2845 #[derive(Clone, Default, PartialEq)]
2846 #[non_exhaustive]
2847 pub struct PrecedenceRule {
2848 /// Shipment index of the "first" event. This field must be specified.
2849 pub first_index: std::option::Option<i32>,
2850
2851 /// Indicates if the "first" event is a delivery.
2852 pub first_is_delivery: bool,
2853
2854 /// Shipment index of the "second" event. This field must be specified.
2855 pub second_index: std::option::Option<i32>,
2856
2857 /// Indicates if the "second" event is a delivery.
2858 pub second_is_delivery: bool,
2859
2860 /// The offset between the "first" and "second" event. It can be negative.
2861 pub offset_duration: std::option::Option<wkt::Duration>,
2862
2863 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2864 }
2865
2866 impl PrecedenceRule {
2867 /// Creates a new default instance.
2868 pub fn new() -> Self {
2869 std::default::Default::default()
2870 }
2871
2872 /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2873 ///
2874 /// # Example
2875 /// ```ignore,no_run
2876 /// # use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2877 /// let x = PrecedenceRule::new().set_first_index(42);
2878 /// ```
2879 pub fn set_first_index<T>(mut self, v: T) -> Self
2880 where
2881 T: std::convert::Into<i32>,
2882 {
2883 self.first_index = std::option::Option::Some(v.into());
2884 self
2885 }
2886
2887 /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2888 ///
2889 /// # Example
2890 /// ```ignore,no_run
2891 /// # use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2892 /// let x = PrecedenceRule::new().set_or_clear_first_index(Some(42));
2893 /// let x = PrecedenceRule::new().set_or_clear_first_index(None::<i32>);
2894 /// ```
2895 pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
2896 where
2897 T: std::convert::Into<i32>,
2898 {
2899 self.first_index = v.map(|x| x.into());
2900 self
2901 }
2902
2903 /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
2904 ///
2905 /// # Example
2906 /// ```ignore,no_run
2907 /// # use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2908 /// let x = PrecedenceRule::new().set_first_is_delivery(true);
2909 /// ```
2910 pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2911 self.first_is_delivery = v.into();
2912 self
2913 }
2914
2915 /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2916 ///
2917 /// # Example
2918 /// ```ignore,no_run
2919 /// # use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2920 /// let x = PrecedenceRule::new().set_second_index(42);
2921 /// ```
2922 pub fn set_second_index<T>(mut self, v: T) -> Self
2923 where
2924 T: std::convert::Into<i32>,
2925 {
2926 self.second_index = std::option::Option::Some(v.into());
2927 self
2928 }
2929
2930 /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2931 ///
2932 /// # Example
2933 /// ```ignore,no_run
2934 /// # use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2935 /// let x = PrecedenceRule::new().set_or_clear_second_index(Some(42));
2936 /// let x = PrecedenceRule::new().set_or_clear_second_index(None::<i32>);
2937 /// ```
2938 pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
2939 where
2940 T: std::convert::Into<i32>,
2941 {
2942 self.second_index = v.map(|x| x.into());
2943 self
2944 }
2945
2946 /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
2947 ///
2948 /// # Example
2949 /// ```ignore,no_run
2950 /// # use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2951 /// let x = PrecedenceRule::new().set_second_is_delivery(true);
2952 /// ```
2953 pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2954 self.second_is_delivery = v.into();
2955 self
2956 }
2957
2958 /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
2959 ///
2960 /// # Example
2961 /// ```ignore,no_run
2962 /// # use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2963 /// use wkt::Duration;
2964 /// let x = PrecedenceRule::new().set_offset_duration(Duration::default()/* use setters */);
2965 /// ```
2966 pub fn set_offset_duration<T>(mut self, v: T) -> Self
2967 where
2968 T: std::convert::Into<wkt::Duration>,
2969 {
2970 self.offset_duration = std::option::Option::Some(v.into());
2971 self
2972 }
2973
2974 /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
2975 ///
2976 /// # Example
2977 /// ```ignore,no_run
2978 /// # use google_maps_routeoptimization_v1::model::shipment_model::PrecedenceRule;
2979 /// use wkt::Duration;
2980 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(Some(Duration::default()/* use setters */));
2981 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(None::<Duration>);
2982 /// ```
2983 pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
2984 where
2985 T: std::convert::Into<wkt::Duration>,
2986 {
2987 self.offset_duration = v.map(|x| x.into());
2988 self
2989 }
2990 }
2991
2992 impl wkt::message::Message for PrecedenceRule {
2993 fn typename() -> &'static str {
2994 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentModel.PrecedenceRule"
2995 }
2996 }
2997}
2998
2999/// The shipment of a single item, from one of its pickups to one of its
3000/// deliveries. For the shipment to be considered as performed, a unique vehicle
3001/// must visit one of its pickup locations (and decrease its spare capacities
3002/// accordingly), then visit one of its delivery locations later on (and
3003/// therefore re-increase its spare capacities accordingly).
3004#[derive(Clone, Default, PartialEq)]
3005#[non_exhaustive]
3006pub struct Shipment {
3007 /// The user-defined display name of the shipment.
3008 /// It can be up to 63 characters long and may use UTF-8 characters.
3009 pub display_name: std::string::String,
3010
3011 /// Set of pickup alternatives associated to the shipment. If not specified,
3012 /// the vehicle only needs to visit a location corresponding to the deliveries.
3013 pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
3014
3015 /// Set of delivery alternatives associated to the shipment. If not specified,
3016 /// the vehicle only needs to visit a location corresponding to the pickups.
3017 pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
3018
3019 /// Load demands of the shipment (for example weight, volume, number of
3020 /// pallets etc). The keys in the map should be identifiers describing the type
3021 /// of the corresponding load, ideally also including the units.
3022 /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
3023 /// If a given key does not appear in the map, the corresponding load is
3024 /// considered as null.
3025 pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3026
3027 /// If the shipment is not completed, this penalty is added to the overall
3028 /// cost of the routes. A shipment is considered completed if one of its pickup
3029 /// and delivery alternatives is visited. The cost may be expressed in the
3030 /// same unit used for all other cost-related fields in the model and must be
3031 /// positive.
3032 ///
3033 /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
3034 /// i.e. the shipment must be completed.
3035 pub penalty_cost: std::option::Option<f64>,
3036
3037 /// The set of vehicles that may perform this shipment. If empty, all vehicles
3038 /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
3039 /// `vehicles` list.
3040 pub allowed_vehicle_indices: std::vec::Vec<i32>,
3041
3042 /// Specifies the cost that is incurred when this shipment is delivered by each
3043 /// vehicle. If specified, it must have EITHER:
3044 ///
3045 /// * the same number of elements as `costs_per_vehicle_indices`.
3046 /// `costs_per_vehicle[i]` corresponds to vehicle
3047 /// `costs_per_vehicle_indices[i]` of the model.
3048 /// * the same number of elements as there are vehicles in the model. The
3049 /// i-th element corresponds to vehicle #i of the model.
3050 ///
3051 /// These costs must be in the same unit as `penalty_cost` and must not be
3052 /// negative. Leave this field empty, if there are no such costs.
3053 pub costs_per_vehicle: std::vec::Vec<f64>,
3054
3055 /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
3056 /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
3057 /// index may not be specified more than once. If a vehicle is excluded from
3058 /// `costs_per_vehicle_indices`, its cost is zero.
3059 pub costs_per_vehicle_indices: std::vec::Vec<i32>,
3060
3061 /// Specifies the maximum relative detour time compared to the shortest path
3062 /// from pickup to delivery. If specified, it must be nonnegative, and the
3063 /// shipment must contain at least a pickup and a delivery.
3064 ///
3065 /// For example, let t be the shortest time taken to go from the selected
3066 /// pickup alternative directly to the selected delivery alternative. Then
3067 /// setting `pickup_to_delivery_relative_detour_limit` enforces:
3068 ///
3069 /// ```norust
3070 /// start_time(delivery) - start_time(pickup) <=
3071 /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
3072 /// ```
3073 ///
3074 /// If both relative and absolute limits are specified on the same shipment,
3075 /// the more constraining limit is used for each possible pickup/delivery pair.
3076 /// As of 2017/10, detours are only supported when travel durations do not
3077 /// depend on vehicles.
3078 pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
3079
3080 /// Specifies the maximum absolute detour time compared to the shortest path
3081 /// from pickup to delivery. If specified, it must be nonnegative, and the
3082 /// shipment must contain at least a pickup and a delivery.
3083 ///
3084 /// For example, let t be the shortest time taken to go from the selected
3085 /// pickup alternative directly to the selected delivery alternative. Then
3086 /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
3087 ///
3088 /// ```norust
3089 /// start_time(delivery) - start_time(pickup) <=
3090 /// t + pickup_to_delivery_absolute_detour_limit
3091 /// ```
3092 ///
3093 /// If both relative and absolute limits are specified on the same shipment,
3094 /// the more constraining limit is used for each possible pickup/delivery pair.
3095 /// As of 2017/10, detours are only supported when travel durations do not
3096 /// depend on vehicles.
3097 pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
3098
3099 /// Specifies the maximum duration from start of pickup to start of delivery of
3100 /// a shipment. If specified, it must be nonnegative, and the shipment must
3101 /// contain at least a pickup and a delivery. This does not depend on which
3102 /// alternatives are selected for pickup and delivery, nor on vehicle speed.
3103 /// This can be specified alongside maximum detour constraints: the solution
3104 /// will respect both specifications.
3105 pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
3106
3107 /// Non-empty string specifying a "type" for this shipment.
3108 /// This feature can be used to define incompatibilities or requirements
3109 /// between `shipment_types` (see `shipment_type_incompatibilities` and
3110 /// `shipment_type_requirements` in `ShipmentModel`).
3111 ///
3112 /// Differs from `visit_types` which is specified for a single visit: All
3113 /// pickup/deliveries belonging to the same shipment share the same
3114 /// `shipment_type`.
3115 pub shipment_type: std::string::String,
3116
3117 /// Specifies a label for this shipment. This label is reported in the response
3118 /// in the `shipment_label` of the corresponding
3119 /// [ShipmentRoute.Visit][google.maps.routeoptimization.v1.ShipmentRoute.Visit].
3120 ///
3121 /// [google.maps.routeoptimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3122 pub label: std::string::String,
3123
3124 /// If true, skip this shipment, but don't apply a `penalty_cost`.
3125 ///
3126 /// Ignoring a shipment results in a validation error when there are any
3127 /// `shipment_type_requirements` in the model.
3128 ///
3129 /// Ignoring a shipment that is performed in `injected_first_solution_routes`
3130 /// or `injected_solution_constraint` is permitted; the solver removes the
3131 /// related pickup/delivery visits from the performing route.
3132 /// `precedence_rules` that reference ignored shipments will also be ignored.
3133 pub ignore: bool,
3134
3135 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3136}
3137
3138impl Shipment {
3139 /// Creates a new default instance.
3140 pub fn new() -> Self {
3141 std::default::Default::default()
3142 }
3143
3144 /// Sets the value of [display_name][crate::model::Shipment::display_name].
3145 ///
3146 /// # Example
3147 /// ```ignore,no_run
3148 /// # use google_maps_routeoptimization_v1::model::Shipment;
3149 /// let x = Shipment::new().set_display_name("example");
3150 /// ```
3151 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3152 self.display_name = v.into();
3153 self
3154 }
3155
3156 /// Sets the value of [pickups][crate::model::Shipment::pickups].
3157 ///
3158 /// # Example
3159 /// ```ignore,no_run
3160 /// # use google_maps_routeoptimization_v1::model::Shipment;
3161 /// use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3162 /// let x = Shipment::new()
3163 /// .set_pickups([
3164 /// VisitRequest::default()/* use setters */,
3165 /// VisitRequest::default()/* use (different) setters */,
3166 /// ]);
3167 /// ```
3168 pub fn set_pickups<T, V>(mut self, v: T) -> Self
3169 where
3170 T: std::iter::IntoIterator<Item = V>,
3171 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3172 {
3173 use std::iter::Iterator;
3174 self.pickups = v.into_iter().map(|i| i.into()).collect();
3175 self
3176 }
3177
3178 /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
3179 ///
3180 /// # Example
3181 /// ```ignore,no_run
3182 /// # use google_maps_routeoptimization_v1::model::Shipment;
3183 /// use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3184 /// let x = Shipment::new()
3185 /// .set_deliveries([
3186 /// VisitRequest::default()/* use setters */,
3187 /// VisitRequest::default()/* use (different) setters */,
3188 /// ]);
3189 /// ```
3190 pub fn set_deliveries<T, V>(mut self, v: T) -> Self
3191 where
3192 T: std::iter::IntoIterator<Item = V>,
3193 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3194 {
3195 use std::iter::Iterator;
3196 self.deliveries = v.into_iter().map(|i| i.into()).collect();
3197 self
3198 }
3199
3200 /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
3201 ///
3202 /// # Example
3203 /// ```ignore,no_run
3204 /// # use google_maps_routeoptimization_v1::model::Shipment;
3205 /// use google_maps_routeoptimization_v1::model::shipment::Load;
3206 /// let x = Shipment::new().set_load_demands([
3207 /// ("key0", Load::default()/* use setters */),
3208 /// ("key1", Load::default()/* use (different) setters */),
3209 /// ]);
3210 /// ```
3211 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
3212 where
3213 T: std::iter::IntoIterator<Item = (K, V)>,
3214 K: std::convert::Into<std::string::String>,
3215 V: std::convert::Into<crate::model::shipment::Load>,
3216 {
3217 use std::iter::Iterator;
3218 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3219 self
3220 }
3221
3222 /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3223 ///
3224 /// # Example
3225 /// ```ignore,no_run
3226 /// # use google_maps_routeoptimization_v1::model::Shipment;
3227 /// let x = Shipment::new().set_penalty_cost(42.0);
3228 /// ```
3229 pub fn set_penalty_cost<T>(mut self, v: T) -> Self
3230 where
3231 T: std::convert::Into<f64>,
3232 {
3233 self.penalty_cost = std::option::Option::Some(v.into());
3234 self
3235 }
3236
3237 /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3238 ///
3239 /// # Example
3240 /// ```ignore,no_run
3241 /// # use google_maps_routeoptimization_v1::model::Shipment;
3242 /// let x = Shipment::new().set_or_clear_penalty_cost(Some(42.0));
3243 /// let x = Shipment::new().set_or_clear_penalty_cost(None::<f32>);
3244 /// ```
3245 pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
3246 where
3247 T: std::convert::Into<f64>,
3248 {
3249 self.penalty_cost = v.map(|x| x.into());
3250 self
3251 }
3252
3253 /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
3254 ///
3255 /// # Example
3256 /// ```ignore,no_run
3257 /// # use google_maps_routeoptimization_v1::model::Shipment;
3258 /// let x = Shipment::new().set_allowed_vehicle_indices([1, 2, 3]);
3259 /// ```
3260 pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
3261 where
3262 T: std::iter::IntoIterator<Item = V>,
3263 V: std::convert::Into<i32>,
3264 {
3265 use std::iter::Iterator;
3266 self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3267 self
3268 }
3269
3270 /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
3271 ///
3272 /// # Example
3273 /// ```ignore,no_run
3274 /// # use google_maps_routeoptimization_v1::model::Shipment;
3275 /// let x = Shipment::new().set_costs_per_vehicle([1.0, 2.0, 3.0]);
3276 /// ```
3277 pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
3278 where
3279 T: std::iter::IntoIterator<Item = V>,
3280 V: std::convert::Into<f64>,
3281 {
3282 use std::iter::Iterator;
3283 self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
3284 self
3285 }
3286
3287 /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
3288 ///
3289 /// # Example
3290 /// ```ignore,no_run
3291 /// # use google_maps_routeoptimization_v1::model::Shipment;
3292 /// let x = Shipment::new().set_costs_per_vehicle_indices([1, 2, 3]);
3293 /// ```
3294 pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
3295 where
3296 T: std::iter::IntoIterator<Item = V>,
3297 V: std::convert::Into<i32>,
3298 {
3299 use std::iter::Iterator;
3300 self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3301 self
3302 }
3303
3304 /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3305 ///
3306 /// # Example
3307 /// ```ignore,no_run
3308 /// # use google_maps_routeoptimization_v1::model::Shipment;
3309 /// let x = Shipment::new().set_pickup_to_delivery_relative_detour_limit(42.0);
3310 /// ```
3311 pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
3312 where
3313 T: std::convert::Into<f64>,
3314 {
3315 self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
3316 self
3317 }
3318
3319 /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3320 ///
3321 /// # Example
3322 /// ```ignore,no_run
3323 /// # use google_maps_routeoptimization_v1::model::Shipment;
3324 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(Some(42.0));
3325 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(None::<f32>);
3326 /// ```
3327 pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
3328 mut self,
3329 v: std::option::Option<T>,
3330 ) -> Self
3331 where
3332 T: std::convert::Into<f64>,
3333 {
3334 self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
3335 self
3336 }
3337
3338 /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3339 ///
3340 /// # Example
3341 /// ```ignore,no_run
3342 /// # use google_maps_routeoptimization_v1::model::Shipment;
3343 /// use wkt::Duration;
3344 /// let x = Shipment::new().set_pickup_to_delivery_absolute_detour_limit(Duration::default()/* use setters */);
3345 /// ```
3346 pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
3347 where
3348 T: std::convert::Into<wkt::Duration>,
3349 {
3350 self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
3351 self
3352 }
3353
3354 /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3355 ///
3356 /// # Example
3357 /// ```ignore,no_run
3358 /// # use google_maps_routeoptimization_v1::model::Shipment;
3359 /// use wkt::Duration;
3360 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(Some(Duration::default()/* use setters */));
3361 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(None::<Duration>);
3362 /// ```
3363 pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
3364 mut self,
3365 v: std::option::Option<T>,
3366 ) -> Self
3367 where
3368 T: std::convert::Into<wkt::Duration>,
3369 {
3370 self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
3371 self
3372 }
3373
3374 /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3375 ///
3376 /// # Example
3377 /// ```ignore,no_run
3378 /// # use google_maps_routeoptimization_v1::model::Shipment;
3379 /// use wkt::Duration;
3380 /// let x = Shipment::new().set_pickup_to_delivery_time_limit(Duration::default()/* use setters */);
3381 /// ```
3382 pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
3383 where
3384 T: std::convert::Into<wkt::Duration>,
3385 {
3386 self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
3387 self
3388 }
3389
3390 /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3391 ///
3392 /// # Example
3393 /// ```ignore,no_run
3394 /// # use google_maps_routeoptimization_v1::model::Shipment;
3395 /// use wkt::Duration;
3396 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(Some(Duration::default()/* use setters */));
3397 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(None::<Duration>);
3398 /// ```
3399 pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
3400 mut self,
3401 v: std::option::Option<T>,
3402 ) -> Self
3403 where
3404 T: std::convert::Into<wkt::Duration>,
3405 {
3406 self.pickup_to_delivery_time_limit = v.map(|x| x.into());
3407 self
3408 }
3409
3410 /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
3411 ///
3412 /// # Example
3413 /// ```ignore,no_run
3414 /// # use google_maps_routeoptimization_v1::model::Shipment;
3415 /// let x = Shipment::new().set_shipment_type("example");
3416 /// ```
3417 pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3418 self.shipment_type = v.into();
3419 self
3420 }
3421
3422 /// Sets the value of [label][crate::model::Shipment::label].
3423 ///
3424 /// # Example
3425 /// ```ignore,no_run
3426 /// # use google_maps_routeoptimization_v1::model::Shipment;
3427 /// let x = Shipment::new().set_label("example");
3428 /// ```
3429 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3430 self.label = v.into();
3431 self
3432 }
3433
3434 /// Sets the value of [ignore][crate::model::Shipment::ignore].
3435 ///
3436 /// # Example
3437 /// ```ignore,no_run
3438 /// # use google_maps_routeoptimization_v1::model::Shipment;
3439 /// let x = Shipment::new().set_ignore(true);
3440 /// ```
3441 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3442 self.ignore = v.into();
3443 self
3444 }
3445}
3446
3447impl wkt::message::Message for Shipment {
3448 fn typename() -> &'static str {
3449 "type.googleapis.com/google.maps.routeoptimization.v1.Shipment"
3450 }
3451}
3452
3453/// Defines additional types related to [Shipment].
3454pub mod shipment {
3455 #[allow(unused_imports)]
3456 use super::*;
3457
3458 /// Request for a visit which can be done by a vehicle: it has a geo-location
3459 /// (or two, see below), opening and closing times represented by time windows,
3460 /// and a service duration time (time spent by the vehicle once it has arrived
3461 /// to pickup or drop off goods).
3462 #[derive(Clone, Default, PartialEq)]
3463 #[non_exhaustive]
3464 pub struct VisitRequest {
3465 /// The geo-location where the vehicle arrives when performing this
3466 /// `VisitRequest`. If the shipment model has duration distance matrices,
3467 /// `arrival_location` must not be specified.
3468 pub arrival_location: std::option::Option<google_cloud_type::model::LatLng>,
3469
3470 /// The waypoint where the vehicle arrives when performing this
3471 /// `VisitRequest`. If the shipment model has duration distance matrices,
3472 /// `arrival_waypoint` must not be specified.
3473 pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
3474
3475 /// The geo-location where the vehicle departs after completing this
3476 /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
3477 /// If the shipment model has duration distance matrices,
3478 /// `departure_location` must not be specified.
3479 pub departure_location: std::option::Option<google_cloud_type::model::LatLng>,
3480
3481 /// The waypoint where the vehicle departs after completing this
3482 /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
3483 /// If the shipment model has duration distance matrices,
3484 /// `departure_waypoint` must not be specified.
3485 pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
3486
3487 /// Specifies tags attached to the visit request.
3488 /// Empty or duplicate strings are not allowed.
3489 pub tags: std::vec::Vec<std::string::String>,
3490
3491 /// Time windows which constrain the arrival time at a visit.
3492 /// Note that a vehicle may depart outside of the arrival time window, i.e.
3493 /// arrival time + duration do not need to be inside a time window. This can
3494 /// result in waiting time if the vehicle arrives before
3495 /// [TimeWindow.start_time][google.maps.routeoptimization.v1.TimeWindow.start_time].
3496 ///
3497 /// The absence of `TimeWindow` means that the vehicle can perform this visit
3498 /// at any time.
3499 ///
3500 /// Time windows must be disjoint, i.e. no time window must overlap with or
3501 /// be adjacent to another, and they must be in increasing order.
3502 ///
3503 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
3504 /// be set if there is a single time window.
3505 ///
3506 /// [google.maps.routeoptimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
3507 pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
3508
3509 /// Duration of the visit, i.e. time spent by the vehicle between arrival
3510 /// and departure (to be added to the possible waiting time; see
3511 /// `time_windows`).
3512 pub duration: std::option::Option<wkt::Duration>,
3513
3514 /// Cost to service this visit request on a vehicle route. This can be used
3515 /// to pay different costs for each alternative pickup or delivery of a
3516 /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
3517 /// and must not be negative.
3518 pub cost: f64,
3519
3520 /// Load demands of this visit request. This is just like
3521 /// [Shipment.load_demands][google.maps.routeoptimization.v1.Shipment.load_demands]
3522 /// field, except that it only applies to this
3523 /// [VisitRequest][google.maps.routeoptimization.v1.Shipment.VisitRequest]
3524 /// instead of the whole
3525 /// [Shipment][google.maps.routeoptimization.v1.Shipment]. The demands listed
3526 /// here are added to the demands listed in
3527 /// [Shipment.load_demands][google.maps.routeoptimization.v1.Shipment.load_demands].
3528 ///
3529 /// [google.maps.routeoptimization.v1.Shipment]: crate::model::Shipment
3530 /// [google.maps.routeoptimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
3531 /// [google.maps.routeoptimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3532 pub load_demands:
3533 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3534
3535 /// Specifies the types of the visit. This may be used to allocate additional
3536 /// time required for a vehicle to complete this visit (see
3537 /// [Vehicle.extra_visit_duration_for_visit_type][google.maps.routeoptimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
3538 ///
3539 /// A type can only appear once.
3540 ///
3541 /// [google.maps.routeoptimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
3542 pub visit_types: std::vec::Vec<std::string::String>,
3543
3544 /// Specifies a label for this `VisitRequest`. This label is reported in the
3545 /// response as `visit_label` in the corresponding
3546 /// [ShipmentRoute.Visit][google.maps.routeoptimization.v1.ShipmentRoute.Visit].
3547 ///
3548 /// [google.maps.routeoptimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3549 pub label: std::string::String,
3550
3551 /// Specifies whether U-turns should be avoided in driving routes at this
3552 /// location.
3553 /// U-turn avoidance is best effort and complete avoidance is not guaranteed.
3554 /// This is an experimental feature and behavior is subject to change.
3555 ///
3556 /// Experimental: See
3557 /// <https://developers.google.com/maps/tt/route-optimization/experimental/u-turn-avoidance/make-request>
3558 /// for more details.
3559 pub avoid_u_turns: std::option::Option<bool>,
3560
3561 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3562 }
3563
3564 impl VisitRequest {
3565 /// Creates a new default instance.
3566 pub fn new() -> Self {
3567 std::default::Default::default()
3568 }
3569
3570 /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3571 ///
3572 /// # Example
3573 /// ```ignore,no_run
3574 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3575 /// use google_cloud_type::model::LatLng;
3576 /// let x = VisitRequest::new().set_arrival_location(LatLng::default()/* use setters */);
3577 /// ```
3578 pub fn set_arrival_location<T>(mut self, v: T) -> Self
3579 where
3580 T: std::convert::Into<google_cloud_type::model::LatLng>,
3581 {
3582 self.arrival_location = std::option::Option::Some(v.into());
3583 self
3584 }
3585
3586 /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3587 ///
3588 /// # Example
3589 /// ```ignore,no_run
3590 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3591 /// use google_cloud_type::model::LatLng;
3592 /// let x = VisitRequest::new().set_or_clear_arrival_location(Some(LatLng::default()/* use setters */));
3593 /// let x = VisitRequest::new().set_or_clear_arrival_location(None::<LatLng>);
3594 /// ```
3595 pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
3596 where
3597 T: std::convert::Into<google_cloud_type::model::LatLng>,
3598 {
3599 self.arrival_location = v.map(|x| x.into());
3600 self
3601 }
3602
3603 /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
3604 ///
3605 /// # Example
3606 /// ```ignore,no_run
3607 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3608 /// use google_maps_routeoptimization_v1::model::Waypoint;
3609 /// let x = VisitRequest::new().set_arrival_waypoint(Waypoint::default()/* use setters */);
3610 /// ```
3611 pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
3612 where
3613 T: std::convert::Into<crate::model::Waypoint>,
3614 {
3615 self.arrival_waypoint = std::option::Option::Some(v.into());
3616 self
3617 }
3618
3619 /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
3620 ///
3621 /// # Example
3622 /// ```ignore,no_run
3623 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3624 /// use google_maps_routeoptimization_v1::model::Waypoint;
3625 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(Some(Waypoint::default()/* use setters */));
3626 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(None::<Waypoint>);
3627 /// ```
3628 pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
3629 where
3630 T: std::convert::Into<crate::model::Waypoint>,
3631 {
3632 self.arrival_waypoint = v.map(|x| x.into());
3633 self
3634 }
3635
3636 /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
3637 ///
3638 /// # Example
3639 /// ```ignore,no_run
3640 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3641 /// use google_cloud_type::model::LatLng;
3642 /// let x = VisitRequest::new().set_departure_location(LatLng::default()/* use setters */);
3643 /// ```
3644 pub fn set_departure_location<T>(mut self, v: T) -> Self
3645 where
3646 T: std::convert::Into<google_cloud_type::model::LatLng>,
3647 {
3648 self.departure_location = std::option::Option::Some(v.into());
3649 self
3650 }
3651
3652 /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
3653 ///
3654 /// # Example
3655 /// ```ignore,no_run
3656 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3657 /// use google_cloud_type::model::LatLng;
3658 /// let x = VisitRequest::new().set_or_clear_departure_location(Some(LatLng::default()/* use setters */));
3659 /// let x = VisitRequest::new().set_or_clear_departure_location(None::<LatLng>);
3660 /// ```
3661 pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
3662 where
3663 T: std::convert::Into<google_cloud_type::model::LatLng>,
3664 {
3665 self.departure_location = v.map(|x| x.into());
3666 self
3667 }
3668
3669 /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
3670 ///
3671 /// # Example
3672 /// ```ignore,no_run
3673 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3674 /// use google_maps_routeoptimization_v1::model::Waypoint;
3675 /// let x = VisitRequest::new().set_departure_waypoint(Waypoint::default()/* use setters */);
3676 /// ```
3677 pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
3678 where
3679 T: std::convert::Into<crate::model::Waypoint>,
3680 {
3681 self.departure_waypoint = std::option::Option::Some(v.into());
3682 self
3683 }
3684
3685 /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
3686 ///
3687 /// # Example
3688 /// ```ignore,no_run
3689 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3690 /// use google_maps_routeoptimization_v1::model::Waypoint;
3691 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(Some(Waypoint::default()/* use setters */));
3692 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(None::<Waypoint>);
3693 /// ```
3694 pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
3695 where
3696 T: std::convert::Into<crate::model::Waypoint>,
3697 {
3698 self.departure_waypoint = v.map(|x| x.into());
3699 self
3700 }
3701
3702 /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
3703 ///
3704 /// # Example
3705 /// ```ignore,no_run
3706 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3707 /// let x = VisitRequest::new().set_tags(["a", "b", "c"]);
3708 /// ```
3709 pub fn set_tags<T, V>(mut self, v: T) -> Self
3710 where
3711 T: std::iter::IntoIterator<Item = V>,
3712 V: std::convert::Into<std::string::String>,
3713 {
3714 use std::iter::Iterator;
3715 self.tags = v.into_iter().map(|i| i.into()).collect();
3716 self
3717 }
3718
3719 /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
3720 ///
3721 /// # Example
3722 /// ```ignore,no_run
3723 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3724 /// use google_maps_routeoptimization_v1::model::TimeWindow;
3725 /// let x = VisitRequest::new()
3726 /// .set_time_windows([
3727 /// TimeWindow::default()/* use setters */,
3728 /// TimeWindow::default()/* use (different) setters */,
3729 /// ]);
3730 /// ```
3731 pub fn set_time_windows<T, V>(mut self, v: T) -> Self
3732 where
3733 T: std::iter::IntoIterator<Item = V>,
3734 V: std::convert::Into<crate::model::TimeWindow>,
3735 {
3736 use std::iter::Iterator;
3737 self.time_windows = v.into_iter().map(|i| i.into()).collect();
3738 self
3739 }
3740
3741 /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
3742 ///
3743 /// # Example
3744 /// ```ignore,no_run
3745 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3746 /// use wkt::Duration;
3747 /// let x = VisitRequest::new().set_duration(Duration::default()/* use setters */);
3748 /// ```
3749 pub fn set_duration<T>(mut self, v: T) -> Self
3750 where
3751 T: std::convert::Into<wkt::Duration>,
3752 {
3753 self.duration = std::option::Option::Some(v.into());
3754 self
3755 }
3756
3757 /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
3758 ///
3759 /// # Example
3760 /// ```ignore,no_run
3761 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3762 /// use wkt::Duration;
3763 /// let x = VisitRequest::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
3764 /// let x = VisitRequest::new().set_or_clear_duration(None::<Duration>);
3765 /// ```
3766 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
3767 where
3768 T: std::convert::Into<wkt::Duration>,
3769 {
3770 self.duration = v.map(|x| x.into());
3771 self
3772 }
3773
3774 /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
3775 ///
3776 /// # Example
3777 /// ```ignore,no_run
3778 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3779 /// let x = VisitRequest::new().set_cost(42.0);
3780 /// ```
3781 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3782 self.cost = v.into();
3783 self
3784 }
3785
3786 /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
3787 ///
3788 /// # Example
3789 /// ```ignore,no_run
3790 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3791 /// use google_maps_routeoptimization_v1::model::shipment::Load;
3792 /// let x = VisitRequest::new().set_load_demands([
3793 /// ("key0", Load::default()/* use setters */),
3794 /// ("key1", Load::default()/* use (different) setters */),
3795 /// ]);
3796 /// ```
3797 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
3798 where
3799 T: std::iter::IntoIterator<Item = (K, V)>,
3800 K: std::convert::Into<std::string::String>,
3801 V: std::convert::Into<crate::model::shipment::Load>,
3802 {
3803 use std::iter::Iterator;
3804 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3805 self
3806 }
3807
3808 /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
3809 ///
3810 /// # Example
3811 /// ```ignore,no_run
3812 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3813 /// let x = VisitRequest::new().set_visit_types(["a", "b", "c"]);
3814 /// ```
3815 pub fn set_visit_types<T, V>(mut self, v: T) -> Self
3816 where
3817 T: std::iter::IntoIterator<Item = V>,
3818 V: std::convert::Into<std::string::String>,
3819 {
3820 use std::iter::Iterator;
3821 self.visit_types = v.into_iter().map(|i| i.into()).collect();
3822 self
3823 }
3824
3825 /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
3826 ///
3827 /// # Example
3828 /// ```ignore,no_run
3829 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3830 /// let x = VisitRequest::new().set_label("example");
3831 /// ```
3832 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3833 self.label = v.into();
3834 self
3835 }
3836
3837 /// Sets the value of [avoid_u_turns][crate::model::shipment::VisitRequest::avoid_u_turns].
3838 ///
3839 /// # Example
3840 /// ```ignore,no_run
3841 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3842 /// let x = VisitRequest::new().set_avoid_u_turns(true);
3843 /// ```
3844 pub fn set_avoid_u_turns<T>(mut self, v: T) -> Self
3845 where
3846 T: std::convert::Into<bool>,
3847 {
3848 self.avoid_u_turns = std::option::Option::Some(v.into());
3849 self
3850 }
3851
3852 /// Sets or clears the value of [avoid_u_turns][crate::model::shipment::VisitRequest::avoid_u_turns].
3853 ///
3854 /// # Example
3855 /// ```ignore,no_run
3856 /// # use google_maps_routeoptimization_v1::model::shipment::VisitRequest;
3857 /// let x = VisitRequest::new().set_or_clear_avoid_u_turns(Some(false));
3858 /// let x = VisitRequest::new().set_or_clear_avoid_u_turns(None::<bool>);
3859 /// ```
3860 pub fn set_or_clear_avoid_u_turns<T>(mut self, v: std::option::Option<T>) -> Self
3861 where
3862 T: std::convert::Into<bool>,
3863 {
3864 self.avoid_u_turns = v.map(|x| x.into());
3865 self
3866 }
3867 }
3868
3869 impl wkt::message::Message for VisitRequest {
3870 fn typename() -> &'static str {
3871 "type.googleapis.com/google.maps.routeoptimization.v1.Shipment.VisitRequest"
3872 }
3873 }
3874
3875 /// When performing a visit, a predefined amount may be added to the vehicle
3876 /// load if it's a pickup, or subtracted if it's a delivery. This message
3877 /// defines such amount. See
3878 /// [load_demands][google.maps.routeoptimization.v1.Shipment.load_demands].
3879 ///
3880 /// [google.maps.routeoptimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3881 #[derive(Clone, Default, PartialEq)]
3882 #[non_exhaustive]
3883 pub struct Load {
3884 /// The amount by which the load of the vehicle performing the corresponding
3885 /// visit will vary. Since it is an integer, users are advised to choose an
3886 /// appropriate unit to avoid loss of precision. Must be ≥ 0.
3887 pub amount: i64,
3888
3889 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3890 }
3891
3892 impl Load {
3893 /// Creates a new default instance.
3894 pub fn new() -> Self {
3895 std::default::Default::default()
3896 }
3897
3898 /// Sets the value of [amount][crate::model::shipment::Load::amount].
3899 ///
3900 /// # Example
3901 /// ```ignore,no_run
3902 /// # use google_maps_routeoptimization_v1::model::shipment::Load;
3903 /// let x = Load::new().set_amount(42);
3904 /// ```
3905 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3906 self.amount = v.into();
3907 self
3908 }
3909 }
3910
3911 impl wkt::message::Message for Load {
3912 fn typename() -> &'static str {
3913 "type.googleapis.com/google.maps.routeoptimization.v1.Shipment.Load"
3914 }
3915 }
3916}
3917
3918/// Specifies incompatibilties between shipments depending on their
3919/// shipment_type. The appearance of incompatible shipments on the same route is
3920/// restricted based on the incompatibility mode.
3921#[derive(Clone, Default, PartialEq)]
3922#[non_exhaustive]
3923pub struct ShipmentTypeIncompatibility {
3924 /// List of incompatible types. Two shipments having different `shipment_types`
3925 /// among those listed are "incompatible".
3926 pub types: std::vec::Vec<std::string::String>,
3927
3928 /// Mode applied to the incompatibility.
3929 pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
3930
3931 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3932}
3933
3934impl ShipmentTypeIncompatibility {
3935 /// Creates a new default instance.
3936 pub fn new() -> Self {
3937 std::default::Default::default()
3938 }
3939
3940 /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
3941 ///
3942 /// # Example
3943 /// ```ignore,no_run
3944 /// # use google_maps_routeoptimization_v1::model::ShipmentTypeIncompatibility;
3945 /// let x = ShipmentTypeIncompatibility::new().set_types(["a", "b", "c"]);
3946 /// ```
3947 pub fn set_types<T, V>(mut self, v: T) -> Self
3948 where
3949 T: std::iter::IntoIterator<Item = V>,
3950 V: std::convert::Into<std::string::String>,
3951 {
3952 use std::iter::Iterator;
3953 self.types = v.into_iter().map(|i| i.into()).collect();
3954 self
3955 }
3956
3957 /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
3958 ///
3959 /// # Example
3960 /// ```ignore,no_run
3961 /// # use google_maps_routeoptimization_v1::model::ShipmentTypeIncompatibility;
3962 /// use google_maps_routeoptimization_v1::model::shipment_type_incompatibility::IncompatibilityMode;
3963 /// let x0 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotPerformedBySameVehicle);
3964 /// let x1 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotInSameVehicleSimultaneously);
3965 /// ```
3966 pub fn set_incompatibility_mode<
3967 T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
3968 >(
3969 mut self,
3970 v: T,
3971 ) -> Self {
3972 self.incompatibility_mode = v.into();
3973 self
3974 }
3975}
3976
3977impl wkt::message::Message for ShipmentTypeIncompatibility {
3978 fn typename() -> &'static str {
3979 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentTypeIncompatibility"
3980 }
3981}
3982
3983/// Defines additional types related to [ShipmentTypeIncompatibility].
3984pub mod shipment_type_incompatibility {
3985 #[allow(unused_imports)]
3986 use super::*;
3987
3988 /// Modes defining how the appearance of incompatible shipments are restricted
3989 /// on the same route.
3990 ///
3991 /// # Working with unknown values
3992 ///
3993 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3994 /// additional enum variants at any time. Adding new variants is not considered
3995 /// a breaking change. Applications should write their code in anticipation of:
3996 ///
3997 /// - New values appearing in future releases of the client library, **and**
3998 /// - New values received dynamically, without application changes.
3999 ///
4000 /// Please consult the [Working with enums] section in the user guide for some
4001 /// guidelines.
4002 ///
4003 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4004 #[derive(Clone, Debug, PartialEq)]
4005 #[non_exhaustive]
4006 pub enum IncompatibilityMode {
4007 /// Unspecified incompatibility mode. This value should never be used.
4008 Unspecified,
4009 /// In this mode, two shipments with incompatible types can never share the
4010 /// same vehicle.
4011 NotPerformedBySameVehicle,
4012 /// In this mode, two shipments with incompatible types can never be on the
4013 /// same vehicle at the same time:
4014 ///
4015 /// * They can share the same vehicle only if one is delivered before the
4016 /// other is picked up.
4017 /// * When both shipments are pickups-only (no deliveries) or deliveries-only
4018 /// (no pickups), they can't share the same vehicle at all.
4019 NotInSameVehicleSimultaneously,
4020 /// If set, the enum was initialized with an unknown value.
4021 ///
4022 /// Applications can examine the value using [IncompatibilityMode::value] or
4023 /// [IncompatibilityMode::name].
4024 UnknownValue(incompatibility_mode::UnknownValue),
4025 }
4026
4027 #[doc(hidden)]
4028 pub mod incompatibility_mode {
4029 #[allow(unused_imports)]
4030 use super::*;
4031 #[derive(Clone, Debug, PartialEq)]
4032 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4033 }
4034
4035 impl IncompatibilityMode {
4036 /// Gets the enum value.
4037 ///
4038 /// Returns `None` if the enum contains an unknown value deserialized from
4039 /// the string representation of enums.
4040 pub fn value(&self) -> std::option::Option<i32> {
4041 match self {
4042 Self::Unspecified => std::option::Option::Some(0),
4043 Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
4044 Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
4045 Self::UnknownValue(u) => u.0.value(),
4046 }
4047 }
4048
4049 /// Gets the enum value as a string.
4050 ///
4051 /// Returns `None` if the enum contains an unknown value deserialized from
4052 /// the integer representation of enums.
4053 pub fn name(&self) -> std::option::Option<&str> {
4054 match self {
4055 Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
4056 Self::NotPerformedBySameVehicle => {
4057 std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
4058 }
4059 Self::NotInSameVehicleSimultaneously => {
4060 std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
4061 }
4062 Self::UnknownValue(u) => u.0.name(),
4063 }
4064 }
4065 }
4066
4067 impl std::default::Default for IncompatibilityMode {
4068 fn default() -> Self {
4069 use std::convert::From;
4070 Self::from(0)
4071 }
4072 }
4073
4074 impl std::fmt::Display for IncompatibilityMode {
4075 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4076 wkt::internal::display_enum(f, self.name(), self.value())
4077 }
4078 }
4079
4080 impl std::convert::From<i32> for IncompatibilityMode {
4081 fn from(value: i32) -> Self {
4082 match value {
4083 0 => Self::Unspecified,
4084 1 => Self::NotPerformedBySameVehicle,
4085 2 => Self::NotInSameVehicleSimultaneously,
4086 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4087 wkt::internal::UnknownEnumValue::Integer(value),
4088 )),
4089 }
4090 }
4091 }
4092
4093 impl std::convert::From<&str> for IncompatibilityMode {
4094 fn from(value: &str) -> Self {
4095 use std::string::ToString;
4096 match value {
4097 "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
4098 "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
4099 "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
4100 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4101 wkt::internal::UnknownEnumValue::String(value.to_string()),
4102 )),
4103 }
4104 }
4105 }
4106
4107 impl serde::ser::Serialize for IncompatibilityMode {
4108 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4109 where
4110 S: serde::Serializer,
4111 {
4112 match self {
4113 Self::Unspecified => serializer.serialize_i32(0),
4114 Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
4115 Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
4116 Self::UnknownValue(u) => u.0.serialize(serializer),
4117 }
4118 }
4119 }
4120
4121 impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
4122 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4123 where
4124 D: serde::Deserializer<'de>,
4125 {
4126 deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
4127 ".google.maps.routeoptimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
4128 ))
4129 }
4130 }
4131}
4132
4133/// Specifies requirements between shipments based on their shipment_type.
4134/// The specifics of the requirement are defined by the requirement mode.
4135#[derive(Clone, Default, PartialEq)]
4136#[non_exhaustive]
4137pub struct ShipmentTypeRequirement {
4138 /// List of alternative shipment types required by the
4139 /// `dependent_shipment_types`.
4140 pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
4141
4142 /// All shipments with a type in the `dependent_shipment_types` field require
4143 /// at least one shipment of type `required_shipment_type_alternatives` to be
4144 /// visited on the same route.
4145 ///
4146 /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
4147 /// are not allowed.
4148 pub dependent_shipment_types: std::vec::Vec<std::string::String>,
4149
4150 /// Mode applied to the requirement.
4151 pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
4152
4153 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4154}
4155
4156impl ShipmentTypeRequirement {
4157 /// Creates a new default instance.
4158 pub fn new() -> Self {
4159 std::default::Default::default()
4160 }
4161
4162 /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
4163 ///
4164 /// # Example
4165 /// ```ignore,no_run
4166 /// # use google_maps_routeoptimization_v1::model::ShipmentTypeRequirement;
4167 /// let x = ShipmentTypeRequirement::new().set_required_shipment_type_alternatives(["a", "b", "c"]);
4168 /// ```
4169 pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
4170 where
4171 T: std::iter::IntoIterator<Item = V>,
4172 V: std::convert::Into<std::string::String>,
4173 {
4174 use std::iter::Iterator;
4175 self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
4176 self
4177 }
4178
4179 /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
4180 ///
4181 /// # Example
4182 /// ```ignore,no_run
4183 /// # use google_maps_routeoptimization_v1::model::ShipmentTypeRequirement;
4184 /// let x = ShipmentTypeRequirement::new().set_dependent_shipment_types(["a", "b", "c"]);
4185 /// ```
4186 pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
4187 where
4188 T: std::iter::IntoIterator<Item = V>,
4189 V: std::convert::Into<std::string::String>,
4190 {
4191 use std::iter::Iterator;
4192 self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
4193 self
4194 }
4195
4196 /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
4197 ///
4198 /// # Example
4199 /// ```ignore,no_run
4200 /// # use google_maps_routeoptimization_v1::model::ShipmentTypeRequirement;
4201 /// use google_maps_routeoptimization_v1::model::shipment_type_requirement::RequirementMode;
4202 /// let x0 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::PerformedBySameVehicle);
4203 /// let x1 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtPickupTime);
4204 /// let x2 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtDeliveryTime);
4205 /// ```
4206 pub fn set_requirement_mode<
4207 T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
4208 >(
4209 mut self,
4210 v: T,
4211 ) -> Self {
4212 self.requirement_mode = v.into();
4213 self
4214 }
4215}
4216
4217impl wkt::message::Message for ShipmentTypeRequirement {
4218 fn typename() -> &'static str {
4219 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentTypeRequirement"
4220 }
4221}
4222
4223/// Defines additional types related to [ShipmentTypeRequirement].
4224pub mod shipment_type_requirement {
4225 #[allow(unused_imports)]
4226 use super::*;
4227
4228 /// Modes defining the appearance of dependent shipments on a route.
4229 ///
4230 /// # Working with unknown values
4231 ///
4232 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4233 /// additional enum variants at any time. Adding new variants is not considered
4234 /// a breaking change. Applications should write their code in anticipation of:
4235 ///
4236 /// - New values appearing in future releases of the client library, **and**
4237 /// - New values received dynamically, without application changes.
4238 ///
4239 /// Please consult the [Working with enums] section in the user guide for some
4240 /// guidelines.
4241 ///
4242 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4243 #[derive(Clone, Debug, PartialEq)]
4244 #[non_exhaustive]
4245 pub enum RequirementMode {
4246 /// Unspecified requirement mode. This value should never be used.
4247 Unspecified,
4248 /// In this mode, all "dependent" shipments must share the same vehicle as at
4249 /// least one of their "required" shipments.
4250 PerformedBySameVehicle,
4251 /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
4252 /// shipments need to have at least one "required" shipment on their vehicle
4253 /// at the time of their pickup.
4254 ///
4255 /// A "dependent" shipment pickup must therefore have either:
4256 ///
4257 /// * A delivery-only "required" shipment delivered on the route after, or
4258 /// * A "required" shipment picked up on the route before it, and if the
4259 /// "required" shipment has a delivery, this delivery must be performed
4260 /// after the "dependent" shipment's pickup.
4261 InSameVehicleAtPickupTime,
4262 /// Same as before, except the "dependent" shipments need to have a
4263 /// "required" shipment on their vehicle at the time of their *delivery*.
4264 InSameVehicleAtDeliveryTime,
4265 /// If set, the enum was initialized with an unknown value.
4266 ///
4267 /// Applications can examine the value using [RequirementMode::value] or
4268 /// [RequirementMode::name].
4269 UnknownValue(requirement_mode::UnknownValue),
4270 }
4271
4272 #[doc(hidden)]
4273 pub mod requirement_mode {
4274 #[allow(unused_imports)]
4275 use super::*;
4276 #[derive(Clone, Debug, PartialEq)]
4277 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4278 }
4279
4280 impl RequirementMode {
4281 /// Gets the enum value.
4282 ///
4283 /// Returns `None` if the enum contains an unknown value deserialized from
4284 /// the string representation of enums.
4285 pub fn value(&self) -> std::option::Option<i32> {
4286 match self {
4287 Self::Unspecified => std::option::Option::Some(0),
4288 Self::PerformedBySameVehicle => std::option::Option::Some(1),
4289 Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
4290 Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
4291 Self::UnknownValue(u) => u.0.value(),
4292 }
4293 }
4294
4295 /// Gets the enum value as a string.
4296 ///
4297 /// Returns `None` if the enum contains an unknown value deserialized from
4298 /// the integer representation of enums.
4299 pub fn name(&self) -> std::option::Option<&str> {
4300 match self {
4301 Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
4302 Self::PerformedBySameVehicle => {
4303 std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
4304 }
4305 Self::InSameVehicleAtPickupTime => {
4306 std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
4307 }
4308 Self::InSameVehicleAtDeliveryTime => {
4309 std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
4310 }
4311 Self::UnknownValue(u) => u.0.name(),
4312 }
4313 }
4314 }
4315
4316 impl std::default::Default for RequirementMode {
4317 fn default() -> Self {
4318 use std::convert::From;
4319 Self::from(0)
4320 }
4321 }
4322
4323 impl std::fmt::Display for RequirementMode {
4324 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4325 wkt::internal::display_enum(f, self.name(), self.value())
4326 }
4327 }
4328
4329 impl std::convert::From<i32> for RequirementMode {
4330 fn from(value: i32) -> Self {
4331 match value {
4332 0 => Self::Unspecified,
4333 1 => Self::PerformedBySameVehicle,
4334 2 => Self::InSameVehicleAtPickupTime,
4335 3 => Self::InSameVehicleAtDeliveryTime,
4336 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4337 wkt::internal::UnknownEnumValue::Integer(value),
4338 )),
4339 }
4340 }
4341 }
4342
4343 impl std::convert::From<&str> for RequirementMode {
4344 fn from(value: &str) -> Self {
4345 use std::string::ToString;
4346 match value {
4347 "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
4348 "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
4349 "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
4350 "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
4351 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4352 wkt::internal::UnknownEnumValue::String(value.to_string()),
4353 )),
4354 }
4355 }
4356 }
4357
4358 impl serde::ser::Serialize for RequirementMode {
4359 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4360 where
4361 S: serde::Serializer,
4362 {
4363 match self {
4364 Self::Unspecified => serializer.serialize_i32(0),
4365 Self::PerformedBySameVehicle => serializer.serialize_i32(1),
4366 Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
4367 Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
4368 Self::UnknownValue(u) => u.0.serialize(serializer),
4369 }
4370 }
4371 }
4372
4373 impl<'de> serde::de::Deserialize<'de> for RequirementMode {
4374 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4375 where
4376 D: serde::Deserializer<'de>,
4377 {
4378 deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
4379 ".google.maps.routeoptimization.v1.ShipmentTypeRequirement.RequirementMode",
4380 ))
4381 }
4382 }
4383}
4384
4385/// Encapsulates a set of optional conditions to satisfy when calculating
4386/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
4387/// Platform Routes Preferred API; see:
4388/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
4389#[derive(Clone, Default, PartialEq)]
4390#[non_exhaustive]
4391pub struct RouteModifiers {
4392 /// Specifies whether to avoid toll roads where reasonable. Preference will be
4393 /// given to routes not containing toll roads. Applies only to motorized travel
4394 /// modes.
4395 pub avoid_tolls: bool,
4396
4397 /// Specifies whether to avoid highways where reasonable. Preference will be
4398 /// given to routes not containing highways. Applies only to motorized travel
4399 /// modes.
4400 pub avoid_highways: bool,
4401
4402 /// Specifies whether to avoid ferries where reasonable. Preference will be
4403 /// given to routes not containing travel by ferries. Applies only to motorized
4404 /// travel modes.
4405 pub avoid_ferries: bool,
4406
4407 /// Optional. Specifies whether to avoid navigating indoors where reasonable.
4408 /// Preference will be given to routes not containing indoor navigation.
4409 /// Applies only to the `WALKING` travel mode.
4410 pub avoid_indoor: bool,
4411
4412 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4413}
4414
4415impl RouteModifiers {
4416 /// Creates a new default instance.
4417 pub fn new() -> Self {
4418 std::default::Default::default()
4419 }
4420
4421 /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
4422 ///
4423 /// # Example
4424 /// ```ignore,no_run
4425 /// # use google_maps_routeoptimization_v1::model::RouteModifiers;
4426 /// let x = RouteModifiers::new().set_avoid_tolls(true);
4427 /// ```
4428 pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4429 self.avoid_tolls = v.into();
4430 self
4431 }
4432
4433 /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
4434 ///
4435 /// # Example
4436 /// ```ignore,no_run
4437 /// # use google_maps_routeoptimization_v1::model::RouteModifiers;
4438 /// let x = RouteModifiers::new().set_avoid_highways(true);
4439 /// ```
4440 pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4441 self.avoid_highways = v.into();
4442 self
4443 }
4444
4445 /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
4446 ///
4447 /// # Example
4448 /// ```ignore,no_run
4449 /// # use google_maps_routeoptimization_v1::model::RouteModifiers;
4450 /// let x = RouteModifiers::new().set_avoid_ferries(true);
4451 /// ```
4452 pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4453 self.avoid_ferries = v.into();
4454 self
4455 }
4456
4457 /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
4458 ///
4459 /// # Example
4460 /// ```ignore,no_run
4461 /// # use google_maps_routeoptimization_v1::model::RouteModifiers;
4462 /// let x = RouteModifiers::new().set_avoid_indoor(true);
4463 /// ```
4464 pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4465 self.avoid_indoor = v.into();
4466 self
4467 }
4468}
4469
4470impl wkt::message::Message for RouteModifiers {
4471 fn typename() -> &'static str {
4472 "type.googleapis.com/google.maps.routeoptimization.v1.RouteModifiers"
4473 }
4474}
4475
4476/// Models a vehicle in a shipment problem. Solving a shipment problem will
4477/// build a route starting from `start_location` and ending at `end_location`
4478/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
4479#[derive(Clone, Default, PartialEq)]
4480#[non_exhaustive]
4481pub struct Vehicle {
4482 /// The user-defined display name of the vehicle.
4483 /// It can be up to 63 characters long and may use UTF-8 characters.
4484 pub display_name: std::string::String,
4485
4486 /// The travel mode which affects the roads usable by the vehicle and its
4487 /// speed. See also `travel_duration_multiple`.
4488 pub travel_mode: crate::model::vehicle::TravelMode,
4489
4490 /// A set of conditions to satisfy that affect the way routes are calculated
4491 /// for the given vehicle.
4492 pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
4493
4494 /// Geographic location where the vehicle starts before picking up any
4495 /// shipments. If not specified, the vehicle starts at its first pickup.
4496 /// If the shipment model has duration and distance matrices, `start_location`
4497 /// must not be specified.
4498 pub start_location: std::option::Option<google_cloud_type::model::LatLng>,
4499
4500 /// Waypoint representing a geographic location where the vehicle starts before
4501 /// picking up any shipments. If neither `start_waypoint` nor `start_location`
4502 /// is specified, the vehicle starts at its first pickup.
4503 /// If the shipment model has duration and distance matrices, `start_waypoint`
4504 /// must not be specified.
4505 pub start_waypoint: std::option::Option<crate::model::Waypoint>,
4506
4507 /// Geographic location where the vehicle ends after it has completed its last
4508 /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
4509 /// immediately when it completes its last `VisitRequest`.
4510 /// If the shipment model has duration and distance matrices, `end_location`
4511 /// must not be specified.
4512 pub end_location: std::option::Option<google_cloud_type::model::LatLng>,
4513
4514 /// Waypoint representing a geographic location where the vehicle ends after
4515 /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
4516 /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
4517 /// when it completes its last `VisitRequest`.
4518 /// If the shipment model has duration and distance matrices, `end_waypoint`
4519 /// must not be specified.
4520 pub end_waypoint: std::option::Option<crate::model::Waypoint>,
4521
4522 /// Specifies tags attached to the start of the vehicle's route.
4523 ///
4524 /// Empty or duplicate strings are not allowed.
4525 pub start_tags: std::vec::Vec<std::string::String>,
4526
4527 /// Specifies tags attached to the end of the vehicle's route.
4528 ///
4529 /// Empty or duplicate strings are not allowed.
4530 pub end_tags: std::vec::Vec<std::string::String>,
4531
4532 /// Time windows during which the vehicle may depart its start location.
4533 /// They must be within the global time limits (see
4534 /// [ShipmentModel.global_*][google.maps.routeoptimization.v1.ShipmentModel.global_start_time]
4535 /// fields). If unspecified, there is no limitation besides those global time
4536 /// limits.
4537 ///
4538 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4539 /// time window can overlap with or be adjacent to another, and they must be in
4540 /// chronological order.
4541 ///
4542 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4543 /// there is a single time window.
4544 ///
4545 /// [google.maps.routeoptimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4546 pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4547
4548 /// Time windows during which the vehicle may arrive at its end location.
4549 /// They must be within the global time limits (see
4550 /// [ShipmentModel.global_*][google.maps.routeoptimization.v1.ShipmentModel.global_start_time]
4551 /// fields). If unspecified, there is no limitation besides those global time
4552 /// limits.
4553 ///
4554 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4555 /// time window can overlap with or be adjacent to another, and they must be in
4556 /// chronological order.
4557 ///
4558 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4559 /// there is a single time window.
4560 ///
4561 /// [google.maps.routeoptimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4562 pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4563
4564 /// Specifies a multiplicative factor that can be used to increase or decrease
4565 /// travel times of this vehicle. For example, setting this to 2.0 means
4566 /// that this vehicle is slower and has travel times that are twice what they
4567 /// are for standard vehicles. This multiple does not affect visit durations.
4568 /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
4569 /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
4570 /// is standard, and this multiple is considered 1.0.
4571 ///
4572 /// WARNING: Travel times will be rounded to the nearest second after this
4573 /// multiple is applied but before performing any numerical operations, thus,
4574 /// a small multiple may result in a loss of precision.
4575 ///
4576 /// See also `extra_visit_duration_for_visit_type` below.
4577 pub travel_duration_multiple: std::option::Option<f64>,
4578
4579 /// Unloading policy enforced on the vehicle.
4580 pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
4581
4582 /// Capacities of the vehicle (weight, volume, # of pallets for example).
4583 /// The keys in the map are the identifiers of the type of load, consistent
4584 /// with the keys of the
4585 /// [Shipment.load_demands][google.maps.routeoptimization.v1.Shipment.load_demands]
4586 /// field. If a given key is absent from this map, the corresponding capacity
4587 /// is considered to be limitless.
4588 ///
4589 /// [google.maps.routeoptimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4590 pub load_limits:
4591 std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
4592
4593 /// Vehicle costs: all costs add up and must be in the same unit as
4594 /// [Shipment.penalty_cost][google.maps.routeoptimization.v1.Shipment.penalty_cost].
4595 ///
4596 /// Cost per hour of the vehicle route. This cost is applied to the total time
4597 /// taken by the route, and includes travel time, waiting time, and visit time.
4598 /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
4599 /// in additional latency.
4600 ///
4601 /// [google.maps.routeoptimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
4602 pub cost_per_hour: f64,
4603
4604 /// Cost per traveled hour of the vehicle route. This cost is applied only to
4605 /// travel time taken by the route (i.e., that reported in
4606 /// [ShipmentRoute.transitions][google.maps.routeoptimization.v1.ShipmentRoute.transitions]),
4607 /// and excludes waiting time and visit time.
4608 ///
4609 /// [google.maps.routeoptimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
4610 pub cost_per_traveled_hour: f64,
4611
4612 /// Cost per kilometer of the vehicle route. This cost is applied to the
4613 /// distance reported in the
4614 /// [ShipmentRoute.transitions][google.maps.routeoptimization.v1.ShipmentRoute.transitions]
4615 /// and does not apply to any distance implicitly traveled from the
4616 /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
4617 ///
4618 /// [google.maps.routeoptimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
4619 pub cost_per_kilometer: f64,
4620
4621 /// Fixed cost applied if this vehicle is used to handle a shipment.
4622 pub fixed_cost: f64,
4623
4624 /// This field only applies to vehicles when their route does not serve any
4625 /// shipments. It indicates if the vehicle should be considered as used or not
4626 /// in this case.
4627 ///
4628 /// If true, the vehicle goes from its start to its end location even if it
4629 /// doesn't serve any shipments, and time and distance costs resulting from its
4630 /// start --> end travel are taken into account.
4631 ///
4632 /// Otherwise, it doesn't travel from its start to its end location, and no
4633 /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
4634 /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
4635 /// information except for the vehicle index and label.
4636 pub used_if_route_is_empty: bool,
4637
4638 /// Limit applied to the total duration of the vehicle's route. In a given
4639 /// `OptimizeToursResponse`, the route duration of a vehicle is the
4640 /// difference between its `vehicle_end_time` and `vehicle_start_time`.
4641 pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
4642
4643 /// Limit applied to the travel duration of the vehicle's route. In a given
4644 /// `OptimizeToursResponse`, the route travel duration is the sum of all its
4645 /// [transitions.travel_duration][google.maps.routeoptimization.v1.ShipmentRoute.Transition.travel_duration].
4646 ///
4647 /// [google.maps.routeoptimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
4648 pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
4649
4650 /// Limit applied to the total distance of the vehicle's route. In a given
4651 /// `OptimizeToursResponse`, the route distance is the sum of all its
4652 /// [transitions.travel_distance_meters][google.maps.routeoptimization.v1.ShipmentRoute.Transition.travel_distance_meters].
4653 ///
4654 /// [google.maps.routeoptimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
4655 pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
4656
4657 /// Specifies a map from visit_types strings to durations. The duration is time
4658 /// in addition to
4659 /// [VisitRequest.duration][google.maps.routeoptimization.v1.Shipment.VisitRequest.duration]
4660 /// to be taken at visits with the specified `visit_types`. This extra visit
4661 /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
4662 /// `visit_types`) cannot be empty strings.
4663 ///
4664 /// If a visit request has multiple types, a duration will be added for each
4665 /// type in the map.
4666 ///
4667 /// [google.maps.routeoptimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
4668 pub extra_visit_duration_for_visit_type:
4669 std::collections::HashMap<std::string::String, wkt::Duration>,
4670
4671 /// Describes the break schedule to be enforced on this vehicle.
4672 /// If empty, no breaks will be scheduled for this vehicle.
4673 pub break_rule: std::option::Option<crate::model::BreakRule>,
4674
4675 /// Specifies a label for this vehicle. This label is reported in the response
4676 /// as the `vehicle_label` of the corresponding
4677 /// [ShipmentRoute][google.maps.routeoptimization.v1.ShipmentRoute].
4678 ///
4679 /// [google.maps.routeoptimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
4680 pub label: std::string::String,
4681
4682 /// If true, `used_if_route_is_empty` must be false, and this vehicle will
4683 /// remain unused.
4684 ///
4685 /// If a shipment is performed by an ignored vehicle in
4686 /// `injected_first_solution_routes`, it is skipped in the first solution but
4687 /// is free to be performed in the response.
4688 ///
4689 /// If a shipment is performed by an ignored vehicle in
4690 /// `injected_solution_constraint` and any related pickup/delivery is
4691 /// constrained to remain on the vehicle (i.e., not relaxed to level
4692 /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
4693 /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
4694 /// the allowed vehicles are ignored, it is skipped in the response.
4695 pub ignore: bool,
4696
4697 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4698}
4699
4700impl Vehicle {
4701 /// Creates a new default instance.
4702 pub fn new() -> Self {
4703 std::default::Default::default()
4704 }
4705
4706 /// Sets the value of [display_name][crate::model::Vehicle::display_name].
4707 ///
4708 /// # Example
4709 /// ```ignore,no_run
4710 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4711 /// let x = Vehicle::new().set_display_name("example");
4712 /// ```
4713 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4714 self.display_name = v.into();
4715 self
4716 }
4717
4718 /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
4719 ///
4720 /// # Example
4721 /// ```ignore,no_run
4722 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4723 /// use google_maps_routeoptimization_v1::model::vehicle::TravelMode;
4724 /// let x0 = Vehicle::new().set_travel_mode(TravelMode::Driving);
4725 /// let x1 = Vehicle::new().set_travel_mode(TravelMode::Walking);
4726 /// ```
4727 pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
4728 mut self,
4729 v: T,
4730 ) -> Self {
4731 self.travel_mode = v.into();
4732 self
4733 }
4734
4735 /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
4736 ///
4737 /// # Example
4738 /// ```ignore,no_run
4739 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4740 /// use google_maps_routeoptimization_v1::model::RouteModifiers;
4741 /// let x = Vehicle::new().set_route_modifiers(RouteModifiers::default()/* use setters */);
4742 /// ```
4743 pub fn set_route_modifiers<T>(mut self, v: T) -> Self
4744 where
4745 T: std::convert::Into<crate::model::RouteModifiers>,
4746 {
4747 self.route_modifiers = std::option::Option::Some(v.into());
4748 self
4749 }
4750
4751 /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
4752 ///
4753 /// # Example
4754 /// ```ignore,no_run
4755 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4756 /// use google_maps_routeoptimization_v1::model::RouteModifiers;
4757 /// let x = Vehicle::new().set_or_clear_route_modifiers(Some(RouteModifiers::default()/* use setters */));
4758 /// let x = Vehicle::new().set_or_clear_route_modifiers(None::<RouteModifiers>);
4759 /// ```
4760 pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
4761 where
4762 T: std::convert::Into<crate::model::RouteModifiers>,
4763 {
4764 self.route_modifiers = v.map(|x| x.into());
4765 self
4766 }
4767
4768 /// Sets the value of [start_location][crate::model::Vehicle::start_location].
4769 ///
4770 /// # Example
4771 /// ```ignore,no_run
4772 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4773 /// use google_cloud_type::model::LatLng;
4774 /// let x = Vehicle::new().set_start_location(LatLng::default()/* use setters */);
4775 /// ```
4776 pub fn set_start_location<T>(mut self, v: T) -> Self
4777 where
4778 T: std::convert::Into<google_cloud_type::model::LatLng>,
4779 {
4780 self.start_location = std::option::Option::Some(v.into());
4781 self
4782 }
4783
4784 /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
4785 ///
4786 /// # Example
4787 /// ```ignore,no_run
4788 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4789 /// use google_cloud_type::model::LatLng;
4790 /// let x = Vehicle::new().set_or_clear_start_location(Some(LatLng::default()/* use setters */));
4791 /// let x = Vehicle::new().set_or_clear_start_location(None::<LatLng>);
4792 /// ```
4793 pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
4794 where
4795 T: std::convert::Into<google_cloud_type::model::LatLng>,
4796 {
4797 self.start_location = v.map(|x| x.into());
4798 self
4799 }
4800
4801 /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
4802 ///
4803 /// # Example
4804 /// ```ignore,no_run
4805 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4806 /// use google_maps_routeoptimization_v1::model::Waypoint;
4807 /// let x = Vehicle::new().set_start_waypoint(Waypoint::default()/* use setters */);
4808 /// ```
4809 pub fn set_start_waypoint<T>(mut self, v: T) -> Self
4810 where
4811 T: std::convert::Into<crate::model::Waypoint>,
4812 {
4813 self.start_waypoint = std::option::Option::Some(v.into());
4814 self
4815 }
4816
4817 /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
4818 ///
4819 /// # Example
4820 /// ```ignore,no_run
4821 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4822 /// use google_maps_routeoptimization_v1::model::Waypoint;
4823 /// let x = Vehicle::new().set_or_clear_start_waypoint(Some(Waypoint::default()/* use setters */));
4824 /// let x = Vehicle::new().set_or_clear_start_waypoint(None::<Waypoint>);
4825 /// ```
4826 pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4827 where
4828 T: std::convert::Into<crate::model::Waypoint>,
4829 {
4830 self.start_waypoint = v.map(|x| x.into());
4831 self
4832 }
4833
4834 /// Sets the value of [end_location][crate::model::Vehicle::end_location].
4835 ///
4836 /// # Example
4837 /// ```ignore,no_run
4838 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4839 /// use google_cloud_type::model::LatLng;
4840 /// let x = Vehicle::new().set_end_location(LatLng::default()/* use setters */);
4841 /// ```
4842 pub fn set_end_location<T>(mut self, v: T) -> Self
4843 where
4844 T: std::convert::Into<google_cloud_type::model::LatLng>,
4845 {
4846 self.end_location = std::option::Option::Some(v.into());
4847 self
4848 }
4849
4850 /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
4851 ///
4852 /// # Example
4853 /// ```ignore,no_run
4854 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4855 /// use google_cloud_type::model::LatLng;
4856 /// let x = Vehicle::new().set_or_clear_end_location(Some(LatLng::default()/* use setters */));
4857 /// let x = Vehicle::new().set_or_clear_end_location(None::<LatLng>);
4858 /// ```
4859 pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
4860 where
4861 T: std::convert::Into<google_cloud_type::model::LatLng>,
4862 {
4863 self.end_location = v.map(|x| x.into());
4864 self
4865 }
4866
4867 /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
4868 ///
4869 /// # Example
4870 /// ```ignore,no_run
4871 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4872 /// use google_maps_routeoptimization_v1::model::Waypoint;
4873 /// let x = Vehicle::new().set_end_waypoint(Waypoint::default()/* use setters */);
4874 /// ```
4875 pub fn set_end_waypoint<T>(mut self, v: T) -> Self
4876 where
4877 T: std::convert::Into<crate::model::Waypoint>,
4878 {
4879 self.end_waypoint = std::option::Option::Some(v.into());
4880 self
4881 }
4882
4883 /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
4884 ///
4885 /// # Example
4886 /// ```ignore,no_run
4887 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4888 /// use google_maps_routeoptimization_v1::model::Waypoint;
4889 /// let x = Vehicle::new().set_or_clear_end_waypoint(Some(Waypoint::default()/* use setters */));
4890 /// let x = Vehicle::new().set_or_clear_end_waypoint(None::<Waypoint>);
4891 /// ```
4892 pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4893 where
4894 T: std::convert::Into<crate::model::Waypoint>,
4895 {
4896 self.end_waypoint = v.map(|x| x.into());
4897 self
4898 }
4899
4900 /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
4901 ///
4902 /// # Example
4903 /// ```ignore,no_run
4904 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4905 /// let x = Vehicle::new().set_start_tags(["a", "b", "c"]);
4906 /// ```
4907 pub fn set_start_tags<T, V>(mut self, v: T) -> Self
4908 where
4909 T: std::iter::IntoIterator<Item = V>,
4910 V: std::convert::Into<std::string::String>,
4911 {
4912 use std::iter::Iterator;
4913 self.start_tags = v.into_iter().map(|i| i.into()).collect();
4914 self
4915 }
4916
4917 /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
4918 ///
4919 /// # Example
4920 /// ```ignore,no_run
4921 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4922 /// let x = Vehicle::new().set_end_tags(["a", "b", "c"]);
4923 /// ```
4924 pub fn set_end_tags<T, V>(mut self, v: T) -> Self
4925 where
4926 T: std::iter::IntoIterator<Item = V>,
4927 V: std::convert::Into<std::string::String>,
4928 {
4929 use std::iter::Iterator;
4930 self.end_tags = v.into_iter().map(|i| i.into()).collect();
4931 self
4932 }
4933
4934 /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
4935 ///
4936 /// # Example
4937 /// ```ignore,no_run
4938 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4939 /// use google_maps_routeoptimization_v1::model::TimeWindow;
4940 /// let x = Vehicle::new()
4941 /// .set_start_time_windows([
4942 /// TimeWindow::default()/* use setters */,
4943 /// TimeWindow::default()/* use (different) setters */,
4944 /// ]);
4945 /// ```
4946 pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
4947 where
4948 T: std::iter::IntoIterator<Item = V>,
4949 V: std::convert::Into<crate::model::TimeWindow>,
4950 {
4951 use std::iter::Iterator;
4952 self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
4953 self
4954 }
4955
4956 /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
4957 ///
4958 /// # Example
4959 /// ```ignore,no_run
4960 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4961 /// use google_maps_routeoptimization_v1::model::TimeWindow;
4962 /// let x = Vehicle::new()
4963 /// .set_end_time_windows([
4964 /// TimeWindow::default()/* use setters */,
4965 /// TimeWindow::default()/* use (different) setters */,
4966 /// ]);
4967 /// ```
4968 pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
4969 where
4970 T: std::iter::IntoIterator<Item = V>,
4971 V: std::convert::Into<crate::model::TimeWindow>,
4972 {
4973 use std::iter::Iterator;
4974 self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
4975 self
4976 }
4977
4978 /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
4979 ///
4980 /// # Example
4981 /// ```ignore,no_run
4982 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4983 /// let x = Vehicle::new().set_travel_duration_multiple(42.0);
4984 /// ```
4985 pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
4986 where
4987 T: std::convert::Into<f64>,
4988 {
4989 self.travel_duration_multiple = std::option::Option::Some(v.into());
4990 self
4991 }
4992
4993 /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
4994 ///
4995 /// # Example
4996 /// ```ignore,no_run
4997 /// # use google_maps_routeoptimization_v1::model::Vehicle;
4998 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(Some(42.0));
4999 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(None::<f32>);
5000 /// ```
5001 pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
5002 where
5003 T: std::convert::Into<f64>,
5004 {
5005 self.travel_duration_multiple = v.map(|x| x.into());
5006 self
5007 }
5008
5009 /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
5010 ///
5011 /// # Example
5012 /// ```ignore,no_run
5013 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5014 /// use google_maps_routeoptimization_v1::model::vehicle::UnloadingPolicy;
5015 /// let x0 = Vehicle::new().set_unloading_policy(UnloadingPolicy::LastInFirstOut);
5016 /// let x1 = Vehicle::new().set_unloading_policy(UnloadingPolicy::FirstInFirstOut);
5017 /// ```
5018 pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
5019 mut self,
5020 v: T,
5021 ) -> Self {
5022 self.unloading_policy = v.into();
5023 self
5024 }
5025
5026 /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
5027 ///
5028 /// # Example
5029 /// ```ignore,no_run
5030 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5031 /// use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5032 /// let x = Vehicle::new().set_load_limits([
5033 /// ("key0", LoadLimit::default()/* use setters */),
5034 /// ("key1", LoadLimit::default()/* use (different) setters */),
5035 /// ]);
5036 /// ```
5037 pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
5038 where
5039 T: std::iter::IntoIterator<Item = (K, V)>,
5040 K: std::convert::Into<std::string::String>,
5041 V: std::convert::Into<crate::model::vehicle::LoadLimit>,
5042 {
5043 use std::iter::Iterator;
5044 self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5045 self
5046 }
5047
5048 /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
5049 ///
5050 /// # Example
5051 /// ```ignore,no_run
5052 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5053 /// let x = Vehicle::new().set_cost_per_hour(42.0);
5054 /// ```
5055 pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5056 self.cost_per_hour = v.into();
5057 self
5058 }
5059
5060 /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
5061 ///
5062 /// # Example
5063 /// ```ignore,no_run
5064 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5065 /// let x = Vehicle::new().set_cost_per_traveled_hour(42.0);
5066 /// ```
5067 pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5068 self.cost_per_traveled_hour = v.into();
5069 self
5070 }
5071
5072 /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
5073 ///
5074 /// # Example
5075 /// ```ignore,no_run
5076 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5077 /// let x = Vehicle::new().set_cost_per_kilometer(42.0);
5078 /// ```
5079 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5080 self.cost_per_kilometer = v.into();
5081 self
5082 }
5083
5084 /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
5085 ///
5086 /// # Example
5087 /// ```ignore,no_run
5088 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5089 /// let x = Vehicle::new().set_fixed_cost(42.0);
5090 /// ```
5091 pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5092 self.fixed_cost = v.into();
5093 self
5094 }
5095
5096 /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
5097 ///
5098 /// # Example
5099 /// ```ignore,no_run
5100 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5101 /// let x = Vehicle::new().set_used_if_route_is_empty(true);
5102 /// ```
5103 pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5104 self.used_if_route_is_empty = v.into();
5105 self
5106 }
5107
5108 /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5109 ///
5110 /// # Example
5111 /// ```ignore,no_run
5112 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5113 /// use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
5114 /// let x = Vehicle::new().set_route_duration_limit(DurationLimit::default()/* use setters */);
5115 /// ```
5116 pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
5117 where
5118 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5119 {
5120 self.route_duration_limit = std::option::Option::Some(v.into());
5121 self
5122 }
5123
5124 /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5125 ///
5126 /// # Example
5127 /// ```ignore,no_run
5128 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5129 /// use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
5130 /// let x = Vehicle::new().set_or_clear_route_duration_limit(Some(DurationLimit::default()/* use setters */));
5131 /// let x = Vehicle::new().set_or_clear_route_duration_limit(None::<DurationLimit>);
5132 /// ```
5133 pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5134 where
5135 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5136 {
5137 self.route_duration_limit = v.map(|x| x.into());
5138 self
5139 }
5140
5141 /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5142 ///
5143 /// # Example
5144 /// ```ignore,no_run
5145 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5146 /// use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
5147 /// let x = Vehicle::new().set_travel_duration_limit(DurationLimit::default()/* use setters */);
5148 /// ```
5149 pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
5150 where
5151 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5152 {
5153 self.travel_duration_limit = std::option::Option::Some(v.into());
5154 self
5155 }
5156
5157 /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5158 ///
5159 /// # Example
5160 /// ```ignore,no_run
5161 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5162 /// use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
5163 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(Some(DurationLimit::default()/* use setters */));
5164 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(None::<DurationLimit>);
5165 /// ```
5166 pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5167 where
5168 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5169 {
5170 self.travel_duration_limit = v.map(|x| x.into());
5171 self
5172 }
5173
5174 /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5175 ///
5176 /// # Example
5177 /// ```ignore,no_run
5178 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5179 /// use google_maps_routeoptimization_v1::model::DistanceLimit;
5180 /// let x = Vehicle::new().set_route_distance_limit(DistanceLimit::default()/* use setters */);
5181 /// ```
5182 pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
5183 where
5184 T: std::convert::Into<crate::model::DistanceLimit>,
5185 {
5186 self.route_distance_limit = std::option::Option::Some(v.into());
5187 self
5188 }
5189
5190 /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5191 ///
5192 /// # Example
5193 /// ```ignore,no_run
5194 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5195 /// use google_maps_routeoptimization_v1::model::DistanceLimit;
5196 /// let x = Vehicle::new().set_or_clear_route_distance_limit(Some(DistanceLimit::default()/* use setters */));
5197 /// let x = Vehicle::new().set_or_clear_route_distance_limit(None::<DistanceLimit>);
5198 /// ```
5199 pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
5200 where
5201 T: std::convert::Into<crate::model::DistanceLimit>,
5202 {
5203 self.route_distance_limit = v.map(|x| x.into());
5204 self
5205 }
5206
5207 /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
5208 ///
5209 /// # Example
5210 /// ```ignore,no_run
5211 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5212 /// use wkt::Duration;
5213 /// let x = Vehicle::new().set_extra_visit_duration_for_visit_type([
5214 /// ("key0", Duration::default()/* use setters */),
5215 /// ("key1", Duration::default()/* use (different) setters */),
5216 /// ]);
5217 /// ```
5218 pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
5219 where
5220 T: std::iter::IntoIterator<Item = (K, V)>,
5221 K: std::convert::Into<std::string::String>,
5222 V: std::convert::Into<wkt::Duration>,
5223 {
5224 use std::iter::Iterator;
5225 self.extra_visit_duration_for_visit_type =
5226 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5227 self
5228 }
5229
5230 /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
5231 ///
5232 /// # Example
5233 /// ```ignore,no_run
5234 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5235 /// use google_maps_routeoptimization_v1::model::BreakRule;
5236 /// let x = Vehicle::new().set_break_rule(BreakRule::default()/* use setters */);
5237 /// ```
5238 pub fn set_break_rule<T>(mut self, v: T) -> Self
5239 where
5240 T: std::convert::Into<crate::model::BreakRule>,
5241 {
5242 self.break_rule = std::option::Option::Some(v.into());
5243 self
5244 }
5245
5246 /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
5247 ///
5248 /// # Example
5249 /// ```ignore,no_run
5250 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5251 /// use google_maps_routeoptimization_v1::model::BreakRule;
5252 /// let x = Vehicle::new().set_or_clear_break_rule(Some(BreakRule::default()/* use setters */));
5253 /// let x = Vehicle::new().set_or_clear_break_rule(None::<BreakRule>);
5254 /// ```
5255 pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
5256 where
5257 T: std::convert::Into<crate::model::BreakRule>,
5258 {
5259 self.break_rule = v.map(|x| x.into());
5260 self
5261 }
5262
5263 /// Sets the value of [label][crate::model::Vehicle::label].
5264 ///
5265 /// # Example
5266 /// ```ignore,no_run
5267 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5268 /// let x = Vehicle::new().set_label("example");
5269 /// ```
5270 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5271 self.label = v.into();
5272 self
5273 }
5274
5275 /// Sets the value of [ignore][crate::model::Vehicle::ignore].
5276 ///
5277 /// # Example
5278 /// ```ignore,no_run
5279 /// # use google_maps_routeoptimization_v1::model::Vehicle;
5280 /// let x = Vehicle::new().set_ignore(true);
5281 /// ```
5282 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5283 self.ignore = v.into();
5284 self
5285 }
5286}
5287
5288impl wkt::message::Message for Vehicle {
5289 fn typename() -> &'static str {
5290 "type.googleapis.com/google.maps.routeoptimization.v1.Vehicle"
5291 }
5292}
5293
5294/// Defines additional types related to [Vehicle].
5295pub mod vehicle {
5296 #[allow(unused_imports)]
5297 use super::*;
5298
5299 /// Defines a load limit applying to a vehicle, e.g. "this truck may only
5300 /// carry up to 3500 kg". See
5301 /// [load_limits][google.maps.routeoptimization.v1.Vehicle.load_limits].
5302 ///
5303 /// [google.maps.routeoptimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5304 #[derive(Clone, Default, PartialEq)]
5305 #[non_exhaustive]
5306 pub struct LoadLimit {
5307 /// The maximum acceptable amount of load.
5308 pub max_load: std::option::Option<i64>,
5309
5310 /// A soft limit of the load. See
5311 /// [cost_per_unit_above_soft_max][google.maps.routeoptimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
5312 ///
5313 /// [google.maps.routeoptimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5314 pub soft_max_load: i64,
5315
5316 /// If the load ever exceeds
5317 /// [soft_max_load][google.maps.routeoptimization.v1.Vehicle.LoadLimit.soft_max_load]
5318 /// along this vehicle's route, the following cost penalty applies (only once
5319 /// per vehicle): (load -
5320 /// [soft_max_load][google.maps.routeoptimization.v1.Vehicle.LoadLimit.soft_max_load])
5321 ///
5322 /// * [cost_per_unit_above_soft_max][google.maps.routeoptimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
5323 /// add up and must be in the same unit as
5324 /// [Shipment.penalty_cost][google.maps.routeoptimization.v1.Shipment.penalty_cost].
5325 /// Soft limits may only be defined on types that apply to either pickups
5326 /// only or deliveries only throughout the model.
5327 ///
5328 /// [google.maps.routeoptimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
5329 /// [google.maps.routeoptimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5330 /// [google.maps.routeoptimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
5331 pub cost_per_unit_above_soft_max: f64,
5332
5333 /// The acceptable load interval of the vehicle at the start of the route.
5334 pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5335
5336 /// The acceptable load interval of the vehicle at the end of the route.
5337 pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5338
5339 /// Cost of moving one unit of load over one kilometer for this vehicle.
5340 /// This can be used as a proxy for fuel consumption: if the load is a weight
5341 /// (in Newtons), then load*kilometer has the dimension of an energy.
5342 ///
5343 /// Experimental: See
5344 /// <https://developers.google.com/maps/tt/route-optimization/experimental/load-cost/make-request>
5345 /// for more details.
5346 pub cost_per_kilometer: std::option::Option<crate::model::vehicle::load_limit::LoadCost>,
5347
5348 /// Cost of traveling with a unit of load during one hour for this vehicle.
5349 ///
5350 /// Experimental: See
5351 /// <https://developers.google.com/maps/tt/route-optimization/experimental/load-cost/make-request>
5352 /// for more details.
5353 pub cost_per_traveled_hour:
5354 std::option::Option<crate::model::vehicle::load_limit::LoadCost>,
5355
5356 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5357 }
5358
5359 impl LoadLimit {
5360 /// Creates a new default instance.
5361 pub fn new() -> Self {
5362 std::default::Default::default()
5363 }
5364
5365 /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5366 ///
5367 /// # Example
5368 /// ```ignore,no_run
5369 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5370 /// let x = LoadLimit::new().set_max_load(42);
5371 /// ```
5372 pub fn set_max_load<T>(mut self, v: T) -> Self
5373 where
5374 T: std::convert::Into<i64>,
5375 {
5376 self.max_load = std::option::Option::Some(v.into());
5377 self
5378 }
5379
5380 /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5381 ///
5382 /// # Example
5383 /// ```ignore,no_run
5384 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5385 /// let x = LoadLimit::new().set_or_clear_max_load(Some(42));
5386 /// let x = LoadLimit::new().set_or_clear_max_load(None::<i32>);
5387 /// ```
5388 pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
5389 where
5390 T: std::convert::Into<i64>,
5391 {
5392 self.max_load = v.map(|x| x.into());
5393 self
5394 }
5395
5396 /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
5397 ///
5398 /// # Example
5399 /// ```ignore,no_run
5400 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5401 /// let x = LoadLimit::new().set_soft_max_load(42);
5402 /// ```
5403 pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5404 self.soft_max_load = v.into();
5405 self
5406 }
5407
5408 /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
5409 ///
5410 /// # Example
5411 /// ```ignore,no_run
5412 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5413 /// let x = LoadLimit::new().set_cost_per_unit_above_soft_max(42.0);
5414 /// ```
5415 pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
5416 mut self,
5417 v: T,
5418 ) -> Self {
5419 self.cost_per_unit_above_soft_max = v.into();
5420 self
5421 }
5422
5423 /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5424 ///
5425 /// # Example
5426 /// ```ignore,no_run
5427 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5428 /// use google_maps_routeoptimization_v1::model::vehicle::load_limit::Interval;
5429 /// let x = LoadLimit::new().set_start_load_interval(Interval::default()/* use setters */);
5430 /// ```
5431 pub fn set_start_load_interval<T>(mut self, v: T) -> Self
5432 where
5433 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5434 {
5435 self.start_load_interval = std::option::Option::Some(v.into());
5436 self
5437 }
5438
5439 /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5440 ///
5441 /// # Example
5442 /// ```ignore,no_run
5443 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5444 /// use google_maps_routeoptimization_v1::model::vehicle::load_limit::Interval;
5445 /// let x = LoadLimit::new().set_or_clear_start_load_interval(Some(Interval::default()/* use setters */));
5446 /// let x = LoadLimit::new().set_or_clear_start_load_interval(None::<Interval>);
5447 /// ```
5448 pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5449 where
5450 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5451 {
5452 self.start_load_interval = v.map(|x| x.into());
5453 self
5454 }
5455
5456 /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5457 ///
5458 /// # Example
5459 /// ```ignore,no_run
5460 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5461 /// use google_maps_routeoptimization_v1::model::vehicle::load_limit::Interval;
5462 /// let x = LoadLimit::new().set_end_load_interval(Interval::default()/* use setters */);
5463 /// ```
5464 pub fn set_end_load_interval<T>(mut self, v: T) -> Self
5465 where
5466 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5467 {
5468 self.end_load_interval = std::option::Option::Some(v.into());
5469 self
5470 }
5471
5472 /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5473 ///
5474 /// # Example
5475 /// ```ignore,no_run
5476 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5477 /// use google_maps_routeoptimization_v1::model::vehicle::load_limit::Interval;
5478 /// let x = LoadLimit::new().set_or_clear_end_load_interval(Some(Interval::default()/* use setters */));
5479 /// let x = LoadLimit::new().set_or_clear_end_load_interval(None::<Interval>);
5480 /// ```
5481 pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5482 where
5483 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5484 {
5485 self.end_load_interval = v.map(|x| x.into());
5486 self
5487 }
5488
5489 /// Sets the value of [cost_per_kilometer][crate::model::vehicle::LoadLimit::cost_per_kilometer].
5490 ///
5491 /// # Example
5492 /// ```ignore,no_run
5493 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5494 /// use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5495 /// let x = LoadLimit::new().set_cost_per_kilometer(LoadCost::default()/* use setters */);
5496 /// ```
5497 pub fn set_cost_per_kilometer<T>(mut self, v: T) -> Self
5498 where
5499 T: std::convert::Into<crate::model::vehicle::load_limit::LoadCost>,
5500 {
5501 self.cost_per_kilometer = std::option::Option::Some(v.into());
5502 self
5503 }
5504
5505 /// Sets or clears the value of [cost_per_kilometer][crate::model::vehicle::LoadLimit::cost_per_kilometer].
5506 ///
5507 /// # Example
5508 /// ```ignore,no_run
5509 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5510 /// use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5511 /// let x = LoadLimit::new().set_or_clear_cost_per_kilometer(Some(LoadCost::default()/* use setters */));
5512 /// let x = LoadLimit::new().set_or_clear_cost_per_kilometer(None::<LoadCost>);
5513 /// ```
5514 pub fn set_or_clear_cost_per_kilometer<T>(mut self, v: std::option::Option<T>) -> Self
5515 where
5516 T: std::convert::Into<crate::model::vehicle::load_limit::LoadCost>,
5517 {
5518 self.cost_per_kilometer = v.map(|x| x.into());
5519 self
5520 }
5521
5522 /// Sets the value of [cost_per_traveled_hour][crate::model::vehicle::LoadLimit::cost_per_traveled_hour].
5523 ///
5524 /// # Example
5525 /// ```ignore,no_run
5526 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5527 /// use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5528 /// let x = LoadLimit::new().set_cost_per_traveled_hour(LoadCost::default()/* use setters */);
5529 /// ```
5530 pub fn set_cost_per_traveled_hour<T>(mut self, v: T) -> Self
5531 where
5532 T: std::convert::Into<crate::model::vehicle::load_limit::LoadCost>,
5533 {
5534 self.cost_per_traveled_hour = std::option::Option::Some(v.into());
5535 self
5536 }
5537
5538 /// Sets or clears the value of [cost_per_traveled_hour][crate::model::vehicle::LoadLimit::cost_per_traveled_hour].
5539 ///
5540 /// # Example
5541 /// ```ignore,no_run
5542 /// # use google_maps_routeoptimization_v1::model::vehicle::LoadLimit;
5543 /// use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5544 /// let x = LoadLimit::new().set_or_clear_cost_per_traveled_hour(Some(LoadCost::default()/* use setters */));
5545 /// let x = LoadLimit::new().set_or_clear_cost_per_traveled_hour(None::<LoadCost>);
5546 /// ```
5547 pub fn set_or_clear_cost_per_traveled_hour<T>(mut self, v: std::option::Option<T>) -> Self
5548 where
5549 T: std::convert::Into<crate::model::vehicle::load_limit::LoadCost>,
5550 {
5551 self.cost_per_traveled_hour = v.map(|x| x.into());
5552 self
5553 }
5554 }
5555
5556 impl wkt::message::Message for LoadLimit {
5557 fn typename() -> &'static str {
5558 "type.googleapis.com/google.maps.routeoptimization.v1.Vehicle.LoadLimit"
5559 }
5560 }
5561
5562 /// Defines additional types related to [LoadLimit].
5563 pub mod load_limit {
5564 #[allow(unused_imports)]
5565 use super::*;
5566
5567 /// Interval of acceptable load amounts.
5568 #[derive(Clone, Default, PartialEq)]
5569 #[non_exhaustive]
5570 pub struct Interval {
5571 /// A minimum acceptable load. Must be ≥ 0.
5572 /// If they're both specified,
5573 /// [min][google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval.min]
5574 /// must be ≤
5575 /// [max][google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval.max].
5576 ///
5577 /// [google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
5578 /// [google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
5579 pub min: i64,
5580
5581 /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
5582 /// load is unrestricted by this message.
5583 /// If they're both specified,
5584 /// [min][google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval.min]
5585 /// must be ≤
5586 /// [max][google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval.max].
5587 ///
5588 /// [google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
5589 /// [google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
5590 pub max: std::option::Option<i64>,
5591
5592 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5593 }
5594
5595 impl Interval {
5596 /// Creates a new default instance.
5597 pub fn new() -> Self {
5598 std::default::Default::default()
5599 }
5600
5601 /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
5602 ///
5603 /// # Example
5604 /// ```ignore,no_run
5605 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::Interval;
5606 /// let x = Interval::new().set_min(42);
5607 /// ```
5608 pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5609 self.min = v.into();
5610 self
5611 }
5612
5613 /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
5614 ///
5615 /// # Example
5616 /// ```ignore,no_run
5617 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::Interval;
5618 /// let x = Interval::new().set_max(42);
5619 /// ```
5620 pub fn set_max<T>(mut self, v: T) -> Self
5621 where
5622 T: std::convert::Into<i64>,
5623 {
5624 self.max = std::option::Option::Some(v.into());
5625 self
5626 }
5627
5628 /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
5629 ///
5630 /// # Example
5631 /// ```ignore,no_run
5632 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::Interval;
5633 /// let x = Interval::new().set_or_clear_max(Some(42));
5634 /// let x = Interval::new().set_or_clear_max(None::<i32>);
5635 /// ```
5636 pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
5637 where
5638 T: std::convert::Into<i64>,
5639 {
5640 self.max = v.map(|x| x.into());
5641 self
5642 }
5643 }
5644
5645 impl wkt::message::Message for Interval {
5646 fn typename() -> &'static str {
5647 "type.googleapis.com/google.maps.routeoptimization.v1.Vehicle.LoadLimit.Interval"
5648 }
5649 }
5650
5651 /// Cost of moving one unit of load during a `Transition`.
5652 /// For a given load, the cost is the sum of two parts:
5653 ///
5654 /// - min(load, `load_threshold`) * `cost_per_unit_below_threshold`
5655 /// - max(0, load - `load_threshold`) * `cost_per_unit_above_threshold`
5656 ///
5657 /// With this cost, solutions prefer to deliver high demands first,
5658 /// or equivalently pickup high demands last.
5659 /// For example, if a vehicle has
5660 ///
5661 /// ```norust
5662 /// load_limit {
5663 /// key: "weight"
5664 /// value {
5665 /// cost_per_kilometer {
5666 /// load_threshold: 15
5667 /// cost_per_unit_below_threshold: 2.0
5668 /// cost_per_unit_above_threshold: 10.0
5669 /// }
5670 /// }
5671 /// }
5672 /// ```
5673 ///
5674 /// and its route is start,pickup,pickup,delivery,delivery,end with
5675 /// transitions:
5676 ///
5677 /// ```norust
5678 /// transition { vehicle_load['weight'] { amount: 0 }
5679 /// travel_distance_meters: 1000.0 }
5680 /// transition { vehicle_load['weight'] { amount: 10 }
5681 /// travel_distance_meters: 1000.0 }
5682 /// transition { vehicle_load['weight'] { amount: 20 }
5683 /// travel_distance_meters: 1000.0 }
5684 /// transition { vehicle_load['weight'] { amount: 10 }
5685 /// travel_distance_meters: 1000.0 }
5686 /// transition { vehicle_load['weight'] { amount: 0 }
5687 /// travel_distance_meters: 1000.0 }
5688 /// ```
5689 ///
5690 /// then the cost incurred by this `LoadCost` is
5691 /// (cost_below * load_below * kilometers + cost_above * load_above * kms)
5692 ///
5693 /// - transition 0: 0.0
5694 /// - transition 1: 2.0 * 10 * 1.0 + 10.0 * 0 * 1.0 = 20.0
5695 /// - transition 2: 2.0 * 15 * 1.0 + 10.0 * (20 - 15) * 1.0 = 80.0
5696 /// - transition 3: 2.0 * 10 * 1.0 + 10.0 * 0 * 1.0 = 20.0
5697 /// - transition 4: 0.0
5698 ///
5699 /// So the `LoadCost` over the route is 120.0.
5700 ///
5701 /// However, if the route is start,pickup,delivery,pickup,delivery,end
5702 /// with transitions:
5703 ///
5704 /// ```norust
5705 /// transition { vehicle_load['weight'] { amount: 0 }
5706 /// travel_distance_meters: 1000.0 }
5707 /// transition { vehicle_load['weight'] { amount: 10 }
5708 /// travel_distance_meters: 1000.0 }
5709 /// transition { vehicle_load['weight'] { amount: 0 }
5710 /// travel_distance_meters: 1000.0 }
5711 /// transition { vehicle_load['weight'] { amount: 10 }
5712 /// travel_distance_meters: 1000.0 }
5713 /// transition { vehicle_load['weight'] { amount: 0 }
5714 /// travel_distance_meters: 1000.0 }
5715 /// ```
5716 ///
5717 /// then the cost incurred by this `LoadCost` is
5718 ///
5719 /// - transition 0: 0.0
5720 /// - transition 1: 2.0 * 10 * 1.0 + 10.0 * 0 * 1.0 = 20.0
5721 /// - transition 2: 0.0
5722 /// - transition 3: 2.0 * 10 * 1.0 + 10.0 * 0 * 1.0 = 20.0
5723 /// - transition 4: 0.0
5724 ///
5725 /// Here the `LoadCost` over the route is 40.0.
5726 ///
5727 /// `LoadCost` makes solutions with heavy-loaded transitions more expensive.
5728 ///
5729 /// Experimental: See
5730 /// <https://developers.google.com/maps/tt/route-optimization/experimental/load-cost/make-request>
5731 /// for more details.
5732 #[derive(Clone, Default, PartialEq)]
5733 #[non_exhaustive]
5734 pub struct LoadCost {
5735 /// Amount of load above which the cost of moving a unit of load changes
5736 /// from cost_per_unit_below_threshold to cost_per_unit_above_threshold.
5737 /// Must be >= 0.
5738 pub load_threshold: std::option::Option<i64>,
5739
5740 /// Cost of moving a unit of load, for each unit between 0 and threshold.
5741 /// Must be a finite value, and >= 0.
5742 pub cost_per_unit_below_threshold: std::option::Option<f64>,
5743
5744 /// Cost of moving a unit of load, for each unit above threshold.
5745 /// In the special case threshold = 0, this is a fixed cost per unit.
5746 /// Must be a finite value, and >= 0.
5747 pub cost_per_unit_above_threshold: std::option::Option<f64>,
5748
5749 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5750 }
5751
5752 impl LoadCost {
5753 /// Creates a new default instance.
5754 pub fn new() -> Self {
5755 std::default::Default::default()
5756 }
5757
5758 /// Sets the value of [load_threshold][crate::model::vehicle::load_limit::LoadCost::load_threshold].
5759 ///
5760 /// # Example
5761 /// ```ignore,no_run
5762 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5763 /// let x = LoadCost::new().set_load_threshold(42);
5764 /// ```
5765 pub fn set_load_threshold<T>(mut self, v: T) -> Self
5766 where
5767 T: std::convert::Into<i64>,
5768 {
5769 self.load_threshold = std::option::Option::Some(v.into());
5770 self
5771 }
5772
5773 /// Sets or clears the value of [load_threshold][crate::model::vehicle::load_limit::LoadCost::load_threshold].
5774 ///
5775 /// # Example
5776 /// ```ignore,no_run
5777 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5778 /// let x = LoadCost::new().set_or_clear_load_threshold(Some(42));
5779 /// let x = LoadCost::new().set_or_clear_load_threshold(None::<i32>);
5780 /// ```
5781 pub fn set_or_clear_load_threshold<T>(mut self, v: std::option::Option<T>) -> Self
5782 where
5783 T: std::convert::Into<i64>,
5784 {
5785 self.load_threshold = v.map(|x| x.into());
5786 self
5787 }
5788
5789 /// Sets the value of [cost_per_unit_below_threshold][crate::model::vehicle::load_limit::LoadCost::cost_per_unit_below_threshold].
5790 ///
5791 /// # Example
5792 /// ```ignore,no_run
5793 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5794 /// let x = LoadCost::new().set_cost_per_unit_below_threshold(42.0);
5795 /// ```
5796 pub fn set_cost_per_unit_below_threshold<T>(mut self, v: T) -> Self
5797 where
5798 T: std::convert::Into<f64>,
5799 {
5800 self.cost_per_unit_below_threshold = std::option::Option::Some(v.into());
5801 self
5802 }
5803
5804 /// Sets or clears the value of [cost_per_unit_below_threshold][crate::model::vehicle::load_limit::LoadCost::cost_per_unit_below_threshold].
5805 ///
5806 /// # Example
5807 /// ```ignore,no_run
5808 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5809 /// let x = LoadCost::new().set_or_clear_cost_per_unit_below_threshold(Some(42.0));
5810 /// let x = LoadCost::new().set_or_clear_cost_per_unit_below_threshold(None::<f32>);
5811 /// ```
5812 pub fn set_or_clear_cost_per_unit_below_threshold<T>(
5813 mut self,
5814 v: std::option::Option<T>,
5815 ) -> Self
5816 where
5817 T: std::convert::Into<f64>,
5818 {
5819 self.cost_per_unit_below_threshold = v.map(|x| x.into());
5820 self
5821 }
5822
5823 /// Sets the value of [cost_per_unit_above_threshold][crate::model::vehicle::load_limit::LoadCost::cost_per_unit_above_threshold].
5824 ///
5825 /// # Example
5826 /// ```ignore,no_run
5827 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5828 /// let x = LoadCost::new().set_cost_per_unit_above_threshold(42.0);
5829 /// ```
5830 pub fn set_cost_per_unit_above_threshold<T>(mut self, v: T) -> Self
5831 where
5832 T: std::convert::Into<f64>,
5833 {
5834 self.cost_per_unit_above_threshold = std::option::Option::Some(v.into());
5835 self
5836 }
5837
5838 /// Sets or clears the value of [cost_per_unit_above_threshold][crate::model::vehicle::load_limit::LoadCost::cost_per_unit_above_threshold].
5839 ///
5840 /// # Example
5841 /// ```ignore,no_run
5842 /// # use google_maps_routeoptimization_v1::model::vehicle::load_limit::LoadCost;
5843 /// let x = LoadCost::new().set_or_clear_cost_per_unit_above_threshold(Some(42.0));
5844 /// let x = LoadCost::new().set_or_clear_cost_per_unit_above_threshold(None::<f32>);
5845 /// ```
5846 pub fn set_or_clear_cost_per_unit_above_threshold<T>(
5847 mut self,
5848 v: std::option::Option<T>,
5849 ) -> Self
5850 where
5851 T: std::convert::Into<f64>,
5852 {
5853 self.cost_per_unit_above_threshold = v.map(|x| x.into());
5854 self
5855 }
5856 }
5857
5858 impl wkt::message::Message for LoadCost {
5859 fn typename() -> &'static str {
5860 "type.googleapis.com/google.maps.routeoptimization.v1.Vehicle.LoadLimit.LoadCost"
5861 }
5862 }
5863 }
5864
5865 /// A limit defining a maximum duration of the route of a vehicle. It can be
5866 /// either hard or soft.
5867 ///
5868 /// When a soft limit field is defined, both the soft max threshold and its
5869 /// associated cost must be defined together.
5870 #[derive(Clone, Default, PartialEq)]
5871 #[non_exhaustive]
5872 pub struct DurationLimit {
5873 /// A hard limit constraining the duration to be at most max_duration.
5874 pub max_duration: std::option::Option<wkt::Duration>,
5875
5876 /// A soft limit not enforcing a maximum duration limit, but when violated
5877 /// makes the route incur a cost. This cost adds up to other costs defined in
5878 /// the model, with the same unit.
5879 ///
5880 /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
5881 /// also defined, `soft_max_duration` must be less than max_duration.
5882 pub soft_max_duration: std::option::Option<wkt::Duration>,
5883
5884 /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
5885 /// The additional cost is 0 if the duration is under the threshold,
5886 /// otherwise the cost depends on the duration as follows:
5887 ///
5888 /// ```norust
5889 /// cost_per_hour_after_soft_max * (duration - soft_max_duration)
5890 /// ```
5891 ///
5892 /// The cost must be nonnegative.
5893 pub cost_per_hour_after_soft_max: std::option::Option<f64>,
5894
5895 /// A soft limit not enforcing a maximum duration limit, but when violated
5896 /// makes the route incur a cost, quadratic in the duration. This cost adds
5897 /// up to other costs defined in the model, with the same unit.
5898 ///
5899 /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
5900 /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
5901 /// less than `max_duration`, and the difference must be no larger than one
5902 /// day:
5903 ///
5904 /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
5905 pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
5906
5907 /// Cost per square hour incurred if the
5908 /// `quadratic_soft_max_duration` threshold is violated.
5909 ///
5910 /// The additional cost is 0 if the duration is under the threshold,
5911 /// otherwise the cost depends on the duration as follows:
5912 ///
5913 /// ```norust
5914 /// cost_per_square_hour_after_quadratic_soft_max *
5915 /// (duration - quadratic_soft_max_duration)^2
5916 /// ```
5917 ///
5918 /// The cost must be nonnegative.
5919 pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
5920
5921 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5922 }
5923
5924 impl DurationLimit {
5925 /// Creates a new default instance.
5926 pub fn new() -> Self {
5927 std::default::Default::default()
5928 }
5929
5930 /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
5931 ///
5932 /// # Example
5933 /// ```ignore,no_run
5934 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
5935 /// use wkt::Duration;
5936 /// let x = DurationLimit::new().set_max_duration(Duration::default()/* use setters */);
5937 /// ```
5938 pub fn set_max_duration<T>(mut self, v: T) -> Self
5939 where
5940 T: std::convert::Into<wkt::Duration>,
5941 {
5942 self.max_duration = std::option::Option::Some(v.into());
5943 self
5944 }
5945
5946 /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
5947 ///
5948 /// # Example
5949 /// ```ignore,no_run
5950 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
5951 /// use wkt::Duration;
5952 /// let x = DurationLimit::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
5953 /// let x = DurationLimit::new().set_or_clear_max_duration(None::<Duration>);
5954 /// ```
5955 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
5956 where
5957 T: std::convert::Into<wkt::Duration>,
5958 {
5959 self.max_duration = v.map(|x| x.into());
5960 self
5961 }
5962
5963 /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
5964 ///
5965 /// # Example
5966 /// ```ignore,no_run
5967 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
5968 /// use wkt::Duration;
5969 /// let x = DurationLimit::new().set_soft_max_duration(Duration::default()/* use setters */);
5970 /// ```
5971 pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
5972 where
5973 T: std::convert::Into<wkt::Duration>,
5974 {
5975 self.soft_max_duration = std::option::Option::Some(v.into());
5976 self
5977 }
5978
5979 /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
5980 ///
5981 /// # Example
5982 /// ```ignore,no_run
5983 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
5984 /// use wkt::Duration;
5985 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(Some(Duration::default()/* use setters */));
5986 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(None::<Duration>);
5987 /// ```
5988 pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
5989 where
5990 T: std::convert::Into<wkt::Duration>,
5991 {
5992 self.soft_max_duration = v.map(|x| x.into());
5993 self
5994 }
5995
5996 /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
5997 ///
5998 /// # Example
5999 /// ```ignore,no_run
6000 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
6001 /// let x = DurationLimit::new().set_cost_per_hour_after_soft_max(42.0);
6002 /// ```
6003 pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
6004 where
6005 T: std::convert::Into<f64>,
6006 {
6007 self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
6008 self
6009 }
6010
6011 /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6012 ///
6013 /// # Example
6014 /// ```ignore,no_run
6015 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
6016 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(Some(42.0));
6017 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(None::<f32>);
6018 /// ```
6019 pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
6020 mut self,
6021 v: std::option::Option<T>,
6022 ) -> Self
6023 where
6024 T: std::convert::Into<f64>,
6025 {
6026 self.cost_per_hour_after_soft_max = v.map(|x| x.into());
6027 self
6028 }
6029
6030 /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6031 ///
6032 /// # Example
6033 /// ```ignore,no_run
6034 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
6035 /// use wkt::Duration;
6036 /// let x = DurationLimit::new().set_quadratic_soft_max_duration(Duration::default()/* use setters */);
6037 /// ```
6038 pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
6039 where
6040 T: std::convert::Into<wkt::Duration>,
6041 {
6042 self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
6043 self
6044 }
6045
6046 /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6047 ///
6048 /// # Example
6049 /// ```ignore,no_run
6050 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
6051 /// use wkt::Duration;
6052 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(Some(Duration::default()/* use setters */));
6053 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(None::<Duration>);
6054 /// ```
6055 pub fn set_or_clear_quadratic_soft_max_duration<T>(
6056 mut self,
6057 v: std::option::Option<T>,
6058 ) -> Self
6059 where
6060 T: std::convert::Into<wkt::Duration>,
6061 {
6062 self.quadratic_soft_max_duration = v.map(|x| x.into());
6063 self
6064 }
6065
6066 /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6067 ///
6068 /// # Example
6069 /// ```ignore,no_run
6070 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
6071 /// let x = DurationLimit::new().set_cost_per_square_hour_after_quadratic_soft_max(42.0);
6072 /// ```
6073 pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
6074 where
6075 T: std::convert::Into<f64>,
6076 {
6077 self.cost_per_square_hour_after_quadratic_soft_max =
6078 std::option::Option::Some(v.into());
6079 self
6080 }
6081
6082 /// Sets or clears the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6083 ///
6084 /// # Example
6085 /// ```ignore,no_run
6086 /// # use google_maps_routeoptimization_v1::model::vehicle::DurationLimit;
6087 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(Some(42.0));
6088 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(None::<f32>);
6089 /// ```
6090 pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
6091 mut self,
6092 v: std::option::Option<T>,
6093 ) -> Self
6094 where
6095 T: std::convert::Into<f64>,
6096 {
6097 self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
6098 self
6099 }
6100 }
6101
6102 impl wkt::message::Message for DurationLimit {
6103 fn typename() -> &'static str {
6104 "type.googleapis.com/google.maps.routeoptimization.v1.Vehicle.DurationLimit"
6105 }
6106 }
6107
6108 /// Travel modes which can be used by vehicles.
6109 ///
6110 /// These should be a subset of the Google Maps Platform Routes API travel
6111 /// modes, see:
6112 /// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteTravelMode>
6113 ///
6114 /// Note: `WALKING` routes are in beta and might sometimes be missing clear
6115 /// sidewalks or pedestrian paths. You must display this warning to the user
6116 /// for all walking routes that you display in your app.
6117 ///
6118 /// # Working with unknown values
6119 ///
6120 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6121 /// additional enum variants at any time. Adding new variants is not considered
6122 /// a breaking change. Applications should write their code in anticipation of:
6123 ///
6124 /// - New values appearing in future releases of the client library, **and**
6125 /// - New values received dynamically, without application changes.
6126 ///
6127 /// Please consult the [Working with enums] section in the user guide for some
6128 /// guidelines.
6129 ///
6130 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6131 #[derive(Clone, Debug, PartialEq)]
6132 #[non_exhaustive]
6133 pub enum TravelMode {
6134 /// Unspecified travel mode, equivalent to `DRIVING`.
6135 Unspecified,
6136 /// Travel mode corresponding to driving directions (car, ...).
6137 Driving,
6138 /// Travel mode corresponding to walking directions.
6139 Walking,
6140 /// If set, the enum was initialized with an unknown value.
6141 ///
6142 /// Applications can examine the value using [TravelMode::value] or
6143 /// [TravelMode::name].
6144 UnknownValue(travel_mode::UnknownValue),
6145 }
6146
6147 #[doc(hidden)]
6148 pub mod travel_mode {
6149 #[allow(unused_imports)]
6150 use super::*;
6151 #[derive(Clone, Debug, PartialEq)]
6152 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6153 }
6154
6155 impl TravelMode {
6156 /// Gets the enum value.
6157 ///
6158 /// Returns `None` if the enum contains an unknown value deserialized from
6159 /// the string representation of enums.
6160 pub fn value(&self) -> std::option::Option<i32> {
6161 match self {
6162 Self::Unspecified => std::option::Option::Some(0),
6163 Self::Driving => std::option::Option::Some(1),
6164 Self::Walking => std::option::Option::Some(2),
6165 Self::UnknownValue(u) => u.0.value(),
6166 }
6167 }
6168
6169 /// Gets the enum value as a string.
6170 ///
6171 /// Returns `None` if the enum contains an unknown value deserialized from
6172 /// the integer representation of enums.
6173 pub fn name(&self) -> std::option::Option<&str> {
6174 match self {
6175 Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
6176 Self::Driving => std::option::Option::Some("DRIVING"),
6177 Self::Walking => std::option::Option::Some("WALKING"),
6178 Self::UnknownValue(u) => u.0.name(),
6179 }
6180 }
6181 }
6182
6183 impl std::default::Default for TravelMode {
6184 fn default() -> Self {
6185 use std::convert::From;
6186 Self::from(0)
6187 }
6188 }
6189
6190 impl std::fmt::Display for TravelMode {
6191 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6192 wkt::internal::display_enum(f, self.name(), self.value())
6193 }
6194 }
6195
6196 impl std::convert::From<i32> for TravelMode {
6197 fn from(value: i32) -> Self {
6198 match value {
6199 0 => Self::Unspecified,
6200 1 => Self::Driving,
6201 2 => Self::Walking,
6202 _ => Self::UnknownValue(travel_mode::UnknownValue(
6203 wkt::internal::UnknownEnumValue::Integer(value),
6204 )),
6205 }
6206 }
6207 }
6208
6209 impl std::convert::From<&str> for TravelMode {
6210 fn from(value: &str) -> Self {
6211 use std::string::ToString;
6212 match value {
6213 "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
6214 "DRIVING" => Self::Driving,
6215 "WALKING" => Self::Walking,
6216 _ => Self::UnknownValue(travel_mode::UnknownValue(
6217 wkt::internal::UnknownEnumValue::String(value.to_string()),
6218 )),
6219 }
6220 }
6221 }
6222
6223 impl serde::ser::Serialize for TravelMode {
6224 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6225 where
6226 S: serde::Serializer,
6227 {
6228 match self {
6229 Self::Unspecified => serializer.serialize_i32(0),
6230 Self::Driving => serializer.serialize_i32(1),
6231 Self::Walking => serializer.serialize_i32(2),
6232 Self::UnknownValue(u) => u.0.serialize(serializer),
6233 }
6234 }
6235 }
6236
6237 impl<'de> serde::de::Deserialize<'de> for TravelMode {
6238 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6239 where
6240 D: serde::Deserializer<'de>,
6241 {
6242 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
6243 ".google.maps.routeoptimization.v1.Vehicle.TravelMode",
6244 ))
6245 }
6246 }
6247
6248 /// Policy on how a vehicle can be unloaded. Applies only to shipments having
6249 /// both a pickup and a delivery.
6250 ///
6251 /// Other shipments are free to occur anywhere on the route independent of
6252 /// `unloading_policy`.
6253 ///
6254 /// # Working with unknown values
6255 ///
6256 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6257 /// additional enum variants at any time. Adding new variants is not considered
6258 /// a breaking change. Applications should write their code in anticipation of:
6259 ///
6260 /// - New values appearing in future releases of the client library, **and**
6261 /// - New values received dynamically, without application changes.
6262 ///
6263 /// Please consult the [Working with enums] section in the user guide for some
6264 /// guidelines.
6265 ///
6266 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6267 #[derive(Clone, Debug, PartialEq)]
6268 #[non_exhaustive]
6269 pub enum UnloadingPolicy {
6270 /// Unspecified unloading policy; deliveries must just occur after their
6271 /// corresponding pickups.
6272 Unspecified,
6273 /// Deliveries must occur in reverse order of pickups
6274 LastInFirstOut,
6275 /// Deliveries must occur in the same order as pickups
6276 FirstInFirstOut,
6277 /// If set, the enum was initialized with an unknown value.
6278 ///
6279 /// Applications can examine the value using [UnloadingPolicy::value] or
6280 /// [UnloadingPolicy::name].
6281 UnknownValue(unloading_policy::UnknownValue),
6282 }
6283
6284 #[doc(hidden)]
6285 pub mod unloading_policy {
6286 #[allow(unused_imports)]
6287 use super::*;
6288 #[derive(Clone, Debug, PartialEq)]
6289 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6290 }
6291
6292 impl UnloadingPolicy {
6293 /// Gets the enum value.
6294 ///
6295 /// Returns `None` if the enum contains an unknown value deserialized from
6296 /// the string representation of enums.
6297 pub fn value(&self) -> std::option::Option<i32> {
6298 match self {
6299 Self::Unspecified => std::option::Option::Some(0),
6300 Self::LastInFirstOut => std::option::Option::Some(1),
6301 Self::FirstInFirstOut => std::option::Option::Some(2),
6302 Self::UnknownValue(u) => u.0.value(),
6303 }
6304 }
6305
6306 /// Gets the enum value as a string.
6307 ///
6308 /// Returns `None` if the enum contains an unknown value deserialized from
6309 /// the integer representation of enums.
6310 pub fn name(&self) -> std::option::Option<&str> {
6311 match self {
6312 Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
6313 Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
6314 Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
6315 Self::UnknownValue(u) => u.0.name(),
6316 }
6317 }
6318 }
6319
6320 impl std::default::Default for UnloadingPolicy {
6321 fn default() -> Self {
6322 use std::convert::From;
6323 Self::from(0)
6324 }
6325 }
6326
6327 impl std::fmt::Display for UnloadingPolicy {
6328 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6329 wkt::internal::display_enum(f, self.name(), self.value())
6330 }
6331 }
6332
6333 impl std::convert::From<i32> for UnloadingPolicy {
6334 fn from(value: i32) -> Self {
6335 match value {
6336 0 => Self::Unspecified,
6337 1 => Self::LastInFirstOut,
6338 2 => Self::FirstInFirstOut,
6339 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6340 wkt::internal::UnknownEnumValue::Integer(value),
6341 )),
6342 }
6343 }
6344 }
6345
6346 impl std::convert::From<&str> for UnloadingPolicy {
6347 fn from(value: &str) -> Self {
6348 use std::string::ToString;
6349 match value {
6350 "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
6351 "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
6352 "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
6353 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6354 wkt::internal::UnknownEnumValue::String(value.to_string()),
6355 )),
6356 }
6357 }
6358 }
6359
6360 impl serde::ser::Serialize for UnloadingPolicy {
6361 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6362 where
6363 S: serde::Serializer,
6364 {
6365 match self {
6366 Self::Unspecified => serializer.serialize_i32(0),
6367 Self::LastInFirstOut => serializer.serialize_i32(1),
6368 Self::FirstInFirstOut => serializer.serialize_i32(2),
6369 Self::UnknownValue(u) => u.0.serialize(serializer),
6370 }
6371 }
6372 }
6373
6374 impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
6375 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6376 where
6377 D: serde::Deserializer<'de>,
6378 {
6379 deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
6380 ".google.maps.routeoptimization.v1.Vehicle.UnloadingPolicy",
6381 ))
6382 }
6383 }
6384}
6385
6386/// Time windows constrain the time of an event, such as the arrival time at a
6387/// visit, or the start and end time of a vehicle.
6388///
6389/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
6390/// and latest time of the event, such that `start_time <= event_time <=
6391/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
6392/// preference for the event to happen at or after `soft_start_time` by incurring
6393/// a cost proportional to how long before soft_start_time the event occurs. The
6394/// soft time window upper bound, `soft_end_time`, expresses a preference for the
6395/// event to happen at or before `soft_end_time` by incurring a cost proportional
6396/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
6397/// `soft_start_time` and `soft_end_time` should be within the global time limits
6398/// (see
6399/// [ShipmentModel.global_start_time][google.maps.routeoptimization.v1.ShipmentModel.global_start_time]
6400/// and
6401/// [ShipmentModel.global_end_time][google.maps.routeoptimization.v1.ShipmentModel.global_end_time])
6402/// and should respect:
6403///
6404/// ```norust
6405/// 0 <= `start_time` <= `end_time` and
6406/// 0 <= `start_time` <= `soft_start_time` and
6407/// 0 <= `soft_end_time` <= `end_time`.
6408/// ```
6409///
6410/// [google.maps.routeoptimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
6411/// [google.maps.routeoptimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
6412#[derive(Clone, Default, PartialEq)]
6413#[non_exhaustive]
6414pub struct TimeWindow {
6415 /// The hard time window start time. If unspecified it will be set to
6416 /// `ShipmentModel.global_start_time`.
6417 pub start_time: std::option::Option<wkt::Timestamp>,
6418
6419 /// The hard time window end time. If unspecified it will be set to
6420 /// `ShipmentModel.global_end_time`.
6421 pub end_time: std::option::Option<wkt::Timestamp>,
6422
6423 /// The soft start time of the time window.
6424 pub soft_start_time: std::option::Option<wkt::Timestamp>,
6425
6426 /// The soft end time of the time window.
6427 pub soft_end_time: std::option::Option<wkt::Timestamp>,
6428
6429 /// A cost per hour added to other costs in the model if the event occurs
6430 /// before soft_start_time, computed as:
6431 ///
6432 /// ```norust
6433 /// max(0, soft_start_time - t.seconds)
6434 /// * cost_per_hour_before_soft_start_time / 3600,
6435 /// t being the time of the event.
6436 /// ```
6437 ///
6438 /// This cost must be positive, and the field can only be set if
6439 /// soft_start_time has been set.
6440 pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
6441
6442 /// A cost per hour added to other costs in the model if the event occurs after
6443 /// `soft_end_time`, computed as:
6444 ///
6445 /// ```norust
6446 /// max(0, t.seconds - soft_end_time.seconds)
6447 /// * cost_per_hour_after_soft_end_time / 3600,
6448 /// t being the time of the event.
6449 /// ```
6450 ///
6451 /// This cost must be positive, and the field can only be set if
6452 /// `soft_end_time` has been set.
6453 pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
6454
6455 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6456}
6457
6458impl TimeWindow {
6459 /// Creates a new default instance.
6460 pub fn new() -> Self {
6461 std::default::Default::default()
6462 }
6463
6464 /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
6465 ///
6466 /// # Example
6467 /// ```ignore,no_run
6468 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6469 /// use wkt::Timestamp;
6470 /// let x = TimeWindow::new().set_start_time(Timestamp::default()/* use setters */);
6471 /// ```
6472 pub fn set_start_time<T>(mut self, v: T) -> Self
6473 where
6474 T: std::convert::Into<wkt::Timestamp>,
6475 {
6476 self.start_time = std::option::Option::Some(v.into());
6477 self
6478 }
6479
6480 /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
6481 ///
6482 /// # Example
6483 /// ```ignore,no_run
6484 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6485 /// use wkt::Timestamp;
6486 /// let x = TimeWindow::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
6487 /// let x = TimeWindow::new().set_or_clear_start_time(None::<Timestamp>);
6488 /// ```
6489 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6490 where
6491 T: std::convert::Into<wkt::Timestamp>,
6492 {
6493 self.start_time = v.map(|x| x.into());
6494 self
6495 }
6496
6497 /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
6498 ///
6499 /// # Example
6500 /// ```ignore,no_run
6501 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6502 /// use wkt::Timestamp;
6503 /// let x = TimeWindow::new().set_end_time(Timestamp::default()/* use setters */);
6504 /// ```
6505 pub fn set_end_time<T>(mut self, v: T) -> Self
6506 where
6507 T: std::convert::Into<wkt::Timestamp>,
6508 {
6509 self.end_time = std::option::Option::Some(v.into());
6510 self
6511 }
6512
6513 /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
6514 ///
6515 /// # Example
6516 /// ```ignore,no_run
6517 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6518 /// use wkt::Timestamp;
6519 /// let x = TimeWindow::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
6520 /// let x = TimeWindow::new().set_or_clear_end_time(None::<Timestamp>);
6521 /// ```
6522 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6523 where
6524 T: std::convert::Into<wkt::Timestamp>,
6525 {
6526 self.end_time = v.map(|x| x.into());
6527 self
6528 }
6529
6530 /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6531 ///
6532 /// # Example
6533 /// ```ignore,no_run
6534 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6535 /// use wkt::Timestamp;
6536 /// let x = TimeWindow::new().set_soft_start_time(Timestamp::default()/* use setters */);
6537 /// ```
6538 pub fn set_soft_start_time<T>(mut self, v: T) -> Self
6539 where
6540 T: std::convert::Into<wkt::Timestamp>,
6541 {
6542 self.soft_start_time = std::option::Option::Some(v.into());
6543 self
6544 }
6545
6546 /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6547 ///
6548 /// # Example
6549 /// ```ignore,no_run
6550 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6551 /// use wkt::Timestamp;
6552 /// let x = TimeWindow::new().set_or_clear_soft_start_time(Some(Timestamp::default()/* use setters */));
6553 /// let x = TimeWindow::new().set_or_clear_soft_start_time(None::<Timestamp>);
6554 /// ```
6555 pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6556 where
6557 T: std::convert::Into<wkt::Timestamp>,
6558 {
6559 self.soft_start_time = v.map(|x| x.into());
6560 self
6561 }
6562
6563 /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6564 ///
6565 /// # Example
6566 /// ```ignore,no_run
6567 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6568 /// use wkt::Timestamp;
6569 /// let x = TimeWindow::new().set_soft_end_time(Timestamp::default()/* use setters */);
6570 /// ```
6571 pub fn set_soft_end_time<T>(mut self, v: T) -> Self
6572 where
6573 T: std::convert::Into<wkt::Timestamp>,
6574 {
6575 self.soft_end_time = std::option::Option::Some(v.into());
6576 self
6577 }
6578
6579 /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6580 ///
6581 /// # Example
6582 /// ```ignore,no_run
6583 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6584 /// use wkt::Timestamp;
6585 /// let x = TimeWindow::new().set_or_clear_soft_end_time(Some(Timestamp::default()/* use setters */));
6586 /// let x = TimeWindow::new().set_or_clear_soft_end_time(None::<Timestamp>);
6587 /// ```
6588 pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6589 where
6590 T: std::convert::Into<wkt::Timestamp>,
6591 {
6592 self.soft_end_time = v.map(|x| x.into());
6593 self
6594 }
6595
6596 /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6597 ///
6598 /// # Example
6599 /// ```ignore,no_run
6600 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6601 /// let x = TimeWindow::new().set_cost_per_hour_before_soft_start_time(42.0);
6602 /// ```
6603 pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
6604 where
6605 T: std::convert::Into<f64>,
6606 {
6607 self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
6608 self
6609 }
6610
6611 /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6612 ///
6613 /// # Example
6614 /// ```ignore,no_run
6615 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6616 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(Some(42.0));
6617 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(None::<f32>);
6618 /// ```
6619 pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
6620 mut self,
6621 v: std::option::Option<T>,
6622 ) -> Self
6623 where
6624 T: std::convert::Into<f64>,
6625 {
6626 self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
6627 self
6628 }
6629
6630 /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6631 ///
6632 /// # Example
6633 /// ```ignore,no_run
6634 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6635 /// let x = TimeWindow::new().set_cost_per_hour_after_soft_end_time(42.0);
6636 /// ```
6637 pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
6638 where
6639 T: std::convert::Into<f64>,
6640 {
6641 self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
6642 self
6643 }
6644
6645 /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6646 ///
6647 /// # Example
6648 /// ```ignore,no_run
6649 /// # use google_maps_routeoptimization_v1::model::TimeWindow;
6650 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(Some(42.0));
6651 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(None::<f32>);
6652 /// ```
6653 pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
6654 mut self,
6655 v: std::option::Option<T>,
6656 ) -> Self
6657 where
6658 T: std::convert::Into<f64>,
6659 {
6660 self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
6661 self
6662 }
6663}
6664
6665impl wkt::message::Message for TimeWindow {
6666 fn typename() -> &'static str {
6667 "type.googleapis.com/google.maps.routeoptimization.v1.TimeWindow"
6668 }
6669}
6670
6671/// A limit defining a maximum distance which can be traveled. It can be either
6672/// hard or soft.
6673///
6674/// If a soft limit is defined, both `soft_max_meters` and
6675/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
6676#[derive(Clone, Default, PartialEq)]
6677#[non_exhaustive]
6678pub struct DistanceLimit {
6679 /// A hard limit constraining the distance to be at most max_meters. The limit
6680 /// must be nonnegative.
6681 pub max_meters: std::option::Option<i64>,
6682
6683 /// A soft limit not enforcing a maximum distance limit, but when violated
6684 /// results in a cost which adds up to other costs defined in the model,
6685 /// with the same unit.
6686 ///
6687 /// If defined soft_max_meters must be less than max_meters and must be
6688 /// nonnegative.
6689 pub soft_max_meters: std::option::Option<i64>,
6690
6691 /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
6692 /// formula:
6693 ///
6694 /// ```norust
6695 /// min(distance_meters, soft_max_meters) / 1000.0 *
6696 /// cost_per_kilometer_below_soft_max.
6697 /// ```
6698 ///
6699 /// This cost is not supported in `route_distance_limit`.
6700 pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
6701
6702 /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
6703 /// The additional cost is 0 if the distance is under the limit, otherwise the
6704 /// formula used to compute the cost is the following:
6705 ///
6706 /// ```norust
6707 /// (distance_meters - soft_max_meters) / 1000.0 *
6708 /// cost_per_kilometer_above_soft_max.
6709 /// ```
6710 ///
6711 /// The cost must be nonnegative.
6712 pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
6713
6714 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6715}
6716
6717impl DistanceLimit {
6718 /// Creates a new default instance.
6719 pub fn new() -> Self {
6720 std::default::Default::default()
6721 }
6722
6723 /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
6724 ///
6725 /// # Example
6726 /// ```ignore,no_run
6727 /// # use google_maps_routeoptimization_v1::model::DistanceLimit;
6728 /// let x = DistanceLimit::new().set_max_meters(42);
6729 /// ```
6730 pub fn set_max_meters<T>(mut self, v: T) -> Self
6731 where
6732 T: std::convert::Into<i64>,
6733 {
6734 self.max_meters = std::option::Option::Some(v.into());
6735 self
6736 }
6737
6738 /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
6739 ///
6740 /// # Example
6741 /// ```ignore,no_run
6742 /// # use google_maps_routeoptimization_v1::model::DistanceLimit;
6743 /// let x = DistanceLimit::new().set_or_clear_max_meters(Some(42));
6744 /// let x = DistanceLimit::new().set_or_clear_max_meters(None::<i32>);
6745 /// ```
6746 pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
6747 where
6748 T: std::convert::Into<i64>,
6749 {
6750 self.max_meters = v.map(|x| x.into());
6751 self
6752 }
6753
6754 /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
6755 ///
6756 /// # Example
6757 /// ```ignore,no_run
6758 /// # use google_maps_routeoptimization_v1::model::DistanceLimit;
6759 /// let x = DistanceLimit::new().set_soft_max_meters(42);
6760 /// ```
6761 pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
6762 where
6763 T: std::convert::Into<i64>,
6764 {
6765 self.soft_max_meters = std::option::Option::Some(v.into());
6766 self
6767 }
6768
6769 /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
6770 ///
6771 /// # Example
6772 /// ```ignore,no_run
6773 /// # use google_maps_routeoptimization_v1::model::DistanceLimit;
6774 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(Some(42));
6775 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(None::<i32>);
6776 /// ```
6777 pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
6778 where
6779 T: std::convert::Into<i64>,
6780 {
6781 self.soft_max_meters = v.map(|x| x.into());
6782 self
6783 }
6784
6785 /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
6786 ///
6787 /// # Example
6788 /// ```ignore,no_run
6789 /// # use google_maps_routeoptimization_v1::model::DistanceLimit;
6790 /// let x = DistanceLimit::new().set_cost_per_kilometer_below_soft_max(42.0);
6791 /// ```
6792 pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
6793 where
6794 T: std::convert::Into<f64>,
6795 {
6796 self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
6797 self
6798 }
6799
6800 /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
6801 ///
6802 /// # Example
6803 /// ```ignore,no_run
6804 /// # use google_maps_routeoptimization_v1::model::DistanceLimit;
6805 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(Some(42.0));
6806 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(None::<f32>);
6807 /// ```
6808 pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
6809 mut self,
6810 v: std::option::Option<T>,
6811 ) -> Self
6812 where
6813 T: std::convert::Into<f64>,
6814 {
6815 self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
6816 self
6817 }
6818
6819 /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
6820 ///
6821 /// # Example
6822 /// ```ignore,no_run
6823 /// # use google_maps_routeoptimization_v1::model::DistanceLimit;
6824 /// let x = DistanceLimit::new().set_cost_per_kilometer_above_soft_max(42.0);
6825 /// ```
6826 pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
6827 where
6828 T: std::convert::Into<f64>,
6829 {
6830 self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
6831 self
6832 }
6833
6834 /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
6835 ///
6836 /// # Example
6837 /// ```ignore,no_run
6838 /// # use google_maps_routeoptimization_v1::model::DistanceLimit;
6839 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(Some(42.0));
6840 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(None::<f32>);
6841 /// ```
6842 pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
6843 mut self,
6844 v: std::option::Option<T>,
6845 ) -> Self
6846 where
6847 T: std::convert::Into<f64>,
6848 {
6849 self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
6850 self
6851 }
6852}
6853
6854impl wkt::message::Message for DistanceLimit {
6855 fn typename() -> &'static str {
6856 "type.googleapis.com/google.maps.routeoptimization.v1.DistanceLimit"
6857 }
6858}
6859
6860/// Specifies attributes of transitions between two consecutive visits on a
6861/// route. Several `TransitionAttributes` may apply to the same transition: in
6862/// that case, all extra costs add up and the strictest constraint or limit
6863/// applies (following natural "AND" semantics).
6864#[derive(Clone, Default, PartialEq)]
6865#[non_exhaustive]
6866pub struct TransitionAttributes {
6867 /// Tags defining the set of (src->dst) transitions these attributes apply to.
6868 ///
6869 /// A source visit or vehicle start matches iff its
6870 /// [VisitRequest.tags][google.maps.routeoptimization.v1.Shipment.VisitRequest.tags]
6871 /// or
6872 /// [Vehicle.start_tags][google.maps.routeoptimization.v1.Vehicle.start_tags]
6873 /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
6874 /// on which of these two fields is non-empty).
6875 ///
6876 /// [google.maps.routeoptimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
6877 /// [google.maps.routeoptimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
6878 pub src_tag: std::string::String,
6879
6880 /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
6881 /// non-empty.
6882 pub excluded_src_tag: std::string::String,
6883
6884 /// A destination visit or vehicle end matches iff its
6885 /// [VisitRequest.tags][google.maps.routeoptimization.v1.Shipment.VisitRequest.tags]
6886 /// or [Vehicle.end_tags][google.maps.routeoptimization.v1.Vehicle.end_tags]
6887 /// either contains `dst_tag` or does not contain `excluded_dst_tag` (depending
6888 /// on which of these two fields is non-empty).
6889 ///
6890 /// [google.maps.routeoptimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
6891 /// [google.maps.routeoptimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
6892 pub dst_tag: std::string::String,
6893
6894 /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
6895 /// non-empty.
6896 pub excluded_dst_tag: std::string::String,
6897
6898 /// Specifies a cost for performing this transition. This is in the same unit
6899 /// as all other costs in the model and must not be negative. It is applied on
6900 /// top of all other existing costs.
6901 pub cost: f64,
6902
6903 /// Specifies a cost per kilometer applied to the distance traveled while
6904 /// performing this transition. It adds up to any
6905 /// [Vehicle.cost_per_kilometer][google.maps.routeoptimization.v1.Vehicle.cost_per_kilometer]
6906 /// specified on vehicles.
6907 ///
6908 /// [google.maps.routeoptimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
6909 pub cost_per_kilometer: f64,
6910
6911 /// Specifies a limit on the distance traveled while performing this
6912 /// transition.
6913 ///
6914 /// As of 2021/06, only soft limits are supported.
6915 pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
6916
6917 /// Specifies a delay incurred when performing this transition.
6918 ///
6919 /// This delay always occurs *after* finishing the source visit and *before*
6920 /// starting the destination visit.
6921 pub delay: std::option::Option<wkt::Duration>,
6922
6923 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6924}
6925
6926impl TransitionAttributes {
6927 /// Creates a new default instance.
6928 pub fn new() -> Self {
6929 std::default::Default::default()
6930 }
6931
6932 /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
6933 ///
6934 /// # Example
6935 /// ```ignore,no_run
6936 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
6937 /// let x = TransitionAttributes::new().set_src_tag("example");
6938 /// ```
6939 pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6940 self.src_tag = v.into();
6941 self
6942 }
6943
6944 /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
6945 ///
6946 /// # Example
6947 /// ```ignore,no_run
6948 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
6949 /// let x = TransitionAttributes::new().set_excluded_src_tag("example");
6950 /// ```
6951 pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
6952 mut self,
6953 v: T,
6954 ) -> Self {
6955 self.excluded_src_tag = v.into();
6956 self
6957 }
6958
6959 /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
6960 ///
6961 /// # Example
6962 /// ```ignore,no_run
6963 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
6964 /// let x = TransitionAttributes::new().set_dst_tag("example");
6965 /// ```
6966 pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6967 self.dst_tag = v.into();
6968 self
6969 }
6970
6971 /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
6972 ///
6973 /// # Example
6974 /// ```ignore,no_run
6975 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
6976 /// let x = TransitionAttributes::new().set_excluded_dst_tag("example");
6977 /// ```
6978 pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
6979 mut self,
6980 v: T,
6981 ) -> Self {
6982 self.excluded_dst_tag = v.into();
6983 self
6984 }
6985
6986 /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
6987 ///
6988 /// # Example
6989 /// ```ignore,no_run
6990 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
6991 /// let x = TransitionAttributes::new().set_cost(42.0);
6992 /// ```
6993 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
6994 self.cost = v.into();
6995 self
6996 }
6997
6998 /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
6999 ///
7000 /// # Example
7001 /// ```ignore,no_run
7002 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
7003 /// let x = TransitionAttributes::new().set_cost_per_kilometer(42.0);
7004 /// ```
7005 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7006 self.cost_per_kilometer = v.into();
7007 self
7008 }
7009
7010 /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7011 ///
7012 /// # Example
7013 /// ```ignore,no_run
7014 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
7015 /// use google_maps_routeoptimization_v1::model::DistanceLimit;
7016 /// let x = TransitionAttributes::new().set_distance_limit(DistanceLimit::default()/* use setters */);
7017 /// ```
7018 pub fn set_distance_limit<T>(mut self, v: T) -> Self
7019 where
7020 T: std::convert::Into<crate::model::DistanceLimit>,
7021 {
7022 self.distance_limit = std::option::Option::Some(v.into());
7023 self
7024 }
7025
7026 /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7027 ///
7028 /// # Example
7029 /// ```ignore,no_run
7030 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
7031 /// use google_maps_routeoptimization_v1::model::DistanceLimit;
7032 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(Some(DistanceLimit::default()/* use setters */));
7033 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(None::<DistanceLimit>);
7034 /// ```
7035 pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
7036 where
7037 T: std::convert::Into<crate::model::DistanceLimit>,
7038 {
7039 self.distance_limit = v.map(|x| x.into());
7040 self
7041 }
7042
7043 /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
7044 ///
7045 /// # Example
7046 /// ```ignore,no_run
7047 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
7048 /// use wkt::Duration;
7049 /// let x = TransitionAttributes::new().set_delay(Duration::default()/* use setters */);
7050 /// ```
7051 pub fn set_delay<T>(mut self, v: T) -> Self
7052 where
7053 T: std::convert::Into<wkt::Duration>,
7054 {
7055 self.delay = std::option::Option::Some(v.into());
7056 self
7057 }
7058
7059 /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
7060 ///
7061 /// # Example
7062 /// ```ignore,no_run
7063 /// # use google_maps_routeoptimization_v1::model::TransitionAttributes;
7064 /// use wkt::Duration;
7065 /// let x = TransitionAttributes::new().set_or_clear_delay(Some(Duration::default()/* use setters */));
7066 /// let x = TransitionAttributes::new().set_or_clear_delay(None::<Duration>);
7067 /// ```
7068 pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
7069 where
7070 T: std::convert::Into<wkt::Duration>,
7071 {
7072 self.delay = v.map(|x| x.into());
7073 self
7074 }
7075}
7076
7077impl wkt::message::Message for TransitionAttributes {
7078 fn typename() -> &'static str {
7079 "type.googleapis.com/google.maps.routeoptimization.v1.TransitionAttributes"
7080 }
7081}
7082
7083/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
7084/// VisitRequests, and start and end locations of Vehicles.
7085#[derive(Clone, Default, PartialEq)]
7086#[non_exhaustive]
7087pub struct Waypoint {
7088 /// Optional. Indicates that the location of this waypoint is meant to have a
7089 /// preference for the vehicle to stop at a particular side of road. When you
7090 /// set this value, the route will pass through the location so that the
7091 /// vehicle can stop at the side of road that the location is biased towards
7092 /// from the center of the road. This option doesn't work for the 'WALKING'
7093 /// travel mode.
7094 pub side_of_road: bool,
7095
7096 /// Indicates that the waypoint is meant for vehicles to stop at, where the
7097 /// intention is to either pick up or drop off. This option works only for the
7098 /// 'DRIVING' travel mode, and when the 'location_type' is 'location'.
7099 ///
7100 /// Experimental: This field's behavior or existence may change in future.
7101 pub vehicle_stopover: bool,
7102
7103 /// Different ways to represent a location.
7104 pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
7105
7106 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7107}
7108
7109impl Waypoint {
7110 /// Creates a new default instance.
7111 pub fn new() -> Self {
7112 std::default::Default::default()
7113 }
7114
7115 /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
7116 ///
7117 /// # Example
7118 /// ```ignore,no_run
7119 /// # use google_maps_routeoptimization_v1::model::Waypoint;
7120 /// let x = Waypoint::new().set_side_of_road(true);
7121 /// ```
7122 pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7123 self.side_of_road = v.into();
7124 self
7125 }
7126
7127 /// Sets the value of [vehicle_stopover][crate::model::Waypoint::vehicle_stopover].
7128 ///
7129 /// # Example
7130 /// ```ignore,no_run
7131 /// # use google_maps_routeoptimization_v1::model::Waypoint;
7132 /// let x = Waypoint::new().set_vehicle_stopover(true);
7133 /// ```
7134 pub fn set_vehicle_stopover<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7135 self.vehicle_stopover = v.into();
7136 self
7137 }
7138
7139 /// Sets the value of [location_type][crate::model::Waypoint::location_type].
7140 ///
7141 /// Note that all the setters affecting `location_type` are mutually
7142 /// exclusive.
7143 ///
7144 /// # Example
7145 /// ```ignore,no_run
7146 /// # use google_maps_routeoptimization_v1::model::Waypoint;
7147 /// use google_maps_routeoptimization_v1::model::waypoint::LocationType;
7148 /// let x = Waypoint::new().set_location_type(Some(LocationType::PlaceId("example".to_string())));
7149 /// ```
7150 pub fn set_location_type<
7151 T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
7152 >(
7153 mut self,
7154 v: T,
7155 ) -> Self {
7156 self.location_type = v.into();
7157 self
7158 }
7159
7160 /// The value of [location_type][crate::model::Waypoint::location_type]
7161 /// if it holds a `Location`, `None` if the field is not set or
7162 /// holds a different branch.
7163 pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
7164 #[allow(unreachable_patterns)]
7165 self.location_type.as_ref().and_then(|v| match v {
7166 crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
7167 _ => std::option::Option::None,
7168 })
7169 }
7170
7171 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7172 /// to hold a `Location`.
7173 ///
7174 /// Note that all the setters affecting `location_type` are
7175 /// mutually exclusive.
7176 ///
7177 /// # Example
7178 /// ```ignore,no_run
7179 /// # use google_maps_routeoptimization_v1::model::Waypoint;
7180 /// use google_maps_routeoptimization_v1::model::Location;
7181 /// let x = Waypoint::new().set_location(Location::default()/* use setters */);
7182 /// assert!(x.location().is_some());
7183 /// assert!(x.place_id().is_none());
7184 /// ```
7185 pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
7186 mut self,
7187 v: T,
7188 ) -> Self {
7189 self.location_type =
7190 std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
7191 self
7192 }
7193
7194 /// The value of [location_type][crate::model::Waypoint::location_type]
7195 /// if it holds a `PlaceId`, `None` if the field is not set or
7196 /// holds a different branch.
7197 pub fn place_id(&self) -> std::option::Option<&std::string::String> {
7198 #[allow(unreachable_patterns)]
7199 self.location_type.as_ref().and_then(|v| match v {
7200 crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
7201 _ => std::option::Option::None,
7202 })
7203 }
7204
7205 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7206 /// to hold a `PlaceId`.
7207 ///
7208 /// Note that all the setters affecting `location_type` are
7209 /// mutually exclusive.
7210 ///
7211 /// # Example
7212 /// ```ignore,no_run
7213 /// # use google_maps_routeoptimization_v1::model::Waypoint;
7214 /// let x = Waypoint::new().set_place_id("example");
7215 /// assert!(x.place_id().is_some());
7216 /// assert!(x.location().is_none());
7217 /// ```
7218 pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7219 self.location_type =
7220 std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
7221 self
7222 }
7223}
7224
7225impl wkt::message::Message for Waypoint {
7226 fn typename() -> &'static str {
7227 "type.googleapis.com/google.maps.routeoptimization.v1.Waypoint"
7228 }
7229}
7230
7231/// Defines additional types related to [Waypoint].
7232pub mod waypoint {
7233 #[allow(unused_imports)]
7234 use super::*;
7235
7236 /// Different ways to represent a location.
7237 #[derive(Clone, Debug, PartialEq)]
7238 #[non_exhaustive]
7239 pub enum LocationType {
7240 /// A point specified using geographic coordinates, including an optional
7241 /// heading.
7242 Location(std::boxed::Box<crate::model::Location>),
7243 /// The POI place ID associated with the waypoint.
7244 ///
7245 /// When using a place ID to specify arrival or departure location of a
7246 /// VisitRequest, use a place ID that is specific enough to determine a
7247 /// LatLng location for navigation to the place.
7248 /// For example, a place ID representing a building is suitable, but a place
7249 /// ID representing a road is discouraged.
7250 PlaceId(std::string::String),
7251 }
7252}
7253
7254/// Encapsulates a location (a geographic point, and an optional heading).
7255#[derive(Clone, Default, PartialEq)]
7256#[non_exhaustive]
7257pub struct Location {
7258 /// The waypoint's geographic coordinates.
7259 pub lat_lng: std::option::Option<google_cloud_type::model::LatLng>,
7260
7261 /// The compass heading associated with the direction of the flow of traffic.
7262 /// This value is used to specify the side of the road to use for pickup and
7263 /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
7264 /// of due North, 90 specifies a heading of due East, etc.
7265 pub heading: std::option::Option<i32>,
7266
7267 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7268}
7269
7270impl Location {
7271 /// Creates a new default instance.
7272 pub fn new() -> Self {
7273 std::default::Default::default()
7274 }
7275
7276 /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
7277 ///
7278 /// # Example
7279 /// ```ignore,no_run
7280 /// # use google_maps_routeoptimization_v1::model::Location;
7281 /// use google_cloud_type::model::LatLng;
7282 /// let x = Location::new().set_lat_lng(LatLng::default()/* use setters */);
7283 /// ```
7284 pub fn set_lat_lng<T>(mut self, v: T) -> Self
7285 where
7286 T: std::convert::Into<google_cloud_type::model::LatLng>,
7287 {
7288 self.lat_lng = std::option::Option::Some(v.into());
7289 self
7290 }
7291
7292 /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
7293 ///
7294 /// # Example
7295 /// ```ignore,no_run
7296 /// # use google_maps_routeoptimization_v1::model::Location;
7297 /// use google_cloud_type::model::LatLng;
7298 /// let x = Location::new().set_or_clear_lat_lng(Some(LatLng::default()/* use setters */));
7299 /// let x = Location::new().set_or_clear_lat_lng(None::<LatLng>);
7300 /// ```
7301 pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
7302 where
7303 T: std::convert::Into<google_cloud_type::model::LatLng>,
7304 {
7305 self.lat_lng = v.map(|x| x.into());
7306 self
7307 }
7308
7309 /// Sets the value of [heading][crate::model::Location::heading].
7310 ///
7311 /// # Example
7312 /// ```ignore,no_run
7313 /// # use google_maps_routeoptimization_v1::model::Location;
7314 /// let x = Location::new().set_heading(42);
7315 /// ```
7316 pub fn set_heading<T>(mut self, v: T) -> Self
7317 where
7318 T: std::convert::Into<i32>,
7319 {
7320 self.heading = std::option::Option::Some(v.into());
7321 self
7322 }
7323
7324 /// Sets or clears the value of [heading][crate::model::Location::heading].
7325 ///
7326 /// # Example
7327 /// ```ignore,no_run
7328 /// # use google_maps_routeoptimization_v1::model::Location;
7329 /// let x = Location::new().set_or_clear_heading(Some(42));
7330 /// let x = Location::new().set_or_clear_heading(None::<i32>);
7331 /// ```
7332 pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
7333 where
7334 T: std::convert::Into<i32>,
7335 {
7336 self.heading = v.map(|x| x.into());
7337 self
7338 }
7339}
7340
7341impl wkt::message::Message for Location {
7342 fn typename() -> &'static str {
7343 "type.googleapis.com/google.maps.routeoptimization.v1.Location"
7344 }
7345}
7346
7347/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
7348/// is a contiguous period of time during which the vehicle remains idle at its
7349/// current position and cannot perform any visit. A break may occur:
7350///
7351/// * during the travel between two visits (which includes the time right
7352/// before or right after a visit, but not in the middle of a visit), in
7353/// which case it extends the corresponding transit time between the visits,
7354/// * or before the vehicle start (the vehicle may not start in the middle of
7355/// a break), in which case it does not affect the vehicle start time.
7356/// * or after the vehicle end (ditto, with the vehicle end time).
7357#[derive(Clone, Default, PartialEq)]
7358#[non_exhaustive]
7359pub struct BreakRule {
7360 /// Sequence of breaks. See the `BreakRequest` message.
7361 pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
7362
7363 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
7364 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
7365 pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
7366
7367 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7368}
7369
7370impl BreakRule {
7371 /// Creates a new default instance.
7372 pub fn new() -> Self {
7373 std::default::Default::default()
7374 }
7375
7376 /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
7377 ///
7378 /// # Example
7379 /// ```ignore,no_run
7380 /// # use google_maps_routeoptimization_v1::model::BreakRule;
7381 /// use google_maps_routeoptimization_v1::model::break_rule::BreakRequest;
7382 /// let x = BreakRule::new()
7383 /// .set_break_requests([
7384 /// BreakRequest::default()/* use setters */,
7385 /// BreakRequest::default()/* use (different) setters */,
7386 /// ]);
7387 /// ```
7388 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
7389 where
7390 T: std::iter::IntoIterator<Item = V>,
7391 V: std::convert::Into<crate::model::break_rule::BreakRequest>,
7392 {
7393 use std::iter::Iterator;
7394 self.break_requests = v.into_iter().map(|i| i.into()).collect();
7395 self
7396 }
7397
7398 /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
7399 ///
7400 /// # Example
7401 /// ```ignore,no_run
7402 /// # use google_maps_routeoptimization_v1::model::BreakRule;
7403 /// use google_maps_routeoptimization_v1::model::break_rule::FrequencyConstraint;
7404 /// let x = BreakRule::new()
7405 /// .set_frequency_constraints([
7406 /// FrequencyConstraint::default()/* use setters */,
7407 /// FrequencyConstraint::default()/* use (different) setters */,
7408 /// ]);
7409 /// ```
7410 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
7411 where
7412 T: std::iter::IntoIterator<Item = V>,
7413 V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
7414 {
7415 use std::iter::Iterator;
7416 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
7417 self
7418 }
7419}
7420
7421impl wkt::message::Message for BreakRule {
7422 fn typename() -> &'static str {
7423 "type.googleapis.com/google.maps.routeoptimization.v1.BreakRule"
7424 }
7425}
7426
7427/// Defines additional types related to [BreakRule].
7428pub mod break_rule {
7429 #[allow(unused_imports)]
7430 use super::*;
7431
7432 /// The sequence of breaks (i.e. their number and order) that apply to each
7433 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
7434 /// that sequence, in the order in which they must occur. Their time windows
7435 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
7436 /// be compatible with the order (this is checked).
7437 #[derive(Clone, Default, PartialEq)]
7438 #[non_exhaustive]
7439 pub struct BreakRequest {
7440 /// Required. Lower bound (inclusive) on the start of the break.
7441 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
7442
7443 /// Required. Upper bound (inclusive) on the start of the break.
7444 pub latest_start_time: std::option::Option<wkt::Timestamp>,
7445
7446 /// Required. Minimum duration of the break. Must be positive.
7447 pub min_duration: std::option::Option<wkt::Duration>,
7448
7449 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7450 }
7451
7452 impl BreakRequest {
7453 /// Creates a new default instance.
7454 pub fn new() -> Self {
7455 std::default::Default::default()
7456 }
7457
7458 /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7459 ///
7460 /// # Example
7461 /// ```ignore,no_run
7462 /// # use google_maps_routeoptimization_v1::model::break_rule::BreakRequest;
7463 /// use wkt::Timestamp;
7464 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
7465 /// ```
7466 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
7467 where
7468 T: std::convert::Into<wkt::Timestamp>,
7469 {
7470 self.earliest_start_time = std::option::Option::Some(v.into());
7471 self
7472 }
7473
7474 /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7475 ///
7476 /// # Example
7477 /// ```ignore,no_run
7478 /// # use google_maps_routeoptimization_v1::model::break_rule::BreakRequest;
7479 /// use wkt::Timestamp;
7480 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
7481 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
7482 /// ```
7483 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7484 where
7485 T: std::convert::Into<wkt::Timestamp>,
7486 {
7487 self.earliest_start_time = v.map(|x| x.into());
7488 self
7489 }
7490
7491 /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7492 ///
7493 /// # Example
7494 /// ```ignore,no_run
7495 /// # use google_maps_routeoptimization_v1::model::break_rule::BreakRequest;
7496 /// use wkt::Timestamp;
7497 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
7498 /// ```
7499 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
7500 where
7501 T: std::convert::Into<wkt::Timestamp>,
7502 {
7503 self.latest_start_time = std::option::Option::Some(v.into());
7504 self
7505 }
7506
7507 /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7508 ///
7509 /// # Example
7510 /// ```ignore,no_run
7511 /// # use google_maps_routeoptimization_v1::model::break_rule::BreakRequest;
7512 /// use wkt::Timestamp;
7513 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
7514 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
7515 /// ```
7516 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7517 where
7518 T: std::convert::Into<wkt::Timestamp>,
7519 {
7520 self.latest_start_time = v.map(|x| x.into());
7521 self
7522 }
7523
7524 /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7525 ///
7526 /// # Example
7527 /// ```ignore,no_run
7528 /// # use google_maps_routeoptimization_v1::model::break_rule::BreakRequest;
7529 /// use wkt::Duration;
7530 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
7531 /// ```
7532 pub fn set_min_duration<T>(mut self, v: T) -> Self
7533 where
7534 T: std::convert::Into<wkt::Duration>,
7535 {
7536 self.min_duration = std::option::Option::Some(v.into());
7537 self
7538 }
7539
7540 /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7541 ///
7542 /// # Example
7543 /// ```ignore,no_run
7544 /// # use google_maps_routeoptimization_v1::model::break_rule::BreakRequest;
7545 /// use wkt::Duration;
7546 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
7547 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
7548 /// ```
7549 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
7550 where
7551 T: std::convert::Into<wkt::Duration>,
7552 {
7553 self.min_duration = v.map(|x| x.into());
7554 self
7555 }
7556 }
7557
7558 impl wkt::message::Message for BreakRequest {
7559 fn typename() -> &'static str {
7560 "type.googleapis.com/google.maps.routeoptimization.v1.BreakRule.BreakRequest"
7561 }
7562 }
7563
7564 /// One may further constrain the frequency and duration of the breaks
7565 /// specified above, by enforcing a minimum break frequency, such as
7566 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
7567 /// this can be interpreted as "Within any sliding time window of 12h, there
7568 /// must be at least one break of at least one hour", that example would
7569 /// translate to the following `FrequencyConstraint`:
7570 ///
7571 /// ```norust
7572 /// {
7573 /// min_break_duration { seconds: 3600 } # 1 hour.
7574 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
7575 /// }
7576 /// ```
7577 ///
7578 /// The timing and duration of the breaks in the solution will respect all
7579 /// such constraints, in addition to the time windows and minimum durations
7580 /// already specified in the `BreakRequest`.
7581 ///
7582 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
7583 /// For example, the following schedule honors the "1h every 12h" example:
7584 ///
7585 /// ```norust
7586 /// 04:00 vehicle start
7587 /// .. performing travel and visits ..
7588 /// 09:00 1 hour break
7589 /// 10:00 end of the break
7590 /// .. performing travel and visits ..
7591 /// 12:00 20-min lunch break
7592 /// 12:20 end of the break
7593 /// .. performing travel and visits ..
7594 /// 21:00 1 hour break
7595 /// 22:00 end of the break
7596 /// .. performing travel and visits ..
7597 /// 23:59 vehicle end
7598 /// ```
7599 #[derive(Clone, Default, PartialEq)]
7600 #[non_exhaustive]
7601 pub struct FrequencyConstraint {
7602 /// Required. Minimum break duration for this constraint. Nonnegative.
7603 /// See description of `FrequencyConstraint`.
7604 pub min_break_duration: std::option::Option<wkt::Duration>,
7605
7606 /// Required. Maximum allowed span of any interval of time in the route that
7607 /// does not include at least partially a break of `duration >=
7608 /// min_break_duration`. Must be positive.
7609 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
7610
7611 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7612 }
7613
7614 impl FrequencyConstraint {
7615 /// Creates a new default instance.
7616 pub fn new() -> Self {
7617 std::default::Default::default()
7618 }
7619
7620 /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7621 ///
7622 /// # Example
7623 /// ```ignore,no_run
7624 /// # use google_maps_routeoptimization_v1::model::break_rule::FrequencyConstraint;
7625 /// use wkt::Duration;
7626 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
7627 /// ```
7628 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
7629 where
7630 T: std::convert::Into<wkt::Duration>,
7631 {
7632 self.min_break_duration = std::option::Option::Some(v.into());
7633 self
7634 }
7635
7636 /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7637 ///
7638 /// # Example
7639 /// ```ignore,no_run
7640 /// # use google_maps_routeoptimization_v1::model::break_rule::FrequencyConstraint;
7641 /// use wkt::Duration;
7642 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
7643 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
7644 /// ```
7645 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7646 where
7647 T: std::convert::Into<wkt::Duration>,
7648 {
7649 self.min_break_duration = v.map(|x| x.into());
7650 self
7651 }
7652
7653 /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7654 ///
7655 /// # Example
7656 /// ```ignore,no_run
7657 /// # use google_maps_routeoptimization_v1::model::break_rule::FrequencyConstraint;
7658 /// use wkt::Duration;
7659 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
7660 /// ```
7661 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
7662 where
7663 T: std::convert::Into<wkt::Duration>,
7664 {
7665 self.max_inter_break_duration = std::option::Option::Some(v.into());
7666 self
7667 }
7668
7669 /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7670 ///
7671 /// # Example
7672 /// ```ignore,no_run
7673 /// # use google_maps_routeoptimization_v1::model::break_rule::FrequencyConstraint;
7674 /// use wkt::Duration;
7675 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
7676 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
7677 /// ```
7678 pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7679 where
7680 T: std::convert::Into<wkt::Duration>,
7681 {
7682 self.max_inter_break_duration = v.map(|x| x.into());
7683 self
7684 }
7685 }
7686
7687 impl wkt::message::Message for FrequencyConstraint {
7688 fn typename() -> &'static str {
7689 "type.googleapis.com/google.maps.routeoptimization.v1.BreakRule.FrequencyConstraint"
7690 }
7691 }
7692}
7693
7694/// A vehicle's route can be decomposed, along the time axis, like this (we
7695/// assume there are n visits):
7696///
7697/// ```norust
7698/// | | | | | T[2], | | |
7699/// | Transition | Visit #0 | | | V[2], | | |
7700/// | #0 | aka | T[1] | V[1] | ... | V[n-1] | T[n] |
7701/// | aka T[0] | V[0] | | | V[n-2],| | |
7702/// | | | | | T[n-1] | | |
7703/// ^ ^ ^ ^ ^ ^ ^ ^
7704/// vehicle V[0].start V[0].end V[1]. V[1]. V[n]. V[n]. vehicle
7705/// start (arrival) (departure) start end start end end
7706/// ```
7707///
7708/// Note that we make a difference between:
7709///
7710/// * "punctual events", such as the vehicle start and end and each visit's start
7711/// and end (aka arrival and departure). They happen at a given second.
7712/// * "time intervals", such as the visits themselves, and the transition between
7713/// visits. Though time intervals can sometimes have zero duration, i.e. start
7714/// and end at the same second, they often have a positive duration.
7715///
7716/// Invariants:
7717///
7718/// * If there are n visits, there are n+1 transitions.
7719/// * A visit is always surrounded by a transition before it (same index) and a
7720/// transition after it (index + 1).
7721/// * The vehicle start is always followed by transition #0.
7722/// * The vehicle end is always preceded by transition #n.
7723///
7724/// Zooming in, here is what happens during a `Transition` and a `Visit`:
7725///
7726/// ```norust
7727/// ---+-------------------------------------+-----------------------------+-->
7728/// | TRANSITION[i] | VISIT[i] |
7729/// | | |
7730/// | * TRAVEL: the vehicle moves from | PERFORM the visit: |
7731/// | VISIT[i-1].departure_location to | |
7732/// | VISIT[i].arrival_location, which | * Spend some time: |
7733/// | takes a given travel duration | the "visit duration". |
7734/// | and distance | |
7735/// | | * Load or unload |
7736/// | * BREAKS: the driver may have | some quantities from the |
7737/// | breaks (e.g. lunch break). | vehicle: the "demand". |
7738/// | | |
7739/// | * WAIT: the driver/vehicle does | |
7740/// | nothing. This can happen for | |
7741/// | many reasons, for example when | |
7742/// | the vehicle reaches the next | |
7743/// | event's destination before the | |
7744/// | start of its time window | |
7745/// | | |
7746/// | * DELAY: *right before* the next | |
7747/// | arrival. E.g. the vehicle and/or | |
7748/// | driver spends time unloading. | |
7749/// | | |
7750/// ---+-------------------------------------+-----------------------------+-->
7751/// ^ ^ ^
7752/// V[i-1].end V[i].start V[i].end
7753/// ```
7754///
7755/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
7756/// during a transition.
7757///
7758/// * They don't overlap.
7759/// * The DELAY is unique and *must* be a contiguous period of time right
7760/// before the next visit (or vehicle end). Thus, it suffice to know the
7761/// delay duration to know its start and end time.
7762/// * The BREAKS are contiguous, non-overlapping periods of time. The
7763/// response specifies the start time and duration of each break.
7764/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
7765/// during this transition. Clients can assume that travel happens "as soon as
7766/// possible" and that "wait" fills the remaining time.
7767///
7768/// A (complex) example:
7769///
7770/// ```norust
7771/// TRANSITION[i]
7772/// --++-----+-----------------------------------------------------------++-->
7773/// || | | | | | | ||
7774/// || T | B | T | | B | | D ||
7775/// || r | r | r | W | r | W | e ||
7776/// || a | e | a | a | e | a | l ||
7777/// || v | a | v | i | a | i | a ||
7778/// || e | k | e | t | k | t | y ||
7779/// || l | | l | | | | ||
7780/// || | | | | | | ||
7781/// --++-----------------------------------------------------------------++-->
7782/// ```
7783#[derive(Clone, Default, PartialEq)]
7784#[non_exhaustive]
7785pub struct ShipmentRoute {
7786 /// Vehicle performing the route, identified by its index in the source
7787 /// `ShipmentModel`.
7788 pub vehicle_index: i32,
7789
7790 /// Label of the vehicle performing this route, equal to
7791 /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
7792 pub vehicle_label: std::string::String,
7793
7794 /// Time at which the vehicle starts its route.
7795 pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
7796
7797 /// Time at which the vehicle finishes its route.
7798 pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
7799
7800 /// Ordered sequence of visits representing a route.
7801 /// visits[i] is the i-th visit in the route.
7802 /// If this field is empty, the vehicle is considered as unused.
7803 pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
7804
7805 /// Ordered list of transitions for the route.
7806 pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
7807
7808 /// When
7809 /// [OptimizeToursRequest.consider_road_traffic][google.maps.routeoptimization.v1.OptimizeToursRequest.consider_road_traffic],
7810 /// is set to true, this field indicates that inconsistencies in route timings
7811 /// are predicted using traffic-based travel duration estimates. There may be
7812 /// insufficient time to complete traffic-adjusted travel, delays, and breaks
7813 /// between visits, before the first visit, or after the last visit, while
7814 /// still satisfying the visit and vehicle time windows. For example,
7815 ///
7816 /// ```norust
7817 /// start_time(previous_visit) + duration(previous_visit) +
7818 /// travel_duration(previous_visit, next_visit) > start_time(next_visit)
7819 /// ```
7820 ///
7821 /// Arrival at next_visit will likely happen later than its current
7822 /// time window due the increased estimate of travel time
7823 /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
7824 /// may be forced to overlap with a visit due to an increase in travel time
7825 /// estimates and visit or break time window restrictions.
7826 ///
7827 /// [google.maps.routeoptimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
7828 pub has_traffic_infeasibilities: bool,
7829
7830 /// The encoded polyline representation of the route.
7831 /// This field is only populated if
7832 /// [OptimizeToursRequest.populate_polylines][google.maps.routeoptimization.v1.OptimizeToursRequest.populate_polylines]
7833 /// is set to true.
7834 ///
7835 /// [google.maps.routeoptimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
7836 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
7837
7838 /// Breaks scheduled for the vehicle performing this route.
7839 /// The `breaks` sequence represents time intervals, each starting at the
7840 /// corresponding `start_time` and lasting `duration` seconds.
7841 pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
7842
7843 /// Duration, distance and load metrics for this route. The fields of
7844 /// [AggregatedMetrics][google.maps.routeoptimization.v1.AggregatedMetrics] are
7845 /// summed over all
7846 /// [ShipmentRoute.transitions][google.maps.routeoptimization.v1.ShipmentRoute.transitions]
7847 /// or
7848 /// [ShipmentRoute.visits][google.maps.routeoptimization.v1.ShipmentRoute.visits],
7849 /// depending on the context.
7850 ///
7851 /// [google.maps.routeoptimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
7852 /// [google.maps.routeoptimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
7853 /// [google.maps.routeoptimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
7854 pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
7855
7856 /// [VehicleFullness][google.maps.routeoptimization.v1.VehicleFullness] field
7857 /// for computing how close the capped metrics are to their respective vehicle
7858 /// limits. Its fields are ratios between a capped metric field (e.g.
7859 /// [AggregatedMetrics.travel_distance_meters][google.maps.routeoptimization.v1.AggregatedMetrics.travel_distance_meters])
7860 /// and the related vehicle limit (e.g.
7861 /// [Vehicle.route_distance_limit][google.maps.routeoptimization.v1.Vehicle.route_distance_limit]).
7862 ///
7863 /// Experimental: This field's behavior or existence may change in future.
7864 ///
7865 /// [google.maps.routeoptimization.v1.AggregatedMetrics.travel_distance_meters]: crate::model::AggregatedMetrics::travel_distance_meters
7866 /// [google.maps.routeoptimization.v1.Vehicle.route_distance_limit]: crate::model::Vehicle::route_distance_limit
7867 /// [google.maps.routeoptimization.v1.VehicleFullness]: crate::model::VehicleFullness
7868 pub vehicle_fullness: std::option::Option<crate::model::VehicleFullness>,
7869
7870 /// Cost of the route, broken down by cost-related request fields.
7871 /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
7872 /// "model.shipments.pickups.cost", and the values are the total cost
7873 /// generated by the corresponding cost field, aggregated over the whole route.
7874 /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
7875 /// pickup costs over the route. All costs defined in the model are reported in
7876 /// detail here with the exception of costs related to TransitionAttributes
7877 /// that are only reported in an aggregated way as of 2022/01.
7878 pub route_costs: std::collections::HashMap<std::string::String, f64>,
7879
7880 /// Total cost of the route. The sum of all costs in the cost map.
7881 pub route_total_cost: f64,
7882
7883 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7884}
7885
7886impl ShipmentRoute {
7887 /// Creates a new default instance.
7888 pub fn new() -> Self {
7889 std::default::Default::default()
7890 }
7891
7892 /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
7893 ///
7894 /// # Example
7895 /// ```ignore,no_run
7896 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
7897 /// let x = ShipmentRoute::new().set_vehicle_index(42);
7898 /// ```
7899 pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7900 self.vehicle_index = v.into();
7901 self
7902 }
7903
7904 /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
7905 ///
7906 /// # Example
7907 /// ```ignore,no_run
7908 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
7909 /// let x = ShipmentRoute::new().set_vehicle_label("example");
7910 /// ```
7911 pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7912 self.vehicle_label = v.into();
7913 self
7914 }
7915
7916 /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
7917 ///
7918 /// # Example
7919 /// ```ignore,no_run
7920 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
7921 /// use wkt::Timestamp;
7922 /// let x = ShipmentRoute::new().set_vehicle_start_time(Timestamp::default()/* use setters */);
7923 /// ```
7924 pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
7925 where
7926 T: std::convert::Into<wkt::Timestamp>,
7927 {
7928 self.vehicle_start_time = std::option::Option::Some(v.into());
7929 self
7930 }
7931
7932 /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
7933 ///
7934 /// # Example
7935 /// ```ignore,no_run
7936 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
7937 /// use wkt::Timestamp;
7938 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(Some(Timestamp::default()/* use setters */));
7939 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(None::<Timestamp>);
7940 /// ```
7941 pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7942 where
7943 T: std::convert::Into<wkt::Timestamp>,
7944 {
7945 self.vehicle_start_time = v.map(|x| x.into());
7946 self
7947 }
7948
7949 /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
7950 ///
7951 /// # Example
7952 /// ```ignore,no_run
7953 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
7954 /// use wkt::Timestamp;
7955 /// let x = ShipmentRoute::new().set_vehicle_end_time(Timestamp::default()/* use setters */);
7956 /// ```
7957 pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
7958 where
7959 T: std::convert::Into<wkt::Timestamp>,
7960 {
7961 self.vehicle_end_time = std::option::Option::Some(v.into());
7962 self
7963 }
7964
7965 /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
7966 ///
7967 /// # Example
7968 /// ```ignore,no_run
7969 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
7970 /// use wkt::Timestamp;
7971 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(Some(Timestamp::default()/* use setters */));
7972 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(None::<Timestamp>);
7973 /// ```
7974 pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
7975 where
7976 T: std::convert::Into<wkt::Timestamp>,
7977 {
7978 self.vehicle_end_time = v.map(|x| x.into());
7979 self
7980 }
7981
7982 /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
7983 ///
7984 /// # Example
7985 /// ```ignore,no_run
7986 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
7987 /// use google_maps_routeoptimization_v1::model::shipment_route::Visit;
7988 /// let x = ShipmentRoute::new()
7989 /// .set_visits([
7990 /// Visit::default()/* use setters */,
7991 /// Visit::default()/* use (different) setters */,
7992 /// ]);
7993 /// ```
7994 pub fn set_visits<T, V>(mut self, v: T) -> Self
7995 where
7996 T: std::iter::IntoIterator<Item = V>,
7997 V: std::convert::Into<crate::model::shipment_route::Visit>,
7998 {
7999 use std::iter::Iterator;
8000 self.visits = v.into_iter().map(|i| i.into()).collect();
8001 self
8002 }
8003
8004 /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
8005 ///
8006 /// # Example
8007 /// ```ignore,no_run
8008 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8009 /// use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8010 /// let x = ShipmentRoute::new()
8011 /// .set_transitions([
8012 /// Transition::default()/* use setters */,
8013 /// Transition::default()/* use (different) setters */,
8014 /// ]);
8015 /// ```
8016 pub fn set_transitions<T, V>(mut self, v: T) -> Self
8017 where
8018 T: std::iter::IntoIterator<Item = V>,
8019 V: std::convert::Into<crate::model::shipment_route::Transition>,
8020 {
8021 use std::iter::Iterator;
8022 self.transitions = v.into_iter().map(|i| i.into()).collect();
8023 self
8024 }
8025
8026 /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
8027 ///
8028 /// # Example
8029 /// ```ignore,no_run
8030 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8031 /// let x = ShipmentRoute::new().set_has_traffic_infeasibilities(true);
8032 /// ```
8033 pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8034 self.has_traffic_infeasibilities = v.into();
8035 self
8036 }
8037
8038 /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8039 ///
8040 /// # Example
8041 /// ```ignore,no_run
8042 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8043 /// use google_maps_routeoptimization_v1::model::shipment_route::EncodedPolyline;
8044 /// let x = ShipmentRoute::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
8045 /// ```
8046 pub fn set_route_polyline<T>(mut self, v: T) -> Self
8047 where
8048 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8049 {
8050 self.route_polyline = std::option::Option::Some(v.into());
8051 self
8052 }
8053
8054 /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8055 ///
8056 /// # Example
8057 /// ```ignore,no_run
8058 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8059 /// use google_maps_routeoptimization_v1::model::shipment_route::EncodedPolyline;
8060 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
8061 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
8062 /// ```
8063 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
8064 where
8065 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8066 {
8067 self.route_polyline = v.map(|x| x.into());
8068 self
8069 }
8070
8071 /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
8072 ///
8073 /// # Example
8074 /// ```ignore,no_run
8075 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8076 /// use google_maps_routeoptimization_v1::model::shipment_route::Break;
8077 /// let x = ShipmentRoute::new()
8078 /// .set_breaks([
8079 /// Break::default()/* use setters */,
8080 /// Break::default()/* use (different) setters */,
8081 /// ]);
8082 /// ```
8083 pub fn set_breaks<T, V>(mut self, v: T) -> Self
8084 where
8085 T: std::iter::IntoIterator<Item = V>,
8086 V: std::convert::Into<crate::model::shipment_route::Break>,
8087 {
8088 use std::iter::Iterator;
8089 self.breaks = v.into_iter().map(|i| i.into()).collect();
8090 self
8091 }
8092
8093 /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
8094 ///
8095 /// # Example
8096 /// ```ignore,no_run
8097 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8098 /// use google_maps_routeoptimization_v1::model::AggregatedMetrics;
8099 /// let x = ShipmentRoute::new().set_metrics(AggregatedMetrics::default()/* use setters */);
8100 /// ```
8101 pub fn set_metrics<T>(mut self, v: T) -> Self
8102 where
8103 T: std::convert::Into<crate::model::AggregatedMetrics>,
8104 {
8105 self.metrics = std::option::Option::Some(v.into());
8106 self
8107 }
8108
8109 /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
8110 ///
8111 /// # Example
8112 /// ```ignore,no_run
8113 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8114 /// use google_maps_routeoptimization_v1::model::AggregatedMetrics;
8115 /// let x = ShipmentRoute::new().set_or_clear_metrics(Some(AggregatedMetrics::default()/* use setters */));
8116 /// let x = ShipmentRoute::new().set_or_clear_metrics(None::<AggregatedMetrics>);
8117 /// ```
8118 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
8119 where
8120 T: std::convert::Into<crate::model::AggregatedMetrics>,
8121 {
8122 self.metrics = v.map(|x| x.into());
8123 self
8124 }
8125
8126 /// Sets the value of [vehicle_fullness][crate::model::ShipmentRoute::vehicle_fullness].
8127 ///
8128 /// # Example
8129 /// ```ignore,no_run
8130 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8131 /// use google_maps_routeoptimization_v1::model::VehicleFullness;
8132 /// let x = ShipmentRoute::new().set_vehicle_fullness(VehicleFullness::default()/* use setters */);
8133 /// ```
8134 pub fn set_vehicle_fullness<T>(mut self, v: T) -> Self
8135 where
8136 T: std::convert::Into<crate::model::VehicleFullness>,
8137 {
8138 self.vehicle_fullness = std::option::Option::Some(v.into());
8139 self
8140 }
8141
8142 /// Sets or clears the value of [vehicle_fullness][crate::model::ShipmentRoute::vehicle_fullness].
8143 ///
8144 /// # Example
8145 /// ```ignore,no_run
8146 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8147 /// use google_maps_routeoptimization_v1::model::VehicleFullness;
8148 /// let x = ShipmentRoute::new().set_or_clear_vehicle_fullness(Some(VehicleFullness::default()/* use setters */));
8149 /// let x = ShipmentRoute::new().set_or_clear_vehicle_fullness(None::<VehicleFullness>);
8150 /// ```
8151 pub fn set_or_clear_vehicle_fullness<T>(mut self, v: std::option::Option<T>) -> Self
8152 where
8153 T: std::convert::Into<crate::model::VehicleFullness>,
8154 {
8155 self.vehicle_fullness = v.map(|x| x.into());
8156 self
8157 }
8158
8159 /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
8160 ///
8161 /// # Example
8162 /// ```ignore,no_run
8163 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8164 /// let x = ShipmentRoute::new().set_route_costs([
8165 /// ("key0", 123.5),
8166 /// ("key1", 456.5),
8167 /// ]);
8168 /// ```
8169 pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
8170 where
8171 T: std::iter::IntoIterator<Item = (K, V)>,
8172 K: std::convert::Into<std::string::String>,
8173 V: std::convert::Into<f64>,
8174 {
8175 use std::iter::Iterator;
8176 self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8177 self
8178 }
8179
8180 /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
8181 ///
8182 /// # Example
8183 /// ```ignore,no_run
8184 /// # use google_maps_routeoptimization_v1::model::ShipmentRoute;
8185 /// let x = ShipmentRoute::new().set_route_total_cost(42.0);
8186 /// ```
8187 pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8188 self.route_total_cost = v.into();
8189 self
8190 }
8191}
8192
8193impl wkt::message::Message for ShipmentRoute {
8194 fn typename() -> &'static str {
8195 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentRoute"
8196 }
8197}
8198
8199/// Defines additional types related to [ShipmentRoute].
8200pub mod shipment_route {
8201 #[allow(unused_imports)]
8202 use super::*;
8203
8204 /// A visit performed during a route. This visit corresponds to a pickup or a
8205 /// delivery of a `Shipment`.
8206 #[derive(Clone, Default, PartialEq)]
8207 #[non_exhaustive]
8208 pub struct Visit {
8209 /// Index of the `shipments` field in the source
8210 /// [ShipmentModel][google.maps.routeoptimization.v1.ShipmentModel].
8211 ///
8212 /// [google.maps.routeoptimization.v1.ShipmentModel]: crate::model::ShipmentModel
8213 pub shipment_index: i32,
8214
8215 /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
8216 /// corresponds to a delivery.
8217 pub is_pickup: bool,
8218
8219 /// Index of `VisitRequest` in either the pickup or delivery field of the
8220 /// `Shipment` (see `is_pickup`).
8221 pub visit_request_index: i32,
8222
8223 /// Time at which the visit starts. Note that the vehicle may arrive earlier
8224 /// than this at the visit location. Times are consistent with the
8225 /// `ShipmentModel`.
8226 pub start_time: std::option::Option<wkt::Timestamp>,
8227
8228 /// Total visit load demand as the sum of the shipment and the visit request
8229 /// `load_demands`. The values are negative if the visit is a delivery.
8230 /// Demands are reported for the same types as the
8231 /// [Transition.loads][google.maps.routeoptimization.v1.ShipmentRoute.Transition]
8232 /// (see this field).
8233 ///
8234 /// [google.maps.routeoptimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
8235 pub load_demands:
8236 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
8237
8238 /// Extra detour time due to the shipments visited on the route before the
8239 /// visit and to the potential waiting time induced by time windows.
8240 /// If the visit is a delivery, the detour is computed from the corresponding
8241 /// pickup visit and is equal to:
8242 ///
8243 /// ```norust
8244 /// start_time(delivery) - start_time(pickup)
8245 /// - (duration(pickup) + travel duration from the pickup location
8246 /// to the delivery location).
8247 /// ```
8248 ///
8249 /// Otherwise, it is computed from the vehicle `start_location` and is equal
8250 /// to:
8251 ///
8252 /// ```norust
8253 /// start_time - vehicle_start_time - travel duration from
8254 /// the vehicle's `start_location` to the visit.
8255 /// ```
8256 pub detour: std::option::Option<wkt::Duration>,
8257
8258 /// Copy of the corresponding `Shipment.label`, if specified in the
8259 /// `Shipment`.
8260 pub shipment_label: std::string::String,
8261
8262 /// Copy of the corresponding
8263 /// [VisitRequest.label][google.maps.routeoptimization.v1.Shipment.VisitRequest.label],
8264 /// if specified in the `VisitRequest`.
8265 ///
8266 /// [google.maps.routeoptimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
8267 pub visit_label: std::string::String,
8268
8269 /// An opaque token representing information about a visit location.
8270 ///
8271 /// This field may be populated in the result routes' visits when
8272 /// [VisitRequest.avoid_u_turns][google.maps.routeoptimization.v1.Shipment.VisitRequest.avoid_u_turns]
8273 /// was set to true for this visit or if
8274 /// [ShipmentModel.avoid_u_turns][google.maps.routeoptimization.v1.ShipmentModel.avoid_u_turns]
8275 /// was set to true in the request
8276 /// [OptimizeToursRequest][google.maps.routeoptimization.v1.OptimizeToursRequest].
8277 ///
8278 /// Experimental: See
8279 /// <https://developers.google.com/maps/tt/route-optimization/experimental/u-turn-avoidance/make-request>
8280 /// for more details.
8281 ///
8282 /// [google.maps.routeoptimization.v1.OptimizeToursRequest]: crate::model::OptimizeToursRequest
8283 /// [google.maps.routeoptimization.v1.Shipment.VisitRequest.avoid_u_turns]: crate::model::shipment::VisitRequest::avoid_u_turns
8284 pub injected_solution_location_token: std::option::Option<i32>,
8285
8286 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8287 }
8288
8289 impl Visit {
8290 /// Creates a new default instance.
8291 pub fn new() -> Self {
8292 std::default::Default::default()
8293 }
8294
8295 /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
8296 ///
8297 /// # Example
8298 /// ```ignore,no_run
8299 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8300 /// let x = Visit::new().set_shipment_index(42);
8301 /// ```
8302 pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8303 self.shipment_index = v.into();
8304 self
8305 }
8306
8307 /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
8308 ///
8309 /// # Example
8310 /// ```ignore,no_run
8311 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8312 /// let x = Visit::new().set_is_pickup(true);
8313 /// ```
8314 pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8315 self.is_pickup = v.into();
8316 self
8317 }
8318
8319 /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
8320 ///
8321 /// # Example
8322 /// ```ignore,no_run
8323 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8324 /// let x = Visit::new().set_visit_request_index(42);
8325 /// ```
8326 pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8327 self.visit_request_index = v.into();
8328 self
8329 }
8330
8331 /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
8332 ///
8333 /// # Example
8334 /// ```ignore,no_run
8335 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8336 /// use wkt::Timestamp;
8337 /// let x = Visit::new().set_start_time(Timestamp::default()/* use setters */);
8338 /// ```
8339 pub fn set_start_time<T>(mut self, v: T) -> Self
8340 where
8341 T: std::convert::Into<wkt::Timestamp>,
8342 {
8343 self.start_time = std::option::Option::Some(v.into());
8344 self
8345 }
8346
8347 /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
8348 ///
8349 /// # Example
8350 /// ```ignore,no_run
8351 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8352 /// use wkt::Timestamp;
8353 /// let x = Visit::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8354 /// let x = Visit::new().set_or_clear_start_time(None::<Timestamp>);
8355 /// ```
8356 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8357 where
8358 T: std::convert::Into<wkt::Timestamp>,
8359 {
8360 self.start_time = v.map(|x| x.into());
8361 self
8362 }
8363
8364 /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
8365 ///
8366 /// # Example
8367 /// ```ignore,no_run
8368 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8369 /// use google_maps_routeoptimization_v1::model::shipment::Load;
8370 /// let x = Visit::new().set_load_demands([
8371 /// ("key0", Load::default()/* use setters */),
8372 /// ("key1", Load::default()/* use (different) setters */),
8373 /// ]);
8374 /// ```
8375 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
8376 where
8377 T: std::iter::IntoIterator<Item = (K, V)>,
8378 K: std::convert::Into<std::string::String>,
8379 V: std::convert::Into<crate::model::shipment::Load>,
8380 {
8381 use std::iter::Iterator;
8382 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8383 self
8384 }
8385
8386 /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
8387 ///
8388 /// # Example
8389 /// ```ignore,no_run
8390 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8391 /// use wkt::Duration;
8392 /// let x = Visit::new().set_detour(Duration::default()/* use setters */);
8393 /// ```
8394 pub fn set_detour<T>(mut self, v: T) -> Self
8395 where
8396 T: std::convert::Into<wkt::Duration>,
8397 {
8398 self.detour = std::option::Option::Some(v.into());
8399 self
8400 }
8401
8402 /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
8403 ///
8404 /// # Example
8405 /// ```ignore,no_run
8406 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8407 /// use wkt::Duration;
8408 /// let x = Visit::new().set_or_clear_detour(Some(Duration::default()/* use setters */));
8409 /// let x = Visit::new().set_or_clear_detour(None::<Duration>);
8410 /// ```
8411 pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
8412 where
8413 T: std::convert::Into<wkt::Duration>,
8414 {
8415 self.detour = v.map(|x| x.into());
8416 self
8417 }
8418
8419 /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
8420 ///
8421 /// # Example
8422 /// ```ignore,no_run
8423 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8424 /// let x = Visit::new().set_shipment_label("example");
8425 /// ```
8426 pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
8427 mut self,
8428 v: T,
8429 ) -> Self {
8430 self.shipment_label = v.into();
8431 self
8432 }
8433
8434 /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
8435 ///
8436 /// # Example
8437 /// ```ignore,no_run
8438 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8439 /// let x = Visit::new().set_visit_label("example");
8440 /// ```
8441 pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8442 self.visit_label = v.into();
8443 self
8444 }
8445
8446 /// Sets the value of [injected_solution_location_token][crate::model::shipment_route::Visit::injected_solution_location_token].
8447 ///
8448 /// # Example
8449 /// ```ignore,no_run
8450 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8451 /// let x = Visit::new().set_injected_solution_location_token(42);
8452 /// ```
8453 pub fn set_injected_solution_location_token<T>(mut self, v: T) -> Self
8454 where
8455 T: std::convert::Into<i32>,
8456 {
8457 self.injected_solution_location_token = std::option::Option::Some(v.into());
8458 self
8459 }
8460
8461 /// Sets or clears the value of [injected_solution_location_token][crate::model::shipment_route::Visit::injected_solution_location_token].
8462 ///
8463 /// # Example
8464 /// ```ignore,no_run
8465 /// # use google_maps_routeoptimization_v1::model::shipment_route::Visit;
8466 /// let x = Visit::new().set_or_clear_injected_solution_location_token(Some(42));
8467 /// let x = Visit::new().set_or_clear_injected_solution_location_token(None::<i32>);
8468 /// ```
8469 pub fn set_or_clear_injected_solution_location_token<T>(
8470 mut self,
8471 v: std::option::Option<T>,
8472 ) -> Self
8473 where
8474 T: std::convert::Into<i32>,
8475 {
8476 self.injected_solution_location_token = v.map(|x| x.into());
8477 self
8478 }
8479 }
8480
8481 impl wkt::message::Message for Visit {
8482 fn typename() -> &'static str {
8483 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentRoute.Visit"
8484 }
8485 }
8486
8487 /// Transition between two events on the route. See the description of
8488 /// [ShipmentRoute][google.maps.routeoptimization.v1.ShipmentRoute].
8489 ///
8490 /// If the vehicle does not have a `start_location` and/or `end_location`, the
8491 /// corresponding travel metrics are 0.
8492 ///
8493 /// [google.maps.routeoptimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
8494 #[derive(Clone, Default, PartialEq)]
8495 #[non_exhaustive]
8496 pub struct Transition {
8497 /// Travel duration during this transition.
8498 pub travel_duration: std::option::Option<wkt::Duration>,
8499
8500 /// Distance traveled during the transition.
8501 pub travel_distance_meters: f64,
8502
8503 /// When traffic is requested via
8504 /// [OptimizeToursRequest.consider_road_traffic]
8505 /// [google.maps.routeoptimization.v1.OptimizeToursRequest.consider_road_traffic],
8506 /// and the traffic info couldn't be retrieved for a `Transition`, this
8507 /// boolean is set to true. This may be temporary (rare hiccup in the
8508 /// realtime traffic servers) or permanent (no data for this location).
8509 pub traffic_info_unavailable: bool,
8510
8511 /// Sum of the delay durations applied to this transition. If any, the delay
8512 /// starts exactly `delay_duration` seconds before the next event (visit or
8513 /// vehicle end). See
8514 /// [TransitionAttributes.delay][google.maps.routeoptimization.v1.TransitionAttributes.delay].
8515 ///
8516 /// [google.maps.routeoptimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8517 pub delay_duration: std::option::Option<wkt::Duration>,
8518
8519 /// Sum of the duration of the breaks occurring during this transition, if
8520 /// any. Details about each break's start time and duration are stored in
8521 /// [ShipmentRoute.breaks][google.maps.routeoptimization.v1.ShipmentRoute.breaks].
8522 ///
8523 /// [google.maps.routeoptimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
8524 pub break_duration: std::option::Option<wkt::Duration>,
8525
8526 /// Time spent waiting during this transition. Wait duration corresponds to
8527 /// idle time and does not include break time. Also note that this wait time
8528 /// may be split into several non-contiguous intervals.
8529 pub wait_duration: std::option::Option<wkt::Duration>,
8530
8531 /// Total duration of the transition, provided for convenience. It is equal
8532 /// to:
8533 ///
8534 /// * next visit `start_time` (or `vehicle_end_time` if this is the last
8535 /// transition) - this transition's `start_time`;
8536 /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
8537 /// additionally holds: `total_duration = travel_duration + delay_duration
8538 ///
8539 /// + break_duration + wait_duration`.
8540 pub total_duration: std::option::Option<wkt::Duration>,
8541
8542 /// Start time of this transition.
8543 pub start_time: std::option::Option<wkt::Timestamp>,
8544
8545 /// The encoded polyline representation of the route followed during the
8546 /// transition.
8547 /// This field is only populated if [populate_transition_polylines]
8548 /// [google.maps.routeoptimization.v1.OptimizeToursRequest.populate_transition_polylines]
8549 /// is set to true.
8550 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
8551
8552 /// Output only. An opaque token that can be passed to [Navigation
8553 /// SDK](https://developers.google.com/maps/documentation/navigation) to
8554 /// reconstruct the route during navigation, and, in the event of rerouting,
8555 /// honor the original intention when the route was created. Treat this token
8556 /// as an opaque blob. Don't compare its value across requests as its value
8557 /// may change even if the service returns the exact same route. This field
8558 /// is only populated if [populate_transition_polylines]
8559 /// [google.maps.routeoptimization.v1.OptimizeToursRequest.populate_transition_polylines]
8560 /// is set to true.
8561 pub route_token: std::string::String,
8562
8563 /// Vehicle loads during this transition, for each type that either appears
8564 /// in this vehicle's
8565 /// [Vehicle.load_limits][google.maps.routeoptimization.v1.Vehicle.load_limits],
8566 /// or that have non-zero
8567 /// [Shipment.load_demands][google.maps.routeoptimization.v1.Shipment.load_demands]
8568 /// on some shipment performed on this route.
8569 ///
8570 /// The loads during the first transition are the starting loads of the
8571 /// vehicle route. Then, after each visit, the visit's `load_demands` are
8572 /// either added or subtracted to get the next transition's loads, depending
8573 /// on whether the visit was a pickup or a delivery.
8574 ///
8575 /// [google.maps.routeoptimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
8576 /// [google.maps.routeoptimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
8577 pub vehicle_loads: std::collections::HashMap<
8578 std::string::String,
8579 crate::model::shipment_route::VehicleLoad,
8580 >,
8581
8582 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8583 }
8584
8585 impl Transition {
8586 /// Creates a new default instance.
8587 pub fn new() -> Self {
8588 std::default::Default::default()
8589 }
8590
8591 /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
8592 ///
8593 /// # Example
8594 /// ```ignore,no_run
8595 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8596 /// use wkt::Duration;
8597 /// let x = Transition::new().set_travel_duration(Duration::default()/* use setters */);
8598 /// ```
8599 pub fn set_travel_duration<T>(mut self, v: T) -> Self
8600 where
8601 T: std::convert::Into<wkt::Duration>,
8602 {
8603 self.travel_duration = std::option::Option::Some(v.into());
8604 self
8605 }
8606
8607 /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
8608 ///
8609 /// # Example
8610 /// ```ignore,no_run
8611 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8612 /// use wkt::Duration;
8613 /// let x = Transition::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
8614 /// let x = Transition::new().set_or_clear_travel_duration(None::<Duration>);
8615 /// ```
8616 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
8617 where
8618 T: std::convert::Into<wkt::Duration>,
8619 {
8620 self.travel_duration = v.map(|x| x.into());
8621 self
8622 }
8623
8624 /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
8625 ///
8626 /// # Example
8627 /// ```ignore,no_run
8628 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8629 /// let x = Transition::new().set_travel_distance_meters(42.0);
8630 /// ```
8631 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8632 self.travel_distance_meters = v.into();
8633 self
8634 }
8635
8636 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
8637 ///
8638 /// # Example
8639 /// ```ignore,no_run
8640 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8641 /// let x = Transition::new().set_traffic_info_unavailable(true);
8642 /// ```
8643 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8644 self.traffic_info_unavailable = v.into();
8645 self
8646 }
8647
8648 /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
8649 ///
8650 /// # Example
8651 /// ```ignore,no_run
8652 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8653 /// use wkt::Duration;
8654 /// let x = Transition::new().set_delay_duration(Duration::default()/* use setters */);
8655 /// ```
8656 pub fn set_delay_duration<T>(mut self, v: T) -> Self
8657 where
8658 T: std::convert::Into<wkt::Duration>,
8659 {
8660 self.delay_duration = std::option::Option::Some(v.into());
8661 self
8662 }
8663
8664 /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
8665 ///
8666 /// # Example
8667 /// ```ignore,no_run
8668 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8669 /// use wkt::Duration;
8670 /// let x = Transition::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
8671 /// let x = Transition::new().set_or_clear_delay_duration(None::<Duration>);
8672 /// ```
8673 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
8674 where
8675 T: std::convert::Into<wkt::Duration>,
8676 {
8677 self.delay_duration = v.map(|x| x.into());
8678 self
8679 }
8680
8681 /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
8682 ///
8683 /// # Example
8684 /// ```ignore,no_run
8685 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8686 /// use wkt::Duration;
8687 /// let x = Transition::new().set_break_duration(Duration::default()/* use setters */);
8688 /// ```
8689 pub fn set_break_duration<T>(mut self, v: T) -> Self
8690 where
8691 T: std::convert::Into<wkt::Duration>,
8692 {
8693 self.break_duration = std::option::Option::Some(v.into());
8694 self
8695 }
8696
8697 /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
8698 ///
8699 /// # Example
8700 /// ```ignore,no_run
8701 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8702 /// use wkt::Duration;
8703 /// let x = Transition::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
8704 /// let x = Transition::new().set_or_clear_break_duration(None::<Duration>);
8705 /// ```
8706 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
8707 where
8708 T: std::convert::Into<wkt::Duration>,
8709 {
8710 self.break_duration = v.map(|x| x.into());
8711 self
8712 }
8713
8714 /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
8715 ///
8716 /// # Example
8717 /// ```ignore,no_run
8718 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8719 /// use wkt::Duration;
8720 /// let x = Transition::new().set_wait_duration(Duration::default()/* use setters */);
8721 /// ```
8722 pub fn set_wait_duration<T>(mut self, v: T) -> Self
8723 where
8724 T: std::convert::Into<wkt::Duration>,
8725 {
8726 self.wait_duration = std::option::Option::Some(v.into());
8727 self
8728 }
8729
8730 /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
8731 ///
8732 /// # Example
8733 /// ```ignore,no_run
8734 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8735 /// use wkt::Duration;
8736 /// let x = Transition::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
8737 /// let x = Transition::new().set_or_clear_wait_duration(None::<Duration>);
8738 /// ```
8739 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
8740 where
8741 T: std::convert::Into<wkt::Duration>,
8742 {
8743 self.wait_duration = v.map(|x| x.into());
8744 self
8745 }
8746
8747 /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
8748 ///
8749 /// # Example
8750 /// ```ignore,no_run
8751 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8752 /// use wkt::Duration;
8753 /// let x = Transition::new().set_total_duration(Duration::default()/* use setters */);
8754 /// ```
8755 pub fn set_total_duration<T>(mut self, v: T) -> Self
8756 where
8757 T: std::convert::Into<wkt::Duration>,
8758 {
8759 self.total_duration = std::option::Option::Some(v.into());
8760 self
8761 }
8762
8763 /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
8764 ///
8765 /// # Example
8766 /// ```ignore,no_run
8767 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8768 /// use wkt::Duration;
8769 /// let x = Transition::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
8770 /// let x = Transition::new().set_or_clear_total_duration(None::<Duration>);
8771 /// ```
8772 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
8773 where
8774 T: std::convert::Into<wkt::Duration>,
8775 {
8776 self.total_duration = v.map(|x| x.into());
8777 self
8778 }
8779
8780 /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
8781 ///
8782 /// # Example
8783 /// ```ignore,no_run
8784 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8785 /// use wkt::Timestamp;
8786 /// let x = Transition::new().set_start_time(Timestamp::default()/* use setters */);
8787 /// ```
8788 pub fn set_start_time<T>(mut self, v: T) -> Self
8789 where
8790 T: std::convert::Into<wkt::Timestamp>,
8791 {
8792 self.start_time = std::option::Option::Some(v.into());
8793 self
8794 }
8795
8796 /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
8797 ///
8798 /// # Example
8799 /// ```ignore,no_run
8800 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8801 /// use wkt::Timestamp;
8802 /// let x = Transition::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8803 /// let x = Transition::new().set_or_clear_start_time(None::<Timestamp>);
8804 /// ```
8805 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8806 where
8807 T: std::convert::Into<wkt::Timestamp>,
8808 {
8809 self.start_time = v.map(|x| x.into());
8810 self
8811 }
8812
8813 /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
8814 ///
8815 /// # Example
8816 /// ```ignore,no_run
8817 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8818 /// use google_maps_routeoptimization_v1::model::shipment_route::EncodedPolyline;
8819 /// let x = Transition::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
8820 /// ```
8821 pub fn set_route_polyline<T>(mut self, v: T) -> Self
8822 where
8823 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8824 {
8825 self.route_polyline = std::option::Option::Some(v.into());
8826 self
8827 }
8828
8829 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
8830 ///
8831 /// # Example
8832 /// ```ignore,no_run
8833 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8834 /// use google_maps_routeoptimization_v1::model::shipment_route::EncodedPolyline;
8835 /// let x = Transition::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
8836 /// let x = Transition::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
8837 /// ```
8838 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
8839 where
8840 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8841 {
8842 self.route_polyline = v.map(|x| x.into());
8843 self
8844 }
8845
8846 /// Sets the value of [route_token][crate::model::shipment_route::Transition::route_token].
8847 ///
8848 /// # Example
8849 /// ```ignore,no_run
8850 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8851 /// let x = Transition::new().set_route_token("example");
8852 /// ```
8853 pub fn set_route_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8854 self.route_token = v.into();
8855 self
8856 }
8857
8858 /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
8859 ///
8860 /// # Example
8861 /// ```ignore,no_run
8862 /// # use google_maps_routeoptimization_v1::model::shipment_route::Transition;
8863 /// use google_maps_routeoptimization_v1::model::shipment_route::VehicleLoad;
8864 /// let x = Transition::new().set_vehicle_loads([
8865 /// ("key0", VehicleLoad::default()/* use setters */),
8866 /// ("key1", VehicleLoad::default()/* use (different) setters */),
8867 /// ]);
8868 /// ```
8869 pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
8870 where
8871 T: std::iter::IntoIterator<Item = (K, V)>,
8872 K: std::convert::Into<std::string::String>,
8873 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
8874 {
8875 use std::iter::Iterator;
8876 self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8877 self
8878 }
8879 }
8880
8881 impl wkt::message::Message for Transition {
8882 fn typename() -> &'static str {
8883 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentRoute.Transition"
8884 }
8885 }
8886
8887 /// Reports the actual load of the vehicle at some point along the route,
8888 /// for a given type (see
8889 /// [Transition.vehicle_loads][google.maps.routeoptimization.v1.ShipmentRoute.Transition.vehicle_loads]).
8890 ///
8891 /// [google.maps.routeoptimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8892 #[derive(Clone, Default, PartialEq)]
8893 #[non_exhaustive]
8894 pub struct VehicleLoad {
8895 /// The amount of load on the vehicle, for the given type. The unit of load
8896 /// is usually indicated by the type. See
8897 /// [Transition.vehicle_loads][google.maps.routeoptimization.v1.ShipmentRoute.Transition.vehicle_loads].
8898 ///
8899 /// [google.maps.routeoptimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8900 pub amount: i64,
8901
8902 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8903 }
8904
8905 impl VehicleLoad {
8906 /// Creates a new default instance.
8907 pub fn new() -> Self {
8908 std::default::Default::default()
8909 }
8910
8911 /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
8912 ///
8913 /// # Example
8914 /// ```ignore,no_run
8915 /// # use google_maps_routeoptimization_v1::model::shipment_route::VehicleLoad;
8916 /// let x = VehicleLoad::new().set_amount(42);
8917 /// ```
8918 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
8919 self.amount = v.into();
8920 self
8921 }
8922 }
8923
8924 impl wkt::message::Message for VehicleLoad {
8925 fn typename() -> &'static str {
8926 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentRoute.VehicleLoad"
8927 }
8928 }
8929
8930 /// The encoded representation of a polyline. More information on polyline
8931 /// encoding can be found here:
8932 /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
8933 /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
8934 #[derive(Clone, Default, PartialEq)]
8935 #[non_exhaustive]
8936 pub struct EncodedPolyline {
8937 /// String representing encoded points of the polyline.
8938 pub points: std::string::String,
8939
8940 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8941 }
8942
8943 impl EncodedPolyline {
8944 /// Creates a new default instance.
8945 pub fn new() -> Self {
8946 std::default::Default::default()
8947 }
8948
8949 /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
8950 ///
8951 /// # Example
8952 /// ```ignore,no_run
8953 /// # use google_maps_routeoptimization_v1::model::shipment_route::EncodedPolyline;
8954 /// let x = EncodedPolyline::new().set_points("example");
8955 /// ```
8956 pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8957 self.points = v.into();
8958 self
8959 }
8960 }
8961
8962 impl wkt::message::Message for EncodedPolyline {
8963 fn typename() -> &'static str {
8964 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentRoute.EncodedPolyline"
8965 }
8966 }
8967
8968 /// Data representing the execution of a break.
8969 #[derive(Clone, Default, PartialEq)]
8970 #[non_exhaustive]
8971 pub struct Break {
8972 /// Start time of a break.
8973 pub start_time: std::option::Option<wkt::Timestamp>,
8974
8975 /// Duration of a break.
8976 pub duration: std::option::Option<wkt::Duration>,
8977
8978 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8979 }
8980
8981 impl Break {
8982 /// Creates a new default instance.
8983 pub fn new() -> Self {
8984 std::default::Default::default()
8985 }
8986
8987 /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
8988 ///
8989 /// # Example
8990 /// ```ignore,no_run
8991 /// # use google_maps_routeoptimization_v1::model::shipment_route::Break;
8992 /// use wkt::Timestamp;
8993 /// let x = Break::new().set_start_time(Timestamp::default()/* use setters */);
8994 /// ```
8995 pub fn set_start_time<T>(mut self, v: T) -> Self
8996 where
8997 T: std::convert::Into<wkt::Timestamp>,
8998 {
8999 self.start_time = std::option::Option::Some(v.into());
9000 self
9001 }
9002
9003 /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
9004 ///
9005 /// # Example
9006 /// ```ignore,no_run
9007 /// # use google_maps_routeoptimization_v1::model::shipment_route::Break;
9008 /// use wkt::Timestamp;
9009 /// let x = Break::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9010 /// let x = Break::new().set_or_clear_start_time(None::<Timestamp>);
9011 /// ```
9012 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9013 where
9014 T: std::convert::Into<wkt::Timestamp>,
9015 {
9016 self.start_time = v.map(|x| x.into());
9017 self
9018 }
9019
9020 /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
9021 ///
9022 /// # Example
9023 /// ```ignore,no_run
9024 /// # use google_maps_routeoptimization_v1::model::shipment_route::Break;
9025 /// use wkt::Duration;
9026 /// let x = Break::new().set_duration(Duration::default()/* use setters */);
9027 /// ```
9028 pub fn set_duration<T>(mut self, v: T) -> Self
9029 where
9030 T: std::convert::Into<wkt::Duration>,
9031 {
9032 self.duration = std::option::Option::Some(v.into());
9033 self
9034 }
9035
9036 /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
9037 ///
9038 /// # Example
9039 /// ```ignore,no_run
9040 /// # use google_maps_routeoptimization_v1::model::shipment_route::Break;
9041 /// use wkt::Duration;
9042 /// let x = Break::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9043 /// let x = Break::new().set_or_clear_duration(None::<Duration>);
9044 /// ```
9045 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9046 where
9047 T: std::convert::Into<wkt::Duration>,
9048 {
9049 self.duration = v.map(|x| x.into());
9050 self
9051 }
9052 }
9053
9054 impl wkt::message::Message for Break {
9055 fn typename() -> &'static str {
9056 "type.googleapis.com/google.maps.routeoptimization.v1.ShipmentRoute.Break"
9057 }
9058 }
9059}
9060
9061/// Specifies details of unperformed shipments in a solution. For trivial cases
9062/// and/or if we are able to identify the cause for skipping, we report the
9063/// reason here.
9064#[derive(Clone, Default, PartialEq)]
9065#[non_exhaustive]
9066pub struct SkippedShipment {
9067 /// The index corresponds to the index of the shipment in the source
9068 /// `ShipmentModel`.
9069 pub index: i32,
9070
9071 /// Copy of the corresponding
9072 /// [Shipment.label][google.maps.routeoptimization.v1.Shipment.label], if
9073 /// specified in the `Shipment`.
9074 ///
9075 /// [google.maps.routeoptimization.v1.Shipment.label]: crate::model::Shipment::label
9076 pub label: std::string::String,
9077
9078 /// This is a copy of the
9079 /// [Shipment.penalty_cost][google.maps.routeoptimization.v1.Shipment.penalty_cost],
9080 /// included here to make it easier to see the severity of a skipped shipment.
9081 ///
9082 /// Experimental: This field's behavior or existence may change in future.
9083 ///
9084 /// [google.maps.routeoptimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
9085 pub penalty_cost: std::option::Option<f64>,
9086
9087 /// Estimated ratio of vehicles that cannot perform this shipment for at least
9088 /// one of the reasons below.
9089 /// Note: this is only filled when reasons involve a vehicle.
9090 ///
9091 /// Experimental: This field's behavior or existence may change in future.
9092 pub estimated_incompatible_vehicle_ratio: std::option::Option<f64>,
9093
9094 /// A list of reasons that explain why the shipment was skipped. See comment
9095 /// above `Reason`. If we are unable to understand why a shipment was skipped,
9096 /// reasons will not be set.
9097 pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
9098
9099 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9100}
9101
9102impl SkippedShipment {
9103 /// Creates a new default instance.
9104 pub fn new() -> Self {
9105 std::default::Default::default()
9106 }
9107
9108 /// Sets the value of [index][crate::model::SkippedShipment::index].
9109 ///
9110 /// # Example
9111 /// ```ignore,no_run
9112 /// # use google_maps_routeoptimization_v1::model::SkippedShipment;
9113 /// let x = SkippedShipment::new().set_index(42);
9114 /// ```
9115 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9116 self.index = v.into();
9117 self
9118 }
9119
9120 /// Sets the value of [label][crate::model::SkippedShipment::label].
9121 ///
9122 /// # Example
9123 /// ```ignore,no_run
9124 /// # use google_maps_routeoptimization_v1::model::SkippedShipment;
9125 /// let x = SkippedShipment::new().set_label("example");
9126 /// ```
9127 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9128 self.label = v.into();
9129 self
9130 }
9131
9132 /// Sets the value of [penalty_cost][crate::model::SkippedShipment::penalty_cost].
9133 ///
9134 /// # Example
9135 /// ```ignore,no_run
9136 /// # use google_maps_routeoptimization_v1::model::SkippedShipment;
9137 /// let x = SkippedShipment::new().set_penalty_cost(42.0);
9138 /// ```
9139 pub fn set_penalty_cost<T>(mut self, v: T) -> Self
9140 where
9141 T: std::convert::Into<f64>,
9142 {
9143 self.penalty_cost = std::option::Option::Some(v.into());
9144 self
9145 }
9146
9147 /// Sets or clears the value of [penalty_cost][crate::model::SkippedShipment::penalty_cost].
9148 ///
9149 /// # Example
9150 /// ```ignore,no_run
9151 /// # use google_maps_routeoptimization_v1::model::SkippedShipment;
9152 /// let x = SkippedShipment::new().set_or_clear_penalty_cost(Some(42.0));
9153 /// let x = SkippedShipment::new().set_or_clear_penalty_cost(None::<f32>);
9154 /// ```
9155 pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
9156 where
9157 T: std::convert::Into<f64>,
9158 {
9159 self.penalty_cost = v.map(|x| x.into());
9160 self
9161 }
9162
9163 /// Sets the value of [estimated_incompatible_vehicle_ratio][crate::model::SkippedShipment::estimated_incompatible_vehicle_ratio].
9164 ///
9165 /// # Example
9166 /// ```ignore,no_run
9167 /// # use google_maps_routeoptimization_v1::model::SkippedShipment;
9168 /// let x = SkippedShipment::new().set_estimated_incompatible_vehicle_ratio(42.0);
9169 /// ```
9170 pub fn set_estimated_incompatible_vehicle_ratio<T>(mut self, v: T) -> Self
9171 where
9172 T: std::convert::Into<f64>,
9173 {
9174 self.estimated_incompatible_vehicle_ratio = std::option::Option::Some(v.into());
9175 self
9176 }
9177
9178 /// Sets or clears the value of [estimated_incompatible_vehicle_ratio][crate::model::SkippedShipment::estimated_incompatible_vehicle_ratio].
9179 ///
9180 /// # Example
9181 /// ```ignore,no_run
9182 /// # use google_maps_routeoptimization_v1::model::SkippedShipment;
9183 /// let x = SkippedShipment::new().set_or_clear_estimated_incompatible_vehicle_ratio(Some(42.0));
9184 /// let x = SkippedShipment::new().set_or_clear_estimated_incompatible_vehicle_ratio(None::<f32>);
9185 /// ```
9186 pub fn set_or_clear_estimated_incompatible_vehicle_ratio<T>(
9187 mut self,
9188 v: std::option::Option<T>,
9189 ) -> Self
9190 where
9191 T: std::convert::Into<f64>,
9192 {
9193 self.estimated_incompatible_vehicle_ratio = v.map(|x| x.into());
9194 self
9195 }
9196
9197 /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
9198 ///
9199 /// # Example
9200 /// ```ignore,no_run
9201 /// # use google_maps_routeoptimization_v1::model::SkippedShipment;
9202 /// use google_maps_routeoptimization_v1::model::skipped_shipment::Reason;
9203 /// let x = SkippedShipment::new()
9204 /// .set_reasons([
9205 /// Reason::default()/* use setters */,
9206 /// Reason::default()/* use (different) setters */,
9207 /// ]);
9208 /// ```
9209 pub fn set_reasons<T, V>(mut self, v: T) -> Self
9210 where
9211 T: std::iter::IntoIterator<Item = V>,
9212 V: std::convert::Into<crate::model::skipped_shipment::Reason>,
9213 {
9214 use std::iter::Iterator;
9215 self.reasons = v.into_iter().map(|i| i.into()).collect();
9216 self
9217 }
9218}
9219
9220impl wkt::message::Message for SkippedShipment {
9221 fn typename() -> &'static str {
9222 "type.googleapis.com/google.maps.routeoptimization.v1.SkippedShipment"
9223 }
9224}
9225
9226/// Defines additional types related to [SkippedShipment].
9227pub mod skipped_shipment {
9228 #[allow(unused_imports)]
9229 use super::*;
9230
9231 /// If we can explain why the shipment was skipped, reasons will be listed
9232 /// here. If the reason is not the same for all vehicles, `reason` will have
9233 /// more than 1 element. A skipped shipment cannot have duplicate reasons,
9234 /// i.e. where all fields are the same except for `example_vehicle_index`.
9235 /// Example:
9236 ///
9237 /// ```norust
9238 /// reasons {
9239 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9240 /// example_vehicle_index: 1
9241 /// example_exceeded_capacity_type: "Apples"
9242 /// }
9243 /// reasons {
9244 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9245 /// example_vehicle_index: 3
9246 /// example_exceeded_capacity_type: "Pears"
9247 /// }
9248 /// reasons {
9249 /// code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
9250 /// example_vehicle_index: 1
9251 /// }
9252 /// ```
9253 ///
9254 /// The skipped shipment is incompatible with all vehicles. The reasons may
9255 /// be different for all vehicles but at least one vehicle's "Apples"
9256 /// capacity would be exceeded (including vehicle 1), at least one vehicle's
9257 /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
9258 /// vehicle's distance limit would be exceeded (including vehicle 1).
9259 #[derive(Clone, Default, PartialEq)]
9260 #[non_exhaustive]
9261 pub struct Reason {
9262 /// Refer to the comments of Code.
9263 pub code: crate::model::skipped_shipment::reason::Code,
9264
9265 /// If the reason is related to a shipment-vehicle incompatibility, this
9266 /// field provides the index of one relevant vehicle.
9267 pub example_vehicle_index: std::option::Option<i32>,
9268
9269 /// Same as
9270 /// [example_vehicle_index][google.maps.routeoptimization.v1.SkippedShipment.Reason.example_vehicle_index]
9271 /// except that we provide the list of multiple identified vehicles. This
9272 /// list is not necessarily exhaustive. This is only filled if
9273 /// [fill_example_vehicle_indices_in_skipped_reasons][] is true.
9274 ///
9275 /// Experimental: This field's behavior or existence may change in future.
9276 ///
9277 /// [google.maps.routeoptimization.v1.SkippedShipment.Reason.example_vehicle_index]: crate::model::skipped_shipment::Reason::example_vehicle_index
9278 pub example_vehicle_indices: std::vec::Vec<i32>,
9279
9280 /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
9281 /// capacity type that is exceeded.
9282 pub example_exceeded_capacity_type: std::string::String,
9283
9284 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9285 }
9286
9287 impl Reason {
9288 /// Creates a new default instance.
9289 pub fn new() -> Self {
9290 std::default::Default::default()
9291 }
9292
9293 /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
9294 ///
9295 /// # Example
9296 /// ```ignore,no_run
9297 /// # use google_maps_routeoptimization_v1::model::skipped_shipment::Reason;
9298 /// use google_maps_routeoptimization_v1::model::skipped_shipment::reason::Code;
9299 /// let x0 = Reason::new().set_code(Code::NoVehicle);
9300 /// let x1 = Reason::new().set_code(Code::DemandExceedsVehicleCapacity);
9301 /// let x2 = Reason::new().set_code(Code::CannotBePerformedWithinVehicleDistanceLimit);
9302 /// ```
9303 pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
9304 mut self,
9305 v: T,
9306 ) -> Self {
9307 self.code = v.into();
9308 self
9309 }
9310
9311 /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9312 ///
9313 /// # Example
9314 /// ```ignore,no_run
9315 /// # use google_maps_routeoptimization_v1::model::skipped_shipment::Reason;
9316 /// let x = Reason::new().set_example_vehicle_index(42);
9317 /// ```
9318 pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
9319 where
9320 T: std::convert::Into<i32>,
9321 {
9322 self.example_vehicle_index = std::option::Option::Some(v.into());
9323 self
9324 }
9325
9326 /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9327 ///
9328 /// # Example
9329 /// ```ignore,no_run
9330 /// # use google_maps_routeoptimization_v1::model::skipped_shipment::Reason;
9331 /// let x = Reason::new().set_or_clear_example_vehicle_index(Some(42));
9332 /// let x = Reason::new().set_or_clear_example_vehicle_index(None::<i32>);
9333 /// ```
9334 pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
9335 where
9336 T: std::convert::Into<i32>,
9337 {
9338 self.example_vehicle_index = v.map(|x| x.into());
9339 self
9340 }
9341
9342 /// Sets the value of [example_vehicle_indices][crate::model::skipped_shipment::Reason::example_vehicle_indices].
9343 ///
9344 /// # Example
9345 /// ```ignore,no_run
9346 /// # use google_maps_routeoptimization_v1::model::skipped_shipment::Reason;
9347 /// let x = Reason::new().set_example_vehicle_indices([1, 2, 3]);
9348 /// ```
9349 pub fn set_example_vehicle_indices<T, V>(mut self, v: T) -> Self
9350 where
9351 T: std::iter::IntoIterator<Item = V>,
9352 V: std::convert::Into<i32>,
9353 {
9354 use std::iter::Iterator;
9355 self.example_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
9356 self
9357 }
9358
9359 /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
9360 ///
9361 /// # Example
9362 /// ```ignore,no_run
9363 /// # use google_maps_routeoptimization_v1::model::skipped_shipment::Reason;
9364 /// let x = Reason::new().set_example_exceeded_capacity_type("example");
9365 /// ```
9366 pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
9367 mut self,
9368 v: T,
9369 ) -> Self {
9370 self.example_exceeded_capacity_type = v.into();
9371 self
9372 }
9373 }
9374
9375 impl wkt::message::Message for Reason {
9376 fn typename() -> &'static str {
9377 "type.googleapis.com/google.maps.routeoptimization.v1.SkippedShipment.Reason"
9378 }
9379 }
9380
9381 /// Defines additional types related to [Reason].
9382 pub mod reason {
9383 #[allow(unused_imports)]
9384 use super::*;
9385
9386 /// Code identifying the reason type. The order here is meaningless. In
9387 /// particular, it gives no indication of whether a given reason will
9388 /// appear before another in the solution, if both apply.
9389 ///
9390 /// # Working with unknown values
9391 ///
9392 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9393 /// additional enum variants at any time. Adding new variants is not considered
9394 /// a breaking change. Applications should write their code in anticipation of:
9395 ///
9396 /// - New values appearing in future releases of the client library, **and**
9397 /// - New values received dynamically, without application changes.
9398 ///
9399 /// Please consult the [Working with enums] section in the user guide for some
9400 /// guidelines.
9401 ///
9402 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9403 #[derive(Clone, Debug, PartialEq)]
9404 #[non_exhaustive]
9405 pub enum Code {
9406 /// This should never be used.
9407 Unspecified,
9408 /// There is no vehicle in the model making all shipments infeasible.
9409 NoVehicle,
9410 /// The demand of the shipment exceeds a vehicle's capacity for some
9411 /// capacity types, one of which is `example_exceeded_capacity_type`.
9412 DemandExceedsVehicleCapacity,
9413 /// The minimum distance necessary to perform this shipment, i.e. from
9414 /// the vehicle's `start_location` to the shipment's pickup and/or delivery
9415 /// locations and to the vehicle's end location exceeds the vehicle's
9416 /// `route_distance_limit`.
9417 ///
9418 /// Note that for this computation we use the geodesic distances.
9419 CannotBePerformedWithinVehicleDistanceLimit,
9420 /// The minimum time necessary to perform this shipment, including travel
9421 /// time, wait time and service time exceeds the vehicle's
9422 /// `route_duration_limit`.
9423 ///
9424 /// Note: travel time is computed in the best-case scenario, namely as
9425 /// geodesic distance x 36 m/s (roughly 130 km/hour).
9426 CannotBePerformedWithinVehicleDurationLimit,
9427 /// Same as above but we only compare minimum travel time and the
9428 /// vehicle's `travel_duration_limit`.
9429 CannotBePerformedWithinVehicleTravelDurationLimit,
9430 /// The vehicle cannot perform this shipment in the best-case scenario
9431 /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
9432 /// computation) if it starts at its earliest start time: the total time
9433 /// would make the vehicle end after its latest end time.
9434 CannotBePerformedWithinVehicleTimeWindows,
9435 /// The `allowed_vehicle_indices` field of the shipment is not empty and
9436 /// this vehicle does not belong to it.
9437 VehicleNotAllowed,
9438 /// The vehicle's `ignore` field is true.
9439 ///
9440 /// Experimental: This field's behavior or existence may change in future.
9441 VehicleIgnored,
9442 /// The shipment's `ignore` field is true.
9443 ///
9444 /// Experimental: This field's behavior or existence may change in future.
9445 ShipmentIgnored,
9446 /// The shipment is skipped in the `injected_solution_constraint`.
9447 ///
9448 /// Experimental: This field's behavior or existence may change in future.
9449 SkippedInInjectedSolutionConstraint,
9450 /// The vehicle route relaxation specified in the
9451 /// `injected_solution_constraint` doesn't permit any visit to be inserted.
9452 ///
9453 /// Experimental: This field's behavior or existence may change in future.
9454 VehicleRouteIsFullySequenceConstrained,
9455 /// The shipment has a zero penalty cost. While this can be useful as an
9456 /// advanced modelling choice, it may also explain after the fact why a
9457 /// shipment was skipped.
9458 ///
9459 /// Experimental: This field's behavior or existence may change in future.
9460 ZeroPenaltyCost,
9461 /// If set, the enum was initialized with an unknown value.
9462 ///
9463 /// Applications can examine the value using [Code::value] or
9464 /// [Code::name].
9465 UnknownValue(code::UnknownValue),
9466 }
9467
9468 #[doc(hidden)]
9469 pub mod code {
9470 #[allow(unused_imports)]
9471 use super::*;
9472 #[derive(Clone, Debug, PartialEq)]
9473 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9474 }
9475
9476 impl Code {
9477 /// Gets the enum value.
9478 ///
9479 /// Returns `None` if the enum contains an unknown value deserialized from
9480 /// the string representation of enums.
9481 pub fn value(&self) -> std::option::Option<i32> {
9482 match self {
9483 Self::Unspecified => std::option::Option::Some(0),
9484 Self::NoVehicle => std::option::Option::Some(1),
9485 Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
9486 Self::CannotBePerformedWithinVehicleDistanceLimit => {
9487 std::option::Option::Some(3)
9488 }
9489 Self::CannotBePerformedWithinVehicleDurationLimit => {
9490 std::option::Option::Some(4)
9491 }
9492 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
9493 std::option::Option::Some(5)
9494 }
9495 Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
9496 Self::VehicleNotAllowed => std::option::Option::Some(7),
9497 Self::VehicleIgnored => std::option::Option::Some(8),
9498 Self::ShipmentIgnored => std::option::Option::Some(9),
9499 Self::SkippedInInjectedSolutionConstraint => std::option::Option::Some(10),
9500 Self::VehicleRouteIsFullySequenceConstrained => std::option::Option::Some(11),
9501 Self::ZeroPenaltyCost => std::option::Option::Some(13),
9502 Self::UnknownValue(u) => u.0.value(),
9503 }
9504 }
9505
9506 /// Gets the enum value as a string.
9507 ///
9508 /// Returns `None` if the enum contains an unknown value deserialized from
9509 /// the integer representation of enums.
9510 pub fn name(&self) -> std::option::Option<&str> {
9511 match self {
9512 Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
9513 Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
9514 Self::DemandExceedsVehicleCapacity => {
9515 std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
9516 }
9517 Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
9518 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
9519 ),
9520 Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
9521 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
9522 ),
9523 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
9524 std::option::Option::Some(
9525 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
9526 )
9527 }
9528 Self::CannotBePerformedWithinVehicleTimeWindows => {
9529 std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
9530 }
9531 Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
9532 Self::VehicleIgnored => std::option::Option::Some("VEHICLE_IGNORED"),
9533 Self::ShipmentIgnored => std::option::Option::Some("SHIPMENT_IGNORED"),
9534 Self::SkippedInInjectedSolutionConstraint => {
9535 std::option::Option::Some("SKIPPED_IN_INJECTED_SOLUTION_CONSTRAINT")
9536 }
9537 Self::VehicleRouteIsFullySequenceConstrained => {
9538 std::option::Option::Some("VEHICLE_ROUTE_IS_FULLY_SEQUENCE_CONSTRAINED")
9539 }
9540 Self::ZeroPenaltyCost => std::option::Option::Some("ZERO_PENALTY_COST"),
9541 Self::UnknownValue(u) => u.0.name(),
9542 }
9543 }
9544 }
9545
9546 impl std::default::Default for Code {
9547 fn default() -> Self {
9548 use std::convert::From;
9549 Self::from(0)
9550 }
9551 }
9552
9553 impl std::fmt::Display for Code {
9554 fn fmt(
9555 &self,
9556 f: &mut std::fmt::Formatter<'_>,
9557 ) -> std::result::Result<(), std::fmt::Error> {
9558 wkt::internal::display_enum(f, self.name(), self.value())
9559 }
9560 }
9561
9562 impl std::convert::From<i32> for Code {
9563 fn from(value: i32) -> Self {
9564 match value {
9565 0 => Self::Unspecified,
9566 1 => Self::NoVehicle,
9567 2 => Self::DemandExceedsVehicleCapacity,
9568 3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
9569 4 => Self::CannotBePerformedWithinVehicleDurationLimit,
9570 5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
9571 6 => Self::CannotBePerformedWithinVehicleTimeWindows,
9572 7 => Self::VehicleNotAllowed,
9573 8 => Self::VehicleIgnored,
9574 9 => Self::ShipmentIgnored,
9575 10 => Self::SkippedInInjectedSolutionConstraint,
9576 11 => Self::VehicleRouteIsFullySequenceConstrained,
9577 13 => Self::ZeroPenaltyCost,
9578 _ => Self::UnknownValue(code::UnknownValue(
9579 wkt::internal::UnknownEnumValue::Integer(value),
9580 )),
9581 }
9582 }
9583 }
9584
9585 impl std::convert::From<&str> for Code {
9586 fn from(value: &str) -> Self {
9587 use std::string::ToString;
9588 match value {
9589 "CODE_UNSPECIFIED" => Self::Unspecified,
9590 "NO_VEHICLE" => Self::NoVehicle,
9591 "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
9592 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
9593 Self::CannotBePerformedWithinVehicleDistanceLimit
9594 }
9595 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
9596 Self::CannotBePerformedWithinVehicleDurationLimit
9597 }
9598 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
9599 Self::CannotBePerformedWithinVehicleTravelDurationLimit
9600 }
9601 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
9602 Self::CannotBePerformedWithinVehicleTimeWindows
9603 }
9604 "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
9605 "VEHICLE_IGNORED" => Self::VehicleIgnored,
9606 "SHIPMENT_IGNORED" => Self::ShipmentIgnored,
9607 "SKIPPED_IN_INJECTED_SOLUTION_CONSTRAINT" => {
9608 Self::SkippedInInjectedSolutionConstraint
9609 }
9610 "VEHICLE_ROUTE_IS_FULLY_SEQUENCE_CONSTRAINED" => {
9611 Self::VehicleRouteIsFullySequenceConstrained
9612 }
9613 "ZERO_PENALTY_COST" => Self::ZeroPenaltyCost,
9614 _ => Self::UnknownValue(code::UnknownValue(
9615 wkt::internal::UnknownEnumValue::String(value.to_string()),
9616 )),
9617 }
9618 }
9619 }
9620
9621 impl serde::ser::Serialize for Code {
9622 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9623 where
9624 S: serde::Serializer,
9625 {
9626 match self {
9627 Self::Unspecified => serializer.serialize_i32(0),
9628 Self::NoVehicle => serializer.serialize_i32(1),
9629 Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
9630 Self::CannotBePerformedWithinVehicleDistanceLimit => {
9631 serializer.serialize_i32(3)
9632 }
9633 Self::CannotBePerformedWithinVehicleDurationLimit => {
9634 serializer.serialize_i32(4)
9635 }
9636 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
9637 serializer.serialize_i32(5)
9638 }
9639 Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
9640 Self::VehicleNotAllowed => serializer.serialize_i32(7),
9641 Self::VehicleIgnored => serializer.serialize_i32(8),
9642 Self::ShipmentIgnored => serializer.serialize_i32(9),
9643 Self::SkippedInInjectedSolutionConstraint => serializer.serialize_i32(10),
9644 Self::VehicleRouteIsFullySequenceConstrained => serializer.serialize_i32(11),
9645 Self::ZeroPenaltyCost => serializer.serialize_i32(13),
9646 Self::UnknownValue(u) => u.0.serialize(serializer),
9647 }
9648 }
9649 }
9650
9651 impl<'de> serde::de::Deserialize<'de> for Code {
9652 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9653 where
9654 D: serde::Deserializer<'de>,
9655 {
9656 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
9657 ".google.maps.routeoptimization.v1.SkippedShipment.Reason.Code",
9658 ))
9659 }
9660 }
9661 }
9662}
9663
9664/// Aggregated metrics for
9665/// [ShipmentRoute][google.maps.routeoptimization.v1.ShipmentRoute] (resp. for
9666/// [OptimizeToursResponse][google.maps.routeoptimization.v1.OptimizeToursResponse]
9667/// over all
9668/// [Transition][google.maps.routeoptimization.v1.ShipmentRoute.Transition]
9669/// and/or [Visit][google.maps.routeoptimization.v1.ShipmentRoute.Visit] (resp.
9670/// over all [ShipmentRoute][google.maps.routeoptimization.v1.ShipmentRoute])
9671/// elements.
9672///
9673/// [google.maps.routeoptimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
9674/// [google.maps.routeoptimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
9675/// [google.maps.routeoptimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
9676/// [google.maps.routeoptimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
9677#[derive(Clone, Default, PartialEq)]
9678#[non_exhaustive]
9679pub struct AggregatedMetrics {
9680 /// Number of shipments performed. Note that a pickup and delivery pair only
9681 /// counts once.
9682 pub performed_shipment_count: i32,
9683
9684 /// Number of mandatory shipments performed.
9685 ///
9686 /// Experimental: This field's behavior or existence may change in future.
9687 pub performed_mandatory_shipment_count: std::option::Option<i32>,
9688
9689 /// The sum of the
9690 /// [Shipment.penalty_cost][google.maps.routeoptimization.v1.Shipment.penalty_cost]
9691 /// of the performed shipments.
9692 ///
9693 /// Experimental: This field's behavior or existence may change in future.
9694 ///
9695 /// [google.maps.routeoptimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
9696 pub performed_shipment_penalty_cost_sum: std::option::Option<f64>,
9697
9698 /// Total travel duration for a route or a solution.
9699 pub travel_duration: std::option::Option<wkt::Duration>,
9700
9701 /// Total wait duration for a route or a solution.
9702 pub wait_duration: std::option::Option<wkt::Duration>,
9703
9704 /// Total delay duration for a route or a solution.
9705 pub delay_duration: std::option::Option<wkt::Duration>,
9706
9707 /// Total break duration for a route or a solution.
9708 pub break_duration: std::option::Option<wkt::Duration>,
9709
9710 /// Total visit duration for a route or a solution.
9711 pub visit_duration: std::option::Option<wkt::Duration>,
9712
9713 /// The total duration should be equal to the sum of all durations above.
9714 /// For routes, it also corresponds to:
9715 ///
9716 /// ```norust
9717 /// [ShipmentRoute.vehicle_end_time][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_end_time]
9718 /// -
9719 /// [ShipmentRoute.vehicle_start_time][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_start_time]
9720 /// ```
9721 pub total_duration: std::option::Option<wkt::Duration>,
9722
9723 /// Total travel distance for a route or a solution.
9724 pub travel_distance_meters: f64,
9725
9726 /// Maximum load achieved over the entire route (resp. solution), for each of
9727 /// the quantities on this route (resp. solution), computed as the maximum over
9728 /// all
9729 /// [Transition.vehicle_loads][google.maps.routeoptimization.v1.ShipmentRoute.Transition.vehicle_loads]
9730 /// (resp.
9731 /// [ShipmentRoute.metrics.max_loads][google.maps.routeoptimization.v1.AggregatedMetrics.max_loads].
9732 ///
9733 /// [google.maps.routeoptimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
9734 /// [google.maps.routeoptimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9735 pub max_loads:
9736 std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
9737
9738 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9739}
9740
9741impl AggregatedMetrics {
9742 /// Creates a new default instance.
9743 pub fn new() -> Self {
9744 std::default::Default::default()
9745 }
9746
9747 /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
9748 ///
9749 /// # Example
9750 /// ```ignore,no_run
9751 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9752 /// let x = AggregatedMetrics::new().set_performed_shipment_count(42);
9753 /// ```
9754 pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9755 self.performed_shipment_count = v.into();
9756 self
9757 }
9758
9759 /// Sets the value of [performed_mandatory_shipment_count][crate::model::AggregatedMetrics::performed_mandatory_shipment_count].
9760 ///
9761 /// # Example
9762 /// ```ignore,no_run
9763 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9764 /// let x = AggregatedMetrics::new().set_performed_mandatory_shipment_count(42);
9765 /// ```
9766 pub fn set_performed_mandatory_shipment_count<T>(mut self, v: T) -> Self
9767 where
9768 T: std::convert::Into<i32>,
9769 {
9770 self.performed_mandatory_shipment_count = std::option::Option::Some(v.into());
9771 self
9772 }
9773
9774 /// Sets or clears the value of [performed_mandatory_shipment_count][crate::model::AggregatedMetrics::performed_mandatory_shipment_count].
9775 ///
9776 /// # Example
9777 /// ```ignore,no_run
9778 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9779 /// let x = AggregatedMetrics::new().set_or_clear_performed_mandatory_shipment_count(Some(42));
9780 /// let x = AggregatedMetrics::new().set_or_clear_performed_mandatory_shipment_count(None::<i32>);
9781 /// ```
9782 pub fn set_or_clear_performed_mandatory_shipment_count<T>(
9783 mut self,
9784 v: std::option::Option<T>,
9785 ) -> Self
9786 where
9787 T: std::convert::Into<i32>,
9788 {
9789 self.performed_mandatory_shipment_count = v.map(|x| x.into());
9790 self
9791 }
9792
9793 /// Sets the value of [performed_shipment_penalty_cost_sum][crate::model::AggregatedMetrics::performed_shipment_penalty_cost_sum].
9794 ///
9795 /// # Example
9796 /// ```ignore,no_run
9797 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9798 /// let x = AggregatedMetrics::new().set_performed_shipment_penalty_cost_sum(42.0);
9799 /// ```
9800 pub fn set_performed_shipment_penalty_cost_sum<T>(mut self, v: T) -> Self
9801 where
9802 T: std::convert::Into<f64>,
9803 {
9804 self.performed_shipment_penalty_cost_sum = std::option::Option::Some(v.into());
9805 self
9806 }
9807
9808 /// Sets or clears the value of [performed_shipment_penalty_cost_sum][crate::model::AggregatedMetrics::performed_shipment_penalty_cost_sum].
9809 ///
9810 /// # Example
9811 /// ```ignore,no_run
9812 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9813 /// let x = AggregatedMetrics::new().set_or_clear_performed_shipment_penalty_cost_sum(Some(42.0));
9814 /// let x = AggregatedMetrics::new().set_or_clear_performed_shipment_penalty_cost_sum(None::<f32>);
9815 /// ```
9816 pub fn set_or_clear_performed_shipment_penalty_cost_sum<T>(
9817 mut self,
9818 v: std::option::Option<T>,
9819 ) -> Self
9820 where
9821 T: std::convert::Into<f64>,
9822 {
9823 self.performed_shipment_penalty_cost_sum = v.map(|x| x.into());
9824 self
9825 }
9826
9827 /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
9828 ///
9829 /// # Example
9830 /// ```ignore,no_run
9831 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9832 /// use wkt::Duration;
9833 /// let x = AggregatedMetrics::new().set_travel_duration(Duration::default()/* use setters */);
9834 /// ```
9835 pub fn set_travel_duration<T>(mut self, v: T) -> Self
9836 where
9837 T: std::convert::Into<wkt::Duration>,
9838 {
9839 self.travel_duration = std::option::Option::Some(v.into());
9840 self
9841 }
9842
9843 /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
9844 ///
9845 /// # Example
9846 /// ```ignore,no_run
9847 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9848 /// use wkt::Duration;
9849 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
9850 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(None::<Duration>);
9851 /// ```
9852 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
9853 where
9854 T: std::convert::Into<wkt::Duration>,
9855 {
9856 self.travel_duration = v.map(|x| x.into());
9857 self
9858 }
9859
9860 /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
9861 ///
9862 /// # Example
9863 /// ```ignore,no_run
9864 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9865 /// use wkt::Duration;
9866 /// let x = AggregatedMetrics::new().set_wait_duration(Duration::default()/* use setters */);
9867 /// ```
9868 pub fn set_wait_duration<T>(mut self, v: T) -> Self
9869 where
9870 T: std::convert::Into<wkt::Duration>,
9871 {
9872 self.wait_duration = std::option::Option::Some(v.into());
9873 self
9874 }
9875
9876 /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
9877 ///
9878 /// # Example
9879 /// ```ignore,no_run
9880 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9881 /// use wkt::Duration;
9882 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
9883 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(None::<Duration>);
9884 /// ```
9885 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
9886 where
9887 T: std::convert::Into<wkt::Duration>,
9888 {
9889 self.wait_duration = v.map(|x| x.into());
9890 self
9891 }
9892
9893 /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
9894 ///
9895 /// # Example
9896 /// ```ignore,no_run
9897 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9898 /// use wkt::Duration;
9899 /// let x = AggregatedMetrics::new().set_delay_duration(Duration::default()/* use setters */);
9900 /// ```
9901 pub fn set_delay_duration<T>(mut self, v: T) -> Self
9902 where
9903 T: std::convert::Into<wkt::Duration>,
9904 {
9905 self.delay_duration = std::option::Option::Some(v.into());
9906 self
9907 }
9908
9909 /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
9910 ///
9911 /// # Example
9912 /// ```ignore,no_run
9913 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9914 /// use wkt::Duration;
9915 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
9916 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(None::<Duration>);
9917 /// ```
9918 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
9919 where
9920 T: std::convert::Into<wkt::Duration>,
9921 {
9922 self.delay_duration = v.map(|x| x.into());
9923 self
9924 }
9925
9926 /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
9927 ///
9928 /// # Example
9929 /// ```ignore,no_run
9930 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9931 /// use wkt::Duration;
9932 /// let x = AggregatedMetrics::new().set_break_duration(Duration::default()/* use setters */);
9933 /// ```
9934 pub fn set_break_duration<T>(mut self, v: T) -> Self
9935 where
9936 T: std::convert::Into<wkt::Duration>,
9937 {
9938 self.break_duration = std::option::Option::Some(v.into());
9939 self
9940 }
9941
9942 /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
9943 ///
9944 /// # Example
9945 /// ```ignore,no_run
9946 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9947 /// use wkt::Duration;
9948 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
9949 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(None::<Duration>);
9950 /// ```
9951 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
9952 where
9953 T: std::convert::Into<wkt::Duration>,
9954 {
9955 self.break_duration = v.map(|x| x.into());
9956 self
9957 }
9958
9959 /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
9960 ///
9961 /// # Example
9962 /// ```ignore,no_run
9963 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9964 /// use wkt::Duration;
9965 /// let x = AggregatedMetrics::new().set_visit_duration(Duration::default()/* use setters */);
9966 /// ```
9967 pub fn set_visit_duration<T>(mut self, v: T) -> Self
9968 where
9969 T: std::convert::Into<wkt::Duration>,
9970 {
9971 self.visit_duration = std::option::Option::Some(v.into());
9972 self
9973 }
9974
9975 /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
9976 ///
9977 /// # Example
9978 /// ```ignore,no_run
9979 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9980 /// use wkt::Duration;
9981 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(Some(Duration::default()/* use setters */));
9982 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(None::<Duration>);
9983 /// ```
9984 pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
9985 where
9986 T: std::convert::Into<wkt::Duration>,
9987 {
9988 self.visit_duration = v.map(|x| x.into());
9989 self
9990 }
9991
9992 /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
9993 ///
9994 /// # Example
9995 /// ```ignore,no_run
9996 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
9997 /// use wkt::Duration;
9998 /// let x = AggregatedMetrics::new().set_total_duration(Duration::default()/* use setters */);
9999 /// ```
10000 pub fn set_total_duration<T>(mut self, v: T) -> Self
10001 where
10002 T: std::convert::Into<wkt::Duration>,
10003 {
10004 self.total_duration = std::option::Option::Some(v.into());
10005 self
10006 }
10007
10008 /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10009 ///
10010 /// # Example
10011 /// ```ignore,no_run
10012 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
10013 /// use wkt::Duration;
10014 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
10015 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(None::<Duration>);
10016 /// ```
10017 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
10018 where
10019 T: std::convert::Into<wkt::Duration>,
10020 {
10021 self.total_duration = v.map(|x| x.into());
10022 self
10023 }
10024
10025 /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
10026 ///
10027 /// # Example
10028 /// ```ignore,no_run
10029 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
10030 /// let x = AggregatedMetrics::new().set_travel_distance_meters(42.0);
10031 /// ```
10032 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10033 self.travel_distance_meters = v.into();
10034 self
10035 }
10036
10037 /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
10038 ///
10039 /// # Example
10040 /// ```ignore,no_run
10041 /// # use google_maps_routeoptimization_v1::model::AggregatedMetrics;
10042 /// use google_maps_routeoptimization_v1::model::shipment_route::VehicleLoad;
10043 /// let x = AggregatedMetrics::new().set_max_loads([
10044 /// ("key0", VehicleLoad::default()/* use setters */),
10045 /// ("key1", VehicleLoad::default()/* use (different) setters */),
10046 /// ]);
10047 /// ```
10048 pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
10049 where
10050 T: std::iter::IntoIterator<Item = (K, V)>,
10051 K: std::convert::Into<std::string::String>,
10052 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
10053 {
10054 use std::iter::Iterator;
10055 self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10056 self
10057 }
10058}
10059
10060impl wkt::message::Message for AggregatedMetrics {
10061 fn typename() -> &'static str {
10062 "type.googleapis.com/google.maps.routeoptimization.v1.AggregatedMetrics"
10063 }
10064}
10065
10066/// [VehicleFullness][google.maps.routeoptimization.v1.VehicleFullness] is a
10067/// metric which computes how full a vehicle is. Each
10068/// [VehicleFullness][google.maps.routeoptimization.v1.VehicleFullness] field is
10069/// between 0 and 1, computed as the ratio between a capped metric field (e.g.
10070/// [AggregatedMetrics.travel_distance_meters][google.maps.routeoptimization.v1.AggregatedMetrics.travel_distance_meters])
10071/// and its related vehicle limit (e.g.
10072/// [Vehicle.route_distance_limit][google.maps.routeoptimization.v1.Vehicle.route_distance_limit]),
10073/// if it exists. Otherwise the fullness ratio stays unset. If the limit is 0,
10074/// the field is set to 1. Note: when a route is subject to traffic
10075/// infeasibilities, some raw fullness ratios might exceed 1.0, e.g. the vehicle
10076/// might exceed its distance limit. In these cases, we cap the fullness values
10077/// at 1.0.
10078///
10079/// [google.maps.routeoptimization.v1.AggregatedMetrics.travel_distance_meters]: crate::model::AggregatedMetrics::travel_distance_meters
10080/// [google.maps.routeoptimization.v1.Vehicle.route_distance_limit]: crate::model::Vehicle::route_distance_limit
10081/// [google.maps.routeoptimization.v1.VehicleFullness]: crate::model::VehicleFullness
10082#[derive(Clone, Default, PartialEq)]
10083#[non_exhaustive]
10084pub struct VehicleFullness {
10085 /// Maximum of all other fields in this message.
10086 pub max_fullness: std::option::Option<f64>,
10087
10088 /// The ratio between
10089 /// [AggregatedMetrics.travel_distance_meters][google.maps.routeoptimization.v1.AggregatedMetrics.travel_distance_meters]
10090 /// and
10091 /// [Vehicle.route_distance_limit][google.maps.routeoptimization.v1.Vehicle.route_distance_limit].
10092 /// If
10093 /// [Vehicle.route_distance_limit][google.maps.routeoptimization.v1.Vehicle.route_distance_limit]
10094 /// is unset, this field will be unset.
10095 ///
10096 /// [google.maps.routeoptimization.v1.AggregatedMetrics.travel_distance_meters]: crate::model::AggregatedMetrics::travel_distance_meters
10097 /// [google.maps.routeoptimization.v1.Vehicle.route_distance_limit]: crate::model::Vehicle::route_distance_limit
10098 pub distance: std::option::Option<f64>,
10099
10100 /// The ratio between [AggregatedMetrics.travel_duration_seconds][] and
10101 /// [Vehicle.travel_duration_limit][google.maps.routeoptimization.v1.Vehicle.travel_duration_limit].
10102 /// If
10103 /// [Vehicle.travel_duration_limit][google.maps.routeoptimization.v1.Vehicle.travel_duration_limit]
10104 /// is unset, this field will be unset.
10105 ///
10106 /// [google.maps.routeoptimization.v1.Vehicle.travel_duration_limit]: crate::model::Vehicle::travel_duration_limit
10107 pub travel_duration: std::option::Option<f64>,
10108
10109 /// The ratio between [AggregatedMetrics.total_duration_seconds][] and
10110 /// [Vehicle.route_duration_limit][google.maps.routeoptimization.v1.Vehicle.route_duration_limit].
10111 /// If
10112 /// [Vehicle.route_duration_limit][google.maps.routeoptimization.v1.Vehicle.route_duration_limit]
10113 /// is unset, this field will be unset.
10114 ///
10115 /// [google.maps.routeoptimization.v1.Vehicle.route_duration_limit]: crate::model::Vehicle::route_duration_limit
10116 pub active_duration: std::option::Option<f64>,
10117
10118 /// The maximum ratio among all types of [AggregatedMetrics.max_load][] and
10119 /// their respective
10120 /// [Vehicle.load_limits][google.maps.routeoptimization.v1.Vehicle.load_limits].
10121 /// If all
10122 /// [Vehicle.load_limits][google.maps.routeoptimization.v1.Vehicle.load_limits]
10123 /// fields are unset, this field will be unset.
10124 ///
10125 /// [google.maps.routeoptimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
10126 pub max_load: std::option::Option<f64>,
10127
10128 /// The ratio `(vehicle_end_time - vehicle_start_time) /
10129 /// (latest_vehicle_end_time - earliest_vehicle_start_time)` for a
10130 /// given vehicle. If the denominator is not present, it uses
10131 /// `([ShipmentModel.global_end_time] - [ShipmentModel.global_start_time])`
10132 /// instead.
10133 pub active_span: std::option::Option<f64>,
10134
10135 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10136}
10137
10138impl VehicleFullness {
10139 /// Creates a new default instance.
10140 pub fn new() -> Self {
10141 std::default::Default::default()
10142 }
10143
10144 /// Sets the value of [max_fullness][crate::model::VehicleFullness::max_fullness].
10145 ///
10146 /// # Example
10147 /// ```ignore,no_run
10148 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10149 /// let x = VehicleFullness::new().set_max_fullness(42.0);
10150 /// ```
10151 pub fn set_max_fullness<T>(mut self, v: T) -> Self
10152 where
10153 T: std::convert::Into<f64>,
10154 {
10155 self.max_fullness = std::option::Option::Some(v.into());
10156 self
10157 }
10158
10159 /// Sets or clears the value of [max_fullness][crate::model::VehicleFullness::max_fullness].
10160 ///
10161 /// # Example
10162 /// ```ignore,no_run
10163 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10164 /// let x = VehicleFullness::new().set_or_clear_max_fullness(Some(42.0));
10165 /// let x = VehicleFullness::new().set_or_clear_max_fullness(None::<f32>);
10166 /// ```
10167 pub fn set_or_clear_max_fullness<T>(mut self, v: std::option::Option<T>) -> Self
10168 where
10169 T: std::convert::Into<f64>,
10170 {
10171 self.max_fullness = v.map(|x| x.into());
10172 self
10173 }
10174
10175 /// Sets the value of [distance][crate::model::VehicleFullness::distance].
10176 ///
10177 /// # Example
10178 /// ```ignore,no_run
10179 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10180 /// let x = VehicleFullness::new().set_distance(42.0);
10181 /// ```
10182 pub fn set_distance<T>(mut self, v: T) -> Self
10183 where
10184 T: std::convert::Into<f64>,
10185 {
10186 self.distance = std::option::Option::Some(v.into());
10187 self
10188 }
10189
10190 /// Sets or clears the value of [distance][crate::model::VehicleFullness::distance].
10191 ///
10192 /// # Example
10193 /// ```ignore,no_run
10194 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10195 /// let x = VehicleFullness::new().set_or_clear_distance(Some(42.0));
10196 /// let x = VehicleFullness::new().set_or_clear_distance(None::<f32>);
10197 /// ```
10198 pub fn set_or_clear_distance<T>(mut self, v: std::option::Option<T>) -> Self
10199 where
10200 T: std::convert::Into<f64>,
10201 {
10202 self.distance = v.map(|x| x.into());
10203 self
10204 }
10205
10206 /// Sets the value of [travel_duration][crate::model::VehicleFullness::travel_duration].
10207 ///
10208 /// # Example
10209 /// ```ignore,no_run
10210 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10211 /// let x = VehicleFullness::new().set_travel_duration(42.0);
10212 /// ```
10213 pub fn set_travel_duration<T>(mut self, v: T) -> Self
10214 where
10215 T: std::convert::Into<f64>,
10216 {
10217 self.travel_duration = std::option::Option::Some(v.into());
10218 self
10219 }
10220
10221 /// Sets or clears the value of [travel_duration][crate::model::VehicleFullness::travel_duration].
10222 ///
10223 /// # Example
10224 /// ```ignore,no_run
10225 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10226 /// let x = VehicleFullness::new().set_or_clear_travel_duration(Some(42.0));
10227 /// let x = VehicleFullness::new().set_or_clear_travel_duration(None::<f32>);
10228 /// ```
10229 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
10230 where
10231 T: std::convert::Into<f64>,
10232 {
10233 self.travel_duration = v.map(|x| x.into());
10234 self
10235 }
10236
10237 /// Sets the value of [active_duration][crate::model::VehicleFullness::active_duration].
10238 ///
10239 /// # Example
10240 /// ```ignore,no_run
10241 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10242 /// let x = VehicleFullness::new().set_active_duration(42.0);
10243 /// ```
10244 pub fn set_active_duration<T>(mut self, v: T) -> Self
10245 where
10246 T: std::convert::Into<f64>,
10247 {
10248 self.active_duration = std::option::Option::Some(v.into());
10249 self
10250 }
10251
10252 /// Sets or clears the value of [active_duration][crate::model::VehicleFullness::active_duration].
10253 ///
10254 /// # Example
10255 /// ```ignore,no_run
10256 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10257 /// let x = VehicleFullness::new().set_or_clear_active_duration(Some(42.0));
10258 /// let x = VehicleFullness::new().set_or_clear_active_duration(None::<f32>);
10259 /// ```
10260 pub fn set_or_clear_active_duration<T>(mut self, v: std::option::Option<T>) -> Self
10261 where
10262 T: std::convert::Into<f64>,
10263 {
10264 self.active_duration = v.map(|x| x.into());
10265 self
10266 }
10267
10268 /// Sets the value of [max_load][crate::model::VehicleFullness::max_load].
10269 ///
10270 /// # Example
10271 /// ```ignore,no_run
10272 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10273 /// let x = VehicleFullness::new().set_max_load(42.0);
10274 /// ```
10275 pub fn set_max_load<T>(mut self, v: T) -> Self
10276 where
10277 T: std::convert::Into<f64>,
10278 {
10279 self.max_load = std::option::Option::Some(v.into());
10280 self
10281 }
10282
10283 /// Sets or clears the value of [max_load][crate::model::VehicleFullness::max_load].
10284 ///
10285 /// # Example
10286 /// ```ignore,no_run
10287 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10288 /// let x = VehicleFullness::new().set_or_clear_max_load(Some(42.0));
10289 /// let x = VehicleFullness::new().set_or_clear_max_load(None::<f32>);
10290 /// ```
10291 pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
10292 where
10293 T: std::convert::Into<f64>,
10294 {
10295 self.max_load = v.map(|x| x.into());
10296 self
10297 }
10298
10299 /// Sets the value of [active_span][crate::model::VehicleFullness::active_span].
10300 ///
10301 /// # Example
10302 /// ```ignore,no_run
10303 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10304 /// let x = VehicleFullness::new().set_active_span(42.0);
10305 /// ```
10306 pub fn set_active_span<T>(mut self, v: T) -> Self
10307 where
10308 T: std::convert::Into<f64>,
10309 {
10310 self.active_span = std::option::Option::Some(v.into());
10311 self
10312 }
10313
10314 /// Sets or clears the value of [active_span][crate::model::VehicleFullness::active_span].
10315 ///
10316 /// # Example
10317 /// ```ignore,no_run
10318 /// # use google_maps_routeoptimization_v1::model::VehicleFullness;
10319 /// let x = VehicleFullness::new().set_or_clear_active_span(Some(42.0));
10320 /// let x = VehicleFullness::new().set_or_clear_active_span(None::<f32>);
10321 /// ```
10322 pub fn set_or_clear_active_span<T>(mut self, v: std::option::Option<T>) -> Self
10323 where
10324 T: std::convert::Into<f64>,
10325 {
10326 self.active_span = v.map(|x| x.into());
10327 self
10328 }
10329}
10330
10331impl wkt::message::Message for VehicleFullness {
10332 fn typename() -> &'static str {
10333 "type.googleapis.com/google.maps.routeoptimization.v1.VehicleFullness"
10334 }
10335}
10336
10337/// Solution injected in the request including information about which visits
10338/// must be constrained and how they must be constrained.
10339#[derive(Clone, Default, PartialEq)]
10340#[non_exhaustive]
10341pub struct InjectedSolutionConstraint {
10342 /// Routes of the solution to inject. Some routes may be omitted from the
10343 /// original solution. The routes and skipped shipments must satisfy the basic
10344 /// validity assumptions listed for `injected_first_solution_routes`.
10345 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
10346
10347 /// Skipped shipments of the solution to inject. Some may be omitted from the
10348 /// original solution. See the `routes` field.
10349 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
10350
10351 /// For zero or more groups of vehicles, specifies when and how much to relax
10352 /// constraints. If this field is empty, all non-empty vehicle routes are
10353 /// fully constrained.
10354 pub constraint_relaxations:
10355 std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10356
10357 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10358}
10359
10360impl InjectedSolutionConstraint {
10361 /// Creates a new default instance.
10362 pub fn new() -> Self {
10363 std::default::Default::default()
10364 }
10365
10366 /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
10367 ///
10368 /// # Example
10369 /// ```ignore,no_run
10370 /// # use google_maps_routeoptimization_v1::model::InjectedSolutionConstraint;
10371 /// use google_maps_routeoptimization_v1::model::ShipmentRoute;
10372 /// let x = InjectedSolutionConstraint::new()
10373 /// .set_routes([
10374 /// ShipmentRoute::default()/* use setters */,
10375 /// ShipmentRoute::default()/* use (different) setters */,
10376 /// ]);
10377 /// ```
10378 pub fn set_routes<T, V>(mut self, v: T) -> Self
10379 where
10380 T: std::iter::IntoIterator<Item = V>,
10381 V: std::convert::Into<crate::model::ShipmentRoute>,
10382 {
10383 use std::iter::Iterator;
10384 self.routes = v.into_iter().map(|i| i.into()).collect();
10385 self
10386 }
10387
10388 /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
10389 ///
10390 /// # Example
10391 /// ```ignore,no_run
10392 /// # use google_maps_routeoptimization_v1::model::InjectedSolutionConstraint;
10393 /// use google_maps_routeoptimization_v1::model::SkippedShipment;
10394 /// let x = InjectedSolutionConstraint::new()
10395 /// .set_skipped_shipments([
10396 /// SkippedShipment::default()/* use setters */,
10397 /// SkippedShipment::default()/* use (different) setters */,
10398 /// ]);
10399 /// ```
10400 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
10401 where
10402 T: std::iter::IntoIterator<Item = V>,
10403 V: std::convert::Into<crate::model::SkippedShipment>,
10404 {
10405 use std::iter::Iterator;
10406 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
10407 self
10408 }
10409
10410 /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
10411 ///
10412 /// # Example
10413 /// ```ignore,no_run
10414 /// # use google_maps_routeoptimization_v1::model::InjectedSolutionConstraint;
10415 /// use google_maps_routeoptimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10416 /// let x = InjectedSolutionConstraint::new()
10417 /// .set_constraint_relaxations([
10418 /// ConstraintRelaxation::default()/* use setters */,
10419 /// ConstraintRelaxation::default()/* use (different) setters */,
10420 /// ]);
10421 /// ```
10422 pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
10423 where
10424 T: std::iter::IntoIterator<Item = V>,
10425 V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10426 {
10427 use std::iter::Iterator;
10428 self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
10429 self
10430 }
10431}
10432
10433impl wkt::message::Message for InjectedSolutionConstraint {
10434 fn typename() -> &'static str {
10435 "type.googleapis.com/google.maps.routeoptimization.v1.InjectedSolutionConstraint"
10436 }
10437}
10438
10439/// Defines additional types related to [InjectedSolutionConstraint].
10440pub mod injected_solution_constraint {
10441 #[allow(unused_imports)]
10442 use super::*;
10443
10444 /// For a group of vehicles, specifies at what threshold(s) constraints on
10445 /// visits will be relaxed and to which level. Shipments listed in
10446 /// the `skipped_shipment` field are constrained to be skipped; i.e., they
10447 /// cannot be performed.
10448 #[derive(Clone, Default, PartialEq)]
10449 #[non_exhaustive]
10450 pub struct ConstraintRelaxation {
10451 /// All the visit constraint relaxations that will apply to visits on
10452 /// routes with vehicles in `vehicle_indices`.
10453 pub relaxations: std::vec::Vec<
10454 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10455 >,
10456
10457 /// Specifies the vehicle indices to which the visit constraint
10458 /// `relaxations` apply. If empty, this is considered the default and the
10459 /// `relaxations` apply to all vehicles that are not specified in other
10460 /// `constraint_relaxations`. There can be at most one default, i.e., at
10461 /// most one constraint relaxation field is allowed empty
10462 /// `vehicle_indices`. A vehicle index can only be listed once, even within
10463 /// several `constraint_relaxations`.
10464 ///
10465 /// A vehicle index is mapped the same as
10466 /// [ShipmentRoute.vehicle_index][google.maps.routeoptimization.v1.ShipmentRoute.vehicle_index],
10467 /// if `interpret_injected_solutions_using_labels` is true (see `fields`
10468 /// comment).
10469 ///
10470 /// [google.maps.routeoptimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
10471 pub vehicle_indices: std::vec::Vec<i32>,
10472
10473 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10474 }
10475
10476 impl ConstraintRelaxation {
10477 /// Creates a new default instance.
10478 pub fn new() -> Self {
10479 std::default::Default::default()
10480 }
10481
10482 /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
10483 ///
10484 /// # Example
10485 /// ```ignore,no_run
10486 /// # use google_maps_routeoptimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10487 /// use google_maps_routeoptimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10488 /// let x = ConstraintRelaxation::new()
10489 /// .set_relaxations([
10490 /// Relaxation::default()/* use setters */,
10491 /// Relaxation::default()/* use (different) setters */,
10492 /// ]);
10493 /// ```
10494 pub fn set_relaxations<T, V>(mut self, v: T) -> Self
10495 where
10496 T: std::iter::IntoIterator<Item = V>,
10497 V: std::convert::Into<
10498 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10499 >,
10500 {
10501 use std::iter::Iterator;
10502 self.relaxations = v.into_iter().map(|i| i.into()).collect();
10503 self
10504 }
10505
10506 /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
10507 ///
10508 /// # Example
10509 /// ```ignore,no_run
10510 /// # use google_maps_routeoptimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10511 /// let x = ConstraintRelaxation::new().set_vehicle_indices([1, 2, 3]);
10512 /// ```
10513 pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
10514 where
10515 T: std::iter::IntoIterator<Item = V>,
10516 V: std::convert::Into<i32>,
10517 {
10518 use std::iter::Iterator;
10519 self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
10520 self
10521 }
10522 }
10523
10524 impl wkt::message::Message for ConstraintRelaxation {
10525 fn typename() -> &'static str {
10526 "type.googleapis.com/google.maps.routeoptimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
10527 }
10528 }
10529
10530 /// Defines additional types related to [ConstraintRelaxation].
10531 pub mod constraint_relaxation {
10532 #[allow(unused_imports)]
10533 use super::*;
10534
10535 /// If `relaxations` is empty, the start time and sequence of all visits
10536 /// on `routes` are fully constrained and no new visits may be inserted or
10537 /// added to those routes. Also, a vehicle's start and end time in
10538 /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
10539 /// visits and has `used_if_route_is_empty` set to false in the model).
10540 ///
10541 /// `relaxations(i).level` specifies the constraint relaxation level applied
10542 /// to a visit #j that satisfies:
10543 ///
10544 /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
10545 /// * `j + 1 >= relaxations(i).threshold_visit_count`
10546 ///
10547 /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
10548 /// satisfies:
10549 ///
10550 /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
10551 /// * `relaxations(i).threshold_visit_count == 0`
10552 /// and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
10553 /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
10554 /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
10555 ///
10556 /// To apply a relaxation level if a visit meets the `threshold_visit_count`
10557 /// OR the `threshold_time` add two `relaxations` with the same `level`:
10558 /// one with only `threshold_visit_count` set and the other with only
10559 /// `threshold_time` set. If a visit satisfies the conditions of multiple
10560 /// `relaxations`, the most relaxed level applies. As a result, from the
10561 /// vehicle start through the route visits in order to the vehicle end, the
10562 /// relaxation level becomes more relaxed: i.e., the relaxation level is
10563 /// non-decreasing as the route progresses.
10564 ///
10565 /// The timing and sequence of route visits that do not satisfy the
10566 /// threshold conditions of any `relaxations` are fully constrained
10567 /// and no visits may be inserted into these sequences. Also, if a
10568 /// vehicle start or end does not satisfy the conditions of any
10569 /// relaxation the time is fixed, unless the vehicle is empty.
10570 #[derive(Clone, Default, PartialEq)]
10571 #[non_exhaustive]
10572 pub struct Relaxation {
10573
10574 /// The constraint relaxation level that applies when the conditions
10575 /// at or after `threshold_time` AND at least `threshold_visit_count` are
10576 /// satisfied.
10577 pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
10578
10579 /// The time at or after which the relaxation `level` may be applied.
10580 pub threshold_time: std::option::Option<wkt::Timestamp>,
10581
10582 /// The number of visits at or after which the relaxation `level` may be
10583 /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
10584 /// applied directly at the vehicle start.
10585 ///
10586 /// If it is `route.visits_size() + 1`, the `level` may only be applied to
10587 /// the vehicle end. If it is more than `route.visits_size() + 1`,
10588 /// `level` is not applied at all for that route.
10589 pub threshold_visit_count: i32,
10590
10591 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10592 }
10593
10594 impl Relaxation {
10595 /// Creates a new default instance.
10596 pub fn new() -> Self {
10597 std::default::Default::default()
10598 }
10599
10600 /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
10601 ///
10602 /// # Example
10603 /// ```ignore,no_run
10604 /// # use google_maps_routeoptimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10605 /// use google_maps_routeoptimization_v1::model::injected_solution_constraint::constraint_relaxation::relaxation::Level;
10606 /// let x0 = Relaxation::new().set_level(Level::RelaxVisitTimesAfterThreshold);
10607 /// let x1 = Relaxation::new().set_level(Level::RelaxVisitTimesAndSequenceAfterThreshold);
10608 /// let x2 = Relaxation::new().set_level(Level::RelaxAllAfterThreshold);
10609 /// ```
10610 pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
10611 self.level = v.into();
10612 self
10613 }
10614
10615 /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10616 ///
10617 /// # Example
10618 /// ```ignore,no_run
10619 /// # use google_maps_routeoptimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10620 /// use wkt::Timestamp;
10621 /// let x = Relaxation::new().set_threshold_time(Timestamp::default()/* use setters */);
10622 /// ```
10623 pub fn set_threshold_time<T>(mut self, v: T) -> Self
10624 where
10625 T: std::convert::Into<wkt::Timestamp>,
10626 {
10627 self.threshold_time = std::option::Option::Some(v.into());
10628 self
10629 }
10630
10631 /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10632 ///
10633 /// # Example
10634 /// ```ignore,no_run
10635 /// # use google_maps_routeoptimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10636 /// use wkt::Timestamp;
10637 /// let x = Relaxation::new().set_or_clear_threshold_time(Some(Timestamp::default()/* use setters */));
10638 /// let x = Relaxation::new().set_or_clear_threshold_time(None::<Timestamp>);
10639 /// ```
10640 pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
10641 where
10642 T: std::convert::Into<wkt::Timestamp>,
10643 {
10644 self.threshold_time = v.map(|x| x.into());
10645 self
10646 }
10647
10648 /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
10649 ///
10650 /// # Example
10651 /// ```ignore,no_run
10652 /// # use google_maps_routeoptimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10653 /// let x = Relaxation::new().set_threshold_visit_count(42);
10654 /// ```
10655 pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10656 self.threshold_visit_count = v.into();
10657 self
10658 }
10659 }
10660
10661 impl wkt::message::Message for Relaxation {
10662 fn typename() -> &'static str {
10663 "type.googleapis.com/google.maps.routeoptimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
10664 }
10665 }
10666
10667 /// Defines additional types related to [Relaxation].
10668 pub mod relaxation {
10669 #[allow(unused_imports)]
10670 use super::*;
10671
10672 /// Expresses the different constraint relaxation levels, which are
10673 /// applied for a visit and those that follow when it satisfies the
10674 /// threshold conditions.
10675 ///
10676 /// The enumeration below is in order of increasing relaxation.
10677 ///
10678 /// # Working with unknown values
10679 ///
10680 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10681 /// additional enum variants at any time. Adding new variants is not considered
10682 /// a breaking change. Applications should write their code in anticipation of:
10683 ///
10684 /// - New values appearing in future releases of the client library, **and**
10685 /// - New values received dynamically, without application changes.
10686 ///
10687 /// Please consult the [Working with enums] section in the user guide for some
10688 /// guidelines.
10689 ///
10690 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10691 #[derive(Clone, Debug, PartialEq)]
10692 #[non_exhaustive]
10693 pub enum Level {
10694 /// Implicit default relaxation level: no constraints are relaxed,
10695 /// i.e., all visits are fully constrained.
10696 ///
10697 /// This value must not be explicitly used in `level`.
10698 Unspecified,
10699 /// Visit start times and vehicle start/end times will be relaxed, but
10700 /// each visit remains bound to the same vehicle and the visit sequence
10701 /// must be observed: no visit can be inserted between them or before
10702 /// them.
10703 RelaxVisitTimesAfterThreshold,
10704 /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
10705 /// is also relaxed: visits can only be performed by this vehicle, but
10706 /// can potentially become unperformed.
10707 RelaxVisitTimesAndSequenceAfterThreshold,
10708 /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
10709 /// vehicle is also relaxed: visits are completely free at or after the
10710 /// threshold time and can potentially become unperformed.
10711 RelaxAllAfterThreshold,
10712 /// If set, the enum was initialized with an unknown value.
10713 ///
10714 /// Applications can examine the value using [Level::value] or
10715 /// [Level::name].
10716 UnknownValue(level::UnknownValue),
10717 }
10718
10719 #[doc(hidden)]
10720 pub mod level {
10721 #[allow(unused_imports)]
10722 use super::*;
10723 #[derive(Clone, Debug, PartialEq)]
10724 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10725 }
10726
10727 impl Level {
10728 /// Gets the enum value.
10729 ///
10730 /// Returns `None` if the enum contains an unknown value deserialized from
10731 /// the string representation of enums.
10732 pub fn value(&self) -> std::option::Option<i32> {
10733 match self {
10734 Self::Unspecified => std::option::Option::Some(0),
10735 Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
10736 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
10737 std::option::Option::Some(2)
10738 }
10739 Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
10740 Self::UnknownValue(u) => u.0.value(),
10741 }
10742 }
10743
10744 /// Gets the enum value as a string.
10745 ///
10746 /// Returns `None` if the enum contains an unknown value deserialized from
10747 /// the integer representation of enums.
10748 pub fn name(&self) -> std::option::Option<&str> {
10749 match self {
10750 Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
10751 Self::RelaxVisitTimesAfterThreshold => {
10752 std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
10753 }
10754 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
10755 std::option::Option::Some(
10756 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
10757 )
10758 }
10759 Self::RelaxAllAfterThreshold => {
10760 std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
10761 }
10762 Self::UnknownValue(u) => u.0.name(),
10763 }
10764 }
10765 }
10766
10767 impl std::default::Default for Level {
10768 fn default() -> Self {
10769 use std::convert::From;
10770 Self::from(0)
10771 }
10772 }
10773
10774 impl std::fmt::Display for Level {
10775 fn fmt(
10776 &self,
10777 f: &mut std::fmt::Formatter<'_>,
10778 ) -> std::result::Result<(), std::fmt::Error> {
10779 wkt::internal::display_enum(f, self.name(), self.value())
10780 }
10781 }
10782
10783 impl std::convert::From<i32> for Level {
10784 fn from(value: i32) -> Self {
10785 match value {
10786 0 => Self::Unspecified,
10787 1 => Self::RelaxVisitTimesAfterThreshold,
10788 2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
10789 3 => Self::RelaxAllAfterThreshold,
10790 _ => Self::UnknownValue(level::UnknownValue(
10791 wkt::internal::UnknownEnumValue::Integer(value),
10792 )),
10793 }
10794 }
10795 }
10796
10797 impl std::convert::From<&str> for Level {
10798 fn from(value: &str) -> Self {
10799 use std::string::ToString;
10800 match value {
10801 "LEVEL_UNSPECIFIED" => Self::Unspecified,
10802 "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
10803 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
10804 Self::RelaxVisitTimesAndSequenceAfterThreshold
10805 }
10806 "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
10807 _ => Self::UnknownValue(level::UnknownValue(
10808 wkt::internal::UnknownEnumValue::String(value.to_string()),
10809 )),
10810 }
10811 }
10812 }
10813
10814 impl serde::ser::Serialize for Level {
10815 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10816 where
10817 S: serde::Serializer,
10818 {
10819 match self {
10820 Self::Unspecified => serializer.serialize_i32(0),
10821 Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
10822 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
10823 serializer.serialize_i32(2)
10824 }
10825 Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
10826 Self::UnknownValue(u) => u.0.serialize(serializer),
10827 }
10828 }
10829 }
10830
10831 impl<'de> serde::de::Deserialize<'de> for Level {
10832 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10833 where
10834 D: serde::Deserializer<'de>,
10835 {
10836 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
10837 ".google.maps.routeoptimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
10838 }
10839 }
10840 }
10841 }
10842}
10843
10844/// Describes an error or warning encountered when validating an
10845/// `OptimizeToursRequest`.
10846#[derive(Clone, Default, PartialEq)]
10847#[non_exhaustive]
10848pub struct OptimizeToursValidationError {
10849 /// A validation error is defined by the pair (`code`, `display_name`) which
10850 /// are always present.
10851 ///
10852 /// The fields following this section provide more context about the error.
10853 ///
10854 /// *MULTIPLE ERRORS*:
10855 /// When there are multiple errors, the validation process tries to output
10856 /// several of them. Much like a compiler, this is an imperfect process. Some
10857 /// validation errors will be "fatal", meaning that they stop the entire
10858 /// validation process. This is the case for `display_name="UNSPECIFIED"`
10859 /// errors, among others. Some errors may cause the validation process to skip
10860 /// other errors.
10861 ///
10862 /// *STABILITY*:
10863 /// `code` and `display_name` should be very stable. But new codes and
10864 /// display names may appear over time, which may cause a given (invalid)
10865 /// request to yield a different (`code`, `display_name`) pair because the new
10866 /// error hid the old one. For example, see "MULTIPLE ERRORS".
10867 pub code: i32,
10868
10869 /// The error display name.
10870 pub display_name: std::string::String,
10871
10872 /// An error context may involve 0, 1 (most of the time) or more fields. For
10873 /// example, referring to vehicle #4 and shipment #2's first pickup can be
10874 /// done as follows:
10875 ///
10876 /// ```norust
10877 /// fields { name: "vehicles" index: 4}
10878 /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
10879 /// ```
10880 ///
10881 /// Note, however, that the cardinality of `fields` should not change for a
10882 /// given error code.
10883 pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
10884
10885 /// Human-readable string describing the error. There is a 1:1 mapping
10886 /// between `code` and `error_message` (when code != "UNSPECIFIED").
10887 ///
10888 /// *STABILITY*: Not stable: the error message associated to a given `code` may
10889 /// change (hopefully to clarify it) over time. Please rely on the
10890 /// `display_name` and `code` instead.
10891 pub error_message: std::string::String,
10892
10893 /// May contain the value(s) of the field(s). This is not always available. You
10894 /// should absolutely not rely on it and use it only for manual model
10895 /// debugging.
10896 pub offending_values: std::string::String,
10897
10898 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10899}
10900
10901impl OptimizeToursValidationError {
10902 /// Creates a new default instance.
10903 pub fn new() -> Self {
10904 std::default::Default::default()
10905 }
10906
10907 /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
10908 ///
10909 /// # Example
10910 /// ```ignore,no_run
10911 /// # use google_maps_routeoptimization_v1::model::OptimizeToursValidationError;
10912 /// let x = OptimizeToursValidationError::new().set_code(42);
10913 /// ```
10914 pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10915 self.code = v.into();
10916 self
10917 }
10918
10919 /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
10920 ///
10921 /// # Example
10922 /// ```ignore,no_run
10923 /// # use google_maps_routeoptimization_v1::model::OptimizeToursValidationError;
10924 /// let x = OptimizeToursValidationError::new().set_display_name("example");
10925 /// ```
10926 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10927 self.display_name = v.into();
10928 self
10929 }
10930
10931 /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
10932 ///
10933 /// # Example
10934 /// ```ignore,no_run
10935 /// # use google_maps_routeoptimization_v1::model::OptimizeToursValidationError;
10936 /// use google_maps_routeoptimization_v1::model::optimize_tours_validation_error::FieldReference;
10937 /// let x = OptimizeToursValidationError::new()
10938 /// .set_fields([
10939 /// FieldReference::default()/* use setters */,
10940 /// FieldReference::default()/* use (different) setters */,
10941 /// ]);
10942 /// ```
10943 pub fn set_fields<T, V>(mut self, v: T) -> Self
10944 where
10945 T: std::iter::IntoIterator<Item = V>,
10946 V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
10947 {
10948 use std::iter::Iterator;
10949 self.fields = v.into_iter().map(|i| i.into()).collect();
10950 self
10951 }
10952
10953 /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
10954 ///
10955 /// # Example
10956 /// ```ignore,no_run
10957 /// # use google_maps_routeoptimization_v1::model::OptimizeToursValidationError;
10958 /// let x = OptimizeToursValidationError::new().set_error_message("example");
10959 /// ```
10960 pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10961 self.error_message = v.into();
10962 self
10963 }
10964
10965 /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
10966 ///
10967 /// # Example
10968 /// ```ignore,no_run
10969 /// # use google_maps_routeoptimization_v1::model::OptimizeToursValidationError;
10970 /// let x = OptimizeToursValidationError::new().set_offending_values("example");
10971 /// ```
10972 pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
10973 mut self,
10974 v: T,
10975 ) -> Self {
10976 self.offending_values = v.into();
10977 self
10978 }
10979}
10980
10981impl wkt::message::Message for OptimizeToursValidationError {
10982 fn typename() -> &'static str {
10983 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursValidationError"
10984 }
10985}
10986
10987/// Defines additional types related to [OptimizeToursValidationError].
10988pub mod optimize_tours_validation_error {
10989 #[allow(unused_imports)]
10990 use super::*;
10991
10992 /// Specifies a context for the validation error. A `FieldReference` always
10993 /// refers to a given field in this file and follows the same hierarchical
10994 /// structure. For example, we may specify element #2 of `start_time_windows`
10995 /// of vehicle #5 using:
10996 ///
10997 /// ```norust
10998 /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
10999 /// ```
11000 ///
11001 /// We however omit top-level entities such as `OptimizeToursRequest` or
11002 /// `ShipmentModel` to avoid crowding the message.
11003 #[derive(Clone, Default, PartialEq)]
11004 #[non_exhaustive]
11005 pub struct FieldReference {
11006 /// Name of the field, e.g., "vehicles".
11007 pub name: std::string::String,
11008
11009 /// Recursively nested sub-field, if needed.
11010 pub sub_field: std::option::Option<
11011 std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
11012 >,
11013
11014 #[allow(missing_docs)]
11015 pub index_or_key: std::option::Option<
11016 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11017 >,
11018
11019 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11020 }
11021
11022 impl FieldReference {
11023 /// Creates a new default instance.
11024 pub fn new() -> Self {
11025 std::default::Default::default()
11026 }
11027
11028 /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
11029 ///
11030 /// # Example
11031 /// ```ignore,no_run
11032 /// # use google_maps_routeoptimization_v1::model::optimize_tours_validation_error::FieldReference;
11033 /// let x = FieldReference::new().set_name("example");
11034 /// ```
11035 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11036 self.name = v.into();
11037 self
11038 }
11039
11040 /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11041 ///
11042 /// # Example
11043 /// ```ignore,no_run
11044 /// # use google_maps_routeoptimization_v1::model::optimize_tours_validation_error::FieldReference;
11045 /// let x = FieldReference::new().set_sub_field(FieldReference::default()/* use setters */);
11046 /// ```
11047 pub fn set_sub_field<T>(mut self, v: T) -> Self
11048 where
11049 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11050 {
11051 self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
11052 self
11053 }
11054
11055 /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11056 ///
11057 /// # Example
11058 /// ```ignore,no_run
11059 /// # use google_maps_routeoptimization_v1::model::optimize_tours_validation_error::FieldReference;
11060 /// let x = FieldReference::new().set_or_clear_sub_field(Some(FieldReference::default()/* use setters */));
11061 /// let x = FieldReference::new().set_or_clear_sub_field(None::<FieldReference>);
11062 /// ```
11063 pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
11064 where
11065 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11066 {
11067 self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
11068 self
11069 }
11070
11071 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
11072 ///
11073 /// Note that all the setters affecting `index_or_key` are mutually
11074 /// exclusive.
11075 ///
11076 /// # Example
11077 /// ```ignore,no_run
11078 /// # use google_maps_routeoptimization_v1::model::optimize_tours_validation_error::FieldReference;
11079 /// use google_maps_routeoptimization_v1::model::optimize_tours_validation_error::field_reference::IndexOrKey;
11080 /// let x = FieldReference::new().set_index_or_key(Some(IndexOrKey::Index(42)));
11081 /// ```
11082 pub fn set_index_or_key<
11083 T: std::convert::Into<
11084 std::option::Option<
11085 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11086 >,
11087 >,
11088 >(
11089 mut self,
11090 v: T,
11091 ) -> Self {
11092 self.index_or_key = v.into();
11093 self
11094 }
11095
11096 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11097 /// if it holds a `Index`, `None` if the field is not set or
11098 /// holds a different branch.
11099 pub fn index(&self) -> std::option::Option<&i32> {
11100 #[allow(unreachable_patterns)]
11101 self.index_or_key.as_ref().and_then(|v| match v {
11102 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
11103 _ => std::option::Option::None,
11104 })
11105 }
11106
11107 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11108 /// to hold a `Index`.
11109 ///
11110 /// Note that all the setters affecting `index_or_key` are
11111 /// mutually exclusive.
11112 ///
11113 /// # Example
11114 /// ```ignore,no_run
11115 /// # use google_maps_routeoptimization_v1::model::optimize_tours_validation_error::FieldReference;
11116 /// let x = FieldReference::new().set_index(42);
11117 /// assert!(x.index().is_some());
11118 /// assert!(x.key().is_none());
11119 /// ```
11120 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11121 self.index_or_key = std::option::Option::Some(
11122 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
11123 v.into(),
11124 ),
11125 );
11126 self
11127 }
11128
11129 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11130 /// if it holds a `Key`, `None` if the field is not set or
11131 /// holds a different branch.
11132 pub fn key(&self) -> std::option::Option<&std::string::String> {
11133 #[allow(unreachable_patterns)]
11134 self.index_or_key.as_ref().and_then(|v| match v {
11135 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11136 v,
11137 ) => std::option::Option::Some(v),
11138 _ => std::option::Option::None,
11139 })
11140 }
11141
11142 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11143 /// to hold a `Key`.
11144 ///
11145 /// Note that all the setters affecting `index_or_key` are
11146 /// mutually exclusive.
11147 ///
11148 /// # Example
11149 /// ```ignore,no_run
11150 /// # use google_maps_routeoptimization_v1::model::optimize_tours_validation_error::FieldReference;
11151 /// let x = FieldReference::new().set_key("example");
11152 /// assert!(x.key().is_some());
11153 /// assert!(x.index().is_none());
11154 /// ```
11155 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11156 self.index_or_key = std::option::Option::Some(
11157 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11158 v.into(),
11159 ),
11160 );
11161 self
11162 }
11163 }
11164
11165 impl wkt::message::Message for FieldReference {
11166 fn typename() -> &'static str {
11167 "type.googleapis.com/google.maps.routeoptimization.v1.OptimizeToursValidationError.FieldReference"
11168 }
11169 }
11170
11171 /// Defines additional types related to [FieldReference].
11172 pub mod field_reference {
11173 #[allow(unused_imports)]
11174 use super::*;
11175
11176 #[allow(missing_docs)]
11177 #[derive(Clone, Debug, PartialEq)]
11178 #[non_exhaustive]
11179 pub enum IndexOrKey {
11180 /// Index of the field if repeated.
11181 Index(i32),
11182 /// Key if the field is a map.
11183 Key(std::string::String),
11184 }
11185 }
11186}
11187
11188/// Specify an input for
11189/// [BatchOptimizeTours][google.maps.routeoptimization.v1.RouteOptimizationService.BatchOptimizeTours].
11190#[derive(Clone, Default, PartialEq)]
11191#[non_exhaustive]
11192pub struct InputConfig {
11193 /// Required. The input data format.
11194 pub data_format: crate::model::DataFormat,
11195
11196 /// Required.
11197 pub source: std::option::Option<crate::model::input_config::Source>,
11198
11199 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11200}
11201
11202impl InputConfig {
11203 /// Creates a new default instance.
11204 pub fn new() -> Self {
11205 std::default::Default::default()
11206 }
11207
11208 /// Sets the value of [data_format][crate::model::InputConfig::data_format].
11209 ///
11210 /// # Example
11211 /// ```ignore,no_run
11212 /// # use google_maps_routeoptimization_v1::model::InputConfig;
11213 /// use google_maps_routeoptimization_v1::model::DataFormat;
11214 /// let x0 = InputConfig::new().set_data_format(DataFormat::Json);
11215 /// let x1 = InputConfig::new().set_data_format(DataFormat::ProtoText);
11216 /// ```
11217 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
11218 mut self,
11219 v: T,
11220 ) -> Self {
11221 self.data_format = v.into();
11222 self
11223 }
11224
11225 /// Sets the value of [source][crate::model::InputConfig::source].
11226 ///
11227 /// Note that all the setters affecting `source` are mutually
11228 /// exclusive.
11229 ///
11230 /// # Example
11231 /// ```ignore,no_run
11232 /// # use google_maps_routeoptimization_v1::model::InputConfig;
11233 /// use google_maps_routeoptimization_v1::model::GcsSource;
11234 /// let x = InputConfig::new().set_source(Some(
11235 /// google_maps_routeoptimization_v1::model::input_config::Source::GcsSource(GcsSource::default().into())));
11236 /// ```
11237 pub fn set_source<
11238 T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
11239 >(
11240 mut self,
11241 v: T,
11242 ) -> Self {
11243 self.source = v.into();
11244 self
11245 }
11246
11247 /// The value of [source][crate::model::InputConfig::source]
11248 /// if it holds a `GcsSource`, `None` if the field is not set or
11249 /// holds a different branch.
11250 pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
11251 #[allow(unreachable_patterns)]
11252 self.source.as_ref().and_then(|v| match v {
11253 crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
11254 _ => std::option::Option::None,
11255 })
11256 }
11257
11258 /// Sets the value of [source][crate::model::InputConfig::source]
11259 /// to hold a `GcsSource`.
11260 ///
11261 /// Note that all the setters affecting `source` are
11262 /// mutually exclusive.
11263 ///
11264 /// # Example
11265 /// ```ignore,no_run
11266 /// # use google_maps_routeoptimization_v1::model::InputConfig;
11267 /// use google_maps_routeoptimization_v1::model::GcsSource;
11268 /// let x = InputConfig::new().set_gcs_source(GcsSource::default()/* use setters */);
11269 /// assert!(x.gcs_source().is_some());
11270 /// ```
11271 pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
11272 mut self,
11273 v: T,
11274 ) -> Self {
11275 self.source =
11276 std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
11277 self
11278 }
11279}
11280
11281impl wkt::message::Message for InputConfig {
11282 fn typename() -> &'static str {
11283 "type.googleapis.com/google.maps.routeoptimization.v1.InputConfig"
11284 }
11285}
11286
11287/// Defines additional types related to [InputConfig].
11288pub mod input_config {
11289 #[allow(unused_imports)]
11290 use super::*;
11291
11292 /// Required.
11293 #[derive(Clone, Debug, PartialEq)]
11294 #[non_exhaustive]
11295 pub enum Source {
11296 /// A Google Cloud Storage location. This must be a single object (file).
11297 GcsSource(std::boxed::Box<crate::model::GcsSource>),
11298 }
11299}
11300
11301/// Specify a destination for
11302/// [BatchOptimizeTours][google.maps.routeoptimization.v1.RouteOptimizationService.BatchOptimizeTours]
11303/// results.
11304#[derive(Clone, Default, PartialEq)]
11305#[non_exhaustive]
11306pub struct OutputConfig {
11307 /// Required. The output data format.
11308 pub data_format: crate::model::DataFormat,
11309
11310 /// Required.
11311 pub destination: std::option::Option<crate::model::output_config::Destination>,
11312
11313 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11314}
11315
11316impl OutputConfig {
11317 /// Creates a new default instance.
11318 pub fn new() -> Self {
11319 std::default::Default::default()
11320 }
11321
11322 /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
11323 ///
11324 /// # Example
11325 /// ```ignore,no_run
11326 /// # use google_maps_routeoptimization_v1::model::OutputConfig;
11327 /// use google_maps_routeoptimization_v1::model::DataFormat;
11328 /// let x0 = OutputConfig::new().set_data_format(DataFormat::Json);
11329 /// let x1 = OutputConfig::new().set_data_format(DataFormat::ProtoText);
11330 /// ```
11331 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
11332 mut self,
11333 v: T,
11334 ) -> Self {
11335 self.data_format = v.into();
11336 self
11337 }
11338
11339 /// Sets the value of [destination][crate::model::OutputConfig::destination].
11340 ///
11341 /// Note that all the setters affecting `destination` are mutually
11342 /// exclusive.
11343 ///
11344 /// # Example
11345 /// ```ignore,no_run
11346 /// # use google_maps_routeoptimization_v1::model::OutputConfig;
11347 /// use google_maps_routeoptimization_v1::model::GcsDestination;
11348 /// let x = OutputConfig::new().set_destination(Some(
11349 /// google_maps_routeoptimization_v1::model::output_config::Destination::GcsDestination(GcsDestination::default().into())));
11350 /// ```
11351 pub fn set_destination<
11352 T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
11353 >(
11354 mut self,
11355 v: T,
11356 ) -> Self {
11357 self.destination = v.into();
11358 self
11359 }
11360
11361 /// The value of [destination][crate::model::OutputConfig::destination]
11362 /// if it holds a `GcsDestination`, `None` if the field is not set or
11363 /// holds a different branch.
11364 pub fn gcs_destination(
11365 &self,
11366 ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
11367 #[allow(unreachable_patterns)]
11368 self.destination.as_ref().and_then(|v| match v {
11369 crate::model::output_config::Destination::GcsDestination(v) => {
11370 std::option::Option::Some(v)
11371 }
11372 _ => std::option::Option::None,
11373 })
11374 }
11375
11376 /// Sets the value of [destination][crate::model::OutputConfig::destination]
11377 /// to hold a `GcsDestination`.
11378 ///
11379 /// Note that all the setters affecting `destination` are
11380 /// mutually exclusive.
11381 ///
11382 /// # Example
11383 /// ```ignore,no_run
11384 /// # use google_maps_routeoptimization_v1::model::OutputConfig;
11385 /// use google_maps_routeoptimization_v1::model::GcsDestination;
11386 /// let x = OutputConfig::new().set_gcs_destination(GcsDestination::default()/* use setters */);
11387 /// assert!(x.gcs_destination().is_some());
11388 /// ```
11389 pub fn set_gcs_destination<
11390 T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
11391 >(
11392 mut self,
11393 v: T,
11394 ) -> Self {
11395 self.destination = std::option::Option::Some(
11396 crate::model::output_config::Destination::GcsDestination(v.into()),
11397 );
11398 self
11399 }
11400}
11401
11402impl wkt::message::Message for OutputConfig {
11403 fn typename() -> &'static str {
11404 "type.googleapis.com/google.maps.routeoptimization.v1.OutputConfig"
11405 }
11406}
11407
11408/// Defines additional types related to [OutputConfig].
11409pub mod output_config {
11410 #[allow(unused_imports)]
11411 use super::*;
11412
11413 /// Required.
11414 #[derive(Clone, Debug, PartialEq)]
11415 #[non_exhaustive]
11416 pub enum Destination {
11417 /// The Google Cloud Storage location to write the output to.
11418 GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
11419 }
11420}
11421
11422/// The Google Cloud Storage location where the input file will be read from.
11423#[derive(Clone, Default, PartialEq)]
11424#[non_exhaustive]
11425pub struct GcsSource {
11426 /// Required. URI of a Google Cloud Storage object with the format
11427 /// `gs://bucket/path/to/object`.
11428 pub uri: std::string::String,
11429
11430 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11431}
11432
11433impl GcsSource {
11434 /// Creates a new default instance.
11435 pub fn new() -> Self {
11436 std::default::Default::default()
11437 }
11438
11439 /// Sets the value of [uri][crate::model::GcsSource::uri].
11440 ///
11441 /// # Example
11442 /// ```ignore,no_run
11443 /// # use google_maps_routeoptimization_v1::model::GcsSource;
11444 /// let x = GcsSource::new().set_uri("example");
11445 /// ```
11446 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11447 self.uri = v.into();
11448 self
11449 }
11450}
11451
11452impl wkt::message::Message for GcsSource {
11453 fn typename() -> &'static str {
11454 "type.googleapis.com/google.maps.routeoptimization.v1.GcsSource"
11455 }
11456}
11457
11458/// The Google Cloud Storage location where the output file(s) will be written
11459/// to.
11460#[derive(Clone, Default, PartialEq)]
11461#[non_exhaustive]
11462pub struct GcsDestination {
11463 /// Required. Google Cloud Storage URI.
11464 pub uri: std::string::String,
11465
11466 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11467}
11468
11469impl GcsDestination {
11470 /// Creates a new default instance.
11471 pub fn new() -> Self {
11472 std::default::Default::default()
11473 }
11474
11475 /// Sets the value of [uri][crate::model::GcsDestination::uri].
11476 ///
11477 /// # Example
11478 /// ```ignore,no_run
11479 /// # use google_maps_routeoptimization_v1::model::GcsDestination;
11480 /// let x = GcsDestination::new().set_uri("example");
11481 /// ```
11482 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11483 self.uri = v.into();
11484 self
11485 }
11486}
11487
11488impl wkt::message::Message for GcsDestination {
11489 fn typename() -> &'static str {
11490 "type.googleapis.com/google.maps.routeoptimization.v1.GcsDestination"
11491 }
11492}
11493
11494/// Data formats for input and output files.
11495///
11496/// # Working with unknown values
11497///
11498/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11499/// additional enum variants at any time. Adding new variants is not considered
11500/// a breaking change. Applications should write their code in anticipation of:
11501///
11502/// - New values appearing in future releases of the client library, **and**
11503/// - New values received dynamically, without application changes.
11504///
11505/// Please consult the [Working with enums] section in the user guide for some
11506/// guidelines.
11507///
11508/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11509#[derive(Clone, Debug, PartialEq)]
11510#[non_exhaustive]
11511pub enum DataFormat {
11512 /// Invalid value, format must not be UNSPECIFIED.
11513 Unspecified,
11514 /// JavaScript Object Notation.
11515 Json,
11516 /// Protocol Buffers text format. See
11517 /// <https://protobuf.dev/reference/protobuf/textformat-spec/>
11518 ProtoText,
11519 /// If set, the enum was initialized with an unknown value.
11520 ///
11521 /// Applications can examine the value using [DataFormat::value] or
11522 /// [DataFormat::name].
11523 UnknownValue(data_format::UnknownValue),
11524}
11525
11526#[doc(hidden)]
11527pub mod data_format {
11528 #[allow(unused_imports)]
11529 use super::*;
11530 #[derive(Clone, Debug, PartialEq)]
11531 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11532}
11533
11534impl DataFormat {
11535 /// Gets the enum value.
11536 ///
11537 /// Returns `None` if the enum contains an unknown value deserialized from
11538 /// the string representation of enums.
11539 pub fn value(&self) -> std::option::Option<i32> {
11540 match self {
11541 Self::Unspecified => std::option::Option::Some(0),
11542 Self::Json => std::option::Option::Some(1),
11543 Self::ProtoText => std::option::Option::Some(2),
11544 Self::UnknownValue(u) => u.0.value(),
11545 }
11546 }
11547
11548 /// Gets the enum value as a string.
11549 ///
11550 /// Returns `None` if the enum contains an unknown value deserialized from
11551 /// the integer representation of enums.
11552 pub fn name(&self) -> std::option::Option<&str> {
11553 match self {
11554 Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
11555 Self::Json => std::option::Option::Some("JSON"),
11556 Self::ProtoText => std::option::Option::Some("PROTO_TEXT"),
11557 Self::UnknownValue(u) => u.0.name(),
11558 }
11559 }
11560}
11561
11562impl std::default::Default for DataFormat {
11563 fn default() -> Self {
11564 use std::convert::From;
11565 Self::from(0)
11566 }
11567}
11568
11569impl std::fmt::Display for DataFormat {
11570 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11571 wkt::internal::display_enum(f, self.name(), self.value())
11572 }
11573}
11574
11575impl std::convert::From<i32> for DataFormat {
11576 fn from(value: i32) -> Self {
11577 match value {
11578 0 => Self::Unspecified,
11579 1 => Self::Json,
11580 2 => Self::ProtoText,
11581 _ => Self::UnknownValue(data_format::UnknownValue(
11582 wkt::internal::UnknownEnumValue::Integer(value),
11583 )),
11584 }
11585 }
11586}
11587
11588impl std::convert::From<&str> for DataFormat {
11589 fn from(value: &str) -> Self {
11590 use std::string::ToString;
11591 match value {
11592 "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
11593 "JSON" => Self::Json,
11594 "PROTO_TEXT" => Self::ProtoText,
11595 _ => Self::UnknownValue(data_format::UnknownValue(
11596 wkt::internal::UnknownEnumValue::String(value.to_string()),
11597 )),
11598 }
11599 }
11600}
11601
11602impl serde::ser::Serialize for DataFormat {
11603 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11604 where
11605 S: serde::Serializer,
11606 {
11607 match self {
11608 Self::Unspecified => serializer.serialize_i32(0),
11609 Self::Json => serializer.serialize_i32(1),
11610 Self::ProtoText => serializer.serialize_i32(2),
11611 Self::UnknownValue(u) => u.0.serialize(serializer),
11612 }
11613 }
11614}
11615
11616impl<'de> serde::de::Deserialize<'de> for DataFormat {
11617 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11618 where
11619 D: serde::Deserializer<'de>,
11620 {
11621 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
11622 ".google.maps.routeoptimization.v1.DataFormat",
11623 ))
11624 }
11625}