google_cloud_optimization_v1/
model.rs

1// Copyright 2025 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::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate gaxi;
24extern crate gtype;
25extern crate lazy_static;
26extern crate longrunning;
27extern crate lro;
28extern crate reqwest;
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/// The desired input location information.
41#[derive(Clone, Default, PartialEq)]
42#[non_exhaustive]
43pub struct InputConfig {
44    /// The input data format that used to store the model in Cloud Storage.
45    pub data_format: crate::model::DataFormat,
46
47    /// The location of the input model in cloud storage.
48    /// Required.
49    pub source: std::option::Option<crate::model::input_config::Source>,
50
51    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
52}
53
54impl InputConfig {
55    pub fn new() -> Self {
56        std::default::Default::default()
57    }
58
59    /// Sets the value of [data_format][crate::model::InputConfig::data_format].
60    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
61        mut self,
62        v: T,
63    ) -> Self {
64        self.data_format = v.into();
65        self
66    }
67
68    /// Sets the value of [source][crate::model::InputConfig::source].
69    ///
70    /// Note that all the setters affecting `source` are mutually
71    /// exclusive.
72    pub fn set_source<
73        T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
74    >(
75        mut self,
76        v: T,
77    ) -> Self {
78        self.source = v.into();
79        self
80    }
81
82    /// The value of [source][crate::model::InputConfig::source]
83    /// if it holds a `GcsSource`, `None` if the field is not set or
84    /// holds a different branch.
85    pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
86        #[allow(unreachable_patterns)]
87        self.source.as_ref().and_then(|v| match v {
88            crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
89            _ => std::option::Option::None,
90        })
91    }
92
93    /// Sets the value of [source][crate::model::InputConfig::source]
94    /// to hold a `GcsSource`.
95    ///
96    /// Note that all the setters affecting `source` are
97    /// mutually exclusive.
98    pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
99        mut self,
100        v: T,
101    ) -> Self {
102        self.source =
103            std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
104        self
105    }
106}
107
108impl wkt::message::Message for InputConfig {
109    fn typename() -> &'static str {
110        "type.googleapis.com/google.cloud.optimization.v1.InputConfig"
111    }
112}
113
114/// Defines additional types related to [InputConfig].
115pub mod input_config {
116    #[allow(unused_imports)]
117    use super::*;
118
119    /// The location of the input model in cloud storage.
120    /// Required.
121    #[derive(Clone, Debug, PartialEq)]
122    #[non_exhaustive]
123    pub enum Source {
124        /// The Google Cloud Storage location to read the input from. This must be a
125        /// single file.
126        GcsSource(std::boxed::Box<crate::model::GcsSource>),
127    }
128}
129
130/// The desired output location.
131#[derive(Clone, Default, PartialEq)]
132#[non_exhaustive]
133pub struct OutputConfig {
134    /// The output data format that used to store the results in Cloud Storage.
135    pub data_format: crate::model::DataFormat,
136
137    /// The location of the output result in cloud storage.
138    /// Required.
139    pub destination: std::option::Option<crate::model::output_config::Destination>,
140
141    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
142}
143
144impl OutputConfig {
145    pub fn new() -> Self {
146        std::default::Default::default()
147    }
148
149    /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
150    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
151        mut self,
152        v: T,
153    ) -> Self {
154        self.data_format = v.into();
155        self
156    }
157
158    /// Sets the value of [destination][crate::model::OutputConfig::destination].
159    ///
160    /// Note that all the setters affecting `destination` are mutually
161    /// exclusive.
162    pub fn set_destination<
163        T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
164    >(
165        mut self,
166        v: T,
167    ) -> Self {
168        self.destination = v.into();
169        self
170    }
171
172    /// The value of [destination][crate::model::OutputConfig::destination]
173    /// if it holds a `GcsDestination`, `None` if the field is not set or
174    /// holds a different branch.
175    pub fn gcs_destination(
176        &self,
177    ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
178        #[allow(unreachable_patterns)]
179        self.destination.as_ref().and_then(|v| match v {
180            crate::model::output_config::Destination::GcsDestination(v) => {
181                std::option::Option::Some(v)
182            }
183            _ => std::option::Option::None,
184        })
185    }
186
187    /// Sets the value of [destination][crate::model::OutputConfig::destination]
188    /// to hold a `GcsDestination`.
189    ///
190    /// Note that all the setters affecting `destination` are
191    /// mutually exclusive.
192    pub fn set_gcs_destination<
193        T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
194    >(
195        mut self,
196        v: T,
197    ) -> Self {
198        self.destination = std::option::Option::Some(
199            crate::model::output_config::Destination::GcsDestination(v.into()),
200        );
201        self
202    }
203}
204
205impl wkt::message::Message for OutputConfig {
206    fn typename() -> &'static str {
207        "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
208    }
209}
210
211/// Defines additional types related to [OutputConfig].
212pub mod output_config {
213    #[allow(unused_imports)]
214    use super::*;
215
216    /// The location of the output result in cloud storage.
217    /// Required.
218    #[derive(Clone, Debug, PartialEq)]
219    #[non_exhaustive]
220    pub enum Destination {
221        /// The Google Cloud Storage location to write the output to.
222        GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
223    }
224}
225
226/// The Google Cloud Storage location where the input file will be read from.
227#[derive(Clone, Default, PartialEq)]
228#[non_exhaustive]
229pub struct GcsSource {
230    /// Required. URI of the Google Cloud Storage location.
231    pub uri: std::string::String,
232
233    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
234}
235
236impl GcsSource {
237    pub fn new() -> Self {
238        std::default::Default::default()
239    }
240
241    /// Sets the value of [uri][crate::model::GcsSource::uri].
242    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
243        self.uri = v.into();
244        self
245    }
246}
247
248impl wkt::message::Message for GcsSource {
249    fn typename() -> &'static str {
250        "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
251    }
252}
253
254/// The Google Cloud Storage location where the output file will be written to.
255#[derive(Clone, Default, PartialEq)]
256#[non_exhaustive]
257pub struct GcsDestination {
258    /// Required. URI of the Google Cloud Storage location.
259    pub uri: std::string::String,
260
261    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
262}
263
264impl GcsDestination {
265    pub fn new() -> Self {
266        std::default::Default::default()
267    }
268
269    /// Sets the value of [uri][crate::model::GcsDestination::uri].
270    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
271        self.uri = v.into();
272        self
273    }
274}
275
276impl wkt::message::Message for GcsDestination {
277    fn typename() -> &'static str {
278        "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
279    }
280}
281
282/// The long running operation metadata for async model related methods.
283#[derive(Clone, Default, PartialEq)]
284#[non_exhaustive]
285pub struct AsyncModelMetadata {
286    /// The state of the current operation.
287    pub state: crate::model::async_model_metadata::State,
288
289    /// A message providing more details about the current state of the operation.
290    /// For example, the error message if the operation is failed.
291    pub state_message: std::string::String,
292
293    /// The creation time of the operation.
294    pub create_time: std::option::Option<wkt::Timestamp>,
295
296    /// The last update time of the operation.
297    pub update_time: std::option::Option<wkt::Timestamp>,
298
299    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
300}
301
302impl AsyncModelMetadata {
303    pub fn new() -> Self {
304        std::default::Default::default()
305    }
306
307    /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
308    pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
309        mut self,
310        v: T,
311    ) -> Self {
312        self.state = v.into();
313        self
314    }
315
316    /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
317    pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
318        self.state_message = v.into();
319        self
320    }
321
322    /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
323    pub fn set_create_time<T>(mut self, v: T) -> Self
324    where
325        T: std::convert::Into<wkt::Timestamp>,
326    {
327        self.create_time = std::option::Option::Some(v.into());
328        self
329    }
330
331    /// Sets or clears the value of [create_time][crate::model::AsyncModelMetadata::create_time].
332    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
333    where
334        T: std::convert::Into<wkt::Timestamp>,
335    {
336        self.create_time = v.map(|x| x.into());
337        self
338    }
339
340    /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
341    pub fn set_update_time<T>(mut self, v: T) -> Self
342    where
343        T: std::convert::Into<wkt::Timestamp>,
344    {
345        self.update_time = std::option::Option::Some(v.into());
346        self
347    }
348
349    /// Sets or clears the value of [update_time][crate::model::AsyncModelMetadata::update_time].
350    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
351    where
352        T: std::convert::Into<wkt::Timestamp>,
353    {
354        self.update_time = v.map(|x| x.into());
355        self
356    }
357}
358
359impl wkt::message::Message for AsyncModelMetadata {
360    fn typename() -> &'static str {
361        "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
362    }
363}
364
365/// Defines additional types related to [AsyncModelMetadata].
366pub mod async_model_metadata {
367    #[allow(unused_imports)]
368    use super::*;
369
370    /// Possible states of the operation.
371    ///
372    /// # Working with unknown values
373    ///
374    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
375    /// additional enum variants at any time. Adding new variants is not considered
376    /// a breaking change. Applications should write their code in anticipation of:
377    ///
378    /// - New values appearing in future releases of the client library, **and**
379    /// - New values received dynamically, without application changes.
380    ///
381    /// Please consult the [Working with enums] section in the user guide for some
382    /// guidelines.
383    ///
384    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
385    #[derive(Clone, Debug, PartialEq)]
386    #[non_exhaustive]
387    pub enum State {
388        /// The default value. This value is used if the state is omitted.
389        Unspecified,
390        /// Request is being processed.
391        Running,
392        /// The operation completed successfully.
393        Succeeded,
394        /// The operation was cancelled.
395        Cancelled,
396        /// The operation has failed.
397        Failed,
398        /// If set, the enum was initialized with an unknown value.
399        ///
400        /// Applications can examine the value using [State::value] or
401        /// [State::name].
402        UnknownValue(state::UnknownValue),
403    }
404
405    #[doc(hidden)]
406    pub mod state {
407        #[allow(unused_imports)]
408        use super::*;
409        #[derive(Clone, Debug, PartialEq)]
410        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
411    }
412
413    impl State {
414        /// Gets the enum value.
415        ///
416        /// Returns `None` if the enum contains an unknown value deserialized from
417        /// the string representation of enums.
418        pub fn value(&self) -> std::option::Option<i32> {
419            match self {
420                Self::Unspecified => std::option::Option::Some(0),
421                Self::Running => std::option::Option::Some(1),
422                Self::Succeeded => std::option::Option::Some(2),
423                Self::Cancelled => std::option::Option::Some(3),
424                Self::Failed => std::option::Option::Some(4),
425                Self::UnknownValue(u) => u.0.value(),
426            }
427        }
428
429        /// Gets the enum value as a string.
430        ///
431        /// Returns `None` if the enum contains an unknown value deserialized from
432        /// the integer representation of enums.
433        pub fn name(&self) -> std::option::Option<&str> {
434            match self {
435                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
436                Self::Running => std::option::Option::Some("RUNNING"),
437                Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
438                Self::Cancelled => std::option::Option::Some("CANCELLED"),
439                Self::Failed => std::option::Option::Some("FAILED"),
440                Self::UnknownValue(u) => u.0.name(),
441            }
442        }
443    }
444
445    impl std::default::Default for State {
446        fn default() -> Self {
447            use std::convert::From;
448            Self::from(0)
449        }
450    }
451
452    impl std::fmt::Display for State {
453        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
454            wkt::internal::display_enum(f, self.name(), self.value())
455        }
456    }
457
458    impl std::convert::From<i32> for State {
459        fn from(value: i32) -> Self {
460            match value {
461                0 => Self::Unspecified,
462                1 => Self::Running,
463                2 => Self::Succeeded,
464                3 => Self::Cancelled,
465                4 => Self::Failed,
466                _ => Self::UnknownValue(state::UnknownValue(
467                    wkt::internal::UnknownEnumValue::Integer(value),
468                )),
469            }
470        }
471    }
472
473    impl std::convert::From<&str> for State {
474        fn from(value: &str) -> Self {
475            use std::string::ToString;
476            match value {
477                "STATE_UNSPECIFIED" => Self::Unspecified,
478                "RUNNING" => Self::Running,
479                "SUCCEEDED" => Self::Succeeded,
480                "CANCELLED" => Self::Cancelled,
481                "FAILED" => Self::Failed,
482                _ => Self::UnknownValue(state::UnknownValue(
483                    wkt::internal::UnknownEnumValue::String(value.to_string()),
484                )),
485            }
486        }
487    }
488
489    impl serde::ser::Serialize for State {
490        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
491        where
492            S: serde::Serializer,
493        {
494            match self {
495                Self::Unspecified => serializer.serialize_i32(0),
496                Self::Running => serializer.serialize_i32(1),
497                Self::Succeeded => serializer.serialize_i32(2),
498                Self::Cancelled => serializer.serialize_i32(3),
499                Self::Failed => serializer.serialize_i32(4),
500                Self::UnknownValue(u) => u.0.serialize(serializer),
501            }
502        }
503    }
504
505    impl<'de> serde::de::Deserialize<'de> for State {
506        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
507        where
508            D: serde::Deserializer<'de>,
509        {
510            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
511                ".google.cloud.optimization.v1.AsyncModelMetadata.State",
512            ))
513        }
514    }
515}
516
517/// Request to be given to a tour optimization solver which defines the
518/// shipment model to solve as well as optimization parameters.
519#[derive(Clone, Default, PartialEq)]
520#[non_exhaustive]
521pub struct OptimizeToursRequest {
522    /// Required. Target project and location to make a call.
523    ///
524    /// Format: `projects/{project-id}/locations/{location-id}`.
525    ///
526    /// If no location is specified, a region will be chosen automatically.
527    pub parent: std::string::String,
528
529    /// If this timeout is set, the server returns a response before the timeout
530    /// period has elapsed or the server deadline for synchronous requests is
531    /// reached, whichever is sooner.
532    ///
533    /// For asynchronous requests, the server will generate a solution (if
534    /// possible) before the timeout has elapsed.
535    pub timeout: std::option::Option<wkt::Duration>,
536
537    /// Shipment model to solve.
538    pub model: std::option::Option<crate::model::ShipmentModel>,
539
540    /// By default, the solving mode is `DEFAULT_SOLVE` (0).
541    pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
542
543    /// Search mode used to solve the request.
544    pub search_mode: crate::model::optimize_tours_request::SearchMode,
545
546    /// Guide the optimization algorithm in finding a first solution that is
547    /// similar to a previous solution.
548    ///
549    /// The model is constrained when the first solution is built.
550    /// Any shipments not performed on a route are implicitly skipped in the first
551    /// solution, but they may be performed in successive solutions.
552    ///
553    /// The solution must satisfy some basic validity assumptions:
554    ///
555    /// * for all routes, `vehicle_index` must be in range and not be duplicated.
556    /// * for all visits, `shipment_index` and `visit_request_index` must be
557    ///   in range.
558    /// * a shipment may only be referenced on one route.
559    /// * the pickup of a pickup-delivery shipment must be performed before
560    ///   the delivery.
561    /// * no more than one pickup alternative or delivery alternative of
562    ///   a shipment may be performed.
563    /// * for all routes, times are increasing (i.e., `vehicle_start_time
564    ///   <= visits[0].start_time <= visits[1].start_time ...
565    ///   <= vehicle_end_time`).
566    /// * a shipment may only be performed on a vehicle that is allowed. A
567    ///   vehicle is allowed if
568    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
569    ///   is empty or its `vehicle_index` is included in
570    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
571    ///
572    /// If the injected solution is not feasible, a validation error is not
573    /// necessarily returned and an error indicating infeasibility may be returned
574    /// instead.
575    ///
576    /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
577    pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
578
579    /// Constrain the optimization algorithm to find a final solution that is
580    /// similar to a previous solution. For example, this may be used to freeze
581    /// portions of routes which have already been completed or which are to be
582    /// completed but must not be modified.
583    ///
584    /// If the injected solution is not feasible, a validation error is not
585    /// necessarily returned and an error indicating infeasibility may be returned
586    /// instead.
587    pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
588
589    /// If non-empty, the given routes will be refreshed, without modifying their
590    /// underlying sequence of visits or travel times: only other details will be
591    /// updated. This does not solve the model.
592    ///
593    /// As of 2020/11, this only populates the polylines of non-empty routes and
594    /// requires that `populate_polylines` is true.
595    ///
596    /// The `route_polyline` fields of the passed-in routes may be inconsistent
597    /// with route `transitions`.
598    ///
599    /// This field must not be used together with `injected_first_solution_routes`
600    /// or `injected_solution_constraint`.
601    ///
602    /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
603    /// Polylines are still populated between all visits in all non-empty routes
604    /// regardless of whether the related shipments or vehicles are ignored.
605    pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
606
607    /// If true:
608    ///
609    /// * uses
610    ///   [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
611    ///   instead of `vehicle_index` to
612    ///   match routes in an injected solution with vehicles in the request;
613    ///   reuses the mapping of original
614    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
615    ///   to new
616    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
617    ///   to update
618    ///   [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
619    ///   if non-empty, but the mapping must be unambiguous (i.e., multiple
620    ///   `ShipmentRoute`s must not share the same original `vehicle_index`).
621    /// * uses
622    ///   [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
623    ///   instead of `shipment_index`
624    ///   to match visits in an injected solution with shipments in the request;
625    /// * uses
626    ///   [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
627    ///   instead of
628    ///   [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
629    ///   to
630    ///   match skipped shipments in the injected solution with request
631    ///   shipments.
632    ///
633    /// This interpretation applies to the `injected_first_solution_routes`,
634    /// `injected_solution_constraint`, and `refresh_details_routes` fields.
635    /// It can be used when shipment or vehicle indices in the request have
636    /// changed since the solution was created, perhaps because shipments or
637    /// vehicles have been removed from or added to the request.
638    ///
639    /// If true, labels in the following categories must appear at most once in
640    /// their category:
641    ///
642    /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
643    ///   request;
644    /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
645    ///   request;
646    /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
647    /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
648    ///   the injected solution (except pickup/delivery visit pairs, whose
649    ///   `shipment_label` must appear twice).
650    ///
651    /// If a `vehicle_label` in the injected solution does not correspond to a
652    /// request vehicle, the corresponding route is removed from the solution
653    /// along with its visits. If a `shipment_label` in the injected solution does
654    /// not correspond to a request shipment, the corresponding visit is removed
655    /// from the solution. If a
656    /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
657    /// in the injected solution does not correspond to a request shipment, the
658    /// `SkippedShipment` is removed from the solution.
659    ///
660    /// Removing route visits or entire routes from an injected solution may
661    /// have an effect on the implied constraints, which may lead to change in
662    /// solution, validation errors, or infeasibility.
663    ///
664    /// NOTE: The caller must ensure that each
665    /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
666    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
667    /// identifies a vehicle (resp. shipment) entity used across the two relevant
668    /// requests: the past request that produced the `OptimizeToursResponse` used
669    /// in the injected solution and the current request that includes the injected
670    /// solution. The uniqueness checks described above are not enough to guarantee
671    /// this requirement.
672    ///
673    /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
674    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
675    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
676    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
677    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
678    /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
679    /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
680    /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
681    pub interpret_injected_solutions_using_labels: bool,
682
683    /// Consider traffic estimation in calculating `ShipmentRoute` fields
684    /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
685    /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
686    /// and `vehicle_end_time`; in setting the
687    /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
688    /// field, and in calculating the
689    /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
690    /// field.
691    ///
692    /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
693    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
694    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
695    /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
696    pub consider_road_traffic: bool,
697
698    /// If true, polylines will be populated in response `ShipmentRoute`s.
699    pub populate_polylines: bool,
700
701    /// If true, polylines will be populated in response
702    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
703    /// Note that in this case, the polylines will also be populated in the
704    /// deprecated `travel_steps`.
705    ///
706    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
707    pub populate_transition_polylines: bool,
708
709    /// If this is set, then the request can have a deadline
710    /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
711    /// Otherwise, the maximum deadline is only 30 minutes.
712    /// Note that long-lived requests have a significantly larger (but still small)
713    /// risk of interruption.
714    pub allow_large_deadline_despite_interruption_risk: bool,
715
716    /// If true, travel distances will be computed using geodesic distances instead
717    /// of Google Maps distances, and travel times will be computed using geodesic
718    /// distances with a speed defined by `geodesic_meters_per_second`.
719    pub use_geodesic_distances: bool,
720
721    /// When `use_geodesic_distances` is true, this field must be set and defines
722    /// the speed applied to compute travel times. Its value must be at least 1.0
723    /// meters/seconds.
724    pub geodesic_meters_per_second: std::option::Option<f64>,
725
726    /// Truncates the number of validation errors returned. These errors are
727    /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
728    /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
729    /// unless solving_mode=VALIDATE_ONLY: see the
730    /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
731    /// field.
732    /// This defaults to 100 and is capped at 10,000.
733    ///
734    /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
735    pub max_validation_errors: std::option::Option<i32>,
736
737    /// Label that may be used to identify this request, reported back in the
738    /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
739    ///
740    /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
741    pub label: std::string::String,
742
743    /// Deprecated: Use
744    /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
745    /// instead. If true, polylines will be populated in response
746    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
747    /// Note that in this case, the polylines will also be populated in the
748    /// deprecated `travel_steps`.
749    ///
750    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
751    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
752    #[deprecated]
753    pub populate_travel_step_polylines: bool,
754
755    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
756}
757
758impl OptimizeToursRequest {
759    pub fn new() -> Self {
760        std::default::Default::default()
761    }
762
763    /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
764    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
765        self.parent = v.into();
766        self
767    }
768
769    /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
770    pub fn set_timeout<T>(mut self, v: T) -> Self
771    where
772        T: std::convert::Into<wkt::Duration>,
773    {
774        self.timeout = std::option::Option::Some(v.into());
775        self
776    }
777
778    /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
779    pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
780    where
781        T: std::convert::Into<wkt::Duration>,
782    {
783        self.timeout = v.map(|x| x.into());
784        self
785    }
786
787    /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
788    pub fn set_model<T>(mut self, v: T) -> Self
789    where
790        T: std::convert::Into<crate::model::ShipmentModel>,
791    {
792        self.model = std::option::Option::Some(v.into());
793        self
794    }
795
796    /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
797    pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
798    where
799        T: std::convert::Into<crate::model::ShipmentModel>,
800    {
801        self.model = v.map(|x| x.into());
802        self
803    }
804
805    /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
806    pub fn set_solving_mode<
807        T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
808    >(
809        mut self,
810        v: T,
811    ) -> Self {
812        self.solving_mode = v.into();
813        self
814    }
815
816    /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
817    pub fn set_search_mode<
818        T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
819    >(
820        mut self,
821        v: T,
822    ) -> Self {
823        self.search_mode = v.into();
824        self
825    }
826
827    /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
828    pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
829    where
830        T: std::iter::IntoIterator<Item = V>,
831        V: std::convert::Into<crate::model::ShipmentRoute>,
832    {
833        use std::iter::Iterator;
834        self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
835        self
836    }
837
838    /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
839    pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
840    where
841        T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
842    {
843        self.injected_solution_constraint = std::option::Option::Some(v.into());
844        self
845    }
846
847    /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
848    pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
849    where
850        T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
851    {
852        self.injected_solution_constraint = v.map(|x| x.into());
853        self
854    }
855
856    /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
857    pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
858    where
859        T: std::iter::IntoIterator<Item = V>,
860        V: std::convert::Into<crate::model::ShipmentRoute>,
861    {
862        use std::iter::Iterator;
863        self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
864        self
865    }
866
867    /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
868    pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
869        mut self,
870        v: T,
871    ) -> Self {
872        self.interpret_injected_solutions_using_labels = v.into();
873        self
874    }
875
876    /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
877    pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
878        self.consider_road_traffic = v.into();
879        self
880    }
881
882    /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
883    pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
884        self.populate_polylines = v.into();
885        self
886    }
887
888    /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
889    pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
890        self.populate_transition_polylines = v.into();
891        self
892    }
893
894    /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
895    pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
896        mut self,
897        v: T,
898    ) -> Self {
899        self.allow_large_deadline_despite_interruption_risk = v.into();
900        self
901    }
902
903    /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
904    pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
905        self.use_geodesic_distances = v.into();
906        self
907    }
908
909    /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
910    pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
911    where
912        T: std::convert::Into<f64>,
913    {
914        self.geodesic_meters_per_second = std::option::Option::Some(v.into());
915        self
916    }
917
918    /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
919    pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
920    where
921        T: std::convert::Into<f64>,
922    {
923        self.geodesic_meters_per_second = v.map(|x| x.into());
924        self
925    }
926
927    /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
928    pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
929    where
930        T: std::convert::Into<i32>,
931    {
932        self.max_validation_errors = std::option::Option::Some(v.into());
933        self
934    }
935
936    /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
937    pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
938    where
939        T: std::convert::Into<i32>,
940    {
941        self.max_validation_errors = v.map(|x| x.into());
942        self
943    }
944
945    /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
946    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
947        self.label = v.into();
948        self
949    }
950
951    /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
952    #[deprecated]
953    pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
954        self.populate_travel_step_polylines = v.into();
955        self
956    }
957}
958
959impl wkt::message::Message for OptimizeToursRequest {
960    fn typename() -> &'static str {
961        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
962    }
963}
964
965/// Defines additional types related to [OptimizeToursRequest].
966pub mod optimize_tours_request {
967    #[allow(unused_imports)]
968    use super::*;
969
970    /// Defines how the solver should handle the request. In all modes but
971    /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
972    /// `INVALID_REQUEST` error. See
973    /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
974    /// to cap the number of errors returned.
975    ///
976    /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
977    ///
978    /// # Working with unknown values
979    ///
980    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
981    /// additional enum variants at any time. Adding new variants is not considered
982    /// a breaking change. Applications should write their code in anticipation of:
983    ///
984    /// - New values appearing in future releases of the client library, **and**
985    /// - New values received dynamically, without application changes.
986    ///
987    /// Please consult the [Working with enums] section in the user guide for some
988    /// guidelines.
989    ///
990    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
991    #[derive(Clone, Debug, PartialEq)]
992    #[non_exhaustive]
993    pub enum SolvingMode {
994        /// Solve the model.
995        DefaultSolve,
996        /// Only validates the model without solving it: populates as many
997        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
998        /// as possible.
999        ///
1000        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1001        ValidateOnly,
1002        /// Only populates
1003        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1004        /// or
1005        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
1006        /// and doesn't actually solve the rest of the request (`status` and `routes`
1007        /// are unset in the response).
1008        /// If infeasibilities in `injected_solution_constraint` routes are detected
1009        /// they are populated in the
1010        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1011        /// field and
1012        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
1013        /// is left empty.
1014        ///
1015        /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
1016        /// ones that are detected as infeasible during preprocessing.
1017        ///
1018        /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
1019        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1020        DetectSomeInfeasibleShipments,
1021        /// If set, the enum was initialized with an unknown value.
1022        ///
1023        /// Applications can examine the value using [SolvingMode::value] or
1024        /// [SolvingMode::name].
1025        UnknownValue(solving_mode::UnknownValue),
1026    }
1027
1028    #[doc(hidden)]
1029    pub mod solving_mode {
1030        #[allow(unused_imports)]
1031        use super::*;
1032        #[derive(Clone, Debug, PartialEq)]
1033        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1034    }
1035
1036    impl SolvingMode {
1037        /// Gets the enum value.
1038        ///
1039        /// Returns `None` if the enum contains an unknown value deserialized from
1040        /// the string representation of enums.
1041        pub fn value(&self) -> std::option::Option<i32> {
1042            match self {
1043                Self::DefaultSolve => std::option::Option::Some(0),
1044                Self::ValidateOnly => std::option::Option::Some(1),
1045                Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
1046                Self::UnknownValue(u) => u.0.value(),
1047            }
1048        }
1049
1050        /// Gets the enum value as a string.
1051        ///
1052        /// Returns `None` if the enum contains an unknown value deserialized from
1053        /// the integer representation of enums.
1054        pub fn name(&self) -> std::option::Option<&str> {
1055            match self {
1056                Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
1057                Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
1058                Self::DetectSomeInfeasibleShipments => {
1059                    std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
1060                }
1061                Self::UnknownValue(u) => u.0.name(),
1062            }
1063        }
1064    }
1065
1066    impl std::default::Default for SolvingMode {
1067        fn default() -> Self {
1068            use std::convert::From;
1069            Self::from(0)
1070        }
1071    }
1072
1073    impl std::fmt::Display for SolvingMode {
1074        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1075            wkt::internal::display_enum(f, self.name(), self.value())
1076        }
1077    }
1078
1079    impl std::convert::From<i32> for SolvingMode {
1080        fn from(value: i32) -> Self {
1081            match value {
1082                0 => Self::DefaultSolve,
1083                1 => Self::ValidateOnly,
1084                2 => Self::DetectSomeInfeasibleShipments,
1085                _ => Self::UnknownValue(solving_mode::UnknownValue(
1086                    wkt::internal::UnknownEnumValue::Integer(value),
1087                )),
1088            }
1089        }
1090    }
1091
1092    impl std::convert::From<&str> for SolvingMode {
1093        fn from(value: &str) -> Self {
1094            use std::string::ToString;
1095            match value {
1096                "DEFAULT_SOLVE" => Self::DefaultSolve,
1097                "VALIDATE_ONLY" => Self::ValidateOnly,
1098                "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
1099                _ => Self::UnknownValue(solving_mode::UnknownValue(
1100                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1101                )),
1102            }
1103        }
1104    }
1105
1106    impl serde::ser::Serialize for SolvingMode {
1107        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1108        where
1109            S: serde::Serializer,
1110        {
1111            match self {
1112                Self::DefaultSolve => serializer.serialize_i32(0),
1113                Self::ValidateOnly => serializer.serialize_i32(1),
1114                Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
1115                Self::UnknownValue(u) => u.0.serialize(serializer),
1116            }
1117        }
1118    }
1119
1120    impl<'de> serde::de::Deserialize<'de> for SolvingMode {
1121        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1122        where
1123            D: serde::Deserializer<'de>,
1124        {
1125            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
1126                ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
1127            ))
1128        }
1129    }
1130
1131    /// Mode defining the behavior of the search, trading off latency versus
1132    /// solution quality. In all modes, the global request deadline is enforced.
1133    ///
1134    /// # Working with unknown values
1135    ///
1136    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1137    /// additional enum variants at any time. Adding new variants is not considered
1138    /// a breaking change. Applications should write their code in anticipation of:
1139    ///
1140    /// - New values appearing in future releases of the client library, **and**
1141    /// - New values received dynamically, without application changes.
1142    ///
1143    /// Please consult the [Working with enums] section in the user guide for some
1144    /// guidelines.
1145    ///
1146    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1147    #[derive(Clone, Debug, PartialEq)]
1148    #[non_exhaustive]
1149    pub enum SearchMode {
1150        /// Unspecified search mode, equivalent to `RETURN_FAST`.
1151        Unspecified,
1152        /// Stop the search after finding the first good solution.
1153        ReturnFast,
1154        /// Spend all the available time to search for better solutions.
1155        ConsumeAllAvailableTime,
1156        /// If set, the enum was initialized with an unknown value.
1157        ///
1158        /// Applications can examine the value using [SearchMode::value] or
1159        /// [SearchMode::name].
1160        UnknownValue(search_mode::UnknownValue),
1161    }
1162
1163    #[doc(hidden)]
1164    pub mod search_mode {
1165        #[allow(unused_imports)]
1166        use super::*;
1167        #[derive(Clone, Debug, PartialEq)]
1168        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1169    }
1170
1171    impl SearchMode {
1172        /// Gets the enum value.
1173        ///
1174        /// Returns `None` if the enum contains an unknown value deserialized from
1175        /// the string representation of enums.
1176        pub fn value(&self) -> std::option::Option<i32> {
1177            match self {
1178                Self::Unspecified => std::option::Option::Some(0),
1179                Self::ReturnFast => std::option::Option::Some(1),
1180                Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
1181                Self::UnknownValue(u) => u.0.value(),
1182            }
1183        }
1184
1185        /// Gets the enum value as a string.
1186        ///
1187        /// Returns `None` if the enum contains an unknown value deserialized from
1188        /// the integer representation of enums.
1189        pub fn name(&self) -> std::option::Option<&str> {
1190            match self {
1191                Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
1192                Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
1193                Self::ConsumeAllAvailableTime => {
1194                    std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
1195                }
1196                Self::UnknownValue(u) => u.0.name(),
1197            }
1198        }
1199    }
1200
1201    impl std::default::Default for SearchMode {
1202        fn default() -> Self {
1203            use std::convert::From;
1204            Self::from(0)
1205        }
1206    }
1207
1208    impl std::fmt::Display for SearchMode {
1209        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1210            wkt::internal::display_enum(f, self.name(), self.value())
1211        }
1212    }
1213
1214    impl std::convert::From<i32> for SearchMode {
1215        fn from(value: i32) -> Self {
1216            match value {
1217                0 => Self::Unspecified,
1218                1 => Self::ReturnFast,
1219                2 => Self::ConsumeAllAvailableTime,
1220                _ => Self::UnknownValue(search_mode::UnknownValue(
1221                    wkt::internal::UnknownEnumValue::Integer(value),
1222                )),
1223            }
1224        }
1225    }
1226
1227    impl std::convert::From<&str> for SearchMode {
1228        fn from(value: &str) -> Self {
1229            use std::string::ToString;
1230            match value {
1231                "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
1232                "RETURN_FAST" => Self::ReturnFast,
1233                "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
1234                _ => Self::UnknownValue(search_mode::UnknownValue(
1235                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1236                )),
1237            }
1238        }
1239    }
1240
1241    impl serde::ser::Serialize for SearchMode {
1242        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1243        where
1244            S: serde::Serializer,
1245        {
1246            match self {
1247                Self::Unspecified => serializer.serialize_i32(0),
1248                Self::ReturnFast => serializer.serialize_i32(1),
1249                Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
1250                Self::UnknownValue(u) => u.0.serialize(serializer),
1251            }
1252        }
1253    }
1254
1255    impl<'de> serde::de::Deserialize<'de> for SearchMode {
1256        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1257        where
1258            D: serde::Deserializer<'de>,
1259        {
1260            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
1261                ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
1262            ))
1263        }
1264    }
1265}
1266
1267/// Response after solving a tour optimization problem containing the routes
1268/// followed by each vehicle, the shipments which have been skipped and the
1269/// overall cost of the solution.
1270#[derive(Clone, Default, PartialEq)]
1271#[non_exhaustive]
1272pub struct OptimizeToursResponse {
1273    /// Routes computed for each vehicle; the i-th route corresponds to the i-th
1274    /// vehicle in the model.
1275    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
1276
1277    /// Copy of the
1278    /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
1279    /// if a label was specified in the request.
1280    ///
1281    /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
1282    pub request_label: std::string::String,
1283
1284    /// The list of all shipments skipped.
1285    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
1286
1287    /// List of all the validation errors that we were able to detect
1288    /// independently. See the "MULTIPLE ERRORS" explanation for the
1289    /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
1290    /// message.
1291    ///
1292    /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
1293    pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
1294
1295    /// Duration, distance and usage metrics for this solution.
1296    pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
1297
1298    /// Deprecated: Use
1299    /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
1300    /// instead. Total cost of the solution. This takes into account all costs:
1301    /// costs per per hour and travel hour, fixed vehicle costs, unperformed
1302    /// shipment penalty costs, global duration cost, etc.
1303    ///
1304    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
1305    #[deprecated]
1306    pub total_cost: f64,
1307
1308    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1309}
1310
1311impl OptimizeToursResponse {
1312    pub fn new() -> Self {
1313        std::default::Default::default()
1314    }
1315
1316    /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
1317    pub fn set_routes<T, V>(mut self, v: T) -> Self
1318    where
1319        T: std::iter::IntoIterator<Item = V>,
1320        V: std::convert::Into<crate::model::ShipmentRoute>,
1321    {
1322        use std::iter::Iterator;
1323        self.routes = v.into_iter().map(|i| i.into()).collect();
1324        self
1325    }
1326
1327    /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
1328    pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1329        self.request_label = v.into();
1330        self
1331    }
1332
1333    /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
1334    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
1335    where
1336        T: std::iter::IntoIterator<Item = V>,
1337        V: std::convert::Into<crate::model::SkippedShipment>,
1338    {
1339        use std::iter::Iterator;
1340        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
1341        self
1342    }
1343
1344    /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
1345    pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
1346    where
1347        T: std::iter::IntoIterator<Item = V>,
1348        V: std::convert::Into<crate::model::OptimizeToursValidationError>,
1349    {
1350        use std::iter::Iterator;
1351        self.validation_errors = v.into_iter().map(|i| i.into()).collect();
1352        self
1353    }
1354
1355    /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1356    pub fn set_metrics<T>(mut self, v: T) -> Self
1357    where
1358        T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1359    {
1360        self.metrics = std::option::Option::Some(v.into());
1361        self
1362    }
1363
1364    /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1365    pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1366    where
1367        T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1368    {
1369        self.metrics = v.map(|x| x.into());
1370        self
1371    }
1372
1373    /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
1374    #[deprecated]
1375    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1376        self.total_cost = v.into();
1377        self
1378    }
1379}
1380
1381impl wkt::message::Message for OptimizeToursResponse {
1382    fn typename() -> &'static str {
1383        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
1384    }
1385}
1386
1387/// Defines additional types related to [OptimizeToursResponse].
1388pub mod optimize_tours_response {
1389    #[allow(unused_imports)]
1390    use super::*;
1391
1392    /// Overall metrics, aggregated over all routes.
1393    #[derive(Clone, Default, PartialEq)]
1394    #[non_exhaustive]
1395    pub struct Metrics {
1396        /// Aggregated over the routes. Each metric is the sum (or max, for loads)
1397        /// over all
1398        /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
1399        /// fields of the same name.
1400        ///
1401        /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
1402        pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
1403
1404        /// Number of mandatory shipments skipped.
1405        pub skipped_mandatory_shipment_count: i32,
1406
1407        /// Number of vehicles used. Note: if a vehicle route is empty and
1408        /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
1409        /// is true, the vehicle is considered used.
1410        ///
1411        /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
1412        pub used_vehicle_count: i32,
1413
1414        /// The earliest start time for a used vehicle, computed as the minimum over
1415        /// all used vehicles of
1416        /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
1417        ///
1418        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
1419        pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
1420
1421        /// The latest end time for a used vehicle, computed as the maximum over all
1422        /// used vehicles of
1423        /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
1424        ///
1425        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
1426        pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
1427
1428        /// Cost of the solution, broken down by cost-related request fields.
1429        /// The keys are proto paths, relative to the input OptimizeToursRequest,
1430        /// e.g. "model.shipments.pickups.cost", and the values are the total cost
1431        /// generated by the corresponding cost field, aggregated over the whole
1432        /// solution. In other words, costs["model.shipments.pickups.cost"] is the
1433        /// sum of all pickup costs over the solution. All costs defined in the model
1434        /// are reported in detail here with the exception of costs related to
1435        /// TransitionAttributes that are only reported in an aggregated way as of
1436        /// 2022/01.
1437        pub costs: std::collections::HashMap<std::string::String, f64>,
1438
1439        /// Total cost of the solution. The sum of all values in the costs map.
1440        pub total_cost: f64,
1441
1442        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1443    }
1444
1445    impl Metrics {
1446        pub fn new() -> Self {
1447            std::default::Default::default()
1448        }
1449
1450        /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1451        pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
1452        where
1453            T: std::convert::Into<crate::model::AggregatedMetrics>,
1454        {
1455            self.aggregated_route_metrics = std::option::Option::Some(v.into());
1456            self
1457        }
1458
1459        /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1460        pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1461        where
1462            T: std::convert::Into<crate::model::AggregatedMetrics>,
1463        {
1464            self.aggregated_route_metrics = v.map(|x| x.into());
1465            self
1466        }
1467
1468        /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
1469        pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
1470            mut self,
1471            v: T,
1472        ) -> Self {
1473            self.skipped_mandatory_shipment_count = v.into();
1474            self
1475        }
1476
1477        /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
1478        pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1479            self.used_vehicle_count = v.into();
1480            self
1481        }
1482
1483        /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1484        pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
1485        where
1486            T: std::convert::Into<wkt::Timestamp>,
1487        {
1488            self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
1489            self
1490        }
1491
1492        /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1493        pub fn set_or_clear_earliest_vehicle_start_time<T>(
1494            mut self,
1495            v: std::option::Option<T>,
1496        ) -> Self
1497        where
1498            T: std::convert::Into<wkt::Timestamp>,
1499        {
1500            self.earliest_vehicle_start_time = v.map(|x| x.into());
1501            self
1502        }
1503
1504        /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1505        pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
1506        where
1507            T: std::convert::Into<wkt::Timestamp>,
1508        {
1509            self.latest_vehicle_end_time = std::option::Option::Some(v.into());
1510            self
1511        }
1512
1513        /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1514        pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1515        where
1516            T: std::convert::Into<wkt::Timestamp>,
1517        {
1518            self.latest_vehicle_end_time = v.map(|x| x.into());
1519            self
1520        }
1521
1522        /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
1523        pub fn set_costs<T, K, V>(mut self, v: T) -> Self
1524        where
1525            T: std::iter::IntoIterator<Item = (K, V)>,
1526            K: std::convert::Into<std::string::String>,
1527            V: std::convert::Into<f64>,
1528        {
1529            use std::iter::Iterator;
1530            self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1531            self
1532        }
1533
1534        /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
1535        pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1536            self.total_cost = v.into();
1537            self
1538        }
1539    }
1540
1541    impl wkt::message::Message for Metrics {
1542        fn typename() -> &'static str {
1543            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
1544        }
1545    }
1546}
1547
1548/// Request to batch optimize tours as an asynchronous operation.
1549/// Each input file should contain one `OptimizeToursRequest`, and each output
1550/// file will contain one `OptimizeToursResponse`. The request contains
1551/// information to read/write and parse the files. All the input and output files
1552/// should be under the same project.
1553#[derive(Clone, Default, PartialEq)]
1554#[non_exhaustive]
1555pub struct BatchOptimizeToursRequest {
1556    /// Required. Target project and location to make a call.
1557    ///
1558    /// Format: `projects/{project-id}/locations/{location-id}`.
1559    ///
1560    /// If no location is specified, a region will be chosen automatically.
1561    pub parent: std::string::String,
1562
1563    /// Required. Input/Output information each purchase model, such as file paths
1564    /// and data formats.
1565    pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1566
1567    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1568}
1569
1570impl BatchOptimizeToursRequest {
1571    pub fn new() -> Self {
1572        std::default::Default::default()
1573    }
1574
1575    /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
1576    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1577        self.parent = v.into();
1578        self
1579    }
1580
1581    /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
1582    pub fn set_model_configs<T, V>(mut self, v: T) -> Self
1583    where
1584        T: std::iter::IntoIterator<Item = V>,
1585        V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1586    {
1587        use std::iter::Iterator;
1588        self.model_configs = v.into_iter().map(|i| i.into()).collect();
1589        self
1590    }
1591}
1592
1593impl wkt::message::Message for BatchOptimizeToursRequest {
1594    fn typename() -> &'static str {
1595        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
1596    }
1597}
1598
1599/// Defines additional types related to [BatchOptimizeToursRequest].
1600pub mod batch_optimize_tours_request {
1601    #[allow(unused_imports)]
1602    use super::*;
1603
1604    /// Information for solving one optimization model asynchronously.
1605    #[derive(Clone, Default, PartialEq)]
1606    #[non_exhaustive]
1607    pub struct AsyncModelConfig {
1608        /// User defined model name, can be used as alias by users to keep track of
1609        /// models.
1610        pub display_name: std::string::String,
1611
1612        /// Required. Information about the input model.
1613        pub input_config: std::option::Option<crate::model::InputConfig>,
1614
1615        /// Required. The desired output location information.
1616        pub output_config: std::option::Option<crate::model::OutputConfig>,
1617
1618        /// If this is set, the model will be solved in the checkpoint mode. In this
1619        /// mode, the input model can have a deadline longer than 30 mins without the
1620        /// risk of interruption. The model will be solved in multiple short-running
1621        /// stages. Each stage generates an intermediate checkpoint
1622        /// and stores it in the user's Cloud Storage buckets. The checkpoint
1623        /// mode should be preferred over
1624        /// allow_large_deadline_despite_interruption_risk since it prevents the risk
1625        /// of interruption.
1626        pub enable_checkpoints: bool,
1627
1628        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1629    }
1630
1631    impl AsyncModelConfig {
1632        pub fn new() -> Self {
1633            std::default::Default::default()
1634        }
1635
1636        /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
1637        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
1638            mut self,
1639            v: T,
1640        ) -> Self {
1641            self.display_name = v.into();
1642            self
1643        }
1644
1645        /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
1646        pub fn set_input_config<T>(mut self, v: T) -> Self
1647        where
1648            T: std::convert::Into<crate::model::InputConfig>,
1649        {
1650            self.input_config = std::option::Option::Some(v.into());
1651            self
1652        }
1653
1654        /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
1655        pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
1656        where
1657            T: std::convert::Into<crate::model::InputConfig>,
1658        {
1659            self.input_config = v.map(|x| x.into());
1660            self
1661        }
1662
1663        /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
1664        pub fn set_output_config<T>(mut self, v: T) -> Self
1665        where
1666            T: std::convert::Into<crate::model::OutputConfig>,
1667        {
1668            self.output_config = std::option::Option::Some(v.into());
1669            self
1670        }
1671
1672        /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
1673        pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
1674        where
1675            T: std::convert::Into<crate::model::OutputConfig>,
1676        {
1677            self.output_config = v.map(|x| x.into());
1678            self
1679        }
1680
1681        /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
1682        pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1683            self.enable_checkpoints = v.into();
1684            self
1685        }
1686    }
1687
1688    impl wkt::message::Message for AsyncModelConfig {
1689        fn typename() -> &'static str {
1690            "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
1691        }
1692    }
1693}
1694
1695/// Response to a `BatchOptimizeToursRequest`. This is returned in
1696/// the LRO Operation after the operation is complete.
1697#[derive(Clone, Default, PartialEq)]
1698#[non_exhaustive]
1699pub struct BatchOptimizeToursResponse {
1700    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1701}
1702
1703impl BatchOptimizeToursResponse {
1704    pub fn new() -> Self {
1705        std::default::Default::default()
1706    }
1707}
1708
1709impl wkt::message::Message for BatchOptimizeToursResponse {
1710    fn typename() -> &'static str {
1711        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
1712    }
1713}
1714
1715/// A shipment model contains a set of shipments which must be performed by a
1716/// set of vehicles, while minimizing the overall cost, which is the sum of:
1717///
1718/// * the cost of routing the vehicles (sum of cost per total time, cost per
1719///   travel time, and fixed cost over all vehicles).
1720/// * the unperformed shipment penalties.
1721/// * the cost of the global duration of the shipments
1722#[derive(Clone, Default, PartialEq)]
1723#[non_exhaustive]
1724pub struct ShipmentModel {
1725    /// Set of shipments which must be performed in the model.
1726    pub shipments: std::vec::Vec<crate::model::Shipment>,
1727
1728    /// Set of vehicles which can be used to perform visits.
1729    pub vehicles: std::vec::Vec<crate::model::Vehicle>,
1730
1731    /// Constrains the maximum number of active vehicles. A vehicle is active if
1732    /// its route performs at least one shipment. This can be used to limit the
1733    /// number of routes in the case where there are fewer drivers than
1734    /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
1735    /// will then select the best subset of vehicles to use.
1736    /// Must be strictly positive.
1737    pub max_active_vehicles: std::option::Option<i32>,
1738
1739    /// Global start and end time of the model: no times outside of this range
1740    /// can be considered valid.
1741    ///
1742    /// The model's time span must be less than a year, i.e. the `global_end_time`
1743    /// and the `global_start_time` must be within 31536000 seconds of each other.
1744    ///
1745    /// When using `cost_per_*hour` fields, you might want to set this window to a
1746    /// smaller interval to increase performance (eg. if you model a single day,
1747    /// you should set the global time limits to that day).
1748    /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
1749    /// as default.
1750    pub global_start_time: std::option::Option<wkt::Timestamp>,
1751
1752    /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
1753    /// is used as default.
1754    pub global_end_time: std::option::Option<wkt::Timestamp>,
1755
1756    /// The "global duration" of the overall plan is the difference between the
1757    /// earliest effective start time and the latest effective end time of
1758    /// all vehicles. Users can assign a cost per hour to that quantity to try
1759    /// and optimize for earliest job completion, for example. This cost must be in
1760    /// the same unit as
1761    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
1762    ///
1763    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
1764    pub global_duration_cost_per_hour: f64,
1765
1766    /// Specifies duration and distance matrices used in the model. If this field
1767    /// is empty, Google Maps or geodesic distances will be used instead, depending
1768    /// on the value of the `use_geodesic_distances` field. If it is not empty,
1769    /// `use_geodesic_distances` cannot be true and neither
1770    /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
1771    /// can be empty.
1772    ///
1773    /// Usage examples:
1774    ///
1775    /// * There are two locations: locA and locB.
1776    /// * 1 vehicle starting its route at locA and ending it at locA.
1777    /// * 1 pickup visit request at locB.
1778    ///
1779    /// ```norust
1780    /// model {
1781    ///   vehicles { start_tags: "locA"  end_tags: "locA" }
1782    ///   shipments { pickups { tags: "locB" } }
1783    ///   duration_distance_matrix_src_tags: "locA"
1784    ///   duration_distance_matrix_src_tags: "locB"
1785    ///   duration_distance_matrix_dst_tags: "locA"
1786    ///   duration_distance_matrix_dst_tags: "locB"
1787    ///   duration_distance_matrices {
1788    ///     rows {  # from: locA
1789    ///       durations { seconds: 0 }   meters: 0    # to: locA
1790    ///       durations { seconds: 100 } meters: 1000 # to: locB
1791    ///     }
1792    ///     rows {  # from: locB
1793    ///       durations { seconds: 102 } meters: 990 # to: locA
1794    ///       durations { seconds: 0 }   meters: 0   # to: locB
1795    ///     }
1796    ///   }
1797    /// }
1798    /// ```
1799    ///
1800    /// * There are three locations: locA, locB and locC.
1801    /// * 1 vehicle starting its route at locA and ending it at locB, using
1802    ///   matrix "fast".
1803    /// * 1 vehicle starting its route at locB and ending it at locB, using
1804    ///   matrix "slow".
1805    /// * 1 vehicle starting its route at locB and ending it at locB, using
1806    ///   matrix "fast".
1807    /// * 1 pickup visit request at locC.
1808    ///
1809    /// ```norust
1810    /// model {
1811    ///   vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
1812    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
1813    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
1814    ///   shipments { pickups { tags: "locC" } }
1815    ///   duration_distance_matrix_src_tags: "locA"
1816    ///   duration_distance_matrix_src_tags: "locB"
1817    ///   duration_distance_matrix_src_tags: "locC"
1818    ///   duration_distance_matrix_dst_tags: "locB"
1819    ///   duration_distance_matrix_dst_tags: "locC"
1820    ///   duration_distance_matrices {
1821    ///     vehicle_start_tag: "fast"
1822    ///     rows {  # from: locA
1823    ///       durations { seconds: 1000 } meters: 2000 # to: locB
1824    ///       durations { seconds: 600 }  meters: 1000 # to: locC
1825    ///     }
1826    ///     rows {  # from: locB
1827    ///       durations { seconds: 0 }   meters: 0    # to: locB
1828    ///       durations { seconds: 700 } meters: 1200 # to: locC
1829    ///     }
1830    ///     rows {  # from: locC
1831    ///       durations { seconds: 702 } meters: 1190 # to: locB
1832    ///       durations { seconds: 0 }   meters: 0    # to: locC
1833    ///     }
1834    ///   }
1835    ///   duration_distance_matrices {
1836    ///     vehicle_start_tag: "slow"
1837    ///     rows {  # from: locA
1838    ///       durations { seconds: 1800 } meters: 2001 # to: locB
1839    ///       durations { seconds: 900 }  meters: 1002 # to: locC
1840    ///     }
1841    ///     rows {  # from: locB
1842    ///       durations { seconds: 0 }    meters: 0    # to: locB
1843    ///       durations { seconds: 1000 } meters: 1202 # to: locC
1844    ///     }
1845    ///     rows {  # from: locC
1846    ///       durations { seconds: 1001 } meters: 1195 # to: locB
1847    ///       durations { seconds: 0 }    meters: 0    # to: locC
1848    ///     }
1849    ///   }
1850    /// }
1851    /// ```
1852    pub duration_distance_matrices:
1853        std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
1854
1855    /// Tags defining the sources of the duration and distance matrices;
1856    /// `duration_distance_matrices(i).rows(j)` defines durations and distances
1857    /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
1858    /// in matrix i.
1859    ///
1860    /// Tags correspond to
1861    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
1862    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
1863    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
1864    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
1865    /// the same; similarly a `VisitRequest`'s source and destination tags may be
1866    /// the same. All tags must be different and cannot be empty strings. If this
1867    /// field is not empty, then `duration_distance_matrices` must not be empty.
1868    ///
1869    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
1870    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
1871    pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
1872
1873    /// Tags defining the destinations of the duration and distance matrices;
1874    /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
1875    /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
1876    /// (resp. the distance) of the travel from visits with tag
1877    /// `duration_distance_matrix_src_tags(j)` to visits with tag
1878    /// `duration_distance_matrix_dst_tags(k)` in matrix i.
1879    ///
1880    /// Tags correspond to
1881    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
1882    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
1883    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
1884    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
1885    /// the same; similarly a `VisitRequest`'s source and destination tags may be
1886    /// the same. All tags must be different and cannot be empty strings. If this
1887    /// field is not empty, then `duration_distance_matrices` must not be empty.
1888    ///
1889    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
1890    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
1891    pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
1892
1893    /// Transition attributes added to the model.
1894    pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
1895
1896    /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
1897    pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
1898
1899    /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
1900    pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
1901
1902    /// Set of precedence rules which must be enforced in the model.
1903    pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
1904
1905    /// Deprecated: No longer used.
1906    /// Set of break rules used in the model.
1907    /// Each vehicle specifies the `BreakRule` that applies to it via the
1908    /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
1909    /// field (which must be a singleton).
1910    ///
1911    /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
1912    #[deprecated]
1913    pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
1914
1915    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1916}
1917
1918impl ShipmentModel {
1919    pub fn new() -> Self {
1920        std::default::Default::default()
1921    }
1922
1923    /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
1924    pub fn set_shipments<T, V>(mut self, v: T) -> Self
1925    where
1926        T: std::iter::IntoIterator<Item = V>,
1927        V: std::convert::Into<crate::model::Shipment>,
1928    {
1929        use std::iter::Iterator;
1930        self.shipments = v.into_iter().map(|i| i.into()).collect();
1931        self
1932    }
1933
1934    /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
1935    pub fn set_vehicles<T, V>(mut self, v: T) -> Self
1936    where
1937        T: std::iter::IntoIterator<Item = V>,
1938        V: std::convert::Into<crate::model::Vehicle>,
1939    {
1940        use std::iter::Iterator;
1941        self.vehicles = v.into_iter().map(|i| i.into()).collect();
1942        self
1943    }
1944
1945    /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
1946    pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
1947    where
1948        T: std::convert::Into<i32>,
1949    {
1950        self.max_active_vehicles = std::option::Option::Some(v.into());
1951        self
1952    }
1953
1954    /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
1955    pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
1956    where
1957        T: std::convert::Into<i32>,
1958    {
1959        self.max_active_vehicles = v.map(|x| x.into());
1960        self
1961    }
1962
1963    /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
1964    pub fn set_global_start_time<T>(mut self, v: T) -> Self
1965    where
1966        T: std::convert::Into<wkt::Timestamp>,
1967    {
1968        self.global_start_time = std::option::Option::Some(v.into());
1969        self
1970    }
1971
1972    /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
1973    pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
1974    where
1975        T: std::convert::Into<wkt::Timestamp>,
1976    {
1977        self.global_start_time = v.map(|x| x.into());
1978        self
1979    }
1980
1981    /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
1982    pub fn set_global_end_time<T>(mut self, v: T) -> Self
1983    where
1984        T: std::convert::Into<wkt::Timestamp>,
1985    {
1986        self.global_end_time = std::option::Option::Some(v.into());
1987        self
1988    }
1989
1990    /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
1991    pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1992    where
1993        T: std::convert::Into<wkt::Timestamp>,
1994    {
1995        self.global_end_time = v.map(|x| x.into());
1996        self
1997    }
1998
1999    /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
2000    pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2001        self.global_duration_cost_per_hour = v.into();
2002        self
2003    }
2004
2005    /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
2006    pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
2007    where
2008        T: std::iter::IntoIterator<Item = V>,
2009        V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
2010    {
2011        use std::iter::Iterator;
2012        self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
2013        self
2014    }
2015
2016    /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
2017    pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
2018    where
2019        T: std::iter::IntoIterator<Item = V>,
2020        V: std::convert::Into<std::string::String>,
2021    {
2022        use std::iter::Iterator;
2023        self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
2024        self
2025    }
2026
2027    /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
2028    pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
2029    where
2030        T: std::iter::IntoIterator<Item = V>,
2031        V: std::convert::Into<std::string::String>,
2032    {
2033        use std::iter::Iterator;
2034        self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
2035        self
2036    }
2037
2038    /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
2039    pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
2040    where
2041        T: std::iter::IntoIterator<Item = V>,
2042        V: std::convert::Into<crate::model::TransitionAttributes>,
2043    {
2044        use std::iter::Iterator;
2045        self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
2046        self
2047    }
2048
2049    /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
2050    pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
2051    where
2052        T: std::iter::IntoIterator<Item = V>,
2053        V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
2054    {
2055        use std::iter::Iterator;
2056        self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
2057        self
2058    }
2059
2060    /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
2061    pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
2062    where
2063        T: std::iter::IntoIterator<Item = V>,
2064        V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
2065    {
2066        use std::iter::Iterator;
2067        self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
2068        self
2069    }
2070
2071    /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
2072    pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
2073    where
2074        T: std::iter::IntoIterator<Item = V>,
2075        V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
2076    {
2077        use std::iter::Iterator;
2078        self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
2079        self
2080    }
2081
2082    /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
2083    #[deprecated]
2084    pub fn set_break_rules<T, V>(mut self, v: T) -> Self
2085    where
2086        T: std::iter::IntoIterator<Item = V>,
2087        V: std::convert::Into<crate::model::shipment_model::BreakRule>,
2088    {
2089        use std::iter::Iterator;
2090        self.break_rules = v.into_iter().map(|i| i.into()).collect();
2091        self
2092    }
2093}
2094
2095impl wkt::message::Message for ShipmentModel {
2096    fn typename() -> &'static str {
2097        "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
2098    }
2099}
2100
2101/// Defines additional types related to [ShipmentModel].
2102pub mod shipment_model {
2103    #[allow(unused_imports)]
2104    use super::*;
2105
2106    /// Specifies a duration and distance matrix from visit and vehicle start
2107    /// locations to visit and vehicle end locations.
2108    #[derive(Clone, Default, PartialEq)]
2109    #[non_exhaustive]
2110    pub struct DurationDistanceMatrix {
2111        /// Specifies the rows of the duration and distance matrix. It must have as
2112        /// many elements as
2113        /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
2114        ///
2115        /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
2116        pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
2117
2118        /// Tag defining to which vehicles this duration and distance matrix applies.
2119        /// If empty, this applies to all vehicles, and there can only be a single
2120        /// matrix.
2121        ///
2122        /// Each vehicle start must match exactly one matrix, i.e. exactly one of
2123        /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
2124        /// (and of that matrix only).
2125        ///
2126        /// All matrices must have a different `vehicle_start_tag`.
2127        pub vehicle_start_tag: std::string::String,
2128
2129        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2130    }
2131
2132    impl DurationDistanceMatrix {
2133        pub fn new() -> Self {
2134            std::default::Default::default()
2135        }
2136
2137        /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
2138        pub fn set_rows<T, V>(mut self, v: T) -> Self
2139        where
2140            T: std::iter::IntoIterator<Item = V>,
2141            V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
2142        {
2143            use std::iter::Iterator;
2144            self.rows = v.into_iter().map(|i| i.into()).collect();
2145            self
2146        }
2147
2148        /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
2149        pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
2150            mut self,
2151            v: T,
2152        ) -> Self {
2153            self.vehicle_start_tag = v.into();
2154            self
2155        }
2156    }
2157
2158    impl wkt::message::Message for DurationDistanceMatrix {
2159        fn typename() -> &'static str {
2160            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
2161        }
2162    }
2163
2164    /// Defines additional types related to [DurationDistanceMatrix].
2165    pub mod duration_distance_matrix {
2166        #[allow(unused_imports)]
2167        use super::*;
2168
2169        /// Specifies a row of the duration and distance matrix.
2170        #[derive(Clone, Default, PartialEq)]
2171        #[non_exhaustive]
2172        pub struct Row {
2173            /// Duration values for a given row. It must have as many elements as
2174            /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
2175            ///
2176            /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
2177            pub durations: std::vec::Vec<wkt::Duration>,
2178
2179            /// Distance values for a given row. If no costs or constraints refer to
2180            /// distances in the model, this can be left empty; otherwise it must have
2181            /// as many elements as `durations`.
2182            pub meters: std::vec::Vec<f64>,
2183
2184            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2185        }
2186
2187        impl Row {
2188            pub fn new() -> Self {
2189                std::default::Default::default()
2190            }
2191
2192            /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
2193            pub fn set_durations<T, V>(mut self, v: T) -> Self
2194            where
2195                T: std::iter::IntoIterator<Item = V>,
2196                V: std::convert::Into<wkt::Duration>,
2197            {
2198                use std::iter::Iterator;
2199                self.durations = v.into_iter().map(|i| i.into()).collect();
2200                self
2201            }
2202
2203            /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
2204            pub fn set_meters<T, V>(mut self, v: T) -> Self
2205            where
2206                T: std::iter::IntoIterator<Item = V>,
2207                V: std::convert::Into<f64>,
2208            {
2209                use std::iter::Iterator;
2210                self.meters = v.into_iter().map(|i| i.into()).collect();
2211                self
2212            }
2213        }
2214
2215        impl wkt::message::Message for Row {
2216            fn typename() -> &'static str {
2217                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
2218            }
2219        }
2220    }
2221
2222    /// A precedence rule between two events (each event is the pickup or the
2223    /// delivery of a shipment): the "second" event has to start at least
2224    /// `offset_duration` after "first" has started.
2225    ///
2226    /// Several precedences can refer to the same (or related) events, e.g.,
2227    /// "pickup of B happens after delivery of A" and "pickup of C happens after
2228    /// pickup of B".
2229    ///
2230    /// Furthermore, precedences only apply when both shipments are performed and
2231    /// are otherwise ignored.
2232    #[derive(Clone, Default, PartialEq)]
2233    #[non_exhaustive]
2234    pub struct PrecedenceRule {
2235        /// Shipment index of the "first" event. This field must be specified.
2236        pub first_index: std::option::Option<i32>,
2237
2238        /// Indicates if the "first" event is a delivery.
2239        pub first_is_delivery: bool,
2240
2241        /// Shipment index of the "second" event. This field must be specified.
2242        pub second_index: std::option::Option<i32>,
2243
2244        /// Indicates if the "second" event is a delivery.
2245        pub second_is_delivery: bool,
2246
2247        /// The offset between the "first" and "second" event. It can be negative.
2248        pub offset_duration: std::option::Option<wkt::Duration>,
2249
2250        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2251    }
2252
2253    impl PrecedenceRule {
2254        pub fn new() -> Self {
2255            std::default::Default::default()
2256        }
2257
2258        /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2259        pub fn set_first_index<T>(mut self, v: T) -> Self
2260        where
2261            T: std::convert::Into<i32>,
2262        {
2263            self.first_index = std::option::Option::Some(v.into());
2264            self
2265        }
2266
2267        /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2268        pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
2269        where
2270            T: std::convert::Into<i32>,
2271        {
2272            self.first_index = v.map(|x| x.into());
2273            self
2274        }
2275
2276        /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
2277        pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2278            self.first_is_delivery = v.into();
2279            self
2280        }
2281
2282        /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2283        pub fn set_second_index<T>(mut self, v: T) -> Self
2284        where
2285            T: std::convert::Into<i32>,
2286        {
2287            self.second_index = std::option::Option::Some(v.into());
2288            self
2289        }
2290
2291        /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2292        pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
2293        where
2294            T: std::convert::Into<i32>,
2295        {
2296            self.second_index = v.map(|x| x.into());
2297            self
2298        }
2299
2300        /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
2301        pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2302            self.second_is_delivery = v.into();
2303            self
2304        }
2305
2306        /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
2307        pub fn set_offset_duration<T>(mut self, v: T) -> Self
2308        where
2309            T: std::convert::Into<wkt::Duration>,
2310        {
2311            self.offset_duration = std::option::Option::Some(v.into());
2312            self
2313        }
2314
2315        /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
2316        pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
2317        where
2318            T: std::convert::Into<wkt::Duration>,
2319        {
2320            self.offset_duration = v.map(|x| x.into());
2321            self
2322        }
2323    }
2324
2325    impl wkt::message::Message for PrecedenceRule {
2326        fn typename() -> &'static str {
2327            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
2328        }
2329    }
2330
2331    /// Deprecated: Use top level
2332    /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
2333    /// Rules to generate time breaks for a vehicle (e.g. lunch
2334    /// breaks). A break is a contiguous period of time during which the vehicle
2335    /// remains idle at its current position and cannot perform any visit. A break
2336    /// may occur:
2337    ///
2338    /// * during the travel between two visits (which includes the time right
2339    ///   before or right after a visit, but not in the middle of a visit), in
2340    ///   which case it extends the corresponding transit time between the visits
2341    /// * before the vehicle start (the vehicle may not start in the middle of
2342    ///   a break), in which case it does not affect the vehicle start time.
2343    /// * after the vehicle end (ditto, with the vehicle end time).
2344    ///
2345    /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
2346    #[derive(Clone, Default, PartialEq)]
2347    #[non_exhaustive]
2348    #[deprecated]
2349    pub struct BreakRule {
2350        /// Sequence of breaks. See the `BreakRequest` message.
2351        pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
2352
2353        /// Several `FrequencyConstraint` may apply. They must all be satisfied by
2354        /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
2355        pub frequency_constraints:
2356            std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
2357
2358        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2359    }
2360
2361    impl BreakRule {
2362        pub fn new() -> Self {
2363            std::default::Default::default()
2364        }
2365
2366        /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
2367        pub fn set_break_requests<T, V>(mut self, v: T) -> Self
2368        where
2369            T: std::iter::IntoIterator<Item = V>,
2370            V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
2371        {
2372            use std::iter::Iterator;
2373            self.break_requests = v.into_iter().map(|i| i.into()).collect();
2374            self
2375        }
2376
2377        /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
2378        pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
2379        where
2380            T: std::iter::IntoIterator<Item = V>,
2381            V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
2382        {
2383            use std::iter::Iterator;
2384            self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
2385            self
2386        }
2387    }
2388
2389    impl wkt::message::Message for BreakRule {
2390        fn typename() -> &'static str {
2391            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
2392        }
2393    }
2394
2395    /// Defines additional types related to [BreakRule].
2396    pub mod break_rule {
2397        #[allow(unused_imports)]
2398        use super::*;
2399
2400        /// The sequence of breaks (i.e. their number and order) that apply to each
2401        /// vehicle must be known beforehand. The repeated `BreakRequest`s define
2402        /// that sequence, in the order in which they must occur. Their time windows
2403        /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
2404        /// be compatible with the order (this is checked).
2405        #[derive(Clone, Default, PartialEq)]
2406        #[non_exhaustive]
2407        pub struct BreakRequest {
2408            /// Required. Lower bound (inclusive) on the start of the break.
2409            pub earliest_start_time: std::option::Option<wkt::Timestamp>,
2410
2411            /// Required. Upper bound (inclusive) on the start of the break.
2412            pub latest_start_time: std::option::Option<wkt::Timestamp>,
2413
2414            /// Required. Minimum duration of the break. Must be positive.
2415            pub min_duration: std::option::Option<wkt::Duration>,
2416
2417            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2418        }
2419
2420        impl BreakRequest {
2421            pub fn new() -> Self {
2422                std::default::Default::default()
2423            }
2424
2425            /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
2426            pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
2427            where
2428                T: std::convert::Into<wkt::Timestamp>,
2429            {
2430                self.earliest_start_time = std::option::Option::Some(v.into());
2431                self
2432            }
2433
2434            /// Sets or clears the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
2435            pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2436            where
2437                T: std::convert::Into<wkt::Timestamp>,
2438            {
2439                self.earliest_start_time = v.map(|x| x.into());
2440                self
2441            }
2442
2443            /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
2444            pub fn set_latest_start_time<T>(mut self, v: T) -> Self
2445            where
2446                T: std::convert::Into<wkt::Timestamp>,
2447            {
2448                self.latest_start_time = std::option::Option::Some(v.into());
2449                self
2450            }
2451
2452            /// Sets or clears the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
2453            pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2454            where
2455                T: std::convert::Into<wkt::Timestamp>,
2456            {
2457                self.latest_start_time = v.map(|x| x.into());
2458                self
2459            }
2460
2461            /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
2462            pub fn set_min_duration<T>(mut self, v: T) -> Self
2463            where
2464                T: std::convert::Into<wkt::Duration>,
2465            {
2466                self.min_duration = std::option::Option::Some(v.into());
2467                self
2468            }
2469
2470            /// Sets or clears the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
2471            pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
2472            where
2473                T: std::convert::Into<wkt::Duration>,
2474            {
2475                self.min_duration = v.map(|x| x.into());
2476                self
2477            }
2478        }
2479
2480        impl wkt::message::Message for BreakRequest {
2481            fn typename() -> &'static str {
2482                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
2483            }
2484        }
2485
2486        /// One may further constrain the frequency and duration of the breaks
2487        /// specified above, by enforcing a minimum break frequency, such as
2488        /// "There must be a break of at least 1 hour every 12 hours". Assuming that
2489        /// this can be interpreted as "Within any sliding time window of 12h, there
2490        /// must be at least one break of at least one hour", that example would
2491        /// translate to the following `FrequencyConstraint`:
2492        ///
2493        /// ```norust
2494        /// {
2495        ///    min_break_duration { seconds: 3600 }         # 1 hour.
2496        ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
2497        /// }
2498        /// ```
2499        ///
2500        /// The timing and duration of the breaks in the solution will respect all
2501        /// such constraints, in addition to the time windows and minimum durations
2502        /// already specified in the `BreakRequest`.
2503        ///
2504        /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
2505        /// For example, the following schedule honors the "1h every 12h" example:
2506        ///
2507        /// ```norust
2508        ///   04:00 vehicle start
2509        ///    .. performing travel and visits ..
2510        ///   09:00 1 hour break
2511        ///   10:00 end of the break
2512        ///    .. performing travel and visits ..
2513        ///   12:00 20-min lunch break
2514        ///   12:20 end of the break
2515        ///    .. performing travel and visits ..
2516        ///   21:00 1 hour break
2517        ///   22:00 end of the break
2518        ///    .. performing travel and visits ..
2519        ///   23:59 vehicle end
2520        /// ```
2521        #[derive(Clone, Default, PartialEq)]
2522        #[non_exhaustive]
2523        pub struct FrequencyConstraint {
2524            /// Required. Minimum break duration for this constraint. Nonnegative.
2525            /// See description of `FrequencyConstraint`.
2526            pub min_break_duration: std::option::Option<wkt::Duration>,
2527
2528            /// Required. Maximum allowed span of any interval of time in the route
2529            /// that does not include at least partially a break of `duration >=
2530            /// min_break_duration`. Must be positive.
2531            pub max_inter_break_duration: std::option::Option<wkt::Duration>,
2532
2533            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2534        }
2535
2536        impl FrequencyConstraint {
2537            pub fn new() -> Self {
2538                std::default::Default::default()
2539            }
2540
2541            /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
2542            pub fn set_min_break_duration<T>(mut self, v: T) -> Self
2543            where
2544                T: std::convert::Into<wkt::Duration>,
2545            {
2546                self.min_break_duration = std::option::Option::Some(v.into());
2547                self
2548            }
2549
2550            /// Sets or clears the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
2551            pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
2552            where
2553                T: std::convert::Into<wkt::Duration>,
2554            {
2555                self.min_break_duration = v.map(|x| x.into());
2556                self
2557            }
2558
2559            /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
2560            pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
2561            where
2562                T: std::convert::Into<wkt::Duration>,
2563            {
2564                self.max_inter_break_duration = std::option::Option::Some(v.into());
2565                self
2566            }
2567
2568            /// Sets or clears the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
2569            pub fn set_or_clear_max_inter_break_duration<T>(
2570                mut self,
2571                v: std::option::Option<T>,
2572            ) -> Self
2573            where
2574                T: std::convert::Into<wkt::Duration>,
2575            {
2576                self.max_inter_break_duration = v.map(|x| x.into());
2577                self
2578            }
2579        }
2580
2581        impl wkt::message::Message for FrequencyConstraint {
2582            fn typename() -> &'static str {
2583                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
2584            }
2585        }
2586    }
2587}
2588
2589/// The shipment of a single item, from one of its pickups to one of its
2590/// deliveries. For the shipment to be considered as performed, a unique vehicle
2591/// must visit one of its pickup locations (and decrease its spare capacities
2592/// accordingly), then visit one of its delivery locations later on (and
2593/// therefore re-increase its spare capacities accordingly).
2594#[derive(Clone, Default, PartialEq)]
2595#[non_exhaustive]
2596pub struct Shipment {
2597    /// Set of pickup alternatives associated to the shipment. If not specified,
2598    /// the vehicle only needs to visit a location corresponding to the deliveries.
2599    pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
2600
2601    /// Set of delivery alternatives associated to the shipment. If not specified,
2602    /// the vehicle only needs to visit a location corresponding to the pickups.
2603    pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
2604
2605    /// Load demands of the shipment (for example weight, volume, number of
2606    /// pallets etc). The keys in the map should be identifiers describing the type
2607    /// of the corresponding load, ideally also including the units.
2608    /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
2609    /// If a given key does not appear in the map, the corresponding load is
2610    /// considered as null.
2611    pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
2612
2613    /// If the shipment is not completed, this penalty is added to the overall
2614    /// cost of the routes. A shipment is considered completed if one of its pickup
2615    /// and delivery alternatives is visited. The cost may be expressed in the
2616    /// same unit used for all other cost-related fields in the model and must be
2617    /// positive.
2618    ///
2619    /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
2620    /// i.e. the shipment must be completed.
2621    pub penalty_cost: std::option::Option<f64>,
2622
2623    /// The set of vehicles that may perform this shipment. If empty, all vehicles
2624    /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
2625    /// `vehicles` list.
2626    pub allowed_vehicle_indices: std::vec::Vec<i32>,
2627
2628    /// Specifies the cost that is incurred when this shipment is delivered by each
2629    /// vehicle. If specified, it must have EITHER:
2630    ///
2631    /// * the same number of elements as `costs_per_vehicle_indices`.
2632    ///   `costs_per_vehicle[i]` corresponds to vehicle
2633    ///   `costs_per_vehicle_indices[i]` of the model.
2634    /// * the same number of elements as there are vehicles in the model. The
2635    ///   i-th element corresponds to vehicle #i of the model.
2636    ///
2637    /// These costs must be in the same unit as `penalty_cost` and must not be
2638    /// negative. Leave this field empty, if there are no such costs.
2639    pub costs_per_vehicle: std::vec::Vec<f64>,
2640
2641    /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
2642    /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
2643    /// index may not be specified more than once. If a vehicle is excluded from
2644    /// `costs_per_vehicle_indices`, its cost is zero.
2645    pub costs_per_vehicle_indices: std::vec::Vec<i32>,
2646
2647    /// Specifies the maximum relative detour time compared to the shortest path
2648    /// from pickup to delivery. If specified, it must be nonnegative, and the
2649    /// shipment must contain at least a pickup and a delivery.
2650    ///
2651    /// For example, let t be the shortest time taken to go from the selected
2652    /// pickup alternative directly to the selected delivery alternative. Then
2653    /// setting `pickup_to_delivery_relative_detour_limit` enforces:
2654    ///
2655    /// ```norust
2656    /// start_time(delivery) - start_time(pickup) <=
2657    /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
2658    /// ```
2659    ///
2660    /// If both relative and absolute limits are specified on the same shipment,
2661    /// the more constraining limit is used for each possible pickup/delivery pair.
2662    /// As of 2017/10, detours are only supported when travel durations do not
2663    /// depend on vehicles.
2664    pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
2665
2666    /// Specifies the maximum absolute detour time compared to the shortest path
2667    /// from pickup to delivery. If specified, it must be nonnegative, and the
2668    /// shipment must contain at least a pickup and a delivery.
2669    ///
2670    /// For example, let t be the shortest time taken to go from the selected
2671    /// pickup alternative directly to the selected delivery alternative. Then
2672    /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
2673    ///
2674    /// ```norust
2675    /// start_time(delivery) - start_time(pickup) <=
2676    /// t + pickup_to_delivery_absolute_detour_limit
2677    /// ```
2678    ///
2679    /// If both relative and absolute limits are specified on the same shipment,
2680    /// the more constraining limit is used for each possible pickup/delivery pair.
2681    /// As of 2017/10, detours are only supported when travel durations do not
2682    /// depend on vehicles.
2683    pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
2684
2685    /// Specifies the maximum duration from start of pickup to start of delivery of
2686    /// a shipment. If specified, it must be nonnegative, and the shipment must
2687    /// contain at least a pickup and a delivery. This does not depend on which
2688    /// alternatives are selected for pickup and delivery, nor on vehicle speed.
2689    /// This can be specified alongside maximum detour constraints: the solution
2690    /// will respect both specifications.
2691    pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
2692
2693    /// Non-empty string specifying a "type" for this shipment.
2694    /// This feature can be used to define incompatibilities or requirements
2695    /// between `shipment_types` (see `shipment_type_incompatibilities` and
2696    /// `shipment_type_requirements` in `ShipmentModel`).
2697    ///
2698    /// Differs from `visit_types` which is specified for a single visit: All
2699    /// pickup/deliveries belonging to the same shipment share the same
2700    /// `shipment_type`.
2701    pub shipment_type: std::string::String,
2702
2703    /// Specifies a label for this shipment. This label is reported in the response
2704    /// in the `shipment_label` of the corresponding
2705    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
2706    ///
2707    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
2708    pub label: std::string::String,
2709
2710    /// If true, skip this shipment, but don't apply a `penalty_cost`.
2711    ///
2712    /// Ignoring a shipment results in a validation error when there are any
2713    /// `shipment_type_requirements` in the model.
2714    ///
2715    /// Ignoring a shipment that is performed in `injected_first_solution_routes`
2716    /// or `injected_solution_constraint` is permitted; the solver removes the
2717    /// related pickup/delivery visits from the performing route.
2718    /// `precedence_rules` that reference ignored shipments will also be ignored.
2719    pub ignore: bool,
2720
2721    /// Deprecated: Use
2722    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
2723    /// instead.
2724    ///
2725    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
2726    #[deprecated]
2727    pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
2728
2729    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2730}
2731
2732impl Shipment {
2733    pub fn new() -> Self {
2734        std::default::Default::default()
2735    }
2736
2737    /// Sets the value of [pickups][crate::model::Shipment::pickups].
2738    pub fn set_pickups<T, V>(mut self, v: T) -> Self
2739    where
2740        T: std::iter::IntoIterator<Item = V>,
2741        V: std::convert::Into<crate::model::shipment::VisitRequest>,
2742    {
2743        use std::iter::Iterator;
2744        self.pickups = v.into_iter().map(|i| i.into()).collect();
2745        self
2746    }
2747
2748    /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
2749    pub fn set_deliveries<T, V>(mut self, v: T) -> Self
2750    where
2751        T: std::iter::IntoIterator<Item = V>,
2752        V: std::convert::Into<crate::model::shipment::VisitRequest>,
2753    {
2754        use std::iter::Iterator;
2755        self.deliveries = v.into_iter().map(|i| i.into()).collect();
2756        self
2757    }
2758
2759    /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
2760    pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
2761    where
2762        T: std::iter::IntoIterator<Item = (K, V)>,
2763        K: std::convert::Into<std::string::String>,
2764        V: std::convert::Into<crate::model::shipment::Load>,
2765    {
2766        use std::iter::Iterator;
2767        self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2768        self
2769    }
2770
2771    /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
2772    pub fn set_penalty_cost<T>(mut self, v: T) -> Self
2773    where
2774        T: std::convert::Into<f64>,
2775    {
2776        self.penalty_cost = std::option::Option::Some(v.into());
2777        self
2778    }
2779
2780    /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
2781    pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
2782    where
2783        T: std::convert::Into<f64>,
2784    {
2785        self.penalty_cost = v.map(|x| x.into());
2786        self
2787    }
2788
2789    /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
2790    pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
2791    where
2792        T: std::iter::IntoIterator<Item = V>,
2793        V: std::convert::Into<i32>,
2794    {
2795        use std::iter::Iterator;
2796        self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
2797        self
2798    }
2799
2800    /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
2801    pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
2802    where
2803        T: std::iter::IntoIterator<Item = V>,
2804        V: std::convert::Into<f64>,
2805    {
2806        use std::iter::Iterator;
2807        self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
2808        self
2809    }
2810
2811    /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
2812    pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
2813    where
2814        T: std::iter::IntoIterator<Item = V>,
2815        V: std::convert::Into<i32>,
2816    {
2817        use std::iter::Iterator;
2818        self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
2819        self
2820    }
2821
2822    /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
2823    pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
2824    where
2825        T: std::convert::Into<f64>,
2826    {
2827        self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
2828        self
2829    }
2830
2831    /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
2832    pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
2833        mut self,
2834        v: std::option::Option<T>,
2835    ) -> Self
2836    where
2837        T: std::convert::Into<f64>,
2838    {
2839        self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
2840        self
2841    }
2842
2843    /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
2844    pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
2845    where
2846        T: std::convert::Into<wkt::Duration>,
2847    {
2848        self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
2849        self
2850    }
2851
2852    /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
2853    pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
2854        mut self,
2855        v: std::option::Option<T>,
2856    ) -> Self
2857    where
2858        T: std::convert::Into<wkt::Duration>,
2859    {
2860        self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
2861        self
2862    }
2863
2864    /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
2865    pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
2866    where
2867        T: std::convert::Into<wkt::Duration>,
2868    {
2869        self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
2870        self
2871    }
2872
2873    /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
2874    pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
2875        mut self,
2876        v: std::option::Option<T>,
2877    ) -> Self
2878    where
2879        T: std::convert::Into<wkt::Duration>,
2880    {
2881        self.pickup_to_delivery_time_limit = v.map(|x| x.into());
2882        self
2883    }
2884
2885    /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
2886    pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2887        self.shipment_type = v.into();
2888        self
2889    }
2890
2891    /// Sets the value of [label][crate::model::Shipment::label].
2892    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2893        self.label = v.into();
2894        self
2895    }
2896
2897    /// Sets the value of [ignore][crate::model::Shipment::ignore].
2898    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2899        self.ignore = v.into();
2900        self
2901    }
2902
2903    /// Sets the value of [demands][crate::model::Shipment::demands].
2904    #[deprecated]
2905    pub fn set_demands<T, V>(mut self, v: T) -> Self
2906    where
2907        T: std::iter::IntoIterator<Item = V>,
2908        V: std::convert::Into<crate::model::CapacityQuantity>,
2909    {
2910        use std::iter::Iterator;
2911        self.demands = v.into_iter().map(|i| i.into()).collect();
2912        self
2913    }
2914}
2915
2916impl wkt::message::Message for Shipment {
2917    fn typename() -> &'static str {
2918        "type.googleapis.com/google.cloud.optimization.v1.Shipment"
2919    }
2920}
2921
2922/// Defines additional types related to [Shipment].
2923pub mod shipment {
2924    #[allow(unused_imports)]
2925    use super::*;
2926
2927    /// Request for a visit which can be done by a vehicle: it has a geo-location
2928    /// (or two, see below), opening and closing times represented by time windows,
2929    /// and a service duration time (time spent by the vehicle once it has arrived
2930    /// to pickup or drop off goods).
2931    #[derive(Clone, Default, PartialEq)]
2932    #[non_exhaustive]
2933    pub struct VisitRequest {
2934        /// The geo-location where the vehicle arrives when performing this
2935        /// `VisitRequest`. If the shipment model has duration distance matrices,
2936        /// `arrival_location` must not be specified.
2937        pub arrival_location: std::option::Option<gtype::model::LatLng>,
2938
2939        /// The waypoint where the vehicle arrives when performing this
2940        /// `VisitRequest`. If the shipment model has duration distance matrices,
2941        /// `arrival_waypoint` must not be specified.
2942        pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
2943
2944        /// The geo-location where the vehicle departs after completing this
2945        /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
2946        /// If the shipment model has duration distance matrices,
2947        /// `departure_location` must not be specified.
2948        pub departure_location: std::option::Option<gtype::model::LatLng>,
2949
2950        /// The waypoint where the vehicle departs after completing this
2951        /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
2952        /// If the shipment model has duration distance matrices,
2953        /// `departure_waypoint` must not be specified.
2954        pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
2955
2956        /// Specifies tags attached to the visit request.
2957        /// Empty or duplicate strings are not allowed.
2958        pub tags: std::vec::Vec<std::string::String>,
2959
2960        /// Time windows which constrain the arrival time at a visit.
2961        /// Note that a vehicle may depart outside of the arrival time window, i.e.
2962        /// arrival time + duration do not need to be inside a time window. This can
2963        /// result in waiting time if the vehicle arrives before
2964        /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
2965        ///
2966        /// The absence of `TimeWindow` means that the vehicle can perform this visit
2967        /// at any time.
2968        ///
2969        /// Time windows must be disjoint, i.e. no time window must overlap with or
2970        /// be adjacent to another, and they must be in increasing order.
2971        ///
2972        /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
2973        /// be set if there is a single time window.
2974        ///
2975        /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
2976        pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
2977
2978        /// Duration of the visit, i.e. time spent by the vehicle between arrival
2979        /// and departure (to be added to the possible waiting time; see
2980        /// `time_windows`).
2981        pub duration: std::option::Option<wkt::Duration>,
2982
2983        /// Cost to service this visit request on a vehicle route. This can be used
2984        /// to pay different costs for each alternative pickup or delivery of a
2985        /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
2986        /// and must not be negative.
2987        pub cost: f64,
2988
2989        /// Load demands of this visit request. This is just like
2990        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
2991        /// field, except that it only applies to this
2992        /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
2993        /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
2994        /// The demands listed here are added to the demands listed in
2995        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
2996        ///
2997        /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
2998        /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
2999        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3000        pub load_demands:
3001            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3002
3003        /// Specifies the types of the visit. This may be used to allocate additional
3004        /// time required for a vehicle to complete this visit (see
3005        /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
3006        ///
3007        /// A type can only appear once.
3008        ///
3009        /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
3010        pub visit_types: std::vec::Vec<std::string::String>,
3011
3012        /// Specifies a label for this `VisitRequest`. This label is reported in the
3013        /// response as `visit_label` in the corresponding
3014        /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3015        ///
3016        /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3017        pub label: std::string::String,
3018
3019        /// Deprecated: Use
3020        /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
3021        /// instead.
3022        ///
3023        /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
3024        #[deprecated]
3025        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3026
3027        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3028    }
3029
3030    impl VisitRequest {
3031        pub fn new() -> Self {
3032            std::default::Default::default()
3033        }
3034
3035        /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3036        pub fn set_arrival_location<T>(mut self, v: T) -> Self
3037        where
3038            T: std::convert::Into<gtype::model::LatLng>,
3039        {
3040            self.arrival_location = std::option::Option::Some(v.into());
3041            self
3042        }
3043
3044        /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3045        pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
3046        where
3047            T: std::convert::Into<gtype::model::LatLng>,
3048        {
3049            self.arrival_location = v.map(|x| x.into());
3050            self
3051        }
3052
3053        /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
3054        pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
3055        where
3056            T: std::convert::Into<crate::model::Waypoint>,
3057        {
3058            self.arrival_waypoint = std::option::Option::Some(v.into());
3059            self
3060        }
3061
3062        /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
3063        pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
3064        where
3065            T: std::convert::Into<crate::model::Waypoint>,
3066        {
3067            self.arrival_waypoint = v.map(|x| x.into());
3068            self
3069        }
3070
3071        /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
3072        pub fn set_departure_location<T>(mut self, v: T) -> Self
3073        where
3074            T: std::convert::Into<gtype::model::LatLng>,
3075        {
3076            self.departure_location = std::option::Option::Some(v.into());
3077            self
3078        }
3079
3080        /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
3081        pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
3082        where
3083            T: std::convert::Into<gtype::model::LatLng>,
3084        {
3085            self.departure_location = v.map(|x| x.into());
3086            self
3087        }
3088
3089        /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
3090        pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
3091        where
3092            T: std::convert::Into<crate::model::Waypoint>,
3093        {
3094            self.departure_waypoint = std::option::Option::Some(v.into());
3095            self
3096        }
3097
3098        /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
3099        pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
3100        where
3101            T: std::convert::Into<crate::model::Waypoint>,
3102        {
3103            self.departure_waypoint = v.map(|x| x.into());
3104            self
3105        }
3106
3107        /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
3108        pub fn set_tags<T, V>(mut self, v: T) -> Self
3109        where
3110            T: std::iter::IntoIterator<Item = V>,
3111            V: std::convert::Into<std::string::String>,
3112        {
3113            use std::iter::Iterator;
3114            self.tags = v.into_iter().map(|i| i.into()).collect();
3115            self
3116        }
3117
3118        /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
3119        pub fn set_time_windows<T, V>(mut self, v: T) -> Self
3120        where
3121            T: std::iter::IntoIterator<Item = V>,
3122            V: std::convert::Into<crate::model::TimeWindow>,
3123        {
3124            use std::iter::Iterator;
3125            self.time_windows = v.into_iter().map(|i| i.into()).collect();
3126            self
3127        }
3128
3129        /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
3130        pub fn set_duration<T>(mut self, v: T) -> Self
3131        where
3132            T: std::convert::Into<wkt::Duration>,
3133        {
3134            self.duration = std::option::Option::Some(v.into());
3135            self
3136        }
3137
3138        /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
3139        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
3140        where
3141            T: std::convert::Into<wkt::Duration>,
3142        {
3143            self.duration = v.map(|x| x.into());
3144            self
3145        }
3146
3147        /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
3148        pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3149            self.cost = v.into();
3150            self
3151        }
3152
3153        /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
3154        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
3155        where
3156            T: std::iter::IntoIterator<Item = (K, V)>,
3157            K: std::convert::Into<std::string::String>,
3158            V: std::convert::Into<crate::model::shipment::Load>,
3159        {
3160            use std::iter::Iterator;
3161            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3162            self
3163        }
3164
3165        /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
3166        pub fn set_visit_types<T, V>(mut self, v: T) -> Self
3167        where
3168            T: std::iter::IntoIterator<Item = V>,
3169            V: std::convert::Into<std::string::String>,
3170        {
3171            use std::iter::Iterator;
3172            self.visit_types = v.into_iter().map(|i| i.into()).collect();
3173            self
3174        }
3175
3176        /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
3177        pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3178            self.label = v.into();
3179            self
3180        }
3181
3182        /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
3183        #[deprecated]
3184        pub fn set_demands<T, V>(mut self, v: T) -> Self
3185        where
3186            T: std::iter::IntoIterator<Item = V>,
3187            V: std::convert::Into<crate::model::CapacityQuantity>,
3188        {
3189            use std::iter::Iterator;
3190            self.demands = v.into_iter().map(|i| i.into()).collect();
3191            self
3192        }
3193    }
3194
3195    impl wkt::message::Message for VisitRequest {
3196        fn typename() -> &'static str {
3197            "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
3198        }
3199    }
3200
3201    /// When performing a visit, a predefined amount may be added to the vehicle
3202    /// load if it's a pickup, or subtracted if it's a delivery. This message
3203    /// defines such amount. See
3204    /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
3205    ///
3206    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3207    #[derive(Clone, Default, PartialEq)]
3208    #[non_exhaustive]
3209    pub struct Load {
3210        /// The amount by which the load of the vehicle performing the corresponding
3211        /// visit will vary. Since it is an integer, users are advised to choose an
3212        /// appropriate unit to avoid loss of precision. Must be ≥ 0.
3213        pub amount: i64,
3214
3215        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3216    }
3217
3218    impl Load {
3219        pub fn new() -> Self {
3220            std::default::Default::default()
3221        }
3222
3223        /// Sets the value of [amount][crate::model::shipment::Load::amount].
3224        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3225            self.amount = v.into();
3226            self
3227        }
3228    }
3229
3230    impl wkt::message::Message for Load {
3231        fn typename() -> &'static str {
3232            "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
3233        }
3234    }
3235}
3236
3237/// Specifies incompatibilties between shipments depending on their
3238/// shipment_type. The appearance of incompatible shipments on the same route is
3239/// restricted based on the incompatibility mode.
3240#[derive(Clone, Default, PartialEq)]
3241#[non_exhaustive]
3242pub struct ShipmentTypeIncompatibility {
3243    /// List of incompatible types. Two shipments having different `shipment_types`
3244    /// among those listed are "incompatible".
3245    pub types: std::vec::Vec<std::string::String>,
3246
3247    /// Mode applied to the incompatibility.
3248    pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
3249
3250    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3251}
3252
3253impl ShipmentTypeIncompatibility {
3254    pub fn new() -> Self {
3255        std::default::Default::default()
3256    }
3257
3258    /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
3259    pub fn set_types<T, V>(mut self, v: T) -> Self
3260    where
3261        T: std::iter::IntoIterator<Item = V>,
3262        V: std::convert::Into<std::string::String>,
3263    {
3264        use std::iter::Iterator;
3265        self.types = v.into_iter().map(|i| i.into()).collect();
3266        self
3267    }
3268
3269    /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
3270    pub fn set_incompatibility_mode<
3271        T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
3272    >(
3273        mut self,
3274        v: T,
3275    ) -> Self {
3276        self.incompatibility_mode = v.into();
3277        self
3278    }
3279}
3280
3281impl wkt::message::Message for ShipmentTypeIncompatibility {
3282    fn typename() -> &'static str {
3283        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
3284    }
3285}
3286
3287/// Defines additional types related to [ShipmentTypeIncompatibility].
3288pub mod shipment_type_incompatibility {
3289    #[allow(unused_imports)]
3290    use super::*;
3291
3292    /// Modes defining how the appearance of incompatible shipments are restricted
3293    /// on the same route.
3294    ///
3295    /// # Working with unknown values
3296    ///
3297    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3298    /// additional enum variants at any time. Adding new variants is not considered
3299    /// a breaking change. Applications should write their code in anticipation of:
3300    ///
3301    /// - New values appearing in future releases of the client library, **and**
3302    /// - New values received dynamically, without application changes.
3303    ///
3304    /// Please consult the [Working with enums] section in the user guide for some
3305    /// guidelines.
3306    ///
3307    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
3308    #[derive(Clone, Debug, PartialEq)]
3309    #[non_exhaustive]
3310    pub enum IncompatibilityMode {
3311        /// Unspecified incompatibility mode. This value should never be used.
3312        Unspecified,
3313        /// In this mode, two shipments with incompatible types can never share the
3314        /// same vehicle.
3315        NotPerformedBySameVehicle,
3316        /// For two shipments with incompatible types with the
3317        /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
3318        ///
3319        /// * If both are pickups only (no deliveries) or deliveries only (no
3320        ///   pickups), they cannot share the same vehicle at all.
3321        /// * If one of the shipments has a delivery and the other a pickup, the two
3322        ///   shipments can share the same vehicle iff the former shipment is
3323        ///   delivered before the latter is picked up.
3324        NotInSameVehicleSimultaneously,
3325        /// If set, the enum was initialized with an unknown value.
3326        ///
3327        /// Applications can examine the value using [IncompatibilityMode::value] or
3328        /// [IncompatibilityMode::name].
3329        UnknownValue(incompatibility_mode::UnknownValue),
3330    }
3331
3332    #[doc(hidden)]
3333    pub mod incompatibility_mode {
3334        #[allow(unused_imports)]
3335        use super::*;
3336        #[derive(Clone, Debug, PartialEq)]
3337        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3338    }
3339
3340    impl IncompatibilityMode {
3341        /// Gets the enum value.
3342        ///
3343        /// Returns `None` if the enum contains an unknown value deserialized from
3344        /// the string representation of enums.
3345        pub fn value(&self) -> std::option::Option<i32> {
3346            match self {
3347                Self::Unspecified => std::option::Option::Some(0),
3348                Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
3349                Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
3350                Self::UnknownValue(u) => u.0.value(),
3351            }
3352        }
3353
3354        /// Gets the enum value as a string.
3355        ///
3356        /// Returns `None` if the enum contains an unknown value deserialized from
3357        /// the integer representation of enums.
3358        pub fn name(&self) -> std::option::Option<&str> {
3359            match self {
3360                Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
3361                Self::NotPerformedBySameVehicle => {
3362                    std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
3363                }
3364                Self::NotInSameVehicleSimultaneously => {
3365                    std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
3366                }
3367                Self::UnknownValue(u) => u.0.name(),
3368            }
3369        }
3370    }
3371
3372    impl std::default::Default for IncompatibilityMode {
3373        fn default() -> Self {
3374            use std::convert::From;
3375            Self::from(0)
3376        }
3377    }
3378
3379    impl std::fmt::Display for IncompatibilityMode {
3380        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3381            wkt::internal::display_enum(f, self.name(), self.value())
3382        }
3383    }
3384
3385    impl std::convert::From<i32> for IncompatibilityMode {
3386        fn from(value: i32) -> Self {
3387            match value {
3388                0 => Self::Unspecified,
3389                1 => Self::NotPerformedBySameVehicle,
3390                2 => Self::NotInSameVehicleSimultaneously,
3391                _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
3392                    wkt::internal::UnknownEnumValue::Integer(value),
3393                )),
3394            }
3395        }
3396    }
3397
3398    impl std::convert::From<&str> for IncompatibilityMode {
3399        fn from(value: &str) -> Self {
3400            use std::string::ToString;
3401            match value {
3402                "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
3403                "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
3404                "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
3405                _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
3406                    wkt::internal::UnknownEnumValue::String(value.to_string()),
3407                )),
3408            }
3409        }
3410    }
3411
3412    impl serde::ser::Serialize for IncompatibilityMode {
3413        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3414        where
3415            S: serde::Serializer,
3416        {
3417            match self {
3418                Self::Unspecified => serializer.serialize_i32(0),
3419                Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
3420                Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
3421                Self::UnknownValue(u) => u.0.serialize(serializer),
3422            }
3423        }
3424    }
3425
3426    impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
3427        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3428        where
3429            D: serde::Deserializer<'de>,
3430        {
3431            deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
3432                ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
3433            ))
3434        }
3435    }
3436}
3437
3438/// Specifies requirements between shipments based on their shipment_type.
3439/// The specifics of the requirement are defined by the requirement mode.
3440#[derive(Clone, Default, PartialEq)]
3441#[non_exhaustive]
3442pub struct ShipmentTypeRequirement {
3443    /// List of alternative shipment types required by the
3444    /// `dependent_shipment_types`.
3445    pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
3446
3447    /// All shipments with a type in the `dependent_shipment_types` field require
3448    /// at least one shipment of type `required_shipment_type_alternatives` to be
3449    /// visited on the same route.
3450    ///
3451    /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
3452    /// are not allowed.
3453    pub dependent_shipment_types: std::vec::Vec<std::string::String>,
3454
3455    /// Mode applied to the requirement.
3456    pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
3457
3458    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3459}
3460
3461impl ShipmentTypeRequirement {
3462    pub fn new() -> Self {
3463        std::default::Default::default()
3464    }
3465
3466    /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
3467    pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
3468    where
3469        T: std::iter::IntoIterator<Item = V>,
3470        V: std::convert::Into<std::string::String>,
3471    {
3472        use std::iter::Iterator;
3473        self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
3474        self
3475    }
3476
3477    /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
3478    pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
3479    where
3480        T: std::iter::IntoIterator<Item = V>,
3481        V: std::convert::Into<std::string::String>,
3482    {
3483        use std::iter::Iterator;
3484        self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
3485        self
3486    }
3487
3488    /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
3489    pub fn set_requirement_mode<
3490        T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
3491    >(
3492        mut self,
3493        v: T,
3494    ) -> Self {
3495        self.requirement_mode = v.into();
3496        self
3497    }
3498}
3499
3500impl wkt::message::Message for ShipmentTypeRequirement {
3501    fn typename() -> &'static str {
3502        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
3503    }
3504}
3505
3506/// Defines additional types related to [ShipmentTypeRequirement].
3507pub mod shipment_type_requirement {
3508    #[allow(unused_imports)]
3509    use super::*;
3510
3511    /// Modes defining the appearance of dependent shipments on a route.
3512    ///
3513    /// # Working with unknown values
3514    ///
3515    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3516    /// additional enum variants at any time. Adding new variants is not considered
3517    /// a breaking change. Applications should write their code in anticipation of:
3518    ///
3519    /// - New values appearing in future releases of the client library, **and**
3520    /// - New values received dynamically, without application changes.
3521    ///
3522    /// Please consult the [Working with enums] section in the user guide for some
3523    /// guidelines.
3524    ///
3525    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
3526    #[derive(Clone, Debug, PartialEq)]
3527    #[non_exhaustive]
3528    pub enum RequirementMode {
3529        /// Unspecified requirement mode. This value should never be used.
3530        Unspecified,
3531        /// In this mode, all "dependent" shipments must share the same vehicle as at
3532        /// least one of their "required" shipments.
3533        PerformedBySameVehicle,
3534        /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
3535        /// shipments need to have at least one "required" shipment on their vehicle
3536        /// at the time of their pickup.
3537        ///
3538        /// A "dependent" shipment pickup must therefore have either:
3539        ///
3540        /// * A delivery-only "required" shipment delivered on the route after, or
3541        /// * A "required" shipment picked up on the route before it, and if the
3542        ///   "required" shipment has a delivery, this delivery must be performed
3543        ///   after the "dependent" shipment's pickup.
3544        InSameVehicleAtPickupTime,
3545        /// Same as before, except the "dependent" shipments need to have a
3546        /// "required" shipment on their vehicle at the time of their *delivery*.
3547        InSameVehicleAtDeliveryTime,
3548        /// If set, the enum was initialized with an unknown value.
3549        ///
3550        /// Applications can examine the value using [RequirementMode::value] or
3551        /// [RequirementMode::name].
3552        UnknownValue(requirement_mode::UnknownValue),
3553    }
3554
3555    #[doc(hidden)]
3556    pub mod requirement_mode {
3557        #[allow(unused_imports)]
3558        use super::*;
3559        #[derive(Clone, Debug, PartialEq)]
3560        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3561    }
3562
3563    impl RequirementMode {
3564        /// Gets the enum value.
3565        ///
3566        /// Returns `None` if the enum contains an unknown value deserialized from
3567        /// the string representation of enums.
3568        pub fn value(&self) -> std::option::Option<i32> {
3569            match self {
3570                Self::Unspecified => std::option::Option::Some(0),
3571                Self::PerformedBySameVehicle => std::option::Option::Some(1),
3572                Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
3573                Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
3574                Self::UnknownValue(u) => u.0.value(),
3575            }
3576        }
3577
3578        /// Gets the enum value as a string.
3579        ///
3580        /// Returns `None` if the enum contains an unknown value deserialized from
3581        /// the integer representation of enums.
3582        pub fn name(&self) -> std::option::Option<&str> {
3583            match self {
3584                Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
3585                Self::PerformedBySameVehicle => {
3586                    std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
3587                }
3588                Self::InSameVehicleAtPickupTime => {
3589                    std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
3590                }
3591                Self::InSameVehicleAtDeliveryTime => {
3592                    std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
3593                }
3594                Self::UnknownValue(u) => u.0.name(),
3595            }
3596        }
3597    }
3598
3599    impl std::default::Default for RequirementMode {
3600        fn default() -> Self {
3601            use std::convert::From;
3602            Self::from(0)
3603        }
3604    }
3605
3606    impl std::fmt::Display for RequirementMode {
3607        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3608            wkt::internal::display_enum(f, self.name(), self.value())
3609        }
3610    }
3611
3612    impl std::convert::From<i32> for RequirementMode {
3613        fn from(value: i32) -> Self {
3614            match value {
3615                0 => Self::Unspecified,
3616                1 => Self::PerformedBySameVehicle,
3617                2 => Self::InSameVehicleAtPickupTime,
3618                3 => Self::InSameVehicleAtDeliveryTime,
3619                _ => Self::UnknownValue(requirement_mode::UnknownValue(
3620                    wkt::internal::UnknownEnumValue::Integer(value),
3621                )),
3622            }
3623        }
3624    }
3625
3626    impl std::convert::From<&str> for RequirementMode {
3627        fn from(value: &str) -> Self {
3628            use std::string::ToString;
3629            match value {
3630                "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
3631                "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
3632                "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
3633                "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
3634                _ => Self::UnknownValue(requirement_mode::UnknownValue(
3635                    wkt::internal::UnknownEnumValue::String(value.to_string()),
3636                )),
3637            }
3638        }
3639    }
3640
3641    impl serde::ser::Serialize for RequirementMode {
3642        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3643        where
3644            S: serde::Serializer,
3645        {
3646            match self {
3647                Self::Unspecified => serializer.serialize_i32(0),
3648                Self::PerformedBySameVehicle => serializer.serialize_i32(1),
3649                Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
3650                Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
3651                Self::UnknownValue(u) => u.0.serialize(serializer),
3652            }
3653        }
3654    }
3655
3656    impl<'de> serde::de::Deserialize<'de> for RequirementMode {
3657        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3658        where
3659            D: serde::Deserializer<'de>,
3660        {
3661            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
3662                ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
3663            ))
3664        }
3665    }
3666}
3667
3668/// Encapsulates a set of optional conditions to satisfy when calculating
3669/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
3670/// Platform API; see:
3671/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
3672#[derive(Clone, Default, PartialEq)]
3673#[non_exhaustive]
3674pub struct RouteModifiers {
3675    /// Specifies whether to avoid toll roads where reasonable. Preference will be
3676    /// given to routes not containing toll roads. Applies only to motorized travel
3677    /// modes.
3678    pub avoid_tolls: bool,
3679
3680    /// Specifies whether to avoid highways where reasonable. Preference will be
3681    /// given to routes not containing highways. Applies only to motorized travel
3682    /// modes.
3683    pub avoid_highways: bool,
3684
3685    /// Specifies whether to avoid ferries where reasonable. Preference will be
3686    /// given to routes not containing travel by ferries. Applies only to motorized
3687    /// travel modes.
3688    pub avoid_ferries: bool,
3689
3690    /// Optional. Specifies whether to avoid navigating indoors where reasonable.
3691    /// Preference will be given to routes not containing indoor navigation.
3692    /// Applies only to the `WALKING` travel mode.
3693    pub avoid_indoor: bool,
3694
3695    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3696}
3697
3698impl RouteModifiers {
3699    pub fn new() -> Self {
3700        std::default::Default::default()
3701    }
3702
3703    /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
3704    pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3705        self.avoid_tolls = v.into();
3706        self
3707    }
3708
3709    /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
3710    pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3711        self.avoid_highways = v.into();
3712        self
3713    }
3714
3715    /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
3716    pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3717        self.avoid_ferries = v.into();
3718        self
3719    }
3720
3721    /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
3722    pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3723        self.avoid_indoor = v.into();
3724        self
3725    }
3726}
3727
3728impl wkt::message::Message for RouteModifiers {
3729    fn typename() -> &'static str {
3730        "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
3731    }
3732}
3733
3734/// Models a vehicle in a shipment problem. Solving a shipment problem will
3735/// build a route starting from `start_location` and ending at `end_location`
3736/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
3737#[derive(Clone, Default, PartialEq)]
3738#[non_exhaustive]
3739pub struct Vehicle {
3740    /// The travel mode which affects the roads usable by the vehicle and its
3741    /// speed. See also `travel_duration_multiple`.
3742    pub travel_mode: crate::model::vehicle::TravelMode,
3743
3744    /// Optional. A set of conditions to satisfy that affect the way routes are
3745    /// calculated for the given vehicle.
3746    pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
3747
3748    /// Geographic location where the vehicle starts before picking up any
3749    /// shipments. If not specified, the vehicle starts at its first pickup.
3750    /// If the shipment model has duration and distance matrices, `start_location`
3751    /// must not be specified.
3752    pub start_location: std::option::Option<gtype::model::LatLng>,
3753
3754    /// Waypoint representing a geographic location where the vehicle starts before
3755    /// picking up any shipments. If neither `start_waypoint` nor `start_location`
3756    /// is specified, the vehicle starts at its first pickup.
3757    /// If the shipment model has duration and distance matrices, `start_waypoint`
3758    /// must not be specified.
3759    pub start_waypoint: std::option::Option<crate::model::Waypoint>,
3760
3761    /// Geographic location where the vehicle ends after it has completed its last
3762    /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
3763    /// immediately when it completes its last `VisitRequest`.
3764    /// If the shipment model has duration and distance matrices, `end_location`
3765    /// must not be specified.
3766    pub end_location: std::option::Option<gtype::model::LatLng>,
3767
3768    /// Waypoint representing a geographic location where the vehicle ends after
3769    /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
3770    /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
3771    /// when it completes its last `VisitRequest`.
3772    /// If the shipment model has duration and distance matrices, `end_waypoint`
3773    /// must not be specified.
3774    pub end_waypoint: std::option::Option<crate::model::Waypoint>,
3775
3776    /// Specifies tags attached to the start of the vehicle's route.
3777    ///
3778    /// Empty or duplicate strings are not allowed.
3779    pub start_tags: std::vec::Vec<std::string::String>,
3780
3781    /// Specifies tags attached to the end of the vehicle's route.
3782    ///
3783    /// Empty or duplicate strings are not allowed.
3784    pub end_tags: std::vec::Vec<std::string::String>,
3785
3786    /// Time windows during which the vehicle may depart its start location.
3787    /// They must be within the global time limits (see
3788    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
3789    /// fields). If unspecified, there is no limitation besides those global time
3790    /// limits.
3791    ///
3792    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
3793    /// time window can overlap with or be adjacent to another, and they must be in
3794    /// chronological order.
3795    ///
3796    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
3797    /// there is a single time window.
3798    ///
3799    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
3800    pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
3801
3802    /// Time windows during which the vehicle may arrive at its end location.
3803    /// They must be within the global time limits (see
3804    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
3805    /// fields). If unspecified, there is no limitation besides those global time
3806    /// limits.
3807    ///
3808    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
3809    /// time window can overlap with or be adjacent to another, and they must be in
3810    /// chronological order.
3811    ///
3812    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
3813    /// there is a single time window.
3814    ///
3815    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
3816    pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
3817
3818    /// Specifies a multiplicative factor that can be used to increase or decrease
3819    /// travel times of this vehicle. For example, setting this to 2.0 means
3820    /// that this vehicle is slower and has travel times that are twice what they
3821    /// are for standard vehicles. This multiple does not affect visit durations.
3822    /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
3823    /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
3824    /// is standard, and this multiple is considered 1.0.
3825    ///
3826    /// WARNING: Travel times will be rounded to the nearest second after this
3827    /// multiple is applied but before performing any numerical operations, thus,
3828    /// a small multiple may result in a loss of precision.
3829    ///
3830    /// See also `extra_visit_duration_for_visit_type` below.
3831    pub travel_duration_multiple: std::option::Option<f64>,
3832
3833    /// Unloading policy enforced on the vehicle.
3834    pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
3835
3836    /// Capacities of the vehicle (weight, volume, # of pallets for example).
3837    /// The keys in the map are the identifiers of the type of load, consistent
3838    /// with the keys of the
3839    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3840    /// field. If a given key is absent from this map, the corresponding capacity
3841    /// is considered to be limitless.
3842    ///
3843    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3844    pub load_limits:
3845        std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
3846
3847    /// Vehicle costs: all costs add up and must be in the same unit as
3848    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
3849    ///
3850    /// Cost per hour of the vehicle route. This cost is applied to the total time
3851    /// taken by the route, and includes travel time, waiting time, and visit time.
3852    /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
3853    /// in additional latency.
3854    ///
3855    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
3856    pub cost_per_hour: f64,
3857
3858    /// Cost per traveled hour of the vehicle route. This cost is applied only to
3859    /// travel time taken by the route (i.e., that reported in
3860    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
3861    /// and excludes waiting time and visit time.
3862    ///
3863    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
3864    pub cost_per_traveled_hour: f64,
3865
3866    /// Cost per kilometer of the vehicle route. This cost is applied to the
3867    /// distance reported in the
3868    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
3869    /// and does not apply to any distance implicitly traveled from the
3870    /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
3871    ///
3872    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
3873    pub cost_per_kilometer: f64,
3874
3875    /// Fixed cost applied if this vehicle is used to handle a shipment.
3876    pub fixed_cost: f64,
3877
3878    /// This field only applies to vehicles when their route does not serve any
3879    /// shipments. It indicates if the vehicle should be considered as used or not
3880    /// in this case.
3881    ///
3882    /// If true, the vehicle goes from its start to its end location even if it
3883    /// doesn't serve any shipments, and time and distance costs resulting from its
3884    /// start --> end travel are taken into account.
3885    ///
3886    /// Otherwise, it doesn't travel from its start to its end location, and no
3887    /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
3888    /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
3889    /// information except for the vehicle index and label.
3890    pub used_if_route_is_empty: bool,
3891
3892    /// Limit applied to the total duration of the vehicle's route. In a given
3893    /// `OptimizeToursResponse`, the route duration of a vehicle is the
3894    /// difference between its `vehicle_end_time` and `vehicle_start_time`.
3895    pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
3896
3897    /// Limit applied to the travel duration of the vehicle's route. In a given
3898    /// `OptimizeToursResponse`, the route travel duration is the sum of all its
3899    /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
3900    ///
3901    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
3902    pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
3903
3904    /// Limit applied to the total distance of the vehicle's route. In a given
3905    /// `OptimizeToursResponse`, the route distance is the sum of all its
3906    /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
3907    ///
3908    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
3909    pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
3910
3911    /// Specifies a map from visit_types strings to durations. The duration is time
3912    /// in addition to
3913    /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
3914    /// to be taken at visits with the specified `visit_types`. This extra visit
3915    /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
3916    /// `visit_types`) cannot be empty strings.
3917    ///
3918    /// If a visit request has multiple types, a duration will be added for each
3919    /// type in the map.
3920    ///
3921    /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
3922    pub extra_visit_duration_for_visit_type:
3923        std::collections::HashMap<std::string::String, wkt::Duration>,
3924
3925    /// Describes the break schedule to be enforced on this vehicle.
3926    /// If empty, no breaks will be scheduled for this vehicle.
3927    pub break_rule: std::option::Option<crate::model::BreakRule>,
3928
3929    /// Specifies a label for this vehicle. This label is reported in the response
3930    /// as the `vehicle_label` of the corresponding
3931    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
3932    ///
3933    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
3934    pub label: std::string::String,
3935
3936    /// If true, `used_if_route_is_empty` must be false, and this vehicle will
3937    /// remain unused.
3938    ///
3939    /// If a shipment is performed by an ignored vehicle in
3940    /// `injected_first_solution_routes`, it is skipped in the first solution but
3941    /// is free to be performed in the response.
3942    ///
3943    /// If a shipment is performed by an ignored vehicle in
3944    /// `injected_solution_constraint` and any related pickup/delivery is
3945    /// constrained to remain on the vehicle (i.e., not relaxed to level
3946    /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
3947    /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
3948    /// the allowed vehicles are ignored, it is skipped in the response.
3949    pub ignore: bool,
3950
3951    /// Deprecated: No longer used.
3952    /// Indices in the `break_rule` field in the source
3953    /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
3954    /// correspond to break rules enforced on the vehicle.
3955    ///
3956    /// As of 2018/03, at most one rule index per vehicle can be specified.
3957    ///
3958    /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
3959    #[deprecated]
3960    pub break_rule_indices: std::vec::Vec<i32>,
3961
3962    /// Deprecated: Use
3963    /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
3964    /// instead.
3965    ///
3966    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
3967    #[deprecated]
3968    pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
3969
3970    /// Deprecated: Use
3971    /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
3972    /// instead.
3973    ///
3974    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
3975    #[deprecated]
3976    pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
3977
3978    /// Deprecated: Use
3979    /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
3980    /// instead.
3981    ///
3982    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
3983    #[deprecated]
3984    pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
3985
3986    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3987}
3988
3989impl Vehicle {
3990    pub fn new() -> Self {
3991        std::default::Default::default()
3992    }
3993
3994    /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
3995    pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
3996        mut self,
3997        v: T,
3998    ) -> Self {
3999        self.travel_mode = v.into();
4000        self
4001    }
4002
4003    /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
4004    pub fn set_route_modifiers<T>(mut self, v: T) -> Self
4005    where
4006        T: std::convert::Into<crate::model::RouteModifiers>,
4007    {
4008        self.route_modifiers = std::option::Option::Some(v.into());
4009        self
4010    }
4011
4012    /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
4013    pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
4014    where
4015        T: std::convert::Into<crate::model::RouteModifiers>,
4016    {
4017        self.route_modifiers = v.map(|x| x.into());
4018        self
4019    }
4020
4021    /// Sets the value of [start_location][crate::model::Vehicle::start_location].
4022    pub fn set_start_location<T>(mut self, v: T) -> Self
4023    where
4024        T: std::convert::Into<gtype::model::LatLng>,
4025    {
4026        self.start_location = std::option::Option::Some(v.into());
4027        self
4028    }
4029
4030    /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
4031    pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
4032    where
4033        T: std::convert::Into<gtype::model::LatLng>,
4034    {
4035        self.start_location = v.map(|x| x.into());
4036        self
4037    }
4038
4039    /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
4040    pub fn set_start_waypoint<T>(mut self, v: T) -> Self
4041    where
4042        T: std::convert::Into<crate::model::Waypoint>,
4043    {
4044        self.start_waypoint = std::option::Option::Some(v.into());
4045        self
4046    }
4047
4048    /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
4049    pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4050    where
4051        T: std::convert::Into<crate::model::Waypoint>,
4052    {
4053        self.start_waypoint = v.map(|x| x.into());
4054        self
4055    }
4056
4057    /// Sets the value of [end_location][crate::model::Vehicle::end_location].
4058    pub fn set_end_location<T>(mut self, v: T) -> Self
4059    where
4060        T: std::convert::Into<gtype::model::LatLng>,
4061    {
4062        self.end_location = std::option::Option::Some(v.into());
4063        self
4064    }
4065
4066    /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
4067    pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
4068    where
4069        T: std::convert::Into<gtype::model::LatLng>,
4070    {
4071        self.end_location = v.map(|x| x.into());
4072        self
4073    }
4074
4075    /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
4076    pub fn set_end_waypoint<T>(mut self, v: T) -> Self
4077    where
4078        T: std::convert::Into<crate::model::Waypoint>,
4079    {
4080        self.end_waypoint = std::option::Option::Some(v.into());
4081        self
4082    }
4083
4084    /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
4085    pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4086    where
4087        T: std::convert::Into<crate::model::Waypoint>,
4088    {
4089        self.end_waypoint = v.map(|x| x.into());
4090        self
4091    }
4092
4093    /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
4094    pub fn set_start_tags<T, V>(mut self, v: T) -> Self
4095    where
4096        T: std::iter::IntoIterator<Item = V>,
4097        V: std::convert::Into<std::string::String>,
4098    {
4099        use std::iter::Iterator;
4100        self.start_tags = v.into_iter().map(|i| i.into()).collect();
4101        self
4102    }
4103
4104    /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
4105    pub fn set_end_tags<T, V>(mut self, v: T) -> Self
4106    where
4107        T: std::iter::IntoIterator<Item = V>,
4108        V: std::convert::Into<std::string::String>,
4109    {
4110        use std::iter::Iterator;
4111        self.end_tags = v.into_iter().map(|i| i.into()).collect();
4112        self
4113    }
4114
4115    /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
4116    pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
4117    where
4118        T: std::iter::IntoIterator<Item = V>,
4119        V: std::convert::Into<crate::model::TimeWindow>,
4120    {
4121        use std::iter::Iterator;
4122        self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
4123        self
4124    }
4125
4126    /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
4127    pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
4128    where
4129        T: std::iter::IntoIterator<Item = V>,
4130        V: std::convert::Into<crate::model::TimeWindow>,
4131    {
4132        use std::iter::Iterator;
4133        self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
4134        self
4135    }
4136
4137    /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
4138    pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
4139    where
4140        T: std::convert::Into<f64>,
4141    {
4142        self.travel_duration_multiple = std::option::Option::Some(v.into());
4143        self
4144    }
4145
4146    /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
4147    pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
4148    where
4149        T: std::convert::Into<f64>,
4150    {
4151        self.travel_duration_multiple = v.map(|x| x.into());
4152        self
4153    }
4154
4155    /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
4156    pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
4157        mut self,
4158        v: T,
4159    ) -> Self {
4160        self.unloading_policy = v.into();
4161        self
4162    }
4163
4164    /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
4165    pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
4166    where
4167        T: std::iter::IntoIterator<Item = (K, V)>,
4168        K: std::convert::Into<std::string::String>,
4169        V: std::convert::Into<crate::model::vehicle::LoadLimit>,
4170    {
4171        use std::iter::Iterator;
4172        self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4173        self
4174    }
4175
4176    /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
4177    pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4178        self.cost_per_hour = v.into();
4179        self
4180    }
4181
4182    /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
4183    pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4184        self.cost_per_traveled_hour = v.into();
4185        self
4186    }
4187
4188    /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
4189    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4190        self.cost_per_kilometer = v.into();
4191        self
4192    }
4193
4194    /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
4195    pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4196        self.fixed_cost = v.into();
4197        self
4198    }
4199
4200    /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
4201    pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4202        self.used_if_route_is_empty = v.into();
4203        self
4204    }
4205
4206    /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
4207    pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
4208    where
4209        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
4210    {
4211        self.route_duration_limit = std::option::Option::Some(v.into());
4212        self
4213    }
4214
4215    /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
4216    pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
4217    where
4218        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
4219    {
4220        self.route_duration_limit = v.map(|x| x.into());
4221        self
4222    }
4223
4224    /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
4225    pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
4226    where
4227        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
4228    {
4229        self.travel_duration_limit = std::option::Option::Some(v.into());
4230        self
4231    }
4232
4233    /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
4234    pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
4235    where
4236        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
4237    {
4238        self.travel_duration_limit = v.map(|x| x.into());
4239        self
4240    }
4241
4242    /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
4243    pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
4244    where
4245        T: std::convert::Into<crate::model::DistanceLimit>,
4246    {
4247        self.route_distance_limit = std::option::Option::Some(v.into());
4248        self
4249    }
4250
4251    /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
4252    pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
4253    where
4254        T: std::convert::Into<crate::model::DistanceLimit>,
4255    {
4256        self.route_distance_limit = v.map(|x| x.into());
4257        self
4258    }
4259
4260    /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
4261    pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
4262    where
4263        T: std::iter::IntoIterator<Item = (K, V)>,
4264        K: std::convert::Into<std::string::String>,
4265        V: std::convert::Into<wkt::Duration>,
4266    {
4267        use std::iter::Iterator;
4268        self.extra_visit_duration_for_visit_type =
4269            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4270        self
4271    }
4272
4273    /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
4274    pub fn set_break_rule<T>(mut self, v: T) -> Self
4275    where
4276        T: std::convert::Into<crate::model::BreakRule>,
4277    {
4278        self.break_rule = std::option::Option::Some(v.into());
4279        self
4280    }
4281
4282    /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
4283    pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
4284    where
4285        T: std::convert::Into<crate::model::BreakRule>,
4286    {
4287        self.break_rule = v.map(|x| x.into());
4288        self
4289    }
4290
4291    /// Sets the value of [label][crate::model::Vehicle::label].
4292    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4293        self.label = v.into();
4294        self
4295    }
4296
4297    /// Sets the value of [ignore][crate::model::Vehicle::ignore].
4298    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4299        self.ignore = v.into();
4300        self
4301    }
4302
4303    /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
4304    #[deprecated]
4305    pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
4306    where
4307        T: std::iter::IntoIterator<Item = V>,
4308        V: std::convert::Into<i32>,
4309    {
4310        use std::iter::Iterator;
4311        self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
4312        self
4313    }
4314
4315    /// Sets the value of [capacities][crate::model::Vehicle::capacities].
4316    #[deprecated]
4317    pub fn set_capacities<T, V>(mut self, v: T) -> Self
4318    where
4319        T: std::iter::IntoIterator<Item = V>,
4320        V: std::convert::Into<crate::model::CapacityQuantity>,
4321    {
4322        use std::iter::Iterator;
4323        self.capacities = v.into_iter().map(|i| i.into()).collect();
4324        self
4325    }
4326
4327    /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
4328    #[deprecated]
4329    pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
4330    where
4331        T: std::iter::IntoIterator<Item = V>,
4332        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
4333    {
4334        use std::iter::Iterator;
4335        self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
4336        self
4337    }
4338
4339    /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
4340    #[deprecated]
4341    pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
4342    where
4343        T: std::iter::IntoIterator<Item = V>,
4344        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
4345    {
4346        use std::iter::Iterator;
4347        self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
4348        self
4349    }
4350}
4351
4352impl wkt::message::Message for Vehicle {
4353    fn typename() -> &'static str {
4354        "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
4355    }
4356}
4357
4358/// Defines additional types related to [Vehicle].
4359pub mod vehicle {
4360    #[allow(unused_imports)]
4361    use super::*;
4362
4363    /// Defines a load limit applying to a vehicle, e.g. "this truck may only
4364    /// carry up to 3500 kg". See
4365    /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
4366    ///
4367    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
4368    #[derive(Clone, Default, PartialEq)]
4369    #[non_exhaustive]
4370    pub struct LoadLimit {
4371        /// The maximum acceptable amount of load.
4372        pub max_load: std::option::Option<i64>,
4373
4374        /// A soft limit of the load. See
4375        /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
4376        ///
4377        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
4378        pub soft_max_load: i64,
4379
4380        /// If the load ever exceeds
4381        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
4382        /// along this vehicle's route, the following cost penalty applies (only once
4383        /// per vehicle): (load -
4384        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
4385        ///
4386        /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
4387        ///   add up and must be in the same unit as
4388        ///   [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
4389        ///
4390        /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
4391        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
4392        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
4393        pub cost_per_unit_above_soft_max: f64,
4394
4395        /// The acceptable load interval of the vehicle at the start of the route.
4396        pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
4397
4398        /// The acceptable load interval of the vehicle at the end of the route.
4399        pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
4400
4401        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4402    }
4403
4404    impl LoadLimit {
4405        pub fn new() -> Self {
4406            std::default::Default::default()
4407        }
4408
4409        /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
4410        pub fn set_max_load<T>(mut self, v: T) -> Self
4411        where
4412            T: std::convert::Into<i64>,
4413        {
4414            self.max_load = std::option::Option::Some(v.into());
4415            self
4416        }
4417
4418        /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
4419        pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
4420        where
4421            T: std::convert::Into<i64>,
4422        {
4423            self.max_load = v.map(|x| x.into());
4424            self
4425        }
4426
4427        /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
4428        pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4429            self.soft_max_load = v.into();
4430            self
4431        }
4432
4433        /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
4434        pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
4435            mut self,
4436            v: T,
4437        ) -> Self {
4438            self.cost_per_unit_above_soft_max = v.into();
4439            self
4440        }
4441
4442        /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
4443        pub fn set_start_load_interval<T>(mut self, v: T) -> Self
4444        where
4445            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
4446        {
4447            self.start_load_interval = std::option::Option::Some(v.into());
4448            self
4449        }
4450
4451        /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
4452        pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
4453        where
4454            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
4455        {
4456            self.start_load_interval = v.map(|x| x.into());
4457            self
4458        }
4459
4460        /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
4461        pub fn set_end_load_interval<T>(mut self, v: T) -> Self
4462        where
4463            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
4464        {
4465            self.end_load_interval = std::option::Option::Some(v.into());
4466            self
4467        }
4468
4469        /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
4470        pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
4471        where
4472            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
4473        {
4474            self.end_load_interval = v.map(|x| x.into());
4475            self
4476        }
4477    }
4478
4479    impl wkt::message::Message for LoadLimit {
4480        fn typename() -> &'static str {
4481            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
4482        }
4483    }
4484
4485    /// Defines additional types related to [LoadLimit].
4486    pub mod load_limit {
4487        #[allow(unused_imports)]
4488        use super::*;
4489
4490        /// Interval of acceptable load amounts.
4491        #[derive(Clone, Default, PartialEq)]
4492        #[non_exhaustive]
4493        pub struct Interval {
4494            /// A minimum acceptable load. Must be ≥ 0.
4495            /// If they're both specified,
4496            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
4497            /// be ≤
4498            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
4499            ///
4500            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
4501            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
4502            pub min: i64,
4503
4504            /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
4505            /// load is unrestricted by this message.
4506            /// If they're both specified,
4507            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
4508            /// be ≤
4509            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
4510            ///
4511            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
4512            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
4513            pub max: std::option::Option<i64>,
4514
4515            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4516        }
4517
4518        impl Interval {
4519            pub fn new() -> Self {
4520                std::default::Default::default()
4521            }
4522
4523            /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
4524            pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4525                self.min = v.into();
4526                self
4527            }
4528
4529            /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
4530            pub fn set_max<T>(mut self, v: T) -> Self
4531            where
4532                T: std::convert::Into<i64>,
4533            {
4534                self.max = std::option::Option::Some(v.into());
4535                self
4536            }
4537
4538            /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
4539            pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
4540            where
4541                T: std::convert::Into<i64>,
4542            {
4543                self.max = v.map(|x| x.into());
4544                self
4545            }
4546        }
4547
4548        impl wkt::message::Message for Interval {
4549            fn typename() -> &'static str {
4550                "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
4551            }
4552        }
4553    }
4554
4555    /// A limit defining a maximum duration of the route of a vehicle. It can be
4556    /// either hard or soft.
4557    ///
4558    /// When a soft limit field is defined, both the soft max threshold and its
4559    /// associated cost must be defined together.
4560    #[derive(Clone, Default, PartialEq)]
4561    #[non_exhaustive]
4562    pub struct DurationLimit {
4563        /// A hard limit constraining the duration to be at most max_duration.
4564        pub max_duration: std::option::Option<wkt::Duration>,
4565
4566        /// A soft limit not enforcing a maximum duration limit, but when violated
4567        /// makes the route incur a cost. This cost adds up to other costs defined in
4568        /// the model, with the same unit.
4569        ///
4570        /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
4571        /// also defined, `soft_max_duration` must be less than max_duration.
4572        pub soft_max_duration: std::option::Option<wkt::Duration>,
4573
4574        /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
4575        /// The additional cost is 0 if the duration is under the threshold,
4576        /// otherwise the cost depends on the duration as follows:
4577        ///
4578        /// ```norust
4579        ///   cost_per_hour_after_soft_max * (duration - soft_max_duration)
4580        /// ```
4581        ///
4582        /// The cost must be nonnegative.
4583        pub cost_per_hour_after_soft_max: std::option::Option<f64>,
4584
4585        /// A soft limit not enforcing a maximum duration limit, but when violated
4586        /// makes the route incur a cost, quadratic in the duration. This cost adds
4587        /// up to other costs defined in the model, with the same unit.
4588        ///
4589        /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
4590        /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
4591        /// less than `max_duration`, and the difference must be no larger than one
4592        /// day:
4593        ///
4594        /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
4595        pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
4596
4597        /// Cost per square hour incurred if the
4598        /// `quadratic_soft_max_duration` threshold is violated.
4599        ///
4600        /// The additional cost is 0 if the duration is under the threshold,
4601        /// otherwise the cost depends on the duration as follows:
4602        ///
4603        /// ```norust
4604        ///   cost_per_square_hour_after_quadratic_soft_max *
4605        ///   (duration - quadratic_soft_max_duration)^2
4606        /// ```
4607        ///
4608        /// The cost must be nonnegative.
4609        pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
4610
4611        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4612    }
4613
4614    impl DurationLimit {
4615        pub fn new() -> Self {
4616            std::default::Default::default()
4617        }
4618
4619        /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
4620        pub fn set_max_duration<T>(mut self, v: T) -> Self
4621        where
4622            T: std::convert::Into<wkt::Duration>,
4623        {
4624            self.max_duration = std::option::Option::Some(v.into());
4625            self
4626        }
4627
4628        /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
4629        pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
4630        where
4631            T: std::convert::Into<wkt::Duration>,
4632        {
4633            self.max_duration = v.map(|x| x.into());
4634            self
4635        }
4636
4637        /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
4638        pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
4639        where
4640            T: std::convert::Into<wkt::Duration>,
4641        {
4642            self.soft_max_duration = std::option::Option::Some(v.into());
4643            self
4644        }
4645
4646        /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
4647        pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
4648        where
4649            T: std::convert::Into<wkt::Duration>,
4650        {
4651            self.soft_max_duration = v.map(|x| x.into());
4652            self
4653        }
4654
4655        /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
4656        pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
4657        where
4658            T: std::convert::Into<f64>,
4659        {
4660            self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
4661            self
4662        }
4663
4664        /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
4665        pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
4666            mut self,
4667            v: std::option::Option<T>,
4668        ) -> Self
4669        where
4670            T: std::convert::Into<f64>,
4671        {
4672            self.cost_per_hour_after_soft_max = v.map(|x| x.into());
4673            self
4674        }
4675
4676        /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
4677        pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
4678        where
4679            T: std::convert::Into<wkt::Duration>,
4680        {
4681            self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
4682            self
4683        }
4684
4685        /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
4686        pub fn set_or_clear_quadratic_soft_max_duration<T>(
4687            mut self,
4688            v: std::option::Option<T>,
4689        ) -> Self
4690        where
4691            T: std::convert::Into<wkt::Duration>,
4692        {
4693            self.quadratic_soft_max_duration = v.map(|x| x.into());
4694            self
4695        }
4696
4697        /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
4698        pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
4699        where
4700            T: std::convert::Into<f64>,
4701        {
4702            self.cost_per_square_hour_after_quadratic_soft_max =
4703                std::option::Option::Some(v.into());
4704            self
4705        }
4706
4707        /// 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].
4708        pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
4709            mut self,
4710            v: std::option::Option<T>,
4711        ) -> Self
4712        where
4713            T: std::convert::Into<f64>,
4714        {
4715            self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
4716            self
4717        }
4718    }
4719
4720    impl wkt::message::Message for DurationLimit {
4721        fn typename() -> &'static str {
4722            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
4723        }
4724    }
4725
4726    /// Travel modes which can be used by vehicles.
4727    ///
4728    /// These should be a subset of the Google Maps Platform Routes Preferred API
4729    /// travel modes, see:
4730    /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
4731    ///
4732    /// # Working with unknown values
4733    ///
4734    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4735    /// additional enum variants at any time. Adding new variants is not considered
4736    /// a breaking change. Applications should write their code in anticipation of:
4737    ///
4738    /// - New values appearing in future releases of the client library, **and**
4739    /// - New values received dynamically, without application changes.
4740    ///
4741    /// Please consult the [Working with enums] section in the user guide for some
4742    /// guidelines.
4743    ///
4744    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4745    #[derive(Clone, Debug, PartialEq)]
4746    #[non_exhaustive]
4747    pub enum TravelMode {
4748        /// Unspecified travel mode, equivalent to `DRIVING`.
4749        Unspecified,
4750        /// Travel mode corresponding to driving directions (car, ...).
4751        Driving,
4752        /// Travel mode corresponding to walking directions.
4753        Walking,
4754        /// If set, the enum was initialized with an unknown value.
4755        ///
4756        /// Applications can examine the value using [TravelMode::value] or
4757        /// [TravelMode::name].
4758        UnknownValue(travel_mode::UnknownValue),
4759    }
4760
4761    #[doc(hidden)]
4762    pub mod travel_mode {
4763        #[allow(unused_imports)]
4764        use super::*;
4765        #[derive(Clone, Debug, PartialEq)]
4766        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4767    }
4768
4769    impl TravelMode {
4770        /// Gets the enum value.
4771        ///
4772        /// Returns `None` if the enum contains an unknown value deserialized from
4773        /// the string representation of enums.
4774        pub fn value(&self) -> std::option::Option<i32> {
4775            match self {
4776                Self::Unspecified => std::option::Option::Some(0),
4777                Self::Driving => std::option::Option::Some(1),
4778                Self::Walking => std::option::Option::Some(2),
4779                Self::UnknownValue(u) => u.0.value(),
4780            }
4781        }
4782
4783        /// Gets the enum value as a string.
4784        ///
4785        /// Returns `None` if the enum contains an unknown value deserialized from
4786        /// the integer representation of enums.
4787        pub fn name(&self) -> std::option::Option<&str> {
4788            match self {
4789                Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
4790                Self::Driving => std::option::Option::Some("DRIVING"),
4791                Self::Walking => std::option::Option::Some("WALKING"),
4792                Self::UnknownValue(u) => u.0.name(),
4793            }
4794        }
4795    }
4796
4797    impl std::default::Default for TravelMode {
4798        fn default() -> Self {
4799            use std::convert::From;
4800            Self::from(0)
4801        }
4802    }
4803
4804    impl std::fmt::Display for TravelMode {
4805        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4806            wkt::internal::display_enum(f, self.name(), self.value())
4807        }
4808    }
4809
4810    impl std::convert::From<i32> for TravelMode {
4811        fn from(value: i32) -> Self {
4812            match value {
4813                0 => Self::Unspecified,
4814                1 => Self::Driving,
4815                2 => Self::Walking,
4816                _ => Self::UnknownValue(travel_mode::UnknownValue(
4817                    wkt::internal::UnknownEnumValue::Integer(value),
4818                )),
4819            }
4820        }
4821    }
4822
4823    impl std::convert::From<&str> for TravelMode {
4824        fn from(value: &str) -> Self {
4825            use std::string::ToString;
4826            match value {
4827                "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
4828                "DRIVING" => Self::Driving,
4829                "WALKING" => Self::Walking,
4830                _ => Self::UnknownValue(travel_mode::UnknownValue(
4831                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4832                )),
4833            }
4834        }
4835    }
4836
4837    impl serde::ser::Serialize for TravelMode {
4838        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4839        where
4840            S: serde::Serializer,
4841        {
4842            match self {
4843                Self::Unspecified => serializer.serialize_i32(0),
4844                Self::Driving => serializer.serialize_i32(1),
4845                Self::Walking => serializer.serialize_i32(2),
4846                Self::UnknownValue(u) => u.0.serialize(serializer),
4847            }
4848        }
4849    }
4850
4851    impl<'de> serde::de::Deserialize<'de> for TravelMode {
4852        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4853        where
4854            D: serde::Deserializer<'de>,
4855        {
4856            deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
4857                ".google.cloud.optimization.v1.Vehicle.TravelMode",
4858            ))
4859        }
4860    }
4861
4862    /// Policy on how a vehicle can be unloaded. Applies only to shipments having
4863    /// both a pickup and a delivery.
4864    ///
4865    /// Other shipments are free to occur anywhere on the route independent of
4866    /// `unloading_policy`.
4867    ///
4868    /// # Working with unknown values
4869    ///
4870    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4871    /// additional enum variants at any time. Adding new variants is not considered
4872    /// a breaking change. Applications should write their code in anticipation of:
4873    ///
4874    /// - New values appearing in future releases of the client library, **and**
4875    /// - New values received dynamically, without application changes.
4876    ///
4877    /// Please consult the [Working with enums] section in the user guide for some
4878    /// guidelines.
4879    ///
4880    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4881    #[derive(Clone, Debug, PartialEq)]
4882    #[non_exhaustive]
4883    pub enum UnloadingPolicy {
4884        /// Unspecified unloading policy; deliveries must just occur after their
4885        /// corresponding pickups.
4886        Unspecified,
4887        /// Deliveries must occur in reverse order of pickups
4888        LastInFirstOut,
4889        /// Deliveries must occur in the same order as pickups
4890        FirstInFirstOut,
4891        /// If set, the enum was initialized with an unknown value.
4892        ///
4893        /// Applications can examine the value using [UnloadingPolicy::value] or
4894        /// [UnloadingPolicy::name].
4895        UnknownValue(unloading_policy::UnknownValue),
4896    }
4897
4898    #[doc(hidden)]
4899    pub mod unloading_policy {
4900        #[allow(unused_imports)]
4901        use super::*;
4902        #[derive(Clone, Debug, PartialEq)]
4903        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4904    }
4905
4906    impl UnloadingPolicy {
4907        /// Gets the enum value.
4908        ///
4909        /// Returns `None` if the enum contains an unknown value deserialized from
4910        /// the string representation of enums.
4911        pub fn value(&self) -> std::option::Option<i32> {
4912            match self {
4913                Self::Unspecified => std::option::Option::Some(0),
4914                Self::LastInFirstOut => std::option::Option::Some(1),
4915                Self::FirstInFirstOut => std::option::Option::Some(2),
4916                Self::UnknownValue(u) => u.0.value(),
4917            }
4918        }
4919
4920        /// Gets the enum value as a string.
4921        ///
4922        /// Returns `None` if the enum contains an unknown value deserialized from
4923        /// the integer representation of enums.
4924        pub fn name(&self) -> std::option::Option<&str> {
4925            match self {
4926                Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
4927                Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
4928                Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
4929                Self::UnknownValue(u) => u.0.name(),
4930            }
4931        }
4932    }
4933
4934    impl std::default::Default for UnloadingPolicy {
4935        fn default() -> Self {
4936            use std::convert::From;
4937            Self::from(0)
4938        }
4939    }
4940
4941    impl std::fmt::Display for UnloadingPolicy {
4942        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4943            wkt::internal::display_enum(f, self.name(), self.value())
4944        }
4945    }
4946
4947    impl std::convert::From<i32> for UnloadingPolicy {
4948        fn from(value: i32) -> Self {
4949            match value {
4950                0 => Self::Unspecified,
4951                1 => Self::LastInFirstOut,
4952                2 => Self::FirstInFirstOut,
4953                _ => Self::UnknownValue(unloading_policy::UnknownValue(
4954                    wkt::internal::UnknownEnumValue::Integer(value),
4955                )),
4956            }
4957        }
4958    }
4959
4960    impl std::convert::From<&str> for UnloadingPolicy {
4961        fn from(value: &str) -> Self {
4962            use std::string::ToString;
4963            match value {
4964                "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
4965                "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
4966                "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
4967                _ => Self::UnknownValue(unloading_policy::UnknownValue(
4968                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4969                )),
4970            }
4971        }
4972    }
4973
4974    impl serde::ser::Serialize for UnloadingPolicy {
4975        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4976        where
4977            S: serde::Serializer,
4978        {
4979            match self {
4980                Self::Unspecified => serializer.serialize_i32(0),
4981                Self::LastInFirstOut => serializer.serialize_i32(1),
4982                Self::FirstInFirstOut => serializer.serialize_i32(2),
4983                Self::UnknownValue(u) => u.0.serialize(serializer),
4984            }
4985        }
4986    }
4987
4988    impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
4989        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4990        where
4991            D: serde::Deserializer<'de>,
4992        {
4993            deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
4994                ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
4995            ))
4996        }
4997    }
4998}
4999
5000/// Time windows constrain the time of an event, such as the arrival time at a
5001/// visit, or the start and end time of a vehicle.
5002///
5003/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
5004/// and latest time of the event, such that `start_time <= event_time <=
5005/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
5006/// preference for the event to happen at or after `soft_start_time` by incurring
5007/// a cost proportional to how long before soft_start_time the event occurs. The
5008/// soft time window upper bound, `soft_end_time`, expresses a preference for the
5009/// event to happen at or before `soft_end_time` by incurring a cost proportional
5010/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
5011/// `soft_start_time` and `soft_end_time` should be within the global time limits
5012/// (see
5013/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
5014/// and
5015/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
5016/// and should respect:
5017///
5018/// ```norust
5019///   0 <= `start_time` <= `soft_start_time` <= `end_time` and
5020///   0 <= `start_time` <= `soft_end_time` <= `end_time`.
5021/// ```
5022///
5023/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
5024/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
5025#[derive(Clone, Default, PartialEq)]
5026#[non_exhaustive]
5027pub struct TimeWindow {
5028    /// The hard time window start time. If unspecified it will be set to
5029    /// `ShipmentModel.global_start_time`.
5030    pub start_time: std::option::Option<wkt::Timestamp>,
5031
5032    /// The hard time window end time. If unspecified it will be set to
5033    /// `ShipmentModel.global_end_time`.
5034    pub end_time: std::option::Option<wkt::Timestamp>,
5035
5036    /// The soft start time of the time window.
5037    pub soft_start_time: std::option::Option<wkt::Timestamp>,
5038
5039    /// The soft end time of the time window.
5040    pub soft_end_time: std::option::Option<wkt::Timestamp>,
5041
5042    /// A cost per hour added to other costs in the model if the event occurs
5043    /// before soft_start_time, computed as:
5044    ///
5045    /// ```norust
5046    ///    max(0, soft_start_time - t.seconds)
5047    ///                           * cost_per_hour_before_soft_start_time / 3600,
5048    /// t being the time of the event.
5049    /// ```
5050    ///
5051    /// This cost must be positive, and the field can only be set if
5052    /// soft_start_time has been set.
5053    pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
5054
5055    /// A cost per hour added to other costs in the model if the event occurs after
5056    /// `soft_end_time`, computed as:
5057    ///
5058    /// ```norust
5059    ///    max(0, t.seconds - soft_end_time.seconds)
5060    ///                     * cost_per_hour_after_soft_end_time / 3600,
5061    /// t being the time of the event.
5062    /// ```
5063    ///
5064    /// This cost must be positive, and the field can only be set if
5065    /// `soft_end_time` has been set.
5066    pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
5067
5068    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5069}
5070
5071impl TimeWindow {
5072    pub fn new() -> Self {
5073        std::default::Default::default()
5074    }
5075
5076    /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
5077    pub fn set_start_time<T>(mut self, v: T) -> Self
5078    where
5079        T: std::convert::Into<wkt::Timestamp>,
5080    {
5081        self.start_time = std::option::Option::Some(v.into());
5082        self
5083    }
5084
5085    /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
5086    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5087    where
5088        T: std::convert::Into<wkt::Timestamp>,
5089    {
5090        self.start_time = v.map(|x| x.into());
5091        self
5092    }
5093
5094    /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
5095    pub fn set_end_time<T>(mut self, v: T) -> Self
5096    where
5097        T: std::convert::Into<wkt::Timestamp>,
5098    {
5099        self.end_time = std::option::Option::Some(v.into());
5100        self
5101    }
5102
5103    /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
5104    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
5105    where
5106        T: std::convert::Into<wkt::Timestamp>,
5107    {
5108        self.end_time = v.map(|x| x.into());
5109        self
5110    }
5111
5112    /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
5113    pub fn set_soft_start_time<T>(mut self, v: T) -> Self
5114    where
5115        T: std::convert::Into<wkt::Timestamp>,
5116    {
5117        self.soft_start_time = std::option::Option::Some(v.into());
5118        self
5119    }
5120
5121    /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
5122    pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5123    where
5124        T: std::convert::Into<wkt::Timestamp>,
5125    {
5126        self.soft_start_time = v.map(|x| x.into());
5127        self
5128    }
5129
5130    /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
5131    pub fn set_soft_end_time<T>(mut self, v: T) -> Self
5132    where
5133        T: std::convert::Into<wkt::Timestamp>,
5134    {
5135        self.soft_end_time = std::option::Option::Some(v.into());
5136        self
5137    }
5138
5139    /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
5140    pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
5141    where
5142        T: std::convert::Into<wkt::Timestamp>,
5143    {
5144        self.soft_end_time = v.map(|x| x.into());
5145        self
5146    }
5147
5148    /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
5149    pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
5150    where
5151        T: std::convert::Into<f64>,
5152    {
5153        self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
5154        self
5155    }
5156
5157    /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
5158    pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
5159        mut self,
5160        v: std::option::Option<T>,
5161    ) -> Self
5162    where
5163        T: std::convert::Into<f64>,
5164    {
5165        self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
5166        self
5167    }
5168
5169    /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
5170    pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
5171    where
5172        T: std::convert::Into<f64>,
5173    {
5174        self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
5175        self
5176    }
5177
5178    /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
5179    pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
5180        mut self,
5181        v: std::option::Option<T>,
5182    ) -> Self
5183    where
5184        T: std::convert::Into<f64>,
5185    {
5186        self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
5187        self
5188    }
5189}
5190
5191impl wkt::message::Message for TimeWindow {
5192    fn typename() -> &'static str {
5193        "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
5194    }
5195}
5196
5197/// Deprecated: Use
5198/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
5199/// instead.
5200///
5201/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
5202#[derive(Clone, Default, PartialEq)]
5203#[non_exhaustive]
5204#[deprecated]
5205pub struct CapacityQuantity {
5206    pub r#type: std::string::String,
5207
5208    pub value: i64,
5209
5210    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5211}
5212
5213impl CapacityQuantity {
5214    pub fn new() -> Self {
5215        std::default::Default::default()
5216    }
5217
5218    /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
5219    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5220        self.r#type = v.into();
5221        self
5222    }
5223
5224    /// Sets the value of [value][crate::model::CapacityQuantity::value].
5225    pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5226        self.value = v.into();
5227        self
5228    }
5229}
5230
5231impl wkt::message::Message for CapacityQuantity {
5232    fn typename() -> &'static str {
5233        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
5234    }
5235}
5236
5237/// Deprecated: Use
5238/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
5239/// instead.
5240///
5241/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
5242#[derive(Clone, Default, PartialEq)]
5243#[non_exhaustive]
5244#[deprecated]
5245pub struct CapacityQuantityInterval {
5246    pub r#type: std::string::String,
5247
5248    pub min_value: std::option::Option<i64>,
5249
5250    pub max_value: std::option::Option<i64>,
5251
5252    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5253}
5254
5255impl CapacityQuantityInterval {
5256    pub fn new() -> Self {
5257        std::default::Default::default()
5258    }
5259
5260    /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
5261    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5262        self.r#type = v.into();
5263        self
5264    }
5265
5266    /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
5267    pub fn set_min_value<T>(mut self, v: T) -> Self
5268    where
5269        T: std::convert::Into<i64>,
5270    {
5271        self.min_value = std::option::Option::Some(v.into());
5272        self
5273    }
5274
5275    /// Sets or clears the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
5276    pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
5277    where
5278        T: std::convert::Into<i64>,
5279    {
5280        self.min_value = v.map(|x| x.into());
5281        self
5282    }
5283
5284    /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
5285    pub fn set_max_value<T>(mut self, v: T) -> Self
5286    where
5287        T: std::convert::Into<i64>,
5288    {
5289        self.max_value = std::option::Option::Some(v.into());
5290        self
5291    }
5292
5293    /// Sets or clears the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
5294    pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
5295    where
5296        T: std::convert::Into<i64>,
5297    {
5298        self.max_value = v.map(|x| x.into());
5299        self
5300    }
5301}
5302
5303impl wkt::message::Message for CapacityQuantityInterval {
5304    fn typename() -> &'static str {
5305        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
5306    }
5307}
5308
5309/// A limit defining a maximum distance which can be traveled. It can be either
5310/// hard or soft.
5311///
5312/// If a soft limit is defined, both `soft_max_meters` and
5313/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
5314#[derive(Clone, Default, PartialEq)]
5315#[non_exhaustive]
5316pub struct DistanceLimit {
5317    /// A hard limit constraining the distance to be at most max_meters. The limit
5318    /// must be nonnegative.
5319    pub max_meters: std::option::Option<i64>,
5320
5321    /// A soft limit not enforcing a maximum distance limit, but when violated
5322    /// results in a cost which adds up to other costs defined in the model,
5323    /// with the same unit.
5324    ///
5325    /// If defined soft_max_meters must be less than max_meters and must be
5326    /// nonnegative.
5327    pub soft_max_meters: std::option::Option<i64>,
5328
5329    /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
5330    /// formula:
5331    ///
5332    /// ```norust
5333    ///   min(distance_meters, soft_max_meters) / 1000.0 *
5334    ///   cost_per_kilometer_below_soft_max.
5335    /// ```
5336    ///
5337    /// This cost is not supported in `route_distance_limit`.
5338    pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
5339
5340    /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
5341    /// The additional cost is 0 if the distance is under the limit, otherwise the
5342    /// formula used to compute the cost is the following:
5343    ///
5344    /// ```norust
5345    ///   (distance_meters - soft_max_meters) / 1000.0 *
5346    ///   cost_per_kilometer_above_soft_max.
5347    /// ```
5348    ///
5349    /// The cost must be nonnegative.
5350    pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
5351
5352    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5353}
5354
5355impl DistanceLimit {
5356    pub fn new() -> Self {
5357        std::default::Default::default()
5358    }
5359
5360    /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
5361    pub fn set_max_meters<T>(mut self, v: T) -> Self
5362    where
5363        T: std::convert::Into<i64>,
5364    {
5365        self.max_meters = std::option::Option::Some(v.into());
5366        self
5367    }
5368
5369    /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
5370    pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
5371    where
5372        T: std::convert::Into<i64>,
5373    {
5374        self.max_meters = v.map(|x| x.into());
5375        self
5376    }
5377
5378    /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
5379    pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
5380    where
5381        T: std::convert::Into<i64>,
5382    {
5383        self.soft_max_meters = std::option::Option::Some(v.into());
5384        self
5385    }
5386
5387    /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
5388    pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
5389    where
5390        T: std::convert::Into<i64>,
5391    {
5392        self.soft_max_meters = v.map(|x| x.into());
5393        self
5394    }
5395
5396    /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
5397    pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
5398    where
5399        T: std::convert::Into<f64>,
5400    {
5401        self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
5402        self
5403    }
5404
5405    /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
5406    pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
5407        mut self,
5408        v: std::option::Option<T>,
5409    ) -> Self
5410    where
5411        T: std::convert::Into<f64>,
5412    {
5413        self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
5414        self
5415    }
5416
5417    /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
5418    pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
5419    where
5420        T: std::convert::Into<f64>,
5421    {
5422        self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
5423        self
5424    }
5425
5426    /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
5427    pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
5428        mut self,
5429        v: std::option::Option<T>,
5430    ) -> Self
5431    where
5432        T: std::convert::Into<f64>,
5433    {
5434        self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
5435        self
5436    }
5437}
5438
5439impl wkt::message::Message for DistanceLimit {
5440    fn typename() -> &'static str {
5441        "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
5442    }
5443}
5444
5445/// Specifies attributes of transitions between two consecutive visits on a
5446/// route. Several `TransitionAttributes` may apply to the same transition: in
5447/// that case, all extra costs add up and the strictest constraint or limit
5448/// applies (following natural "AND" semantics).
5449#[derive(Clone, Default, PartialEq)]
5450#[non_exhaustive]
5451pub struct TransitionAttributes {
5452    /// Tags defining the set of (src->dst) transitions these attributes apply to.
5453    ///
5454    /// A source visit or vehicle start matches iff its
5455    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
5456    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
5457    /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
5458    /// on which of these two fields is non-empty).
5459    ///
5460    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
5461    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
5462    pub src_tag: std::string::String,
5463
5464    /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
5465    /// non-empty.
5466    pub excluded_src_tag: std::string::String,
5467
5468    /// A destination visit or vehicle end matches iff its
5469    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
5470    /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
5471    /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
5472    /// which of these two fields is non-empty).
5473    ///
5474    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
5475    /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
5476    pub dst_tag: std::string::String,
5477
5478    /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
5479    /// non-empty.
5480    pub excluded_dst_tag: std::string::String,
5481
5482    /// Specifies a cost for performing this transition. This is in the same unit
5483    /// as all other costs in the model and must not be negative. It is applied on
5484    /// top of all other existing costs.
5485    pub cost: f64,
5486
5487    /// Specifies a cost per kilometer applied to the distance traveled while
5488    /// performing this transition. It adds up to any
5489    /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
5490    /// specified on vehicles.
5491    ///
5492    /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
5493    pub cost_per_kilometer: f64,
5494
5495    /// Specifies a limit on the distance traveled while performing this
5496    /// transition.
5497    ///
5498    /// As of 2021/06, only soft limits are supported.
5499    pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
5500
5501    /// Specifies a delay incurred when performing this transition.
5502    ///
5503    /// This delay always occurs *after* finishing the source visit and *before*
5504    /// starting the destination visit.
5505    pub delay: std::option::Option<wkt::Duration>,
5506
5507    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5508}
5509
5510impl TransitionAttributes {
5511    pub fn new() -> Self {
5512        std::default::Default::default()
5513    }
5514
5515    /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
5516    pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5517        self.src_tag = v.into();
5518        self
5519    }
5520
5521    /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
5522    pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
5523        mut self,
5524        v: T,
5525    ) -> Self {
5526        self.excluded_src_tag = v.into();
5527        self
5528    }
5529
5530    /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
5531    pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5532        self.dst_tag = v.into();
5533        self
5534    }
5535
5536    /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
5537    pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
5538        mut self,
5539        v: T,
5540    ) -> Self {
5541        self.excluded_dst_tag = v.into();
5542        self
5543    }
5544
5545    /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
5546    pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5547        self.cost = v.into();
5548        self
5549    }
5550
5551    /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
5552    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5553        self.cost_per_kilometer = v.into();
5554        self
5555    }
5556
5557    /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
5558    pub fn set_distance_limit<T>(mut self, v: T) -> Self
5559    where
5560        T: std::convert::Into<crate::model::DistanceLimit>,
5561    {
5562        self.distance_limit = std::option::Option::Some(v.into());
5563        self
5564    }
5565
5566    /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
5567    pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
5568    where
5569        T: std::convert::Into<crate::model::DistanceLimit>,
5570    {
5571        self.distance_limit = v.map(|x| x.into());
5572        self
5573    }
5574
5575    /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
5576    pub fn set_delay<T>(mut self, v: T) -> Self
5577    where
5578        T: std::convert::Into<wkt::Duration>,
5579    {
5580        self.delay = std::option::Option::Some(v.into());
5581        self
5582    }
5583
5584    /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
5585    pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
5586    where
5587        T: std::convert::Into<wkt::Duration>,
5588    {
5589        self.delay = v.map(|x| x.into());
5590        self
5591    }
5592}
5593
5594impl wkt::message::Message for TransitionAttributes {
5595    fn typename() -> &'static str {
5596        "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
5597    }
5598}
5599
5600/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
5601/// VisitRequests, and start and end locations of Vehicles.
5602#[derive(Clone, Default, PartialEq)]
5603#[non_exhaustive]
5604pub struct Waypoint {
5605    /// Indicates that the location of this waypoint is meant to have a preference
5606    /// for the vehicle to stop at a particular side of road. When you set this
5607    /// value, the route will pass through the location so that the vehicle can
5608    /// stop at the side of road that the location is biased towards from the
5609    /// center of the road. This option works only for the 'DRIVING' travel mode,
5610    /// and when the 'location_type' is set to 'location'.
5611    pub side_of_road: bool,
5612
5613    /// Different ways to represent a location.
5614    pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
5615
5616    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5617}
5618
5619impl Waypoint {
5620    pub fn new() -> Self {
5621        std::default::Default::default()
5622    }
5623
5624    /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
5625    pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5626        self.side_of_road = v.into();
5627        self
5628    }
5629
5630    /// Sets the value of [location_type][crate::model::Waypoint::location_type].
5631    ///
5632    /// Note that all the setters affecting `location_type` are mutually
5633    /// exclusive.
5634    pub fn set_location_type<
5635        T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
5636    >(
5637        mut self,
5638        v: T,
5639    ) -> Self {
5640        self.location_type = v.into();
5641        self
5642    }
5643
5644    /// The value of [location_type][crate::model::Waypoint::location_type]
5645    /// if it holds a `Location`, `None` if the field is not set or
5646    /// holds a different branch.
5647    pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
5648        #[allow(unreachable_patterns)]
5649        self.location_type.as_ref().and_then(|v| match v {
5650            crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
5651            _ => std::option::Option::None,
5652        })
5653    }
5654
5655    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
5656    /// to hold a `Location`.
5657    ///
5658    /// Note that all the setters affecting `location_type` are
5659    /// mutually exclusive.
5660    pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
5661        mut self,
5662        v: T,
5663    ) -> Self {
5664        self.location_type =
5665            std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
5666        self
5667    }
5668
5669    /// The value of [location_type][crate::model::Waypoint::location_type]
5670    /// if it holds a `PlaceId`, `None` if the field is not set or
5671    /// holds a different branch.
5672    pub fn place_id(&self) -> std::option::Option<&std::string::String> {
5673        #[allow(unreachable_patterns)]
5674        self.location_type.as_ref().and_then(|v| match v {
5675            crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
5676            _ => std::option::Option::None,
5677        })
5678    }
5679
5680    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
5681    /// to hold a `PlaceId`.
5682    ///
5683    /// Note that all the setters affecting `location_type` are
5684    /// mutually exclusive.
5685    pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5686        self.location_type =
5687            std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
5688        self
5689    }
5690}
5691
5692impl wkt::message::Message for Waypoint {
5693    fn typename() -> &'static str {
5694        "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
5695    }
5696}
5697
5698/// Defines additional types related to [Waypoint].
5699pub mod waypoint {
5700    #[allow(unused_imports)]
5701    use super::*;
5702
5703    /// Different ways to represent a location.
5704    #[derive(Clone, Debug, PartialEq)]
5705    #[non_exhaustive]
5706    pub enum LocationType {
5707        /// A point specified using geographic coordinates, including an optional
5708        /// heading.
5709        Location(std::boxed::Box<crate::model::Location>),
5710        /// The POI Place ID associated with the waypoint.
5711        PlaceId(std::string::String),
5712    }
5713}
5714
5715/// Encapsulates a location (a geographic point, and an optional heading).
5716#[derive(Clone, Default, PartialEq)]
5717#[non_exhaustive]
5718pub struct Location {
5719    /// The waypoint's geographic coordinates.
5720    pub lat_lng: std::option::Option<gtype::model::LatLng>,
5721
5722    /// The compass heading associated with the direction of the flow of traffic.
5723    /// This value is used to specify the side of the road to use for pickup and
5724    /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
5725    /// of due North, 90 specifies a heading of due East, etc.
5726    pub heading: std::option::Option<i32>,
5727
5728    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5729}
5730
5731impl Location {
5732    pub fn new() -> Self {
5733        std::default::Default::default()
5734    }
5735
5736    /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
5737    pub fn set_lat_lng<T>(mut self, v: T) -> Self
5738    where
5739        T: std::convert::Into<gtype::model::LatLng>,
5740    {
5741        self.lat_lng = std::option::Option::Some(v.into());
5742        self
5743    }
5744
5745    /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
5746    pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
5747    where
5748        T: std::convert::Into<gtype::model::LatLng>,
5749    {
5750        self.lat_lng = v.map(|x| x.into());
5751        self
5752    }
5753
5754    /// Sets the value of [heading][crate::model::Location::heading].
5755    pub fn set_heading<T>(mut self, v: T) -> Self
5756    where
5757        T: std::convert::Into<i32>,
5758    {
5759        self.heading = std::option::Option::Some(v.into());
5760        self
5761    }
5762
5763    /// Sets or clears the value of [heading][crate::model::Location::heading].
5764    pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
5765    where
5766        T: std::convert::Into<i32>,
5767    {
5768        self.heading = v.map(|x| x.into());
5769        self
5770    }
5771}
5772
5773impl wkt::message::Message for Location {
5774    fn typename() -> &'static str {
5775        "type.googleapis.com/google.cloud.optimization.v1.Location"
5776    }
5777}
5778
5779/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
5780/// is a contiguous period of time during which the vehicle remains idle at its
5781/// current position and cannot perform any visit. A break may occur:
5782///
5783/// * during the travel between two visits (which includes the time right
5784///   before or right after a visit, but not in the middle of a visit), in
5785///   which case it extends the corresponding transit time between the visits,
5786/// * or before the vehicle start (the vehicle may not start in the middle of
5787///   a break), in which case it does not affect the vehicle start time.
5788/// * or after the vehicle end (ditto, with the vehicle end time).
5789#[derive(Clone, Default, PartialEq)]
5790#[non_exhaustive]
5791pub struct BreakRule {
5792    /// Sequence of breaks. See the `BreakRequest` message.
5793    pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
5794
5795    /// Several `FrequencyConstraint` may apply. They must all be satisfied by
5796    /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
5797    pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
5798
5799    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5800}
5801
5802impl BreakRule {
5803    pub fn new() -> Self {
5804        std::default::Default::default()
5805    }
5806
5807    /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
5808    pub fn set_break_requests<T, V>(mut self, v: T) -> Self
5809    where
5810        T: std::iter::IntoIterator<Item = V>,
5811        V: std::convert::Into<crate::model::break_rule::BreakRequest>,
5812    {
5813        use std::iter::Iterator;
5814        self.break_requests = v.into_iter().map(|i| i.into()).collect();
5815        self
5816    }
5817
5818    /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
5819    pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
5820    where
5821        T: std::iter::IntoIterator<Item = V>,
5822        V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
5823    {
5824        use std::iter::Iterator;
5825        self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
5826        self
5827    }
5828}
5829
5830impl wkt::message::Message for BreakRule {
5831    fn typename() -> &'static str {
5832        "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
5833    }
5834}
5835
5836/// Defines additional types related to [BreakRule].
5837pub mod break_rule {
5838    #[allow(unused_imports)]
5839    use super::*;
5840
5841    /// The sequence of breaks (i.e. their number and order) that apply to each
5842    /// vehicle must be known beforehand. The repeated `BreakRequest`s define
5843    /// that sequence, in the order in which they must occur. Their time windows
5844    /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
5845    /// be compatible with the order (this is checked).
5846    #[derive(Clone, Default, PartialEq)]
5847    #[non_exhaustive]
5848    pub struct BreakRequest {
5849        /// Required. Lower bound (inclusive) on the start of the break.
5850        pub earliest_start_time: std::option::Option<wkt::Timestamp>,
5851
5852        /// Required. Upper bound (inclusive) on the start of the break.
5853        pub latest_start_time: std::option::Option<wkt::Timestamp>,
5854
5855        /// Required. Minimum duration of the break. Must be positive.
5856        pub min_duration: std::option::Option<wkt::Duration>,
5857
5858        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5859    }
5860
5861    impl BreakRequest {
5862        pub fn new() -> Self {
5863            std::default::Default::default()
5864        }
5865
5866        /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
5867        pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
5868        where
5869            T: std::convert::Into<wkt::Timestamp>,
5870        {
5871            self.earliest_start_time = std::option::Option::Some(v.into());
5872            self
5873        }
5874
5875        /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
5876        pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5877        where
5878            T: std::convert::Into<wkt::Timestamp>,
5879        {
5880            self.earliest_start_time = v.map(|x| x.into());
5881            self
5882        }
5883
5884        /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
5885        pub fn set_latest_start_time<T>(mut self, v: T) -> Self
5886        where
5887            T: std::convert::Into<wkt::Timestamp>,
5888        {
5889            self.latest_start_time = std::option::Option::Some(v.into());
5890            self
5891        }
5892
5893        /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
5894        pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5895        where
5896            T: std::convert::Into<wkt::Timestamp>,
5897        {
5898            self.latest_start_time = v.map(|x| x.into());
5899            self
5900        }
5901
5902        /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
5903        pub fn set_min_duration<T>(mut self, v: T) -> Self
5904        where
5905            T: std::convert::Into<wkt::Duration>,
5906        {
5907            self.min_duration = std::option::Option::Some(v.into());
5908            self
5909        }
5910
5911        /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
5912        pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
5913        where
5914            T: std::convert::Into<wkt::Duration>,
5915        {
5916            self.min_duration = v.map(|x| x.into());
5917            self
5918        }
5919    }
5920
5921    impl wkt::message::Message for BreakRequest {
5922        fn typename() -> &'static str {
5923            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
5924        }
5925    }
5926
5927    /// One may further constrain the frequency and duration of the breaks
5928    /// specified above, by enforcing a minimum break frequency, such as
5929    /// "There must be a break of at least 1 hour every 12 hours". Assuming that
5930    /// this can be interpreted as "Within any sliding time window of 12h, there
5931    /// must be at least one break of at least one hour", that example would
5932    /// translate to the following `FrequencyConstraint`:
5933    ///
5934    /// ```norust
5935    /// {
5936    ///    min_break_duration { seconds: 3600 }         # 1 hour.
5937    ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
5938    /// }
5939    /// ```
5940    ///
5941    /// The timing and duration of the breaks in the solution will respect all
5942    /// such constraints, in addition to the time windows and minimum durations
5943    /// already specified in the `BreakRequest`.
5944    ///
5945    /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
5946    /// For example, the following schedule honors the "1h every 12h" example:
5947    ///
5948    /// ```norust
5949    ///   04:00 vehicle start
5950    ///    .. performing travel and visits ..
5951    ///   09:00 1 hour break
5952    ///   10:00 end of the break
5953    ///    .. performing travel and visits ..
5954    ///   12:00 20-min lunch break
5955    ///   12:20 end of the break
5956    ///    .. performing travel and visits ..
5957    ///   21:00 1 hour break
5958    ///   22:00 end of the break
5959    ///    .. performing travel and visits ..
5960    ///   23:59 vehicle end
5961    /// ```
5962    #[derive(Clone, Default, PartialEq)]
5963    #[non_exhaustive]
5964    pub struct FrequencyConstraint {
5965        /// Required. Minimum break duration for this constraint. Nonnegative.
5966        /// See description of `FrequencyConstraint`.
5967        pub min_break_duration: std::option::Option<wkt::Duration>,
5968
5969        /// Required. Maximum allowed span of any interval of time in the route that
5970        /// does not include at least partially a break of `duration >=
5971        /// min_break_duration`. Must be positive.
5972        pub max_inter_break_duration: std::option::Option<wkt::Duration>,
5973
5974        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5975    }
5976
5977    impl FrequencyConstraint {
5978        pub fn new() -> Self {
5979            std::default::Default::default()
5980        }
5981
5982        /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
5983        pub fn set_min_break_duration<T>(mut self, v: T) -> Self
5984        where
5985            T: std::convert::Into<wkt::Duration>,
5986        {
5987            self.min_break_duration = std::option::Option::Some(v.into());
5988            self
5989        }
5990
5991        /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
5992        pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
5993        where
5994            T: std::convert::Into<wkt::Duration>,
5995        {
5996            self.min_break_duration = v.map(|x| x.into());
5997            self
5998        }
5999
6000        /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
6001        pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
6002        where
6003            T: std::convert::Into<wkt::Duration>,
6004        {
6005            self.max_inter_break_duration = std::option::Option::Some(v.into());
6006            self
6007        }
6008
6009        /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
6010        pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
6011        where
6012            T: std::convert::Into<wkt::Duration>,
6013        {
6014            self.max_inter_break_duration = v.map(|x| x.into());
6015            self
6016        }
6017    }
6018
6019    impl wkt::message::Message for FrequencyConstraint {
6020        fn typename() -> &'static str {
6021            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
6022        }
6023    }
6024}
6025
6026/// A vehicle's route can be decomposed, along the time axis, like this (we
6027/// assume there are n visits):
6028///
6029/// ```norust
6030///   |            |            |          |       |  T[2], |        |      |
6031///   | Transition |  Visit #0  |          |       |  V[2], |        |      |
6032///   |     #0     |    aka     |   T[1]   |  V[1] |  ...   | V[n-1] | T[n] |
6033///   |  aka T[0]  |    V[0]    |          |       | V[n-2],|        |      |
6034///   |            |            |          |       | T[n-1] |        |      |
6035///   ^            ^            ^          ^       ^        ^        ^      ^
6036/// vehicle    V[0].start   V[0].end     V[1].   V[1].    V[n].    V[n]. vehicle
6037///  start     (arrival)   (departure)   start   end      start    end     end
6038/// ```
6039///
6040/// Note that we make a difference between:
6041///
6042/// * "punctual events", such as the vehicle start and end and each visit's start
6043///   and end (aka arrival and departure). They happen at a given second.
6044/// * "time intervals", such as the visits themselves, and the transition between
6045///   visits. Though time intervals can sometimes have zero duration, i.e. start
6046///   and end at the same second, they often have a positive duration.
6047///
6048/// Invariants:
6049///
6050/// * If there are n visits, there are n+1 transitions.
6051/// * A visit is always surrounded by a transition before it (same index) and a
6052///   transition after it (index + 1).
6053/// * The vehicle start is always followed by transition #0.
6054/// * The vehicle end is always preceded by transition #n.
6055///
6056/// Zooming in, here is what happens during a `Transition` and a `Visit`:
6057///
6058/// ```norust
6059/// ---+-------------------------------------+-----------------------------+-->
6060///    |           TRANSITION[i]             |           VISIT[i]          |
6061///    |                                     |                             |
6062///    |  * TRAVEL: the vehicle moves from   |      PERFORM the visit:     |
6063///    |    VISIT[i-1].departure_location to |                             |
6064///    |    VISIT[i].arrival_location, which |  * Spend some time:         |
6065///    |    takes a given travel duration    |    the "visit duration".    |
6066///    |    and distance                     |                             |
6067///    |                                     |  * Load or unload           |
6068///    |  * BREAKS: the driver may have      |    some quantities from the |
6069///    |    breaks (e.g. lunch break).       |    vehicle: the "demand".   |
6070///    |                                     |                             |
6071///    |  * WAIT: the driver/vehicle does    |                             |
6072///    |    nothing. This can happen for     |                             |
6073///    |    many reasons, for example when   |                             |
6074///    |    the vehicle reaches the next     |                             |
6075///    |    event's destination before the   |                             |
6076///    |    start of its time window         |                             |
6077///    |                                     |                             |
6078///    |  * DELAY: *right before* the next   |                             |
6079///    |    arrival. E.g. the vehicle and/or |                             |
6080///    |    driver spends time unloading.    |                             |
6081///    |                                     |                             |
6082/// ---+-------------------------------------+-----------------------------+-->
6083///    ^                                     ^                             ^
6084/// V[i-1].end                           V[i].start                    V[i].end
6085/// ```
6086///
6087/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
6088/// during a transition.
6089///
6090/// * They don't overlap.
6091/// * The DELAY is unique and *must* be a contiguous period of time right
6092///   before the next visit (or vehicle end). Thus, it suffice to know the
6093///   delay duration to know its start and end time.
6094/// * The BREAKS are contiguous, non-overlapping periods of time. The
6095///   response specifies the start time and duration of each break.
6096/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
6097///   during this transition. Clients can assume that travel happens "as soon as
6098///   possible" and that "wait" fills the remaining time.
6099///
6100/// A (complex) example:
6101///
6102/// ```norust
6103///                                TRANSITION[i]
6104/// --++-----+-----------------------------------------------------------++-->
6105///   ||     |       |           |       |           |         |         ||
6106///   ||  T  |   B   |     T     |       |     B     |         |    D    ||
6107///   ||  r  |   r   |     r     |   W   |     r     |    W    |    e    ||
6108///   ||  a  |   e   |     a     |   a   |     e     |    a    |    l    ||
6109///   ||  v  |   a   |     v     |   i   |     a     |    i    |    a    ||
6110///   ||  e  |   k   |     e     |   t   |     k     |    t    |    y    ||
6111///   ||  l  |       |     l     |       |           |         |         ||
6112///   ||     |       |           |       |           |         |         ||
6113/// --++-----------------------------------------------------------------++-->
6114/// ```
6115#[derive(Clone, Default, PartialEq)]
6116#[non_exhaustive]
6117pub struct ShipmentRoute {
6118    /// Vehicle performing the route, identified by its index in the source
6119    /// `ShipmentModel`.
6120    pub vehicle_index: i32,
6121
6122    /// Label of the vehicle performing this route, equal to
6123    /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
6124    pub vehicle_label: std::string::String,
6125
6126    /// Time at which the vehicle starts its route.
6127    pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
6128
6129    /// Time at which the vehicle finishes its route.
6130    pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
6131
6132    /// Ordered sequence of visits representing a route.
6133    /// visits[i] is the i-th visit in the route.
6134    /// If this field is empty, the vehicle is considered as unused.
6135    pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
6136
6137    /// Ordered list of transitions for the route.
6138    pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
6139
6140    /// When
6141    /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
6142    /// is set to true, this field indicates that inconsistencies in route timings
6143    /// are predicted using traffic-based travel duration estimates. There may be
6144    /// insufficient time to complete traffic-adjusted travel, delays, and breaks
6145    /// between visits, before the first visit, or after the last visit, while
6146    /// still satisfying the visit and vehicle time windows. For example,
6147    ///
6148    /// ```norust
6149    ///   start_time(previous_visit) + duration(previous_visit) +
6150    ///   travel_duration(previous_visit, next_visit) > start_time(next_visit)
6151    /// ```
6152    ///
6153    /// Arrival at next_visit will likely happen later than its current
6154    /// time window due the increased estimate of travel time
6155    /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
6156    /// may be forced to overlap with a visit due to an increase in travel time
6157    /// estimates and visit or break time window restrictions.
6158    ///
6159    /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
6160    pub has_traffic_infeasibilities: bool,
6161
6162    /// The encoded polyline representation of the route.
6163    /// This field is only populated if
6164    /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
6165    /// is set to true.
6166    ///
6167    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
6168    pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
6169
6170    /// Breaks scheduled for the vehicle performing this route.
6171    /// The `breaks` sequence represents time intervals, each starting at the
6172    /// corresponding `start_time` and lasting `duration` seconds.
6173    pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
6174
6175    /// Duration, distance and load metrics for this route. The fields of
6176    /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
6177    /// summed over all
6178    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
6179    /// or
6180    /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
6181    /// depending on the context.
6182    ///
6183    /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
6184    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
6185    /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
6186    pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
6187
6188    /// Cost of the route, broken down by cost-related request fields.
6189    /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
6190    /// "model.shipments.pickups.cost", and the values are the total cost
6191    /// generated by the corresponding cost field, aggregated over the whole route.
6192    /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
6193    /// pickup costs over the route. All costs defined in the model are reported in
6194    /// detail here with the exception of costs related to TransitionAttributes
6195    /// that are only reported in an aggregated way as of 2022/01.
6196    pub route_costs: std::collections::HashMap<std::string::String, f64>,
6197
6198    /// Total cost of the route. The sum of all costs in the cost map.
6199    pub route_total_cost: f64,
6200
6201    /// Deprecated: Use
6202    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
6203    /// instead. Vehicle loads upon arrival at its end location, for each type
6204    /// specified in
6205    /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
6206    /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
6207    /// loads for quantity types unconstrained by intervals and that don't have any
6208    /// non-zero demand on the route.
6209    ///
6210    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
6211    /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
6212    #[deprecated]
6213    pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
6214
6215    /// Deprecated: Use
6216    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
6217    /// instead. Ordered list of travel steps for the route.
6218    ///
6219    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
6220    #[deprecated]
6221    pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
6222
6223    /// Deprecated: No longer used.
6224    /// This field will only be populated at the
6225    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
6226    /// level.
6227    ///
6228    /// This field is the extra detour time due to the shipments visited on the
6229    /// route.
6230    ///
6231    /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
6232    /// from the vehicle's start_location to its `end_location`.
6233    ///
6234    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
6235    #[deprecated]
6236    pub vehicle_detour: std::option::Option<wkt::Duration>,
6237
6238    /// Deprecated: Delay occurring before the vehicle end. See
6239    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
6240    ///
6241    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
6242    #[deprecated]
6243    pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
6244
6245    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6246}
6247
6248impl ShipmentRoute {
6249    pub fn new() -> Self {
6250        std::default::Default::default()
6251    }
6252
6253    /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
6254    pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
6255        self.vehicle_index = v.into();
6256        self
6257    }
6258
6259    /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
6260    pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6261        self.vehicle_label = v.into();
6262        self
6263    }
6264
6265    /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
6266    pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
6267    where
6268        T: std::convert::Into<wkt::Timestamp>,
6269    {
6270        self.vehicle_start_time = std::option::Option::Some(v.into());
6271        self
6272    }
6273
6274    /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
6275    pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6276    where
6277        T: std::convert::Into<wkt::Timestamp>,
6278    {
6279        self.vehicle_start_time = v.map(|x| x.into());
6280        self
6281    }
6282
6283    /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
6284    pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
6285    where
6286        T: std::convert::Into<wkt::Timestamp>,
6287    {
6288        self.vehicle_end_time = std::option::Option::Some(v.into());
6289        self
6290    }
6291
6292    /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
6293    pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6294    where
6295        T: std::convert::Into<wkt::Timestamp>,
6296    {
6297        self.vehicle_end_time = v.map(|x| x.into());
6298        self
6299    }
6300
6301    /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
6302    pub fn set_visits<T, V>(mut self, v: T) -> Self
6303    where
6304        T: std::iter::IntoIterator<Item = V>,
6305        V: std::convert::Into<crate::model::shipment_route::Visit>,
6306    {
6307        use std::iter::Iterator;
6308        self.visits = v.into_iter().map(|i| i.into()).collect();
6309        self
6310    }
6311
6312    /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
6313    pub fn set_transitions<T, V>(mut self, v: T) -> Self
6314    where
6315        T: std::iter::IntoIterator<Item = V>,
6316        V: std::convert::Into<crate::model::shipment_route::Transition>,
6317    {
6318        use std::iter::Iterator;
6319        self.transitions = v.into_iter().map(|i| i.into()).collect();
6320        self
6321    }
6322
6323    /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
6324    pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6325        self.has_traffic_infeasibilities = v.into();
6326        self
6327    }
6328
6329    /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
6330    pub fn set_route_polyline<T>(mut self, v: T) -> Self
6331    where
6332        T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
6333    {
6334        self.route_polyline = std::option::Option::Some(v.into());
6335        self
6336    }
6337
6338    /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
6339    pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
6340    where
6341        T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
6342    {
6343        self.route_polyline = v.map(|x| x.into());
6344        self
6345    }
6346
6347    /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
6348    pub fn set_breaks<T, V>(mut self, v: T) -> Self
6349    where
6350        T: std::iter::IntoIterator<Item = V>,
6351        V: std::convert::Into<crate::model::shipment_route::Break>,
6352    {
6353        use std::iter::Iterator;
6354        self.breaks = v.into_iter().map(|i| i.into()).collect();
6355        self
6356    }
6357
6358    /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
6359    pub fn set_metrics<T>(mut self, v: T) -> Self
6360    where
6361        T: std::convert::Into<crate::model::AggregatedMetrics>,
6362    {
6363        self.metrics = std::option::Option::Some(v.into());
6364        self
6365    }
6366
6367    /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
6368    pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
6369    where
6370        T: std::convert::Into<crate::model::AggregatedMetrics>,
6371    {
6372        self.metrics = v.map(|x| x.into());
6373        self
6374    }
6375
6376    /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
6377    pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
6378    where
6379        T: std::iter::IntoIterator<Item = (K, V)>,
6380        K: std::convert::Into<std::string::String>,
6381        V: std::convert::Into<f64>,
6382    {
6383        use std::iter::Iterator;
6384        self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6385        self
6386    }
6387
6388    /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
6389    pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
6390        self.route_total_cost = v.into();
6391        self
6392    }
6393
6394    /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
6395    #[deprecated]
6396    pub fn set_end_loads<T, V>(mut self, v: T) -> Self
6397    where
6398        T: std::iter::IntoIterator<Item = V>,
6399        V: std::convert::Into<crate::model::CapacityQuantity>,
6400    {
6401        use std::iter::Iterator;
6402        self.end_loads = v.into_iter().map(|i| i.into()).collect();
6403        self
6404    }
6405
6406    /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
6407    #[deprecated]
6408    pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
6409    where
6410        T: std::iter::IntoIterator<Item = V>,
6411        V: std::convert::Into<crate::model::shipment_route::TravelStep>,
6412    {
6413        use std::iter::Iterator;
6414        self.travel_steps = v.into_iter().map(|i| i.into()).collect();
6415        self
6416    }
6417
6418    /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
6419    #[deprecated]
6420    pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
6421    where
6422        T: std::convert::Into<wkt::Duration>,
6423    {
6424        self.vehicle_detour = std::option::Option::Some(v.into());
6425        self
6426    }
6427
6428    /// Sets or clears the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
6429    #[deprecated]
6430    pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
6431    where
6432        T: std::convert::Into<wkt::Duration>,
6433    {
6434        self.vehicle_detour = v.map(|x| x.into());
6435        self
6436    }
6437
6438    /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
6439    #[deprecated]
6440    pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
6441    where
6442        T: std::convert::Into<crate::model::shipment_route::Delay>,
6443    {
6444        self.delay_before_vehicle_end = std::option::Option::Some(v.into());
6445        self
6446    }
6447
6448    /// Sets or clears the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
6449    #[deprecated]
6450    pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
6451    where
6452        T: std::convert::Into<crate::model::shipment_route::Delay>,
6453    {
6454        self.delay_before_vehicle_end = v.map(|x| x.into());
6455        self
6456    }
6457}
6458
6459impl wkt::message::Message for ShipmentRoute {
6460    fn typename() -> &'static str {
6461        "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
6462    }
6463}
6464
6465/// Defines additional types related to [ShipmentRoute].
6466pub mod shipment_route {
6467    #[allow(unused_imports)]
6468    use super::*;
6469
6470    /// Deprecated: Use
6471    /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
6472    /// instead. Time interval spent on the route resulting from a
6473    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
6474    ///
6475    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
6476    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
6477    #[derive(Clone, Default, PartialEq)]
6478    #[non_exhaustive]
6479    #[deprecated]
6480    pub struct Delay {
6481        /// Start of the delay.
6482        pub start_time: std::option::Option<wkt::Timestamp>,
6483
6484        /// Duration of the delay.
6485        pub duration: std::option::Option<wkt::Duration>,
6486
6487        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6488    }
6489
6490    impl Delay {
6491        pub fn new() -> Self {
6492            std::default::Default::default()
6493        }
6494
6495        /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
6496        pub fn set_start_time<T>(mut self, v: T) -> Self
6497        where
6498            T: std::convert::Into<wkt::Timestamp>,
6499        {
6500            self.start_time = std::option::Option::Some(v.into());
6501            self
6502        }
6503
6504        /// Sets or clears the value of [start_time][crate::model::shipment_route::Delay::start_time].
6505        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6506        where
6507            T: std::convert::Into<wkt::Timestamp>,
6508        {
6509            self.start_time = v.map(|x| x.into());
6510            self
6511        }
6512
6513        /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
6514        pub fn set_duration<T>(mut self, v: T) -> Self
6515        where
6516            T: std::convert::Into<wkt::Duration>,
6517        {
6518            self.duration = std::option::Option::Some(v.into());
6519            self
6520        }
6521
6522        /// Sets or clears the value of [duration][crate::model::shipment_route::Delay::duration].
6523        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
6524        where
6525            T: std::convert::Into<wkt::Duration>,
6526        {
6527            self.duration = v.map(|x| x.into());
6528            self
6529        }
6530    }
6531
6532    impl wkt::message::Message for Delay {
6533        fn typename() -> &'static str {
6534            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
6535        }
6536    }
6537
6538    /// A visit performed during a route. This visit corresponds to a pickup or a
6539    /// delivery of a `Shipment`.
6540    #[derive(Clone, Default, PartialEq)]
6541    #[non_exhaustive]
6542    pub struct Visit {
6543        /// Index of the `shipments` field in the source
6544        /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
6545        ///
6546        /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
6547        pub shipment_index: i32,
6548
6549        /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
6550        /// corresponds to a delivery.
6551        pub is_pickup: bool,
6552
6553        /// Index of `VisitRequest` in either the pickup or delivery field of the
6554        /// `Shipment` (see `is_pickup`).
6555        pub visit_request_index: i32,
6556
6557        /// Time at which the visit starts. Note that the vehicle may arrive earlier
6558        /// than this at the visit location. Times are consistent with the
6559        /// `ShipmentModel`.
6560        pub start_time: std::option::Option<wkt::Timestamp>,
6561
6562        /// Total visit load demand as the sum of the shipment and the visit request
6563        /// `load_demands`. The values are negative if the visit is a delivery.
6564        /// Demands are reported for the same types as the
6565        /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
6566        /// (see this field).
6567        ///
6568        /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
6569        pub load_demands:
6570            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
6571
6572        /// Extra detour time due to the shipments visited on the route before the
6573        /// visit and to the potential waiting time induced by time windows.
6574        /// If the visit is a delivery, the detour is computed from the corresponding
6575        /// pickup visit and is equal to:
6576        ///
6577        /// ```norust
6578        /// start_time(delivery) - start_time(pickup)
6579        /// - (duration(pickup) + travel duration from the pickup location
6580        /// to the delivery location).
6581        /// ```
6582        ///
6583        /// Otherwise, it is computed from the vehicle `start_location` and is equal
6584        /// to:
6585        ///
6586        /// ```norust
6587        /// start_time - vehicle_start_time - travel duration from
6588        /// the vehicle's `start_location` to the visit.
6589        /// ```
6590        pub detour: std::option::Option<wkt::Duration>,
6591
6592        /// Copy of the corresponding `Shipment.label`, if specified in the
6593        /// `Shipment`.
6594        pub shipment_label: std::string::String,
6595
6596        /// Copy of the corresponding
6597        /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
6598        /// if specified in the `VisitRequest`.
6599        ///
6600        /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
6601        pub visit_label: std::string::String,
6602
6603        /// Deprecated: Use
6604        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
6605        /// instead. Vehicle loads upon arrival at the visit location, for each type
6606        /// specified in
6607        /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
6608        /// `start_load_intervals`, `end_load_intervals` or `demands`.
6609        ///
6610        /// Exception: we omit loads for quantity types unconstrained by intervals
6611        /// and that don't have any non-zero demand on the route.
6612        ///
6613        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
6614        /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
6615        #[deprecated]
6616        pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
6617
6618        /// Deprecated: Use
6619        /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
6620        /// instead. Delay occurring before the visit starts.
6621        ///
6622        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
6623        #[deprecated]
6624        pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
6625
6626        /// Deprecated: Use
6627        /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
6628        /// instead.
6629        ///
6630        /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
6631        #[deprecated]
6632        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
6633
6634        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6635    }
6636
6637    impl Visit {
6638        pub fn new() -> Self {
6639            std::default::Default::default()
6640        }
6641
6642        /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
6643        pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
6644            self.shipment_index = v.into();
6645            self
6646        }
6647
6648        /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
6649        pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6650            self.is_pickup = v.into();
6651            self
6652        }
6653
6654        /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
6655        pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
6656            self.visit_request_index = v.into();
6657            self
6658        }
6659
6660        /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
6661        pub fn set_start_time<T>(mut self, v: T) -> Self
6662        where
6663            T: std::convert::Into<wkt::Timestamp>,
6664        {
6665            self.start_time = std::option::Option::Some(v.into());
6666            self
6667        }
6668
6669        /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
6670        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6671        where
6672            T: std::convert::Into<wkt::Timestamp>,
6673        {
6674            self.start_time = v.map(|x| x.into());
6675            self
6676        }
6677
6678        /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
6679        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
6680        where
6681            T: std::iter::IntoIterator<Item = (K, V)>,
6682            K: std::convert::Into<std::string::String>,
6683            V: std::convert::Into<crate::model::shipment::Load>,
6684        {
6685            use std::iter::Iterator;
6686            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6687            self
6688        }
6689
6690        /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
6691        pub fn set_detour<T>(mut self, v: T) -> Self
6692        where
6693            T: std::convert::Into<wkt::Duration>,
6694        {
6695            self.detour = std::option::Option::Some(v.into());
6696            self
6697        }
6698
6699        /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
6700        pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
6701        where
6702            T: std::convert::Into<wkt::Duration>,
6703        {
6704            self.detour = v.map(|x| x.into());
6705            self
6706        }
6707
6708        /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
6709        pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
6710            mut self,
6711            v: T,
6712        ) -> Self {
6713            self.shipment_label = v.into();
6714            self
6715        }
6716
6717        /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
6718        pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6719            self.visit_label = v.into();
6720            self
6721        }
6722
6723        /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
6724        #[deprecated]
6725        pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
6726        where
6727            T: std::iter::IntoIterator<Item = V>,
6728            V: std::convert::Into<crate::model::CapacityQuantity>,
6729        {
6730            use std::iter::Iterator;
6731            self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
6732            self
6733        }
6734
6735        /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
6736        #[deprecated]
6737        pub fn set_delay_before_start<T>(mut self, v: T) -> Self
6738        where
6739            T: std::convert::Into<crate::model::shipment_route::Delay>,
6740        {
6741            self.delay_before_start = std::option::Option::Some(v.into());
6742            self
6743        }
6744
6745        /// Sets or clears the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
6746        #[deprecated]
6747        pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
6748        where
6749            T: std::convert::Into<crate::model::shipment_route::Delay>,
6750        {
6751            self.delay_before_start = v.map(|x| x.into());
6752            self
6753        }
6754
6755        /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
6756        #[deprecated]
6757        pub fn set_demands<T, V>(mut self, v: T) -> Self
6758        where
6759            T: std::iter::IntoIterator<Item = V>,
6760            V: std::convert::Into<crate::model::CapacityQuantity>,
6761        {
6762            use std::iter::Iterator;
6763            self.demands = v.into_iter().map(|i| i.into()).collect();
6764            self
6765        }
6766    }
6767
6768    impl wkt::message::Message for Visit {
6769        fn typename() -> &'static str {
6770            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
6771        }
6772    }
6773
6774    /// Transition between two events on the route. See the description of
6775    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
6776    ///
6777    /// If the vehicle does not have a `start_location` and/or `end_location`, the
6778    /// corresponding travel metrics are 0.
6779    ///
6780    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
6781    #[derive(Clone, Default, PartialEq)]
6782    #[non_exhaustive]
6783    pub struct Transition {
6784        /// Travel duration during this transition.
6785        pub travel_duration: std::option::Option<wkt::Duration>,
6786
6787        /// Distance traveled during the transition.
6788        pub travel_distance_meters: f64,
6789
6790        /// When traffic is requested via
6791        /// [OptimizeToursRequest.consider_road_traffic]
6792        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
6793        /// and the traffic info couldn't be retrieved for a `Transition`, this
6794        /// boolean is set to true. This may be temporary (rare hiccup in the
6795        /// realtime traffic servers) or permanent (no data for this location).
6796        pub traffic_info_unavailable: bool,
6797
6798        /// Sum of the delay durations applied to this transition. If any, the delay
6799        /// starts exactly `delay_duration` seconds before the next event (visit or
6800        /// vehicle end). See
6801        /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
6802        ///
6803        /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
6804        pub delay_duration: std::option::Option<wkt::Duration>,
6805
6806        /// Sum of the duration of the breaks occurring during this transition, if
6807        /// any. Details about each break's start time and duration are stored in
6808        /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
6809        ///
6810        /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
6811        pub break_duration: std::option::Option<wkt::Duration>,
6812
6813        /// Time spent waiting during this transition. Wait duration corresponds to
6814        /// idle time and does not include break time. Also note that this wait time
6815        /// may be split into several non-contiguous intervals.
6816        pub wait_duration: std::option::Option<wkt::Duration>,
6817
6818        /// Total duration of the transition, provided for convenience. It is equal
6819        /// to:
6820        ///
6821        /// * next visit `start_time` (or `vehicle_end_time` if this is the last
6822        ///   transition) - this transition's `start_time`;
6823        /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
6824        ///   additionally holds: `total_duration = travel_duration + delay_duration
6825        ///
6826        /// + break_duration + wait_duration`.
6827        pub total_duration: std::option::Option<wkt::Duration>,
6828
6829        /// Start time of this transition.
6830        pub start_time: std::option::Option<wkt::Timestamp>,
6831
6832        /// The encoded polyline representation of the route followed during the
6833        /// transition.
6834        /// This field is only populated if [populate_transition_polylines]
6835        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
6836        /// is set to true.
6837        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
6838
6839        /// Vehicle loads during this transition, for each type that either appears
6840        /// in this vehicle's
6841        /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
6842        /// or that have non-zero
6843        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
6844        /// on some shipment performed on this route.
6845        ///
6846        /// The loads during the first transition are the starting loads of the
6847        /// vehicle route. Then, after each visit, the visit's `load_demands` are
6848        /// either added or subtracted to get the next transition's loads, depending
6849        /// on whether the visit was a pickup or a delivery.
6850        ///
6851        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
6852        /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
6853        pub vehicle_loads: std::collections::HashMap<
6854            std::string::String,
6855            crate::model::shipment_route::VehicleLoad,
6856        >,
6857
6858        /// Deprecated: Use
6859        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
6860        /// instead.
6861        ///
6862        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
6863        #[deprecated]
6864        pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
6865
6866        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6867    }
6868
6869    impl Transition {
6870        pub fn new() -> Self {
6871            std::default::Default::default()
6872        }
6873
6874        /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
6875        pub fn set_travel_duration<T>(mut self, v: T) -> Self
6876        where
6877            T: std::convert::Into<wkt::Duration>,
6878        {
6879            self.travel_duration = std::option::Option::Some(v.into());
6880            self
6881        }
6882
6883        /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
6884        pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
6885        where
6886            T: std::convert::Into<wkt::Duration>,
6887        {
6888            self.travel_duration = v.map(|x| x.into());
6889            self
6890        }
6891
6892        /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
6893        pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
6894            self.travel_distance_meters = v.into();
6895            self
6896        }
6897
6898        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
6899        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6900            self.traffic_info_unavailable = v.into();
6901            self
6902        }
6903
6904        /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
6905        pub fn set_delay_duration<T>(mut self, v: T) -> Self
6906        where
6907            T: std::convert::Into<wkt::Duration>,
6908        {
6909            self.delay_duration = std::option::Option::Some(v.into());
6910            self
6911        }
6912
6913        /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
6914        pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
6915        where
6916            T: std::convert::Into<wkt::Duration>,
6917        {
6918            self.delay_duration = v.map(|x| x.into());
6919            self
6920        }
6921
6922        /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
6923        pub fn set_break_duration<T>(mut self, v: T) -> Self
6924        where
6925            T: std::convert::Into<wkt::Duration>,
6926        {
6927            self.break_duration = std::option::Option::Some(v.into());
6928            self
6929        }
6930
6931        /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
6932        pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
6933        where
6934            T: std::convert::Into<wkt::Duration>,
6935        {
6936            self.break_duration = v.map(|x| x.into());
6937            self
6938        }
6939
6940        /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
6941        pub fn set_wait_duration<T>(mut self, v: T) -> Self
6942        where
6943            T: std::convert::Into<wkt::Duration>,
6944        {
6945            self.wait_duration = std::option::Option::Some(v.into());
6946            self
6947        }
6948
6949        /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
6950        pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
6951        where
6952            T: std::convert::Into<wkt::Duration>,
6953        {
6954            self.wait_duration = v.map(|x| x.into());
6955            self
6956        }
6957
6958        /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
6959        pub fn set_total_duration<T>(mut self, v: T) -> Self
6960        where
6961            T: std::convert::Into<wkt::Duration>,
6962        {
6963            self.total_duration = std::option::Option::Some(v.into());
6964            self
6965        }
6966
6967        /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
6968        pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
6969        where
6970            T: std::convert::Into<wkt::Duration>,
6971        {
6972            self.total_duration = v.map(|x| x.into());
6973            self
6974        }
6975
6976        /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
6977        pub fn set_start_time<T>(mut self, v: T) -> Self
6978        where
6979            T: std::convert::Into<wkt::Timestamp>,
6980        {
6981            self.start_time = std::option::Option::Some(v.into());
6982            self
6983        }
6984
6985        /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
6986        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6987        where
6988            T: std::convert::Into<wkt::Timestamp>,
6989        {
6990            self.start_time = v.map(|x| x.into());
6991            self
6992        }
6993
6994        /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
6995        pub fn set_route_polyline<T>(mut self, v: T) -> Self
6996        where
6997            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
6998        {
6999            self.route_polyline = std::option::Option::Some(v.into());
7000            self
7001        }
7002
7003        /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
7004        pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
7005        where
7006            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
7007        {
7008            self.route_polyline = v.map(|x| x.into());
7009            self
7010        }
7011
7012        /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
7013        pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
7014        where
7015            T: std::iter::IntoIterator<Item = (K, V)>,
7016            K: std::convert::Into<std::string::String>,
7017            V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
7018        {
7019            use std::iter::Iterator;
7020            self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7021            self
7022        }
7023
7024        /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
7025        #[deprecated]
7026        pub fn set_loads<T, V>(mut self, v: T) -> Self
7027        where
7028            T: std::iter::IntoIterator<Item = V>,
7029            V: std::convert::Into<crate::model::CapacityQuantity>,
7030        {
7031            use std::iter::Iterator;
7032            self.loads = v.into_iter().map(|i| i.into()).collect();
7033            self
7034        }
7035    }
7036
7037    impl wkt::message::Message for Transition {
7038        fn typename() -> &'static str {
7039            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
7040        }
7041    }
7042
7043    /// Reports the actual load of the vehicle at some point along the route,
7044    /// for a given type (see
7045    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
7046    ///
7047    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
7048    #[derive(Clone, Default, PartialEq)]
7049    #[non_exhaustive]
7050    pub struct VehicleLoad {
7051        /// The amount of load on the vehicle, for the given type. The unit of load
7052        /// is usually indicated by the type. See
7053        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
7054        ///
7055        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
7056        pub amount: i64,
7057
7058        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7059    }
7060
7061    impl VehicleLoad {
7062        pub fn new() -> Self {
7063            std::default::Default::default()
7064        }
7065
7066        /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
7067        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7068            self.amount = v.into();
7069            self
7070        }
7071    }
7072
7073    impl wkt::message::Message for VehicleLoad {
7074        fn typename() -> &'static str {
7075            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
7076        }
7077    }
7078
7079    /// The encoded representation of a polyline. More information on polyline
7080    /// encoding can be found here:
7081    /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
7082    /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
7083    #[derive(Clone, Default, PartialEq)]
7084    #[non_exhaustive]
7085    pub struct EncodedPolyline {
7086        /// String representing encoded points of the polyline.
7087        pub points: std::string::String,
7088
7089        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7090    }
7091
7092    impl EncodedPolyline {
7093        pub fn new() -> Self {
7094            std::default::Default::default()
7095        }
7096
7097        /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
7098        pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7099            self.points = v.into();
7100            self
7101        }
7102    }
7103
7104    impl wkt::message::Message for EncodedPolyline {
7105        fn typename() -> &'static str {
7106            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
7107        }
7108    }
7109
7110    /// Data representing the execution of a break.
7111    #[derive(Clone, Default, PartialEq)]
7112    #[non_exhaustive]
7113    pub struct Break {
7114        /// Start time of a break.
7115        pub start_time: std::option::Option<wkt::Timestamp>,
7116
7117        /// Duration of a break.
7118        pub duration: std::option::Option<wkt::Duration>,
7119
7120        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7121    }
7122
7123    impl Break {
7124        pub fn new() -> Self {
7125            std::default::Default::default()
7126        }
7127
7128        /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
7129        pub fn set_start_time<T>(mut self, v: T) -> Self
7130        where
7131            T: std::convert::Into<wkt::Timestamp>,
7132        {
7133            self.start_time = std::option::Option::Some(v.into());
7134            self
7135        }
7136
7137        /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
7138        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7139        where
7140            T: std::convert::Into<wkt::Timestamp>,
7141        {
7142            self.start_time = v.map(|x| x.into());
7143            self
7144        }
7145
7146        /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
7147        pub fn set_duration<T>(mut self, v: T) -> Self
7148        where
7149            T: std::convert::Into<wkt::Duration>,
7150        {
7151            self.duration = std::option::Option::Some(v.into());
7152            self
7153        }
7154
7155        /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
7156        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
7157        where
7158            T: std::convert::Into<wkt::Duration>,
7159        {
7160            self.duration = v.map(|x| x.into());
7161            self
7162        }
7163    }
7164
7165    impl wkt::message::Message for Break {
7166        fn typename() -> &'static str {
7167            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
7168        }
7169    }
7170
7171    /// Deprecated: Use
7172    /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
7173    /// instead. Travel between each visit along the route: from the vehicle's
7174    /// `start_location` to the first visit's `arrival_location`, then from the
7175    /// first visit's `departure_location` to the second visit's
7176    /// `arrival_location`, and so on until the vehicle's `end_location`. This
7177    /// accounts only for the actual travel between visits, not counting the
7178    /// waiting time, the time spent performing a visit, nor the distance covered
7179    /// during a visit.
7180    ///
7181    /// Invariant: `travel_steps_size() == visits_size() + 1`.
7182    ///
7183    /// If the vehicle does not have a start_ and/or end_location, the
7184    /// corresponding travel metrics are 0 and/or empty.
7185    ///
7186    /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
7187    #[derive(Clone, Default, PartialEq)]
7188    #[non_exhaustive]
7189    #[deprecated]
7190    pub struct TravelStep {
7191        /// Duration of the travel step.
7192        pub duration: std::option::Option<wkt::Duration>,
7193
7194        /// Distance traveled during the step.
7195        pub distance_meters: f64,
7196
7197        /// When traffic is requested via
7198        /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
7199        /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
7200        /// is set to true. This may be temporary (rare hiccup in the realtime
7201        /// traffic servers) or permanent (no data for this location).
7202        ///
7203        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
7204        pub traffic_info_unavailable: bool,
7205
7206        /// The encoded polyline representation of the route followed during the
7207        /// step.
7208        ///
7209        /// This field is only populated if
7210        /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
7211        /// is set to true.
7212        ///
7213        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
7214        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
7215
7216        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7217    }
7218
7219    impl TravelStep {
7220        pub fn new() -> Self {
7221            std::default::Default::default()
7222        }
7223
7224        /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
7225        pub fn set_duration<T>(mut self, v: T) -> Self
7226        where
7227            T: std::convert::Into<wkt::Duration>,
7228        {
7229            self.duration = std::option::Option::Some(v.into());
7230            self
7231        }
7232
7233        /// Sets or clears the value of [duration][crate::model::shipment_route::TravelStep::duration].
7234        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
7235        where
7236            T: std::convert::Into<wkt::Duration>,
7237        {
7238            self.duration = v.map(|x| x.into());
7239            self
7240        }
7241
7242        /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
7243        pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7244            self.distance_meters = v.into();
7245            self
7246        }
7247
7248        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
7249        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7250            self.traffic_info_unavailable = v.into();
7251            self
7252        }
7253
7254        /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
7255        pub fn set_route_polyline<T>(mut self, v: T) -> Self
7256        where
7257            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
7258        {
7259            self.route_polyline = std::option::Option::Some(v.into());
7260            self
7261        }
7262
7263        /// Sets or clears the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
7264        pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
7265        where
7266            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
7267        {
7268            self.route_polyline = v.map(|x| x.into());
7269            self
7270        }
7271    }
7272
7273    impl wkt::message::Message for TravelStep {
7274        fn typename() -> &'static str {
7275            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
7276        }
7277    }
7278}
7279
7280/// Specifies details of unperformed shipments in a solution. For trivial cases
7281/// and/or if we are able to identify the cause for skipping, we report the
7282/// reason here.
7283#[derive(Clone, Default, PartialEq)]
7284#[non_exhaustive]
7285pub struct SkippedShipment {
7286    /// The index corresponds to the index of the shipment in the source
7287    /// `ShipmentModel`.
7288    pub index: i32,
7289
7290    /// Copy of the corresponding
7291    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
7292    /// in the `Shipment`.
7293    ///
7294    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
7295    pub label: std::string::String,
7296
7297    /// A list of reasons that explain why the shipment was skipped. See comment
7298    /// above `Reason`.
7299    pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
7300
7301    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7302}
7303
7304impl SkippedShipment {
7305    pub fn new() -> Self {
7306        std::default::Default::default()
7307    }
7308
7309    /// Sets the value of [index][crate::model::SkippedShipment::index].
7310    pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7311        self.index = v.into();
7312        self
7313    }
7314
7315    /// Sets the value of [label][crate::model::SkippedShipment::label].
7316    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7317        self.label = v.into();
7318        self
7319    }
7320
7321    /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
7322    pub fn set_reasons<T, V>(mut self, v: T) -> Self
7323    where
7324        T: std::iter::IntoIterator<Item = V>,
7325        V: std::convert::Into<crate::model::skipped_shipment::Reason>,
7326    {
7327        use std::iter::Iterator;
7328        self.reasons = v.into_iter().map(|i| i.into()).collect();
7329        self
7330    }
7331}
7332
7333impl wkt::message::Message for SkippedShipment {
7334    fn typename() -> &'static str {
7335        "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
7336    }
7337}
7338
7339/// Defines additional types related to [SkippedShipment].
7340pub mod skipped_shipment {
7341    #[allow(unused_imports)]
7342    use super::*;
7343
7344    /// If we can explain why the shipment was skipped, reasons will be listed
7345    /// here. If the reason is not the same for all vehicles, `reason` will have
7346    /// more than 1 element. A skipped shipment cannot have duplicate reasons,
7347    /// i.e. where all fields are the same except for `example_vehicle_index`.
7348    /// Example:
7349    ///
7350    /// ```norust
7351    /// reasons {
7352    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
7353    ///   example_vehicle_index: 1
7354    ///   example_exceeded_capacity_type: "Apples"
7355    /// }
7356    /// reasons {
7357    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
7358    ///   example_vehicle_index: 3
7359    ///   example_exceeded_capacity_type: "Pears"
7360    /// }
7361    /// reasons {
7362    ///   code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
7363    ///   example_vehicle_index: 1
7364    /// }
7365    /// ```
7366    ///
7367    /// The skipped shipment is incompatible with all vehicles. The reasons may
7368    /// be different for all vehicles but at least one vehicle's "Apples"
7369    /// capacity would be exceeded (including vehicle 1), at least one vehicle's
7370    /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
7371    /// vehicle's distance limit would be exceeded (including vehicle 1).
7372    #[derive(Clone, Default, PartialEq)]
7373    #[non_exhaustive]
7374    pub struct Reason {
7375        /// Refer to the comments of Code.
7376        pub code: crate::model::skipped_shipment::reason::Code,
7377
7378        /// If the reason is related to a shipment-vehicle incompatibility, this
7379        /// field provides the index of one relevant vehicle.
7380        pub example_vehicle_index: std::option::Option<i32>,
7381
7382        /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
7383        /// capacity type that is exceeded.
7384        pub example_exceeded_capacity_type: std::string::String,
7385
7386        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7387    }
7388
7389    impl Reason {
7390        pub fn new() -> Self {
7391            std::default::Default::default()
7392        }
7393
7394        /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
7395        pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
7396            mut self,
7397            v: T,
7398        ) -> Self {
7399            self.code = v.into();
7400            self
7401        }
7402
7403        /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
7404        pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
7405        where
7406            T: std::convert::Into<i32>,
7407        {
7408            self.example_vehicle_index = std::option::Option::Some(v.into());
7409            self
7410        }
7411
7412        /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
7413        pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
7414        where
7415            T: std::convert::Into<i32>,
7416        {
7417            self.example_vehicle_index = v.map(|x| x.into());
7418            self
7419        }
7420
7421        /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
7422        pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
7423            mut self,
7424            v: T,
7425        ) -> Self {
7426            self.example_exceeded_capacity_type = v.into();
7427            self
7428        }
7429    }
7430
7431    impl wkt::message::Message for Reason {
7432        fn typename() -> &'static str {
7433            "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
7434        }
7435    }
7436
7437    /// Defines additional types related to [Reason].
7438    pub mod reason {
7439        #[allow(unused_imports)]
7440        use super::*;
7441
7442        /// Code identifying the reason type. The order here is meaningless. In
7443        /// particular, it gives no indication of whether a given reason will
7444        /// appear before another in the solution, if both apply.
7445        ///
7446        /// # Working with unknown values
7447        ///
7448        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7449        /// additional enum variants at any time. Adding new variants is not considered
7450        /// a breaking change. Applications should write their code in anticipation of:
7451        ///
7452        /// - New values appearing in future releases of the client library, **and**
7453        /// - New values received dynamically, without application changes.
7454        ///
7455        /// Please consult the [Working with enums] section in the user guide for some
7456        /// guidelines.
7457        ///
7458        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
7459        #[derive(Clone, Debug, PartialEq)]
7460        #[non_exhaustive]
7461        pub enum Code {
7462            /// This should never be used. If we are unable to understand why a
7463            /// shipment was skipped, we simply return an empty set of reasons.
7464            Unspecified,
7465            /// There is no vehicle in the model making all shipments infeasible.
7466            NoVehicle,
7467            /// The demand of the shipment exceeds a vehicle's capacity for some
7468            /// capacity types, one of which is `example_exceeded_capacity_type`.
7469            DemandExceedsVehicleCapacity,
7470            /// The minimum distance necessary to perform this shipment, i.e. from
7471            /// the vehicle's `start_location` to the shipment's pickup and/or delivery
7472            /// locations and to the vehicle's end location exceeds the vehicle's
7473            /// `route_distance_limit`.
7474            ///
7475            /// Note that for this computation we use the geodesic distances.
7476            CannotBePerformedWithinVehicleDistanceLimit,
7477            /// The minimum time necessary to perform this shipment, including travel
7478            /// time, wait time and service time exceeds the vehicle's
7479            /// `route_duration_limit`.
7480            ///
7481            /// Note: travel time is computed in the best-case scenario, namely as
7482            /// geodesic distance x 36 m/s (roughly 130 km/hour).
7483            CannotBePerformedWithinVehicleDurationLimit,
7484            /// Same as above but we only compare minimum travel time and the
7485            /// vehicle's `travel_duration_limit`.
7486            CannotBePerformedWithinVehicleTravelDurationLimit,
7487            /// The vehicle cannot perform this shipment in the best-case scenario
7488            /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
7489            /// computation) if it starts at its earliest start time: the total time
7490            /// would make the vehicle end after its latest end time.
7491            CannotBePerformedWithinVehicleTimeWindows,
7492            /// The `allowed_vehicle_indices` field of the shipment is not empty and
7493            /// this vehicle does not belong to it.
7494            VehicleNotAllowed,
7495            /// If set, the enum was initialized with an unknown value.
7496            ///
7497            /// Applications can examine the value using [Code::value] or
7498            /// [Code::name].
7499            UnknownValue(code::UnknownValue),
7500        }
7501
7502        #[doc(hidden)]
7503        pub mod code {
7504            #[allow(unused_imports)]
7505            use super::*;
7506            #[derive(Clone, Debug, PartialEq)]
7507            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7508        }
7509
7510        impl Code {
7511            /// Gets the enum value.
7512            ///
7513            /// Returns `None` if the enum contains an unknown value deserialized from
7514            /// the string representation of enums.
7515            pub fn value(&self) -> std::option::Option<i32> {
7516                match self {
7517                    Self::Unspecified => std::option::Option::Some(0),
7518                    Self::NoVehicle => std::option::Option::Some(1),
7519                    Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
7520                    Self::CannotBePerformedWithinVehicleDistanceLimit => {
7521                        std::option::Option::Some(3)
7522                    }
7523                    Self::CannotBePerformedWithinVehicleDurationLimit => {
7524                        std::option::Option::Some(4)
7525                    }
7526                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
7527                        std::option::Option::Some(5)
7528                    }
7529                    Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
7530                    Self::VehicleNotAllowed => std::option::Option::Some(7),
7531                    Self::UnknownValue(u) => u.0.value(),
7532                }
7533            }
7534
7535            /// Gets the enum value as a string.
7536            ///
7537            /// Returns `None` if the enum contains an unknown value deserialized from
7538            /// the integer representation of enums.
7539            pub fn name(&self) -> std::option::Option<&str> {
7540                match self {
7541                    Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
7542                    Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
7543                    Self::DemandExceedsVehicleCapacity => {
7544                        std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
7545                    }
7546                    Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
7547                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
7548                    ),
7549                    Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
7550                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
7551                    ),
7552                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
7553                        std::option::Option::Some(
7554                            "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
7555                        )
7556                    }
7557                    Self::CannotBePerformedWithinVehicleTimeWindows => {
7558                        std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
7559                    }
7560                    Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
7561                    Self::UnknownValue(u) => u.0.name(),
7562                }
7563            }
7564        }
7565
7566        impl std::default::Default for Code {
7567            fn default() -> Self {
7568                use std::convert::From;
7569                Self::from(0)
7570            }
7571        }
7572
7573        impl std::fmt::Display for Code {
7574            fn fmt(
7575                &self,
7576                f: &mut std::fmt::Formatter<'_>,
7577            ) -> std::result::Result<(), std::fmt::Error> {
7578                wkt::internal::display_enum(f, self.name(), self.value())
7579            }
7580        }
7581
7582        impl std::convert::From<i32> for Code {
7583            fn from(value: i32) -> Self {
7584                match value {
7585                    0 => Self::Unspecified,
7586                    1 => Self::NoVehicle,
7587                    2 => Self::DemandExceedsVehicleCapacity,
7588                    3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
7589                    4 => Self::CannotBePerformedWithinVehicleDurationLimit,
7590                    5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
7591                    6 => Self::CannotBePerformedWithinVehicleTimeWindows,
7592                    7 => Self::VehicleNotAllowed,
7593                    _ => Self::UnknownValue(code::UnknownValue(
7594                        wkt::internal::UnknownEnumValue::Integer(value),
7595                    )),
7596                }
7597            }
7598        }
7599
7600        impl std::convert::From<&str> for Code {
7601            fn from(value: &str) -> Self {
7602                use std::string::ToString;
7603                match value {
7604                    "CODE_UNSPECIFIED" => Self::Unspecified,
7605                    "NO_VEHICLE" => Self::NoVehicle,
7606                    "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
7607                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
7608                        Self::CannotBePerformedWithinVehicleDistanceLimit
7609                    }
7610                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
7611                        Self::CannotBePerformedWithinVehicleDurationLimit
7612                    }
7613                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
7614                        Self::CannotBePerformedWithinVehicleTravelDurationLimit
7615                    }
7616                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
7617                        Self::CannotBePerformedWithinVehicleTimeWindows
7618                    }
7619                    "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
7620                    _ => Self::UnknownValue(code::UnknownValue(
7621                        wkt::internal::UnknownEnumValue::String(value.to_string()),
7622                    )),
7623                }
7624            }
7625        }
7626
7627        impl serde::ser::Serialize for Code {
7628            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7629            where
7630                S: serde::Serializer,
7631            {
7632                match self {
7633                    Self::Unspecified => serializer.serialize_i32(0),
7634                    Self::NoVehicle => serializer.serialize_i32(1),
7635                    Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
7636                    Self::CannotBePerformedWithinVehicleDistanceLimit => {
7637                        serializer.serialize_i32(3)
7638                    }
7639                    Self::CannotBePerformedWithinVehicleDurationLimit => {
7640                        serializer.serialize_i32(4)
7641                    }
7642                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
7643                        serializer.serialize_i32(5)
7644                    }
7645                    Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
7646                    Self::VehicleNotAllowed => serializer.serialize_i32(7),
7647                    Self::UnknownValue(u) => u.0.serialize(serializer),
7648                }
7649            }
7650        }
7651
7652        impl<'de> serde::de::Deserialize<'de> for Code {
7653            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7654            where
7655                D: serde::Deserializer<'de>,
7656            {
7657                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
7658                    ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
7659                ))
7660            }
7661        }
7662    }
7663}
7664
7665/// Aggregated metrics for
7666/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
7667/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
7668/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
7669/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
7670/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
7671///
7672/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
7673/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
7674/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
7675/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
7676#[derive(Clone, Default, PartialEq)]
7677#[non_exhaustive]
7678pub struct AggregatedMetrics {
7679    /// Number of shipments performed. Note that a pickup and delivery pair only
7680    /// counts once.
7681    pub performed_shipment_count: i32,
7682
7683    /// Total travel duration for a route or a solution.
7684    pub travel_duration: std::option::Option<wkt::Duration>,
7685
7686    /// Total wait duration for a route or a solution.
7687    pub wait_duration: std::option::Option<wkt::Duration>,
7688
7689    /// Total delay duration for a route or a solution.
7690    pub delay_duration: std::option::Option<wkt::Duration>,
7691
7692    /// Total break duration for a route or a solution.
7693    pub break_duration: std::option::Option<wkt::Duration>,
7694
7695    /// Total visit duration for a route or a solution.
7696    pub visit_duration: std::option::Option<wkt::Duration>,
7697
7698    /// The total duration should be equal to the sum of all durations above.
7699    /// For routes, it also corresponds to:
7700    /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
7701    /// `-`
7702    /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
7703    ///
7704    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
7705    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
7706    pub total_duration: std::option::Option<wkt::Duration>,
7707
7708    /// Total travel distance for a route or a solution.
7709    pub travel_distance_meters: f64,
7710
7711    /// Maximum load achieved over the entire route (resp. solution), for each of
7712    /// the quantities on this route (resp. solution), computed as the maximum over
7713    /// all
7714    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
7715    /// (resp.
7716    /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
7717    ///
7718    /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
7719    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
7720    pub max_loads:
7721        std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
7722
7723    /// Deprecated: Use
7724    /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
7725    /// and
7726    /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
7727    /// instead.
7728    ///
7729    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
7730    /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
7731    #[deprecated]
7732    pub costs: std::collections::HashMap<std::string::String, f64>,
7733
7734    /// Deprecated: Use
7735    /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
7736    /// and
7737    /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
7738    /// instead.
7739    ///
7740    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
7741    /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
7742    #[deprecated]
7743    pub total_cost: f64,
7744
7745    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7746}
7747
7748impl AggregatedMetrics {
7749    pub fn new() -> Self {
7750        std::default::Default::default()
7751    }
7752
7753    /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
7754    pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7755        self.performed_shipment_count = v.into();
7756        self
7757    }
7758
7759    /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
7760    pub fn set_travel_duration<T>(mut self, v: T) -> Self
7761    where
7762        T: std::convert::Into<wkt::Duration>,
7763    {
7764        self.travel_duration = std::option::Option::Some(v.into());
7765        self
7766    }
7767
7768    /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
7769    pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
7770    where
7771        T: std::convert::Into<wkt::Duration>,
7772    {
7773        self.travel_duration = v.map(|x| x.into());
7774        self
7775    }
7776
7777    /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
7778    pub fn set_wait_duration<T>(mut self, v: T) -> Self
7779    where
7780        T: std::convert::Into<wkt::Duration>,
7781    {
7782        self.wait_duration = std::option::Option::Some(v.into());
7783        self
7784    }
7785
7786    /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
7787    pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
7788    where
7789        T: std::convert::Into<wkt::Duration>,
7790    {
7791        self.wait_duration = v.map(|x| x.into());
7792        self
7793    }
7794
7795    /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
7796    pub fn set_delay_duration<T>(mut self, v: T) -> Self
7797    where
7798        T: std::convert::Into<wkt::Duration>,
7799    {
7800        self.delay_duration = std::option::Option::Some(v.into());
7801        self
7802    }
7803
7804    /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
7805    pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
7806    where
7807        T: std::convert::Into<wkt::Duration>,
7808    {
7809        self.delay_duration = v.map(|x| x.into());
7810        self
7811    }
7812
7813    /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
7814    pub fn set_break_duration<T>(mut self, v: T) -> Self
7815    where
7816        T: std::convert::Into<wkt::Duration>,
7817    {
7818        self.break_duration = std::option::Option::Some(v.into());
7819        self
7820    }
7821
7822    /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
7823    pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7824    where
7825        T: std::convert::Into<wkt::Duration>,
7826    {
7827        self.break_duration = v.map(|x| x.into());
7828        self
7829    }
7830
7831    /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
7832    pub fn set_visit_duration<T>(mut self, v: T) -> Self
7833    where
7834        T: std::convert::Into<wkt::Duration>,
7835    {
7836        self.visit_duration = std::option::Option::Some(v.into());
7837        self
7838    }
7839
7840    /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
7841    pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
7842    where
7843        T: std::convert::Into<wkt::Duration>,
7844    {
7845        self.visit_duration = v.map(|x| x.into());
7846        self
7847    }
7848
7849    /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
7850    pub fn set_total_duration<T>(mut self, v: T) -> Self
7851    where
7852        T: std::convert::Into<wkt::Duration>,
7853    {
7854        self.total_duration = std::option::Option::Some(v.into());
7855        self
7856    }
7857
7858    /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
7859    pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
7860    where
7861        T: std::convert::Into<wkt::Duration>,
7862    {
7863        self.total_duration = v.map(|x| x.into());
7864        self
7865    }
7866
7867    /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
7868    pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7869        self.travel_distance_meters = v.into();
7870        self
7871    }
7872
7873    /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
7874    pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
7875    where
7876        T: std::iter::IntoIterator<Item = (K, V)>,
7877        K: std::convert::Into<std::string::String>,
7878        V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
7879    {
7880        use std::iter::Iterator;
7881        self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7882        self
7883    }
7884
7885    /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
7886    #[deprecated]
7887    pub fn set_costs<T, K, V>(mut self, v: T) -> Self
7888    where
7889        T: std::iter::IntoIterator<Item = (K, V)>,
7890        K: std::convert::Into<std::string::String>,
7891        V: std::convert::Into<f64>,
7892    {
7893        use std::iter::Iterator;
7894        self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7895        self
7896    }
7897
7898    /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
7899    #[deprecated]
7900    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7901        self.total_cost = v.into();
7902        self
7903    }
7904}
7905
7906impl wkt::message::Message for AggregatedMetrics {
7907    fn typename() -> &'static str {
7908        "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
7909    }
7910}
7911
7912/// Solution injected in the request including information about which visits
7913/// must be constrained and how they must be constrained.
7914#[derive(Clone, Default, PartialEq)]
7915#[non_exhaustive]
7916pub struct InjectedSolutionConstraint {
7917    /// Routes of the solution to inject. Some routes may be omitted from the
7918    /// original solution. The routes and skipped shipments must satisfy the basic
7919    /// validity assumptions listed for `injected_first_solution_routes`.
7920    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
7921
7922    /// Skipped shipments of the solution to inject. Some may be omitted from the
7923    /// original solution. See the `routes` field.
7924    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
7925
7926    /// For zero or more groups of vehicles, specifies when and how much to relax
7927    /// constraints. If this field is empty, all non-empty vehicle routes are
7928    /// fully constrained.
7929    pub constraint_relaxations:
7930        std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
7931
7932    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7933}
7934
7935impl InjectedSolutionConstraint {
7936    pub fn new() -> Self {
7937        std::default::Default::default()
7938    }
7939
7940    /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
7941    pub fn set_routes<T, V>(mut self, v: T) -> Self
7942    where
7943        T: std::iter::IntoIterator<Item = V>,
7944        V: std::convert::Into<crate::model::ShipmentRoute>,
7945    {
7946        use std::iter::Iterator;
7947        self.routes = v.into_iter().map(|i| i.into()).collect();
7948        self
7949    }
7950
7951    /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
7952    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
7953    where
7954        T: std::iter::IntoIterator<Item = V>,
7955        V: std::convert::Into<crate::model::SkippedShipment>,
7956    {
7957        use std::iter::Iterator;
7958        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
7959        self
7960    }
7961
7962    /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
7963    pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
7964    where
7965        T: std::iter::IntoIterator<Item = V>,
7966        V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
7967    {
7968        use std::iter::Iterator;
7969        self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
7970        self
7971    }
7972}
7973
7974impl wkt::message::Message for InjectedSolutionConstraint {
7975    fn typename() -> &'static str {
7976        "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
7977    }
7978}
7979
7980/// Defines additional types related to [InjectedSolutionConstraint].
7981pub mod injected_solution_constraint {
7982    #[allow(unused_imports)]
7983    use super::*;
7984
7985    /// For a group of vehicles, specifies at what threshold(s) constraints on
7986    /// visits will be relaxed and to which level. Shipments listed in
7987    /// the `skipped_shipment` field are constrained to be skipped; i.e., they
7988    /// cannot be performed.
7989    #[derive(Clone, Default, PartialEq)]
7990    #[non_exhaustive]
7991    pub struct ConstraintRelaxation {
7992        /// All the visit constraint relaxations that will apply to visits on
7993        /// routes with vehicles in `vehicle_indices`.
7994        pub relaxations: std::vec::Vec<
7995            crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
7996        >,
7997
7998        /// Specifies the vehicle indices to which the visit constraint
7999        /// `relaxations` apply. If empty, this is considered the default and the
8000        /// `relaxations` apply to all vehicles that are not specified in other
8001        /// `constraint_relaxations`. There can be at most one default, i.e., at
8002        /// most one constraint relaxation field is allowed empty
8003        /// `vehicle_indices`. A vehicle index can only be listed once, even within
8004        /// several `constraint_relaxations`.
8005        ///
8006        /// A vehicle index is mapped the same as
8007        /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
8008        /// if `interpret_injected_solutions_using_labels` is true (see `fields`
8009        /// comment).
8010        ///
8011        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
8012        pub vehicle_indices: std::vec::Vec<i32>,
8013
8014        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8015    }
8016
8017    impl ConstraintRelaxation {
8018        pub fn new() -> Self {
8019            std::default::Default::default()
8020        }
8021
8022        /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
8023        pub fn set_relaxations<T, V>(mut self, v: T) -> Self
8024        where
8025            T: std::iter::IntoIterator<Item = V>,
8026            V: std::convert::Into<
8027                    crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
8028                >,
8029        {
8030            use std::iter::Iterator;
8031            self.relaxations = v.into_iter().map(|i| i.into()).collect();
8032            self
8033        }
8034
8035        /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
8036        pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
8037        where
8038            T: std::iter::IntoIterator<Item = V>,
8039            V: std::convert::Into<i32>,
8040        {
8041            use std::iter::Iterator;
8042            self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
8043            self
8044        }
8045    }
8046
8047    impl wkt::message::Message for ConstraintRelaxation {
8048        fn typename() -> &'static str {
8049            "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
8050        }
8051    }
8052
8053    /// Defines additional types related to [ConstraintRelaxation].
8054    pub mod constraint_relaxation {
8055        #[allow(unused_imports)]
8056        use super::*;
8057
8058        /// If `relaxations` is empty, the start time and sequence of all visits
8059        /// on `routes` are fully constrained and no new visits may be inserted or
8060        /// added to those routes. Also, a vehicle's start and end time in
8061        /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
8062        /// visits and has `used_if_route_is_empty` set to false in the model).
8063        ///
8064        /// `relaxations(i).level` specifies the constraint relaxation level applied
8065        /// to a visit #j that satisfies:
8066        ///
8067        /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
8068        /// * `j + 1 >= relaxations(i).threshold_visit_count`
8069        ///
8070        /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
8071        /// satisfies:
8072        ///
8073        /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
8074        /// * `relaxations(i).threshold_visit_count == 0`
8075        ///   and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
8076        /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
8077        /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
8078        ///
8079        /// To apply a relaxation level if a visit meets the `threshold_visit_count`
8080        /// OR the `threshold_time` add two `relaxations` with the same `level`:
8081        /// one with only `threshold_visit_count` set and the other with only
8082        /// `threshold_time` set. If a visit satisfies the conditions of multiple
8083        /// `relaxations`, the most relaxed level applies. As a result, from the
8084        /// vehicle start through the route visits in order to the vehicle end, the
8085        /// relaxation level becomes more relaxed: i.e., the relaxation level is
8086        /// non-decreasing as the route progresses.
8087        ///
8088        /// The timing and sequence of route visits that do not satisfy the
8089        /// threshold conditions of any `relaxations` are fully constrained
8090        /// and no visits may be inserted into these sequences. Also, if a
8091        /// vehicle start or end does not satisfy the conditions of any
8092        /// relaxation the time is fixed, unless the vehicle is empty.
8093        #[derive(Clone, Default, PartialEq)]
8094        #[non_exhaustive]
8095        pub struct Relaxation {
8096
8097            /// The constraint relaxation level that applies when the conditions
8098            /// at or after `threshold_time` AND at least `threshold_visit_count` are
8099            /// satisfied.
8100            pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
8101
8102            /// The time at or after which the relaxation `level` may be applied.
8103            pub threshold_time: std::option::Option<wkt::Timestamp>,
8104
8105            /// The number of visits at or after which the relaxation `level` may be
8106            /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
8107            /// applied directly at the vehicle start.
8108            ///
8109            /// If it is `route.visits_size() + 1`, the `level` may only be applied to
8110            /// the vehicle end. If it is more than `route.visits_size() + 1`,
8111            /// `level` is not applied at all for that route.
8112            pub threshold_visit_count: i32,
8113
8114            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8115        }
8116
8117        impl Relaxation {
8118            pub fn new() -> Self {
8119                std::default::Default::default()
8120            }
8121
8122            /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
8123            pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
8124                self.level = v.into();
8125                self
8126            }
8127
8128            /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
8129            pub fn set_threshold_time<T>(mut self, v: T) -> Self
8130            where
8131                T: std::convert::Into<wkt::Timestamp>,
8132            {
8133                self.threshold_time = std::option::Option::Some(v.into());
8134                self
8135            }
8136
8137            /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
8138            pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
8139            where
8140                T: std::convert::Into<wkt::Timestamp>,
8141            {
8142                self.threshold_time = v.map(|x| x.into());
8143                self
8144            }
8145
8146            /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
8147            pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8148                self.threshold_visit_count = v.into();
8149                self
8150            }
8151        }
8152
8153        impl wkt::message::Message for Relaxation {
8154            fn typename() -> &'static str {
8155                "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
8156            }
8157        }
8158
8159        /// Defines additional types related to [Relaxation].
8160        pub mod relaxation {
8161            #[allow(unused_imports)]
8162            use super::*;
8163
8164            /// Expresses the different constraint relaxation levels, which are
8165            /// applied for a visit and those that follow when it satisfies the
8166            /// threshold conditions.
8167            ///
8168            /// The enumeration below is in order of increasing relaxation.
8169            ///
8170            /// # Working with unknown values
8171            ///
8172            /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8173            /// additional enum variants at any time. Adding new variants is not considered
8174            /// a breaking change. Applications should write their code in anticipation of:
8175            ///
8176            /// - New values appearing in future releases of the client library, **and**
8177            /// - New values received dynamically, without application changes.
8178            ///
8179            /// Please consult the [Working with enums] section in the user guide for some
8180            /// guidelines.
8181            ///
8182            /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
8183            #[derive(Clone, Debug, PartialEq)]
8184            #[non_exhaustive]
8185            pub enum Level {
8186                /// Implicit default relaxation level: no constraints are relaxed,
8187                /// i.e., all visits are fully constrained.
8188                ///
8189                /// This value must not be explicitly used in `level`.
8190                Unspecified,
8191                /// Visit start times and vehicle start/end times will be relaxed, but
8192                /// each visit remains bound to the same vehicle and the visit sequence
8193                /// must be observed: no visit can be inserted between them or before
8194                /// them.
8195                RelaxVisitTimesAfterThreshold,
8196                /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
8197                /// is also relaxed: visits can only be performed by this vehicle, but
8198                /// can potentially become unperformed.
8199                RelaxVisitTimesAndSequenceAfterThreshold,
8200                /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
8201                /// vehicle is also relaxed: visits are completely free at or after the
8202                /// threshold time and can potentially become unperformed.
8203                RelaxAllAfterThreshold,
8204                /// If set, the enum was initialized with an unknown value.
8205                ///
8206                /// Applications can examine the value using [Level::value] or
8207                /// [Level::name].
8208                UnknownValue(level::UnknownValue),
8209            }
8210
8211            #[doc(hidden)]
8212            pub mod level {
8213                #[allow(unused_imports)]
8214                use super::*;
8215                #[derive(Clone, Debug, PartialEq)]
8216                pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8217            }
8218
8219            impl Level {
8220                /// Gets the enum value.
8221                ///
8222                /// Returns `None` if the enum contains an unknown value deserialized from
8223                /// the string representation of enums.
8224                pub fn value(&self) -> std::option::Option<i32> {
8225                    match self {
8226                        Self::Unspecified => std::option::Option::Some(0),
8227                        Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
8228                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
8229                            std::option::Option::Some(2)
8230                        }
8231                        Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
8232                        Self::UnknownValue(u) => u.0.value(),
8233                    }
8234                }
8235
8236                /// Gets the enum value as a string.
8237                ///
8238                /// Returns `None` if the enum contains an unknown value deserialized from
8239                /// the integer representation of enums.
8240                pub fn name(&self) -> std::option::Option<&str> {
8241                    match self {
8242                        Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
8243                        Self::RelaxVisitTimesAfterThreshold => {
8244                            std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
8245                        }
8246                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
8247                            std::option::Option::Some(
8248                                "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
8249                            )
8250                        }
8251                        Self::RelaxAllAfterThreshold => {
8252                            std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
8253                        }
8254                        Self::UnknownValue(u) => u.0.name(),
8255                    }
8256                }
8257            }
8258
8259            impl std::default::Default for Level {
8260                fn default() -> Self {
8261                    use std::convert::From;
8262                    Self::from(0)
8263                }
8264            }
8265
8266            impl std::fmt::Display for Level {
8267                fn fmt(
8268                    &self,
8269                    f: &mut std::fmt::Formatter<'_>,
8270                ) -> std::result::Result<(), std::fmt::Error> {
8271                    wkt::internal::display_enum(f, self.name(), self.value())
8272                }
8273            }
8274
8275            impl std::convert::From<i32> for Level {
8276                fn from(value: i32) -> Self {
8277                    match value {
8278                        0 => Self::Unspecified,
8279                        1 => Self::RelaxVisitTimesAfterThreshold,
8280                        2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
8281                        3 => Self::RelaxAllAfterThreshold,
8282                        _ => Self::UnknownValue(level::UnknownValue(
8283                            wkt::internal::UnknownEnumValue::Integer(value),
8284                        )),
8285                    }
8286                }
8287            }
8288
8289            impl std::convert::From<&str> for Level {
8290                fn from(value: &str) -> Self {
8291                    use std::string::ToString;
8292                    match value {
8293                        "LEVEL_UNSPECIFIED" => Self::Unspecified,
8294                        "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
8295                        "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
8296                            Self::RelaxVisitTimesAndSequenceAfterThreshold
8297                        }
8298                        "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
8299                        _ => Self::UnknownValue(level::UnknownValue(
8300                            wkt::internal::UnknownEnumValue::String(value.to_string()),
8301                        )),
8302                    }
8303                }
8304            }
8305
8306            impl serde::ser::Serialize for Level {
8307                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8308                where
8309                    S: serde::Serializer,
8310                {
8311                    match self {
8312                        Self::Unspecified => serializer.serialize_i32(0),
8313                        Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
8314                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
8315                            serializer.serialize_i32(2)
8316                        }
8317                        Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
8318                        Self::UnknownValue(u) => u.0.serialize(serializer),
8319                    }
8320                }
8321            }
8322
8323            impl<'de> serde::de::Deserialize<'de> for Level {
8324                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8325                where
8326                    D: serde::Deserializer<'de>,
8327                {
8328                    deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
8329                        ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
8330                }
8331            }
8332        }
8333    }
8334}
8335
8336/// Describes an error encountered when validating an `OptimizeToursRequest`.
8337#[derive(Clone, Default, PartialEq)]
8338#[non_exhaustive]
8339pub struct OptimizeToursValidationError {
8340    /// A validation error is defined by the pair (`code`, `display_name`) which
8341    /// are always present.
8342    ///
8343    /// Other fields (below) provide more context about the error.
8344    ///
8345    /// *MULTIPLE ERRORS*:
8346    /// When there are multiple errors, the validation process tries to output
8347    /// several of them. Much like a compiler, this is an imperfect process. Some
8348    /// validation errors will be "fatal", meaning that they stop the entire
8349    /// validation process. This is the case for `display_name="UNSPECIFIED"`
8350    /// errors, among others. Some may cause the validation process to skip other
8351    /// errors.
8352    ///
8353    /// *STABILITY*:
8354    /// `code` and `display_name` should be very stable. But new codes and
8355    /// display names may appear over time, which may cause a given (invalid)
8356    /// request to yield a different (`code`, `display_name`) pair because the new
8357    /// error hid the old one (see "MULTIPLE ERRORS").
8358    ///
8359    /// *REFERENCE*: A list of all (code, name) pairs:
8360    ///
8361    /// * UNSPECIFIED = 0;
8362    ///
8363    /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
8364    ///   the deadline.
8365    ///
8366    /// * REQUEST_OPTIONS_ERROR = 12;
8367    ///
8368    ///   * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
8369    ///   * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
8370    ///   * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
8371    ///   * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
8372    ///   * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
8373    ///   * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
8374    ///     = 1207;
8375    ///   * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
8376    ///   * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
8377    ///   * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
8378    ///   * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
8379    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
8380    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
8381    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
8382    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
8383    /// * INJECTED_SOLUTION_ERROR = 20;
8384    ///
8385    ///   * INJECTED_SOLUTION_MISSING_LABEL = 2000;
8386    ///   * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
8387    ///   * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
8388    ///   * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
8389    ///   * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
8390    ///   * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
8391    ///   * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
8392    ///   * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
8393    ///   * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
8394    /// * SHIPMENT_MODEL_ERROR = 22;
8395    ///
8396    ///   * SHIPMENT_MODEL_TOO_LARGE = 2200;
8397    ///   * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
8398    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
8399    ///   * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
8400    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
8401    ///   * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
8402    ///   * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
8403    ///   * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
8404    /// * INDEX_ERROR = 24;
8405    ///
8406    /// * TAG_ERROR = 26;
8407    ///
8408    /// * TIME_WINDOW_ERROR = 28;
8409    ///
8410    ///   * TIME_WINDOW_INVALID_START_TIME = 2800;
8411    ///   * TIME_WINDOW_INVALID_END_TIME = 2801;
8412    ///   * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
8413    ///   * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
8414    ///   * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
8415    ///   * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
8416    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
8417    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
8418    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
8419    ///     = 2808;
8420    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
8421    ///   * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
8422    ///     = 2810;
8423    ///   * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
8424    ///   * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
8425    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
8426    ///   * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
8427    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
8428    ///   * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
8429    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
8430    ///     = 2817;
8431    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
8432    ///   * TRANSITION_ATTRIBUTES_ERROR = 30;
8433    ///   * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
8434    ///   * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
8435    ///   * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
8436    ///   * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
8437    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
8438    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
8439    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
8440    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
8441    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
8442    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
8443    /// * AMOUNT_ERROR = 31;
8444    ///
8445    ///   * AMOUNT_NEGATIVE_VALUE = 3100;
8446    /// * LOAD_LIMIT_ERROR = 33;
8447    ///
8448    ///   * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
8449    ///   * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
8450    ///   * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
8451    ///   * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
8452    ///   * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
8453    ///   * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
8454    ///   * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
8455    /// * INTERVAL_ERROR = 34;
8456    ///
8457    ///   * INTERVAL_MIN_EXCEEDS_MAX = 3401;
8458    ///   * INTERVAL_NEGATIVE_MIN = 3402;
8459    ///   * INTERVAL_NEGATIVE_MAX = 3403;
8460    ///   * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
8461    ///   * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
8462    /// * DISTANCE_LIMIT_ERROR = 36;
8463    ///
8464    ///   * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
8465    ///   * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
8466    ///   * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
8467    ///   * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
8468    ///   * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
8469    ///   * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
8470    /// * DURATION_LIMIT_ERROR = 38;
8471    ///
8472    ///   * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
8473    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
8474    ///   * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
8475    ///   * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
8476    ///   * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
8477    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
8478    ///   * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
8479    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
8480    ///     = 3807;
8481    ///   * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
8482    ///     = 3808;
8483    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
8484    ///   * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
8485    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
8486    ///   * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
8487    ///     = 3812;
8488    ///   * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
8489    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
8490    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
8491    ///     = 3815;
8492    /// * SHIPMENT_ERROR = 40;
8493    ///
8494    ///   * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
8495    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
8496    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
8497    ///     = 4001;
8498    ///   * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
8499    ///   * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
8500    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
8501    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
8502    ///   * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
8503    ///   * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
8504    ///   * SHIPMENT_INVALID_PENALTY_COST = 4006;
8505    ///   * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
8506    ///   * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
8507    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
8508    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
8509    ///   * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
8510    ///   * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
8511    ///   * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
8512    /// * VEHICLE_ERROR = 42;
8513    ///
8514    ///   * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
8515    ///   * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
8516    ///   * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
8517    ///   * VEHICLE_EMPTY_START_TAG = 4203;
8518    ///   * VEHICLE_DUPLICATE_START_TAG = 4204;
8519    ///   * VEHICLE_EMPTY_END_TAG = 4205;
8520    ///   * VEHICLE_DUPLICATE_END_TAG = 4206;
8521    ///   * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
8522    ///   * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
8523    ///   * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
8524    ///   * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
8525    ///   * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
8526    ///   * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
8527    ///   * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
8528    ///   * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
8529    ///   * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
8530    ///   * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
8531    ///   * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
8532    ///   * VEHICLE_INVALID_COST_PER_HOUR = 4218;
8533    ///   * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
8534    ///   * VEHICLE_INVALID_FIXED_COST = 4220;
8535    ///   * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
8536    ///   * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
8537    ///     = 4223;
8538    ///   * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
8539    ///   * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
8540    /// * VISIT_REQUEST_ERROR = 44;
8541    ///
8542    ///   * VISIT_REQUEST_EMPTY_TAG = 4400;
8543    ///   * VISIT_REQUEST_DUPLICATE_TAG = 4401;
8544    ///   * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
8545    ///   * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
8546    /// * PRECEDENCE_ERROR = 46;
8547    ///
8548    ///   * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
8549    ///   * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
8550    ///   * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
8551    ///   * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
8552    ///   * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
8553    ///   * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
8554    ///   * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
8555    /// * BREAK_ERROR = 48;
8556    ///
8557    ///   * BREAK_RULE_EMPTY = 4800;
8558    ///   * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
8559    ///   * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
8560    ///   * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
8561    ///   * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
8562    ///   * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
8563    ///   * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
8564    ///   * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
8565    ///   * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
8566    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
8567    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
8568    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
8569    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
8570    ///     = 4812;
8571    ///   * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
8572    ///   * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
8573    ///   * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
8574    /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
8575    ///
8576    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
8577    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
8578    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
8579    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
8580    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
8581    /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
8582    ///
8583    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
8584    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
8585    ///   * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
8586    ///   * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
8587    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
8588    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
8589    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
8590    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
8591    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
8592    ///   * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
8593    ///   * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
8594    /// * VEHICLE_OPERATOR_ERROR = 54;
8595    ///
8596    ///   * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
8597    ///   * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
8598    ///   * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
8599    ///   * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
8600    ///   * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
8601    /// * DURATION_SECONDS_MATRIX_ERROR = 56;
8602    ///
8603    ///   * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
8604    ///   * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
8605    pub code: i32,
8606
8607    /// The error display name.
8608    pub display_name: std::string::String,
8609
8610    /// An error context may involve 0, 1 (most of the time) or more fields. For
8611    /// example, referring to vehicle #4 and shipment #2's first pickup can be
8612    /// done as follows:
8613    ///
8614    /// ```norust
8615    /// fields { name: "vehicles" index: 4}
8616    /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
8617    /// ```
8618    ///
8619    /// Note, however, that the cardinality of `fields` should not change for a
8620    /// given error code.
8621    pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
8622
8623    /// Human-readable string describing the error. There is a 1:1 mapping
8624    /// between `code` and `error_message` (when code != "UNSPECIFIED").
8625    ///
8626    /// *STABILITY*: Not stable: the error message associated to a given `code` may
8627    /// change (hopefully to clarify it) over time. Please rely on the
8628    /// `display_name` and `code` instead.
8629    pub error_message: std::string::String,
8630
8631    /// May contain the value(s) of the field(s). This is not always available. You
8632    /// should absolutely not rely on it and use it only for manual model
8633    /// debugging.
8634    pub offending_values: std::string::String,
8635
8636    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8637}
8638
8639impl OptimizeToursValidationError {
8640    pub fn new() -> Self {
8641        std::default::Default::default()
8642    }
8643
8644    /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
8645    pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8646        self.code = v.into();
8647        self
8648    }
8649
8650    /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
8651    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8652        self.display_name = v.into();
8653        self
8654    }
8655
8656    /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
8657    pub fn set_fields<T, V>(mut self, v: T) -> Self
8658    where
8659        T: std::iter::IntoIterator<Item = V>,
8660        V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
8661    {
8662        use std::iter::Iterator;
8663        self.fields = v.into_iter().map(|i| i.into()).collect();
8664        self
8665    }
8666
8667    /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
8668    pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8669        self.error_message = v.into();
8670        self
8671    }
8672
8673    /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
8674    pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
8675        mut self,
8676        v: T,
8677    ) -> Self {
8678        self.offending_values = v.into();
8679        self
8680    }
8681}
8682
8683impl wkt::message::Message for OptimizeToursValidationError {
8684    fn typename() -> &'static str {
8685        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
8686    }
8687}
8688
8689/// Defines additional types related to [OptimizeToursValidationError].
8690pub mod optimize_tours_validation_error {
8691    #[allow(unused_imports)]
8692    use super::*;
8693
8694    /// Specifies a context for the validation error. A `FieldReference` always
8695    /// refers to a given field in this file and follows the same hierarchical
8696    /// structure. For example, we may specify element #2 of `start_time_windows`
8697    /// of vehicle #5 using:
8698    ///
8699    /// ```norust
8700    /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
8701    /// ```
8702    ///
8703    /// We however omit top-level entities such as `OptimizeToursRequest` or
8704    /// `ShipmentModel` to avoid crowding the message.
8705    #[derive(Clone, Default, PartialEq)]
8706    #[non_exhaustive]
8707    pub struct FieldReference {
8708        /// Name of the field, e.g., "vehicles".
8709        pub name: std::string::String,
8710
8711        /// Recursively nested sub-field, if needed.
8712        pub sub_field: std::option::Option<
8713            std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
8714        >,
8715
8716        pub index_or_key: std::option::Option<
8717            crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
8718        >,
8719
8720        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8721    }
8722
8723    impl FieldReference {
8724        pub fn new() -> Self {
8725            std::default::Default::default()
8726        }
8727
8728        /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
8729        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8730            self.name = v.into();
8731            self
8732        }
8733
8734        /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
8735        pub fn set_sub_field<T>(mut self, v: T) -> Self
8736        where
8737            T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
8738        {
8739            self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
8740            self
8741        }
8742
8743        /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
8744        pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
8745        where
8746            T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
8747        {
8748            self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
8749            self
8750        }
8751
8752        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
8753        ///
8754        /// Note that all the setters affecting `index_or_key` are mutually
8755        /// exclusive.
8756        pub fn set_index_or_key<
8757            T: std::convert::Into<
8758                    std::option::Option<
8759                        crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
8760                    >,
8761                >,
8762        >(
8763            mut self,
8764            v: T,
8765        ) -> Self {
8766            self.index_or_key = v.into();
8767            self
8768        }
8769
8770        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
8771        /// if it holds a `Index`, `None` if the field is not set or
8772        /// holds a different branch.
8773        pub fn index(&self) -> std::option::Option<&i32> {
8774            #[allow(unreachable_patterns)]
8775            self.index_or_key.as_ref().and_then(|v| match v {
8776                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
8777                _ => std::option::Option::None,
8778            })
8779        }
8780
8781        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
8782        /// to hold a `Index`.
8783        ///
8784        /// Note that all the setters affecting `index_or_key` are
8785        /// mutually exclusive.
8786        pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8787            self.index_or_key = std::option::Option::Some(
8788                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
8789                    v.into(),
8790                ),
8791            );
8792            self
8793        }
8794
8795        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
8796        /// if it holds a `Key`, `None` if the field is not set or
8797        /// holds a different branch.
8798        pub fn key(&self) -> std::option::Option<&std::string::String> {
8799            #[allow(unreachable_patterns)]
8800            self.index_or_key.as_ref().and_then(|v| match v {
8801                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
8802                    v,
8803                ) => std::option::Option::Some(v),
8804                _ => std::option::Option::None,
8805            })
8806        }
8807
8808        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
8809        /// to hold a `Key`.
8810        ///
8811        /// Note that all the setters affecting `index_or_key` are
8812        /// mutually exclusive.
8813        pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8814            self.index_or_key = std::option::Option::Some(
8815                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
8816                    v.into(),
8817                ),
8818            );
8819            self
8820        }
8821    }
8822
8823    impl wkt::message::Message for FieldReference {
8824        fn typename() -> &'static str {
8825            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
8826        }
8827    }
8828
8829    /// Defines additional types related to [FieldReference].
8830    pub mod field_reference {
8831        #[allow(unused_imports)]
8832        use super::*;
8833
8834        #[derive(Clone, Debug, PartialEq)]
8835        #[non_exhaustive]
8836        pub enum IndexOrKey {
8837            /// Index of the field if repeated.
8838            Index(i32),
8839            /// Key if the field is a map.
8840            Key(std::string::String),
8841        }
8842    }
8843}
8844
8845/// Data formats for input and output files.
8846///
8847/// # Working with unknown values
8848///
8849/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8850/// additional enum variants at any time. Adding new variants is not considered
8851/// a breaking change. Applications should write their code in anticipation of:
8852///
8853/// - New values appearing in future releases of the client library, **and**
8854/// - New values received dynamically, without application changes.
8855///
8856/// Please consult the [Working with enums] section in the user guide for some
8857/// guidelines.
8858///
8859/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
8860#[derive(Clone, Debug, PartialEq)]
8861#[non_exhaustive]
8862pub enum DataFormat {
8863    /// Default value.
8864    Unspecified,
8865    /// Input data in json format.
8866    Json,
8867    /// Input data in string format.
8868    String,
8869    /// If set, the enum was initialized with an unknown value.
8870    ///
8871    /// Applications can examine the value using [DataFormat::value] or
8872    /// [DataFormat::name].
8873    UnknownValue(data_format::UnknownValue),
8874}
8875
8876#[doc(hidden)]
8877pub mod data_format {
8878    #[allow(unused_imports)]
8879    use super::*;
8880    #[derive(Clone, Debug, PartialEq)]
8881    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8882}
8883
8884impl DataFormat {
8885    /// Gets the enum value.
8886    ///
8887    /// Returns `None` if the enum contains an unknown value deserialized from
8888    /// the string representation of enums.
8889    pub fn value(&self) -> std::option::Option<i32> {
8890        match self {
8891            Self::Unspecified => std::option::Option::Some(0),
8892            Self::Json => std::option::Option::Some(1),
8893            Self::String => std::option::Option::Some(2),
8894            Self::UnknownValue(u) => u.0.value(),
8895        }
8896    }
8897
8898    /// Gets the enum value as a string.
8899    ///
8900    /// Returns `None` if the enum contains an unknown value deserialized from
8901    /// the integer representation of enums.
8902    pub fn name(&self) -> std::option::Option<&str> {
8903        match self {
8904            Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
8905            Self::Json => std::option::Option::Some("JSON"),
8906            Self::String => std::option::Option::Some("STRING"),
8907            Self::UnknownValue(u) => u.0.name(),
8908        }
8909    }
8910}
8911
8912impl std::default::Default for DataFormat {
8913    fn default() -> Self {
8914        use std::convert::From;
8915        Self::from(0)
8916    }
8917}
8918
8919impl std::fmt::Display for DataFormat {
8920    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8921        wkt::internal::display_enum(f, self.name(), self.value())
8922    }
8923}
8924
8925impl std::convert::From<i32> for DataFormat {
8926    fn from(value: i32) -> Self {
8927        match value {
8928            0 => Self::Unspecified,
8929            1 => Self::Json,
8930            2 => Self::String,
8931            _ => Self::UnknownValue(data_format::UnknownValue(
8932                wkt::internal::UnknownEnumValue::Integer(value),
8933            )),
8934        }
8935    }
8936}
8937
8938impl std::convert::From<&str> for DataFormat {
8939    fn from(value: &str) -> Self {
8940        use std::string::ToString;
8941        match value {
8942            "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
8943            "JSON" => Self::Json,
8944            "STRING" => Self::String,
8945            _ => Self::UnknownValue(data_format::UnknownValue(
8946                wkt::internal::UnknownEnumValue::String(value.to_string()),
8947            )),
8948        }
8949    }
8950}
8951
8952impl serde::ser::Serialize for DataFormat {
8953    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8954    where
8955        S: serde::Serializer,
8956    {
8957        match self {
8958            Self::Unspecified => serializer.serialize_i32(0),
8959            Self::Json => serializer.serialize_i32(1),
8960            Self::String => serializer.serialize_i32(2),
8961            Self::UnknownValue(u) => u.0.serialize(serializer),
8962        }
8963    }
8964}
8965
8966impl<'de> serde::de::Deserialize<'de> for DataFormat {
8967    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8968    where
8969        D: serde::Deserializer<'de>,
8970    {
8971        deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
8972            ".google.cloud.optimization.v1.DataFormat",
8973        ))
8974    }
8975}