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    ///
61    /// # Example
62    /// ```ignore,no_run
63    /// # use google_cloud_optimization_v1::model::InputConfig;
64    /// use google_cloud_optimization_v1::model::DataFormat;
65    /// let x0 = InputConfig::new().set_data_format(DataFormat::Json);
66    /// let x1 = InputConfig::new().set_data_format(DataFormat::String);
67    /// ```
68    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
69        mut self,
70        v: T,
71    ) -> Self {
72        self.data_format = v.into();
73        self
74    }
75
76    /// Sets the value of [source][crate::model::InputConfig::source].
77    ///
78    /// Note that all the setters affecting `source` are mutually
79    /// exclusive.
80    ///
81    /// # Example
82    /// ```ignore,no_run
83    /// # use google_cloud_optimization_v1::model::InputConfig;
84    /// use google_cloud_optimization_v1::model::GcsSource;
85    /// let x = InputConfig::new().set_source(Some(
86    ///     google_cloud_optimization_v1::model::input_config::Source::GcsSource(GcsSource::default().into())));
87    /// ```
88    pub fn set_source<
89        T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
90    >(
91        mut self,
92        v: T,
93    ) -> Self {
94        self.source = v.into();
95        self
96    }
97
98    /// The value of [source][crate::model::InputConfig::source]
99    /// if it holds a `GcsSource`, `None` if the field is not set or
100    /// holds a different branch.
101    pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
102        #[allow(unreachable_patterns)]
103        self.source.as_ref().and_then(|v| match v {
104            crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
105            _ => std::option::Option::None,
106        })
107    }
108
109    /// Sets the value of [source][crate::model::InputConfig::source]
110    /// to hold a `GcsSource`.
111    ///
112    /// Note that all the setters affecting `source` are
113    /// mutually exclusive.
114    ///
115    /// # Example
116    /// ```ignore,no_run
117    /// # use google_cloud_optimization_v1::model::InputConfig;
118    /// use google_cloud_optimization_v1::model::GcsSource;
119    /// let x = InputConfig::new().set_gcs_source(GcsSource::default()/* use setters */);
120    /// assert!(x.gcs_source().is_some());
121    /// ```
122    pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
123        mut self,
124        v: T,
125    ) -> Self {
126        self.source =
127            std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
128        self
129    }
130}
131
132impl wkt::message::Message for InputConfig {
133    fn typename() -> &'static str {
134        "type.googleapis.com/google.cloud.optimization.v1.InputConfig"
135    }
136}
137
138/// Defines additional types related to [InputConfig].
139pub mod input_config {
140    #[allow(unused_imports)]
141    use super::*;
142
143    /// The location of the input model in cloud storage.
144    /// Required.
145    #[derive(Clone, Debug, PartialEq)]
146    #[non_exhaustive]
147    pub enum Source {
148        /// The Google Cloud Storage location to read the input from. This must be a
149        /// single file.
150        GcsSource(std::boxed::Box<crate::model::GcsSource>),
151    }
152}
153
154/// The desired output location.
155#[derive(Clone, Default, PartialEq)]
156#[non_exhaustive]
157pub struct OutputConfig {
158    /// The output data format that used to store the results in Cloud Storage.
159    pub data_format: crate::model::DataFormat,
160
161    /// The location of the output result in cloud storage.
162    /// Required.
163    pub destination: std::option::Option<crate::model::output_config::Destination>,
164
165    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
166}
167
168impl OutputConfig {
169    pub fn new() -> Self {
170        std::default::Default::default()
171    }
172
173    /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
174    ///
175    /// # Example
176    /// ```ignore,no_run
177    /// # use google_cloud_optimization_v1::model::OutputConfig;
178    /// use google_cloud_optimization_v1::model::DataFormat;
179    /// let x0 = OutputConfig::new().set_data_format(DataFormat::Json);
180    /// let x1 = OutputConfig::new().set_data_format(DataFormat::String);
181    /// ```
182    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
183        mut self,
184        v: T,
185    ) -> Self {
186        self.data_format = v.into();
187        self
188    }
189
190    /// Sets the value of [destination][crate::model::OutputConfig::destination].
191    ///
192    /// Note that all the setters affecting `destination` are mutually
193    /// exclusive.
194    ///
195    /// # Example
196    /// ```ignore,no_run
197    /// # use google_cloud_optimization_v1::model::OutputConfig;
198    /// use google_cloud_optimization_v1::model::GcsDestination;
199    /// let x = OutputConfig::new().set_destination(Some(
200    ///     google_cloud_optimization_v1::model::output_config::Destination::GcsDestination(GcsDestination::default().into())));
201    /// ```
202    pub fn set_destination<
203        T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
204    >(
205        mut self,
206        v: T,
207    ) -> Self {
208        self.destination = v.into();
209        self
210    }
211
212    /// The value of [destination][crate::model::OutputConfig::destination]
213    /// if it holds a `GcsDestination`, `None` if the field is not set or
214    /// holds a different branch.
215    pub fn gcs_destination(
216        &self,
217    ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
218        #[allow(unreachable_patterns)]
219        self.destination.as_ref().and_then(|v| match v {
220            crate::model::output_config::Destination::GcsDestination(v) => {
221                std::option::Option::Some(v)
222            }
223            _ => std::option::Option::None,
224        })
225    }
226
227    /// Sets the value of [destination][crate::model::OutputConfig::destination]
228    /// to hold a `GcsDestination`.
229    ///
230    /// Note that all the setters affecting `destination` are
231    /// mutually exclusive.
232    ///
233    /// # Example
234    /// ```ignore,no_run
235    /// # use google_cloud_optimization_v1::model::OutputConfig;
236    /// use google_cloud_optimization_v1::model::GcsDestination;
237    /// let x = OutputConfig::new().set_gcs_destination(GcsDestination::default()/* use setters */);
238    /// assert!(x.gcs_destination().is_some());
239    /// ```
240    pub fn set_gcs_destination<
241        T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
242    >(
243        mut self,
244        v: T,
245    ) -> Self {
246        self.destination = std::option::Option::Some(
247            crate::model::output_config::Destination::GcsDestination(v.into()),
248        );
249        self
250    }
251}
252
253impl wkt::message::Message for OutputConfig {
254    fn typename() -> &'static str {
255        "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
256    }
257}
258
259/// Defines additional types related to [OutputConfig].
260pub mod output_config {
261    #[allow(unused_imports)]
262    use super::*;
263
264    /// The location of the output result in cloud storage.
265    /// Required.
266    #[derive(Clone, Debug, PartialEq)]
267    #[non_exhaustive]
268    pub enum Destination {
269        /// The Google Cloud Storage location to write the output to.
270        GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
271    }
272}
273
274/// The Google Cloud Storage location where the input file will be read from.
275#[derive(Clone, Default, PartialEq)]
276#[non_exhaustive]
277pub struct GcsSource {
278    /// Required. URI of the Google Cloud Storage location.
279    pub uri: std::string::String,
280
281    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
282}
283
284impl GcsSource {
285    pub fn new() -> Self {
286        std::default::Default::default()
287    }
288
289    /// Sets the value of [uri][crate::model::GcsSource::uri].
290    ///
291    /// # Example
292    /// ```ignore,no_run
293    /// # use google_cloud_optimization_v1::model::GcsSource;
294    /// let x = GcsSource::new().set_uri("example");
295    /// ```
296    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
297        self.uri = v.into();
298        self
299    }
300}
301
302impl wkt::message::Message for GcsSource {
303    fn typename() -> &'static str {
304        "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
305    }
306}
307
308/// The Google Cloud Storage location where the output file will be written to.
309#[derive(Clone, Default, PartialEq)]
310#[non_exhaustive]
311pub struct GcsDestination {
312    /// Required. URI of the Google Cloud Storage location.
313    pub uri: std::string::String,
314
315    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
316}
317
318impl GcsDestination {
319    pub fn new() -> Self {
320        std::default::Default::default()
321    }
322
323    /// Sets the value of [uri][crate::model::GcsDestination::uri].
324    ///
325    /// # Example
326    /// ```ignore,no_run
327    /// # use google_cloud_optimization_v1::model::GcsDestination;
328    /// let x = GcsDestination::new().set_uri("example");
329    /// ```
330    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
331        self.uri = v.into();
332        self
333    }
334}
335
336impl wkt::message::Message for GcsDestination {
337    fn typename() -> &'static str {
338        "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
339    }
340}
341
342/// The long running operation metadata for async model related methods.
343#[derive(Clone, Default, PartialEq)]
344#[non_exhaustive]
345pub struct AsyncModelMetadata {
346    /// The state of the current operation.
347    pub state: crate::model::async_model_metadata::State,
348
349    /// A message providing more details about the current state of the operation.
350    /// For example, the error message if the operation is failed.
351    pub state_message: std::string::String,
352
353    /// The creation time of the operation.
354    pub create_time: std::option::Option<wkt::Timestamp>,
355
356    /// The last update time of the operation.
357    pub update_time: std::option::Option<wkt::Timestamp>,
358
359    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
360}
361
362impl AsyncModelMetadata {
363    pub fn new() -> Self {
364        std::default::Default::default()
365    }
366
367    /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
368    ///
369    /// # Example
370    /// ```ignore,no_run
371    /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
372    /// use google_cloud_optimization_v1::model::async_model_metadata::State;
373    /// let x0 = AsyncModelMetadata::new().set_state(State::Running);
374    /// let x1 = AsyncModelMetadata::new().set_state(State::Succeeded);
375    /// let x2 = AsyncModelMetadata::new().set_state(State::Cancelled);
376    /// ```
377    pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
378        mut self,
379        v: T,
380    ) -> Self {
381        self.state = v.into();
382        self
383    }
384
385    /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
386    ///
387    /// # Example
388    /// ```ignore,no_run
389    /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
390    /// let x = AsyncModelMetadata::new().set_state_message("example");
391    /// ```
392    pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
393        self.state_message = v.into();
394        self
395    }
396
397    /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
398    ///
399    /// # Example
400    /// ```ignore,no_run
401    /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
402    /// use wkt::Timestamp;
403    /// let x = AsyncModelMetadata::new().set_create_time(Timestamp::default()/* use setters */);
404    /// ```
405    pub fn set_create_time<T>(mut self, v: T) -> Self
406    where
407        T: std::convert::Into<wkt::Timestamp>,
408    {
409        self.create_time = std::option::Option::Some(v.into());
410        self
411    }
412
413    /// Sets or clears the value of [create_time][crate::model::AsyncModelMetadata::create_time].
414    ///
415    /// # Example
416    /// ```ignore,no_run
417    /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
418    /// use wkt::Timestamp;
419    /// let x = AsyncModelMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
420    /// let x = AsyncModelMetadata::new().set_or_clear_create_time(None::<Timestamp>);
421    /// ```
422    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
423    where
424        T: std::convert::Into<wkt::Timestamp>,
425    {
426        self.create_time = v.map(|x| x.into());
427        self
428    }
429
430    /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
431    ///
432    /// # Example
433    /// ```ignore,no_run
434    /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
435    /// use wkt::Timestamp;
436    /// let x = AsyncModelMetadata::new().set_update_time(Timestamp::default()/* use setters */);
437    /// ```
438    pub fn set_update_time<T>(mut self, v: T) -> Self
439    where
440        T: std::convert::Into<wkt::Timestamp>,
441    {
442        self.update_time = std::option::Option::Some(v.into());
443        self
444    }
445
446    /// Sets or clears the value of [update_time][crate::model::AsyncModelMetadata::update_time].
447    ///
448    /// # Example
449    /// ```ignore,no_run
450    /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
451    /// use wkt::Timestamp;
452    /// let x = AsyncModelMetadata::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
453    /// let x = AsyncModelMetadata::new().set_or_clear_update_time(None::<Timestamp>);
454    /// ```
455    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
456    where
457        T: std::convert::Into<wkt::Timestamp>,
458    {
459        self.update_time = v.map(|x| x.into());
460        self
461    }
462}
463
464impl wkt::message::Message for AsyncModelMetadata {
465    fn typename() -> &'static str {
466        "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
467    }
468}
469
470/// Defines additional types related to [AsyncModelMetadata].
471pub mod async_model_metadata {
472    #[allow(unused_imports)]
473    use super::*;
474
475    /// Possible states of the operation.
476    ///
477    /// # Working with unknown values
478    ///
479    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
480    /// additional enum variants at any time. Adding new variants is not considered
481    /// a breaking change. Applications should write their code in anticipation of:
482    ///
483    /// - New values appearing in future releases of the client library, **and**
484    /// - New values received dynamically, without application changes.
485    ///
486    /// Please consult the [Working with enums] section in the user guide for some
487    /// guidelines.
488    ///
489    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
490    #[derive(Clone, Debug, PartialEq)]
491    #[non_exhaustive]
492    pub enum State {
493        /// The default value. This value is used if the state is omitted.
494        Unspecified,
495        /// Request is being processed.
496        Running,
497        /// The operation completed successfully.
498        Succeeded,
499        /// The operation was cancelled.
500        Cancelled,
501        /// The operation has failed.
502        Failed,
503        /// If set, the enum was initialized with an unknown value.
504        ///
505        /// Applications can examine the value using [State::value] or
506        /// [State::name].
507        UnknownValue(state::UnknownValue),
508    }
509
510    #[doc(hidden)]
511    pub mod state {
512        #[allow(unused_imports)]
513        use super::*;
514        #[derive(Clone, Debug, PartialEq)]
515        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
516    }
517
518    impl State {
519        /// Gets the enum value.
520        ///
521        /// Returns `None` if the enum contains an unknown value deserialized from
522        /// the string representation of enums.
523        pub fn value(&self) -> std::option::Option<i32> {
524            match self {
525                Self::Unspecified => std::option::Option::Some(0),
526                Self::Running => std::option::Option::Some(1),
527                Self::Succeeded => std::option::Option::Some(2),
528                Self::Cancelled => std::option::Option::Some(3),
529                Self::Failed => std::option::Option::Some(4),
530                Self::UnknownValue(u) => u.0.value(),
531            }
532        }
533
534        /// Gets the enum value as a string.
535        ///
536        /// Returns `None` if the enum contains an unknown value deserialized from
537        /// the integer representation of enums.
538        pub fn name(&self) -> std::option::Option<&str> {
539            match self {
540                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
541                Self::Running => std::option::Option::Some("RUNNING"),
542                Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
543                Self::Cancelled => std::option::Option::Some("CANCELLED"),
544                Self::Failed => std::option::Option::Some("FAILED"),
545                Self::UnknownValue(u) => u.0.name(),
546            }
547        }
548    }
549
550    impl std::default::Default for State {
551        fn default() -> Self {
552            use std::convert::From;
553            Self::from(0)
554        }
555    }
556
557    impl std::fmt::Display for State {
558        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
559            wkt::internal::display_enum(f, self.name(), self.value())
560        }
561    }
562
563    impl std::convert::From<i32> for State {
564        fn from(value: i32) -> Self {
565            match value {
566                0 => Self::Unspecified,
567                1 => Self::Running,
568                2 => Self::Succeeded,
569                3 => Self::Cancelled,
570                4 => Self::Failed,
571                _ => Self::UnknownValue(state::UnknownValue(
572                    wkt::internal::UnknownEnumValue::Integer(value),
573                )),
574            }
575        }
576    }
577
578    impl std::convert::From<&str> for State {
579        fn from(value: &str) -> Self {
580            use std::string::ToString;
581            match value {
582                "STATE_UNSPECIFIED" => Self::Unspecified,
583                "RUNNING" => Self::Running,
584                "SUCCEEDED" => Self::Succeeded,
585                "CANCELLED" => Self::Cancelled,
586                "FAILED" => Self::Failed,
587                _ => Self::UnknownValue(state::UnknownValue(
588                    wkt::internal::UnknownEnumValue::String(value.to_string()),
589                )),
590            }
591        }
592    }
593
594    impl serde::ser::Serialize for State {
595        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
596        where
597            S: serde::Serializer,
598        {
599            match self {
600                Self::Unspecified => serializer.serialize_i32(0),
601                Self::Running => serializer.serialize_i32(1),
602                Self::Succeeded => serializer.serialize_i32(2),
603                Self::Cancelled => serializer.serialize_i32(3),
604                Self::Failed => serializer.serialize_i32(4),
605                Self::UnknownValue(u) => u.0.serialize(serializer),
606            }
607        }
608    }
609
610    impl<'de> serde::de::Deserialize<'de> for State {
611        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
612        where
613            D: serde::Deserializer<'de>,
614        {
615            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
616                ".google.cloud.optimization.v1.AsyncModelMetadata.State",
617            ))
618        }
619    }
620}
621
622/// Request to be given to a tour optimization solver which defines the
623/// shipment model to solve as well as optimization parameters.
624#[derive(Clone, Default, PartialEq)]
625#[non_exhaustive]
626pub struct OptimizeToursRequest {
627    /// Required. Target project and location to make a call.
628    ///
629    /// Format: `projects/{project-id}/locations/{location-id}`.
630    ///
631    /// If no location is specified, a region will be chosen automatically.
632    pub parent: std::string::String,
633
634    /// If this timeout is set, the server returns a response before the timeout
635    /// period has elapsed or the server deadline for synchronous requests is
636    /// reached, whichever is sooner.
637    ///
638    /// For asynchronous requests, the server will generate a solution (if
639    /// possible) before the timeout has elapsed.
640    pub timeout: std::option::Option<wkt::Duration>,
641
642    /// Shipment model to solve.
643    pub model: std::option::Option<crate::model::ShipmentModel>,
644
645    /// By default, the solving mode is `DEFAULT_SOLVE` (0).
646    pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
647
648    /// Search mode used to solve the request.
649    pub search_mode: crate::model::optimize_tours_request::SearchMode,
650
651    /// Guide the optimization algorithm in finding a first solution that is
652    /// similar to a previous solution.
653    ///
654    /// The model is constrained when the first solution is built.
655    /// Any shipments not performed on a route are implicitly skipped in the first
656    /// solution, but they may be performed in successive solutions.
657    ///
658    /// The solution must satisfy some basic validity assumptions:
659    ///
660    /// * for all routes, `vehicle_index` must be in range and not be duplicated.
661    /// * for all visits, `shipment_index` and `visit_request_index` must be
662    ///   in range.
663    /// * a shipment may only be referenced on one route.
664    /// * the pickup of a pickup-delivery shipment must be performed before
665    ///   the delivery.
666    /// * no more than one pickup alternative or delivery alternative of
667    ///   a shipment may be performed.
668    /// * for all routes, times are increasing (i.e., `vehicle_start_time
669    ///   <= visits[0].start_time <= visits[1].start_time ...
670    ///   <= vehicle_end_time`).
671    /// * a shipment may only be performed on a vehicle that is allowed. A
672    ///   vehicle is allowed if
673    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
674    ///   is empty or its `vehicle_index` is included in
675    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
676    ///
677    /// If the injected solution is not feasible, a validation error is not
678    /// necessarily returned and an error indicating infeasibility may be returned
679    /// instead.
680    ///
681    /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
682    pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
683
684    /// Constrain the optimization algorithm to find a final solution that is
685    /// similar to a previous solution. For example, this may be used to freeze
686    /// portions of routes which have already been completed or which are to be
687    /// completed but must not be modified.
688    ///
689    /// If the injected solution is not feasible, a validation error is not
690    /// necessarily returned and an error indicating infeasibility may be returned
691    /// instead.
692    pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
693
694    /// If non-empty, the given routes will be refreshed, without modifying their
695    /// underlying sequence of visits or travel times: only other details will be
696    /// updated. This does not solve the model.
697    ///
698    /// As of 2020/11, this only populates the polylines of non-empty routes and
699    /// requires that `populate_polylines` is true.
700    ///
701    /// The `route_polyline` fields of the passed-in routes may be inconsistent
702    /// with route `transitions`.
703    ///
704    /// This field must not be used together with `injected_first_solution_routes`
705    /// or `injected_solution_constraint`.
706    ///
707    /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
708    /// Polylines are still populated between all visits in all non-empty routes
709    /// regardless of whether the related shipments or vehicles are ignored.
710    pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
711
712    /// If true:
713    ///
714    /// * uses
715    ///   [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
716    ///   instead of `vehicle_index` to
717    ///   match routes in an injected solution with vehicles in the request;
718    ///   reuses the mapping of original
719    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
720    ///   to new
721    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
722    ///   to update
723    ///   [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
724    ///   if non-empty, but the mapping must be unambiguous (i.e., multiple
725    ///   `ShipmentRoute`s must not share the same original `vehicle_index`).
726    /// * uses
727    ///   [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
728    ///   instead of `shipment_index`
729    ///   to match visits in an injected solution with shipments in the request;
730    /// * uses
731    ///   [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
732    ///   instead of
733    ///   [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
734    ///   to
735    ///   match skipped shipments in the injected solution with request
736    ///   shipments.
737    ///
738    /// This interpretation applies to the `injected_first_solution_routes`,
739    /// `injected_solution_constraint`, and `refresh_details_routes` fields.
740    /// It can be used when shipment or vehicle indices in the request have
741    /// changed since the solution was created, perhaps because shipments or
742    /// vehicles have been removed from or added to the request.
743    ///
744    /// If true, labels in the following categories must appear at most once in
745    /// their category:
746    ///
747    /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
748    ///   request;
749    /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
750    ///   request;
751    /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
752    /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
753    ///   the injected solution (except pickup/delivery visit pairs, whose
754    ///   `shipment_label` must appear twice).
755    ///
756    /// If a `vehicle_label` in the injected solution does not correspond to a
757    /// request vehicle, the corresponding route is removed from the solution
758    /// along with its visits. If a `shipment_label` in the injected solution does
759    /// not correspond to a request shipment, the corresponding visit is removed
760    /// from the solution. If a
761    /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
762    /// in the injected solution does not correspond to a request shipment, the
763    /// `SkippedShipment` is removed from the solution.
764    ///
765    /// Removing route visits or entire routes from an injected solution may
766    /// have an effect on the implied constraints, which may lead to change in
767    /// solution, validation errors, or infeasibility.
768    ///
769    /// NOTE: The caller must ensure that each
770    /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
771    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
772    /// identifies a vehicle (resp. shipment) entity used across the two relevant
773    /// requests: the past request that produced the `OptimizeToursResponse` used
774    /// in the injected solution and the current request that includes the injected
775    /// solution. The uniqueness checks described above are not enough to guarantee
776    /// this requirement.
777    ///
778    /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
779    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
780    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
781    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
782    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
783    /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
784    /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
785    /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
786    pub interpret_injected_solutions_using_labels: bool,
787
788    /// Consider traffic estimation in calculating `ShipmentRoute` fields
789    /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
790    /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
791    /// and `vehicle_end_time`; in setting the
792    /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
793    /// field, and in calculating the
794    /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
795    /// field.
796    ///
797    /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
798    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
799    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
800    /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
801    pub consider_road_traffic: bool,
802
803    /// If true, polylines will be populated in response `ShipmentRoute`s.
804    pub populate_polylines: bool,
805
806    /// If true, polylines will be populated in response
807    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
808    /// Note that in this case, the polylines will also be populated in the
809    /// deprecated `travel_steps`.
810    ///
811    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
812    pub populate_transition_polylines: bool,
813
814    /// If this is set, then the request can have a deadline
815    /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
816    /// Otherwise, the maximum deadline is only 30 minutes.
817    /// Note that long-lived requests have a significantly larger (but still small)
818    /// risk of interruption.
819    pub allow_large_deadline_despite_interruption_risk: bool,
820
821    /// If true, travel distances will be computed using geodesic distances instead
822    /// of Google Maps distances, and travel times will be computed using geodesic
823    /// distances with a speed defined by `geodesic_meters_per_second`.
824    pub use_geodesic_distances: bool,
825
826    /// When `use_geodesic_distances` is true, this field must be set and defines
827    /// the speed applied to compute travel times. Its value must be at least 1.0
828    /// meters/seconds.
829    pub geodesic_meters_per_second: std::option::Option<f64>,
830
831    /// Truncates the number of validation errors returned. These errors are
832    /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
833    /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
834    /// unless solving_mode=VALIDATE_ONLY: see the
835    /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
836    /// field.
837    /// This defaults to 100 and is capped at 10,000.
838    ///
839    /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
840    pub max_validation_errors: std::option::Option<i32>,
841
842    /// Label that may be used to identify this request, reported back in the
843    /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
844    ///
845    /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
846    pub label: std::string::String,
847
848    /// Deprecated: Use
849    /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
850    /// instead. If true, polylines will be populated in response
851    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
852    /// Note that in this case, the polylines will also be populated in the
853    /// deprecated `travel_steps`.
854    ///
855    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
856    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
857    #[deprecated]
858    pub populate_travel_step_polylines: bool,
859
860    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
861}
862
863impl OptimizeToursRequest {
864    pub fn new() -> Self {
865        std::default::Default::default()
866    }
867
868    /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
869    ///
870    /// # Example
871    /// ```ignore,no_run
872    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
873    /// let x = OptimizeToursRequest::new().set_parent("example");
874    /// ```
875    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
876        self.parent = v.into();
877        self
878    }
879
880    /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
881    ///
882    /// # Example
883    /// ```ignore,no_run
884    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
885    /// use wkt::Duration;
886    /// let x = OptimizeToursRequest::new().set_timeout(Duration::default()/* use setters */);
887    /// ```
888    pub fn set_timeout<T>(mut self, v: T) -> Self
889    where
890        T: std::convert::Into<wkt::Duration>,
891    {
892        self.timeout = std::option::Option::Some(v.into());
893        self
894    }
895
896    /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
897    ///
898    /// # Example
899    /// ```ignore,no_run
900    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
901    /// use wkt::Duration;
902    /// let x = OptimizeToursRequest::new().set_or_clear_timeout(Some(Duration::default()/* use setters */));
903    /// let x = OptimizeToursRequest::new().set_or_clear_timeout(None::<Duration>);
904    /// ```
905    pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
906    where
907        T: std::convert::Into<wkt::Duration>,
908    {
909        self.timeout = v.map(|x| x.into());
910        self
911    }
912
913    /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
914    ///
915    /// # Example
916    /// ```ignore,no_run
917    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
918    /// use google_cloud_optimization_v1::model::ShipmentModel;
919    /// let x = OptimizeToursRequest::new().set_model(ShipmentModel::default()/* use setters */);
920    /// ```
921    pub fn set_model<T>(mut self, v: T) -> Self
922    where
923        T: std::convert::Into<crate::model::ShipmentModel>,
924    {
925        self.model = std::option::Option::Some(v.into());
926        self
927    }
928
929    /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
930    ///
931    /// # Example
932    /// ```ignore,no_run
933    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
934    /// use google_cloud_optimization_v1::model::ShipmentModel;
935    /// let x = OptimizeToursRequest::new().set_or_clear_model(Some(ShipmentModel::default()/* use setters */));
936    /// let x = OptimizeToursRequest::new().set_or_clear_model(None::<ShipmentModel>);
937    /// ```
938    pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
939    where
940        T: std::convert::Into<crate::model::ShipmentModel>,
941    {
942        self.model = v.map(|x| x.into());
943        self
944    }
945
946    /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
947    ///
948    /// # Example
949    /// ```ignore,no_run
950    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
951    /// use google_cloud_optimization_v1::model::optimize_tours_request::SolvingMode;
952    /// let x0 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::ValidateOnly);
953    /// let x1 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::DetectSomeInfeasibleShipments);
954    /// ```
955    pub fn set_solving_mode<
956        T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
957    >(
958        mut self,
959        v: T,
960    ) -> Self {
961        self.solving_mode = v.into();
962        self
963    }
964
965    /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
966    ///
967    /// # Example
968    /// ```ignore,no_run
969    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
970    /// use google_cloud_optimization_v1::model::optimize_tours_request::SearchMode;
971    /// let x0 = OptimizeToursRequest::new().set_search_mode(SearchMode::ReturnFast);
972    /// let x1 = OptimizeToursRequest::new().set_search_mode(SearchMode::ConsumeAllAvailableTime);
973    /// ```
974    pub fn set_search_mode<
975        T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
976    >(
977        mut self,
978        v: T,
979    ) -> Self {
980        self.search_mode = v.into();
981        self
982    }
983
984    /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
985    ///
986    /// # Example
987    /// ```ignore,no_run
988    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
989    /// use google_cloud_optimization_v1::model::ShipmentRoute;
990    /// let x = OptimizeToursRequest::new()
991    ///     .set_injected_first_solution_routes([
992    ///         ShipmentRoute::default()/* use setters */,
993    ///         ShipmentRoute::default()/* use (different) setters */,
994    ///     ]);
995    /// ```
996    pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
997    where
998        T: std::iter::IntoIterator<Item = V>,
999        V: std::convert::Into<crate::model::ShipmentRoute>,
1000    {
1001        use std::iter::Iterator;
1002        self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
1003        self
1004    }
1005
1006    /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1007    ///
1008    /// # Example
1009    /// ```ignore,no_run
1010    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1011    /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1012    /// let x = OptimizeToursRequest::new().set_injected_solution_constraint(InjectedSolutionConstraint::default()/* use setters */);
1013    /// ```
1014    pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
1015    where
1016        T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1017    {
1018        self.injected_solution_constraint = std::option::Option::Some(v.into());
1019        self
1020    }
1021
1022    /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1023    ///
1024    /// # Example
1025    /// ```ignore,no_run
1026    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1027    /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1028    /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(Some(InjectedSolutionConstraint::default()/* use setters */));
1029    /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(None::<InjectedSolutionConstraint>);
1030    /// ```
1031    pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
1032    where
1033        T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1034    {
1035        self.injected_solution_constraint = v.map(|x| x.into());
1036        self
1037    }
1038
1039    /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
1040    ///
1041    /// # Example
1042    /// ```ignore,no_run
1043    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1044    /// use google_cloud_optimization_v1::model::ShipmentRoute;
1045    /// let x = OptimizeToursRequest::new()
1046    ///     .set_refresh_details_routes([
1047    ///         ShipmentRoute::default()/* use setters */,
1048    ///         ShipmentRoute::default()/* use (different) setters */,
1049    ///     ]);
1050    /// ```
1051    pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
1052    where
1053        T: std::iter::IntoIterator<Item = V>,
1054        V: std::convert::Into<crate::model::ShipmentRoute>,
1055    {
1056        use std::iter::Iterator;
1057        self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
1058        self
1059    }
1060
1061    /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
1062    ///
1063    /// # Example
1064    /// ```ignore,no_run
1065    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1066    /// let x = OptimizeToursRequest::new().set_interpret_injected_solutions_using_labels(true);
1067    /// ```
1068    pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
1069        mut self,
1070        v: T,
1071    ) -> Self {
1072        self.interpret_injected_solutions_using_labels = v.into();
1073        self
1074    }
1075
1076    /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
1077    ///
1078    /// # Example
1079    /// ```ignore,no_run
1080    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1081    /// let x = OptimizeToursRequest::new().set_consider_road_traffic(true);
1082    /// ```
1083    pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1084        self.consider_road_traffic = v.into();
1085        self
1086    }
1087
1088    /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
1089    ///
1090    /// # Example
1091    /// ```ignore,no_run
1092    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1093    /// let x = OptimizeToursRequest::new().set_populate_polylines(true);
1094    /// ```
1095    pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1096        self.populate_polylines = v.into();
1097        self
1098    }
1099
1100    /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
1101    ///
1102    /// # Example
1103    /// ```ignore,no_run
1104    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1105    /// let x = OptimizeToursRequest::new().set_populate_transition_polylines(true);
1106    /// ```
1107    pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1108        self.populate_transition_polylines = v.into();
1109        self
1110    }
1111
1112    /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
1113    ///
1114    /// # Example
1115    /// ```ignore,no_run
1116    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1117    /// let x = OptimizeToursRequest::new().set_allow_large_deadline_despite_interruption_risk(true);
1118    /// ```
1119    pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1120        mut self,
1121        v: T,
1122    ) -> Self {
1123        self.allow_large_deadline_despite_interruption_risk = v.into();
1124        self
1125    }
1126
1127    /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
1128    ///
1129    /// # Example
1130    /// ```ignore,no_run
1131    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1132    /// let x = OptimizeToursRequest::new().set_use_geodesic_distances(true);
1133    /// ```
1134    pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1135        self.use_geodesic_distances = v.into();
1136        self
1137    }
1138
1139    /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1140    ///
1141    /// # Example
1142    /// ```ignore,no_run
1143    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1144    /// let x = OptimizeToursRequest::new().set_geodesic_meters_per_second(42.0);
1145    /// ```
1146    pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1147    where
1148        T: std::convert::Into<f64>,
1149    {
1150        self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1151        self
1152    }
1153
1154    /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1155    ///
1156    /// # Example
1157    /// ```ignore,no_run
1158    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1159    /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(Some(42.0));
1160    /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(None::<f32>);
1161    /// ```
1162    pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1163    where
1164        T: std::convert::Into<f64>,
1165    {
1166        self.geodesic_meters_per_second = v.map(|x| x.into());
1167        self
1168    }
1169
1170    /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1171    ///
1172    /// # Example
1173    /// ```ignore,no_run
1174    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1175    /// let x = OptimizeToursRequest::new().set_max_validation_errors(42);
1176    /// ```
1177    pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1178    where
1179        T: std::convert::Into<i32>,
1180    {
1181        self.max_validation_errors = std::option::Option::Some(v.into());
1182        self
1183    }
1184
1185    /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1186    ///
1187    /// # Example
1188    /// ```ignore,no_run
1189    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1190    /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(Some(42));
1191    /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(None::<i32>);
1192    /// ```
1193    pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1194    where
1195        T: std::convert::Into<i32>,
1196    {
1197        self.max_validation_errors = v.map(|x| x.into());
1198        self
1199    }
1200
1201    /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
1202    ///
1203    /// # Example
1204    /// ```ignore,no_run
1205    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1206    /// let x = OptimizeToursRequest::new().set_label("example");
1207    /// ```
1208    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1209        self.label = v.into();
1210        self
1211    }
1212
1213    /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
1214    ///
1215    /// # Example
1216    /// ```ignore,no_run
1217    /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1218    /// let x = OptimizeToursRequest::new().set_populate_travel_step_polylines(true);
1219    /// ```
1220    #[deprecated]
1221    pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1222        self.populate_travel_step_polylines = v.into();
1223        self
1224    }
1225}
1226
1227impl wkt::message::Message for OptimizeToursRequest {
1228    fn typename() -> &'static str {
1229        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
1230    }
1231}
1232
1233/// Defines additional types related to [OptimizeToursRequest].
1234pub mod optimize_tours_request {
1235    #[allow(unused_imports)]
1236    use super::*;
1237
1238    /// Defines how the solver should handle the request. In all modes but
1239    /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
1240    /// `INVALID_REQUEST` error. See
1241    /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
1242    /// to cap the number of errors returned.
1243    ///
1244    /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
1245    ///
1246    /// # Working with unknown values
1247    ///
1248    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1249    /// additional enum variants at any time. Adding new variants is not considered
1250    /// a breaking change. Applications should write their code in anticipation of:
1251    ///
1252    /// - New values appearing in future releases of the client library, **and**
1253    /// - New values received dynamically, without application changes.
1254    ///
1255    /// Please consult the [Working with enums] section in the user guide for some
1256    /// guidelines.
1257    ///
1258    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1259    #[derive(Clone, Debug, PartialEq)]
1260    #[non_exhaustive]
1261    pub enum SolvingMode {
1262        /// Solve the model.
1263        DefaultSolve,
1264        /// Only validates the model without solving it: populates as many
1265        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1266        /// as possible.
1267        ///
1268        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1269        ValidateOnly,
1270        /// Only populates
1271        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1272        /// or
1273        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
1274        /// and doesn't actually solve the rest of the request (`status` and `routes`
1275        /// are unset in the response).
1276        /// If infeasibilities in `injected_solution_constraint` routes are detected
1277        /// they are populated in the
1278        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1279        /// field and
1280        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
1281        /// is left empty.
1282        ///
1283        /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
1284        /// ones that are detected as infeasible during preprocessing.
1285        ///
1286        /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
1287        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1288        DetectSomeInfeasibleShipments,
1289        /// If set, the enum was initialized with an unknown value.
1290        ///
1291        /// Applications can examine the value using [SolvingMode::value] or
1292        /// [SolvingMode::name].
1293        UnknownValue(solving_mode::UnknownValue),
1294    }
1295
1296    #[doc(hidden)]
1297    pub mod solving_mode {
1298        #[allow(unused_imports)]
1299        use super::*;
1300        #[derive(Clone, Debug, PartialEq)]
1301        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1302    }
1303
1304    impl SolvingMode {
1305        /// Gets the enum value.
1306        ///
1307        /// Returns `None` if the enum contains an unknown value deserialized from
1308        /// the string representation of enums.
1309        pub fn value(&self) -> std::option::Option<i32> {
1310            match self {
1311                Self::DefaultSolve => std::option::Option::Some(0),
1312                Self::ValidateOnly => std::option::Option::Some(1),
1313                Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
1314                Self::UnknownValue(u) => u.0.value(),
1315            }
1316        }
1317
1318        /// Gets the enum value as a string.
1319        ///
1320        /// Returns `None` if the enum contains an unknown value deserialized from
1321        /// the integer representation of enums.
1322        pub fn name(&self) -> std::option::Option<&str> {
1323            match self {
1324                Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
1325                Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
1326                Self::DetectSomeInfeasibleShipments => {
1327                    std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
1328                }
1329                Self::UnknownValue(u) => u.0.name(),
1330            }
1331        }
1332    }
1333
1334    impl std::default::Default for SolvingMode {
1335        fn default() -> Self {
1336            use std::convert::From;
1337            Self::from(0)
1338        }
1339    }
1340
1341    impl std::fmt::Display for SolvingMode {
1342        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1343            wkt::internal::display_enum(f, self.name(), self.value())
1344        }
1345    }
1346
1347    impl std::convert::From<i32> for SolvingMode {
1348        fn from(value: i32) -> Self {
1349            match value {
1350                0 => Self::DefaultSolve,
1351                1 => Self::ValidateOnly,
1352                2 => Self::DetectSomeInfeasibleShipments,
1353                _ => Self::UnknownValue(solving_mode::UnknownValue(
1354                    wkt::internal::UnknownEnumValue::Integer(value),
1355                )),
1356            }
1357        }
1358    }
1359
1360    impl std::convert::From<&str> for SolvingMode {
1361        fn from(value: &str) -> Self {
1362            use std::string::ToString;
1363            match value {
1364                "DEFAULT_SOLVE" => Self::DefaultSolve,
1365                "VALIDATE_ONLY" => Self::ValidateOnly,
1366                "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
1367                _ => Self::UnknownValue(solving_mode::UnknownValue(
1368                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1369                )),
1370            }
1371        }
1372    }
1373
1374    impl serde::ser::Serialize for SolvingMode {
1375        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1376        where
1377            S: serde::Serializer,
1378        {
1379            match self {
1380                Self::DefaultSolve => serializer.serialize_i32(0),
1381                Self::ValidateOnly => serializer.serialize_i32(1),
1382                Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
1383                Self::UnknownValue(u) => u.0.serialize(serializer),
1384            }
1385        }
1386    }
1387
1388    impl<'de> serde::de::Deserialize<'de> for SolvingMode {
1389        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1390        where
1391            D: serde::Deserializer<'de>,
1392        {
1393            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
1394                ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
1395            ))
1396        }
1397    }
1398
1399    /// Mode defining the behavior of the search, trading off latency versus
1400    /// solution quality. In all modes, the global request deadline is enforced.
1401    ///
1402    /// # Working with unknown values
1403    ///
1404    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1405    /// additional enum variants at any time. Adding new variants is not considered
1406    /// a breaking change. Applications should write their code in anticipation of:
1407    ///
1408    /// - New values appearing in future releases of the client library, **and**
1409    /// - New values received dynamically, without application changes.
1410    ///
1411    /// Please consult the [Working with enums] section in the user guide for some
1412    /// guidelines.
1413    ///
1414    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1415    #[derive(Clone, Debug, PartialEq)]
1416    #[non_exhaustive]
1417    pub enum SearchMode {
1418        /// Unspecified search mode, equivalent to `RETURN_FAST`.
1419        Unspecified,
1420        /// Stop the search after finding the first good solution.
1421        ReturnFast,
1422        /// Spend all the available time to search for better solutions.
1423        ConsumeAllAvailableTime,
1424        /// If set, the enum was initialized with an unknown value.
1425        ///
1426        /// Applications can examine the value using [SearchMode::value] or
1427        /// [SearchMode::name].
1428        UnknownValue(search_mode::UnknownValue),
1429    }
1430
1431    #[doc(hidden)]
1432    pub mod search_mode {
1433        #[allow(unused_imports)]
1434        use super::*;
1435        #[derive(Clone, Debug, PartialEq)]
1436        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1437    }
1438
1439    impl SearchMode {
1440        /// Gets the enum value.
1441        ///
1442        /// Returns `None` if the enum contains an unknown value deserialized from
1443        /// the string representation of enums.
1444        pub fn value(&self) -> std::option::Option<i32> {
1445            match self {
1446                Self::Unspecified => std::option::Option::Some(0),
1447                Self::ReturnFast => std::option::Option::Some(1),
1448                Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
1449                Self::UnknownValue(u) => u.0.value(),
1450            }
1451        }
1452
1453        /// Gets the enum value as a string.
1454        ///
1455        /// Returns `None` if the enum contains an unknown value deserialized from
1456        /// the integer representation of enums.
1457        pub fn name(&self) -> std::option::Option<&str> {
1458            match self {
1459                Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
1460                Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
1461                Self::ConsumeAllAvailableTime => {
1462                    std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
1463                }
1464                Self::UnknownValue(u) => u.0.name(),
1465            }
1466        }
1467    }
1468
1469    impl std::default::Default for SearchMode {
1470        fn default() -> Self {
1471            use std::convert::From;
1472            Self::from(0)
1473        }
1474    }
1475
1476    impl std::fmt::Display for SearchMode {
1477        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1478            wkt::internal::display_enum(f, self.name(), self.value())
1479        }
1480    }
1481
1482    impl std::convert::From<i32> for SearchMode {
1483        fn from(value: i32) -> Self {
1484            match value {
1485                0 => Self::Unspecified,
1486                1 => Self::ReturnFast,
1487                2 => Self::ConsumeAllAvailableTime,
1488                _ => Self::UnknownValue(search_mode::UnknownValue(
1489                    wkt::internal::UnknownEnumValue::Integer(value),
1490                )),
1491            }
1492        }
1493    }
1494
1495    impl std::convert::From<&str> for SearchMode {
1496        fn from(value: &str) -> Self {
1497            use std::string::ToString;
1498            match value {
1499                "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
1500                "RETURN_FAST" => Self::ReturnFast,
1501                "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
1502                _ => Self::UnknownValue(search_mode::UnknownValue(
1503                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1504                )),
1505            }
1506        }
1507    }
1508
1509    impl serde::ser::Serialize for SearchMode {
1510        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1511        where
1512            S: serde::Serializer,
1513        {
1514            match self {
1515                Self::Unspecified => serializer.serialize_i32(0),
1516                Self::ReturnFast => serializer.serialize_i32(1),
1517                Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
1518                Self::UnknownValue(u) => u.0.serialize(serializer),
1519            }
1520        }
1521    }
1522
1523    impl<'de> serde::de::Deserialize<'de> for SearchMode {
1524        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1525        where
1526            D: serde::Deserializer<'de>,
1527        {
1528            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
1529                ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
1530            ))
1531        }
1532    }
1533}
1534
1535/// Response after solving a tour optimization problem containing the routes
1536/// followed by each vehicle, the shipments which have been skipped and the
1537/// overall cost of the solution.
1538#[derive(Clone, Default, PartialEq)]
1539#[non_exhaustive]
1540pub struct OptimizeToursResponse {
1541    /// Routes computed for each vehicle; the i-th route corresponds to the i-th
1542    /// vehicle in the model.
1543    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
1544
1545    /// Copy of the
1546    /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
1547    /// if a label was specified in the request.
1548    ///
1549    /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
1550    pub request_label: std::string::String,
1551
1552    /// The list of all shipments skipped.
1553    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
1554
1555    /// List of all the validation errors that we were able to detect
1556    /// independently. See the "MULTIPLE ERRORS" explanation for the
1557    /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
1558    /// message.
1559    ///
1560    /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
1561    pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
1562
1563    /// Duration, distance and usage metrics for this solution.
1564    pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
1565
1566    /// Deprecated: Use
1567    /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
1568    /// instead. Total cost of the solution. This takes into account all costs:
1569    /// costs per per hour and travel hour, fixed vehicle costs, unperformed
1570    /// shipment penalty costs, global duration cost, etc.
1571    ///
1572    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
1573    #[deprecated]
1574    pub total_cost: f64,
1575
1576    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1577}
1578
1579impl OptimizeToursResponse {
1580    pub fn new() -> Self {
1581        std::default::Default::default()
1582    }
1583
1584    /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
1585    ///
1586    /// # Example
1587    /// ```ignore,no_run
1588    /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1589    /// use google_cloud_optimization_v1::model::ShipmentRoute;
1590    /// let x = OptimizeToursResponse::new()
1591    ///     .set_routes([
1592    ///         ShipmentRoute::default()/* use setters */,
1593    ///         ShipmentRoute::default()/* use (different) setters */,
1594    ///     ]);
1595    /// ```
1596    pub fn set_routes<T, V>(mut self, v: T) -> Self
1597    where
1598        T: std::iter::IntoIterator<Item = V>,
1599        V: std::convert::Into<crate::model::ShipmentRoute>,
1600    {
1601        use std::iter::Iterator;
1602        self.routes = v.into_iter().map(|i| i.into()).collect();
1603        self
1604    }
1605
1606    /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
1607    ///
1608    /// # Example
1609    /// ```ignore,no_run
1610    /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1611    /// let x = OptimizeToursResponse::new().set_request_label("example");
1612    /// ```
1613    pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1614        self.request_label = v.into();
1615        self
1616    }
1617
1618    /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
1619    ///
1620    /// # Example
1621    /// ```ignore,no_run
1622    /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1623    /// use google_cloud_optimization_v1::model::SkippedShipment;
1624    /// let x = OptimizeToursResponse::new()
1625    ///     .set_skipped_shipments([
1626    ///         SkippedShipment::default()/* use setters */,
1627    ///         SkippedShipment::default()/* use (different) setters */,
1628    ///     ]);
1629    /// ```
1630    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
1631    where
1632        T: std::iter::IntoIterator<Item = V>,
1633        V: std::convert::Into<crate::model::SkippedShipment>,
1634    {
1635        use std::iter::Iterator;
1636        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
1637        self
1638    }
1639
1640    /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
1641    ///
1642    /// # Example
1643    /// ```ignore,no_run
1644    /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1645    /// use google_cloud_optimization_v1::model::OptimizeToursValidationError;
1646    /// let x = OptimizeToursResponse::new()
1647    ///     .set_validation_errors([
1648    ///         OptimizeToursValidationError::default()/* use setters */,
1649    ///         OptimizeToursValidationError::default()/* use (different) setters */,
1650    ///     ]);
1651    /// ```
1652    pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
1653    where
1654        T: std::iter::IntoIterator<Item = V>,
1655        V: std::convert::Into<crate::model::OptimizeToursValidationError>,
1656    {
1657        use std::iter::Iterator;
1658        self.validation_errors = v.into_iter().map(|i| i.into()).collect();
1659        self
1660    }
1661
1662    /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1663    ///
1664    /// # Example
1665    /// ```ignore,no_run
1666    /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1667    /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1668    /// let x = OptimizeToursResponse::new().set_metrics(Metrics::default()/* use setters */);
1669    /// ```
1670    pub fn set_metrics<T>(mut self, v: T) -> Self
1671    where
1672        T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1673    {
1674        self.metrics = std::option::Option::Some(v.into());
1675        self
1676    }
1677
1678    /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1679    ///
1680    /// # Example
1681    /// ```ignore,no_run
1682    /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1683    /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1684    /// let x = OptimizeToursResponse::new().set_or_clear_metrics(Some(Metrics::default()/* use setters */));
1685    /// let x = OptimizeToursResponse::new().set_or_clear_metrics(None::<Metrics>);
1686    /// ```
1687    pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1688    where
1689        T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1690    {
1691        self.metrics = v.map(|x| x.into());
1692        self
1693    }
1694
1695    /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
1696    ///
1697    /// # Example
1698    /// ```ignore,no_run
1699    /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1700    /// let x = OptimizeToursResponse::new().set_total_cost(42.0);
1701    /// ```
1702    #[deprecated]
1703    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1704        self.total_cost = v.into();
1705        self
1706    }
1707}
1708
1709impl wkt::message::Message for OptimizeToursResponse {
1710    fn typename() -> &'static str {
1711        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
1712    }
1713}
1714
1715/// Defines additional types related to [OptimizeToursResponse].
1716pub mod optimize_tours_response {
1717    #[allow(unused_imports)]
1718    use super::*;
1719
1720    /// Overall metrics, aggregated over all routes.
1721    #[derive(Clone, Default, PartialEq)]
1722    #[non_exhaustive]
1723    pub struct Metrics {
1724        /// Aggregated over the routes. Each metric is the sum (or max, for loads)
1725        /// over all
1726        /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
1727        /// fields of the same name.
1728        ///
1729        /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
1730        pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
1731
1732        /// Number of mandatory shipments skipped.
1733        pub skipped_mandatory_shipment_count: i32,
1734
1735        /// Number of vehicles used. Note: if a vehicle route is empty and
1736        /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
1737        /// is true, the vehicle is considered used.
1738        ///
1739        /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
1740        pub used_vehicle_count: i32,
1741
1742        /// The earliest start time for a used vehicle, computed as the minimum over
1743        /// all used vehicles of
1744        /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
1745        ///
1746        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
1747        pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
1748
1749        /// The latest end time for a used vehicle, computed as the maximum over all
1750        /// used vehicles of
1751        /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
1752        ///
1753        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
1754        pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
1755
1756        /// Cost of the solution, broken down by cost-related request fields.
1757        /// The keys are proto paths, relative to the input OptimizeToursRequest,
1758        /// e.g. "model.shipments.pickups.cost", and the values are the total cost
1759        /// generated by the corresponding cost field, aggregated over the whole
1760        /// solution. In other words, costs["model.shipments.pickups.cost"] is the
1761        /// sum of all pickup costs over the solution. All costs defined in the model
1762        /// are reported in detail here with the exception of costs related to
1763        /// TransitionAttributes that are only reported in an aggregated way as of
1764        /// 2022/01.
1765        pub costs: std::collections::HashMap<std::string::String, f64>,
1766
1767        /// Total cost of the solution. The sum of all values in the costs map.
1768        pub total_cost: f64,
1769
1770        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1771    }
1772
1773    impl Metrics {
1774        pub fn new() -> Self {
1775            std::default::Default::default()
1776        }
1777
1778        /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1779        ///
1780        /// # Example
1781        /// ```ignore,no_run
1782        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1783        /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1784        /// let x = Metrics::new().set_aggregated_route_metrics(AggregatedMetrics::default()/* use setters */);
1785        /// ```
1786        pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
1787        where
1788            T: std::convert::Into<crate::model::AggregatedMetrics>,
1789        {
1790            self.aggregated_route_metrics = std::option::Option::Some(v.into());
1791            self
1792        }
1793
1794        /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1795        ///
1796        /// # Example
1797        /// ```ignore,no_run
1798        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1799        /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1800        /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(Some(AggregatedMetrics::default()/* use setters */));
1801        /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(None::<AggregatedMetrics>);
1802        /// ```
1803        pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1804        where
1805            T: std::convert::Into<crate::model::AggregatedMetrics>,
1806        {
1807            self.aggregated_route_metrics = v.map(|x| x.into());
1808            self
1809        }
1810
1811        /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
1812        ///
1813        /// # Example
1814        /// ```ignore,no_run
1815        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1816        /// let x = Metrics::new().set_skipped_mandatory_shipment_count(42);
1817        /// ```
1818        pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
1819            mut self,
1820            v: T,
1821        ) -> Self {
1822            self.skipped_mandatory_shipment_count = v.into();
1823            self
1824        }
1825
1826        /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
1827        ///
1828        /// # Example
1829        /// ```ignore,no_run
1830        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1831        /// let x = Metrics::new().set_used_vehicle_count(42);
1832        /// ```
1833        pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1834            self.used_vehicle_count = v.into();
1835            self
1836        }
1837
1838        /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1839        ///
1840        /// # Example
1841        /// ```ignore,no_run
1842        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1843        /// use wkt::Timestamp;
1844        /// let x = Metrics::new().set_earliest_vehicle_start_time(Timestamp::default()/* use setters */);
1845        /// ```
1846        pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
1847        where
1848            T: std::convert::Into<wkt::Timestamp>,
1849        {
1850            self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
1851            self
1852        }
1853
1854        /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1855        ///
1856        /// # Example
1857        /// ```ignore,no_run
1858        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1859        /// use wkt::Timestamp;
1860        /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(Some(Timestamp::default()/* use setters */));
1861        /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(None::<Timestamp>);
1862        /// ```
1863        pub fn set_or_clear_earliest_vehicle_start_time<T>(
1864            mut self,
1865            v: std::option::Option<T>,
1866        ) -> Self
1867        where
1868            T: std::convert::Into<wkt::Timestamp>,
1869        {
1870            self.earliest_vehicle_start_time = v.map(|x| x.into());
1871            self
1872        }
1873
1874        /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1875        ///
1876        /// # Example
1877        /// ```ignore,no_run
1878        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1879        /// use wkt::Timestamp;
1880        /// let x = Metrics::new().set_latest_vehicle_end_time(Timestamp::default()/* use setters */);
1881        /// ```
1882        pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
1883        where
1884            T: std::convert::Into<wkt::Timestamp>,
1885        {
1886            self.latest_vehicle_end_time = std::option::Option::Some(v.into());
1887            self
1888        }
1889
1890        /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1891        ///
1892        /// # Example
1893        /// ```ignore,no_run
1894        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1895        /// use wkt::Timestamp;
1896        /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(Some(Timestamp::default()/* use setters */));
1897        /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(None::<Timestamp>);
1898        /// ```
1899        pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1900        where
1901            T: std::convert::Into<wkt::Timestamp>,
1902        {
1903            self.latest_vehicle_end_time = v.map(|x| x.into());
1904            self
1905        }
1906
1907        /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
1908        ///
1909        /// # Example
1910        /// ```ignore,no_run
1911        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1912        /// let x = Metrics::new().set_costs([
1913        ///     ("key0", 123.5),
1914        ///     ("key1", 456.5),
1915        /// ]);
1916        /// ```
1917        pub fn set_costs<T, K, V>(mut self, v: T) -> Self
1918        where
1919            T: std::iter::IntoIterator<Item = (K, V)>,
1920            K: std::convert::Into<std::string::String>,
1921            V: std::convert::Into<f64>,
1922        {
1923            use std::iter::Iterator;
1924            self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1925            self
1926        }
1927
1928        /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
1929        ///
1930        /// # Example
1931        /// ```ignore,no_run
1932        /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1933        /// let x = Metrics::new().set_total_cost(42.0);
1934        /// ```
1935        pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1936            self.total_cost = v.into();
1937            self
1938        }
1939    }
1940
1941    impl wkt::message::Message for Metrics {
1942        fn typename() -> &'static str {
1943            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
1944        }
1945    }
1946}
1947
1948/// Request to batch optimize tours as an asynchronous operation.
1949/// Each input file should contain one `OptimizeToursRequest`, and each output
1950/// file will contain one `OptimizeToursResponse`. The request contains
1951/// information to read/write and parse the files. All the input and output files
1952/// should be under the same project.
1953#[derive(Clone, Default, PartialEq)]
1954#[non_exhaustive]
1955pub struct BatchOptimizeToursRequest {
1956    /// Required. Target project and location to make a call.
1957    ///
1958    /// Format: `projects/{project-id}/locations/{location-id}`.
1959    ///
1960    /// If no location is specified, a region will be chosen automatically.
1961    pub parent: std::string::String,
1962
1963    /// Required. Input/Output information each purchase model, such as file paths
1964    /// and data formats.
1965    pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1966
1967    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1968}
1969
1970impl BatchOptimizeToursRequest {
1971    pub fn new() -> Self {
1972        std::default::Default::default()
1973    }
1974
1975    /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
1976    ///
1977    /// # Example
1978    /// ```ignore,no_run
1979    /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1980    /// let x = BatchOptimizeToursRequest::new().set_parent("example");
1981    /// ```
1982    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1983        self.parent = v.into();
1984        self
1985    }
1986
1987    /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
1988    ///
1989    /// # Example
1990    /// ```ignore,no_run
1991    /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1992    /// use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
1993    /// let x = BatchOptimizeToursRequest::new()
1994    ///     .set_model_configs([
1995    ///         AsyncModelConfig::default()/* use setters */,
1996    ///         AsyncModelConfig::default()/* use (different) setters */,
1997    ///     ]);
1998    /// ```
1999    pub fn set_model_configs<T, V>(mut self, v: T) -> Self
2000    where
2001        T: std::iter::IntoIterator<Item = V>,
2002        V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
2003    {
2004        use std::iter::Iterator;
2005        self.model_configs = v.into_iter().map(|i| i.into()).collect();
2006        self
2007    }
2008}
2009
2010impl wkt::message::Message for BatchOptimizeToursRequest {
2011    fn typename() -> &'static str {
2012        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
2013    }
2014}
2015
2016/// Defines additional types related to [BatchOptimizeToursRequest].
2017pub mod batch_optimize_tours_request {
2018    #[allow(unused_imports)]
2019    use super::*;
2020
2021    /// Information for solving one optimization model asynchronously.
2022    #[derive(Clone, Default, PartialEq)]
2023    #[non_exhaustive]
2024    pub struct AsyncModelConfig {
2025        /// User defined model name, can be used as alias by users to keep track of
2026        /// models.
2027        pub display_name: std::string::String,
2028
2029        /// Required. Information about the input model.
2030        pub input_config: std::option::Option<crate::model::InputConfig>,
2031
2032        /// Required. The desired output location information.
2033        pub output_config: std::option::Option<crate::model::OutputConfig>,
2034
2035        /// If this is set, the model will be solved in the checkpoint mode. In this
2036        /// mode, the input model can have a deadline longer than 30 mins without the
2037        /// risk of interruption. The model will be solved in multiple short-running
2038        /// stages. Each stage generates an intermediate checkpoint
2039        /// and stores it in the user's Cloud Storage buckets. The checkpoint
2040        /// mode should be preferred over
2041        /// allow_large_deadline_despite_interruption_risk since it prevents the risk
2042        /// of interruption.
2043        pub enable_checkpoints: bool,
2044
2045        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2046    }
2047
2048    impl AsyncModelConfig {
2049        pub fn new() -> Self {
2050            std::default::Default::default()
2051        }
2052
2053        /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
2054        ///
2055        /// # Example
2056        /// ```ignore,no_run
2057        /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2058        /// let x = AsyncModelConfig::new().set_display_name("example");
2059        /// ```
2060        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
2061            mut self,
2062            v: T,
2063        ) -> Self {
2064            self.display_name = v.into();
2065            self
2066        }
2067
2068        /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2069        ///
2070        /// # Example
2071        /// ```ignore,no_run
2072        /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2073        /// use google_cloud_optimization_v1::model::InputConfig;
2074        /// let x = AsyncModelConfig::new().set_input_config(InputConfig::default()/* use setters */);
2075        /// ```
2076        pub fn set_input_config<T>(mut self, v: T) -> Self
2077        where
2078            T: std::convert::Into<crate::model::InputConfig>,
2079        {
2080            self.input_config = std::option::Option::Some(v.into());
2081            self
2082        }
2083
2084        /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2085        ///
2086        /// # Example
2087        /// ```ignore,no_run
2088        /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2089        /// use google_cloud_optimization_v1::model::InputConfig;
2090        /// let x = AsyncModelConfig::new().set_or_clear_input_config(Some(InputConfig::default()/* use setters */));
2091        /// let x = AsyncModelConfig::new().set_or_clear_input_config(None::<InputConfig>);
2092        /// ```
2093        pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
2094        where
2095            T: std::convert::Into<crate::model::InputConfig>,
2096        {
2097            self.input_config = v.map(|x| x.into());
2098            self
2099        }
2100
2101        /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2102        ///
2103        /// # Example
2104        /// ```ignore,no_run
2105        /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2106        /// use google_cloud_optimization_v1::model::OutputConfig;
2107        /// let x = AsyncModelConfig::new().set_output_config(OutputConfig::default()/* use setters */);
2108        /// ```
2109        pub fn set_output_config<T>(mut self, v: T) -> Self
2110        where
2111            T: std::convert::Into<crate::model::OutputConfig>,
2112        {
2113            self.output_config = std::option::Option::Some(v.into());
2114            self
2115        }
2116
2117        /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2118        ///
2119        /// # Example
2120        /// ```ignore,no_run
2121        /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2122        /// use google_cloud_optimization_v1::model::OutputConfig;
2123        /// let x = AsyncModelConfig::new().set_or_clear_output_config(Some(OutputConfig::default()/* use setters */));
2124        /// let x = AsyncModelConfig::new().set_or_clear_output_config(None::<OutputConfig>);
2125        /// ```
2126        pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
2127        where
2128            T: std::convert::Into<crate::model::OutputConfig>,
2129        {
2130            self.output_config = v.map(|x| x.into());
2131            self
2132        }
2133
2134        /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
2135        ///
2136        /// # Example
2137        /// ```ignore,no_run
2138        /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2139        /// let x = AsyncModelConfig::new().set_enable_checkpoints(true);
2140        /// ```
2141        pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2142            self.enable_checkpoints = v.into();
2143            self
2144        }
2145    }
2146
2147    impl wkt::message::Message for AsyncModelConfig {
2148        fn typename() -> &'static str {
2149            "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
2150        }
2151    }
2152}
2153
2154/// Response to a `BatchOptimizeToursRequest`. This is returned in
2155/// the LRO Operation after the operation is complete.
2156#[derive(Clone, Default, PartialEq)]
2157#[non_exhaustive]
2158pub struct BatchOptimizeToursResponse {
2159    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2160}
2161
2162impl BatchOptimizeToursResponse {
2163    pub fn new() -> Self {
2164        std::default::Default::default()
2165    }
2166}
2167
2168impl wkt::message::Message for BatchOptimizeToursResponse {
2169    fn typename() -> &'static str {
2170        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
2171    }
2172}
2173
2174/// A shipment model contains a set of shipments which must be performed by a
2175/// set of vehicles, while minimizing the overall cost, which is the sum of:
2176///
2177/// * the cost of routing the vehicles (sum of cost per total time, cost per
2178///   travel time, and fixed cost over all vehicles).
2179/// * the unperformed shipment penalties.
2180/// * the cost of the global duration of the shipments
2181#[derive(Clone, Default, PartialEq)]
2182#[non_exhaustive]
2183pub struct ShipmentModel {
2184    /// Set of shipments which must be performed in the model.
2185    pub shipments: std::vec::Vec<crate::model::Shipment>,
2186
2187    /// Set of vehicles which can be used to perform visits.
2188    pub vehicles: std::vec::Vec<crate::model::Vehicle>,
2189
2190    /// Constrains the maximum number of active vehicles. A vehicle is active if
2191    /// its route performs at least one shipment. This can be used to limit the
2192    /// number of routes in the case where there are fewer drivers than
2193    /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
2194    /// will then select the best subset of vehicles to use.
2195    /// Must be strictly positive.
2196    pub max_active_vehicles: std::option::Option<i32>,
2197
2198    /// Global start and end time of the model: no times outside of this range
2199    /// can be considered valid.
2200    ///
2201    /// The model's time span must be less than a year, i.e. the `global_end_time`
2202    /// and the `global_start_time` must be within 31536000 seconds of each other.
2203    ///
2204    /// When using `cost_per_*hour` fields, you might want to set this window to a
2205    /// smaller interval to increase performance (eg. if you model a single day,
2206    /// you should set the global time limits to that day).
2207    /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
2208    /// as default.
2209    pub global_start_time: std::option::Option<wkt::Timestamp>,
2210
2211    /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
2212    /// is used as default.
2213    pub global_end_time: std::option::Option<wkt::Timestamp>,
2214
2215    /// The "global duration" of the overall plan is the difference between the
2216    /// earliest effective start time and the latest effective end time of
2217    /// all vehicles. Users can assign a cost per hour to that quantity to try
2218    /// and optimize for earliest job completion, for example. This cost must be in
2219    /// the same unit as
2220    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
2221    ///
2222    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
2223    pub global_duration_cost_per_hour: f64,
2224
2225    /// Specifies duration and distance matrices used in the model. If this field
2226    /// is empty, Google Maps or geodesic distances will be used instead, depending
2227    /// on the value of the `use_geodesic_distances` field. If it is not empty,
2228    /// `use_geodesic_distances` cannot be true and neither
2229    /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
2230    /// can be empty.
2231    ///
2232    /// Usage examples:
2233    ///
2234    /// * There are two locations: locA and locB.
2235    /// * 1 vehicle starting its route at locA and ending it at locA.
2236    /// * 1 pickup visit request at locB.
2237    ///
2238    /// ```norust
2239    /// model {
2240    ///   vehicles { start_tags: "locA"  end_tags: "locA" }
2241    ///   shipments { pickups { tags: "locB" } }
2242    ///   duration_distance_matrix_src_tags: "locA"
2243    ///   duration_distance_matrix_src_tags: "locB"
2244    ///   duration_distance_matrix_dst_tags: "locA"
2245    ///   duration_distance_matrix_dst_tags: "locB"
2246    ///   duration_distance_matrices {
2247    ///     rows {  # from: locA
2248    ///       durations { seconds: 0 }   meters: 0    # to: locA
2249    ///       durations { seconds: 100 } meters: 1000 # to: locB
2250    ///     }
2251    ///     rows {  # from: locB
2252    ///       durations { seconds: 102 } meters: 990 # to: locA
2253    ///       durations { seconds: 0 }   meters: 0   # to: locB
2254    ///     }
2255    ///   }
2256    /// }
2257    /// ```
2258    ///
2259    /// * There are three locations: locA, locB and locC.
2260    /// * 1 vehicle starting its route at locA and ending it at locB, using
2261    ///   matrix "fast".
2262    /// * 1 vehicle starting its route at locB and ending it at locB, using
2263    ///   matrix "slow".
2264    /// * 1 vehicle starting its route at locB and ending it at locB, using
2265    ///   matrix "fast".
2266    /// * 1 pickup visit request at locC.
2267    ///
2268    /// ```norust
2269    /// model {
2270    ///   vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
2271    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
2272    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
2273    ///   shipments { pickups { tags: "locC" } }
2274    ///   duration_distance_matrix_src_tags: "locA"
2275    ///   duration_distance_matrix_src_tags: "locB"
2276    ///   duration_distance_matrix_src_tags: "locC"
2277    ///   duration_distance_matrix_dst_tags: "locB"
2278    ///   duration_distance_matrix_dst_tags: "locC"
2279    ///   duration_distance_matrices {
2280    ///     vehicle_start_tag: "fast"
2281    ///     rows {  # from: locA
2282    ///       durations { seconds: 1000 } meters: 2000 # to: locB
2283    ///       durations { seconds: 600 }  meters: 1000 # to: locC
2284    ///     }
2285    ///     rows {  # from: locB
2286    ///       durations { seconds: 0 }   meters: 0    # to: locB
2287    ///       durations { seconds: 700 } meters: 1200 # to: locC
2288    ///     }
2289    ///     rows {  # from: locC
2290    ///       durations { seconds: 702 } meters: 1190 # to: locB
2291    ///       durations { seconds: 0 }   meters: 0    # to: locC
2292    ///     }
2293    ///   }
2294    ///   duration_distance_matrices {
2295    ///     vehicle_start_tag: "slow"
2296    ///     rows {  # from: locA
2297    ///       durations { seconds: 1800 } meters: 2001 # to: locB
2298    ///       durations { seconds: 900 }  meters: 1002 # to: locC
2299    ///     }
2300    ///     rows {  # from: locB
2301    ///       durations { seconds: 0 }    meters: 0    # to: locB
2302    ///       durations { seconds: 1000 } meters: 1202 # to: locC
2303    ///     }
2304    ///     rows {  # from: locC
2305    ///       durations { seconds: 1001 } meters: 1195 # to: locB
2306    ///       durations { seconds: 0 }    meters: 0    # to: locC
2307    ///     }
2308    ///   }
2309    /// }
2310    /// ```
2311    pub duration_distance_matrices:
2312        std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
2313
2314    /// Tags defining the sources of the duration and distance matrices;
2315    /// `duration_distance_matrices(i).rows(j)` defines durations and distances
2316    /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
2317    /// in matrix i.
2318    ///
2319    /// Tags correspond to
2320    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2321    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2322    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2323    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2324    /// the same; similarly a `VisitRequest`'s source and destination tags may be
2325    /// the same. All tags must be different and cannot be empty strings. If this
2326    /// field is not empty, then `duration_distance_matrices` must not be empty.
2327    ///
2328    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2329    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2330    pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
2331
2332    /// Tags defining the destinations of the duration and distance matrices;
2333    /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
2334    /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
2335    /// (resp. the distance) of the travel from visits with tag
2336    /// `duration_distance_matrix_src_tags(j)` to visits with tag
2337    /// `duration_distance_matrix_dst_tags(k)` in matrix i.
2338    ///
2339    /// Tags correspond to
2340    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2341    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2342    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2343    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2344    /// the same; similarly a `VisitRequest`'s source and destination tags may be
2345    /// the same. All tags must be different and cannot be empty strings. If this
2346    /// field is not empty, then `duration_distance_matrices` must not be empty.
2347    ///
2348    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2349    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2350    pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
2351
2352    /// Transition attributes added to the model.
2353    pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
2354
2355    /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
2356    pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
2357
2358    /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
2359    pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
2360
2361    /// Set of precedence rules which must be enforced in the model.
2362    pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
2363
2364    /// Deprecated: No longer used.
2365    /// Set of break rules used in the model.
2366    /// Each vehicle specifies the `BreakRule` that applies to it via the
2367    /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
2368    /// field (which must be a singleton).
2369    ///
2370    /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
2371    #[deprecated]
2372    pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
2373
2374    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2375}
2376
2377impl ShipmentModel {
2378    pub fn new() -> Self {
2379        std::default::Default::default()
2380    }
2381
2382    /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
2383    ///
2384    /// # Example
2385    /// ```ignore,no_run
2386    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2387    /// use google_cloud_optimization_v1::model::Shipment;
2388    /// let x = ShipmentModel::new()
2389    ///     .set_shipments([
2390    ///         Shipment::default()/* use setters */,
2391    ///         Shipment::default()/* use (different) setters */,
2392    ///     ]);
2393    /// ```
2394    pub fn set_shipments<T, V>(mut self, v: T) -> Self
2395    where
2396        T: std::iter::IntoIterator<Item = V>,
2397        V: std::convert::Into<crate::model::Shipment>,
2398    {
2399        use std::iter::Iterator;
2400        self.shipments = v.into_iter().map(|i| i.into()).collect();
2401        self
2402    }
2403
2404    /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
2405    ///
2406    /// # Example
2407    /// ```ignore,no_run
2408    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2409    /// use google_cloud_optimization_v1::model::Vehicle;
2410    /// let x = ShipmentModel::new()
2411    ///     .set_vehicles([
2412    ///         Vehicle::default()/* use setters */,
2413    ///         Vehicle::default()/* use (different) setters */,
2414    ///     ]);
2415    /// ```
2416    pub fn set_vehicles<T, V>(mut self, v: T) -> Self
2417    where
2418        T: std::iter::IntoIterator<Item = V>,
2419        V: std::convert::Into<crate::model::Vehicle>,
2420    {
2421        use std::iter::Iterator;
2422        self.vehicles = v.into_iter().map(|i| i.into()).collect();
2423        self
2424    }
2425
2426    /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2427    ///
2428    /// # Example
2429    /// ```ignore,no_run
2430    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2431    /// let x = ShipmentModel::new().set_max_active_vehicles(42);
2432    /// ```
2433    pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
2434    where
2435        T: std::convert::Into<i32>,
2436    {
2437        self.max_active_vehicles = std::option::Option::Some(v.into());
2438        self
2439    }
2440
2441    /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2442    ///
2443    /// # Example
2444    /// ```ignore,no_run
2445    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2446    /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(Some(42));
2447    /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(None::<i32>);
2448    /// ```
2449    pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
2450    where
2451        T: std::convert::Into<i32>,
2452    {
2453        self.max_active_vehicles = v.map(|x| x.into());
2454        self
2455    }
2456
2457    /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2458    ///
2459    /// # Example
2460    /// ```ignore,no_run
2461    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2462    /// use wkt::Timestamp;
2463    /// let x = ShipmentModel::new().set_global_start_time(Timestamp::default()/* use setters */);
2464    /// ```
2465    pub fn set_global_start_time<T>(mut self, v: T) -> Self
2466    where
2467        T: std::convert::Into<wkt::Timestamp>,
2468    {
2469        self.global_start_time = std::option::Option::Some(v.into());
2470        self
2471    }
2472
2473    /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2474    ///
2475    /// # Example
2476    /// ```ignore,no_run
2477    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2478    /// use wkt::Timestamp;
2479    /// let x = ShipmentModel::new().set_or_clear_global_start_time(Some(Timestamp::default()/* use setters */));
2480    /// let x = ShipmentModel::new().set_or_clear_global_start_time(None::<Timestamp>);
2481    /// ```
2482    pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2483    where
2484        T: std::convert::Into<wkt::Timestamp>,
2485    {
2486        self.global_start_time = v.map(|x| x.into());
2487        self
2488    }
2489
2490    /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2491    ///
2492    /// # Example
2493    /// ```ignore,no_run
2494    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2495    /// use wkt::Timestamp;
2496    /// let x = ShipmentModel::new().set_global_end_time(Timestamp::default()/* use setters */);
2497    /// ```
2498    pub fn set_global_end_time<T>(mut self, v: T) -> Self
2499    where
2500        T: std::convert::Into<wkt::Timestamp>,
2501    {
2502        self.global_end_time = std::option::Option::Some(v.into());
2503        self
2504    }
2505
2506    /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2507    ///
2508    /// # Example
2509    /// ```ignore,no_run
2510    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2511    /// use wkt::Timestamp;
2512    /// let x = ShipmentModel::new().set_or_clear_global_end_time(Some(Timestamp::default()/* use setters */));
2513    /// let x = ShipmentModel::new().set_or_clear_global_end_time(None::<Timestamp>);
2514    /// ```
2515    pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2516    where
2517        T: std::convert::Into<wkt::Timestamp>,
2518    {
2519        self.global_end_time = v.map(|x| x.into());
2520        self
2521    }
2522
2523    /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
2524    ///
2525    /// # Example
2526    /// ```ignore,no_run
2527    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2528    /// let x = ShipmentModel::new().set_global_duration_cost_per_hour(42.0);
2529    /// ```
2530    pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2531        self.global_duration_cost_per_hour = v.into();
2532        self
2533    }
2534
2535    /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
2536    ///
2537    /// # Example
2538    /// ```ignore,no_run
2539    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2540    /// use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2541    /// let x = ShipmentModel::new()
2542    ///     .set_duration_distance_matrices([
2543    ///         DurationDistanceMatrix::default()/* use setters */,
2544    ///         DurationDistanceMatrix::default()/* use (different) setters */,
2545    ///     ]);
2546    /// ```
2547    pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
2548    where
2549        T: std::iter::IntoIterator<Item = V>,
2550        V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
2551    {
2552        use std::iter::Iterator;
2553        self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
2554        self
2555    }
2556
2557    /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
2558    ///
2559    /// # Example
2560    /// ```ignore,no_run
2561    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2562    /// let x = ShipmentModel::new().set_duration_distance_matrix_src_tags(["a", "b", "c"]);
2563    /// ```
2564    pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
2565    where
2566        T: std::iter::IntoIterator<Item = V>,
2567        V: std::convert::Into<std::string::String>,
2568    {
2569        use std::iter::Iterator;
2570        self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
2571        self
2572    }
2573
2574    /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
2575    ///
2576    /// # Example
2577    /// ```ignore,no_run
2578    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2579    /// let x = ShipmentModel::new().set_duration_distance_matrix_dst_tags(["a", "b", "c"]);
2580    /// ```
2581    pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
2582    where
2583        T: std::iter::IntoIterator<Item = V>,
2584        V: std::convert::Into<std::string::String>,
2585    {
2586        use std::iter::Iterator;
2587        self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
2588        self
2589    }
2590
2591    /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
2592    ///
2593    /// # Example
2594    /// ```ignore,no_run
2595    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2596    /// use google_cloud_optimization_v1::model::TransitionAttributes;
2597    /// let x = ShipmentModel::new()
2598    ///     .set_transition_attributes([
2599    ///         TransitionAttributes::default()/* use setters */,
2600    ///         TransitionAttributes::default()/* use (different) setters */,
2601    ///     ]);
2602    /// ```
2603    pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
2604    where
2605        T: std::iter::IntoIterator<Item = V>,
2606        V: std::convert::Into<crate::model::TransitionAttributes>,
2607    {
2608        use std::iter::Iterator;
2609        self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
2610        self
2611    }
2612
2613    /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
2614    ///
2615    /// # Example
2616    /// ```ignore,no_run
2617    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2618    /// use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
2619    /// let x = ShipmentModel::new()
2620    ///     .set_shipment_type_incompatibilities([
2621    ///         ShipmentTypeIncompatibility::default()/* use setters */,
2622    ///         ShipmentTypeIncompatibility::default()/* use (different) setters */,
2623    ///     ]);
2624    /// ```
2625    pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
2626    where
2627        T: std::iter::IntoIterator<Item = V>,
2628        V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
2629    {
2630        use std::iter::Iterator;
2631        self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
2632        self
2633    }
2634
2635    /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
2636    ///
2637    /// # Example
2638    /// ```ignore,no_run
2639    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2640    /// use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
2641    /// let x = ShipmentModel::new()
2642    ///     .set_shipment_type_requirements([
2643    ///         ShipmentTypeRequirement::default()/* use setters */,
2644    ///         ShipmentTypeRequirement::default()/* use (different) setters */,
2645    ///     ]);
2646    /// ```
2647    pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
2648    where
2649        T: std::iter::IntoIterator<Item = V>,
2650        V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
2651    {
2652        use std::iter::Iterator;
2653        self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
2654        self
2655    }
2656
2657    /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
2658    ///
2659    /// # Example
2660    /// ```ignore,no_run
2661    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2662    /// use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2663    /// let x = ShipmentModel::new()
2664    ///     .set_precedence_rules([
2665    ///         PrecedenceRule::default()/* use setters */,
2666    ///         PrecedenceRule::default()/* use (different) setters */,
2667    ///     ]);
2668    /// ```
2669    pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
2670    where
2671        T: std::iter::IntoIterator<Item = V>,
2672        V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
2673    {
2674        use std::iter::Iterator;
2675        self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
2676        self
2677    }
2678
2679    /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
2680    ///
2681    /// # Example
2682    /// ```ignore,no_run
2683    /// # use google_cloud_optimization_v1::model::ShipmentModel;
2684    /// use google_cloud_optimization_v1::model::shipment_model::BreakRule;
2685    /// let x = ShipmentModel::new()
2686    ///     .set_break_rules([
2687    ///         BreakRule::default()/* use setters */,
2688    ///         BreakRule::default()/* use (different) setters */,
2689    ///     ]);
2690    /// ```
2691    #[deprecated]
2692    pub fn set_break_rules<T, V>(mut self, v: T) -> Self
2693    where
2694        T: std::iter::IntoIterator<Item = V>,
2695        V: std::convert::Into<crate::model::shipment_model::BreakRule>,
2696    {
2697        use std::iter::Iterator;
2698        self.break_rules = v.into_iter().map(|i| i.into()).collect();
2699        self
2700    }
2701}
2702
2703impl wkt::message::Message for ShipmentModel {
2704    fn typename() -> &'static str {
2705        "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
2706    }
2707}
2708
2709/// Defines additional types related to [ShipmentModel].
2710pub mod shipment_model {
2711    #[allow(unused_imports)]
2712    use super::*;
2713
2714    /// Specifies a duration and distance matrix from visit and vehicle start
2715    /// locations to visit and vehicle end locations.
2716    #[derive(Clone, Default, PartialEq)]
2717    #[non_exhaustive]
2718    pub struct DurationDistanceMatrix {
2719        /// Specifies the rows of the duration and distance matrix. It must have as
2720        /// many elements as
2721        /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
2722        ///
2723        /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
2724        pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
2725
2726        /// Tag defining to which vehicles this duration and distance matrix applies.
2727        /// If empty, this applies to all vehicles, and there can only be a single
2728        /// matrix.
2729        ///
2730        /// Each vehicle start must match exactly one matrix, i.e. exactly one of
2731        /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
2732        /// (and of that matrix only).
2733        ///
2734        /// All matrices must have a different `vehicle_start_tag`.
2735        pub vehicle_start_tag: std::string::String,
2736
2737        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2738    }
2739
2740    impl DurationDistanceMatrix {
2741        pub fn new() -> Self {
2742            std::default::Default::default()
2743        }
2744
2745        /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
2746        ///
2747        /// # Example
2748        /// ```ignore,no_run
2749        /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2750        /// use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2751        /// let x = DurationDistanceMatrix::new()
2752        ///     .set_rows([
2753        ///         Row::default()/* use setters */,
2754        ///         Row::default()/* use (different) setters */,
2755        ///     ]);
2756        /// ```
2757        pub fn set_rows<T, V>(mut self, v: T) -> Self
2758        where
2759            T: std::iter::IntoIterator<Item = V>,
2760            V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
2761        {
2762            use std::iter::Iterator;
2763            self.rows = v.into_iter().map(|i| i.into()).collect();
2764            self
2765        }
2766
2767        /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
2768        ///
2769        /// # Example
2770        /// ```ignore,no_run
2771        /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2772        /// let x = DurationDistanceMatrix::new().set_vehicle_start_tag("example");
2773        /// ```
2774        pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
2775            mut self,
2776            v: T,
2777        ) -> Self {
2778            self.vehicle_start_tag = v.into();
2779            self
2780        }
2781    }
2782
2783    impl wkt::message::Message for DurationDistanceMatrix {
2784        fn typename() -> &'static str {
2785            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
2786        }
2787    }
2788
2789    /// Defines additional types related to [DurationDistanceMatrix].
2790    pub mod duration_distance_matrix {
2791        #[allow(unused_imports)]
2792        use super::*;
2793
2794        /// Specifies a row of the duration and distance matrix.
2795        #[derive(Clone, Default, PartialEq)]
2796        #[non_exhaustive]
2797        pub struct Row {
2798            /// Duration values for a given row. It must have as many elements as
2799            /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
2800            ///
2801            /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
2802            pub durations: std::vec::Vec<wkt::Duration>,
2803
2804            /// Distance values for a given row. If no costs or constraints refer to
2805            /// distances in the model, this can be left empty; otherwise it must have
2806            /// as many elements as `durations`.
2807            pub meters: std::vec::Vec<f64>,
2808
2809            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2810        }
2811
2812        impl Row {
2813            pub fn new() -> Self {
2814                std::default::Default::default()
2815            }
2816
2817            /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
2818            ///
2819            /// # Example
2820            /// ```ignore,no_run
2821            /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2822            /// use wkt::Duration;
2823            /// let x = Row::new()
2824            ///     .set_durations([
2825            ///         Duration::default()/* use setters */,
2826            ///         Duration::default()/* use (different) setters */,
2827            ///     ]);
2828            /// ```
2829            pub fn set_durations<T, V>(mut self, v: T) -> Self
2830            where
2831                T: std::iter::IntoIterator<Item = V>,
2832                V: std::convert::Into<wkt::Duration>,
2833            {
2834                use std::iter::Iterator;
2835                self.durations = v.into_iter().map(|i| i.into()).collect();
2836                self
2837            }
2838
2839            /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
2840            ///
2841            /// # Example
2842            /// ```ignore,no_run
2843            /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2844            /// let x = Row::new().set_meters([1.0, 2.0, 3.0]);
2845            /// ```
2846            pub fn set_meters<T, V>(mut self, v: T) -> Self
2847            where
2848                T: std::iter::IntoIterator<Item = V>,
2849                V: std::convert::Into<f64>,
2850            {
2851                use std::iter::Iterator;
2852                self.meters = v.into_iter().map(|i| i.into()).collect();
2853                self
2854            }
2855        }
2856
2857        impl wkt::message::Message for Row {
2858            fn typename() -> &'static str {
2859                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
2860            }
2861        }
2862    }
2863
2864    /// A precedence rule between two events (each event is the pickup or the
2865    /// delivery of a shipment): the "second" event has to start at least
2866    /// `offset_duration` after "first" has started.
2867    ///
2868    /// Several precedences can refer to the same (or related) events, e.g.,
2869    /// "pickup of B happens after delivery of A" and "pickup of C happens after
2870    /// pickup of B".
2871    ///
2872    /// Furthermore, precedences only apply when both shipments are performed and
2873    /// are otherwise ignored.
2874    #[derive(Clone, Default, PartialEq)]
2875    #[non_exhaustive]
2876    pub struct PrecedenceRule {
2877        /// Shipment index of the "first" event. This field must be specified.
2878        pub first_index: std::option::Option<i32>,
2879
2880        /// Indicates if the "first" event is a delivery.
2881        pub first_is_delivery: bool,
2882
2883        /// Shipment index of the "second" event. This field must be specified.
2884        pub second_index: std::option::Option<i32>,
2885
2886        /// Indicates if the "second" event is a delivery.
2887        pub second_is_delivery: bool,
2888
2889        /// The offset between the "first" and "second" event. It can be negative.
2890        pub offset_duration: std::option::Option<wkt::Duration>,
2891
2892        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2893    }
2894
2895    impl PrecedenceRule {
2896        pub fn new() -> Self {
2897            std::default::Default::default()
2898        }
2899
2900        /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2901        ///
2902        /// # Example
2903        /// ```ignore,no_run
2904        /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2905        /// let x = PrecedenceRule::new().set_first_index(42);
2906        /// ```
2907        pub fn set_first_index<T>(mut self, v: T) -> Self
2908        where
2909            T: std::convert::Into<i32>,
2910        {
2911            self.first_index = std::option::Option::Some(v.into());
2912            self
2913        }
2914
2915        /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2916        ///
2917        /// # Example
2918        /// ```ignore,no_run
2919        /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2920        /// let x = PrecedenceRule::new().set_or_clear_first_index(Some(42));
2921        /// let x = PrecedenceRule::new().set_or_clear_first_index(None::<i32>);
2922        /// ```
2923        pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
2924        where
2925            T: std::convert::Into<i32>,
2926        {
2927            self.first_index = v.map(|x| x.into());
2928            self
2929        }
2930
2931        /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
2932        ///
2933        /// # Example
2934        /// ```ignore,no_run
2935        /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2936        /// let x = PrecedenceRule::new().set_first_is_delivery(true);
2937        /// ```
2938        pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2939            self.first_is_delivery = v.into();
2940            self
2941        }
2942
2943        /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2944        ///
2945        /// # Example
2946        /// ```ignore,no_run
2947        /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2948        /// let x = PrecedenceRule::new().set_second_index(42);
2949        /// ```
2950        pub fn set_second_index<T>(mut self, v: T) -> Self
2951        where
2952            T: std::convert::Into<i32>,
2953        {
2954            self.second_index = std::option::Option::Some(v.into());
2955            self
2956        }
2957
2958        /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2959        ///
2960        /// # Example
2961        /// ```ignore,no_run
2962        /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2963        /// let x = PrecedenceRule::new().set_or_clear_second_index(Some(42));
2964        /// let x = PrecedenceRule::new().set_or_clear_second_index(None::<i32>);
2965        /// ```
2966        pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
2967        where
2968            T: std::convert::Into<i32>,
2969        {
2970            self.second_index = v.map(|x| x.into());
2971            self
2972        }
2973
2974        /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
2975        ///
2976        /// # Example
2977        /// ```ignore,no_run
2978        /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2979        /// let x = PrecedenceRule::new().set_second_is_delivery(true);
2980        /// ```
2981        pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2982            self.second_is_delivery = v.into();
2983            self
2984        }
2985
2986        /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
2987        ///
2988        /// # Example
2989        /// ```ignore,no_run
2990        /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2991        /// use wkt::Duration;
2992        /// let x = PrecedenceRule::new().set_offset_duration(Duration::default()/* use setters */);
2993        /// ```
2994        pub fn set_offset_duration<T>(mut self, v: T) -> Self
2995        where
2996            T: std::convert::Into<wkt::Duration>,
2997        {
2998            self.offset_duration = std::option::Option::Some(v.into());
2999            self
3000        }
3001
3002        /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
3003        ///
3004        /// # Example
3005        /// ```ignore,no_run
3006        /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
3007        /// use wkt::Duration;
3008        /// let x = PrecedenceRule::new().set_or_clear_offset_duration(Some(Duration::default()/* use setters */));
3009        /// let x = PrecedenceRule::new().set_or_clear_offset_duration(None::<Duration>);
3010        /// ```
3011        pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
3012        where
3013            T: std::convert::Into<wkt::Duration>,
3014        {
3015            self.offset_duration = v.map(|x| x.into());
3016            self
3017        }
3018    }
3019
3020    impl wkt::message::Message for PrecedenceRule {
3021        fn typename() -> &'static str {
3022            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
3023        }
3024    }
3025
3026    /// Deprecated: Use top level
3027    /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
3028    /// Rules to generate time breaks for a vehicle (e.g. lunch
3029    /// breaks). A break is a contiguous period of time during which the vehicle
3030    /// remains idle at its current position and cannot perform any visit. A break
3031    /// may occur:
3032    ///
3033    /// * during the travel between two visits (which includes the time right
3034    ///   before or right after a visit, but not in the middle of a visit), in
3035    ///   which case it extends the corresponding transit time between the visits
3036    /// * before the vehicle start (the vehicle may not start in the middle of
3037    ///   a break), in which case it does not affect the vehicle start time.
3038    /// * after the vehicle end (ditto, with the vehicle end time).
3039    ///
3040    /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
3041    #[derive(Clone, Default, PartialEq)]
3042    #[non_exhaustive]
3043    #[deprecated]
3044    pub struct BreakRule {
3045        /// Sequence of breaks. See the `BreakRequest` message.
3046        pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
3047
3048        /// Several `FrequencyConstraint` may apply. They must all be satisfied by
3049        /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
3050        pub frequency_constraints:
3051            std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3052
3053        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3054    }
3055
3056    impl BreakRule {
3057        pub fn new() -> Self {
3058            std::default::Default::default()
3059        }
3060
3061        /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
3062        ///
3063        /// # Example
3064        /// ```ignore,no_run
3065        /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3066        /// use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3067        /// let x = BreakRule::new()
3068        ///     .set_break_requests([
3069        ///         BreakRequest::default()/* use setters */,
3070        ///         BreakRequest::default()/* use (different) setters */,
3071        ///     ]);
3072        /// ```
3073        pub fn set_break_requests<T, V>(mut self, v: T) -> Self
3074        where
3075            T: std::iter::IntoIterator<Item = V>,
3076            V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
3077        {
3078            use std::iter::Iterator;
3079            self.break_requests = v.into_iter().map(|i| i.into()).collect();
3080            self
3081        }
3082
3083        /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
3084        ///
3085        /// # Example
3086        /// ```ignore,no_run
3087        /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3088        /// use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3089        /// let x = BreakRule::new()
3090        ///     .set_frequency_constraints([
3091        ///         FrequencyConstraint::default()/* use setters */,
3092        ///         FrequencyConstraint::default()/* use (different) setters */,
3093        ///     ]);
3094        /// ```
3095        pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
3096        where
3097            T: std::iter::IntoIterator<Item = V>,
3098            V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3099        {
3100            use std::iter::Iterator;
3101            self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
3102            self
3103        }
3104    }
3105
3106    impl wkt::message::Message for BreakRule {
3107        fn typename() -> &'static str {
3108            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
3109        }
3110    }
3111
3112    /// Defines additional types related to [BreakRule].
3113    pub mod break_rule {
3114        #[allow(unused_imports)]
3115        use super::*;
3116
3117        /// The sequence of breaks (i.e. their number and order) that apply to each
3118        /// vehicle must be known beforehand. The repeated `BreakRequest`s define
3119        /// that sequence, in the order in which they must occur. Their time windows
3120        /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
3121        /// be compatible with the order (this is checked).
3122        #[derive(Clone, Default, PartialEq)]
3123        #[non_exhaustive]
3124        pub struct BreakRequest {
3125            /// Required. Lower bound (inclusive) on the start of the break.
3126            pub earliest_start_time: std::option::Option<wkt::Timestamp>,
3127
3128            /// Required. Upper bound (inclusive) on the start of the break.
3129            pub latest_start_time: std::option::Option<wkt::Timestamp>,
3130
3131            /// Required. Minimum duration of the break. Must be positive.
3132            pub min_duration: std::option::Option<wkt::Duration>,
3133
3134            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3135        }
3136
3137        impl BreakRequest {
3138            pub fn new() -> Self {
3139                std::default::Default::default()
3140            }
3141
3142            /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3143            ///
3144            /// # Example
3145            /// ```ignore,no_run
3146            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3147            /// use wkt::Timestamp;
3148            /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
3149            /// ```
3150            pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
3151            where
3152                T: std::convert::Into<wkt::Timestamp>,
3153            {
3154                self.earliest_start_time = std::option::Option::Some(v.into());
3155                self
3156            }
3157
3158            /// Sets or clears the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3159            ///
3160            /// # Example
3161            /// ```ignore,no_run
3162            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3163            /// use wkt::Timestamp;
3164            /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
3165            /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
3166            /// ```
3167            pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3168            where
3169                T: std::convert::Into<wkt::Timestamp>,
3170            {
3171                self.earliest_start_time = v.map(|x| x.into());
3172                self
3173            }
3174
3175            /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3176            ///
3177            /// # Example
3178            /// ```ignore,no_run
3179            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3180            /// use wkt::Timestamp;
3181            /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
3182            /// ```
3183            pub fn set_latest_start_time<T>(mut self, v: T) -> Self
3184            where
3185                T: std::convert::Into<wkt::Timestamp>,
3186            {
3187                self.latest_start_time = std::option::Option::Some(v.into());
3188                self
3189            }
3190
3191            /// Sets or clears the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3192            ///
3193            /// # Example
3194            /// ```ignore,no_run
3195            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3196            /// use wkt::Timestamp;
3197            /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
3198            /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
3199            /// ```
3200            pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3201            where
3202                T: std::convert::Into<wkt::Timestamp>,
3203            {
3204                self.latest_start_time = v.map(|x| x.into());
3205                self
3206            }
3207
3208            /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3209            ///
3210            /// # Example
3211            /// ```ignore,no_run
3212            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3213            /// use wkt::Duration;
3214            /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
3215            /// ```
3216            pub fn set_min_duration<T>(mut self, v: T) -> Self
3217            where
3218                T: std::convert::Into<wkt::Duration>,
3219            {
3220                self.min_duration = std::option::Option::Some(v.into());
3221                self
3222            }
3223
3224            /// Sets or clears the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3225            ///
3226            /// # Example
3227            /// ```ignore,no_run
3228            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3229            /// use wkt::Duration;
3230            /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
3231            /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
3232            /// ```
3233            pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
3234            where
3235                T: std::convert::Into<wkt::Duration>,
3236            {
3237                self.min_duration = v.map(|x| x.into());
3238                self
3239            }
3240        }
3241
3242        impl wkt::message::Message for BreakRequest {
3243            fn typename() -> &'static str {
3244                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
3245            }
3246        }
3247
3248        /// One may further constrain the frequency and duration of the breaks
3249        /// specified above, by enforcing a minimum break frequency, such as
3250        /// "There must be a break of at least 1 hour every 12 hours". Assuming that
3251        /// this can be interpreted as "Within any sliding time window of 12h, there
3252        /// must be at least one break of at least one hour", that example would
3253        /// translate to the following `FrequencyConstraint`:
3254        ///
3255        /// ```norust
3256        /// {
3257        ///    min_break_duration { seconds: 3600 }         # 1 hour.
3258        ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
3259        /// }
3260        /// ```
3261        ///
3262        /// The timing and duration of the breaks in the solution will respect all
3263        /// such constraints, in addition to the time windows and minimum durations
3264        /// already specified in the `BreakRequest`.
3265        ///
3266        /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
3267        /// For example, the following schedule honors the "1h every 12h" example:
3268        ///
3269        /// ```norust
3270        ///   04:00 vehicle start
3271        ///    .. performing travel and visits ..
3272        ///   09:00 1 hour break
3273        ///   10:00 end of the break
3274        ///    .. performing travel and visits ..
3275        ///   12:00 20-min lunch break
3276        ///   12:20 end of the break
3277        ///    .. performing travel and visits ..
3278        ///   21:00 1 hour break
3279        ///   22:00 end of the break
3280        ///    .. performing travel and visits ..
3281        ///   23:59 vehicle end
3282        /// ```
3283        #[derive(Clone, Default, PartialEq)]
3284        #[non_exhaustive]
3285        pub struct FrequencyConstraint {
3286            /// Required. Minimum break duration for this constraint. Nonnegative.
3287            /// See description of `FrequencyConstraint`.
3288            pub min_break_duration: std::option::Option<wkt::Duration>,
3289
3290            /// Required. Maximum allowed span of any interval of time in the route
3291            /// that does not include at least partially a break of `duration >=
3292            /// min_break_duration`. Must be positive.
3293            pub max_inter_break_duration: std::option::Option<wkt::Duration>,
3294
3295            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3296        }
3297
3298        impl FrequencyConstraint {
3299            pub fn new() -> Self {
3300                std::default::Default::default()
3301            }
3302
3303            /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3304            ///
3305            /// # Example
3306            /// ```ignore,no_run
3307            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3308            /// use wkt::Duration;
3309            /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
3310            /// ```
3311            pub fn set_min_break_duration<T>(mut self, v: T) -> Self
3312            where
3313                T: std::convert::Into<wkt::Duration>,
3314            {
3315                self.min_break_duration = std::option::Option::Some(v.into());
3316                self
3317            }
3318
3319            /// Sets or clears the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3320            ///
3321            /// # Example
3322            /// ```ignore,no_run
3323            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3324            /// use wkt::Duration;
3325            /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
3326            /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
3327            /// ```
3328            pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
3329            where
3330                T: std::convert::Into<wkt::Duration>,
3331            {
3332                self.min_break_duration = v.map(|x| x.into());
3333                self
3334            }
3335
3336            /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3337            ///
3338            /// # Example
3339            /// ```ignore,no_run
3340            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3341            /// use wkt::Duration;
3342            /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
3343            /// ```
3344            pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
3345            where
3346                T: std::convert::Into<wkt::Duration>,
3347            {
3348                self.max_inter_break_duration = std::option::Option::Some(v.into());
3349                self
3350            }
3351
3352            /// Sets or clears the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3353            ///
3354            /// # Example
3355            /// ```ignore,no_run
3356            /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3357            /// use wkt::Duration;
3358            /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
3359            /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
3360            /// ```
3361            pub fn set_or_clear_max_inter_break_duration<T>(
3362                mut self,
3363                v: std::option::Option<T>,
3364            ) -> Self
3365            where
3366                T: std::convert::Into<wkt::Duration>,
3367            {
3368                self.max_inter_break_duration = v.map(|x| x.into());
3369                self
3370            }
3371        }
3372
3373        impl wkt::message::Message for FrequencyConstraint {
3374            fn typename() -> &'static str {
3375                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
3376            }
3377        }
3378    }
3379}
3380
3381/// The shipment of a single item, from one of its pickups to one of its
3382/// deliveries. For the shipment to be considered as performed, a unique vehicle
3383/// must visit one of its pickup locations (and decrease its spare capacities
3384/// accordingly), then visit one of its delivery locations later on (and
3385/// therefore re-increase its spare capacities accordingly).
3386#[derive(Clone, Default, PartialEq)]
3387#[non_exhaustive]
3388pub struct Shipment {
3389    /// Set of pickup alternatives associated to the shipment. If not specified,
3390    /// the vehicle only needs to visit a location corresponding to the deliveries.
3391    pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
3392
3393    /// Set of delivery alternatives associated to the shipment. If not specified,
3394    /// the vehicle only needs to visit a location corresponding to the pickups.
3395    pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
3396
3397    /// Load demands of the shipment (for example weight, volume, number of
3398    /// pallets etc). The keys in the map should be identifiers describing the type
3399    /// of the corresponding load, ideally also including the units.
3400    /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
3401    /// If a given key does not appear in the map, the corresponding load is
3402    /// considered as null.
3403    pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3404
3405    /// If the shipment is not completed, this penalty is added to the overall
3406    /// cost of the routes. A shipment is considered completed if one of its pickup
3407    /// and delivery alternatives is visited. The cost may be expressed in the
3408    /// same unit used for all other cost-related fields in the model and must be
3409    /// positive.
3410    ///
3411    /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
3412    /// i.e. the shipment must be completed.
3413    pub penalty_cost: std::option::Option<f64>,
3414
3415    /// The set of vehicles that may perform this shipment. If empty, all vehicles
3416    /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
3417    /// `vehicles` list.
3418    pub allowed_vehicle_indices: std::vec::Vec<i32>,
3419
3420    /// Specifies the cost that is incurred when this shipment is delivered by each
3421    /// vehicle. If specified, it must have EITHER:
3422    ///
3423    /// * the same number of elements as `costs_per_vehicle_indices`.
3424    ///   `costs_per_vehicle[i]` corresponds to vehicle
3425    ///   `costs_per_vehicle_indices[i]` of the model.
3426    /// * the same number of elements as there are vehicles in the model. The
3427    ///   i-th element corresponds to vehicle #i of the model.
3428    ///
3429    /// These costs must be in the same unit as `penalty_cost` and must not be
3430    /// negative. Leave this field empty, if there are no such costs.
3431    pub costs_per_vehicle: std::vec::Vec<f64>,
3432
3433    /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
3434    /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
3435    /// index may not be specified more than once. If a vehicle is excluded from
3436    /// `costs_per_vehicle_indices`, its cost is zero.
3437    pub costs_per_vehicle_indices: std::vec::Vec<i32>,
3438
3439    /// Specifies the maximum relative detour time compared to the shortest path
3440    /// from pickup to delivery. If specified, it must be nonnegative, and the
3441    /// shipment must contain at least a pickup and a delivery.
3442    ///
3443    /// For example, let t be the shortest time taken to go from the selected
3444    /// pickup alternative directly to the selected delivery alternative. Then
3445    /// setting `pickup_to_delivery_relative_detour_limit` enforces:
3446    ///
3447    /// ```norust
3448    /// start_time(delivery) - start_time(pickup) <=
3449    /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
3450    /// ```
3451    ///
3452    /// If both relative and absolute limits are specified on the same shipment,
3453    /// the more constraining limit is used for each possible pickup/delivery pair.
3454    /// As of 2017/10, detours are only supported when travel durations do not
3455    /// depend on vehicles.
3456    pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
3457
3458    /// Specifies the maximum absolute detour time compared to the shortest path
3459    /// from pickup to delivery. If specified, it must be nonnegative, and the
3460    /// shipment must contain at least a pickup and a delivery.
3461    ///
3462    /// For example, let t be the shortest time taken to go from the selected
3463    /// pickup alternative directly to the selected delivery alternative. Then
3464    /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
3465    ///
3466    /// ```norust
3467    /// start_time(delivery) - start_time(pickup) <=
3468    /// t + pickup_to_delivery_absolute_detour_limit
3469    /// ```
3470    ///
3471    /// If both relative and absolute limits are specified on the same shipment,
3472    /// the more constraining limit is used for each possible pickup/delivery pair.
3473    /// As of 2017/10, detours are only supported when travel durations do not
3474    /// depend on vehicles.
3475    pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
3476
3477    /// Specifies the maximum duration from start of pickup to start of delivery of
3478    /// a shipment. If specified, it must be nonnegative, and the shipment must
3479    /// contain at least a pickup and a delivery. This does not depend on which
3480    /// alternatives are selected for pickup and delivery, nor on vehicle speed.
3481    /// This can be specified alongside maximum detour constraints: the solution
3482    /// will respect both specifications.
3483    pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
3484
3485    /// Non-empty string specifying a "type" for this shipment.
3486    /// This feature can be used to define incompatibilities or requirements
3487    /// between `shipment_types` (see `shipment_type_incompatibilities` and
3488    /// `shipment_type_requirements` in `ShipmentModel`).
3489    ///
3490    /// Differs from `visit_types` which is specified for a single visit: All
3491    /// pickup/deliveries belonging to the same shipment share the same
3492    /// `shipment_type`.
3493    pub shipment_type: std::string::String,
3494
3495    /// Specifies a label for this shipment. This label is reported in the response
3496    /// in the `shipment_label` of the corresponding
3497    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3498    ///
3499    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3500    pub label: std::string::String,
3501
3502    /// If true, skip this shipment, but don't apply a `penalty_cost`.
3503    ///
3504    /// Ignoring a shipment results in a validation error when there are any
3505    /// `shipment_type_requirements` in the model.
3506    ///
3507    /// Ignoring a shipment that is performed in `injected_first_solution_routes`
3508    /// or `injected_solution_constraint` is permitted; the solver removes the
3509    /// related pickup/delivery visits from the performing route.
3510    /// `precedence_rules` that reference ignored shipments will also be ignored.
3511    pub ignore: bool,
3512
3513    /// Deprecated: Use
3514    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3515    /// instead.
3516    ///
3517    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3518    #[deprecated]
3519    pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3520
3521    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3522}
3523
3524impl Shipment {
3525    pub fn new() -> Self {
3526        std::default::Default::default()
3527    }
3528
3529    /// Sets the value of [pickups][crate::model::Shipment::pickups].
3530    ///
3531    /// # Example
3532    /// ```ignore,no_run
3533    /// # use google_cloud_optimization_v1::model::Shipment;
3534    /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3535    /// let x = Shipment::new()
3536    ///     .set_pickups([
3537    ///         VisitRequest::default()/* use setters */,
3538    ///         VisitRequest::default()/* use (different) setters */,
3539    ///     ]);
3540    /// ```
3541    pub fn set_pickups<T, V>(mut self, v: T) -> Self
3542    where
3543        T: std::iter::IntoIterator<Item = V>,
3544        V: std::convert::Into<crate::model::shipment::VisitRequest>,
3545    {
3546        use std::iter::Iterator;
3547        self.pickups = v.into_iter().map(|i| i.into()).collect();
3548        self
3549    }
3550
3551    /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
3552    ///
3553    /// # Example
3554    /// ```ignore,no_run
3555    /// # use google_cloud_optimization_v1::model::Shipment;
3556    /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3557    /// let x = Shipment::new()
3558    ///     .set_deliveries([
3559    ///         VisitRequest::default()/* use setters */,
3560    ///         VisitRequest::default()/* use (different) setters */,
3561    ///     ]);
3562    /// ```
3563    pub fn set_deliveries<T, V>(mut self, v: T) -> Self
3564    where
3565        T: std::iter::IntoIterator<Item = V>,
3566        V: std::convert::Into<crate::model::shipment::VisitRequest>,
3567    {
3568        use std::iter::Iterator;
3569        self.deliveries = v.into_iter().map(|i| i.into()).collect();
3570        self
3571    }
3572
3573    /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
3574    ///
3575    /// # Example
3576    /// ```ignore,no_run
3577    /// # use google_cloud_optimization_v1::model::Shipment;
3578    /// use google_cloud_optimization_v1::model::shipment::Load;
3579    /// let x = Shipment::new().set_load_demands([
3580    ///     ("key0", Load::default()/* use setters */),
3581    ///     ("key1", Load::default()/* use (different) setters */),
3582    /// ]);
3583    /// ```
3584    pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
3585    where
3586        T: std::iter::IntoIterator<Item = (K, V)>,
3587        K: std::convert::Into<std::string::String>,
3588        V: std::convert::Into<crate::model::shipment::Load>,
3589    {
3590        use std::iter::Iterator;
3591        self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3592        self
3593    }
3594
3595    /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3596    ///
3597    /// # Example
3598    /// ```ignore,no_run
3599    /// # use google_cloud_optimization_v1::model::Shipment;
3600    /// let x = Shipment::new().set_penalty_cost(42.0);
3601    /// ```
3602    pub fn set_penalty_cost<T>(mut self, v: T) -> Self
3603    where
3604        T: std::convert::Into<f64>,
3605    {
3606        self.penalty_cost = std::option::Option::Some(v.into());
3607        self
3608    }
3609
3610    /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3611    ///
3612    /// # Example
3613    /// ```ignore,no_run
3614    /// # use google_cloud_optimization_v1::model::Shipment;
3615    /// let x = Shipment::new().set_or_clear_penalty_cost(Some(42.0));
3616    /// let x = Shipment::new().set_or_clear_penalty_cost(None::<f32>);
3617    /// ```
3618    pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
3619    where
3620        T: std::convert::Into<f64>,
3621    {
3622        self.penalty_cost = v.map(|x| x.into());
3623        self
3624    }
3625
3626    /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
3627    ///
3628    /// # Example
3629    /// ```ignore,no_run
3630    /// # use google_cloud_optimization_v1::model::Shipment;
3631    /// let x = Shipment::new().set_allowed_vehicle_indices([1, 2, 3]);
3632    /// ```
3633    pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
3634    where
3635        T: std::iter::IntoIterator<Item = V>,
3636        V: std::convert::Into<i32>,
3637    {
3638        use std::iter::Iterator;
3639        self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3640        self
3641    }
3642
3643    /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
3644    ///
3645    /// # Example
3646    /// ```ignore,no_run
3647    /// # use google_cloud_optimization_v1::model::Shipment;
3648    /// let x = Shipment::new().set_costs_per_vehicle([1.0, 2.0, 3.0]);
3649    /// ```
3650    pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
3651    where
3652        T: std::iter::IntoIterator<Item = V>,
3653        V: std::convert::Into<f64>,
3654    {
3655        use std::iter::Iterator;
3656        self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
3657        self
3658    }
3659
3660    /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
3661    ///
3662    /// # Example
3663    /// ```ignore,no_run
3664    /// # use google_cloud_optimization_v1::model::Shipment;
3665    /// let x = Shipment::new().set_costs_per_vehicle_indices([1, 2, 3]);
3666    /// ```
3667    pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
3668    where
3669        T: std::iter::IntoIterator<Item = V>,
3670        V: std::convert::Into<i32>,
3671    {
3672        use std::iter::Iterator;
3673        self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3674        self
3675    }
3676
3677    /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3678    ///
3679    /// # Example
3680    /// ```ignore,no_run
3681    /// # use google_cloud_optimization_v1::model::Shipment;
3682    /// let x = Shipment::new().set_pickup_to_delivery_relative_detour_limit(42.0);
3683    /// ```
3684    pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
3685    where
3686        T: std::convert::Into<f64>,
3687    {
3688        self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
3689        self
3690    }
3691
3692    /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3693    ///
3694    /// # Example
3695    /// ```ignore,no_run
3696    /// # use google_cloud_optimization_v1::model::Shipment;
3697    /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(Some(42.0));
3698    /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(None::<f32>);
3699    /// ```
3700    pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
3701        mut self,
3702        v: std::option::Option<T>,
3703    ) -> Self
3704    where
3705        T: std::convert::Into<f64>,
3706    {
3707        self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
3708        self
3709    }
3710
3711    /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3712    ///
3713    /// # Example
3714    /// ```ignore,no_run
3715    /// # use google_cloud_optimization_v1::model::Shipment;
3716    /// use wkt::Duration;
3717    /// let x = Shipment::new().set_pickup_to_delivery_absolute_detour_limit(Duration::default()/* use setters */);
3718    /// ```
3719    pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
3720    where
3721        T: std::convert::Into<wkt::Duration>,
3722    {
3723        self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
3724        self
3725    }
3726
3727    /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3728    ///
3729    /// # Example
3730    /// ```ignore,no_run
3731    /// # use google_cloud_optimization_v1::model::Shipment;
3732    /// use wkt::Duration;
3733    /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(Some(Duration::default()/* use setters */));
3734    /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(None::<Duration>);
3735    /// ```
3736    pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
3737        mut self,
3738        v: std::option::Option<T>,
3739    ) -> Self
3740    where
3741        T: std::convert::Into<wkt::Duration>,
3742    {
3743        self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
3744        self
3745    }
3746
3747    /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3748    ///
3749    /// # Example
3750    /// ```ignore,no_run
3751    /// # use google_cloud_optimization_v1::model::Shipment;
3752    /// use wkt::Duration;
3753    /// let x = Shipment::new().set_pickup_to_delivery_time_limit(Duration::default()/* use setters */);
3754    /// ```
3755    pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
3756    where
3757        T: std::convert::Into<wkt::Duration>,
3758    {
3759        self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
3760        self
3761    }
3762
3763    /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3764    ///
3765    /// # Example
3766    /// ```ignore,no_run
3767    /// # use google_cloud_optimization_v1::model::Shipment;
3768    /// use wkt::Duration;
3769    /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(Some(Duration::default()/* use setters */));
3770    /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(None::<Duration>);
3771    /// ```
3772    pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
3773        mut self,
3774        v: std::option::Option<T>,
3775    ) -> Self
3776    where
3777        T: std::convert::Into<wkt::Duration>,
3778    {
3779        self.pickup_to_delivery_time_limit = v.map(|x| x.into());
3780        self
3781    }
3782
3783    /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
3784    ///
3785    /// # Example
3786    /// ```ignore,no_run
3787    /// # use google_cloud_optimization_v1::model::Shipment;
3788    /// let x = Shipment::new().set_shipment_type("example");
3789    /// ```
3790    pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3791        self.shipment_type = v.into();
3792        self
3793    }
3794
3795    /// Sets the value of [label][crate::model::Shipment::label].
3796    ///
3797    /// # Example
3798    /// ```ignore,no_run
3799    /// # use google_cloud_optimization_v1::model::Shipment;
3800    /// let x = Shipment::new().set_label("example");
3801    /// ```
3802    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3803        self.label = v.into();
3804        self
3805    }
3806
3807    /// Sets the value of [ignore][crate::model::Shipment::ignore].
3808    ///
3809    /// # Example
3810    /// ```ignore,no_run
3811    /// # use google_cloud_optimization_v1::model::Shipment;
3812    /// let x = Shipment::new().set_ignore(true);
3813    /// ```
3814    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3815        self.ignore = v.into();
3816        self
3817    }
3818
3819    /// Sets the value of [demands][crate::model::Shipment::demands].
3820    ///
3821    /// # Example
3822    /// ```ignore,no_run
3823    /// # use google_cloud_optimization_v1::model::Shipment;
3824    /// use google_cloud_optimization_v1::model::CapacityQuantity;
3825    /// let x = Shipment::new()
3826    ///     .set_demands([
3827    ///         CapacityQuantity::default()/* use setters */,
3828    ///         CapacityQuantity::default()/* use (different) setters */,
3829    ///     ]);
3830    /// ```
3831    #[deprecated]
3832    pub fn set_demands<T, V>(mut self, v: T) -> Self
3833    where
3834        T: std::iter::IntoIterator<Item = V>,
3835        V: std::convert::Into<crate::model::CapacityQuantity>,
3836    {
3837        use std::iter::Iterator;
3838        self.demands = v.into_iter().map(|i| i.into()).collect();
3839        self
3840    }
3841}
3842
3843impl wkt::message::Message for Shipment {
3844    fn typename() -> &'static str {
3845        "type.googleapis.com/google.cloud.optimization.v1.Shipment"
3846    }
3847}
3848
3849/// Defines additional types related to [Shipment].
3850pub mod shipment {
3851    #[allow(unused_imports)]
3852    use super::*;
3853
3854    /// Request for a visit which can be done by a vehicle: it has a geo-location
3855    /// (or two, see below), opening and closing times represented by time windows,
3856    /// and a service duration time (time spent by the vehicle once it has arrived
3857    /// to pickup or drop off goods).
3858    #[derive(Clone, Default, PartialEq)]
3859    #[non_exhaustive]
3860    pub struct VisitRequest {
3861        /// The geo-location where the vehicle arrives when performing this
3862        /// `VisitRequest`. If the shipment model has duration distance matrices,
3863        /// `arrival_location` must not be specified.
3864        pub arrival_location: std::option::Option<gtype::model::LatLng>,
3865
3866        /// The waypoint where the vehicle arrives when performing this
3867        /// `VisitRequest`. If the shipment model has duration distance matrices,
3868        /// `arrival_waypoint` must not be specified.
3869        pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
3870
3871        /// The geo-location where the vehicle departs after completing this
3872        /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
3873        /// If the shipment model has duration distance matrices,
3874        /// `departure_location` must not be specified.
3875        pub departure_location: std::option::Option<gtype::model::LatLng>,
3876
3877        /// The waypoint where the vehicle departs after completing this
3878        /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
3879        /// If the shipment model has duration distance matrices,
3880        /// `departure_waypoint` must not be specified.
3881        pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
3882
3883        /// Specifies tags attached to the visit request.
3884        /// Empty or duplicate strings are not allowed.
3885        pub tags: std::vec::Vec<std::string::String>,
3886
3887        /// Time windows which constrain the arrival time at a visit.
3888        /// Note that a vehicle may depart outside of the arrival time window, i.e.
3889        /// arrival time + duration do not need to be inside a time window. This can
3890        /// result in waiting time if the vehicle arrives before
3891        /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
3892        ///
3893        /// The absence of `TimeWindow` means that the vehicle can perform this visit
3894        /// at any time.
3895        ///
3896        /// Time windows must be disjoint, i.e. no time window must overlap with or
3897        /// be adjacent to another, and they must be in increasing order.
3898        ///
3899        /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
3900        /// be set if there is a single time window.
3901        ///
3902        /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
3903        pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
3904
3905        /// Duration of the visit, i.e. time spent by the vehicle between arrival
3906        /// and departure (to be added to the possible waiting time; see
3907        /// `time_windows`).
3908        pub duration: std::option::Option<wkt::Duration>,
3909
3910        /// Cost to service this visit request on a vehicle route. This can be used
3911        /// to pay different costs for each alternative pickup or delivery of a
3912        /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
3913        /// and must not be negative.
3914        pub cost: f64,
3915
3916        /// Load demands of this visit request. This is just like
3917        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3918        /// field, except that it only applies to this
3919        /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
3920        /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
3921        /// The demands listed here are added to the demands listed in
3922        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
3923        ///
3924        /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
3925        /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
3926        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3927        pub load_demands:
3928            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3929
3930        /// Specifies the types of the visit. This may be used to allocate additional
3931        /// time required for a vehicle to complete this visit (see
3932        /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
3933        ///
3934        /// A type can only appear once.
3935        ///
3936        /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
3937        pub visit_types: std::vec::Vec<std::string::String>,
3938
3939        /// Specifies a label for this `VisitRequest`. This label is reported in the
3940        /// response as `visit_label` in the corresponding
3941        /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3942        ///
3943        /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3944        pub label: std::string::String,
3945
3946        /// Deprecated: Use
3947        /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
3948        /// instead.
3949        ///
3950        /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
3951        #[deprecated]
3952        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3953
3954        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3955    }
3956
3957    impl VisitRequest {
3958        pub fn new() -> Self {
3959            std::default::Default::default()
3960        }
3961
3962        /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3963        ///
3964        /// # Example
3965        /// ```ignore,no_run
3966        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3967        /// use gtype::model::LatLng;
3968        /// let x = VisitRequest::new().set_arrival_location(LatLng::default()/* use setters */);
3969        /// ```
3970        pub fn set_arrival_location<T>(mut self, v: T) -> Self
3971        where
3972            T: std::convert::Into<gtype::model::LatLng>,
3973        {
3974            self.arrival_location = std::option::Option::Some(v.into());
3975            self
3976        }
3977
3978        /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3979        ///
3980        /// # Example
3981        /// ```ignore,no_run
3982        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3983        /// use gtype::model::LatLng;
3984        /// let x = VisitRequest::new().set_or_clear_arrival_location(Some(LatLng::default()/* use setters */));
3985        /// let x = VisitRequest::new().set_or_clear_arrival_location(None::<LatLng>);
3986        /// ```
3987        pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
3988        where
3989            T: std::convert::Into<gtype::model::LatLng>,
3990        {
3991            self.arrival_location = v.map(|x| x.into());
3992            self
3993        }
3994
3995        /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
3996        ///
3997        /// # Example
3998        /// ```ignore,no_run
3999        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4000        /// use google_cloud_optimization_v1::model::Waypoint;
4001        /// let x = VisitRequest::new().set_arrival_waypoint(Waypoint::default()/* use setters */);
4002        /// ```
4003        pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
4004        where
4005            T: std::convert::Into<crate::model::Waypoint>,
4006        {
4007            self.arrival_waypoint = std::option::Option::Some(v.into());
4008            self
4009        }
4010
4011        /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
4012        ///
4013        /// # Example
4014        /// ```ignore,no_run
4015        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4016        /// use google_cloud_optimization_v1::model::Waypoint;
4017        /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(Some(Waypoint::default()/* use setters */));
4018        /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(None::<Waypoint>);
4019        /// ```
4020        pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4021        where
4022            T: std::convert::Into<crate::model::Waypoint>,
4023        {
4024            self.arrival_waypoint = v.map(|x| x.into());
4025            self
4026        }
4027
4028        /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4029        ///
4030        /// # Example
4031        /// ```ignore,no_run
4032        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4033        /// use gtype::model::LatLng;
4034        /// let x = VisitRequest::new().set_departure_location(LatLng::default()/* use setters */);
4035        /// ```
4036        pub fn set_departure_location<T>(mut self, v: T) -> Self
4037        where
4038            T: std::convert::Into<gtype::model::LatLng>,
4039        {
4040            self.departure_location = std::option::Option::Some(v.into());
4041            self
4042        }
4043
4044        /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4045        ///
4046        /// # Example
4047        /// ```ignore,no_run
4048        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4049        /// use gtype::model::LatLng;
4050        /// let x = VisitRequest::new().set_or_clear_departure_location(Some(LatLng::default()/* use setters */));
4051        /// let x = VisitRequest::new().set_or_clear_departure_location(None::<LatLng>);
4052        /// ```
4053        pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
4054        where
4055            T: std::convert::Into<gtype::model::LatLng>,
4056        {
4057            self.departure_location = v.map(|x| x.into());
4058            self
4059        }
4060
4061        /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4062        ///
4063        /// # Example
4064        /// ```ignore,no_run
4065        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4066        /// use google_cloud_optimization_v1::model::Waypoint;
4067        /// let x = VisitRequest::new().set_departure_waypoint(Waypoint::default()/* use setters */);
4068        /// ```
4069        pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
4070        where
4071            T: std::convert::Into<crate::model::Waypoint>,
4072        {
4073            self.departure_waypoint = std::option::Option::Some(v.into());
4074            self
4075        }
4076
4077        /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4078        ///
4079        /// # Example
4080        /// ```ignore,no_run
4081        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4082        /// use google_cloud_optimization_v1::model::Waypoint;
4083        /// let x = VisitRequest::new().set_or_clear_departure_waypoint(Some(Waypoint::default()/* use setters */));
4084        /// let x = VisitRequest::new().set_or_clear_departure_waypoint(None::<Waypoint>);
4085        /// ```
4086        pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4087        where
4088            T: std::convert::Into<crate::model::Waypoint>,
4089        {
4090            self.departure_waypoint = v.map(|x| x.into());
4091            self
4092        }
4093
4094        /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
4095        ///
4096        /// # Example
4097        /// ```ignore,no_run
4098        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4099        /// let x = VisitRequest::new().set_tags(["a", "b", "c"]);
4100        /// ```
4101        pub fn set_tags<T, V>(mut self, v: T) -> Self
4102        where
4103            T: std::iter::IntoIterator<Item = V>,
4104            V: std::convert::Into<std::string::String>,
4105        {
4106            use std::iter::Iterator;
4107            self.tags = v.into_iter().map(|i| i.into()).collect();
4108            self
4109        }
4110
4111        /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
4112        ///
4113        /// # Example
4114        /// ```ignore,no_run
4115        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4116        /// use google_cloud_optimization_v1::model::TimeWindow;
4117        /// let x = VisitRequest::new()
4118        ///     .set_time_windows([
4119        ///         TimeWindow::default()/* use setters */,
4120        ///         TimeWindow::default()/* use (different) setters */,
4121        ///     ]);
4122        /// ```
4123        pub fn set_time_windows<T, V>(mut self, v: T) -> Self
4124        where
4125            T: std::iter::IntoIterator<Item = V>,
4126            V: std::convert::Into<crate::model::TimeWindow>,
4127        {
4128            use std::iter::Iterator;
4129            self.time_windows = v.into_iter().map(|i| i.into()).collect();
4130            self
4131        }
4132
4133        /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
4134        ///
4135        /// # Example
4136        /// ```ignore,no_run
4137        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4138        /// use wkt::Duration;
4139        /// let x = VisitRequest::new().set_duration(Duration::default()/* use setters */);
4140        /// ```
4141        pub fn set_duration<T>(mut self, v: T) -> Self
4142        where
4143            T: std::convert::Into<wkt::Duration>,
4144        {
4145            self.duration = std::option::Option::Some(v.into());
4146            self
4147        }
4148
4149        /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
4150        ///
4151        /// # Example
4152        /// ```ignore,no_run
4153        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4154        /// use wkt::Duration;
4155        /// let x = VisitRequest::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
4156        /// let x = VisitRequest::new().set_or_clear_duration(None::<Duration>);
4157        /// ```
4158        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
4159        where
4160            T: std::convert::Into<wkt::Duration>,
4161        {
4162            self.duration = v.map(|x| x.into());
4163            self
4164        }
4165
4166        /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
4167        ///
4168        /// # Example
4169        /// ```ignore,no_run
4170        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4171        /// let x = VisitRequest::new().set_cost(42.0);
4172        /// ```
4173        pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4174            self.cost = v.into();
4175            self
4176        }
4177
4178        /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
4179        ///
4180        /// # Example
4181        /// ```ignore,no_run
4182        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4183        /// use google_cloud_optimization_v1::model::shipment::Load;
4184        /// let x = VisitRequest::new().set_load_demands([
4185        ///     ("key0", Load::default()/* use setters */),
4186        ///     ("key1", Load::default()/* use (different) setters */),
4187        /// ]);
4188        /// ```
4189        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
4190        where
4191            T: std::iter::IntoIterator<Item = (K, V)>,
4192            K: std::convert::Into<std::string::String>,
4193            V: std::convert::Into<crate::model::shipment::Load>,
4194        {
4195            use std::iter::Iterator;
4196            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4197            self
4198        }
4199
4200        /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
4201        ///
4202        /// # Example
4203        /// ```ignore,no_run
4204        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4205        /// let x = VisitRequest::new().set_visit_types(["a", "b", "c"]);
4206        /// ```
4207        pub fn set_visit_types<T, V>(mut self, v: T) -> Self
4208        where
4209            T: std::iter::IntoIterator<Item = V>,
4210            V: std::convert::Into<std::string::String>,
4211        {
4212            use std::iter::Iterator;
4213            self.visit_types = v.into_iter().map(|i| i.into()).collect();
4214            self
4215        }
4216
4217        /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
4218        ///
4219        /// # Example
4220        /// ```ignore,no_run
4221        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4222        /// let x = VisitRequest::new().set_label("example");
4223        /// ```
4224        pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4225            self.label = v.into();
4226            self
4227        }
4228
4229        /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
4230        ///
4231        /// # Example
4232        /// ```ignore,no_run
4233        /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4234        /// use google_cloud_optimization_v1::model::CapacityQuantity;
4235        /// let x = VisitRequest::new()
4236        ///     .set_demands([
4237        ///         CapacityQuantity::default()/* use setters */,
4238        ///         CapacityQuantity::default()/* use (different) setters */,
4239        ///     ]);
4240        /// ```
4241        #[deprecated]
4242        pub fn set_demands<T, V>(mut self, v: T) -> Self
4243        where
4244            T: std::iter::IntoIterator<Item = V>,
4245            V: std::convert::Into<crate::model::CapacityQuantity>,
4246        {
4247            use std::iter::Iterator;
4248            self.demands = v.into_iter().map(|i| i.into()).collect();
4249            self
4250        }
4251    }
4252
4253    impl wkt::message::Message for VisitRequest {
4254        fn typename() -> &'static str {
4255            "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
4256        }
4257    }
4258
4259    /// When performing a visit, a predefined amount may be added to the vehicle
4260    /// load if it's a pickup, or subtracted if it's a delivery. This message
4261    /// defines such amount. See
4262    /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
4263    ///
4264    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4265    #[derive(Clone, Default, PartialEq)]
4266    #[non_exhaustive]
4267    pub struct Load {
4268        /// The amount by which the load of the vehicle performing the corresponding
4269        /// visit will vary. Since it is an integer, users are advised to choose an
4270        /// appropriate unit to avoid loss of precision. Must be ≥ 0.
4271        pub amount: i64,
4272
4273        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4274    }
4275
4276    impl Load {
4277        pub fn new() -> Self {
4278            std::default::Default::default()
4279        }
4280
4281        /// Sets the value of [amount][crate::model::shipment::Load::amount].
4282        ///
4283        /// # Example
4284        /// ```ignore,no_run
4285        /// # use google_cloud_optimization_v1::model::shipment::Load;
4286        /// let x = Load::new().set_amount(42);
4287        /// ```
4288        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4289            self.amount = v.into();
4290            self
4291        }
4292    }
4293
4294    impl wkt::message::Message for Load {
4295        fn typename() -> &'static str {
4296            "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
4297        }
4298    }
4299}
4300
4301/// Specifies incompatibilties between shipments depending on their
4302/// shipment_type. The appearance of incompatible shipments on the same route is
4303/// restricted based on the incompatibility mode.
4304#[derive(Clone, Default, PartialEq)]
4305#[non_exhaustive]
4306pub struct ShipmentTypeIncompatibility {
4307    /// List of incompatible types. Two shipments having different `shipment_types`
4308    /// among those listed are "incompatible".
4309    pub types: std::vec::Vec<std::string::String>,
4310
4311    /// Mode applied to the incompatibility.
4312    pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
4313
4314    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4315}
4316
4317impl ShipmentTypeIncompatibility {
4318    pub fn new() -> Self {
4319        std::default::Default::default()
4320    }
4321
4322    /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
4323    ///
4324    /// # Example
4325    /// ```ignore,no_run
4326    /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4327    /// let x = ShipmentTypeIncompatibility::new().set_types(["a", "b", "c"]);
4328    /// ```
4329    pub fn set_types<T, V>(mut self, v: T) -> Self
4330    where
4331        T: std::iter::IntoIterator<Item = V>,
4332        V: std::convert::Into<std::string::String>,
4333    {
4334        use std::iter::Iterator;
4335        self.types = v.into_iter().map(|i| i.into()).collect();
4336        self
4337    }
4338
4339    /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
4340    ///
4341    /// # Example
4342    /// ```ignore,no_run
4343    /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4344    /// use google_cloud_optimization_v1::model::shipment_type_incompatibility::IncompatibilityMode;
4345    /// let x0 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotPerformedBySameVehicle);
4346    /// let x1 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotInSameVehicleSimultaneously);
4347    /// ```
4348    pub fn set_incompatibility_mode<
4349        T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
4350    >(
4351        mut self,
4352        v: T,
4353    ) -> Self {
4354        self.incompatibility_mode = v.into();
4355        self
4356    }
4357}
4358
4359impl wkt::message::Message for ShipmentTypeIncompatibility {
4360    fn typename() -> &'static str {
4361        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
4362    }
4363}
4364
4365/// Defines additional types related to [ShipmentTypeIncompatibility].
4366pub mod shipment_type_incompatibility {
4367    #[allow(unused_imports)]
4368    use super::*;
4369
4370    /// Modes defining how the appearance of incompatible shipments are restricted
4371    /// on the same route.
4372    ///
4373    /// # Working with unknown values
4374    ///
4375    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4376    /// additional enum variants at any time. Adding new variants is not considered
4377    /// a breaking change. Applications should write their code in anticipation of:
4378    ///
4379    /// - New values appearing in future releases of the client library, **and**
4380    /// - New values received dynamically, without application changes.
4381    ///
4382    /// Please consult the [Working with enums] section in the user guide for some
4383    /// guidelines.
4384    ///
4385    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4386    #[derive(Clone, Debug, PartialEq)]
4387    #[non_exhaustive]
4388    pub enum IncompatibilityMode {
4389        /// Unspecified incompatibility mode. This value should never be used.
4390        Unspecified,
4391        /// In this mode, two shipments with incompatible types can never share the
4392        /// same vehicle.
4393        NotPerformedBySameVehicle,
4394        /// For two shipments with incompatible types with the
4395        /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
4396        ///
4397        /// * If both are pickups only (no deliveries) or deliveries only (no
4398        ///   pickups), they cannot share the same vehicle at all.
4399        /// * If one of the shipments has a delivery and the other a pickup, the two
4400        ///   shipments can share the same vehicle iff the former shipment is
4401        ///   delivered before the latter is picked up.
4402        NotInSameVehicleSimultaneously,
4403        /// If set, the enum was initialized with an unknown value.
4404        ///
4405        /// Applications can examine the value using [IncompatibilityMode::value] or
4406        /// [IncompatibilityMode::name].
4407        UnknownValue(incompatibility_mode::UnknownValue),
4408    }
4409
4410    #[doc(hidden)]
4411    pub mod incompatibility_mode {
4412        #[allow(unused_imports)]
4413        use super::*;
4414        #[derive(Clone, Debug, PartialEq)]
4415        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4416    }
4417
4418    impl IncompatibilityMode {
4419        /// Gets the enum value.
4420        ///
4421        /// Returns `None` if the enum contains an unknown value deserialized from
4422        /// the string representation of enums.
4423        pub fn value(&self) -> std::option::Option<i32> {
4424            match self {
4425                Self::Unspecified => std::option::Option::Some(0),
4426                Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
4427                Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
4428                Self::UnknownValue(u) => u.0.value(),
4429            }
4430        }
4431
4432        /// Gets the enum value as a string.
4433        ///
4434        /// Returns `None` if the enum contains an unknown value deserialized from
4435        /// the integer representation of enums.
4436        pub fn name(&self) -> std::option::Option<&str> {
4437            match self {
4438                Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
4439                Self::NotPerformedBySameVehicle => {
4440                    std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
4441                }
4442                Self::NotInSameVehicleSimultaneously => {
4443                    std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
4444                }
4445                Self::UnknownValue(u) => u.0.name(),
4446            }
4447        }
4448    }
4449
4450    impl std::default::Default for IncompatibilityMode {
4451        fn default() -> Self {
4452            use std::convert::From;
4453            Self::from(0)
4454        }
4455    }
4456
4457    impl std::fmt::Display for IncompatibilityMode {
4458        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4459            wkt::internal::display_enum(f, self.name(), self.value())
4460        }
4461    }
4462
4463    impl std::convert::From<i32> for IncompatibilityMode {
4464        fn from(value: i32) -> Self {
4465            match value {
4466                0 => Self::Unspecified,
4467                1 => Self::NotPerformedBySameVehicle,
4468                2 => Self::NotInSameVehicleSimultaneously,
4469                _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4470                    wkt::internal::UnknownEnumValue::Integer(value),
4471                )),
4472            }
4473        }
4474    }
4475
4476    impl std::convert::From<&str> for IncompatibilityMode {
4477        fn from(value: &str) -> Self {
4478            use std::string::ToString;
4479            match value {
4480                "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
4481                "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
4482                "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
4483                _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4484                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4485                )),
4486            }
4487        }
4488    }
4489
4490    impl serde::ser::Serialize for IncompatibilityMode {
4491        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4492        where
4493            S: serde::Serializer,
4494        {
4495            match self {
4496                Self::Unspecified => serializer.serialize_i32(0),
4497                Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
4498                Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
4499                Self::UnknownValue(u) => u.0.serialize(serializer),
4500            }
4501        }
4502    }
4503
4504    impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
4505        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4506        where
4507            D: serde::Deserializer<'de>,
4508        {
4509            deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
4510                ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
4511            ))
4512        }
4513    }
4514}
4515
4516/// Specifies requirements between shipments based on their shipment_type.
4517/// The specifics of the requirement are defined by the requirement mode.
4518#[derive(Clone, Default, PartialEq)]
4519#[non_exhaustive]
4520pub struct ShipmentTypeRequirement {
4521    /// List of alternative shipment types required by the
4522    /// `dependent_shipment_types`.
4523    pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
4524
4525    /// All shipments with a type in the `dependent_shipment_types` field require
4526    /// at least one shipment of type `required_shipment_type_alternatives` to be
4527    /// visited on the same route.
4528    ///
4529    /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
4530    /// are not allowed.
4531    pub dependent_shipment_types: std::vec::Vec<std::string::String>,
4532
4533    /// Mode applied to the requirement.
4534    pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
4535
4536    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4537}
4538
4539impl ShipmentTypeRequirement {
4540    pub fn new() -> Self {
4541        std::default::Default::default()
4542    }
4543
4544    /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
4545    ///
4546    /// # Example
4547    /// ```ignore,no_run
4548    /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4549    /// let x = ShipmentTypeRequirement::new().set_required_shipment_type_alternatives(["a", "b", "c"]);
4550    /// ```
4551    pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
4552    where
4553        T: std::iter::IntoIterator<Item = V>,
4554        V: std::convert::Into<std::string::String>,
4555    {
4556        use std::iter::Iterator;
4557        self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
4558        self
4559    }
4560
4561    /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
4562    ///
4563    /// # Example
4564    /// ```ignore,no_run
4565    /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4566    /// let x = ShipmentTypeRequirement::new().set_dependent_shipment_types(["a", "b", "c"]);
4567    /// ```
4568    pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
4569    where
4570        T: std::iter::IntoIterator<Item = V>,
4571        V: std::convert::Into<std::string::String>,
4572    {
4573        use std::iter::Iterator;
4574        self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
4575        self
4576    }
4577
4578    /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
4579    ///
4580    /// # Example
4581    /// ```ignore,no_run
4582    /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4583    /// use google_cloud_optimization_v1::model::shipment_type_requirement::RequirementMode;
4584    /// let x0 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::PerformedBySameVehicle);
4585    /// let x1 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtPickupTime);
4586    /// let x2 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtDeliveryTime);
4587    /// ```
4588    pub fn set_requirement_mode<
4589        T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
4590    >(
4591        mut self,
4592        v: T,
4593    ) -> Self {
4594        self.requirement_mode = v.into();
4595        self
4596    }
4597}
4598
4599impl wkt::message::Message for ShipmentTypeRequirement {
4600    fn typename() -> &'static str {
4601        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
4602    }
4603}
4604
4605/// Defines additional types related to [ShipmentTypeRequirement].
4606pub mod shipment_type_requirement {
4607    #[allow(unused_imports)]
4608    use super::*;
4609
4610    /// Modes defining the appearance of dependent shipments on a route.
4611    ///
4612    /// # Working with unknown values
4613    ///
4614    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4615    /// additional enum variants at any time. Adding new variants is not considered
4616    /// a breaking change. Applications should write their code in anticipation of:
4617    ///
4618    /// - New values appearing in future releases of the client library, **and**
4619    /// - New values received dynamically, without application changes.
4620    ///
4621    /// Please consult the [Working with enums] section in the user guide for some
4622    /// guidelines.
4623    ///
4624    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4625    #[derive(Clone, Debug, PartialEq)]
4626    #[non_exhaustive]
4627    pub enum RequirementMode {
4628        /// Unspecified requirement mode. This value should never be used.
4629        Unspecified,
4630        /// In this mode, all "dependent" shipments must share the same vehicle as at
4631        /// least one of their "required" shipments.
4632        PerformedBySameVehicle,
4633        /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
4634        /// shipments need to have at least one "required" shipment on their vehicle
4635        /// at the time of their pickup.
4636        ///
4637        /// A "dependent" shipment pickup must therefore have either:
4638        ///
4639        /// * A delivery-only "required" shipment delivered on the route after, or
4640        /// * A "required" shipment picked up on the route before it, and if the
4641        ///   "required" shipment has a delivery, this delivery must be performed
4642        ///   after the "dependent" shipment's pickup.
4643        InSameVehicleAtPickupTime,
4644        /// Same as before, except the "dependent" shipments need to have a
4645        /// "required" shipment on their vehicle at the time of their *delivery*.
4646        InSameVehicleAtDeliveryTime,
4647        /// If set, the enum was initialized with an unknown value.
4648        ///
4649        /// Applications can examine the value using [RequirementMode::value] or
4650        /// [RequirementMode::name].
4651        UnknownValue(requirement_mode::UnknownValue),
4652    }
4653
4654    #[doc(hidden)]
4655    pub mod requirement_mode {
4656        #[allow(unused_imports)]
4657        use super::*;
4658        #[derive(Clone, Debug, PartialEq)]
4659        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4660    }
4661
4662    impl RequirementMode {
4663        /// Gets the enum value.
4664        ///
4665        /// Returns `None` if the enum contains an unknown value deserialized from
4666        /// the string representation of enums.
4667        pub fn value(&self) -> std::option::Option<i32> {
4668            match self {
4669                Self::Unspecified => std::option::Option::Some(0),
4670                Self::PerformedBySameVehicle => std::option::Option::Some(1),
4671                Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
4672                Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
4673                Self::UnknownValue(u) => u.0.value(),
4674            }
4675        }
4676
4677        /// Gets the enum value as a string.
4678        ///
4679        /// Returns `None` if the enum contains an unknown value deserialized from
4680        /// the integer representation of enums.
4681        pub fn name(&self) -> std::option::Option<&str> {
4682            match self {
4683                Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
4684                Self::PerformedBySameVehicle => {
4685                    std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
4686                }
4687                Self::InSameVehicleAtPickupTime => {
4688                    std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
4689                }
4690                Self::InSameVehicleAtDeliveryTime => {
4691                    std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
4692                }
4693                Self::UnknownValue(u) => u.0.name(),
4694            }
4695        }
4696    }
4697
4698    impl std::default::Default for RequirementMode {
4699        fn default() -> Self {
4700            use std::convert::From;
4701            Self::from(0)
4702        }
4703    }
4704
4705    impl std::fmt::Display for RequirementMode {
4706        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4707            wkt::internal::display_enum(f, self.name(), self.value())
4708        }
4709    }
4710
4711    impl std::convert::From<i32> for RequirementMode {
4712        fn from(value: i32) -> Self {
4713            match value {
4714                0 => Self::Unspecified,
4715                1 => Self::PerformedBySameVehicle,
4716                2 => Self::InSameVehicleAtPickupTime,
4717                3 => Self::InSameVehicleAtDeliveryTime,
4718                _ => Self::UnknownValue(requirement_mode::UnknownValue(
4719                    wkt::internal::UnknownEnumValue::Integer(value),
4720                )),
4721            }
4722        }
4723    }
4724
4725    impl std::convert::From<&str> for RequirementMode {
4726        fn from(value: &str) -> Self {
4727            use std::string::ToString;
4728            match value {
4729                "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
4730                "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
4731                "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
4732                "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
4733                _ => Self::UnknownValue(requirement_mode::UnknownValue(
4734                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4735                )),
4736            }
4737        }
4738    }
4739
4740    impl serde::ser::Serialize for RequirementMode {
4741        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4742        where
4743            S: serde::Serializer,
4744        {
4745            match self {
4746                Self::Unspecified => serializer.serialize_i32(0),
4747                Self::PerformedBySameVehicle => serializer.serialize_i32(1),
4748                Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
4749                Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
4750                Self::UnknownValue(u) => u.0.serialize(serializer),
4751            }
4752        }
4753    }
4754
4755    impl<'de> serde::de::Deserialize<'de> for RequirementMode {
4756        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4757        where
4758            D: serde::Deserializer<'de>,
4759        {
4760            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
4761                ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
4762            ))
4763        }
4764    }
4765}
4766
4767/// Encapsulates a set of optional conditions to satisfy when calculating
4768/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
4769/// Platform API; see:
4770/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
4771#[derive(Clone, Default, PartialEq)]
4772#[non_exhaustive]
4773pub struct RouteModifiers {
4774    /// Specifies whether to avoid toll roads where reasonable. Preference will be
4775    /// given to routes not containing toll roads. Applies only to motorized travel
4776    /// modes.
4777    pub avoid_tolls: bool,
4778
4779    /// Specifies whether to avoid highways where reasonable. Preference will be
4780    /// given to routes not containing highways. Applies only to motorized travel
4781    /// modes.
4782    pub avoid_highways: bool,
4783
4784    /// Specifies whether to avoid ferries where reasonable. Preference will be
4785    /// given to routes not containing travel by ferries. Applies only to motorized
4786    /// travel modes.
4787    pub avoid_ferries: bool,
4788
4789    /// Optional. Specifies whether to avoid navigating indoors where reasonable.
4790    /// Preference will be given to routes not containing indoor navigation.
4791    /// Applies only to the `WALKING` travel mode.
4792    pub avoid_indoor: bool,
4793
4794    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4795}
4796
4797impl RouteModifiers {
4798    pub fn new() -> Self {
4799        std::default::Default::default()
4800    }
4801
4802    /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
4803    ///
4804    /// # Example
4805    /// ```ignore,no_run
4806    /// # use google_cloud_optimization_v1::model::RouteModifiers;
4807    /// let x = RouteModifiers::new().set_avoid_tolls(true);
4808    /// ```
4809    pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4810        self.avoid_tolls = v.into();
4811        self
4812    }
4813
4814    /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
4815    ///
4816    /// # Example
4817    /// ```ignore,no_run
4818    /// # use google_cloud_optimization_v1::model::RouteModifiers;
4819    /// let x = RouteModifiers::new().set_avoid_highways(true);
4820    /// ```
4821    pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4822        self.avoid_highways = v.into();
4823        self
4824    }
4825
4826    /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
4827    ///
4828    /// # Example
4829    /// ```ignore,no_run
4830    /// # use google_cloud_optimization_v1::model::RouteModifiers;
4831    /// let x = RouteModifiers::new().set_avoid_ferries(true);
4832    /// ```
4833    pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4834        self.avoid_ferries = v.into();
4835        self
4836    }
4837
4838    /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
4839    ///
4840    /// # Example
4841    /// ```ignore,no_run
4842    /// # use google_cloud_optimization_v1::model::RouteModifiers;
4843    /// let x = RouteModifiers::new().set_avoid_indoor(true);
4844    /// ```
4845    pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4846        self.avoid_indoor = v.into();
4847        self
4848    }
4849}
4850
4851impl wkt::message::Message for RouteModifiers {
4852    fn typename() -> &'static str {
4853        "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
4854    }
4855}
4856
4857/// Models a vehicle in a shipment problem. Solving a shipment problem will
4858/// build a route starting from `start_location` and ending at `end_location`
4859/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
4860#[derive(Clone, Default, PartialEq)]
4861#[non_exhaustive]
4862pub struct Vehicle {
4863    /// The travel mode which affects the roads usable by the vehicle and its
4864    /// speed. See also `travel_duration_multiple`.
4865    pub travel_mode: crate::model::vehicle::TravelMode,
4866
4867    /// Optional. A set of conditions to satisfy that affect the way routes are
4868    /// calculated for the given vehicle.
4869    pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
4870
4871    /// Geographic location where the vehicle starts before picking up any
4872    /// shipments. If not specified, the vehicle starts at its first pickup.
4873    /// If the shipment model has duration and distance matrices, `start_location`
4874    /// must not be specified.
4875    pub start_location: std::option::Option<gtype::model::LatLng>,
4876
4877    /// Waypoint representing a geographic location where the vehicle starts before
4878    /// picking up any shipments. If neither `start_waypoint` nor `start_location`
4879    /// is specified, the vehicle starts at its first pickup.
4880    /// If the shipment model has duration and distance matrices, `start_waypoint`
4881    /// must not be specified.
4882    pub start_waypoint: std::option::Option<crate::model::Waypoint>,
4883
4884    /// Geographic location where the vehicle ends after it has completed its last
4885    /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
4886    /// immediately when it completes its last `VisitRequest`.
4887    /// If the shipment model has duration and distance matrices, `end_location`
4888    /// must not be specified.
4889    pub end_location: std::option::Option<gtype::model::LatLng>,
4890
4891    /// Waypoint representing a geographic location where the vehicle ends after
4892    /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
4893    /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
4894    /// when it completes its last `VisitRequest`.
4895    /// If the shipment model has duration and distance matrices, `end_waypoint`
4896    /// must not be specified.
4897    pub end_waypoint: std::option::Option<crate::model::Waypoint>,
4898
4899    /// Specifies tags attached to the start of the vehicle's route.
4900    ///
4901    /// Empty or duplicate strings are not allowed.
4902    pub start_tags: std::vec::Vec<std::string::String>,
4903
4904    /// Specifies tags attached to the end of the vehicle's route.
4905    ///
4906    /// Empty or duplicate strings are not allowed.
4907    pub end_tags: std::vec::Vec<std::string::String>,
4908
4909    /// Time windows during which the vehicle may depart its start location.
4910    /// They must be within the global time limits (see
4911    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4912    /// fields). If unspecified, there is no limitation besides those global time
4913    /// limits.
4914    ///
4915    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4916    /// time window can overlap with or be adjacent to another, and they must be in
4917    /// chronological order.
4918    ///
4919    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4920    /// there is a single time window.
4921    ///
4922    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4923    pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4924
4925    /// Time windows during which the vehicle may arrive at its end location.
4926    /// They must be within the global time limits (see
4927    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4928    /// fields). If unspecified, there is no limitation besides those global time
4929    /// limits.
4930    ///
4931    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4932    /// time window can overlap with or be adjacent to another, and they must be in
4933    /// chronological order.
4934    ///
4935    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4936    /// there is a single time window.
4937    ///
4938    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4939    pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4940
4941    /// Specifies a multiplicative factor that can be used to increase or decrease
4942    /// travel times of this vehicle. For example, setting this to 2.0 means
4943    /// that this vehicle is slower and has travel times that are twice what they
4944    /// are for standard vehicles. This multiple does not affect visit durations.
4945    /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
4946    /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
4947    /// is standard, and this multiple is considered 1.0.
4948    ///
4949    /// WARNING: Travel times will be rounded to the nearest second after this
4950    /// multiple is applied but before performing any numerical operations, thus,
4951    /// a small multiple may result in a loss of precision.
4952    ///
4953    /// See also `extra_visit_duration_for_visit_type` below.
4954    pub travel_duration_multiple: std::option::Option<f64>,
4955
4956    /// Unloading policy enforced on the vehicle.
4957    pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
4958
4959    /// Capacities of the vehicle (weight, volume, # of pallets for example).
4960    /// The keys in the map are the identifiers of the type of load, consistent
4961    /// with the keys of the
4962    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
4963    /// field. If a given key is absent from this map, the corresponding capacity
4964    /// is considered to be limitless.
4965    ///
4966    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4967    pub load_limits:
4968        std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
4969
4970    /// Vehicle costs: all costs add up and must be in the same unit as
4971    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
4972    ///
4973    /// Cost per hour of the vehicle route. This cost is applied to the total time
4974    /// taken by the route, and includes travel time, waiting time, and visit time.
4975    /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
4976    /// in additional latency.
4977    ///
4978    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
4979    pub cost_per_hour: f64,
4980
4981    /// Cost per traveled hour of the vehicle route. This cost is applied only to
4982    /// travel time taken by the route (i.e., that reported in
4983    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
4984    /// and excludes waiting time and visit time.
4985    ///
4986    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
4987    pub cost_per_traveled_hour: f64,
4988
4989    /// Cost per kilometer of the vehicle route. This cost is applied to the
4990    /// distance reported in the
4991    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
4992    /// and does not apply to any distance implicitly traveled from the
4993    /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
4994    ///
4995    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
4996    pub cost_per_kilometer: f64,
4997
4998    /// Fixed cost applied if this vehicle is used to handle a shipment.
4999    pub fixed_cost: f64,
5000
5001    /// This field only applies to vehicles when their route does not serve any
5002    /// shipments. It indicates if the vehicle should be considered as used or not
5003    /// in this case.
5004    ///
5005    /// If true, the vehicle goes from its start to its end location even if it
5006    /// doesn't serve any shipments, and time and distance costs resulting from its
5007    /// start --> end travel are taken into account.
5008    ///
5009    /// Otherwise, it doesn't travel from its start to its end location, and no
5010    /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
5011    /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
5012    /// information except for the vehicle index and label.
5013    pub used_if_route_is_empty: bool,
5014
5015    /// Limit applied to the total duration of the vehicle's route. In a given
5016    /// `OptimizeToursResponse`, the route duration of a vehicle is the
5017    /// difference between its `vehicle_end_time` and `vehicle_start_time`.
5018    pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5019
5020    /// Limit applied to the travel duration of the vehicle's route. In a given
5021    /// `OptimizeToursResponse`, the route travel duration is the sum of all its
5022    /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
5023    ///
5024    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
5025    pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5026
5027    /// Limit applied to the total distance of the vehicle's route. In a given
5028    /// `OptimizeToursResponse`, the route distance is the sum of all its
5029    /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
5030    ///
5031    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
5032    pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
5033
5034    /// Specifies a map from visit_types strings to durations. The duration is time
5035    /// in addition to
5036    /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
5037    /// to be taken at visits with the specified `visit_types`. This extra visit
5038    /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
5039    /// `visit_types`) cannot be empty strings.
5040    ///
5041    /// If a visit request has multiple types, a duration will be added for each
5042    /// type in the map.
5043    ///
5044    /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
5045    pub extra_visit_duration_for_visit_type:
5046        std::collections::HashMap<std::string::String, wkt::Duration>,
5047
5048    /// Describes the break schedule to be enforced on this vehicle.
5049    /// If empty, no breaks will be scheduled for this vehicle.
5050    pub break_rule: std::option::Option<crate::model::BreakRule>,
5051
5052    /// Specifies a label for this vehicle. This label is reported in the response
5053    /// as the `vehicle_label` of the corresponding
5054    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
5055    ///
5056    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
5057    pub label: std::string::String,
5058
5059    /// If true, `used_if_route_is_empty` must be false, and this vehicle will
5060    /// remain unused.
5061    ///
5062    /// If a shipment is performed by an ignored vehicle in
5063    /// `injected_first_solution_routes`, it is skipped in the first solution but
5064    /// is free to be performed in the response.
5065    ///
5066    /// If a shipment is performed by an ignored vehicle in
5067    /// `injected_solution_constraint` and any related pickup/delivery is
5068    /// constrained to remain on the vehicle (i.e., not relaxed to level
5069    /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
5070    /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
5071    /// the allowed vehicles are ignored, it is skipped in the response.
5072    pub ignore: bool,
5073
5074    /// Deprecated: No longer used.
5075    /// Indices in the `break_rule` field in the source
5076    /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
5077    /// correspond to break rules enforced on the vehicle.
5078    ///
5079    /// As of 2018/03, at most one rule index per vehicle can be specified.
5080    ///
5081    /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
5082    #[deprecated]
5083    pub break_rule_indices: std::vec::Vec<i32>,
5084
5085    /// Deprecated: Use
5086    /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
5087    /// instead.
5088    ///
5089    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5090    #[deprecated]
5091    pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
5092
5093    /// Deprecated: Use
5094    /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
5095    /// instead.
5096    ///
5097    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
5098    #[deprecated]
5099    pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5100
5101    /// Deprecated: Use
5102    /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
5103    /// instead.
5104    ///
5105    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
5106    #[deprecated]
5107    pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5108
5109    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5110}
5111
5112impl Vehicle {
5113    pub fn new() -> Self {
5114        std::default::Default::default()
5115    }
5116
5117    /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
5118    ///
5119    /// # Example
5120    /// ```ignore,no_run
5121    /// # use google_cloud_optimization_v1::model::Vehicle;
5122    /// use google_cloud_optimization_v1::model::vehicle::TravelMode;
5123    /// let x0 = Vehicle::new().set_travel_mode(TravelMode::Driving);
5124    /// let x1 = Vehicle::new().set_travel_mode(TravelMode::Walking);
5125    /// ```
5126    pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
5127        mut self,
5128        v: T,
5129    ) -> Self {
5130        self.travel_mode = v.into();
5131        self
5132    }
5133
5134    /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5135    ///
5136    /// # Example
5137    /// ```ignore,no_run
5138    /// # use google_cloud_optimization_v1::model::Vehicle;
5139    /// use google_cloud_optimization_v1::model::RouteModifiers;
5140    /// let x = Vehicle::new().set_route_modifiers(RouteModifiers::default()/* use setters */);
5141    /// ```
5142    pub fn set_route_modifiers<T>(mut self, v: T) -> Self
5143    where
5144        T: std::convert::Into<crate::model::RouteModifiers>,
5145    {
5146        self.route_modifiers = std::option::Option::Some(v.into());
5147        self
5148    }
5149
5150    /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5151    ///
5152    /// # Example
5153    /// ```ignore,no_run
5154    /// # use google_cloud_optimization_v1::model::Vehicle;
5155    /// use google_cloud_optimization_v1::model::RouteModifiers;
5156    /// let x = Vehicle::new().set_or_clear_route_modifiers(Some(RouteModifiers::default()/* use setters */));
5157    /// let x = Vehicle::new().set_or_clear_route_modifiers(None::<RouteModifiers>);
5158    /// ```
5159    pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
5160    where
5161        T: std::convert::Into<crate::model::RouteModifiers>,
5162    {
5163        self.route_modifiers = v.map(|x| x.into());
5164        self
5165    }
5166
5167    /// Sets the value of [start_location][crate::model::Vehicle::start_location].
5168    ///
5169    /// # Example
5170    /// ```ignore,no_run
5171    /// # use google_cloud_optimization_v1::model::Vehicle;
5172    /// use gtype::model::LatLng;
5173    /// let x = Vehicle::new().set_start_location(LatLng::default()/* use setters */);
5174    /// ```
5175    pub fn set_start_location<T>(mut self, v: T) -> Self
5176    where
5177        T: std::convert::Into<gtype::model::LatLng>,
5178    {
5179        self.start_location = std::option::Option::Some(v.into());
5180        self
5181    }
5182
5183    /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
5184    ///
5185    /// # Example
5186    /// ```ignore,no_run
5187    /// # use google_cloud_optimization_v1::model::Vehicle;
5188    /// use gtype::model::LatLng;
5189    /// let x = Vehicle::new().set_or_clear_start_location(Some(LatLng::default()/* use setters */));
5190    /// let x = Vehicle::new().set_or_clear_start_location(None::<LatLng>);
5191    /// ```
5192    pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
5193    where
5194        T: std::convert::Into<gtype::model::LatLng>,
5195    {
5196        self.start_location = v.map(|x| x.into());
5197        self
5198    }
5199
5200    /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5201    ///
5202    /// # Example
5203    /// ```ignore,no_run
5204    /// # use google_cloud_optimization_v1::model::Vehicle;
5205    /// use google_cloud_optimization_v1::model::Waypoint;
5206    /// let x = Vehicle::new().set_start_waypoint(Waypoint::default()/* use setters */);
5207    /// ```
5208    pub fn set_start_waypoint<T>(mut self, v: T) -> Self
5209    where
5210        T: std::convert::Into<crate::model::Waypoint>,
5211    {
5212        self.start_waypoint = std::option::Option::Some(v.into());
5213        self
5214    }
5215
5216    /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5217    ///
5218    /// # Example
5219    /// ```ignore,no_run
5220    /// # use google_cloud_optimization_v1::model::Vehicle;
5221    /// use google_cloud_optimization_v1::model::Waypoint;
5222    /// let x = Vehicle::new().set_or_clear_start_waypoint(Some(Waypoint::default()/* use setters */));
5223    /// let x = Vehicle::new().set_or_clear_start_waypoint(None::<Waypoint>);
5224    /// ```
5225    pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5226    where
5227        T: std::convert::Into<crate::model::Waypoint>,
5228    {
5229        self.start_waypoint = v.map(|x| x.into());
5230        self
5231    }
5232
5233    /// Sets the value of [end_location][crate::model::Vehicle::end_location].
5234    ///
5235    /// # Example
5236    /// ```ignore,no_run
5237    /// # use google_cloud_optimization_v1::model::Vehicle;
5238    /// use gtype::model::LatLng;
5239    /// let x = Vehicle::new().set_end_location(LatLng::default()/* use setters */);
5240    /// ```
5241    pub fn set_end_location<T>(mut self, v: T) -> Self
5242    where
5243        T: std::convert::Into<gtype::model::LatLng>,
5244    {
5245        self.end_location = std::option::Option::Some(v.into());
5246        self
5247    }
5248
5249    /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
5250    ///
5251    /// # Example
5252    /// ```ignore,no_run
5253    /// # use google_cloud_optimization_v1::model::Vehicle;
5254    /// use gtype::model::LatLng;
5255    /// let x = Vehicle::new().set_or_clear_end_location(Some(LatLng::default()/* use setters */));
5256    /// let x = Vehicle::new().set_or_clear_end_location(None::<LatLng>);
5257    /// ```
5258    pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
5259    where
5260        T: std::convert::Into<gtype::model::LatLng>,
5261    {
5262        self.end_location = v.map(|x| x.into());
5263        self
5264    }
5265
5266    /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5267    ///
5268    /// # Example
5269    /// ```ignore,no_run
5270    /// # use google_cloud_optimization_v1::model::Vehicle;
5271    /// use google_cloud_optimization_v1::model::Waypoint;
5272    /// let x = Vehicle::new().set_end_waypoint(Waypoint::default()/* use setters */);
5273    /// ```
5274    pub fn set_end_waypoint<T>(mut self, v: T) -> Self
5275    where
5276        T: std::convert::Into<crate::model::Waypoint>,
5277    {
5278        self.end_waypoint = std::option::Option::Some(v.into());
5279        self
5280    }
5281
5282    /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5283    ///
5284    /// # Example
5285    /// ```ignore,no_run
5286    /// # use google_cloud_optimization_v1::model::Vehicle;
5287    /// use google_cloud_optimization_v1::model::Waypoint;
5288    /// let x = Vehicle::new().set_or_clear_end_waypoint(Some(Waypoint::default()/* use setters */));
5289    /// let x = Vehicle::new().set_or_clear_end_waypoint(None::<Waypoint>);
5290    /// ```
5291    pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5292    where
5293        T: std::convert::Into<crate::model::Waypoint>,
5294    {
5295        self.end_waypoint = v.map(|x| x.into());
5296        self
5297    }
5298
5299    /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
5300    ///
5301    /// # Example
5302    /// ```ignore,no_run
5303    /// # use google_cloud_optimization_v1::model::Vehicle;
5304    /// let x = Vehicle::new().set_start_tags(["a", "b", "c"]);
5305    /// ```
5306    pub fn set_start_tags<T, V>(mut self, v: T) -> Self
5307    where
5308        T: std::iter::IntoIterator<Item = V>,
5309        V: std::convert::Into<std::string::String>,
5310    {
5311        use std::iter::Iterator;
5312        self.start_tags = v.into_iter().map(|i| i.into()).collect();
5313        self
5314    }
5315
5316    /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
5317    ///
5318    /// # Example
5319    /// ```ignore,no_run
5320    /// # use google_cloud_optimization_v1::model::Vehicle;
5321    /// let x = Vehicle::new().set_end_tags(["a", "b", "c"]);
5322    /// ```
5323    pub fn set_end_tags<T, V>(mut self, v: T) -> Self
5324    where
5325        T: std::iter::IntoIterator<Item = V>,
5326        V: std::convert::Into<std::string::String>,
5327    {
5328        use std::iter::Iterator;
5329        self.end_tags = v.into_iter().map(|i| i.into()).collect();
5330        self
5331    }
5332
5333    /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
5334    ///
5335    /// # Example
5336    /// ```ignore,no_run
5337    /// # use google_cloud_optimization_v1::model::Vehicle;
5338    /// use google_cloud_optimization_v1::model::TimeWindow;
5339    /// let x = Vehicle::new()
5340    ///     .set_start_time_windows([
5341    ///         TimeWindow::default()/* use setters */,
5342    ///         TimeWindow::default()/* use (different) setters */,
5343    ///     ]);
5344    /// ```
5345    pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
5346    where
5347        T: std::iter::IntoIterator<Item = V>,
5348        V: std::convert::Into<crate::model::TimeWindow>,
5349    {
5350        use std::iter::Iterator;
5351        self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
5352        self
5353    }
5354
5355    /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
5356    ///
5357    /// # Example
5358    /// ```ignore,no_run
5359    /// # use google_cloud_optimization_v1::model::Vehicle;
5360    /// use google_cloud_optimization_v1::model::TimeWindow;
5361    /// let x = Vehicle::new()
5362    ///     .set_end_time_windows([
5363    ///         TimeWindow::default()/* use setters */,
5364    ///         TimeWindow::default()/* use (different) setters */,
5365    ///     ]);
5366    /// ```
5367    pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
5368    where
5369        T: std::iter::IntoIterator<Item = V>,
5370        V: std::convert::Into<crate::model::TimeWindow>,
5371    {
5372        use std::iter::Iterator;
5373        self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
5374        self
5375    }
5376
5377    /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5378    ///
5379    /// # Example
5380    /// ```ignore,no_run
5381    /// # use google_cloud_optimization_v1::model::Vehicle;
5382    /// let x = Vehicle::new().set_travel_duration_multiple(42.0);
5383    /// ```
5384    pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
5385    where
5386        T: std::convert::Into<f64>,
5387    {
5388        self.travel_duration_multiple = std::option::Option::Some(v.into());
5389        self
5390    }
5391
5392    /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5393    ///
5394    /// # Example
5395    /// ```ignore,no_run
5396    /// # use google_cloud_optimization_v1::model::Vehicle;
5397    /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(Some(42.0));
5398    /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(None::<f32>);
5399    /// ```
5400    pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
5401    where
5402        T: std::convert::Into<f64>,
5403    {
5404        self.travel_duration_multiple = v.map(|x| x.into());
5405        self
5406    }
5407
5408    /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
5409    ///
5410    /// # Example
5411    /// ```ignore,no_run
5412    /// # use google_cloud_optimization_v1::model::Vehicle;
5413    /// use google_cloud_optimization_v1::model::vehicle::UnloadingPolicy;
5414    /// let x0 = Vehicle::new().set_unloading_policy(UnloadingPolicy::LastInFirstOut);
5415    /// let x1 = Vehicle::new().set_unloading_policy(UnloadingPolicy::FirstInFirstOut);
5416    /// ```
5417    pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
5418        mut self,
5419        v: T,
5420    ) -> Self {
5421        self.unloading_policy = v.into();
5422        self
5423    }
5424
5425    /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
5426    ///
5427    /// # Example
5428    /// ```ignore,no_run
5429    /// # use google_cloud_optimization_v1::model::Vehicle;
5430    /// use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5431    /// let x = Vehicle::new().set_load_limits([
5432    ///     ("key0", LoadLimit::default()/* use setters */),
5433    ///     ("key1", LoadLimit::default()/* use (different) setters */),
5434    /// ]);
5435    /// ```
5436    pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
5437    where
5438        T: std::iter::IntoIterator<Item = (K, V)>,
5439        K: std::convert::Into<std::string::String>,
5440        V: std::convert::Into<crate::model::vehicle::LoadLimit>,
5441    {
5442        use std::iter::Iterator;
5443        self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5444        self
5445    }
5446
5447    /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
5448    ///
5449    /// # Example
5450    /// ```ignore,no_run
5451    /// # use google_cloud_optimization_v1::model::Vehicle;
5452    /// let x = Vehicle::new().set_cost_per_hour(42.0);
5453    /// ```
5454    pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5455        self.cost_per_hour = v.into();
5456        self
5457    }
5458
5459    /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
5460    ///
5461    /// # Example
5462    /// ```ignore,no_run
5463    /// # use google_cloud_optimization_v1::model::Vehicle;
5464    /// let x = Vehicle::new().set_cost_per_traveled_hour(42.0);
5465    /// ```
5466    pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5467        self.cost_per_traveled_hour = v.into();
5468        self
5469    }
5470
5471    /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
5472    ///
5473    /// # Example
5474    /// ```ignore,no_run
5475    /// # use google_cloud_optimization_v1::model::Vehicle;
5476    /// let x = Vehicle::new().set_cost_per_kilometer(42.0);
5477    /// ```
5478    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5479        self.cost_per_kilometer = v.into();
5480        self
5481    }
5482
5483    /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
5484    ///
5485    /// # Example
5486    /// ```ignore,no_run
5487    /// # use google_cloud_optimization_v1::model::Vehicle;
5488    /// let x = Vehicle::new().set_fixed_cost(42.0);
5489    /// ```
5490    pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5491        self.fixed_cost = v.into();
5492        self
5493    }
5494
5495    /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
5496    ///
5497    /// # Example
5498    /// ```ignore,no_run
5499    /// # use google_cloud_optimization_v1::model::Vehicle;
5500    /// let x = Vehicle::new().set_used_if_route_is_empty(true);
5501    /// ```
5502    pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5503        self.used_if_route_is_empty = v.into();
5504        self
5505    }
5506
5507    /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5508    ///
5509    /// # Example
5510    /// ```ignore,no_run
5511    /// # use google_cloud_optimization_v1::model::Vehicle;
5512    /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5513    /// let x = Vehicle::new().set_route_duration_limit(DurationLimit::default()/* use setters */);
5514    /// ```
5515    pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
5516    where
5517        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5518    {
5519        self.route_duration_limit = std::option::Option::Some(v.into());
5520        self
5521    }
5522
5523    /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5524    ///
5525    /// # Example
5526    /// ```ignore,no_run
5527    /// # use google_cloud_optimization_v1::model::Vehicle;
5528    /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5529    /// let x = Vehicle::new().set_or_clear_route_duration_limit(Some(DurationLimit::default()/* use setters */));
5530    /// let x = Vehicle::new().set_or_clear_route_duration_limit(None::<DurationLimit>);
5531    /// ```
5532    pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5533    where
5534        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5535    {
5536        self.route_duration_limit = v.map(|x| x.into());
5537        self
5538    }
5539
5540    /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5541    ///
5542    /// # Example
5543    /// ```ignore,no_run
5544    /// # use google_cloud_optimization_v1::model::Vehicle;
5545    /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5546    /// let x = Vehicle::new().set_travel_duration_limit(DurationLimit::default()/* use setters */);
5547    /// ```
5548    pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
5549    where
5550        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5551    {
5552        self.travel_duration_limit = std::option::Option::Some(v.into());
5553        self
5554    }
5555
5556    /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5557    ///
5558    /// # Example
5559    /// ```ignore,no_run
5560    /// # use google_cloud_optimization_v1::model::Vehicle;
5561    /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5562    /// let x = Vehicle::new().set_or_clear_travel_duration_limit(Some(DurationLimit::default()/* use setters */));
5563    /// let x = Vehicle::new().set_or_clear_travel_duration_limit(None::<DurationLimit>);
5564    /// ```
5565    pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5566    where
5567        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5568    {
5569        self.travel_duration_limit = v.map(|x| x.into());
5570        self
5571    }
5572
5573    /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5574    ///
5575    /// # Example
5576    /// ```ignore,no_run
5577    /// # use google_cloud_optimization_v1::model::Vehicle;
5578    /// use google_cloud_optimization_v1::model::DistanceLimit;
5579    /// let x = Vehicle::new().set_route_distance_limit(DistanceLimit::default()/* use setters */);
5580    /// ```
5581    pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
5582    where
5583        T: std::convert::Into<crate::model::DistanceLimit>,
5584    {
5585        self.route_distance_limit = std::option::Option::Some(v.into());
5586        self
5587    }
5588
5589    /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5590    ///
5591    /// # Example
5592    /// ```ignore,no_run
5593    /// # use google_cloud_optimization_v1::model::Vehicle;
5594    /// use google_cloud_optimization_v1::model::DistanceLimit;
5595    /// let x = Vehicle::new().set_or_clear_route_distance_limit(Some(DistanceLimit::default()/* use setters */));
5596    /// let x = Vehicle::new().set_or_clear_route_distance_limit(None::<DistanceLimit>);
5597    /// ```
5598    pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
5599    where
5600        T: std::convert::Into<crate::model::DistanceLimit>,
5601    {
5602        self.route_distance_limit = v.map(|x| x.into());
5603        self
5604    }
5605
5606    /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
5607    ///
5608    /// # Example
5609    /// ```ignore,no_run
5610    /// # use google_cloud_optimization_v1::model::Vehicle;
5611    /// use wkt::Duration;
5612    /// let x = Vehicle::new().set_extra_visit_duration_for_visit_type([
5613    ///     ("key0", Duration::default()/* use setters */),
5614    ///     ("key1", Duration::default()/* use (different) setters */),
5615    /// ]);
5616    /// ```
5617    pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
5618    where
5619        T: std::iter::IntoIterator<Item = (K, V)>,
5620        K: std::convert::Into<std::string::String>,
5621        V: std::convert::Into<wkt::Duration>,
5622    {
5623        use std::iter::Iterator;
5624        self.extra_visit_duration_for_visit_type =
5625            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5626        self
5627    }
5628
5629    /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
5630    ///
5631    /// # Example
5632    /// ```ignore,no_run
5633    /// # use google_cloud_optimization_v1::model::Vehicle;
5634    /// use google_cloud_optimization_v1::model::BreakRule;
5635    /// let x = Vehicle::new().set_break_rule(BreakRule::default()/* use setters */);
5636    /// ```
5637    pub fn set_break_rule<T>(mut self, v: T) -> Self
5638    where
5639        T: std::convert::Into<crate::model::BreakRule>,
5640    {
5641        self.break_rule = std::option::Option::Some(v.into());
5642        self
5643    }
5644
5645    /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
5646    ///
5647    /// # Example
5648    /// ```ignore,no_run
5649    /// # use google_cloud_optimization_v1::model::Vehicle;
5650    /// use google_cloud_optimization_v1::model::BreakRule;
5651    /// let x = Vehicle::new().set_or_clear_break_rule(Some(BreakRule::default()/* use setters */));
5652    /// let x = Vehicle::new().set_or_clear_break_rule(None::<BreakRule>);
5653    /// ```
5654    pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
5655    where
5656        T: std::convert::Into<crate::model::BreakRule>,
5657    {
5658        self.break_rule = v.map(|x| x.into());
5659        self
5660    }
5661
5662    /// Sets the value of [label][crate::model::Vehicle::label].
5663    ///
5664    /// # Example
5665    /// ```ignore,no_run
5666    /// # use google_cloud_optimization_v1::model::Vehicle;
5667    /// let x = Vehicle::new().set_label("example");
5668    /// ```
5669    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5670        self.label = v.into();
5671        self
5672    }
5673
5674    /// Sets the value of [ignore][crate::model::Vehicle::ignore].
5675    ///
5676    /// # Example
5677    /// ```ignore,no_run
5678    /// # use google_cloud_optimization_v1::model::Vehicle;
5679    /// let x = Vehicle::new().set_ignore(true);
5680    /// ```
5681    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5682        self.ignore = v.into();
5683        self
5684    }
5685
5686    /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
5687    ///
5688    /// # Example
5689    /// ```ignore,no_run
5690    /// # use google_cloud_optimization_v1::model::Vehicle;
5691    /// let x = Vehicle::new().set_break_rule_indices([1, 2, 3]);
5692    /// ```
5693    #[deprecated]
5694    pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
5695    where
5696        T: std::iter::IntoIterator<Item = V>,
5697        V: std::convert::Into<i32>,
5698    {
5699        use std::iter::Iterator;
5700        self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
5701        self
5702    }
5703
5704    /// Sets the value of [capacities][crate::model::Vehicle::capacities].
5705    ///
5706    /// # Example
5707    /// ```ignore,no_run
5708    /// # use google_cloud_optimization_v1::model::Vehicle;
5709    /// use google_cloud_optimization_v1::model::CapacityQuantity;
5710    /// let x = Vehicle::new()
5711    ///     .set_capacities([
5712    ///         CapacityQuantity::default()/* use setters */,
5713    ///         CapacityQuantity::default()/* use (different) setters */,
5714    ///     ]);
5715    /// ```
5716    #[deprecated]
5717    pub fn set_capacities<T, V>(mut self, v: T) -> Self
5718    where
5719        T: std::iter::IntoIterator<Item = V>,
5720        V: std::convert::Into<crate::model::CapacityQuantity>,
5721    {
5722        use std::iter::Iterator;
5723        self.capacities = v.into_iter().map(|i| i.into()).collect();
5724        self
5725    }
5726
5727    /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
5728    ///
5729    /// # Example
5730    /// ```ignore,no_run
5731    /// # use google_cloud_optimization_v1::model::Vehicle;
5732    /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5733    /// let x = Vehicle::new()
5734    ///     .set_start_load_intervals([
5735    ///         CapacityQuantityInterval::default()/* use setters */,
5736    ///         CapacityQuantityInterval::default()/* use (different) setters */,
5737    ///     ]);
5738    /// ```
5739    #[deprecated]
5740    pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
5741    where
5742        T: std::iter::IntoIterator<Item = V>,
5743        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5744    {
5745        use std::iter::Iterator;
5746        self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
5747        self
5748    }
5749
5750    /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
5751    ///
5752    /// # Example
5753    /// ```ignore,no_run
5754    /// # use google_cloud_optimization_v1::model::Vehicle;
5755    /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5756    /// let x = Vehicle::new()
5757    ///     .set_end_load_intervals([
5758    ///         CapacityQuantityInterval::default()/* use setters */,
5759    ///         CapacityQuantityInterval::default()/* use (different) setters */,
5760    ///     ]);
5761    /// ```
5762    #[deprecated]
5763    pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
5764    where
5765        T: std::iter::IntoIterator<Item = V>,
5766        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5767    {
5768        use std::iter::Iterator;
5769        self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
5770        self
5771    }
5772}
5773
5774impl wkt::message::Message for Vehicle {
5775    fn typename() -> &'static str {
5776        "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
5777    }
5778}
5779
5780/// Defines additional types related to [Vehicle].
5781pub mod vehicle {
5782    #[allow(unused_imports)]
5783    use super::*;
5784
5785    /// Defines a load limit applying to a vehicle, e.g. "this truck may only
5786    /// carry up to 3500 kg". See
5787    /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
5788    ///
5789    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5790    #[derive(Clone, Default, PartialEq)]
5791    #[non_exhaustive]
5792    pub struct LoadLimit {
5793        /// The maximum acceptable amount of load.
5794        pub max_load: std::option::Option<i64>,
5795
5796        /// A soft limit of the load. See
5797        /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
5798        ///
5799        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5800        pub soft_max_load: i64,
5801
5802        /// If the load ever exceeds
5803        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
5804        /// along this vehicle's route, the following cost penalty applies (only once
5805        /// per vehicle): (load -
5806        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
5807        ///
5808        /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
5809        ///   add up and must be in the same unit as
5810        ///   [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
5811        ///
5812        /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
5813        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5814        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
5815        pub cost_per_unit_above_soft_max: f64,
5816
5817        /// The acceptable load interval of the vehicle at the start of the route.
5818        pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5819
5820        /// The acceptable load interval of the vehicle at the end of the route.
5821        pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5822
5823        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5824    }
5825
5826    impl LoadLimit {
5827        pub fn new() -> Self {
5828            std::default::Default::default()
5829        }
5830
5831        /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5832        ///
5833        /// # Example
5834        /// ```ignore,no_run
5835        /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5836        /// let x = LoadLimit::new().set_max_load(42);
5837        /// ```
5838        pub fn set_max_load<T>(mut self, v: T) -> Self
5839        where
5840            T: std::convert::Into<i64>,
5841        {
5842            self.max_load = std::option::Option::Some(v.into());
5843            self
5844        }
5845
5846        /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5847        ///
5848        /// # Example
5849        /// ```ignore,no_run
5850        /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5851        /// let x = LoadLimit::new().set_or_clear_max_load(Some(42));
5852        /// let x = LoadLimit::new().set_or_clear_max_load(None::<i32>);
5853        /// ```
5854        pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
5855        where
5856            T: std::convert::Into<i64>,
5857        {
5858            self.max_load = v.map(|x| x.into());
5859            self
5860        }
5861
5862        /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
5863        ///
5864        /// # Example
5865        /// ```ignore,no_run
5866        /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5867        /// let x = LoadLimit::new().set_soft_max_load(42);
5868        /// ```
5869        pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5870            self.soft_max_load = v.into();
5871            self
5872        }
5873
5874        /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
5875        ///
5876        /// # Example
5877        /// ```ignore,no_run
5878        /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5879        /// let x = LoadLimit::new().set_cost_per_unit_above_soft_max(42.0);
5880        /// ```
5881        pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
5882            mut self,
5883            v: T,
5884        ) -> Self {
5885            self.cost_per_unit_above_soft_max = v.into();
5886            self
5887        }
5888
5889        /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5890        ///
5891        /// # Example
5892        /// ```ignore,no_run
5893        /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5894        /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5895        /// let x = LoadLimit::new().set_start_load_interval(Interval::default()/* use setters */);
5896        /// ```
5897        pub fn set_start_load_interval<T>(mut self, v: T) -> Self
5898        where
5899            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5900        {
5901            self.start_load_interval = std::option::Option::Some(v.into());
5902            self
5903        }
5904
5905        /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5906        ///
5907        /// # Example
5908        /// ```ignore,no_run
5909        /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5910        /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5911        /// let x = LoadLimit::new().set_or_clear_start_load_interval(Some(Interval::default()/* use setters */));
5912        /// let x = LoadLimit::new().set_or_clear_start_load_interval(None::<Interval>);
5913        /// ```
5914        pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5915        where
5916            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5917        {
5918            self.start_load_interval = v.map(|x| x.into());
5919            self
5920        }
5921
5922        /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5923        ///
5924        /// # Example
5925        /// ```ignore,no_run
5926        /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5927        /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5928        /// let x = LoadLimit::new().set_end_load_interval(Interval::default()/* use setters */);
5929        /// ```
5930        pub fn set_end_load_interval<T>(mut self, v: T) -> Self
5931        where
5932            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5933        {
5934            self.end_load_interval = std::option::Option::Some(v.into());
5935            self
5936        }
5937
5938        /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5939        ///
5940        /// # Example
5941        /// ```ignore,no_run
5942        /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5943        /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5944        /// let x = LoadLimit::new().set_or_clear_end_load_interval(Some(Interval::default()/* use setters */));
5945        /// let x = LoadLimit::new().set_or_clear_end_load_interval(None::<Interval>);
5946        /// ```
5947        pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5948        where
5949            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5950        {
5951            self.end_load_interval = v.map(|x| x.into());
5952            self
5953        }
5954    }
5955
5956    impl wkt::message::Message for LoadLimit {
5957        fn typename() -> &'static str {
5958            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
5959        }
5960    }
5961
5962    /// Defines additional types related to [LoadLimit].
5963    pub mod load_limit {
5964        #[allow(unused_imports)]
5965        use super::*;
5966
5967        /// Interval of acceptable load amounts.
5968        #[derive(Clone, Default, PartialEq)]
5969        #[non_exhaustive]
5970        pub struct Interval {
5971            /// A minimum acceptable load. Must be ≥ 0.
5972            /// If they're both specified,
5973            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
5974            /// be ≤
5975            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
5976            ///
5977            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
5978            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
5979            pub min: i64,
5980
5981            /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
5982            /// load is unrestricted by this message.
5983            /// If they're both specified,
5984            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
5985            /// be ≤
5986            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
5987            ///
5988            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
5989            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
5990            pub max: std::option::Option<i64>,
5991
5992            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5993        }
5994
5995        impl Interval {
5996            pub fn new() -> Self {
5997                std::default::Default::default()
5998            }
5999
6000            /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
6001            ///
6002            /// # Example
6003            /// ```ignore,no_run
6004            /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6005            /// let x = Interval::new().set_min(42);
6006            /// ```
6007            pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6008                self.min = v.into();
6009                self
6010            }
6011
6012            /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
6013            ///
6014            /// # Example
6015            /// ```ignore,no_run
6016            /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6017            /// let x = Interval::new().set_max(42);
6018            /// ```
6019            pub fn set_max<T>(mut self, v: T) -> Self
6020            where
6021                T: std::convert::Into<i64>,
6022            {
6023                self.max = std::option::Option::Some(v.into());
6024                self
6025            }
6026
6027            /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
6028            ///
6029            /// # Example
6030            /// ```ignore,no_run
6031            /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6032            /// let x = Interval::new().set_or_clear_max(Some(42));
6033            /// let x = Interval::new().set_or_clear_max(None::<i32>);
6034            /// ```
6035            pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
6036            where
6037                T: std::convert::Into<i64>,
6038            {
6039                self.max = v.map(|x| x.into());
6040                self
6041            }
6042        }
6043
6044        impl wkt::message::Message for Interval {
6045            fn typename() -> &'static str {
6046                "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
6047            }
6048        }
6049    }
6050
6051    /// A limit defining a maximum duration of the route of a vehicle. It can be
6052    /// either hard or soft.
6053    ///
6054    /// When a soft limit field is defined, both the soft max threshold and its
6055    /// associated cost must be defined together.
6056    #[derive(Clone, Default, PartialEq)]
6057    #[non_exhaustive]
6058    pub struct DurationLimit {
6059        /// A hard limit constraining the duration to be at most max_duration.
6060        pub max_duration: std::option::Option<wkt::Duration>,
6061
6062        /// A soft limit not enforcing a maximum duration limit, but when violated
6063        /// makes the route incur a cost. This cost adds up to other costs defined in
6064        /// the model, with the same unit.
6065        ///
6066        /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
6067        /// also defined, `soft_max_duration` must be less than max_duration.
6068        pub soft_max_duration: std::option::Option<wkt::Duration>,
6069
6070        /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
6071        /// The additional cost is 0 if the duration is under the threshold,
6072        /// otherwise the cost depends on the duration as follows:
6073        ///
6074        /// ```norust
6075        ///   cost_per_hour_after_soft_max * (duration - soft_max_duration)
6076        /// ```
6077        ///
6078        /// The cost must be nonnegative.
6079        pub cost_per_hour_after_soft_max: std::option::Option<f64>,
6080
6081        /// A soft limit not enforcing a maximum duration limit, but when violated
6082        /// makes the route incur a cost, quadratic in the duration. This cost adds
6083        /// up to other costs defined in the model, with the same unit.
6084        ///
6085        /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
6086        /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
6087        /// less than `max_duration`, and the difference must be no larger than one
6088        /// day:
6089        ///
6090        /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
6091        pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
6092
6093        /// Cost per square hour incurred if the
6094        /// `quadratic_soft_max_duration` threshold is violated.
6095        ///
6096        /// The additional cost is 0 if the duration is under the threshold,
6097        /// otherwise the cost depends on the duration as follows:
6098        ///
6099        /// ```norust
6100        ///   cost_per_square_hour_after_quadratic_soft_max *
6101        ///   (duration - quadratic_soft_max_duration)^2
6102        /// ```
6103        ///
6104        /// The cost must be nonnegative.
6105        pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
6106
6107        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6108    }
6109
6110    impl DurationLimit {
6111        pub fn new() -> Self {
6112            std::default::Default::default()
6113        }
6114
6115        /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6116        ///
6117        /// # Example
6118        /// ```ignore,no_run
6119        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6120        /// use wkt::Duration;
6121        /// let x = DurationLimit::new().set_max_duration(Duration::default()/* use setters */);
6122        /// ```
6123        pub fn set_max_duration<T>(mut self, v: T) -> Self
6124        where
6125            T: std::convert::Into<wkt::Duration>,
6126        {
6127            self.max_duration = std::option::Option::Some(v.into());
6128            self
6129        }
6130
6131        /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6132        ///
6133        /// # Example
6134        /// ```ignore,no_run
6135        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6136        /// use wkt::Duration;
6137        /// let x = DurationLimit::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
6138        /// let x = DurationLimit::new().set_or_clear_max_duration(None::<Duration>);
6139        /// ```
6140        pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6141        where
6142            T: std::convert::Into<wkt::Duration>,
6143        {
6144            self.max_duration = v.map(|x| x.into());
6145            self
6146        }
6147
6148        /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6149        ///
6150        /// # Example
6151        /// ```ignore,no_run
6152        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6153        /// use wkt::Duration;
6154        /// let x = DurationLimit::new().set_soft_max_duration(Duration::default()/* use setters */);
6155        /// ```
6156        pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
6157        where
6158            T: std::convert::Into<wkt::Duration>,
6159        {
6160            self.soft_max_duration = std::option::Option::Some(v.into());
6161            self
6162        }
6163
6164        /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6165        ///
6166        /// # Example
6167        /// ```ignore,no_run
6168        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6169        /// use wkt::Duration;
6170        /// let x = DurationLimit::new().set_or_clear_soft_max_duration(Some(Duration::default()/* use setters */));
6171        /// let x = DurationLimit::new().set_or_clear_soft_max_duration(None::<Duration>);
6172        /// ```
6173        pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6174        where
6175            T: std::convert::Into<wkt::Duration>,
6176        {
6177            self.soft_max_duration = v.map(|x| x.into());
6178            self
6179        }
6180
6181        /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6182        ///
6183        /// # Example
6184        /// ```ignore,no_run
6185        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6186        /// let x = DurationLimit::new().set_cost_per_hour_after_soft_max(42.0);
6187        /// ```
6188        pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
6189        where
6190            T: std::convert::Into<f64>,
6191        {
6192            self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
6193            self
6194        }
6195
6196        /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6197        ///
6198        /// # Example
6199        /// ```ignore,no_run
6200        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6201        /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(Some(42.0));
6202        /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(None::<f32>);
6203        /// ```
6204        pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
6205            mut self,
6206            v: std::option::Option<T>,
6207        ) -> Self
6208        where
6209            T: std::convert::Into<f64>,
6210        {
6211            self.cost_per_hour_after_soft_max = v.map(|x| x.into());
6212            self
6213        }
6214
6215        /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6216        ///
6217        /// # Example
6218        /// ```ignore,no_run
6219        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6220        /// use wkt::Duration;
6221        /// let x = DurationLimit::new().set_quadratic_soft_max_duration(Duration::default()/* use setters */);
6222        /// ```
6223        pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
6224        where
6225            T: std::convert::Into<wkt::Duration>,
6226        {
6227            self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
6228            self
6229        }
6230
6231        /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6232        ///
6233        /// # Example
6234        /// ```ignore,no_run
6235        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6236        /// use wkt::Duration;
6237        /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(Some(Duration::default()/* use setters */));
6238        /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(None::<Duration>);
6239        /// ```
6240        pub fn set_or_clear_quadratic_soft_max_duration<T>(
6241            mut self,
6242            v: std::option::Option<T>,
6243        ) -> Self
6244        where
6245            T: std::convert::Into<wkt::Duration>,
6246        {
6247            self.quadratic_soft_max_duration = v.map(|x| x.into());
6248            self
6249        }
6250
6251        /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6252        ///
6253        /// # Example
6254        /// ```ignore,no_run
6255        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6256        /// let x = DurationLimit::new().set_cost_per_square_hour_after_quadratic_soft_max(42.0);
6257        /// ```
6258        pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
6259        where
6260            T: std::convert::Into<f64>,
6261        {
6262            self.cost_per_square_hour_after_quadratic_soft_max =
6263                std::option::Option::Some(v.into());
6264            self
6265        }
6266
6267        /// 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].
6268        ///
6269        /// # Example
6270        /// ```ignore,no_run
6271        /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6272        /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(Some(42.0));
6273        /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(None::<f32>);
6274        /// ```
6275        pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
6276            mut self,
6277            v: std::option::Option<T>,
6278        ) -> Self
6279        where
6280            T: std::convert::Into<f64>,
6281        {
6282            self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
6283            self
6284        }
6285    }
6286
6287    impl wkt::message::Message for DurationLimit {
6288        fn typename() -> &'static str {
6289            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
6290        }
6291    }
6292
6293    /// Travel modes which can be used by vehicles.
6294    ///
6295    /// These should be a subset of the Google Maps Platform Routes Preferred API
6296    /// travel modes, see:
6297    /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
6298    ///
6299    /// # Working with unknown values
6300    ///
6301    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6302    /// additional enum variants at any time. Adding new variants is not considered
6303    /// a breaking change. Applications should write their code in anticipation of:
6304    ///
6305    /// - New values appearing in future releases of the client library, **and**
6306    /// - New values received dynamically, without application changes.
6307    ///
6308    /// Please consult the [Working with enums] section in the user guide for some
6309    /// guidelines.
6310    ///
6311    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
6312    #[derive(Clone, Debug, PartialEq)]
6313    #[non_exhaustive]
6314    pub enum TravelMode {
6315        /// Unspecified travel mode, equivalent to `DRIVING`.
6316        Unspecified,
6317        /// Travel mode corresponding to driving directions (car, ...).
6318        Driving,
6319        /// Travel mode corresponding to walking directions.
6320        Walking,
6321        /// If set, the enum was initialized with an unknown value.
6322        ///
6323        /// Applications can examine the value using [TravelMode::value] or
6324        /// [TravelMode::name].
6325        UnknownValue(travel_mode::UnknownValue),
6326    }
6327
6328    #[doc(hidden)]
6329    pub mod travel_mode {
6330        #[allow(unused_imports)]
6331        use super::*;
6332        #[derive(Clone, Debug, PartialEq)]
6333        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6334    }
6335
6336    impl TravelMode {
6337        /// Gets the enum value.
6338        ///
6339        /// Returns `None` if the enum contains an unknown value deserialized from
6340        /// the string representation of enums.
6341        pub fn value(&self) -> std::option::Option<i32> {
6342            match self {
6343                Self::Unspecified => std::option::Option::Some(0),
6344                Self::Driving => std::option::Option::Some(1),
6345                Self::Walking => std::option::Option::Some(2),
6346                Self::UnknownValue(u) => u.0.value(),
6347            }
6348        }
6349
6350        /// Gets the enum value as a string.
6351        ///
6352        /// Returns `None` if the enum contains an unknown value deserialized from
6353        /// the integer representation of enums.
6354        pub fn name(&self) -> std::option::Option<&str> {
6355            match self {
6356                Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
6357                Self::Driving => std::option::Option::Some("DRIVING"),
6358                Self::Walking => std::option::Option::Some("WALKING"),
6359                Self::UnknownValue(u) => u.0.name(),
6360            }
6361        }
6362    }
6363
6364    impl std::default::Default for TravelMode {
6365        fn default() -> Self {
6366            use std::convert::From;
6367            Self::from(0)
6368        }
6369    }
6370
6371    impl std::fmt::Display for TravelMode {
6372        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6373            wkt::internal::display_enum(f, self.name(), self.value())
6374        }
6375    }
6376
6377    impl std::convert::From<i32> for TravelMode {
6378        fn from(value: i32) -> Self {
6379            match value {
6380                0 => Self::Unspecified,
6381                1 => Self::Driving,
6382                2 => Self::Walking,
6383                _ => Self::UnknownValue(travel_mode::UnknownValue(
6384                    wkt::internal::UnknownEnumValue::Integer(value),
6385                )),
6386            }
6387        }
6388    }
6389
6390    impl std::convert::From<&str> for TravelMode {
6391        fn from(value: &str) -> Self {
6392            use std::string::ToString;
6393            match value {
6394                "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
6395                "DRIVING" => Self::Driving,
6396                "WALKING" => Self::Walking,
6397                _ => Self::UnknownValue(travel_mode::UnknownValue(
6398                    wkt::internal::UnknownEnumValue::String(value.to_string()),
6399                )),
6400            }
6401        }
6402    }
6403
6404    impl serde::ser::Serialize for TravelMode {
6405        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6406        where
6407            S: serde::Serializer,
6408        {
6409            match self {
6410                Self::Unspecified => serializer.serialize_i32(0),
6411                Self::Driving => serializer.serialize_i32(1),
6412                Self::Walking => serializer.serialize_i32(2),
6413                Self::UnknownValue(u) => u.0.serialize(serializer),
6414            }
6415        }
6416    }
6417
6418    impl<'de> serde::de::Deserialize<'de> for TravelMode {
6419        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6420        where
6421            D: serde::Deserializer<'de>,
6422        {
6423            deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
6424                ".google.cloud.optimization.v1.Vehicle.TravelMode",
6425            ))
6426        }
6427    }
6428
6429    /// Policy on how a vehicle can be unloaded. Applies only to shipments having
6430    /// both a pickup and a delivery.
6431    ///
6432    /// Other shipments are free to occur anywhere on the route independent of
6433    /// `unloading_policy`.
6434    ///
6435    /// # Working with unknown values
6436    ///
6437    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6438    /// additional enum variants at any time. Adding new variants is not considered
6439    /// a breaking change. Applications should write their code in anticipation of:
6440    ///
6441    /// - New values appearing in future releases of the client library, **and**
6442    /// - New values received dynamically, without application changes.
6443    ///
6444    /// Please consult the [Working with enums] section in the user guide for some
6445    /// guidelines.
6446    ///
6447    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
6448    #[derive(Clone, Debug, PartialEq)]
6449    #[non_exhaustive]
6450    pub enum UnloadingPolicy {
6451        /// Unspecified unloading policy; deliveries must just occur after their
6452        /// corresponding pickups.
6453        Unspecified,
6454        /// Deliveries must occur in reverse order of pickups
6455        LastInFirstOut,
6456        /// Deliveries must occur in the same order as pickups
6457        FirstInFirstOut,
6458        /// If set, the enum was initialized with an unknown value.
6459        ///
6460        /// Applications can examine the value using [UnloadingPolicy::value] or
6461        /// [UnloadingPolicy::name].
6462        UnknownValue(unloading_policy::UnknownValue),
6463    }
6464
6465    #[doc(hidden)]
6466    pub mod unloading_policy {
6467        #[allow(unused_imports)]
6468        use super::*;
6469        #[derive(Clone, Debug, PartialEq)]
6470        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6471    }
6472
6473    impl UnloadingPolicy {
6474        /// Gets the enum value.
6475        ///
6476        /// Returns `None` if the enum contains an unknown value deserialized from
6477        /// the string representation of enums.
6478        pub fn value(&self) -> std::option::Option<i32> {
6479            match self {
6480                Self::Unspecified => std::option::Option::Some(0),
6481                Self::LastInFirstOut => std::option::Option::Some(1),
6482                Self::FirstInFirstOut => std::option::Option::Some(2),
6483                Self::UnknownValue(u) => u.0.value(),
6484            }
6485        }
6486
6487        /// Gets the enum value as a string.
6488        ///
6489        /// Returns `None` if the enum contains an unknown value deserialized from
6490        /// the integer representation of enums.
6491        pub fn name(&self) -> std::option::Option<&str> {
6492            match self {
6493                Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
6494                Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
6495                Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
6496                Self::UnknownValue(u) => u.0.name(),
6497            }
6498        }
6499    }
6500
6501    impl std::default::Default for UnloadingPolicy {
6502        fn default() -> Self {
6503            use std::convert::From;
6504            Self::from(0)
6505        }
6506    }
6507
6508    impl std::fmt::Display for UnloadingPolicy {
6509        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6510            wkt::internal::display_enum(f, self.name(), self.value())
6511        }
6512    }
6513
6514    impl std::convert::From<i32> for UnloadingPolicy {
6515        fn from(value: i32) -> Self {
6516            match value {
6517                0 => Self::Unspecified,
6518                1 => Self::LastInFirstOut,
6519                2 => Self::FirstInFirstOut,
6520                _ => Self::UnknownValue(unloading_policy::UnknownValue(
6521                    wkt::internal::UnknownEnumValue::Integer(value),
6522                )),
6523            }
6524        }
6525    }
6526
6527    impl std::convert::From<&str> for UnloadingPolicy {
6528        fn from(value: &str) -> Self {
6529            use std::string::ToString;
6530            match value {
6531                "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
6532                "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
6533                "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
6534                _ => Self::UnknownValue(unloading_policy::UnknownValue(
6535                    wkt::internal::UnknownEnumValue::String(value.to_string()),
6536                )),
6537            }
6538        }
6539    }
6540
6541    impl serde::ser::Serialize for UnloadingPolicy {
6542        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6543        where
6544            S: serde::Serializer,
6545        {
6546            match self {
6547                Self::Unspecified => serializer.serialize_i32(0),
6548                Self::LastInFirstOut => serializer.serialize_i32(1),
6549                Self::FirstInFirstOut => serializer.serialize_i32(2),
6550                Self::UnknownValue(u) => u.0.serialize(serializer),
6551            }
6552        }
6553    }
6554
6555    impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
6556        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6557        where
6558            D: serde::Deserializer<'de>,
6559        {
6560            deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
6561                ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
6562            ))
6563        }
6564    }
6565}
6566
6567/// Time windows constrain the time of an event, such as the arrival time at a
6568/// visit, or the start and end time of a vehicle.
6569///
6570/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
6571/// and latest time of the event, such that `start_time <= event_time <=
6572/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
6573/// preference for the event to happen at or after `soft_start_time` by incurring
6574/// a cost proportional to how long before soft_start_time the event occurs. The
6575/// soft time window upper bound, `soft_end_time`, expresses a preference for the
6576/// event to happen at or before `soft_end_time` by incurring a cost proportional
6577/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
6578/// `soft_start_time` and `soft_end_time` should be within the global time limits
6579/// (see
6580/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
6581/// and
6582/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
6583/// and should respect:
6584///
6585/// ```norust
6586///   0 <= `start_time` <= `soft_start_time` <= `end_time` and
6587///   0 <= `start_time` <= `soft_end_time` <= `end_time`.
6588/// ```
6589///
6590/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
6591/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
6592#[derive(Clone, Default, PartialEq)]
6593#[non_exhaustive]
6594pub struct TimeWindow {
6595    /// The hard time window start time. If unspecified it will be set to
6596    /// `ShipmentModel.global_start_time`.
6597    pub start_time: std::option::Option<wkt::Timestamp>,
6598
6599    /// The hard time window end time. If unspecified it will be set to
6600    /// `ShipmentModel.global_end_time`.
6601    pub end_time: std::option::Option<wkt::Timestamp>,
6602
6603    /// The soft start time of the time window.
6604    pub soft_start_time: std::option::Option<wkt::Timestamp>,
6605
6606    /// The soft end time of the time window.
6607    pub soft_end_time: std::option::Option<wkt::Timestamp>,
6608
6609    /// A cost per hour added to other costs in the model if the event occurs
6610    /// before soft_start_time, computed as:
6611    ///
6612    /// ```norust
6613    ///    max(0, soft_start_time - t.seconds)
6614    ///                           * cost_per_hour_before_soft_start_time / 3600,
6615    /// t being the time of the event.
6616    /// ```
6617    ///
6618    /// This cost must be positive, and the field can only be set if
6619    /// soft_start_time has been set.
6620    pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
6621
6622    /// A cost per hour added to other costs in the model if the event occurs after
6623    /// `soft_end_time`, computed as:
6624    ///
6625    /// ```norust
6626    ///    max(0, t.seconds - soft_end_time.seconds)
6627    ///                     * cost_per_hour_after_soft_end_time / 3600,
6628    /// t being the time of the event.
6629    /// ```
6630    ///
6631    /// This cost must be positive, and the field can only be set if
6632    /// `soft_end_time` has been set.
6633    pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
6634
6635    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6636}
6637
6638impl TimeWindow {
6639    pub fn new() -> Self {
6640        std::default::Default::default()
6641    }
6642
6643    /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
6644    ///
6645    /// # Example
6646    /// ```ignore,no_run
6647    /// # use google_cloud_optimization_v1::model::TimeWindow;
6648    /// use wkt::Timestamp;
6649    /// let x = TimeWindow::new().set_start_time(Timestamp::default()/* use setters */);
6650    /// ```
6651    pub fn set_start_time<T>(mut self, v: T) -> Self
6652    where
6653        T: std::convert::Into<wkt::Timestamp>,
6654    {
6655        self.start_time = std::option::Option::Some(v.into());
6656        self
6657    }
6658
6659    /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
6660    ///
6661    /// # Example
6662    /// ```ignore,no_run
6663    /// # use google_cloud_optimization_v1::model::TimeWindow;
6664    /// use wkt::Timestamp;
6665    /// let x = TimeWindow::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
6666    /// let x = TimeWindow::new().set_or_clear_start_time(None::<Timestamp>);
6667    /// ```
6668    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6669    where
6670        T: std::convert::Into<wkt::Timestamp>,
6671    {
6672        self.start_time = v.map(|x| x.into());
6673        self
6674    }
6675
6676    /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
6677    ///
6678    /// # Example
6679    /// ```ignore,no_run
6680    /// # use google_cloud_optimization_v1::model::TimeWindow;
6681    /// use wkt::Timestamp;
6682    /// let x = TimeWindow::new().set_end_time(Timestamp::default()/* use setters */);
6683    /// ```
6684    pub fn set_end_time<T>(mut self, v: T) -> Self
6685    where
6686        T: std::convert::Into<wkt::Timestamp>,
6687    {
6688        self.end_time = std::option::Option::Some(v.into());
6689        self
6690    }
6691
6692    /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
6693    ///
6694    /// # Example
6695    /// ```ignore,no_run
6696    /// # use google_cloud_optimization_v1::model::TimeWindow;
6697    /// use wkt::Timestamp;
6698    /// let x = TimeWindow::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
6699    /// let x = TimeWindow::new().set_or_clear_end_time(None::<Timestamp>);
6700    /// ```
6701    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6702    where
6703        T: std::convert::Into<wkt::Timestamp>,
6704    {
6705        self.end_time = v.map(|x| x.into());
6706        self
6707    }
6708
6709    /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6710    ///
6711    /// # Example
6712    /// ```ignore,no_run
6713    /// # use google_cloud_optimization_v1::model::TimeWindow;
6714    /// use wkt::Timestamp;
6715    /// let x = TimeWindow::new().set_soft_start_time(Timestamp::default()/* use setters */);
6716    /// ```
6717    pub fn set_soft_start_time<T>(mut self, v: T) -> Self
6718    where
6719        T: std::convert::Into<wkt::Timestamp>,
6720    {
6721        self.soft_start_time = std::option::Option::Some(v.into());
6722        self
6723    }
6724
6725    /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6726    ///
6727    /// # Example
6728    /// ```ignore,no_run
6729    /// # use google_cloud_optimization_v1::model::TimeWindow;
6730    /// use wkt::Timestamp;
6731    /// let x = TimeWindow::new().set_or_clear_soft_start_time(Some(Timestamp::default()/* use setters */));
6732    /// let x = TimeWindow::new().set_or_clear_soft_start_time(None::<Timestamp>);
6733    /// ```
6734    pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6735    where
6736        T: std::convert::Into<wkt::Timestamp>,
6737    {
6738        self.soft_start_time = v.map(|x| x.into());
6739        self
6740    }
6741
6742    /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6743    ///
6744    /// # Example
6745    /// ```ignore,no_run
6746    /// # use google_cloud_optimization_v1::model::TimeWindow;
6747    /// use wkt::Timestamp;
6748    /// let x = TimeWindow::new().set_soft_end_time(Timestamp::default()/* use setters */);
6749    /// ```
6750    pub fn set_soft_end_time<T>(mut self, v: T) -> Self
6751    where
6752        T: std::convert::Into<wkt::Timestamp>,
6753    {
6754        self.soft_end_time = std::option::Option::Some(v.into());
6755        self
6756    }
6757
6758    /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6759    ///
6760    /// # Example
6761    /// ```ignore,no_run
6762    /// # use google_cloud_optimization_v1::model::TimeWindow;
6763    /// use wkt::Timestamp;
6764    /// let x = TimeWindow::new().set_or_clear_soft_end_time(Some(Timestamp::default()/* use setters */));
6765    /// let x = TimeWindow::new().set_or_clear_soft_end_time(None::<Timestamp>);
6766    /// ```
6767    pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6768    where
6769        T: std::convert::Into<wkt::Timestamp>,
6770    {
6771        self.soft_end_time = v.map(|x| x.into());
6772        self
6773    }
6774
6775    /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6776    ///
6777    /// # Example
6778    /// ```ignore,no_run
6779    /// # use google_cloud_optimization_v1::model::TimeWindow;
6780    /// let x = TimeWindow::new().set_cost_per_hour_before_soft_start_time(42.0);
6781    /// ```
6782    pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
6783    where
6784        T: std::convert::Into<f64>,
6785    {
6786        self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
6787        self
6788    }
6789
6790    /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6791    ///
6792    /// # Example
6793    /// ```ignore,no_run
6794    /// # use google_cloud_optimization_v1::model::TimeWindow;
6795    /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(Some(42.0));
6796    /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(None::<f32>);
6797    /// ```
6798    pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
6799        mut self,
6800        v: std::option::Option<T>,
6801    ) -> Self
6802    where
6803        T: std::convert::Into<f64>,
6804    {
6805        self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
6806        self
6807    }
6808
6809    /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6810    ///
6811    /// # Example
6812    /// ```ignore,no_run
6813    /// # use google_cloud_optimization_v1::model::TimeWindow;
6814    /// let x = TimeWindow::new().set_cost_per_hour_after_soft_end_time(42.0);
6815    /// ```
6816    pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
6817    where
6818        T: std::convert::Into<f64>,
6819    {
6820        self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
6821        self
6822    }
6823
6824    /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6825    ///
6826    /// # Example
6827    /// ```ignore,no_run
6828    /// # use google_cloud_optimization_v1::model::TimeWindow;
6829    /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(Some(42.0));
6830    /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(None::<f32>);
6831    /// ```
6832    pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
6833        mut self,
6834        v: std::option::Option<T>,
6835    ) -> Self
6836    where
6837        T: std::convert::Into<f64>,
6838    {
6839        self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
6840        self
6841    }
6842}
6843
6844impl wkt::message::Message for TimeWindow {
6845    fn typename() -> &'static str {
6846        "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
6847    }
6848}
6849
6850/// Deprecated: Use
6851/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6852/// instead.
6853///
6854/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6855#[derive(Clone, Default, PartialEq)]
6856#[non_exhaustive]
6857#[deprecated]
6858pub struct CapacityQuantity {
6859    pub r#type: std::string::String,
6860
6861    pub value: i64,
6862
6863    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6864}
6865
6866impl CapacityQuantity {
6867    pub fn new() -> Self {
6868        std::default::Default::default()
6869    }
6870
6871    /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
6872    ///
6873    /// # Example
6874    /// ```ignore,no_run
6875    /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6876    /// let x = CapacityQuantity::new().set_type("example");
6877    /// ```
6878    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6879        self.r#type = v.into();
6880        self
6881    }
6882
6883    /// Sets the value of [value][crate::model::CapacityQuantity::value].
6884    ///
6885    /// # Example
6886    /// ```ignore,no_run
6887    /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6888    /// let x = CapacityQuantity::new().set_value(42);
6889    /// ```
6890    pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6891        self.value = v.into();
6892        self
6893    }
6894}
6895
6896impl wkt::message::Message for CapacityQuantity {
6897    fn typename() -> &'static str {
6898        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
6899    }
6900}
6901
6902/// Deprecated: Use
6903/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6904/// instead.
6905///
6906/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6907#[derive(Clone, Default, PartialEq)]
6908#[non_exhaustive]
6909#[deprecated]
6910pub struct CapacityQuantityInterval {
6911    pub r#type: std::string::String,
6912
6913    pub min_value: std::option::Option<i64>,
6914
6915    pub max_value: std::option::Option<i64>,
6916
6917    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6918}
6919
6920impl CapacityQuantityInterval {
6921    pub fn new() -> Self {
6922        std::default::Default::default()
6923    }
6924
6925    /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
6926    ///
6927    /// # Example
6928    /// ```ignore,no_run
6929    /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6930    /// let x = CapacityQuantityInterval::new().set_type("example");
6931    /// ```
6932    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6933        self.r#type = v.into();
6934        self
6935    }
6936
6937    /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6938    ///
6939    /// # Example
6940    /// ```ignore,no_run
6941    /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6942    /// let x = CapacityQuantityInterval::new().set_min_value(42);
6943    /// ```
6944    pub fn set_min_value<T>(mut self, v: T) -> Self
6945    where
6946        T: std::convert::Into<i64>,
6947    {
6948        self.min_value = std::option::Option::Some(v.into());
6949        self
6950    }
6951
6952    /// Sets or clears the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6953    ///
6954    /// # Example
6955    /// ```ignore,no_run
6956    /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6957    /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(Some(42));
6958    /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(None::<i32>);
6959    /// ```
6960    pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
6961    where
6962        T: std::convert::Into<i64>,
6963    {
6964        self.min_value = v.map(|x| x.into());
6965        self
6966    }
6967
6968    /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
6969    ///
6970    /// # Example
6971    /// ```ignore,no_run
6972    /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6973    /// let x = CapacityQuantityInterval::new().set_max_value(42);
6974    /// ```
6975    pub fn set_max_value<T>(mut self, v: T) -> Self
6976    where
6977        T: std::convert::Into<i64>,
6978    {
6979        self.max_value = std::option::Option::Some(v.into());
6980        self
6981    }
6982
6983    /// Sets or clears the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
6984    ///
6985    /// # Example
6986    /// ```ignore,no_run
6987    /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6988    /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(Some(42));
6989    /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(None::<i32>);
6990    /// ```
6991    pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
6992    where
6993        T: std::convert::Into<i64>,
6994    {
6995        self.max_value = v.map(|x| x.into());
6996        self
6997    }
6998}
6999
7000impl wkt::message::Message for CapacityQuantityInterval {
7001    fn typename() -> &'static str {
7002        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
7003    }
7004}
7005
7006/// A limit defining a maximum distance which can be traveled. It can be either
7007/// hard or soft.
7008///
7009/// If a soft limit is defined, both `soft_max_meters` and
7010/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
7011#[derive(Clone, Default, PartialEq)]
7012#[non_exhaustive]
7013pub struct DistanceLimit {
7014    /// A hard limit constraining the distance to be at most max_meters. The limit
7015    /// must be nonnegative.
7016    pub max_meters: std::option::Option<i64>,
7017
7018    /// A soft limit not enforcing a maximum distance limit, but when violated
7019    /// results in a cost which adds up to other costs defined in the model,
7020    /// with the same unit.
7021    ///
7022    /// If defined soft_max_meters must be less than max_meters and must be
7023    /// nonnegative.
7024    pub soft_max_meters: std::option::Option<i64>,
7025
7026    /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
7027    /// formula:
7028    ///
7029    /// ```norust
7030    ///   min(distance_meters, soft_max_meters) / 1000.0 *
7031    ///   cost_per_kilometer_below_soft_max.
7032    /// ```
7033    ///
7034    /// This cost is not supported in `route_distance_limit`.
7035    pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
7036
7037    /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
7038    /// The additional cost is 0 if the distance is under the limit, otherwise the
7039    /// formula used to compute the cost is the following:
7040    ///
7041    /// ```norust
7042    ///   (distance_meters - soft_max_meters) / 1000.0 *
7043    ///   cost_per_kilometer_above_soft_max.
7044    /// ```
7045    ///
7046    /// The cost must be nonnegative.
7047    pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
7048
7049    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7050}
7051
7052impl DistanceLimit {
7053    pub fn new() -> Self {
7054        std::default::Default::default()
7055    }
7056
7057    /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
7058    ///
7059    /// # Example
7060    /// ```ignore,no_run
7061    /// # use google_cloud_optimization_v1::model::DistanceLimit;
7062    /// let x = DistanceLimit::new().set_max_meters(42);
7063    /// ```
7064    pub fn set_max_meters<T>(mut self, v: T) -> Self
7065    where
7066        T: std::convert::Into<i64>,
7067    {
7068        self.max_meters = std::option::Option::Some(v.into());
7069        self
7070    }
7071
7072    /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
7073    ///
7074    /// # Example
7075    /// ```ignore,no_run
7076    /// # use google_cloud_optimization_v1::model::DistanceLimit;
7077    /// let x = DistanceLimit::new().set_or_clear_max_meters(Some(42));
7078    /// let x = DistanceLimit::new().set_or_clear_max_meters(None::<i32>);
7079    /// ```
7080    pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7081    where
7082        T: std::convert::Into<i64>,
7083    {
7084        self.max_meters = v.map(|x| x.into());
7085        self
7086    }
7087
7088    /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7089    ///
7090    /// # Example
7091    /// ```ignore,no_run
7092    /// # use google_cloud_optimization_v1::model::DistanceLimit;
7093    /// let x = DistanceLimit::new().set_soft_max_meters(42);
7094    /// ```
7095    pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
7096    where
7097        T: std::convert::Into<i64>,
7098    {
7099        self.soft_max_meters = std::option::Option::Some(v.into());
7100        self
7101    }
7102
7103    /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7104    ///
7105    /// # Example
7106    /// ```ignore,no_run
7107    /// # use google_cloud_optimization_v1::model::DistanceLimit;
7108    /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(Some(42));
7109    /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(None::<i32>);
7110    /// ```
7111    pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7112    where
7113        T: std::convert::Into<i64>,
7114    {
7115        self.soft_max_meters = v.map(|x| x.into());
7116        self
7117    }
7118
7119    /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7120    ///
7121    /// # Example
7122    /// ```ignore,no_run
7123    /// # use google_cloud_optimization_v1::model::DistanceLimit;
7124    /// let x = DistanceLimit::new().set_cost_per_kilometer_below_soft_max(42.0);
7125    /// ```
7126    pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
7127    where
7128        T: std::convert::Into<f64>,
7129    {
7130        self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
7131        self
7132    }
7133
7134    /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7135    ///
7136    /// # Example
7137    /// ```ignore,no_run
7138    /// # use google_cloud_optimization_v1::model::DistanceLimit;
7139    /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(Some(42.0));
7140    /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(None::<f32>);
7141    /// ```
7142    pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
7143        mut self,
7144        v: std::option::Option<T>,
7145    ) -> Self
7146    where
7147        T: std::convert::Into<f64>,
7148    {
7149        self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
7150        self
7151    }
7152
7153    /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7154    ///
7155    /// # Example
7156    /// ```ignore,no_run
7157    /// # use google_cloud_optimization_v1::model::DistanceLimit;
7158    /// let x = DistanceLimit::new().set_cost_per_kilometer_above_soft_max(42.0);
7159    /// ```
7160    pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
7161    where
7162        T: std::convert::Into<f64>,
7163    {
7164        self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
7165        self
7166    }
7167
7168    /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7169    ///
7170    /// # Example
7171    /// ```ignore,no_run
7172    /// # use google_cloud_optimization_v1::model::DistanceLimit;
7173    /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(Some(42.0));
7174    /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(None::<f32>);
7175    /// ```
7176    pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
7177        mut self,
7178        v: std::option::Option<T>,
7179    ) -> Self
7180    where
7181        T: std::convert::Into<f64>,
7182    {
7183        self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
7184        self
7185    }
7186}
7187
7188impl wkt::message::Message for DistanceLimit {
7189    fn typename() -> &'static str {
7190        "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
7191    }
7192}
7193
7194/// Specifies attributes of transitions between two consecutive visits on a
7195/// route. Several `TransitionAttributes` may apply to the same transition: in
7196/// that case, all extra costs add up and the strictest constraint or limit
7197/// applies (following natural "AND" semantics).
7198#[derive(Clone, Default, PartialEq)]
7199#[non_exhaustive]
7200pub struct TransitionAttributes {
7201    /// Tags defining the set of (src->dst) transitions these attributes apply to.
7202    ///
7203    /// A source visit or vehicle start matches iff its
7204    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7205    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
7206    /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
7207    /// on which of these two fields is non-empty).
7208    ///
7209    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7210    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
7211    pub src_tag: std::string::String,
7212
7213    /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
7214    /// non-empty.
7215    pub excluded_src_tag: std::string::String,
7216
7217    /// A destination visit or vehicle end matches iff its
7218    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7219    /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
7220    /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
7221    /// which of these two fields is non-empty).
7222    ///
7223    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7224    /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
7225    pub dst_tag: std::string::String,
7226
7227    /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
7228    /// non-empty.
7229    pub excluded_dst_tag: std::string::String,
7230
7231    /// Specifies a cost for performing this transition. This is in the same unit
7232    /// as all other costs in the model and must not be negative. It is applied on
7233    /// top of all other existing costs.
7234    pub cost: f64,
7235
7236    /// Specifies a cost per kilometer applied to the distance traveled while
7237    /// performing this transition. It adds up to any
7238    /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
7239    /// specified on vehicles.
7240    ///
7241    /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
7242    pub cost_per_kilometer: f64,
7243
7244    /// Specifies a limit on the distance traveled while performing this
7245    /// transition.
7246    ///
7247    /// As of 2021/06, only soft limits are supported.
7248    pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
7249
7250    /// Specifies a delay incurred when performing this transition.
7251    ///
7252    /// This delay always occurs *after* finishing the source visit and *before*
7253    /// starting the destination visit.
7254    pub delay: std::option::Option<wkt::Duration>,
7255
7256    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7257}
7258
7259impl TransitionAttributes {
7260    pub fn new() -> Self {
7261        std::default::Default::default()
7262    }
7263
7264    /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
7265    ///
7266    /// # Example
7267    /// ```ignore,no_run
7268    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7269    /// let x = TransitionAttributes::new().set_src_tag("example");
7270    /// ```
7271    pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7272        self.src_tag = v.into();
7273        self
7274    }
7275
7276    /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
7277    ///
7278    /// # Example
7279    /// ```ignore,no_run
7280    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7281    /// let x = TransitionAttributes::new().set_excluded_src_tag("example");
7282    /// ```
7283    pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
7284        mut self,
7285        v: T,
7286    ) -> Self {
7287        self.excluded_src_tag = v.into();
7288        self
7289    }
7290
7291    /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
7292    ///
7293    /// # Example
7294    /// ```ignore,no_run
7295    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7296    /// let x = TransitionAttributes::new().set_dst_tag("example");
7297    /// ```
7298    pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7299        self.dst_tag = v.into();
7300        self
7301    }
7302
7303    /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
7304    ///
7305    /// # Example
7306    /// ```ignore,no_run
7307    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7308    /// let x = TransitionAttributes::new().set_excluded_dst_tag("example");
7309    /// ```
7310    pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
7311        mut self,
7312        v: T,
7313    ) -> Self {
7314        self.excluded_dst_tag = v.into();
7315        self
7316    }
7317
7318    /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
7319    ///
7320    /// # Example
7321    /// ```ignore,no_run
7322    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7323    /// let x = TransitionAttributes::new().set_cost(42.0);
7324    /// ```
7325    pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7326        self.cost = v.into();
7327        self
7328    }
7329
7330    /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
7331    ///
7332    /// # Example
7333    /// ```ignore,no_run
7334    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7335    /// let x = TransitionAttributes::new().set_cost_per_kilometer(42.0);
7336    /// ```
7337    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7338        self.cost_per_kilometer = v.into();
7339        self
7340    }
7341
7342    /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7343    ///
7344    /// # Example
7345    /// ```ignore,no_run
7346    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7347    /// use google_cloud_optimization_v1::model::DistanceLimit;
7348    /// let x = TransitionAttributes::new().set_distance_limit(DistanceLimit::default()/* use setters */);
7349    /// ```
7350    pub fn set_distance_limit<T>(mut self, v: T) -> Self
7351    where
7352        T: std::convert::Into<crate::model::DistanceLimit>,
7353    {
7354        self.distance_limit = std::option::Option::Some(v.into());
7355        self
7356    }
7357
7358    /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7359    ///
7360    /// # Example
7361    /// ```ignore,no_run
7362    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7363    /// use google_cloud_optimization_v1::model::DistanceLimit;
7364    /// let x = TransitionAttributes::new().set_or_clear_distance_limit(Some(DistanceLimit::default()/* use setters */));
7365    /// let x = TransitionAttributes::new().set_or_clear_distance_limit(None::<DistanceLimit>);
7366    /// ```
7367    pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
7368    where
7369        T: std::convert::Into<crate::model::DistanceLimit>,
7370    {
7371        self.distance_limit = v.map(|x| x.into());
7372        self
7373    }
7374
7375    /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
7376    ///
7377    /// # Example
7378    /// ```ignore,no_run
7379    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7380    /// use wkt::Duration;
7381    /// let x = TransitionAttributes::new().set_delay(Duration::default()/* use setters */);
7382    /// ```
7383    pub fn set_delay<T>(mut self, v: T) -> Self
7384    where
7385        T: std::convert::Into<wkt::Duration>,
7386    {
7387        self.delay = std::option::Option::Some(v.into());
7388        self
7389    }
7390
7391    /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
7392    ///
7393    /// # Example
7394    /// ```ignore,no_run
7395    /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7396    /// use wkt::Duration;
7397    /// let x = TransitionAttributes::new().set_or_clear_delay(Some(Duration::default()/* use setters */));
7398    /// let x = TransitionAttributes::new().set_or_clear_delay(None::<Duration>);
7399    /// ```
7400    pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
7401    where
7402        T: std::convert::Into<wkt::Duration>,
7403    {
7404        self.delay = v.map(|x| x.into());
7405        self
7406    }
7407}
7408
7409impl wkt::message::Message for TransitionAttributes {
7410    fn typename() -> &'static str {
7411        "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
7412    }
7413}
7414
7415/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
7416/// VisitRequests, and start and end locations of Vehicles.
7417#[derive(Clone, Default, PartialEq)]
7418#[non_exhaustive]
7419pub struct Waypoint {
7420    /// Indicates that the location of this waypoint is meant to have a preference
7421    /// for the vehicle to stop at a particular side of road. When you set this
7422    /// value, the route will pass through the location so that the vehicle can
7423    /// stop at the side of road that the location is biased towards from the
7424    /// center of the road. This option works only for the 'DRIVING' travel mode,
7425    /// and when the 'location_type' is set to 'location'.
7426    pub side_of_road: bool,
7427
7428    /// Different ways to represent a location.
7429    pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
7430
7431    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7432}
7433
7434impl Waypoint {
7435    pub fn new() -> Self {
7436        std::default::Default::default()
7437    }
7438
7439    /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
7440    ///
7441    /// # Example
7442    /// ```ignore,no_run
7443    /// # use google_cloud_optimization_v1::model::Waypoint;
7444    /// let x = Waypoint::new().set_side_of_road(true);
7445    /// ```
7446    pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7447        self.side_of_road = v.into();
7448        self
7449    }
7450
7451    /// Sets the value of [location_type][crate::model::Waypoint::location_type].
7452    ///
7453    /// Note that all the setters affecting `location_type` are mutually
7454    /// exclusive.
7455    ///
7456    /// # Example
7457    /// ```ignore,no_run
7458    /// # use google_cloud_optimization_v1::model::Waypoint;
7459    /// use google_cloud_optimization_v1::model::waypoint::LocationType;
7460    /// let x = Waypoint::new().set_location_type(Some(LocationType::PlaceId("example".to_string())));
7461    /// ```
7462    pub fn set_location_type<
7463        T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
7464    >(
7465        mut self,
7466        v: T,
7467    ) -> Self {
7468        self.location_type = v.into();
7469        self
7470    }
7471
7472    /// The value of [location_type][crate::model::Waypoint::location_type]
7473    /// if it holds a `Location`, `None` if the field is not set or
7474    /// holds a different branch.
7475    pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
7476        #[allow(unreachable_patterns)]
7477        self.location_type.as_ref().and_then(|v| match v {
7478            crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
7479            _ => std::option::Option::None,
7480        })
7481    }
7482
7483    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7484    /// to hold a `Location`.
7485    ///
7486    /// Note that all the setters affecting `location_type` are
7487    /// mutually exclusive.
7488    ///
7489    /// # Example
7490    /// ```ignore,no_run
7491    /// # use google_cloud_optimization_v1::model::Waypoint;
7492    /// use google_cloud_optimization_v1::model::Location;
7493    /// let x = Waypoint::new().set_location(Location::default()/* use setters */);
7494    /// assert!(x.location().is_some());
7495    /// assert!(x.place_id().is_none());
7496    /// ```
7497    pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
7498        mut self,
7499        v: T,
7500    ) -> Self {
7501        self.location_type =
7502            std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
7503        self
7504    }
7505
7506    /// The value of [location_type][crate::model::Waypoint::location_type]
7507    /// if it holds a `PlaceId`, `None` if the field is not set or
7508    /// holds a different branch.
7509    pub fn place_id(&self) -> std::option::Option<&std::string::String> {
7510        #[allow(unreachable_patterns)]
7511        self.location_type.as_ref().and_then(|v| match v {
7512            crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
7513            _ => std::option::Option::None,
7514        })
7515    }
7516
7517    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7518    /// to hold a `PlaceId`.
7519    ///
7520    /// Note that all the setters affecting `location_type` are
7521    /// mutually exclusive.
7522    ///
7523    /// # Example
7524    /// ```ignore,no_run
7525    /// # use google_cloud_optimization_v1::model::Waypoint;
7526    /// let x = Waypoint::new().set_place_id("example");
7527    /// assert!(x.place_id().is_some());
7528    /// assert!(x.location().is_none());
7529    /// ```
7530    pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7531        self.location_type =
7532            std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
7533        self
7534    }
7535}
7536
7537impl wkt::message::Message for Waypoint {
7538    fn typename() -> &'static str {
7539        "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
7540    }
7541}
7542
7543/// Defines additional types related to [Waypoint].
7544pub mod waypoint {
7545    #[allow(unused_imports)]
7546    use super::*;
7547
7548    /// Different ways to represent a location.
7549    #[derive(Clone, Debug, PartialEq)]
7550    #[non_exhaustive]
7551    pub enum LocationType {
7552        /// A point specified using geographic coordinates, including an optional
7553        /// heading.
7554        Location(std::boxed::Box<crate::model::Location>),
7555        /// The POI Place ID associated with the waypoint.
7556        PlaceId(std::string::String),
7557    }
7558}
7559
7560/// Encapsulates a location (a geographic point, and an optional heading).
7561#[derive(Clone, Default, PartialEq)]
7562#[non_exhaustive]
7563pub struct Location {
7564    /// The waypoint's geographic coordinates.
7565    pub lat_lng: std::option::Option<gtype::model::LatLng>,
7566
7567    /// The compass heading associated with the direction of the flow of traffic.
7568    /// This value is used to specify the side of the road to use for pickup and
7569    /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
7570    /// of due North, 90 specifies a heading of due East, etc.
7571    pub heading: std::option::Option<i32>,
7572
7573    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7574}
7575
7576impl Location {
7577    pub fn new() -> Self {
7578        std::default::Default::default()
7579    }
7580
7581    /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
7582    ///
7583    /// # Example
7584    /// ```ignore,no_run
7585    /// # use google_cloud_optimization_v1::model::Location;
7586    /// use gtype::model::LatLng;
7587    /// let x = Location::new().set_lat_lng(LatLng::default()/* use setters */);
7588    /// ```
7589    pub fn set_lat_lng<T>(mut self, v: T) -> Self
7590    where
7591        T: std::convert::Into<gtype::model::LatLng>,
7592    {
7593        self.lat_lng = std::option::Option::Some(v.into());
7594        self
7595    }
7596
7597    /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
7598    ///
7599    /// # Example
7600    /// ```ignore,no_run
7601    /// # use google_cloud_optimization_v1::model::Location;
7602    /// use gtype::model::LatLng;
7603    /// let x = Location::new().set_or_clear_lat_lng(Some(LatLng::default()/* use setters */));
7604    /// let x = Location::new().set_or_clear_lat_lng(None::<LatLng>);
7605    /// ```
7606    pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
7607    where
7608        T: std::convert::Into<gtype::model::LatLng>,
7609    {
7610        self.lat_lng = v.map(|x| x.into());
7611        self
7612    }
7613
7614    /// Sets the value of [heading][crate::model::Location::heading].
7615    ///
7616    /// # Example
7617    /// ```ignore,no_run
7618    /// # use google_cloud_optimization_v1::model::Location;
7619    /// let x = Location::new().set_heading(42);
7620    /// ```
7621    pub fn set_heading<T>(mut self, v: T) -> Self
7622    where
7623        T: std::convert::Into<i32>,
7624    {
7625        self.heading = std::option::Option::Some(v.into());
7626        self
7627    }
7628
7629    /// Sets or clears the value of [heading][crate::model::Location::heading].
7630    ///
7631    /// # Example
7632    /// ```ignore,no_run
7633    /// # use google_cloud_optimization_v1::model::Location;
7634    /// let x = Location::new().set_or_clear_heading(Some(42));
7635    /// let x = Location::new().set_or_clear_heading(None::<i32>);
7636    /// ```
7637    pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
7638    where
7639        T: std::convert::Into<i32>,
7640    {
7641        self.heading = v.map(|x| x.into());
7642        self
7643    }
7644}
7645
7646impl wkt::message::Message for Location {
7647    fn typename() -> &'static str {
7648        "type.googleapis.com/google.cloud.optimization.v1.Location"
7649    }
7650}
7651
7652/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
7653/// is a contiguous period of time during which the vehicle remains idle at its
7654/// current position and cannot perform any visit. A break may occur:
7655///
7656/// * during the travel between two visits (which includes the time right
7657///   before or right after a visit, but not in the middle of a visit), in
7658///   which case it extends the corresponding transit time between the visits,
7659/// * or before the vehicle start (the vehicle may not start in the middle of
7660///   a break), in which case it does not affect the vehicle start time.
7661/// * or after the vehicle end (ditto, with the vehicle end time).
7662#[derive(Clone, Default, PartialEq)]
7663#[non_exhaustive]
7664pub struct BreakRule {
7665    /// Sequence of breaks. See the `BreakRequest` message.
7666    pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
7667
7668    /// Several `FrequencyConstraint` may apply. They must all be satisfied by
7669    /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
7670    pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
7671
7672    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7673}
7674
7675impl BreakRule {
7676    pub fn new() -> Self {
7677        std::default::Default::default()
7678    }
7679
7680    /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
7681    ///
7682    /// # Example
7683    /// ```ignore,no_run
7684    /// # use google_cloud_optimization_v1::model::BreakRule;
7685    /// use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7686    /// let x = BreakRule::new()
7687    ///     .set_break_requests([
7688    ///         BreakRequest::default()/* use setters */,
7689    ///         BreakRequest::default()/* use (different) setters */,
7690    ///     ]);
7691    /// ```
7692    pub fn set_break_requests<T, V>(mut self, v: T) -> Self
7693    where
7694        T: std::iter::IntoIterator<Item = V>,
7695        V: std::convert::Into<crate::model::break_rule::BreakRequest>,
7696    {
7697        use std::iter::Iterator;
7698        self.break_requests = v.into_iter().map(|i| i.into()).collect();
7699        self
7700    }
7701
7702    /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
7703    ///
7704    /// # Example
7705    /// ```ignore,no_run
7706    /// # use google_cloud_optimization_v1::model::BreakRule;
7707    /// use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7708    /// let x = BreakRule::new()
7709    ///     .set_frequency_constraints([
7710    ///         FrequencyConstraint::default()/* use setters */,
7711    ///         FrequencyConstraint::default()/* use (different) setters */,
7712    ///     ]);
7713    /// ```
7714    pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
7715    where
7716        T: std::iter::IntoIterator<Item = V>,
7717        V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
7718    {
7719        use std::iter::Iterator;
7720        self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
7721        self
7722    }
7723}
7724
7725impl wkt::message::Message for BreakRule {
7726    fn typename() -> &'static str {
7727        "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
7728    }
7729}
7730
7731/// Defines additional types related to [BreakRule].
7732pub mod break_rule {
7733    #[allow(unused_imports)]
7734    use super::*;
7735
7736    /// The sequence of breaks (i.e. their number and order) that apply to each
7737    /// vehicle must be known beforehand. The repeated `BreakRequest`s define
7738    /// that sequence, in the order in which they must occur. Their time windows
7739    /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
7740    /// be compatible with the order (this is checked).
7741    #[derive(Clone, Default, PartialEq)]
7742    #[non_exhaustive]
7743    pub struct BreakRequest {
7744        /// Required. Lower bound (inclusive) on the start of the break.
7745        pub earliest_start_time: std::option::Option<wkt::Timestamp>,
7746
7747        /// Required. Upper bound (inclusive) on the start of the break.
7748        pub latest_start_time: std::option::Option<wkt::Timestamp>,
7749
7750        /// Required. Minimum duration of the break. Must be positive.
7751        pub min_duration: std::option::Option<wkt::Duration>,
7752
7753        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7754    }
7755
7756    impl BreakRequest {
7757        pub fn new() -> Self {
7758            std::default::Default::default()
7759        }
7760
7761        /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7762        ///
7763        /// # Example
7764        /// ```ignore,no_run
7765        /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7766        /// use wkt::Timestamp;
7767        /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
7768        /// ```
7769        pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
7770        where
7771            T: std::convert::Into<wkt::Timestamp>,
7772        {
7773            self.earliest_start_time = std::option::Option::Some(v.into());
7774            self
7775        }
7776
7777        /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7778        ///
7779        /// # Example
7780        /// ```ignore,no_run
7781        /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7782        /// use wkt::Timestamp;
7783        /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
7784        /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
7785        /// ```
7786        pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7787        where
7788            T: std::convert::Into<wkt::Timestamp>,
7789        {
7790            self.earliest_start_time = v.map(|x| x.into());
7791            self
7792        }
7793
7794        /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7795        ///
7796        /// # Example
7797        /// ```ignore,no_run
7798        /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7799        /// use wkt::Timestamp;
7800        /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
7801        /// ```
7802        pub fn set_latest_start_time<T>(mut self, v: T) -> Self
7803        where
7804            T: std::convert::Into<wkt::Timestamp>,
7805        {
7806            self.latest_start_time = std::option::Option::Some(v.into());
7807            self
7808        }
7809
7810        /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7811        ///
7812        /// # Example
7813        /// ```ignore,no_run
7814        /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7815        /// use wkt::Timestamp;
7816        /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
7817        /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
7818        /// ```
7819        pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7820        where
7821            T: std::convert::Into<wkt::Timestamp>,
7822        {
7823            self.latest_start_time = v.map(|x| x.into());
7824            self
7825        }
7826
7827        /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7828        ///
7829        /// # Example
7830        /// ```ignore,no_run
7831        /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7832        /// use wkt::Duration;
7833        /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
7834        /// ```
7835        pub fn set_min_duration<T>(mut self, v: T) -> Self
7836        where
7837            T: std::convert::Into<wkt::Duration>,
7838        {
7839            self.min_duration = std::option::Option::Some(v.into());
7840            self
7841        }
7842
7843        /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7844        ///
7845        /// # Example
7846        /// ```ignore,no_run
7847        /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7848        /// use wkt::Duration;
7849        /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
7850        /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
7851        /// ```
7852        pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
7853        where
7854            T: std::convert::Into<wkt::Duration>,
7855        {
7856            self.min_duration = v.map(|x| x.into());
7857            self
7858        }
7859    }
7860
7861    impl wkt::message::Message for BreakRequest {
7862        fn typename() -> &'static str {
7863            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
7864        }
7865    }
7866
7867    /// One may further constrain the frequency and duration of the breaks
7868    /// specified above, by enforcing a minimum break frequency, such as
7869    /// "There must be a break of at least 1 hour every 12 hours". Assuming that
7870    /// this can be interpreted as "Within any sliding time window of 12h, there
7871    /// must be at least one break of at least one hour", that example would
7872    /// translate to the following `FrequencyConstraint`:
7873    ///
7874    /// ```norust
7875    /// {
7876    ///    min_break_duration { seconds: 3600 }         # 1 hour.
7877    ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
7878    /// }
7879    /// ```
7880    ///
7881    /// The timing and duration of the breaks in the solution will respect all
7882    /// such constraints, in addition to the time windows and minimum durations
7883    /// already specified in the `BreakRequest`.
7884    ///
7885    /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
7886    /// For example, the following schedule honors the "1h every 12h" example:
7887    ///
7888    /// ```norust
7889    ///   04:00 vehicle start
7890    ///    .. performing travel and visits ..
7891    ///   09:00 1 hour break
7892    ///   10:00 end of the break
7893    ///    .. performing travel and visits ..
7894    ///   12:00 20-min lunch break
7895    ///   12:20 end of the break
7896    ///    .. performing travel and visits ..
7897    ///   21:00 1 hour break
7898    ///   22:00 end of the break
7899    ///    .. performing travel and visits ..
7900    ///   23:59 vehicle end
7901    /// ```
7902    #[derive(Clone, Default, PartialEq)]
7903    #[non_exhaustive]
7904    pub struct FrequencyConstraint {
7905        /// Required. Minimum break duration for this constraint. Nonnegative.
7906        /// See description of `FrequencyConstraint`.
7907        pub min_break_duration: std::option::Option<wkt::Duration>,
7908
7909        /// Required. Maximum allowed span of any interval of time in the route that
7910        /// does not include at least partially a break of `duration >=
7911        /// min_break_duration`. Must be positive.
7912        pub max_inter_break_duration: std::option::Option<wkt::Duration>,
7913
7914        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7915    }
7916
7917    impl FrequencyConstraint {
7918        pub fn new() -> Self {
7919            std::default::Default::default()
7920        }
7921
7922        /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7923        ///
7924        /// # Example
7925        /// ```ignore,no_run
7926        /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7927        /// use wkt::Duration;
7928        /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
7929        /// ```
7930        pub fn set_min_break_duration<T>(mut self, v: T) -> Self
7931        where
7932            T: std::convert::Into<wkt::Duration>,
7933        {
7934            self.min_break_duration = std::option::Option::Some(v.into());
7935            self
7936        }
7937
7938        /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7939        ///
7940        /// # Example
7941        /// ```ignore,no_run
7942        /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7943        /// use wkt::Duration;
7944        /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
7945        /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
7946        /// ```
7947        pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7948        where
7949            T: std::convert::Into<wkt::Duration>,
7950        {
7951            self.min_break_duration = v.map(|x| x.into());
7952            self
7953        }
7954
7955        /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7956        ///
7957        /// # Example
7958        /// ```ignore,no_run
7959        /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7960        /// use wkt::Duration;
7961        /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
7962        /// ```
7963        pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
7964        where
7965            T: std::convert::Into<wkt::Duration>,
7966        {
7967            self.max_inter_break_duration = std::option::Option::Some(v.into());
7968            self
7969        }
7970
7971        /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7972        ///
7973        /// # Example
7974        /// ```ignore,no_run
7975        /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7976        /// use wkt::Duration;
7977        /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
7978        /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
7979        /// ```
7980        pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7981        where
7982            T: std::convert::Into<wkt::Duration>,
7983        {
7984            self.max_inter_break_duration = v.map(|x| x.into());
7985            self
7986        }
7987    }
7988
7989    impl wkt::message::Message for FrequencyConstraint {
7990        fn typename() -> &'static str {
7991            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
7992        }
7993    }
7994}
7995
7996/// A vehicle's route can be decomposed, along the time axis, like this (we
7997/// assume there are n visits):
7998///
7999/// ```norust
8000///   |            |            |          |       |  T[2], |        |      |
8001///   | Transition |  Visit #0  |          |       |  V[2], |        |      |
8002///   |     #0     |    aka     |   T[1]   |  V[1] |  ...   | V[n-1] | T[n] |
8003///   |  aka T[0]  |    V[0]    |          |       | V[n-2],|        |      |
8004///   |            |            |          |       | T[n-1] |        |      |
8005///   ^            ^            ^          ^       ^        ^        ^      ^
8006/// vehicle    V[0].start   V[0].end     V[1].   V[1].    V[n].    V[n]. vehicle
8007///  start     (arrival)   (departure)   start   end      start    end     end
8008/// ```
8009///
8010/// Note that we make a difference between:
8011///
8012/// * "punctual events", such as the vehicle start and end and each visit's start
8013///   and end (aka arrival and departure). They happen at a given second.
8014/// * "time intervals", such as the visits themselves, and the transition between
8015///   visits. Though time intervals can sometimes have zero duration, i.e. start
8016///   and end at the same second, they often have a positive duration.
8017///
8018/// Invariants:
8019///
8020/// * If there are n visits, there are n+1 transitions.
8021/// * A visit is always surrounded by a transition before it (same index) and a
8022///   transition after it (index + 1).
8023/// * The vehicle start is always followed by transition #0.
8024/// * The vehicle end is always preceded by transition #n.
8025///
8026/// Zooming in, here is what happens during a `Transition` and a `Visit`:
8027///
8028/// ```norust
8029/// ---+-------------------------------------+-----------------------------+-->
8030///    |           TRANSITION[i]             |           VISIT[i]          |
8031///    |                                     |                             |
8032///    |  * TRAVEL: the vehicle moves from   |      PERFORM the visit:     |
8033///    |    VISIT[i-1].departure_location to |                             |
8034///    |    VISIT[i].arrival_location, which |  * Spend some time:         |
8035///    |    takes a given travel duration    |    the "visit duration".    |
8036///    |    and distance                     |                             |
8037///    |                                     |  * Load or unload           |
8038///    |  * BREAKS: the driver may have      |    some quantities from the |
8039///    |    breaks (e.g. lunch break).       |    vehicle: the "demand".   |
8040///    |                                     |                             |
8041///    |  * WAIT: the driver/vehicle does    |                             |
8042///    |    nothing. This can happen for     |                             |
8043///    |    many reasons, for example when   |                             |
8044///    |    the vehicle reaches the next     |                             |
8045///    |    event's destination before the   |                             |
8046///    |    start of its time window         |                             |
8047///    |                                     |                             |
8048///    |  * DELAY: *right before* the next   |                             |
8049///    |    arrival. E.g. the vehicle and/or |                             |
8050///    |    driver spends time unloading.    |                             |
8051///    |                                     |                             |
8052/// ---+-------------------------------------+-----------------------------+-->
8053///    ^                                     ^                             ^
8054/// V[i-1].end                           V[i].start                    V[i].end
8055/// ```
8056///
8057/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
8058/// during a transition.
8059///
8060/// * They don't overlap.
8061/// * The DELAY is unique and *must* be a contiguous period of time right
8062///   before the next visit (or vehicle end). Thus, it suffice to know the
8063///   delay duration to know its start and end time.
8064/// * The BREAKS are contiguous, non-overlapping periods of time. The
8065///   response specifies the start time and duration of each break.
8066/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
8067///   during this transition. Clients can assume that travel happens "as soon as
8068///   possible" and that "wait" fills the remaining time.
8069///
8070/// A (complex) example:
8071///
8072/// ```norust
8073///                                TRANSITION[i]
8074/// --++-----+-----------------------------------------------------------++-->
8075///   ||     |       |           |       |           |         |         ||
8076///   ||  T  |   B   |     T     |       |     B     |         |    D    ||
8077///   ||  r  |   r   |     r     |   W   |     r     |    W    |    e    ||
8078///   ||  a  |   e   |     a     |   a   |     e     |    a    |    l    ||
8079///   ||  v  |   a   |     v     |   i   |     a     |    i    |    a    ||
8080///   ||  e  |   k   |     e     |   t   |     k     |    t    |    y    ||
8081///   ||  l  |       |     l     |       |           |         |         ||
8082///   ||     |       |           |       |           |         |         ||
8083/// --++-----------------------------------------------------------------++-->
8084/// ```
8085#[derive(Clone, Default, PartialEq)]
8086#[non_exhaustive]
8087pub struct ShipmentRoute {
8088    /// Vehicle performing the route, identified by its index in the source
8089    /// `ShipmentModel`.
8090    pub vehicle_index: i32,
8091
8092    /// Label of the vehicle performing this route, equal to
8093    /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
8094    pub vehicle_label: std::string::String,
8095
8096    /// Time at which the vehicle starts its route.
8097    pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
8098
8099    /// Time at which the vehicle finishes its route.
8100    pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
8101
8102    /// Ordered sequence of visits representing a route.
8103    /// visits[i] is the i-th visit in the route.
8104    /// If this field is empty, the vehicle is considered as unused.
8105    pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
8106
8107    /// Ordered list of transitions for the route.
8108    pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
8109
8110    /// When
8111    /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
8112    /// is set to true, this field indicates that inconsistencies in route timings
8113    /// are predicted using traffic-based travel duration estimates. There may be
8114    /// insufficient time to complete traffic-adjusted travel, delays, and breaks
8115    /// between visits, before the first visit, or after the last visit, while
8116    /// still satisfying the visit and vehicle time windows. For example,
8117    ///
8118    /// ```norust
8119    ///   start_time(previous_visit) + duration(previous_visit) +
8120    ///   travel_duration(previous_visit, next_visit) > start_time(next_visit)
8121    /// ```
8122    ///
8123    /// Arrival at next_visit will likely happen later than its current
8124    /// time window due the increased estimate of travel time
8125    /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
8126    /// may be forced to overlap with a visit due to an increase in travel time
8127    /// estimates and visit or break time window restrictions.
8128    ///
8129    /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
8130    pub has_traffic_infeasibilities: bool,
8131
8132    /// The encoded polyline representation of the route.
8133    /// This field is only populated if
8134    /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
8135    /// is set to true.
8136    ///
8137    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
8138    pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
8139
8140    /// Breaks scheduled for the vehicle performing this route.
8141    /// The `breaks` sequence represents time intervals, each starting at the
8142    /// corresponding `start_time` and lasting `duration` seconds.
8143    pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
8144
8145    /// Duration, distance and load metrics for this route. The fields of
8146    /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
8147    /// summed over all
8148    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8149    /// or
8150    /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
8151    /// depending on the context.
8152    ///
8153    /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
8154    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8155    /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
8156    pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
8157
8158    /// Cost of the route, broken down by cost-related request fields.
8159    /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
8160    /// "model.shipments.pickups.cost", and the values are the total cost
8161    /// generated by the corresponding cost field, aggregated over the whole route.
8162    /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
8163    /// pickup costs over the route. All costs defined in the model are reported in
8164    /// detail here with the exception of costs related to TransitionAttributes
8165    /// that are only reported in an aggregated way as of 2022/01.
8166    pub route_costs: std::collections::HashMap<std::string::String, f64>,
8167
8168    /// Total cost of the route. The sum of all costs in the cost map.
8169    pub route_total_cost: f64,
8170
8171    /// Deprecated: Use
8172    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8173    /// instead. Vehicle loads upon arrival at its end location, for each type
8174    /// specified in
8175    /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8176    /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
8177    /// loads for quantity types unconstrained by intervals and that don't have any
8178    /// non-zero demand on the route.
8179    ///
8180    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8181    /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8182    #[deprecated]
8183    pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8184
8185    /// Deprecated: Use
8186    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8187    /// instead. Ordered list of travel steps for the route.
8188    ///
8189    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8190    #[deprecated]
8191    pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
8192
8193    /// Deprecated: No longer used.
8194    /// This field will only be populated at the
8195    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
8196    /// level.
8197    ///
8198    /// This field is the extra detour time due to the shipments visited on the
8199    /// route.
8200    ///
8201    /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
8202    /// from the vehicle's start_location to its `end_location`.
8203    ///
8204    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
8205    #[deprecated]
8206    pub vehicle_detour: std::option::Option<wkt::Duration>,
8207
8208    /// Deprecated: Delay occurring before the vehicle end. See
8209    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8210    ///
8211    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8212    #[deprecated]
8213    pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
8214
8215    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8216}
8217
8218impl ShipmentRoute {
8219    pub fn new() -> Self {
8220        std::default::Default::default()
8221    }
8222
8223    /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
8224    ///
8225    /// # Example
8226    /// ```ignore,no_run
8227    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8228    /// let x = ShipmentRoute::new().set_vehicle_index(42);
8229    /// ```
8230    pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8231        self.vehicle_index = v.into();
8232        self
8233    }
8234
8235    /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
8236    ///
8237    /// # Example
8238    /// ```ignore,no_run
8239    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8240    /// let x = ShipmentRoute::new().set_vehicle_label("example");
8241    /// ```
8242    pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8243        self.vehicle_label = v.into();
8244        self
8245    }
8246
8247    /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8248    ///
8249    /// # Example
8250    /// ```ignore,no_run
8251    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8252    /// use wkt::Timestamp;
8253    /// let x = ShipmentRoute::new().set_vehicle_start_time(Timestamp::default()/* use setters */);
8254    /// ```
8255    pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
8256    where
8257        T: std::convert::Into<wkt::Timestamp>,
8258    {
8259        self.vehicle_start_time = std::option::Option::Some(v.into());
8260        self
8261    }
8262
8263    /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8264    ///
8265    /// # Example
8266    /// ```ignore,no_run
8267    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8268    /// use wkt::Timestamp;
8269    /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(Some(Timestamp::default()/* use setters */));
8270    /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(None::<Timestamp>);
8271    /// ```
8272    pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8273    where
8274        T: std::convert::Into<wkt::Timestamp>,
8275    {
8276        self.vehicle_start_time = v.map(|x| x.into());
8277        self
8278    }
8279
8280    /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8281    ///
8282    /// # Example
8283    /// ```ignore,no_run
8284    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8285    /// use wkt::Timestamp;
8286    /// let x = ShipmentRoute::new().set_vehicle_end_time(Timestamp::default()/* use setters */);
8287    /// ```
8288    pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
8289    where
8290        T: std::convert::Into<wkt::Timestamp>,
8291    {
8292        self.vehicle_end_time = std::option::Option::Some(v.into());
8293        self
8294    }
8295
8296    /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8297    ///
8298    /// # Example
8299    /// ```ignore,no_run
8300    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8301    /// use wkt::Timestamp;
8302    /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(Some(Timestamp::default()/* use setters */));
8303    /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(None::<Timestamp>);
8304    /// ```
8305    pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
8306    where
8307        T: std::convert::Into<wkt::Timestamp>,
8308    {
8309        self.vehicle_end_time = v.map(|x| x.into());
8310        self
8311    }
8312
8313    /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
8314    ///
8315    /// # Example
8316    /// ```ignore,no_run
8317    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8318    /// use google_cloud_optimization_v1::model::shipment_route::Visit;
8319    /// let x = ShipmentRoute::new()
8320    ///     .set_visits([
8321    ///         Visit::default()/* use setters */,
8322    ///         Visit::default()/* use (different) setters */,
8323    ///     ]);
8324    /// ```
8325    pub fn set_visits<T, V>(mut self, v: T) -> Self
8326    where
8327        T: std::iter::IntoIterator<Item = V>,
8328        V: std::convert::Into<crate::model::shipment_route::Visit>,
8329    {
8330        use std::iter::Iterator;
8331        self.visits = v.into_iter().map(|i| i.into()).collect();
8332        self
8333    }
8334
8335    /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
8336    ///
8337    /// # Example
8338    /// ```ignore,no_run
8339    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8340    /// use google_cloud_optimization_v1::model::shipment_route::Transition;
8341    /// let x = ShipmentRoute::new()
8342    ///     .set_transitions([
8343    ///         Transition::default()/* use setters */,
8344    ///         Transition::default()/* use (different) setters */,
8345    ///     ]);
8346    /// ```
8347    pub fn set_transitions<T, V>(mut self, v: T) -> Self
8348    where
8349        T: std::iter::IntoIterator<Item = V>,
8350        V: std::convert::Into<crate::model::shipment_route::Transition>,
8351    {
8352        use std::iter::Iterator;
8353        self.transitions = v.into_iter().map(|i| i.into()).collect();
8354        self
8355    }
8356
8357    /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
8358    ///
8359    /// # Example
8360    /// ```ignore,no_run
8361    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8362    /// let x = ShipmentRoute::new().set_has_traffic_infeasibilities(true);
8363    /// ```
8364    pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8365        self.has_traffic_infeasibilities = v.into();
8366        self
8367    }
8368
8369    /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8370    ///
8371    /// # Example
8372    /// ```ignore,no_run
8373    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8374    /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8375    /// let x = ShipmentRoute::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
8376    /// ```
8377    pub fn set_route_polyline<T>(mut self, v: T) -> Self
8378    where
8379        T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8380    {
8381        self.route_polyline = std::option::Option::Some(v.into());
8382        self
8383    }
8384
8385    /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8386    ///
8387    /// # Example
8388    /// ```ignore,no_run
8389    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8390    /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8391    /// let x = ShipmentRoute::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
8392    /// let x = ShipmentRoute::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
8393    /// ```
8394    pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
8395    where
8396        T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8397    {
8398        self.route_polyline = v.map(|x| x.into());
8399        self
8400    }
8401
8402    /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
8403    ///
8404    /// # Example
8405    /// ```ignore,no_run
8406    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8407    /// use google_cloud_optimization_v1::model::shipment_route::Break;
8408    /// let x = ShipmentRoute::new()
8409    ///     .set_breaks([
8410    ///         Break::default()/* use setters */,
8411    ///         Break::default()/* use (different) setters */,
8412    ///     ]);
8413    /// ```
8414    pub fn set_breaks<T, V>(mut self, v: T) -> Self
8415    where
8416        T: std::iter::IntoIterator<Item = V>,
8417        V: std::convert::Into<crate::model::shipment_route::Break>,
8418    {
8419        use std::iter::Iterator;
8420        self.breaks = v.into_iter().map(|i| i.into()).collect();
8421        self
8422    }
8423
8424    /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
8425    ///
8426    /// # Example
8427    /// ```ignore,no_run
8428    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8429    /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8430    /// let x = ShipmentRoute::new().set_metrics(AggregatedMetrics::default()/* use setters */);
8431    /// ```
8432    pub fn set_metrics<T>(mut self, v: T) -> Self
8433    where
8434        T: std::convert::Into<crate::model::AggregatedMetrics>,
8435    {
8436        self.metrics = std::option::Option::Some(v.into());
8437        self
8438    }
8439
8440    /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
8441    ///
8442    /// # Example
8443    /// ```ignore,no_run
8444    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8445    /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8446    /// let x = ShipmentRoute::new().set_or_clear_metrics(Some(AggregatedMetrics::default()/* use setters */));
8447    /// let x = ShipmentRoute::new().set_or_clear_metrics(None::<AggregatedMetrics>);
8448    /// ```
8449    pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
8450    where
8451        T: std::convert::Into<crate::model::AggregatedMetrics>,
8452    {
8453        self.metrics = v.map(|x| x.into());
8454        self
8455    }
8456
8457    /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
8458    ///
8459    /// # Example
8460    /// ```ignore,no_run
8461    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8462    /// let x = ShipmentRoute::new().set_route_costs([
8463    ///     ("key0", 123.5),
8464    ///     ("key1", 456.5),
8465    /// ]);
8466    /// ```
8467    pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
8468    where
8469        T: std::iter::IntoIterator<Item = (K, V)>,
8470        K: std::convert::Into<std::string::String>,
8471        V: std::convert::Into<f64>,
8472    {
8473        use std::iter::Iterator;
8474        self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8475        self
8476    }
8477
8478    /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
8479    ///
8480    /// # Example
8481    /// ```ignore,no_run
8482    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8483    /// let x = ShipmentRoute::new().set_route_total_cost(42.0);
8484    /// ```
8485    pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8486        self.route_total_cost = v.into();
8487        self
8488    }
8489
8490    /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
8491    ///
8492    /// # Example
8493    /// ```ignore,no_run
8494    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8495    /// use google_cloud_optimization_v1::model::CapacityQuantity;
8496    /// let x = ShipmentRoute::new()
8497    ///     .set_end_loads([
8498    ///         CapacityQuantity::default()/* use setters */,
8499    ///         CapacityQuantity::default()/* use (different) setters */,
8500    ///     ]);
8501    /// ```
8502    #[deprecated]
8503    pub fn set_end_loads<T, V>(mut self, v: T) -> Self
8504    where
8505        T: std::iter::IntoIterator<Item = V>,
8506        V: std::convert::Into<crate::model::CapacityQuantity>,
8507    {
8508        use std::iter::Iterator;
8509        self.end_loads = v.into_iter().map(|i| i.into()).collect();
8510        self
8511    }
8512
8513    /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
8514    ///
8515    /// # Example
8516    /// ```ignore,no_run
8517    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8518    /// use google_cloud_optimization_v1::model::shipment_route::TravelStep;
8519    /// let x = ShipmentRoute::new()
8520    ///     .set_travel_steps([
8521    ///         TravelStep::default()/* use setters */,
8522    ///         TravelStep::default()/* use (different) setters */,
8523    ///     ]);
8524    /// ```
8525    #[deprecated]
8526    pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
8527    where
8528        T: std::iter::IntoIterator<Item = V>,
8529        V: std::convert::Into<crate::model::shipment_route::TravelStep>,
8530    {
8531        use std::iter::Iterator;
8532        self.travel_steps = v.into_iter().map(|i| i.into()).collect();
8533        self
8534    }
8535
8536    /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8537    ///
8538    /// # Example
8539    /// ```ignore,no_run
8540    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8541    /// use wkt::Duration;
8542    /// let x = ShipmentRoute::new().set_vehicle_detour(Duration::default()/* use setters */);
8543    /// ```
8544    #[deprecated]
8545    pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
8546    where
8547        T: std::convert::Into<wkt::Duration>,
8548    {
8549        self.vehicle_detour = std::option::Option::Some(v.into());
8550        self
8551    }
8552
8553    /// Sets or clears the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8554    ///
8555    /// # Example
8556    /// ```ignore,no_run
8557    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8558    /// use wkt::Duration;
8559    /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(Some(Duration::default()/* use setters */));
8560    /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(None::<Duration>);
8561    /// ```
8562    #[deprecated]
8563    pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
8564    where
8565        T: std::convert::Into<wkt::Duration>,
8566    {
8567        self.vehicle_detour = v.map(|x| x.into());
8568        self
8569    }
8570
8571    /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8572    ///
8573    /// # Example
8574    /// ```ignore,no_run
8575    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8576    /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8577    /// let x = ShipmentRoute::new().set_delay_before_vehicle_end(Delay::default()/* use setters */);
8578    /// ```
8579    #[deprecated]
8580    pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
8581    where
8582        T: std::convert::Into<crate::model::shipment_route::Delay>,
8583    {
8584        self.delay_before_vehicle_end = std::option::Option::Some(v.into());
8585        self
8586    }
8587
8588    /// Sets or clears the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8589    ///
8590    /// # Example
8591    /// ```ignore,no_run
8592    /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8593    /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8594    /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(Some(Delay::default()/* use setters */));
8595    /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(None::<Delay>);
8596    /// ```
8597    #[deprecated]
8598    pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
8599    where
8600        T: std::convert::Into<crate::model::shipment_route::Delay>,
8601    {
8602        self.delay_before_vehicle_end = v.map(|x| x.into());
8603        self
8604    }
8605}
8606
8607impl wkt::message::Message for ShipmentRoute {
8608    fn typename() -> &'static str {
8609        "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
8610    }
8611}
8612
8613/// Defines additional types related to [ShipmentRoute].
8614pub mod shipment_route {
8615    #[allow(unused_imports)]
8616    use super::*;
8617
8618    /// Deprecated: Use
8619    /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8620    /// instead. Time interval spent on the route resulting from a
8621    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8622    ///
8623    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8624    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8625    #[derive(Clone, Default, PartialEq)]
8626    #[non_exhaustive]
8627    #[deprecated]
8628    pub struct Delay {
8629        /// Start of the delay.
8630        pub start_time: std::option::Option<wkt::Timestamp>,
8631
8632        /// Duration of the delay.
8633        pub duration: std::option::Option<wkt::Duration>,
8634
8635        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8636    }
8637
8638    impl Delay {
8639        pub fn new() -> Self {
8640            std::default::Default::default()
8641        }
8642
8643        /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
8644        ///
8645        /// # Example
8646        /// ```ignore,no_run
8647        /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8648        /// use wkt::Timestamp;
8649        /// let x = Delay::new().set_start_time(Timestamp::default()/* use setters */);
8650        /// ```
8651        pub fn set_start_time<T>(mut self, v: T) -> Self
8652        where
8653            T: std::convert::Into<wkt::Timestamp>,
8654        {
8655            self.start_time = std::option::Option::Some(v.into());
8656            self
8657        }
8658
8659        /// Sets or clears the value of [start_time][crate::model::shipment_route::Delay::start_time].
8660        ///
8661        /// # Example
8662        /// ```ignore,no_run
8663        /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8664        /// use wkt::Timestamp;
8665        /// let x = Delay::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8666        /// let x = Delay::new().set_or_clear_start_time(None::<Timestamp>);
8667        /// ```
8668        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8669        where
8670            T: std::convert::Into<wkt::Timestamp>,
8671        {
8672            self.start_time = v.map(|x| x.into());
8673            self
8674        }
8675
8676        /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
8677        ///
8678        /// # Example
8679        /// ```ignore,no_run
8680        /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8681        /// use wkt::Duration;
8682        /// let x = Delay::new().set_duration(Duration::default()/* use setters */);
8683        /// ```
8684        pub fn set_duration<T>(mut self, v: T) -> Self
8685        where
8686            T: std::convert::Into<wkt::Duration>,
8687        {
8688            self.duration = std::option::Option::Some(v.into());
8689            self
8690        }
8691
8692        /// Sets or clears the value of [duration][crate::model::shipment_route::Delay::duration].
8693        ///
8694        /// # Example
8695        /// ```ignore,no_run
8696        /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8697        /// use wkt::Duration;
8698        /// let x = Delay::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
8699        /// let x = Delay::new().set_or_clear_duration(None::<Duration>);
8700        /// ```
8701        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
8702        where
8703            T: std::convert::Into<wkt::Duration>,
8704        {
8705            self.duration = v.map(|x| x.into());
8706            self
8707        }
8708    }
8709
8710    impl wkt::message::Message for Delay {
8711        fn typename() -> &'static str {
8712            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
8713        }
8714    }
8715
8716    /// A visit performed during a route. This visit corresponds to a pickup or a
8717    /// delivery of a `Shipment`.
8718    #[derive(Clone, Default, PartialEq)]
8719    #[non_exhaustive]
8720    pub struct Visit {
8721        /// Index of the `shipments` field in the source
8722        /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
8723        ///
8724        /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
8725        pub shipment_index: i32,
8726
8727        /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
8728        /// corresponds to a delivery.
8729        pub is_pickup: bool,
8730
8731        /// Index of `VisitRequest` in either the pickup or delivery field of the
8732        /// `Shipment` (see `is_pickup`).
8733        pub visit_request_index: i32,
8734
8735        /// Time at which the visit starts. Note that the vehicle may arrive earlier
8736        /// than this at the visit location. Times are consistent with the
8737        /// `ShipmentModel`.
8738        pub start_time: std::option::Option<wkt::Timestamp>,
8739
8740        /// Total visit load demand as the sum of the shipment and the visit request
8741        /// `load_demands`. The values are negative if the visit is a delivery.
8742        /// Demands are reported for the same types as the
8743        /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
8744        /// (see this field).
8745        ///
8746        /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
8747        pub load_demands:
8748            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
8749
8750        /// Extra detour time due to the shipments visited on the route before the
8751        /// visit and to the potential waiting time induced by time windows.
8752        /// If the visit is a delivery, the detour is computed from the corresponding
8753        /// pickup visit and is equal to:
8754        ///
8755        /// ```norust
8756        /// start_time(delivery) - start_time(pickup)
8757        /// - (duration(pickup) + travel duration from the pickup location
8758        /// to the delivery location).
8759        /// ```
8760        ///
8761        /// Otherwise, it is computed from the vehicle `start_location` and is equal
8762        /// to:
8763        ///
8764        /// ```norust
8765        /// start_time - vehicle_start_time - travel duration from
8766        /// the vehicle's `start_location` to the visit.
8767        /// ```
8768        pub detour: std::option::Option<wkt::Duration>,
8769
8770        /// Copy of the corresponding `Shipment.label`, if specified in the
8771        /// `Shipment`.
8772        pub shipment_label: std::string::String,
8773
8774        /// Copy of the corresponding
8775        /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
8776        /// if specified in the `VisitRequest`.
8777        ///
8778        /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
8779        pub visit_label: std::string::String,
8780
8781        /// Deprecated: Use
8782        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8783        /// instead. Vehicle loads upon arrival at the visit location, for each type
8784        /// specified in
8785        /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8786        /// `start_load_intervals`, `end_load_intervals` or `demands`.
8787        ///
8788        /// Exception: we omit loads for quantity types unconstrained by intervals
8789        /// and that don't have any non-zero demand on the route.
8790        ///
8791        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8792        /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8793        #[deprecated]
8794        pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8795
8796        /// Deprecated: Use
8797        /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8798        /// instead. Delay occurring before the visit starts.
8799        ///
8800        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8801        #[deprecated]
8802        pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
8803
8804        /// Deprecated: Use
8805        /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
8806        /// instead.
8807        ///
8808        /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
8809        #[deprecated]
8810        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
8811
8812        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8813    }
8814
8815    impl Visit {
8816        pub fn new() -> Self {
8817            std::default::Default::default()
8818        }
8819
8820        /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
8821        ///
8822        /// # Example
8823        /// ```ignore,no_run
8824        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8825        /// let x = Visit::new().set_shipment_index(42);
8826        /// ```
8827        pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8828            self.shipment_index = v.into();
8829            self
8830        }
8831
8832        /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
8833        ///
8834        /// # Example
8835        /// ```ignore,no_run
8836        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8837        /// let x = Visit::new().set_is_pickup(true);
8838        /// ```
8839        pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8840            self.is_pickup = v.into();
8841            self
8842        }
8843
8844        /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
8845        ///
8846        /// # Example
8847        /// ```ignore,no_run
8848        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8849        /// let x = Visit::new().set_visit_request_index(42);
8850        /// ```
8851        pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8852            self.visit_request_index = v.into();
8853            self
8854        }
8855
8856        /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
8857        ///
8858        /// # Example
8859        /// ```ignore,no_run
8860        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8861        /// use wkt::Timestamp;
8862        /// let x = Visit::new().set_start_time(Timestamp::default()/* use setters */);
8863        /// ```
8864        pub fn set_start_time<T>(mut self, v: T) -> Self
8865        where
8866            T: std::convert::Into<wkt::Timestamp>,
8867        {
8868            self.start_time = std::option::Option::Some(v.into());
8869            self
8870        }
8871
8872        /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
8873        ///
8874        /// # Example
8875        /// ```ignore,no_run
8876        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8877        /// use wkt::Timestamp;
8878        /// let x = Visit::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8879        /// let x = Visit::new().set_or_clear_start_time(None::<Timestamp>);
8880        /// ```
8881        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8882        where
8883            T: std::convert::Into<wkt::Timestamp>,
8884        {
8885            self.start_time = v.map(|x| x.into());
8886            self
8887        }
8888
8889        /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
8890        ///
8891        /// # Example
8892        /// ```ignore,no_run
8893        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8894        /// use google_cloud_optimization_v1::model::shipment::Load;
8895        /// let x = Visit::new().set_load_demands([
8896        ///     ("key0", Load::default()/* use setters */),
8897        ///     ("key1", Load::default()/* use (different) setters */),
8898        /// ]);
8899        /// ```
8900        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
8901        where
8902            T: std::iter::IntoIterator<Item = (K, V)>,
8903            K: std::convert::Into<std::string::String>,
8904            V: std::convert::Into<crate::model::shipment::Load>,
8905        {
8906            use std::iter::Iterator;
8907            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8908            self
8909        }
8910
8911        /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
8912        ///
8913        /// # Example
8914        /// ```ignore,no_run
8915        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8916        /// use wkt::Duration;
8917        /// let x = Visit::new().set_detour(Duration::default()/* use setters */);
8918        /// ```
8919        pub fn set_detour<T>(mut self, v: T) -> Self
8920        where
8921            T: std::convert::Into<wkt::Duration>,
8922        {
8923            self.detour = std::option::Option::Some(v.into());
8924            self
8925        }
8926
8927        /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
8928        ///
8929        /// # Example
8930        /// ```ignore,no_run
8931        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8932        /// use wkt::Duration;
8933        /// let x = Visit::new().set_or_clear_detour(Some(Duration::default()/* use setters */));
8934        /// let x = Visit::new().set_or_clear_detour(None::<Duration>);
8935        /// ```
8936        pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
8937        where
8938            T: std::convert::Into<wkt::Duration>,
8939        {
8940            self.detour = v.map(|x| x.into());
8941            self
8942        }
8943
8944        /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
8945        ///
8946        /// # Example
8947        /// ```ignore,no_run
8948        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8949        /// let x = Visit::new().set_shipment_label("example");
8950        /// ```
8951        pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
8952            mut self,
8953            v: T,
8954        ) -> Self {
8955            self.shipment_label = v.into();
8956            self
8957        }
8958
8959        /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
8960        ///
8961        /// # Example
8962        /// ```ignore,no_run
8963        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8964        /// let x = Visit::new().set_visit_label("example");
8965        /// ```
8966        pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8967            self.visit_label = v.into();
8968            self
8969        }
8970
8971        /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
8972        ///
8973        /// # Example
8974        /// ```ignore,no_run
8975        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8976        /// use google_cloud_optimization_v1::model::CapacityQuantity;
8977        /// let x = Visit::new()
8978        ///     .set_arrival_loads([
8979        ///         CapacityQuantity::default()/* use setters */,
8980        ///         CapacityQuantity::default()/* use (different) setters */,
8981        ///     ]);
8982        /// ```
8983        #[deprecated]
8984        pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
8985        where
8986            T: std::iter::IntoIterator<Item = V>,
8987            V: std::convert::Into<crate::model::CapacityQuantity>,
8988        {
8989            use std::iter::Iterator;
8990            self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
8991            self
8992        }
8993
8994        /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
8995        ///
8996        /// # Example
8997        /// ```ignore,no_run
8998        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8999        /// use google_cloud_optimization_v1::model::shipment_route::Delay;
9000        /// let x = Visit::new().set_delay_before_start(Delay::default()/* use setters */);
9001        /// ```
9002        #[deprecated]
9003        pub fn set_delay_before_start<T>(mut self, v: T) -> Self
9004        where
9005            T: std::convert::Into<crate::model::shipment_route::Delay>,
9006        {
9007            self.delay_before_start = std::option::Option::Some(v.into());
9008            self
9009        }
9010
9011        /// Sets or clears the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
9012        ///
9013        /// # Example
9014        /// ```ignore,no_run
9015        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9016        /// use google_cloud_optimization_v1::model::shipment_route::Delay;
9017        /// let x = Visit::new().set_or_clear_delay_before_start(Some(Delay::default()/* use setters */));
9018        /// let x = Visit::new().set_or_clear_delay_before_start(None::<Delay>);
9019        /// ```
9020        #[deprecated]
9021        pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
9022        where
9023            T: std::convert::Into<crate::model::shipment_route::Delay>,
9024        {
9025            self.delay_before_start = v.map(|x| x.into());
9026            self
9027        }
9028
9029        /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
9030        ///
9031        /// # Example
9032        /// ```ignore,no_run
9033        /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9034        /// use google_cloud_optimization_v1::model::CapacityQuantity;
9035        /// let x = Visit::new()
9036        ///     .set_demands([
9037        ///         CapacityQuantity::default()/* use setters */,
9038        ///         CapacityQuantity::default()/* use (different) setters */,
9039        ///     ]);
9040        /// ```
9041        #[deprecated]
9042        pub fn set_demands<T, V>(mut self, v: T) -> Self
9043        where
9044            T: std::iter::IntoIterator<Item = V>,
9045            V: std::convert::Into<crate::model::CapacityQuantity>,
9046        {
9047            use std::iter::Iterator;
9048            self.demands = v.into_iter().map(|i| i.into()).collect();
9049            self
9050        }
9051    }
9052
9053    impl wkt::message::Message for Visit {
9054        fn typename() -> &'static str {
9055            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
9056        }
9057    }
9058
9059    /// Transition between two events on the route. See the description of
9060    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
9061    ///
9062    /// If the vehicle does not have a `start_location` and/or `end_location`, the
9063    /// corresponding travel metrics are 0.
9064    ///
9065    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
9066    #[derive(Clone, Default, PartialEq)]
9067    #[non_exhaustive]
9068    pub struct Transition {
9069        /// Travel duration during this transition.
9070        pub travel_duration: std::option::Option<wkt::Duration>,
9071
9072        /// Distance traveled during the transition.
9073        pub travel_distance_meters: f64,
9074
9075        /// When traffic is requested via
9076        /// [OptimizeToursRequest.consider_road_traffic]
9077        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9078        /// and the traffic info couldn't be retrieved for a `Transition`, this
9079        /// boolean is set to true. This may be temporary (rare hiccup in the
9080        /// realtime traffic servers) or permanent (no data for this location).
9081        pub traffic_info_unavailable: bool,
9082
9083        /// Sum of the delay durations applied to this transition. If any, the delay
9084        /// starts exactly `delay_duration` seconds before the next event (visit or
9085        /// vehicle end). See
9086        /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
9087        ///
9088        /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
9089        pub delay_duration: std::option::Option<wkt::Duration>,
9090
9091        /// Sum of the duration of the breaks occurring during this transition, if
9092        /// any. Details about each break's start time and duration are stored in
9093        /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
9094        ///
9095        /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
9096        pub break_duration: std::option::Option<wkt::Duration>,
9097
9098        /// Time spent waiting during this transition. Wait duration corresponds to
9099        /// idle time and does not include break time. Also note that this wait time
9100        /// may be split into several non-contiguous intervals.
9101        pub wait_duration: std::option::Option<wkt::Duration>,
9102
9103        /// Total duration of the transition, provided for convenience. It is equal
9104        /// to:
9105        ///
9106        /// * next visit `start_time` (or `vehicle_end_time` if this is the last
9107        ///   transition) - this transition's `start_time`;
9108        /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
9109        ///   additionally holds: `total_duration = travel_duration + delay_duration
9110        ///
9111        /// + break_duration + wait_duration`.
9112        pub total_duration: std::option::Option<wkt::Duration>,
9113
9114        /// Start time of this transition.
9115        pub start_time: std::option::Option<wkt::Timestamp>,
9116
9117        /// The encoded polyline representation of the route followed during the
9118        /// transition.
9119        /// This field is only populated if [populate_transition_polylines]
9120        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
9121        /// is set to true.
9122        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9123
9124        /// Vehicle loads during this transition, for each type that either appears
9125        /// in this vehicle's
9126        /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
9127        /// or that have non-zero
9128        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
9129        /// on some shipment performed on this route.
9130        ///
9131        /// The loads during the first transition are the starting loads of the
9132        /// vehicle route. Then, after each visit, the visit's `load_demands` are
9133        /// either added or subtracted to get the next transition's loads, depending
9134        /// on whether the visit was a pickup or a delivery.
9135        ///
9136        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
9137        /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
9138        pub vehicle_loads: std::collections::HashMap<
9139            std::string::String,
9140            crate::model::shipment_route::VehicleLoad,
9141        >,
9142
9143        /// Deprecated: Use
9144        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
9145        /// instead.
9146        ///
9147        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9148        #[deprecated]
9149        pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
9150
9151        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9152    }
9153
9154    impl Transition {
9155        pub fn new() -> Self {
9156            std::default::Default::default()
9157        }
9158
9159        /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9160        ///
9161        /// # Example
9162        /// ```ignore,no_run
9163        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9164        /// use wkt::Duration;
9165        /// let x = Transition::new().set_travel_duration(Duration::default()/* use setters */);
9166        /// ```
9167        pub fn set_travel_duration<T>(mut self, v: T) -> Self
9168        where
9169            T: std::convert::Into<wkt::Duration>,
9170        {
9171            self.travel_duration = std::option::Option::Some(v.into());
9172            self
9173        }
9174
9175        /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9176        ///
9177        /// # Example
9178        /// ```ignore,no_run
9179        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9180        /// use wkt::Duration;
9181        /// let x = Transition::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
9182        /// let x = Transition::new().set_or_clear_travel_duration(None::<Duration>);
9183        /// ```
9184        pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
9185        where
9186            T: std::convert::Into<wkt::Duration>,
9187        {
9188            self.travel_duration = v.map(|x| x.into());
9189            self
9190        }
9191
9192        /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
9193        ///
9194        /// # Example
9195        /// ```ignore,no_run
9196        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9197        /// let x = Transition::new().set_travel_distance_meters(42.0);
9198        /// ```
9199        pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9200            self.travel_distance_meters = v.into();
9201            self
9202        }
9203
9204        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
9205        ///
9206        /// # Example
9207        /// ```ignore,no_run
9208        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9209        /// let x = Transition::new().set_traffic_info_unavailable(true);
9210        /// ```
9211        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9212            self.traffic_info_unavailable = v.into();
9213            self
9214        }
9215
9216        /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9217        ///
9218        /// # Example
9219        /// ```ignore,no_run
9220        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9221        /// use wkt::Duration;
9222        /// let x = Transition::new().set_delay_duration(Duration::default()/* use setters */);
9223        /// ```
9224        pub fn set_delay_duration<T>(mut self, v: T) -> Self
9225        where
9226            T: std::convert::Into<wkt::Duration>,
9227        {
9228            self.delay_duration = std::option::Option::Some(v.into());
9229            self
9230        }
9231
9232        /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9233        ///
9234        /// # Example
9235        /// ```ignore,no_run
9236        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9237        /// use wkt::Duration;
9238        /// let x = Transition::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
9239        /// let x = Transition::new().set_or_clear_delay_duration(None::<Duration>);
9240        /// ```
9241        pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
9242        where
9243            T: std::convert::Into<wkt::Duration>,
9244        {
9245            self.delay_duration = v.map(|x| x.into());
9246            self
9247        }
9248
9249        /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9250        ///
9251        /// # Example
9252        /// ```ignore,no_run
9253        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9254        /// use wkt::Duration;
9255        /// let x = Transition::new().set_break_duration(Duration::default()/* use setters */);
9256        /// ```
9257        pub fn set_break_duration<T>(mut self, v: T) -> Self
9258        where
9259            T: std::convert::Into<wkt::Duration>,
9260        {
9261            self.break_duration = std::option::Option::Some(v.into());
9262            self
9263        }
9264
9265        /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9266        ///
9267        /// # Example
9268        /// ```ignore,no_run
9269        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9270        /// use wkt::Duration;
9271        /// let x = Transition::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
9272        /// let x = Transition::new().set_or_clear_break_duration(None::<Duration>);
9273        /// ```
9274        pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
9275        where
9276            T: std::convert::Into<wkt::Duration>,
9277        {
9278            self.break_duration = v.map(|x| x.into());
9279            self
9280        }
9281
9282        /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9283        ///
9284        /// # Example
9285        /// ```ignore,no_run
9286        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9287        /// use wkt::Duration;
9288        /// let x = Transition::new().set_wait_duration(Duration::default()/* use setters */);
9289        /// ```
9290        pub fn set_wait_duration<T>(mut self, v: T) -> Self
9291        where
9292            T: std::convert::Into<wkt::Duration>,
9293        {
9294            self.wait_duration = std::option::Option::Some(v.into());
9295            self
9296        }
9297
9298        /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9299        ///
9300        /// # Example
9301        /// ```ignore,no_run
9302        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9303        /// use wkt::Duration;
9304        /// let x = Transition::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
9305        /// let x = Transition::new().set_or_clear_wait_duration(None::<Duration>);
9306        /// ```
9307        pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
9308        where
9309            T: std::convert::Into<wkt::Duration>,
9310        {
9311            self.wait_duration = v.map(|x| x.into());
9312            self
9313        }
9314
9315        /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9316        ///
9317        /// # Example
9318        /// ```ignore,no_run
9319        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9320        /// use wkt::Duration;
9321        /// let x = Transition::new().set_total_duration(Duration::default()/* use setters */);
9322        /// ```
9323        pub fn set_total_duration<T>(mut self, v: T) -> Self
9324        where
9325            T: std::convert::Into<wkt::Duration>,
9326        {
9327            self.total_duration = std::option::Option::Some(v.into());
9328            self
9329        }
9330
9331        /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9332        ///
9333        /// # Example
9334        /// ```ignore,no_run
9335        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9336        /// use wkt::Duration;
9337        /// let x = Transition::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
9338        /// let x = Transition::new().set_or_clear_total_duration(None::<Duration>);
9339        /// ```
9340        pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
9341        where
9342            T: std::convert::Into<wkt::Duration>,
9343        {
9344            self.total_duration = v.map(|x| x.into());
9345            self
9346        }
9347
9348        /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
9349        ///
9350        /// # Example
9351        /// ```ignore,no_run
9352        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9353        /// use wkt::Timestamp;
9354        /// let x = Transition::new().set_start_time(Timestamp::default()/* use setters */);
9355        /// ```
9356        pub fn set_start_time<T>(mut self, v: T) -> Self
9357        where
9358            T: std::convert::Into<wkt::Timestamp>,
9359        {
9360            self.start_time = std::option::Option::Some(v.into());
9361            self
9362        }
9363
9364        /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
9365        ///
9366        /// # Example
9367        /// ```ignore,no_run
9368        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9369        /// use wkt::Timestamp;
9370        /// let x = Transition::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9371        /// let x = Transition::new().set_or_clear_start_time(None::<Timestamp>);
9372        /// ```
9373        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9374        where
9375            T: std::convert::Into<wkt::Timestamp>,
9376        {
9377            self.start_time = v.map(|x| x.into());
9378            self
9379        }
9380
9381        /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9382        ///
9383        /// # Example
9384        /// ```ignore,no_run
9385        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9386        /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9387        /// let x = Transition::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9388        /// ```
9389        pub fn set_route_polyline<T>(mut self, v: T) -> Self
9390        where
9391            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9392        {
9393            self.route_polyline = std::option::Option::Some(v.into());
9394            self
9395        }
9396
9397        /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9398        ///
9399        /// # Example
9400        /// ```ignore,no_run
9401        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9402        /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9403        /// let x = Transition::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9404        /// let x = Transition::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9405        /// ```
9406        pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9407        where
9408            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9409        {
9410            self.route_polyline = v.map(|x| x.into());
9411            self
9412        }
9413
9414        /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
9415        ///
9416        /// # Example
9417        /// ```ignore,no_run
9418        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9419        /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9420        /// let x = Transition::new().set_vehicle_loads([
9421        ///     ("key0", VehicleLoad::default()/* use setters */),
9422        ///     ("key1", VehicleLoad::default()/* use (different) setters */),
9423        /// ]);
9424        /// ```
9425        pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
9426        where
9427            T: std::iter::IntoIterator<Item = (K, V)>,
9428            K: std::convert::Into<std::string::String>,
9429            V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
9430        {
9431            use std::iter::Iterator;
9432            self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
9433            self
9434        }
9435
9436        /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
9437        ///
9438        /// # Example
9439        /// ```ignore,no_run
9440        /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9441        /// use google_cloud_optimization_v1::model::CapacityQuantity;
9442        /// let x = Transition::new()
9443        ///     .set_loads([
9444        ///         CapacityQuantity::default()/* use setters */,
9445        ///         CapacityQuantity::default()/* use (different) setters */,
9446        ///     ]);
9447        /// ```
9448        #[deprecated]
9449        pub fn set_loads<T, V>(mut self, v: T) -> Self
9450        where
9451            T: std::iter::IntoIterator<Item = V>,
9452            V: std::convert::Into<crate::model::CapacityQuantity>,
9453        {
9454            use std::iter::Iterator;
9455            self.loads = v.into_iter().map(|i| i.into()).collect();
9456            self
9457        }
9458    }
9459
9460    impl wkt::message::Message for Transition {
9461        fn typename() -> &'static str {
9462            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
9463        }
9464    }
9465
9466    /// Reports the actual load of the vehicle at some point along the route,
9467    /// for a given type (see
9468    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
9469    ///
9470    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9471    #[derive(Clone, Default, PartialEq)]
9472    #[non_exhaustive]
9473    pub struct VehicleLoad {
9474        /// The amount of load on the vehicle, for the given type. The unit of load
9475        /// is usually indicated by the type. See
9476        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
9477        ///
9478        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9479        pub amount: i64,
9480
9481        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9482    }
9483
9484    impl VehicleLoad {
9485        pub fn new() -> Self {
9486            std::default::Default::default()
9487        }
9488
9489        /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
9490        ///
9491        /// # Example
9492        /// ```ignore,no_run
9493        /// # use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9494        /// let x = VehicleLoad::new().set_amount(42);
9495        /// ```
9496        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9497            self.amount = v.into();
9498            self
9499        }
9500    }
9501
9502    impl wkt::message::Message for VehicleLoad {
9503        fn typename() -> &'static str {
9504            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
9505        }
9506    }
9507
9508    /// The encoded representation of a polyline. More information on polyline
9509    /// encoding can be found here:
9510    /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
9511    /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
9512    #[derive(Clone, Default, PartialEq)]
9513    #[non_exhaustive]
9514    pub struct EncodedPolyline {
9515        /// String representing encoded points of the polyline.
9516        pub points: std::string::String,
9517
9518        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9519    }
9520
9521    impl EncodedPolyline {
9522        pub fn new() -> Self {
9523            std::default::Default::default()
9524        }
9525
9526        /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
9527        ///
9528        /// # Example
9529        /// ```ignore,no_run
9530        /// # use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9531        /// let x = EncodedPolyline::new().set_points("example");
9532        /// ```
9533        pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9534            self.points = v.into();
9535            self
9536        }
9537    }
9538
9539    impl wkt::message::Message for EncodedPolyline {
9540        fn typename() -> &'static str {
9541            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
9542        }
9543    }
9544
9545    /// Data representing the execution of a break.
9546    #[derive(Clone, Default, PartialEq)]
9547    #[non_exhaustive]
9548    pub struct Break {
9549        /// Start time of a break.
9550        pub start_time: std::option::Option<wkt::Timestamp>,
9551
9552        /// Duration of a break.
9553        pub duration: std::option::Option<wkt::Duration>,
9554
9555        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9556    }
9557
9558    impl Break {
9559        pub fn new() -> Self {
9560            std::default::Default::default()
9561        }
9562
9563        /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
9564        ///
9565        /// # Example
9566        /// ```ignore,no_run
9567        /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9568        /// use wkt::Timestamp;
9569        /// let x = Break::new().set_start_time(Timestamp::default()/* use setters */);
9570        /// ```
9571        pub fn set_start_time<T>(mut self, v: T) -> Self
9572        where
9573            T: std::convert::Into<wkt::Timestamp>,
9574        {
9575            self.start_time = std::option::Option::Some(v.into());
9576            self
9577        }
9578
9579        /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
9580        ///
9581        /// # Example
9582        /// ```ignore,no_run
9583        /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9584        /// use wkt::Timestamp;
9585        /// let x = Break::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9586        /// let x = Break::new().set_or_clear_start_time(None::<Timestamp>);
9587        /// ```
9588        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9589        where
9590            T: std::convert::Into<wkt::Timestamp>,
9591        {
9592            self.start_time = v.map(|x| x.into());
9593            self
9594        }
9595
9596        /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
9597        ///
9598        /// # Example
9599        /// ```ignore,no_run
9600        /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9601        /// use wkt::Duration;
9602        /// let x = Break::new().set_duration(Duration::default()/* use setters */);
9603        /// ```
9604        pub fn set_duration<T>(mut self, v: T) -> Self
9605        where
9606            T: std::convert::Into<wkt::Duration>,
9607        {
9608            self.duration = std::option::Option::Some(v.into());
9609            self
9610        }
9611
9612        /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
9613        ///
9614        /// # Example
9615        /// ```ignore,no_run
9616        /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9617        /// use wkt::Duration;
9618        /// let x = Break::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9619        /// let x = Break::new().set_or_clear_duration(None::<Duration>);
9620        /// ```
9621        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9622        where
9623            T: std::convert::Into<wkt::Duration>,
9624        {
9625            self.duration = v.map(|x| x.into());
9626            self
9627        }
9628    }
9629
9630    impl wkt::message::Message for Break {
9631        fn typename() -> &'static str {
9632            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
9633        }
9634    }
9635
9636    /// Deprecated: Use
9637    /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
9638    /// instead. Travel between each visit along the route: from the vehicle's
9639    /// `start_location` to the first visit's `arrival_location`, then from the
9640    /// first visit's `departure_location` to the second visit's
9641    /// `arrival_location`, and so on until the vehicle's `end_location`. This
9642    /// accounts only for the actual travel between visits, not counting the
9643    /// waiting time, the time spent performing a visit, nor the distance covered
9644    /// during a visit.
9645    ///
9646    /// Invariant: `travel_steps_size() == visits_size() + 1`.
9647    ///
9648    /// If the vehicle does not have a start_ and/or end_location, the
9649    /// corresponding travel metrics are 0 and/or empty.
9650    ///
9651    /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
9652    #[derive(Clone, Default, PartialEq)]
9653    #[non_exhaustive]
9654    #[deprecated]
9655    pub struct TravelStep {
9656        /// Duration of the travel step.
9657        pub duration: std::option::Option<wkt::Duration>,
9658
9659        /// Distance traveled during the step.
9660        pub distance_meters: f64,
9661
9662        /// When traffic is requested via
9663        /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9664        /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
9665        /// is set to true. This may be temporary (rare hiccup in the realtime
9666        /// traffic servers) or permanent (no data for this location).
9667        ///
9668        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
9669        pub traffic_info_unavailable: bool,
9670
9671        /// The encoded polyline representation of the route followed during the
9672        /// step.
9673        ///
9674        /// This field is only populated if
9675        /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
9676        /// is set to true.
9677        ///
9678        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
9679        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9680
9681        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9682    }
9683
9684    impl TravelStep {
9685        pub fn new() -> Self {
9686            std::default::Default::default()
9687        }
9688
9689        /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
9690        ///
9691        /// # Example
9692        /// ```ignore,no_run
9693        /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9694        /// use wkt::Duration;
9695        /// let x = TravelStep::new().set_duration(Duration::default()/* use setters */);
9696        /// ```
9697        pub fn set_duration<T>(mut self, v: T) -> Self
9698        where
9699            T: std::convert::Into<wkt::Duration>,
9700        {
9701            self.duration = std::option::Option::Some(v.into());
9702            self
9703        }
9704
9705        /// Sets or clears the value of [duration][crate::model::shipment_route::TravelStep::duration].
9706        ///
9707        /// # Example
9708        /// ```ignore,no_run
9709        /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9710        /// use wkt::Duration;
9711        /// let x = TravelStep::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9712        /// let x = TravelStep::new().set_or_clear_duration(None::<Duration>);
9713        /// ```
9714        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9715        where
9716            T: std::convert::Into<wkt::Duration>,
9717        {
9718            self.duration = v.map(|x| x.into());
9719            self
9720        }
9721
9722        /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
9723        ///
9724        /// # Example
9725        /// ```ignore,no_run
9726        /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9727        /// let x = TravelStep::new().set_distance_meters(42.0);
9728        /// ```
9729        pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9730            self.distance_meters = v.into();
9731            self
9732        }
9733
9734        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
9735        ///
9736        /// # Example
9737        /// ```ignore,no_run
9738        /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9739        /// let x = TravelStep::new().set_traffic_info_unavailable(true);
9740        /// ```
9741        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9742            self.traffic_info_unavailable = v.into();
9743            self
9744        }
9745
9746        /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9747        ///
9748        /// # Example
9749        /// ```ignore,no_run
9750        /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9751        /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9752        /// let x = TravelStep::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9753        /// ```
9754        pub fn set_route_polyline<T>(mut self, v: T) -> Self
9755        where
9756            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9757        {
9758            self.route_polyline = std::option::Option::Some(v.into());
9759            self
9760        }
9761
9762        /// Sets or clears the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9763        ///
9764        /// # Example
9765        /// ```ignore,no_run
9766        /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9767        /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9768        /// let x = TravelStep::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9769        /// let x = TravelStep::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9770        /// ```
9771        pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9772        where
9773            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9774        {
9775            self.route_polyline = v.map(|x| x.into());
9776            self
9777        }
9778    }
9779
9780    impl wkt::message::Message for TravelStep {
9781        fn typename() -> &'static str {
9782            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
9783        }
9784    }
9785}
9786
9787/// Specifies details of unperformed shipments in a solution. For trivial cases
9788/// and/or if we are able to identify the cause for skipping, we report the
9789/// reason here.
9790#[derive(Clone, Default, PartialEq)]
9791#[non_exhaustive]
9792pub struct SkippedShipment {
9793    /// The index corresponds to the index of the shipment in the source
9794    /// `ShipmentModel`.
9795    pub index: i32,
9796
9797    /// Copy of the corresponding
9798    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
9799    /// in the `Shipment`.
9800    ///
9801    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
9802    pub label: std::string::String,
9803
9804    /// A list of reasons that explain why the shipment was skipped. See comment
9805    /// above `Reason`.
9806    pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
9807
9808    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9809}
9810
9811impl SkippedShipment {
9812    pub fn new() -> Self {
9813        std::default::Default::default()
9814    }
9815
9816    /// Sets the value of [index][crate::model::SkippedShipment::index].
9817    ///
9818    /// # Example
9819    /// ```ignore,no_run
9820    /// # use google_cloud_optimization_v1::model::SkippedShipment;
9821    /// let x = SkippedShipment::new().set_index(42);
9822    /// ```
9823    pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9824        self.index = v.into();
9825        self
9826    }
9827
9828    /// Sets the value of [label][crate::model::SkippedShipment::label].
9829    ///
9830    /// # Example
9831    /// ```ignore,no_run
9832    /// # use google_cloud_optimization_v1::model::SkippedShipment;
9833    /// let x = SkippedShipment::new().set_label("example");
9834    /// ```
9835    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9836        self.label = v.into();
9837        self
9838    }
9839
9840    /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
9841    ///
9842    /// # Example
9843    /// ```ignore,no_run
9844    /// # use google_cloud_optimization_v1::model::SkippedShipment;
9845    /// use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9846    /// let x = SkippedShipment::new()
9847    ///     .set_reasons([
9848    ///         Reason::default()/* use setters */,
9849    ///         Reason::default()/* use (different) setters */,
9850    ///     ]);
9851    /// ```
9852    pub fn set_reasons<T, V>(mut self, v: T) -> Self
9853    where
9854        T: std::iter::IntoIterator<Item = V>,
9855        V: std::convert::Into<crate::model::skipped_shipment::Reason>,
9856    {
9857        use std::iter::Iterator;
9858        self.reasons = v.into_iter().map(|i| i.into()).collect();
9859        self
9860    }
9861}
9862
9863impl wkt::message::Message for SkippedShipment {
9864    fn typename() -> &'static str {
9865        "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
9866    }
9867}
9868
9869/// Defines additional types related to [SkippedShipment].
9870pub mod skipped_shipment {
9871    #[allow(unused_imports)]
9872    use super::*;
9873
9874    /// If we can explain why the shipment was skipped, reasons will be listed
9875    /// here. If the reason is not the same for all vehicles, `reason` will have
9876    /// more than 1 element. A skipped shipment cannot have duplicate reasons,
9877    /// i.e. where all fields are the same except for `example_vehicle_index`.
9878    /// Example:
9879    ///
9880    /// ```norust
9881    /// reasons {
9882    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9883    ///   example_vehicle_index: 1
9884    ///   example_exceeded_capacity_type: "Apples"
9885    /// }
9886    /// reasons {
9887    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9888    ///   example_vehicle_index: 3
9889    ///   example_exceeded_capacity_type: "Pears"
9890    /// }
9891    /// reasons {
9892    ///   code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
9893    ///   example_vehicle_index: 1
9894    /// }
9895    /// ```
9896    ///
9897    /// The skipped shipment is incompatible with all vehicles. The reasons may
9898    /// be different for all vehicles but at least one vehicle's "Apples"
9899    /// capacity would be exceeded (including vehicle 1), at least one vehicle's
9900    /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
9901    /// vehicle's distance limit would be exceeded (including vehicle 1).
9902    #[derive(Clone, Default, PartialEq)]
9903    #[non_exhaustive]
9904    pub struct Reason {
9905        /// Refer to the comments of Code.
9906        pub code: crate::model::skipped_shipment::reason::Code,
9907
9908        /// If the reason is related to a shipment-vehicle incompatibility, this
9909        /// field provides the index of one relevant vehicle.
9910        pub example_vehicle_index: std::option::Option<i32>,
9911
9912        /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
9913        /// capacity type that is exceeded.
9914        pub example_exceeded_capacity_type: std::string::String,
9915
9916        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9917    }
9918
9919    impl Reason {
9920        pub fn new() -> Self {
9921            std::default::Default::default()
9922        }
9923
9924        /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
9925        ///
9926        /// # Example
9927        /// ```ignore,no_run
9928        /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9929        /// use google_cloud_optimization_v1::model::skipped_shipment::reason::Code;
9930        /// let x0 = Reason::new().set_code(Code::NoVehicle);
9931        /// let x1 = Reason::new().set_code(Code::DemandExceedsVehicleCapacity);
9932        /// let x2 = Reason::new().set_code(Code::CannotBePerformedWithinVehicleDistanceLimit);
9933        /// ```
9934        pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
9935            mut self,
9936            v: T,
9937        ) -> Self {
9938            self.code = v.into();
9939            self
9940        }
9941
9942        /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9943        ///
9944        /// # Example
9945        /// ```ignore,no_run
9946        /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9947        /// let x = Reason::new().set_example_vehicle_index(42);
9948        /// ```
9949        pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
9950        where
9951            T: std::convert::Into<i32>,
9952        {
9953            self.example_vehicle_index = std::option::Option::Some(v.into());
9954            self
9955        }
9956
9957        /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9958        ///
9959        /// # Example
9960        /// ```ignore,no_run
9961        /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9962        /// let x = Reason::new().set_or_clear_example_vehicle_index(Some(42));
9963        /// let x = Reason::new().set_or_clear_example_vehicle_index(None::<i32>);
9964        /// ```
9965        pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
9966        where
9967            T: std::convert::Into<i32>,
9968        {
9969            self.example_vehicle_index = v.map(|x| x.into());
9970            self
9971        }
9972
9973        /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
9974        ///
9975        /// # Example
9976        /// ```ignore,no_run
9977        /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9978        /// let x = Reason::new().set_example_exceeded_capacity_type("example");
9979        /// ```
9980        pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
9981            mut self,
9982            v: T,
9983        ) -> Self {
9984            self.example_exceeded_capacity_type = v.into();
9985            self
9986        }
9987    }
9988
9989    impl wkt::message::Message for Reason {
9990        fn typename() -> &'static str {
9991            "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
9992        }
9993    }
9994
9995    /// Defines additional types related to [Reason].
9996    pub mod reason {
9997        #[allow(unused_imports)]
9998        use super::*;
9999
10000        /// Code identifying the reason type. The order here is meaningless. In
10001        /// particular, it gives no indication of whether a given reason will
10002        /// appear before another in the solution, if both apply.
10003        ///
10004        /// # Working with unknown values
10005        ///
10006        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10007        /// additional enum variants at any time. Adding new variants is not considered
10008        /// a breaking change. Applications should write their code in anticipation of:
10009        ///
10010        /// - New values appearing in future releases of the client library, **and**
10011        /// - New values received dynamically, without application changes.
10012        ///
10013        /// Please consult the [Working with enums] section in the user guide for some
10014        /// guidelines.
10015        ///
10016        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
10017        #[derive(Clone, Debug, PartialEq)]
10018        #[non_exhaustive]
10019        pub enum Code {
10020            /// This should never be used. If we are unable to understand why a
10021            /// shipment was skipped, we simply return an empty set of reasons.
10022            Unspecified,
10023            /// There is no vehicle in the model making all shipments infeasible.
10024            NoVehicle,
10025            /// The demand of the shipment exceeds a vehicle's capacity for some
10026            /// capacity types, one of which is `example_exceeded_capacity_type`.
10027            DemandExceedsVehicleCapacity,
10028            /// The minimum distance necessary to perform this shipment, i.e. from
10029            /// the vehicle's `start_location` to the shipment's pickup and/or delivery
10030            /// locations and to the vehicle's end location exceeds the vehicle's
10031            /// `route_distance_limit`.
10032            ///
10033            /// Note that for this computation we use the geodesic distances.
10034            CannotBePerformedWithinVehicleDistanceLimit,
10035            /// The minimum time necessary to perform this shipment, including travel
10036            /// time, wait time and service time exceeds the vehicle's
10037            /// `route_duration_limit`.
10038            ///
10039            /// Note: travel time is computed in the best-case scenario, namely as
10040            /// geodesic distance x 36 m/s (roughly 130 km/hour).
10041            CannotBePerformedWithinVehicleDurationLimit,
10042            /// Same as above but we only compare minimum travel time and the
10043            /// vehicle's `travel_duration_limit`.
10044            CannotBePerformedWithinVehicleTravelDurationLimit,
10045            /// The vehicle cannot perform this shipment in the best-case scenario
10046            /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
10047            /// computation) if it starts at its earliest start time: the total time
10048            /// would make the vehicle end after its latest end time.
10049            CannotBePerformedWithinVehicleTimeWindows,
10050            /// The `allowed_vehicle_indices` field of the shipment is not empty and
10051            /// this vehicle does not belong to it.
10052            VehicleNotAllowed,
10053            /// If set, the enum was initialized with an unknown value.
10054            ///
10055            /// Applications can examine the value using [Code::value] or
10056            /// [Code::name].
10057            UnknownValue(code::UnknownValue),
10058        }
10059
10060        #[doc(hidden)]
10061        pub mod code {
10062            #[allow(unused_imports)]
10063            use super::*;
10064            #[derive(Clone, Debug, PartialEq)]
10065            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10066        }
10067
10068        impl Code {
10069            /// Gets the enum value.
10070            ///
10071            /// Returns `None` if the enum contains an unknown value deserialized from
10072            /// the string representation of enums.
10073            pub fn value(&self) -> std::option::Option<i32> {
10074                match self {
10075                    Self::Unspecified => std::option::Option::Some(0),
10076                    Self::NoVehicle => std::option::Option::Some(1),
10077                    Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
10078                    Self::CannotBePerformedWithinVehicleDistanceLimit => {
10079                        std::option::Option::Some(3)
10080                    }
10081                    Self::CannotBePerformedWithinVehicleDurationLimit => {
10082                        std::option::Option::Some(4)
10083                    }
10084                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10085                        std::option::Option::Some(5)
10086                    }
10087                    Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
10088                    Self::VehicleNotAllowed => std::option::Option::Some(7),
10089                    Self::UnknownValue(u) => u.0.value(),
10090                }
10091            }
10092
10093            /// Gets the enum value as a string.
10094            ///
10095            /// Returns `None` if the enum contains an unknown value deserialized from
10096            /// the integer representation of enums.
10097            pub fn name(&self) -> std::option::Option<&str> {
10098                match self {
10099                    Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
10100                    Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
10101                    Self::DemandExceedsVehicleCapacity => {
10102                        std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
10103                    }
10104                    Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
10105                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
10106                    ),
10107                    Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
10108                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
10109                    ),
10110                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10111                        std::option::Option::Some(
10112                            "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
10113                        )
10114                    }
10115                    Self::CannotBePerformedWithinVehicleTimeWindows => {
10116                        std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
10117                    }
10118                    Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
10119                    Self::UnknownValue(u) => u.0.name(),
10120                }
10121            }
10122        }
10123
10124        impl std::default::Default for Code {
10125            fn default() -> Self {
10126                use std::convert::From;
10127                Self::from(0)
10128            }
10129        }
10130
10131        impl std::fmt::Display for Code {
10132            fn fmt(
10133                &self,
10134                f: &mut std::fmt::Formatter<'_>,
10135            ) -> std::result::Result<(), std::fmt::Error> {
10136                wkt::internal::display_enum(f, self.name(), self.value())
10137            }
10138        }
10139
10140        impl std::convert::From<i32> for Code {
10141            fn from(value: i32) -> Self {
10142                match value {
10143                    0 => Self::Unspecified,
10144                    1 => Self::NoVehicle,
10145                    2 => Self::DemandExceedsVehicleCapacity,
10146                    3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
10147                    4 => Self::CannotBePerformedWithinVehicleDurationLimit,
10148                    5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
10149                    6 => Self::CannotBePerformedWithinVehicleTimeWindows,
10150                    7 => Self::VehicleNotAllowed,
10151                    _ => Self::UnknownValue(code::UnknownValue(
10152                        wkt::internal::UnknownEnumValue::Integer(value),
10153                    )),
10154                }
10155            }
10156        }
10157
10158        impl std::convert::From<&str> for Code {
10159            fn from(value: &str) -> Self {
10160                use std::string::ToString;
10161                match value {
10162                    "CODE_UNSPECIFIED" => Self::Unspecified,
10163                    "NO_VEHICLE" => Self::NoVehicle,
10164                    "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
10165                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
10166                        Self::CannotBePerformedWithinVehicleDistanceLimit
10167                    }
10168                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
10169                        Self::CannotBePerformedWithinVehicleDurationLimit
10170                    }
10171                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
10172                        Self::CannotBePerformedWithinVehicleTravelDurationLimit
10173                    }
10174                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
10175                        Self::CannotBePerformedWithinVehicleTimeWindows
10176                    }
10177                    "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
10178                    _ => Self::UnknownValue(code::UnknownValue(
10179                        wkt::internal::UnknownEnumValue::String(value.to_string()),
10180                    )),
10181                }
10182            }
10183        }
10184
10185        impl serde::ser::Serialize for Code {
10186            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10187            where
10188                S: serde::Serializer,
10189            {
10190                match self {
10191                    Self::Unspecified => serializer.serialize_i32(0),
10192                    Self::NoVehicle => serializer.serialize_i32(1),
10193                    Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
10194                    Self::CannotBePerformedWithinVehicleDistanceLimit => {
10195                        serializer.serialize_i32(3)
10196                    }
10197                    Self::CannotBePerformedWithinVehicleDurationLimit => {
10198                        serializer.serialize_i32(4)
10199                    }
10200                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10201                        serializer.serialize_i32(5)
10202                    }
10203                    Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
10204                    Self::VehicleNotAllowed => serializer.serialize_i32(7),
10205                    Self::UnknownValue(u) => u.0.serialize(serializer),
10206                }
10207            }
10208        }
10209
10210        impl<'de> serde::de::Deserialize<'de> for Code {
10211            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10212            where
10213                D: serde::Deserializer<'de>,
10214            {
10215                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
10216                    ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
10217                ))
10218            }
10219        }
10220    }
10221}
10222
10223/// Aggregated metrics for
10224/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
10225/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
10226/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
10227/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
10228/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
10229///
10230/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
10231/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
10232/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
10233/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
10234#[derive(Clone, Default, PartialEq)]
10235#[non_exhaustive]
10236pub struct AggregatedMetrics {
10237    /// Number of shipments performed. Note that a pickup and delivery pair only
10238    /// counts once.
10239    pub performed_shipment_count: i32,
10240
10241    /// Total travel duration for a route or a solution.
10242    pub travel_duration: std::option::Option<wkt::Duration>,
10243
10244    /// Total wait duration for a route or a solution.
10245    pub wait_duration: std::option::Option<wkt::Duration>,
10246
10247    /// Total delay duration for a route or a solution.
10248    pub delay_duration: std::option::Option<wkt::Duration>,
10249
10250    /// Total break duration for a route or a solution.
10251    pub break_duration: std::option::Option<wkt::Duration>,
10252
10253    /// Total visit duration for a route or a solution.
10254    pub visit_duration: std::option::Option<wkt::Duration>,
10255
10256    /// The total duration should be equal to the sum of all durations above.
10257    /// For routes, it also corresponds to:
10258    /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
10259    /// `-`
10260    /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
10261    ///
10262    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
10263    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
10264    pub total_duration: std::option::Option<wkt::Duration>,
10265
10266    /// Total travel distance for a route or a solution.
10267    pub travel_distance_meters: f64,
10268
10269    /// Maximum load achieved over the entire route (resp. solution), for each of
10270    /// the quantities on this route (resp. solution), computed as the maximum over
10271    /// all
10272    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
10273    /// (resp.
10274    /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
10275    ///
10276    /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
10277    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
10278    pub max_loads:
10279        std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
10280
10281    /// Deprecated: Use
10282    /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
10283    /// and
10284    /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
10285    /// instead.
10286    ///
10287    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
10288    /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
10289    #[deprecated]
10290    pub costs: std::collections::HashMap<std::string::String, f64>,
10291
10292    /// Deprecated: Use
10293    /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
10294    /// and
10295    /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
10296    /// instead.
10297    ///
10298    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
10299    /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
10300    #[deprecated]
10301    pub total_cost: f64,
10302
10303    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10304}
10305
10306impl AggregatedMetrics {
10307    pub fn new() -> Self {
10308        std::default::Default::default()
10309    }
10310
10311    /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
10312    ///
10313    /// # Example
10314    /// ```ignore,no_run
10315    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10316    /// let x = AggregatedMetrics::new().set_performed_shipment_count(42);
10317    /// ```
10318    pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10319        self.performed_shipment_count = v.into();
10320        self
10321    }
10322
10323    /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10324    ///
10325    /// # Example
10326    /// ```ignore,no_run
10327    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10328    /// use wkt::Duration;
10329    /// let x = AggregatedMetrics::new().set_travel_duration(Duration::default()/* use setters */);
10330    /// ```
10331    pub fn set_travel_duration<T>(mut self, v: T) -> Self
10332    where
10333        T: std::convert::Into<wkt::Duration>,
10334    {
10335        self.travel_duration = std::option::Option::Some(v.into());
10336        self
10337    }
10338
10339    /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10340    ///
10341    /// # Example
10342    /// ```ignore,no_run
10343    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10344    /// use wkt::Duration;
10345    /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
10346    /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(None::<Duration>);
10347    /// ```
10348    pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
10349    where
10350        T: std::convert::Into<wkt::Duration>,
10351    {
10352        self.travel_duration = v.map(|x| x.into());
10353        self
10354    }
10355
10356    /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10357    ///
10358    /// # Example
10359    /// ```ignore,no_run
10360    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10361    /// use wkt::Duration;
10362    /// let x = AggregatedMetrics::new().set_wait_duration(Duration::default()/* use setters */);
10363    /// ```
10364    pub fn set_wait_duration<T>(mut self, v: T) -> Self
10365    where
10366        T: std::convert::Into<wkt::Duration>,
10367    {
10368        self.wait_duration = std::option::Option::Some(v.into());
10369        self
10370    }
10371
10372    /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10373    ///
10374    /// # Example
10375    /// ```ignore,no_run
10376    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10377    /// use wkt::Duration;
10378    /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
10379    /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(None::<Duration>);
10380    /// ```
10381    pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
10382    where
10383        T: std::convert::Into<wkt::Duration>,
10384    {
10385        self.wait_duration = v.map(|x| x.into());
10386        self
10387    }
10388
10389    /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10390    ///
10391    /// # Example
10392    /// ```ignore,no_run
10393    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10394    /// use wkt::Duration;
10395    /// let x = AggregatedMetrics::new().set_delay_duration(Duration::default()/* use setters */);
10396    /// ```
10397    pub fn set_delay_duration<T>(mut self, v: T) -> Self
10398    where
10399        T: std::convert::Into<wkt::Duration>,
10400    {
10401        self.delay_duration = std::option::Option::Some(v.into());
10402        self
10403    }
10404
10405    /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10406    ///
10407    /// # Example
10408    /// ```ignore,no_run
10409    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10410    /// use wkt::Duration;
10411    /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
10412    /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(None::<Duration>);
10413    /// ```
10414    pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
10415    where
10416        T: std::convert::Into<wkt::Duration>,
10417    {
10418        self.delay_duration = v.map(|x| x.into());
10419        self
10420    }
10421
10422    /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10423    ///
10424    /// # Example
10425    /// ```ignore,no_run
10426    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10427    /// use wkt::Duration;
10428    /// let x = AggregatedMetrics::new().set_break_duration(Duration::default()/* use setters */);
10429    /// ```
10430    pub fn set_break_duration<T>(mut self, v: T) -> Self
10431    where
10432        T: std::convert::Into<wkt::Duration>,
10433    {
10434        self.break_duration = std::option::Option::Some(v.into());
10435        self
10436    }
10437
10438    /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10439    ///
10440    /// # Example
10441    /// ```ignore,no_run
10442    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10443    /// use wkt::Duration;
10444    /// let x = AggregatedMetrics::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
10445    /// let x = AggregatedMetrics::new().set_or_clear_break_duration(None::<Duration>);
10446    /// ```
10447    pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
10448    where
10449        T: std::convert::Into<wkt::Duration>,
10450    {
10451        self.break_duration = v.map(|x| x.into());
10452        self
10453    }
10454
10455    /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10456    ///
10457    /// # Example
10458    /// ```ignore,no_run
10459    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10460    /// use wkt::Duration;
10461    /// let x = AggregatedMetrics::new().set_visit_duration(Duration::default()/* use setters */);
10462    /// ```
10463    pub fn set_visit_duration<T>(mut self, v: T) -> Self
10464    where
10465        T: std::convert::Into<wkt::Duration>,
10466    {
10467        self.visit_duration = std::option::Option::Some(v.into());
10468        self
10469    }
10470
10471    /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10472    ///
10473    /// # Example
10474    /// ```ignore,no_run
10475    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10476    /// use wkt::Duration;
10477    /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(Some(Duration::default()/* use setters */));
10478    /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(None::<Duration>);
10479    /// ```
10480    pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
10481    where
10482        T: std::convert::Into<wkt::Duration>,
10483    {
10484        self.visit_duration = v.map(|x| x.into());
10485        self
10486    }
10487
10488    /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10489    ///
10490    /// # Example
10491    /// ```ignore,no_run
10492    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10493    /// use wkt::Duration;
10494    /// let x = AggregatedMetrics::new().set_total_duration(Duration::default()/* use setters */);
10495    /// ```
10496    pub fn set_total_duration<T>(mut self, v: T) -> Self
10497    where
10498        T: std::convert::Into<wkt::Duration>,
10499    {
10500        self.total_duration = std::option::Option::Some(v.into());
10501        self
10502    }
10503
10504    /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10505    ///
10506    /// # Example
10507    /// ```ignore,no_run
10508    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10509    /// use wkt::Duration;
10510    /// let x = AggregatedMetrics::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
10511    /// let x = AggregatedMetrics::new().set_or_clear_total_duration(None::<Duration>);
10512    /// ```
10513    pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
10514    where
10515        T: std::convert::Into<wkt::Duration>,
10516    {
10517        self.total_duration = v.map(|x| x.into());
10518        self
10519    }
10520
10521    /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
10522    ///
10523    /// # Example
10524    /// ```ignore,no_run
10525    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10526    /// let x = AggregatedMetrics::new().set_travel_distance_meters(42.0);
10527    /// ```
10528    pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10529        self.travel_distance_meters = v.into();
10530        self
10531    }
10532
10533    /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
10534    ///
10535    /// # Example
10536    /// ```ignore,no_run
10537    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10538    /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
10539    /// let x = AggregatedMetrics::new().set_max_loads([
10540    ///     ("key0", VehicleLoad::default()/* use setters */),
10541    ///     ("key1", VehicleLoad::default()/* use (different) setters */),
10542    /// ]);
10543    /// ```
10544    pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
10545    where
10546        T: std::iter::IntoIterator<Item = (K, V)>,
10547        K: std::convert::Into<std::string::String>,
10548        V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
10549    {
10550        use std::iter::Iterator;
10551        self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10552        self
10553    }
10554
10555    /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
10556    ///
10557    /// # Example
10558    /// ```ignore,no_run
10559    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10560    /// let x = AggregatedMetrics::new().set_costs([
10561    ///     ("key0", 123.5),
10562    ///     ("key1", 456.5),
10563    /// ]);
10564    /// ```
10565    #[deprecated]
10566    pub fn set_costs<T, K, V>(mut self, v: T) -> Self
10567    where
10568        T: std::iter::IntoIterator<Item = (K, V)>,
10569        K: std::convert::Into<std::string::String>,
10570        V: std::convert::Into<f64>,
10571    {
10572        use std::iter::Iterator;
10573        self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10574        self
10575    }
10576
10577    /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
10578    ///
10579    /// # Example
10580    /// ```ignore,no_run
10581    /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10582    /// let x = AggregatedMetrics::new().set_total_cost(42.0);
10583    /// ```
10584    #[deprecated]
10585    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10586        self.total_cost = v.into();
10587        self
10588    }
10589}
10590
10591impl wkt::message::Message for AggregatedMetrics {
10592    fn typename() -> &'static str {
10593        "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
10594    }
10595}
10596
10597/// Solution injected in the request including information about which visits
10598/// must be constrained and how they must be constrained.
10599#[derive(Clone, Default, PartialEq)]
10600#[non_exhaustive]
10601pub struct InjectedSolutionConstraint {
10602    /// Routes of the solution to inject. Some routes may be omitted from the
10603    /// original solution. The routes and skipped shipments must satisfy the basic
10604    /// validity assumptions listed for `injected_first_solution_routes`.
10605    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
10606
10607    /// Skipped shipments of the solution to inject. Some may be omitted from the
10608    /// original solution. See the `routes` field.
10609    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
10610
10611    /// For zero or more groups of vehicles, specifies when and how much to relax
10612    /// constraints. If this field is empty, all non-empty vehicle routes are
10613    /// fully constrained.
10614    pub constraint_relaxations:
10615        std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10616
10617    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10618}
10619
10620impl InjectedSolutionConstraint {
10621    pub fn new() -> Self {
10622        std::default::Default::default()
10623    }
10624
10625    /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
10626    ///
10627    /// # Example
10628    /// ```ignore,no_run
10629    /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10630    /// use google_cloud_optimization_v1::model::ShipmentRoute;
10631    /// let x = InjectedSolutionConstraint::new()
10632    ///     .set_routes([
10633    ///         ShipmentRoute::default()/* use setters */,
10634    ///         ShipmentRoute::default()/* use (different) setters */,
10635    ///     ]);
10636    /// ```
10637    pub fn set_routes<T, V>(mut self, v: T) -> Self
10638    where
10639        T: std::iter::IntoIterator<Item = V>,
10640        V: std::convert::Into<crate::model::ShipmentRoute>,
10641    {
10642        use std::iter::Iterator;
10643        self.routes = v.into_iter().map(|i| i.into()).collect();
10644        self
10645    }
10646
10647    /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
10648    ///
10649    /// # Example
10650    /// ```ignore,no_run
10651    /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10652    /// use google_cloud_optimization_v1::model::SkippedShipment;
10653    /// let x = InjectedSolutionConstraint::new()
10654    ///     .set_skipped_shipments([
10655    ///         SkippedShipment::default()/* use setters */,
10656    ///         SkippedShipment::default()/* use (different) setters */,
10657    ///     ]);
10658    /// ```
10659    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
10660    where
10661        T: std::iter::IntoIterator<Item = V>,
10662        V: std::convert::Into<crate::model::SkippedShipment>,
10663    {
10664        use std::iter::Iterator;
10665        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
10666        self
10667    }
10668
10669    /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
10670    ///
10671    /// # Example
10672    /// ```ignore,no_run
10673    /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10674    /// use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10675    /// let x = InjectedSolutionConstraint::new()
10676    ///     .set_constraint_relaxations([
10677    ///         ConstraintRelaxation::default()/* use setters */,
10678    ///         ConstraintRelaxation::default()/* use (different) setters */,
10679    ///     ]);
10680    /// ```
10681    pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
10682    where
10683        T: std::iter::IntoIterator<Item = V>,
10684        V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10685    {
10686        use std::iter::Iterator;
10687        self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
10688        self
10689    }
10690}
10691
10692impl wkt::message::Message for InjectedSolutionConstraint {
10693    fn typename() -> &'static str {
10694        "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
10695    }
10696}
10697
10698/// Defines additional types related to [InjectedSolutionConstraint].
10699pub mod injected_solution_constraint {
10700    #[allow(unused_imports)]
10701    use super::*;
10702
10703    /// For a group of vehicles, specifies at what threshold(s) constraints on
10704    /// visits will be relaxed and to which level. Shipments listed in
10705    /// the `skipped_shipment` field are constrained to be skipped; i.e., they
10706    /// cannot be performed.
10707    #[derive(Clone, Default, PartialEq)]
10708    #[non_exhaustive]
10709    pub struct ConstraintRelaxation {
10710        /// All the visit constraint relaxations that will apply to visits on
10711        /// routes with vehicles in `vehicle_indices`.
10712        pub relaxations: std::vec::Vec<
10713            crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10714        >,
10715
10716        /// Specifies the vehicle indices to which the visit constraint
10717        /// `relaxations` apply. If empty, this is considered the default and the
10718        /// `relaxations` apply to all vehicles that are not specified in other
10719        /// `constraint_relaxations`. There can be at most one default, i.e., at
10720        /// most one constraint relaxation field is allowed empty
10721        /// `vehicle_indices`. A vehicle index can only be listed once, even within
10722        /// several `constraint_relaxations`.
10723        ///
10724        /// A vehicle index is mapped the same as
10725        /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
10726        /// if `interpret_injected_solutions_using_labels` is true (see `fields`
10727        /// comment).
10728        ///
10729        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
10730        pub vehicle_indices: std::vec::Vec<i32>,
10731
10732        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10733    }
10734
10735    impl ConstraintRelaxation {
10736        pub fn new() -> Self {
10737            std::default::Default::default()
10738        }
10739
10740        /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
10741        ///
10742        /// # Example
10743        /// ```ignore,no_run
10744        /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10745        /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10746        /// let x = ConstraintRelaxation::new()
10747        ///     .set_relaxations([
10748        ///         Relaxation::default()/* use setters */,
10749        ///         Relaxation::default()/* use (different) setters */,
10750        ///     ]);
10751        /// ```
10752        pub fn set_relaxations<T, V>(mut self, v: T) -> Self
10753        where
10754            T: std::iter::IntoIterator<Item = V>,
10755            V: std::convert::Into<
10756                    crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10757                >,
10758        {
10759            use std::iter::Iterator;
10760            self.relaxations = v.into_iter().map(|i| i.into()).collect();
10761            self
10762        }
10763
10764        /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
10765        ///
10766        /// # Example
10767        /// ```ignore,no_run
10768        /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10769        /// let x = ConstraintRelaxation::new().set_vehicle_indices([1, 2, 3]);
10770        /// ```
10771        pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
10772        where
10773            T: std::iter::IntoIterator<Item = V>,
10774            V: std::convert::Into<i32>,
10775        {
10776            use std::iter::Iterator;
10777            self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
10778            self
10779        }
10780    }
10781
10782    impl wkt::message::Message for ConstraintRelaxation {
10783        fn typename() -> &'static str {
10784            "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
10785        }
10786    }
10787
10788    /// Defines additional types related to [ConstraintRelaxation].
10789    pub mod constraint_relaxation {
10790        #[allow(unused_imports)]
10791        use super::*;
10792
10793        /// If `relaxations` is empty, the start time and sequence of all visits
10794        /// on `routes` are fully constrained and no new visits may be inserted or
10795        /// added to those routes. Also, a vehicle's start and end time in
10796        /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
10797        /// visits and has `used_if_route_is_empty` set to false in the model).
10798        ///
10799        /// `relaxations(i).level` specifies the constraint relaxation level applied
10800        /// to a visit #j that satisfies:
10801        ///
10802        /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
10803        /// * `j + 1 >= relaxations(i).threshold_visit_count`
10804        ///
10805        /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
10806        /// satisfies:
10807        ///
10808        /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
10809        /// * `relaxations(i).threshold_visit_count == 0`
10810        ///   and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
10811        /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
10812        /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
10813        ///
10814        /// To apply a relaxation level if a visit meets the `threshold_visit_count`
10815        /// OR the `threshold_time` add two `relaxations` with the same `level`:
10816        /// one with only `threshold_visit_count` set and the other with only
10817        /// `threshold_time` set. If a visit satisfies the conditions of multiple
10818        /// `relaxations`, the most relaxed level applies. As a result, from the
10819        /// vehicle start through the route visits in order to the vehicle end, the
10820        /// relaxation level becomes more relaxed: i.e., the relaxation level is
10821        /// non-decreasing as the route progresses.
10822        ///
10823        /// The timing and sequence of route visits that do not satisfy the
10824        /// threshold conditions of any `relaxations` are fully constrained
10825        /// and no visits may be inserted into these sequences. Also, if a
10826        /// vehicle start or end does not satisfy the conditions of any
10827        /// relaxation the time is fixed, unless the vehicle is empty.
10828        #[derive(Clone, Default, PartialEq)]
10829        #[non_exhaustive]
10830        pub struct Relaxation {
10831
10832            /// The constraint relaxation level that applies when the conditions
10833            /// at or after `threshold_time` AND at least `threshold_visit_count` are
10834            /// satisfied.
10835            pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
10836
10837            /// The time at or after which the relaxation `level` may be applied.
10838            pub threshold_time: std::option::Option<wkt::Timestamp>,
10839
10840            /// The number of visits at or after which the relaxation `level` may be
10841            /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
10842            /// applied directly at the vehicle start.
10843            ///
10844            /// If it is `route.visits_size() + 1`, the `level` may only be applied to
10845            /// the vehicle end. If it is more than `route.visits_size() + 1`,
10846            /// `level` is not applied at all for that route.
10847            pub threshold_visit_count: i32,
10848
10849            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10850        }
10851
10852        impl Relaxation {
10853            pub fn new() -> Self {
10854                std::default::Default::default()
10855            }
10856
10857            /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
10858            ///
10859            /// # Example
10860            /// ```ignore,no_run
10861            /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10862            /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::relaxation::Level;
10863            /// let x0 = Relaxation::new().set_level(Level::RelaxVisitTimesAfterThreshold);
10864            /// let x1 = Relaxation::new().set_level(Level::RelaxVisitTimesAndSequenceAfterThreshold);
10865            /// let x2 = Relaxation::new().set_level(Level::RelaxAllAfterThreshold);
10866            /// ```
10867            pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
10868                self.level = v.into();
10869                self
10870            }
10871
10872            /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10873            ///
10874            /// # Example
10875            /// ```ignore,no_run
10876            /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10877            /// use wkt::Timestamp;
10878            /// let x = Relaxation::new().set_threshold_time(Timestamp::default()/* use setters */);
10879            /// ```
10880            pub fn set_threshold_time<T>(mut self, v: T) -> Self
10881            where
10882                T: std::convert::Into<wkt::Timestamp>,
10883            {
10884                self.threshold_time = std::option::Option::Some(v.into());
10885                self
10886            }
10887
10888            /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10889            ///
10890            /// # Example
10891            /// ```ignore,no_run
10892            /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10893            /// use wkt::Timestamp;
10894            /// let x = Relaxation::new().set_or_clear_threshold_time(Some(Timestamp::default()/* use setters */));
10895            /// let x = Relaxation::new().set_or_clear_threshold_time(None::<Timestamp>);
10896            /// ```
10897            pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
10898            where
10899                T: std::convert::Into<wkt::Timestamp>,
10900            {
10901                self.threshold_time = v.map(|x| x.into());
10902                self
10903            }
10904
10905            /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
10906            ///
10907            /// # Example
10908            /// ```ignore,no_run
10909            /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10910            /// let x = Relaxation::new().set_threshold_visit_count(42);
10911            /// ```
10912            pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10913                self.threshold_visit_count = v.into();
10914                self
10915            }
10916        }
10917
10918        impl wkt::message::Message for Relaxation {
10919            fn typename() -> &'static str {
10920                "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
10921            }
10922        }
10923
10924        /// Defines additional types related to [Relaxation].
10925        pub mod relaxation {
10926            #[allow(unused_imports)]
10927            use super::*;
10928
10929            /// Expresses the different constraint relaxation levels, which are
10930            /// applied for a visit and those that follow when it satisfies the
10931            /// threshold conditions.
10932            ///
10933            /// The enumeration below is in order of increasing relaxation.
10934            ///
10935            /// # Working with unknown values
10936            ///
10937            /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10938            /// additional enum variants at any time. Adding new variants is not considered
10939            /// a breaking change. Applications should write their code in anticipation of:
10940            ///
10941            /// - New values appearing in future releases of the client library, **and**
10942            /// - New values received dynamically, without application changes.
10943            ///
10944            /// Please consult the [Working with enums] section in the user guide for some
10945            /// guidelines.
10946            ///
10947            /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
10948            #[derive(Clone, Debug, PartialEq)]
10949            #[non_exhaustive]
10950            pub enum Level {
10951                /// Implicit default relaxation level: no constraints are relaxed,
10952                /// i.e., all visits are fully constrained.
10953                ///
10954                /// This value must not be explicitly used in `level`.
10955                Unspecified,
10956                /// Visit start times and vehicle start/end times will be relaxed, but
10957                /// each visit remains bound to the same vehicle and the visit sequence
10958                /// must be observed: no visit can be inserted between them or before
10959                /// them.
10960                RelaxVisitTimesAfterThreshold,
10961                /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
10962                /// is also relaxed: visits can only be performed by this vehicle, but
10963                /// can potentially become unperformed.
10964                RelaxVisitTimesAndSequenceAfterThreshold,
10965                /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
10966                /// vehicle is also relaxed: visits are completely free at or after the
10967                /// threshold time and can potentially become unperformed.
10968                RelaxAllAfterThreshold,
10969                /// If set, the enum was initialized with an unknown value.
10970                ///
10971                /// Applications can examine the value using [Level::value] or
10972                /// [Level::name].
10973                UnknownValue(level::UnknownValue),
10974            }
10975
10976            #[doc(hidden)]
10977            pub mod level {
10978                #[allow(unused_imports)]
10979                use super::*;
10980                #[derive(Clone, Debug, PartialEq)]
10981                pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10982            }
10983
10984            impl Level {
10985                /// Gets the enum value.
10986                ///
10987                /// Returns `None` if the enum contains an unknown value deserialized from
10988                /// the string representation of enums.
10989                pub fn value(&self) -> std::option::Option<i32> {
10990                    match self {
10991                        Self::Unspecified => std::option::Option::Some(0),
10992                        Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
10993                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
10994                            std::option::Option::Some(2)
10995                        }
10996                        Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
10997                        Self::UnknownValue(u) => u.0.value(),
10998                    }
10999                }
11000
11001                /// Gets the enum value as a string.
11002                ///
11003                /// Returns `None` if the enum contains an unknown value deserialized from
11004                /// the integer representation of enums.
11005                pub fn name(&self) -> std::option::Option<&str> {
11006                    match self {
11007                        Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
11008                        Self::RelaxVisitTimesAfterThreshold => {
11009                            std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
11010                        }
11011                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11012                            std::option::Option::Some(
11013                                "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
11014                            )
11015                        }
11016                        Self::RelaxAllAfterThreshold => {
11017                            std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
11018                        }
11019                        Self::UnknownValue(u) => u.0.name(),
11020                    }
11021                }
11022            }
11023
11024            impl std::default::Default for Level {
11025                fn default() -> Self {
11026                    use std::convert::From;
11027                    Self::from(0)
11028                }
11029            }
11030
11031            impl std::fmt::Display for Level {
11032                fn fmt(
11033                    &self,
11034                    f: &mut std::fmt::Formatter<'_>,
11035                ) -> std::result::Result<(), std::fmt::Error> {
11036                    wkt::internal::display_enum(f, self.name(), self.value())
11037                }
11038            }
11039
11040            impl std::convert::From<i32> for Level {
11041                fn from(value: i32) -> Self {
11042                    match value {
11043                        0 => Self::Unspecified,
11044                        1 => Self::RelaxVisitTimesAfterThreshold,
11045                        2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
11046                        3 => Self::RelaxAllAfterThreshold,
11047                        _ => Self::UnknownValue(level::UnknownValue(
11048                            wkt::internal::UnknownEnumValue::Integer(value),
11049                        )),
11050                    }
11051                }
11052            }
11053
11054            impl std::convert::From<&str> for Level {
11055                fn from(value: &str) -> Self {
11056                    use std::string::ToString;
11057                    match value {
11058                        "LEVEL_UNSPECIFIED" => Self::Unspecified,
11059                        "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
11060                        "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
11061                            Self::RelaxVisitTimesAndSequenceAfterThreshold
11062                        }
11063                        "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
11064                        _ => Self::UnknownValue(level::UnknownValue(
11065                            wkt::internal::UnknownEnumValue::String(value.to_string()),
11066                        )),
11067                    }
11068                }
11069            }
11070
11071            impl serde::ser::Serialize for Level {
11072                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11073                where
11074                    S: serde::Serializer,
11075                {
11076                    match self {
11077                        Self::Unspecified => serializer.serialize_i32(0),
11078                        Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
11079                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11080                            serializer.serialize_i32(2)
11081                        }
11082                        Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
11083                        Self::UnknownValue(u) => u.0.serialize(serializer),
11084                    }
11085                }
11086            }
11087
11088            impl<'de> serde::de::Deserialize<'de> for Level {
11089                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11090                where
11091                    D: serde::Deserializer<'de>,
11092                {
11093                    deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
11094                        ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
11095                }
11096            }
11097        }
11098    }
11099}
11100
11101/// Describes an error encountered when validating an `OptimizeToursRequest`.
11102#[derive(Clone, Default, PartialEq)]
11103#[non_exhaustive]
11104pub struct OptimizeToursValidationError {
11105    /// A validation error is defined by the pair (`code`, `display_name`) which
11106    /// are always present.
11107    ///
11108    /// Other fields (below) provide more context about the error.
11109    ///
11110    /// *MULTIPLE ERRORS*:
11111    /// When there are multiple errors, the validation process tries to output
11112    /// several of them. Much like a compiler, this is an imperfect process. Some
11113    /// validation errors will be "fatal", meaning that they stop the entire
11114    /// validation process. This is the case for `display_name="UNSPECIFIED"`
11115    /// errors, among others. Some may cause the validation process to skip other
11116    /// errors.
11117    ///
11118    /// *STABILITY*:
11119    /// `code` and `display_name` should be very stable. But new codes and
11120    /// display names may appear over time, which may cause a given (invalid)
11121    /// request to yield a different (`code`, `display_name`) pair because the new
11122    /// error hid the old one (see "MULTIPLE ERRORS").
11123    ///
11124    /// *REFERENCE*: A list of all (code, name) pairs:
11125    ///
11126    /// * UNSPECIFIED = 0;
11127    ///
11128    /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
11129    ///   the deadline.
11130    ///
11131    /// * REQUEST_OPTIONS_ERROR = 12;
11132    ///
11133    ///   * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
11134    ///   * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
11135    ///   * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
11136    ///   * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
11137    ///   * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
11138    ///   * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
11139    ///     = 1207;
11140    ///   * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
11141    ///   * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
11142    ///   * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
11143    ///   * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
11144    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
11145    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
11146    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
11147    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
11148    /// * INJECTED_SOLUTION_ERROR = 20;
11149    ///
11150    ///   * INJECTED_SOLUTION_MISSING_LABEL = 2000;
11151    ///   * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
11152    ///   * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
11153    ///   * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
11154    ///   * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
11155    ///   * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
11156    ///   * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
11157    ///   * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
11158    ///   * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
11159    /// * SHIPMENT_MODEL_ERROR = 22;
11160    ///
11161    ///   * SHIPMENT_MODEL_TOO_LARGE = 2200;
11162    ///   * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
11163    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
11164    ///   * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
11165    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
11166    ///   * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
11167    ///   * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
11168    ///   * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
11169    /// * INDEX_ERROR = 24;
11170    ///
11171    /// * TAG_ERROR = 26;
11172    ///
11173    /// * TIME_WINDOW_ERROR = 28;
11174    ///
11175    ///   * TIME_WINDOW_INVALID_START_TIME = 2800;
11176    ///   * TIME_WINDOW_INVALID_END_TIME = 2801;
11177    ///   * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
11178    ///   * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
11179    ///   * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
11180    ///   * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
11181    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
11182    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
11183    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
11184    ///     = 2808;
11185    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
11186    ///   * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
11187    ///     = 2810;
11188    ///   * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
11189    ///   * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
11190    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
11191    ///   * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
11192    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
11193    ///   * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
11194    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
11195    ///     = 2817;
11196    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
11197    ///   * TRANSITION_ATTRIBUTES_ERROR = 30;
11198    ///   * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
11199    ///   * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
11200    ///   * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
11201    ///   * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
11202    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
11203    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
11204    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
11205    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
11206    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
11207    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
11208    /// * AMOUNT_ERROR = 31;
11209    ///
11210    ///   * AMOUNT_NEGATIVE_VALUE = 3100;
11211    /// * LOAD_LIMIT_ERROR = 33;
11212    ///
11213    ///   * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
11214    ///   * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
11215    ///   * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
11216    ///   * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
11217    ///   * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
11218    ///   * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
11219    ///   * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
11220    /// * INTERVAL_ERROR = 34;
11221    ///
11222    ///   * INTERVAL_MIN_EXCEEDS_MAX = 3401;
11223    ///   * INTERVAL_NEGATIVE_MIN = 3402;
11224    ///   * INTERVAL_NEGATIVE_MAX = 3403;
11225    ///   * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
11226    ///   * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
11227    /// * DISTANCE_LIMIT_ERROR = 36;
11228    ///
11229    ///   * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
11230    ///   * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
11231    ///   * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
11232    ///   * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
11233    ///   * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
11234    ///   * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
11235    /// * DURATION_LIMIT_ERROR = 38;
11236    ///
11237    ///   * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
11238    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
11239    ///   * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
11240    ///   * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
11241    ///   * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
11242    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
11243    ///   * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
11244    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
11245    ///     = 3807;
11246    ///   * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
11247    ///     = 3808;
11248    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
11249    ///   * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
11250    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
11251    ///   * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
11252    ///     = 3812;
11253    ///   * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
11254    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
11255    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
11256    ///     = 3815;
11257    /// * SHIPMENT_ERROR = 40;
11258    ///
11259    ///   * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
11260    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
11261    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
11262    ///     = 4001;
11263    ///   * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
11264    ///   * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
11265    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
11266    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
11267    ///   * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
11268    ///   * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
11269    ///   * SHIPMENT_INVALID_PENALTY_COST = 4006;
11270    ///   * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
11271    ///   * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
11272    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
11273    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
11274    ///   * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
11275    ///   * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
11276    ///   * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
11277    /// * VEHICLE_ERROR = 42;
11278    ///
11279    ///   * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
11280    ///   * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
11281    ///   * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
11282    ///   * VEHICLE_EMPTY_START_TAG = 4203;
11283    ///   * VEHICLE_DUPLICATE_START_TAG = 4204;
11284    ///   * VEHICLE_EMPTY_END_TAG = 4205;
11285    ///   * VEHICLE_DUPLICATE_END_TAG = 4206;
11286    ///   * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
11287    ///   * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
11288    ///   * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
11289    ///   * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
11290    ///   * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
11291    ///   * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
11292    ///   * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
11293    ///   * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
11294    ///   * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
11295    ///   * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
11296    ///   * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
11297    ///   * VEHICLE_INVALID_COST_PER_HOUR = 4218;
11298    ///   * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
11299    ///   * VEHICLE_INVALID_FIXED_COST = 4220;
11300    ///   * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
11301    ///   * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
11302    ///     = 4223;
11303    ///   * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
11304    ///   * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
11305    /// * VISIT_REQUEST_ERROR = 44;
11306    ///
11307    ///   * VISIT_REQUEST_EMPTY_TAG = 4400;
11308    ///   * VISIT_REQUEST_DUPLICATE_TAG = 4401;
11309    ///   * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
11310    ///   * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
11311    /// * PRECEDENCE_ERROR = 46;
11312    ///
11313    ///   * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
11314    ///   * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
11315    ///   * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
11316    ///   * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
11317    ///   * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
11318    ///   * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
11319    ///   * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
11320    /// * BREAK_ERROR = 48;
11321    ///
11322    ///   * BREAK_RULE_EMPTY = 4800;
11323    ///   * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
11324    ///   * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
11325    ///   * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
11326    ///   * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
11327    ///   * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
11328    ///   * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
11329    ///   * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
11330    ///   * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
11331    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
11332    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
11333    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
11334    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
11335    ///     = 4812;
11336    ///   * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
11337    ///   * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
11338    ///   * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
11339    /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
11340    ///
11341    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
11342    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
11343    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
11344    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
11345    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
11346    /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
11347    ///
11348    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
11349    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
11350    ///   * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
11351    ///   * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
11352    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
11353    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
11354    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
11355    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
11356    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
11357    ///   * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
11358    ///   * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
11359    /// * VEHICLE_OPERATOR_ERROR = 54;
11360    ///
11361    ///   * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
11362    ///   * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
11363    ///   * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
11364    ///   * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
11365    ///   * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
11366    /// * DURATION_SECONDS_MATRIX_ERROR = 56;
11367    ///
11368    ///   * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
11369    ///   * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
11370    pub code: i32,
11371
11372    /// The error display name.
11373    pub display_name: std::string::String,
11374
11375    /// An error context may involve 0, 1 (most of the time) or more fields. For
11376    /// example, referring to vehicle #4 and shipment #2's first pickup can be
11377    /// done as follows:
11378    ///
11379    /// ```norust
11380    /// fields { name: "vehicles" index: 4}
11381    /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
11382    /// ```
11383    ///
11384    /// Note, however, that the cardinality of `fields` should not change for a
11385    /// given error code.
11386    pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
11387
11388    /// Human-readable string describing the error. There is a 1:1 mapping
11389    /// between `code` and `error_message` (when code != "UNSPECIFIED").
11390    ///
11391    /// *STABILITY*: Not stable: the error message associated to a given `code` may
11392    /// change (hopefully to clarify it) over time. Please rely on the
11393    /// `display_name` and `code` instead.
11394    pub error_message: std::string::String,
11395
11396    /// May contain the value(s) of the field(s). This is not always available. You
11397    /// should absolutely not rely on it and use it only for manual model
11398    /// debugging.
11399    pub offending_values: std::string::String,
11400
11401    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11402}
11403
11404impl OptimizeToursValidationError {
11405    pub fn new() -> Self {
11406        std::default::Default::default()
11407    }
11408
11409    /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
11410    ///
11411    /// # Example
11412    /// ```ignore,no_run
11413    /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11414    /// let x = OptimizeToursValidationError::new().set_code(42);
11415    /// ```
11416    pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11417        self.code = v.into();
11418        self
11419    }
11420
11421    /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
11422    ///
11423    /// # Example
11424    /// ```ignore,no_run
11425    /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11426    /// let x = OptimizeToursValidationError::new().set_display_name("example");
11427    /// ```
11428    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11429        self.display_name = v.into();
11430        self
11431    }
11432
11433    /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
11434    ///
11435    /// # Example
11436    /// ```ignore,no_run
11437    /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11438    /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11439    /// let x = OptimizeToursValidationError::new()
11440    ///     .set_fields([
11441    ///         FieldReference::default()/* use setters */,
11442    ///         FieldReference::default()/* use (different) setters */,
11443    ///     ]);
11444    /// ```
11445    pub fn set_fields<T, V>(mut self, v: T) -> Self
11446    where
11447        T: std::iter::IntoIterator<Item = V>,
11448        V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11449    {
11450        use std::iter::Iterator;
11451        self.fields = v.into_iter().map(|i| i.into()).collect();
11452        self
11453    }
11454
11455    /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
11456    ///
11457    /// # Example
11458    /// ```ignore,no_run
11459    /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11460    /// let x = OptimizeToursValidationError::new().set_error_message("example");
11461    /// ```
11462    pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11463        self.error_message = v.into();
11464        self
11465    }
11466
11467    /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
11468    ///
11469    /// # Example
11470    /// ```ignore,no_run
11471    /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11472    /// let x = OptimizeToursValidationError::new().set_offending_values("example");
11473    /// ```
11474    pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
11475        mut self,
11476        v: T,
11477    ) -> Self {
11478        self.offending_values = v.into();
11479        self
11480    }
11481}
11482
11483impl wkt::message::Message for OptimizeToursValidationError {
11484    fn typename() -> &'static str {
11485        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
11486    }
11487}
11488
11489/// Defines additional types related to [OptimizeToursValidationError].
11490pub mod optimize_tours_validation_error {
11491    #[allow(unused_imports)]
11492    use super::*;
11493
11494    /// Specifies a context for the validation error. A `FieldReference` always
11495    /// refers to a given field in this file and follows the same hierarchical
11496    /// structure. For example, we may specify element #2 of `start_time_windows`
11497    /// of vehicle #5 using:
11498    ///
11499    /// ```norust
11500    /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
11501    /// ```
11502    ///
11503    /// We however omit top-level entities such as `OptimizeToursRequest` or
11504    /// `ShipmentModel` to avoid crowding the message.
11505    #[derive(Clone, Default, PartialEq)]
11506    #[non_exhaustive]
11507    pub struct FieldReference {
11508        /// Name of the field, e.g., "vehicles".
11509        pub name: std::string::String,
11510
11511        /// Recursively nested sub-field, if needed.
11512        pub sub_field: std::option::Option<
11513            std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
11514        >,
11515
11516        pub index_or_key: std::option::Option<
11517            crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11518        >,
11519
11520        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11521    }
11522
11523    impl FieldReference {
11524        pub fn new() -> Self {
11525            std::default::Default::default()
11526        }
11527
11528        /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
11529        ///
11530        /// # Example
11531        /// ```ignore,no_run
11532        /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11533        /// let x = FieldReference::new().set_name("example");
11534        /// ```
11535        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11536            self.name = v.into();
11537            self
11538        }
11539
11540        /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11541        ///
11542        /// # Example
11543        /// ```ignore,no_run
11544        /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11545        /// let x = FieldReference::new().set_sub_field(FieldReference::default()/* use setters */);
11546        /// ```
11547        pub fn set_sub_field<T>(mut self, v: T) -> Self
11548        where
11549            T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11550        {
11551            self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
11552            self
11553        }
11554
11555        /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11556        ///
11557        /// # Example
11558        /// ```ignore,no_run
11559        /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11560        /// let x = FieldReference::new().set_or_clear_sub_field(Some(FieldReference::default()/* use setters */));
11561        /// let x = FieldReference::new().set_or_clear_sub_field(None::<FieldReference>);
11562        /// ```
11563        pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
11564        where
11565            T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11566        {
11567            self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
11568            self
11569        }
11570
11571        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
11572        ///
11573        /// Note that all the setters affecting `index_or_key` are mutually
11574        /// exclusive.
11575        ///
11576        /// # Example
11577        /// ```ignore,no_run
11578        /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11579        /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::field_reference::IndexOrKey;
11580        /// let x = FieldReference::new().set_index_or_key(Some(IndexOrKey::Index(42)));
11581        /// ```
11582        pub fn set_index_or_key<
11583            T: std::convert::Into<
11584                    std::option::Option<
11585                        crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11586                    >,
11587                >,
11588        >(
11589            mut self,
11590            v: T,
11591        ) -> Self {
11592            self.index_or_key = v.into();
11593            self
11594        }
11595
11596        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11597        /// if it holds a `Index`, `None` if the field is not set or
11598        /// holds a different branch.
11599        pub fn index(&self) -> std::option::Option<&i32> {
11600            #[allow(unreachable_patterns)]
11601            self.index_or_key.as_ref().and_then(|v| match v {
11602                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
11603                _ => std::option::Option::None,
11604            })
11605        }
11606
11607        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11608        /// to hold a `Index`.
11609        ///
11610        /// Note that all the setters affecting `index_or_key` are
11611        /// mutually exclusive.
11612        ///
11613        /// # Example
11614        /// ```ignore,no_run
11615        /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11616        /// let x = FieldReference::new().set_index(42);
11617        /// assert!(x.index().is_some());
11618        /// assert!(x.key().is_none());
11619        /// ```
11620        pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11621            self.index_or_key = std::option::Option::Some(
11622                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
11623                    v.into(),
11624                ),
11625            );
11626            self
11627        }
11628
11629        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11630        /// if it holds a `Key`, `None` if the field is not set or
11631        /// holds a different branch.
11632        pub fn key(&self) -> std::option::Option<&std::string::String> {
11633            #[allow(unreachable_patterns)]
11634            self.index_or_key.as_ref().and_then(|v| match v {
11635                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11636                    v,
11637                ) => std::option::Option::Some(v),
11638                _ => std::option::Option::None,
11639            })
11640        }
11641
11642        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11643        /// to hold a `Key`.
11644        ///
11645        /// Note that all the setters affecting `index_or_key` are
11646        /// mutually exclusive.
11647        ///
11648        /// # Example
11649        /// ```ignore,no_run
11650        /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11651        /// let x = FieldReference::new().set_key("example");
11652        /// assert!(x.key().is_some());
11653        /// assert!(x.index().is_none());
11654        /// ```
11655        pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11656            self.index_or_key = std::option::Option::Some(
11657                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11658                    v.into(),
11659                ),
11660            );
11661            self
11662        }
11663    }
11664
11665    impl wkt::message::Message for FieldReference {
11666        fn typename() -> &'static str {
11667            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
11668        }
11669    }
11670
11671    /// Defines additional types related to [FieldReference].
11672    pub mod field_reference {
11673        #[allow(unused_imports)]
11674        use super::*;
11675
11676        #[derive(Clone, Debug, PartialEq)]
11677        #[non_exhaustive]
11678        pub enum IndexOrKey {
11679            /// Index of the field if repeated.
11680            Index(i32),
11681            /// Key if the field is a map.
11682            Key(std::string::String),
11683        }
11684    }
11685}
11686
11687/// Data formats for input and output files.
11688///
11689/// # Working with unknown values
11690///
11691/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11692/// additional enum variants at any time. Adding new variants is not considered
11693/// a breaking change. Applications should write their code in anticipation of:
11694///
11695/// - New values appearing in future releases of the client library, **and**
11696/// - New values received dynamically, without application changes.
11697///
11698/// Please consult the [Working with enums] section in the user guide for some
11699/// guidelines.
11700///
11701/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
11702#[derive(Clone, Debug, PartialEq)]
11703#[non_exhaustive]
11704pub enum DataFormat {
11705    /// Default value.
11706    Unspecified,
11707    /// Input data in json format.
11708    Json,
11709    /// Input data in string format.
11710    String,
11711    /// If set, the enum was initialized with an unknown value.
11712    ///
11713    /// Applications can examine the value using [DataFormat::value] or
11714    /// [DataFormat::name].
11715    UnknownValue(data_format::UnknownValue),
11716}
11717
11718#[doc(hidden)]
11719pub mod data_format {
11720    #[allow(unused_imports)]
11721    use super::*;
11722    #[derive(Clone, Debug, PartialEq)]
11723    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11724}
11725
11726impl DataFormat {
11727    /// Gets the enum value.
11728    ///
11729    /// Returns `None` if the enum contains an unknown value deserialized from
11730    /// the string representation of enums.
11731    pub fn value(&self) -> std::option::Option<i32> {
11732        match self {
11733            Self::Unspecified => std::option::Option::Some(0),
11734            Self::Json => std::option::Option::Some(1),
11735            Self::String => std::option::Option::Some(2),
11736            Self::UnknownValue(u) => u.0.value(),
11737        }
11738    }
11739
11740    /// Gets the enum value as a string.
11741    ///
11742    /// Returns `None` if the enum contains an unknown value deserialized from
11743    /// the integer representation of enums.
11744    pub fn name(&self) -> std::option::Option<&str> {
11745        match self {
11746            Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
11747            Self::Json => std::option::Option::Some("JSON"),
11748            Self::String => std::option::Option::Some("STRING"),
11749            Self::UnknownValue(u) => u.0.name(),
11750        }
11751    }
11752}
11753
11754impl std::default::Default for DataFormat {
11755    fn default() -> Self {
11756        use std::convert::From;
11757        Self::from(0)
11758    }
11759}
11760
11761impl std::fmt::Display for DataFormat {
11762    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11763        wkt::internal::display_enum(f, self.name(), self.value())
11764    }
11765}
11766
11767impl std::convert::From<i32> for DataFormat {
11768    fn from(value: i32) -> Self {
11769        match value {
11770            0 => Self::Unspecified,
11771            1 => Self::Json,
11772            2 => Self::String,
11773            _ => Self::UnknownValue(data_format::UnknownValue(
11774                wkt::internal::UnknownEnumValue::Integer(value),
11775            )),
11776        }
11777    }
11778}
11779
11780impl std::convert::From<&str> for DataFormat {
11781    fn from(value: &str) -> Self {
11782        use std::string::ToString;
11783        match value {
11784            "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
11785            "JSON" => Self::Json,
11786            "STRING" => Self::String,
11787            _ => Self::UnknownValue(data_format::UnknownValue(
11788                wkt::internal::UnknownEnumValue::String(value.to_string()),
11789            )),
11790        }
11791    }
11792}
11793
11794impl serde::ser::Serialize for DataFormat {
11795    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11796    where
11797        S: serde::Serializer,
11798    {
11799        match self {
11800            Self::Unspecified => serializer.serialize_i32(0),
11801            Self::Json => serializer.serialize_i32(1),
11802            Self::String => serializer.serialize_i32(2),
11803            Self::UnknownValue(u) => u.0.serialize(serializer),
11804        }
11805    }
11806}
11807
11808impl<'de> serde::de::Deserialize<'de> for DataFormat {
11809    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11810    where
11811        D: serde::Deserializer<'de>,
11812    {
11813        deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
11814            ".google.cloud.optimization.v1.DataFormat",
11815        ))
11816    }
11817}