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
36/// The desired input location information.
37#[derive(Clone, Debug, Default, PartialEq)]
38#[non_exhaustive]
39pub struct InputConfig {
40    /// The input data format that used to store the model in Cloud Storage.
41    pub data_format: crate::model::DataFormat,
42
43    /// The location of the input model in cloud storage.
44    /// Required.
45    pub source: std::option::Option<crate::model::input_config::Source>,
46
47    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
48}
49
50impl InputConfig {
51    pub fn new() -> Self {
52        std::default::Default::default()
53    }
54
55    /// Sets the value of [data_format][crate::model::InputConfig::data_format].
56    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
57        mut self,
58        v: T,
59    ) -> Self {
60        self.data_format = v.into();
61        self
62    }
63
64    /// Sets the value of [source][crate::model::InputConfig::source].
65    ///
66    /// Note that all the setters affecting `source` are mutually
67    /// exclusive.
68    pub fn set_source<
69        T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
70    >(
71        mut self,
72        v: T,
73    ) -> Self {
74        self.source = v.into();
75        self
76    }
77
78    /// The value of [source][crate::model::InputConfig::source]
79    /// if it holds a `GcsSource`, `None` if the field is not set or
80    /// holds a different branch.
81    pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
82        #[allow(unreachable_patterns)]
83        self.source.as_ref().and_then(|v| match v {
84            crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
85            _ => std::option::Option::None,
86        })
87    }
88
89    /// Sets the value of [source][crate::model::InputConfig::source]
90    /// to hold a `GcsSource`.
91    ///
92    /// Note that all the setters affecting `source` are
93    /// mutually exclusive.
94    pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
95        mut self,
96        v: T,
97    ) -> Self {
98        self.source =
99            std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
100        self
101    }
102}
103
104impl wkt::message::Message for InputConfig {
105    fn typename() -> &'static str {
106        "type.googleapis.com/google.cloud.optimization.v1.InputConfig"
107    }
108}
109
110#[doc(hidden)]
111impl<'de> serde::de::Deserialize<'de> for InputConfig {
112    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
113    where
114        D: serde::Deserializer<'de>,
115    {
116        #[allow(non_camel_case_types)]
117        #[doc(hidden)]
118        #[derive(PartialEq, Eq, Hash)]
119        enum __FieldTag {
120            __gcs_source,
121            __data_format,
122            Unknown(std::string::String),
123        }
124        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
125            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
126            where
127                D: serde::Deserializer<'de>,
128            {
129                struct Visitor;
130                impl<'de> serde::de::Visitor<'de> for Visitor {
131                    type Value = __FieldTag;
132                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
133                        formatter.write_str("a field name for InputConfig")
134                    }
135                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
136                    where
137                        E: serde::de::Error,
138                    {
139                        use std::result::Result::Ok;
140                        use std::string::ToString;
141                        match value {
142                            "gcsSource" => Ok(__FieldTag::__gcs_source),
143                            "gcs_source" => Ok(__FieldTag::__gcs_source),
144                            "dataFormat" => Ok(__FieldTag::__data_format),
145                            "data_format" => Ok(__FieldTag::__data_format),
146                            _ => Ok(__FieldTag::Unknown(value.to_string())),
147                        }
148                    }
149                }
150                deserializer.deserialize_identifier(Visitor)
151            }
152        }
153        struct Visitor;
154        impl<'de> serde::de::Visitor<'de> for Visitor {
155            type Value = InputConfig;
156            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
157                formatter.write_str("struct InputConfig")
158            }
159            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
160            where
161                A: serde::de::MapAccess<'de>,
162            {
163                #[allow(unused_imports)]
164                use serde::de::Error;
165                use std::option::Option::Some;
166                let mut fields = std::collections::HashSet::new();
167                let mut result = Self::Value::new();
168                while let Some(tag) = map.next_key::<__FieldTag>()? {
169                    #[allow(clippy::match_single_binding)]
170                    match tag {
171                        __FieldTag::__gcs_source => {
172                            if !fields.insert(__FieldTag::__gcs_source) {
173                                return std::result::Result::Err(A::Error::duplicate_field(
174                                    "multiple values for gcs_source",
175                                ));
176                            }
177                            if result.source.is_some() {
178                                return std::result::Result::Err(A::Error::duplicate_field(
179                                    "multiple values for `source`, a oneof with full ID .google.cloud.optimization.v1.InputConfig.gcs_source, latest field was gcsSource",
180                                ));
181                            }
182                            result.source = std::option::Option::Some(
183                                crate::model::input_config::Source::GcsSource(
184                                    map.next_value::<std::option::Option<
185                                        std::boxed::Box<crate::model::GcsSource>,
186                                    >>()?
187                                    .unwrap_or_default(),
188                                ),
189                            );
190                        }
191                        __FieldTag::__data_format => {
192                            if !fields.insert(__FieldTag::__data_format) {
193                                return std::result::Result::Err(A::Error::duplicate_field(
194                                    "multiple values for data_format",
195                                ));
196                            }
197                            result.data_format = map
198                                .next_value::<std::option::Option<crate::model::DataFormat>>()?
199                                .unwrap_or_default();
200                        }
201                        __FieldTag::Unknown(key) => {
202                            let value = map.next_value::<serde_json::Value>()?;
203                            result._unknown_fields.insert(key, value);
204                        }
205                    }
206                }
207                std::result::Result::Ok(result)
208            }
209        }
210        deserializer.deserialize_any(Visitor)
211    }
212}
213
214#[doc(hidden)]
215impl serde::ser::Serialize for InputConfig {
216    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
217    where
218        S: serde::ser::Serializer,
219    {
220        use serde::ser::SerializeMap;
221        #[allow(unused_imports)]
222        use std::option::Option::Some;
223        let mut state = serializer.serialize_map(std::option::Option::None)?;
224        if let Some(value) = self.gcs_source() {
225            state.serialize_entry("gcsSource", value)?;
226        }
227        if !wkt::internal::is_default(&self.data_format) {
228            state.serialize_entry("dataFormat", &self.data_format)?;
229        }
230        if !self._unknown_fields.is_empty() {
231            for (key, value) in self._unknown_fields.iter() {
232                state.serialize_entry(key, &value)?;
233            }
234        }
235        state.end()
236    }
237}
238
239/// Defines additional types related to [InputConfig].
240pub mod input_config {
241    #[allow(unused_imports)]
242    use super::*;
243
244    /// The location of the input model in cloud storage.
245    /// Required.
246    #[derive(Clone, Debug, PartialEq)]
247    #[non_exhaustive]
248    pub enum Source {
249        /// The Google Cloud Storage location to read the input from. This must be a
250        /// single file.
251        GcsSource(std::boxed::Box<crate::model::GcsSource>),
252    }
253}
254
255/// The desired output location.
256#[derive(Clone, Debug, Default, PartialEq)]
257#[non_exhaustive]
258pub struct OutputConfig {
259    /// The output data format that used to store the results in Cloud Storage.
260    pub data_format: crate::model::DataFormat,
261
262    /// The location of the output result in cloud storage.
263    /// Required.
264    pub destination: std::option::Option<crate::model::output_config::Destination>,
265
266    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
267}
268
269impl OutputConfig {
270    pub fn new() -> Self {
271        std::default::Default::default()
272    }
273
274    /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
275    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
276        mut self,
277        v: T,
278    ) -> Self {
279        self.data_format = v.into();
280        self
281    }
282
283    /// Sets the value of [destination][crate::model::OutputConfig::destination].
284    ///
285    /// Note that all the setters affecting `destination` are mutually
286    /// exclusive.
287    pub fn set_destination<
288        T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
289    >(
290        mut self,
291        v: T,
292    ) -> Self {
293        self.destination = v.into();
294        self
295    }
296
297    /// The value of [destination][crate::model::OutputConfig::destination]
298    /// if it holds a `GcsDestination`, `None` if the field is not set or
299    /// holds a different branch.
300    pub fn gcs_destination(
301        &self,
302    ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
303        #[allow(unreachable_patterns)]
304        self.destination.as_ref().and_then(|v| match v {
305            crate::model::output_config::Destination::GcsDestination(v) => {
306                std::option::Option::Some(v)
307            }
308            _ => std::option::Option::None,
309        })
310    }
311
312    /// Sets the value of [destination][crate::model::OutputConfig::destination]
313    /// to hold a `GcsDestination`.
314    ///
315    /// Note that all the setters affecting `destination` are
316    /// mutually exclusive.
317    pub fn set_gcs_destination<
318        T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
319    >(
320        mut self,
321        v: T,
322    ) -> Self {
323        self.destination = std::option::Option::Some(
324            crate::model::output_config::Destination::GcsDestination(v.into()),
325        );
326        self
327    }
328}
329
330impl wkt::message::Message for OutputConfig {
331    fn typename() -> &'static str {
332        "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
333    }
334}
335
336#[doc(hidden)]
337impl<'de> serde::de::Deserialize<'de> for OutputConfig {
338    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
339    where
340        D: serde::Deserializer<'de>,
341    {
342        #[allow(non_camel_case_types)]
343        #[doc(hidden)]
344        #[derive(PartialEq, Eq, Hash)]
345        enum __FieldTag {
346            __gcs_destination,
347            __data_format,
348            Unknown(std::string::String),
349        }
350        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
351            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
352            where
353                D: serde::Deserializer<'de>,
354            {
355                struct Visitor;
356                impl<'de> serde::de::Visitor<'de> for Visitor {
357                    type Value = __FieldTag;
358                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
359                        formatter.write_str("a field name for OutputConfig")
360                    }
361                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
362                    where
363                        E: serde::de::Error,
364                    {
365                        use std::result::Result::Ok;
366                        use std::string::ToString;
367                        match value {
368                            "gcsDestination" => Ok(__FieldTag::__gcs_destination),
369                            "gcs_destination" => Ok(__FieldTag::__gcs_destination),
370                            "dataFormat" => Ok(__FieldTag::__data_format),
371                            "data_format" => Ok(__FieldTag::__data_format),
372                            _ => Ok(__FieldTag::Unknown(value.to_string())),
373                        }
374                    }
375                }
376                deserializer.deserialize_identifier(Visitor)
377            }
378        }
379        struct Visitor;
380        impl<'de> serde::de::Visitor<'de> for Visitor {
381            type Value = OutputConfig;
382            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
383                formatter.write_str("struct OutputConfig")
384            }
385            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
386            where
387                A: serde::de::MapAccess<'de>,
388            {
389                #[allow(unused_imports)]
390                use serde::de::Error;
391                use std::option::Option::Some;
392                let mut fields = std::collections::HashSet::new();
393                let mut result = Self::Value::new();
394                while let Some(tag) = map.next_key::<__FieldTag>()? {
395                    #[allow(clippy::match_single_binding)]
396                    match tag {
397                        __FieldTag::__gcs_destination => {
398                            if !fields.insert(__FieldTag::__gcs_destination) {
399                                return std::result::Result::Err(A::Error::duplicate_field(
400                                    "multiple values for gcs_destination",
401                                ));
402                            }
403                            if result.destination.is_some() {
404                                return std::result::Result::Err(A::Error::duplicate_field(
405                                    "multiple values for `destination`, a oneof with full ID .google.cloud.optimization.v1.OutputConfig.gcs_destination, latest field was gcsDestination",
406                                ));
407                            }
408                            result.destination = std::option::Option::Some(
409                                crate::model::output_config::Destination::GcsDestination(
410                                    map.next_value::<std::option::Option<
411                                        std::boxed::Box<crate::model::GcsDestination>,
412                                    >>()?
413                                    .unwrap_or_default(),
414                                ),
415                            );
416                        }
417                        __FieldTag::__data_format => {
418                            if !fields.insert(__FieldTag::__data_format) {
419                                return std::result::Result::Err(A::Error::duplicate_field(
420                                    "multiple values for data_format",
421                                ));
422                            }
423                            result.data_format = map
424                                .next_value::<std::option::Option<crate::model::DataFormat>>()?
425                                .unwrap_or_default();
426                        }
427                        __FieldTag::Unknown(key) => {
428                            let value = map.next_value::<serde_json::Value>()?;
429                            result._unknown_fields.insert(key, value);
430                        }
431                    }
432                }
433                std::result::Result::Ok(result)
434            }
435        }
436        deserializer.deserialize_any(Visitor)
437    }
438}
439
440#[doc(hidden)]
441impl serde::ser::Serialize for OutputConfig {
442    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
443    where
444        S: serde::ser::Serializer,
445    {
446        use serde::ser::SerializeMap;
447        #[allow(unused_imports)]
448        use std::option::Option::Some;
449        let mut state = serializer.serialize_map(std::option::Option::None)?;
450        if let Some(value) = self.gcs_destination() {
451            state.serialize_entry("gcsDestination", value)?;
452        }
453        if !wkt::internal::is_default(&self.data_format) {
454            state.serialize_entry("dataFormat", &self.data_format)?;
455        }
456        if !self._unknown_fields.is_empty() {
457            for (key, value) in self._unknown_fields.iter() {
458                state.serialize_entry(key, &value)?;
459            }
460        }
461        state.end()
462    }
463}
464
465/// Defines additional types related to [OutputConfig].
466pub mod output_config {
467    #[allow(unused_imports)]
468    use super::*;
469
470    /// The location of the output result in cloud storage.
471    /// Required.
472    #[derive(Clone, Debug, PartialEq)]
473    #[non_exhaustive]
474    pub enum Destination {
475        /// The Google Cloud Storage location to write the output to.
476        GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
477    }
478}
479
480/// The Google Cloud Storage location where the input file will be read from.
481#[derive(Clone, Debug, Default, PartialEq)]
482#[non_exhaustive]
483pub struct GcsSource {
484    /// Required. URI of the Google Cloud Storage location.
485    pub uri: std::string::String,
486
487    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
488}
489
490impl GcsSource {
491    pub fn new() -> Self {
492        std::default::Default::default()
493    }
494
495    /// Sets the value of [uri][crate::model::GcsSource::uri].
496    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
497        self.uri = v.into();
498        self
499    }
500}
501
502impl wkt::message::Message for GcsSource {
503    fn typename() -> &'static str {
504        "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
505    }
506}
507
508#[doc(hidden)]
509impl<'de> serde::de::Deserialize<'de> for GcsSource {
510    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
511    where
512        D: serde::Deserializer<'de>,
513    {
514        #[allow(non_camel_case_types)]
515        #[doc(hidden)]
516        #[derive(PartialEq, Eq, Hash)]
517        enum __FieldTag {
518            __uri,
519            Unknown(std::string::String),
520        }
521        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
522            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
523            where
524                D: serde::Deserializer<'de>,
525            {
526                struct Visitor;
527                impl<'de> serde::de::Visitor<'de> for Visitor {
528                    type Value = __FieldTag;
529                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
530                        formatter.write_str("a field name for GcsSource")
531                    }
532                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
533                    where
534                        E: serde::de::Error,
535                    {
536                        use std::result::Result::Ok;
537                        use std::string::ToString;
538                        match value {
539                            "uri" => Ok(__FieldTag::__uri),
540                            _ => Ok(__FieldTag::Unknown(value.to_string())),
541                        }
542                    }
543                }
544                deserializer.deserialize_identifier(Visitor)
545            }
546        }
547        struct Visitor;
548        impl<'de> serde::de::Visitor<'de> for Visitor {
549            type Value = GcsSource;
550            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
551                formatter.write_str("struct GcsSource")
552            }
553            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
554            where
555                A: serde::de::MapAccess<'de>,
556            {
557                #[allow(unused_imports)]
558                use serde::de::Error;
559                use std::option::Option::Some;
560                let mut fields = std::collections::HashSet::new();
561                let mut result = Self::Value::new();
562                while let Some(tag) = map.next_key::<__FieldTag>()? {
563                    #[allow(clippy::match_single_binding)]
564                    match tag {
565                        __FieldTag::__uri => {
566                            if !fields.insert(__FieldTag::__uri) {
567                                return std::result::Result::Err(A::Error::duplicate_field(
568                                    "multiple values for uri",
569                                ));
570                            }
571                            result.uri = map
572                                .next_value::<std::option::Option<std::string::String>>()?
573                                .unwrap_or_default();
574                        }
575                        __FieldTag::Unknown(key) => {
576                            let value = map.next_value::<serde_json::Value>()?;
577                            result._unknown_fields.insert(key, value);
578                        }
579                    }
580                }
581                std::result::Result::Ok(result)
582            }
583        }
584        deserializer.deserialize_any(Visitor)
585    }
586}
587
588#[doc(hidden)]
589impl serde::ser::Serialize for GcsSource {
590    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
591    where
592        S: serde::ser::Serializer,
593    {
594        use serde::ser::SerializeMap;
595        #[allow(unused_imports)]
596        use std::option::Option::Some;
597        let mut state = serializer.serialize_map(std::option::Option::None)?;
598        if !self.uri.is_empty() {
599            state.serialize_entry("uri", &self.uri)?;
600        }
601        if !self._unknown_fields.is_empty() {
602            for (key, value) in self._unknown_fields.iter() {
603                state.serialize_entry(key, &value)?;
604            }
605        }
606        state.end()
607    }
608}
609
610/// The Google Cloud Storage location where the output file will be written to.
611#[derive(Clone, Debug, Default, PartialEq)]
612#[non_exhaustive]
613pub struct GcsDestination {
614    /// Required. URI of the Google Cloud Storage location.
615    pub uri: std::string::String,
616
617    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
618}
619
620impl GcsDestination {
621    pub fn new() -> Self {
622        std::default::Default::default()
623    }
624
625    /// Sets the value of [uri][crate::model::GcsDestination::uri].
626    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
627        self.uri = v.into();
628        self
629    }
630}
631
632impl wkt::message::Message for GcsDestination {
633    fn typename() -> &'static str {
634        "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
635    }
636}
637
638#[doc(hidden)]
639impl<'de> serde::de::Deserialize<'de> for GcsDestination {
640    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
641    where
642        D: serde::Deserializer<'de>,
643    {
644        #[allow(non_camel_case_types)]
645        #[doc(hidden)]
646        #[derive(PartialEq, Eq, Hash)]
647        enum __FieldTag {
648            __uri,
649            Unknown(std::string::String),
650        }
651        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
652            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
653            where
654                D: serde::Deserializer<'de>,
655            {
656                struct Visitor;
657                impl<'de> serde::de::Visitor<'de> for Visitor {
658                    type Value = __FieldTag;
659                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
660                        formatter.write_str("a field name for GcsDestination")
661                    }
662                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
663                    where
664                        E: serde::de::Error,
665                    {
666                        use std::result::Result::Ok;
667                        use std::string::ToString;
668                        match value {
669                            "uri" => Ok(__FieldTag::__uri),
670                            _ => Ok(__FieldTag::Unknown(value.to_string())),
671                        }
672                    }
673                }
674                deserializer.deserialize_identifier(Visitor)
675            }
676        }
677        struct Visitor;
678        impl<'de> serde::de::Visitor<'de> for Visitor {
679            type Value = GcsDestination;
680            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
681                formatter.write_str("struct GcsDestination")
682            }
683            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
684            where
685                A: serde::de::MapAccess<'de>,
686            {
687                #[allow(unused_imports)]
688                use serde::de::Error;
689                use std::option::Option::Some;
690                let mut fields = std::collections::HashSet::new();
691                let mut result = Self::Value::new();
692                while let Some(tag) = map.next_key::<__FieldTag>()? {
693                    #[allow(clippy::match_single_binding)]
694                    match tag {
695                        __FieldTag::__uri => {
696                            if !fields.insert(__FieldTag::__uri) {
697                                return std::result::Result::Err(A::Error::duplicate_field(
698                                    "multiple values for uri",
699                                ));
700                            }
701                            result.uri = map
702                                .next_value::<std::option::Option<std::string::String>>()?
703                                .unwrap_or_default();
704                        }
705                        __FieldTag::Unknown(key) => {
706                            let value = map.next_value::<serde_json::Value>()?;
707                            result._unknown_fields.insert(key, value);
708                        }
709                    }
710                }
711                std::result::Result::Ok(result)
712            }
713        }
714        deserializer.deserialize_any(Visitor)
715    }
716}
717
718#[doc(hidden)]
719impl serde::ser::Serialize for GcsDestination {
720    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
721    where
722        S: serde::ser::Serializer,
723    {
724        use serde::ser::SerializeMap;
725        #[allow(unused_imports)]
726        use std::option::Option::Some;
727        let mut state = serializer.serialize_map(std::option::Option::None)?;
728        if !self.uri.is_empty() {
729            state.serialize_entry("uri", &self.uri)?;
730        }
731        if !self._unknown_fields.is_empty() {
732            for (key, value) in self._unknown_fields.iter() {
733                state.serialize_entry(key, &value)?;
734            }
735        }
736        state.end()
737    }
738}
739
740/// The long running operation metadata for async model related methods.
741#[derive(Clone, Debug, Default, PartialEq)]
742#[non_exhaustive]
743pub struct AsyncModelMetadata {
744    /// The state of the current operation.
745    pub state: crate::model::async_model_metadata::State,
746
747    /// A message providing more details about the current state of the operation.
748    /// For example, the error message if the operation is failed.
749    pub state_message: std::string::String,
750
751    /// The creation time of the operation.
752    pub create_time: std::option::Option<wkt::Timestamp>,
753
754    /// The last update time of the operation.
755    pub update_time: std::option::Option<wkt::Timestamp>,
756
757    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
758}
759
760impl AsyncModelMetadata {
761    pub fn new() -> Self {
762        std::default::Default::default()
763    }
764
765    /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
766    pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
767        mut self,
768        v: T,
769    ) -> Self {
770        self.state = v.into();
771        self
772    }
773
774    /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
775    pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
776        self.state_message = v.into();
777        self
778    }
779
780    /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
781    pub fn set_create_time<T>(mut self, v: T) -> Self
782    where
783        T: std::convert::Into<wkt::Timestamp>,
784    {
785        self.create_time = std::option::Option::Some(v.into());
786        self
787    }
788
789    /// Sets or clears the value of [create_time][crate::model::AsyncModelMetadata::create_time].
790    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
791    where
792        T: std::convert::Into<wkt::Timestamp>,
793    {
794        self.create_time = v.map(|x| x.into());
795        self
796    }
797
798    /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
799    pub fn set_update_time<T>(mut self, v: T) -> Self
800    where
801        T: std::convert::Into<wkt::Timestamp>,
802    {
803        self.update_time = std::option::Option::Some(v.into());
804        self
805    }
806
807    /// Sets or clears the value of [update_time][crate::model::AsyncModelMetadata::update_time].
808    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
809    where
810        T: std::convert::Into<wkt::Timestamp>,
811    {
812        self.update_time = v.map(|x| x.into());
813        self
814    }
815}
816
817impl wkt::message::Message for AsyncModelMetadata {
818    fn typename() -> &'static str {
819        "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
820    }
821}
822
823#[doc(hidden)]
824impl<'de> serde::de::Deserialize<'de> for AsyncModelMetadata {
825    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
826    where
827        D: serde::Deserializer<'de>,
828    {
829        #[allow(non_camel_case_types)]
830        #[doc(hidden)]
831        #[derive(PartialEq, Eq, Hash)]
832        enum __FieldTag {
833            __state,
834            __state_message,
835            __create_time,
836            __update_time,
837            Unknown(std::string::String),
838        }
839        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
840            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
841            where
842                D: serde::Deserializer<'de>,
843            {
844                struct Visitor;
845                impl<'de> serde::de::Visitor<'de> for Visitor {
846                    type Value = __FieldTag;
847                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
848                        formatter.write_str("a field name for AsyncModelMetadata")
849                    }
850                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
851                    where
852                        E: serde::de::Error,
853                    {
854                        use std::result::Result::Ok;
855                        use std::string::ToString;
856                        match value {
857                            "state" => Ok(__FieldTag::__state),
858                            "stateMessage" => Ok(__FieldTag::__state_message),
859                            "state_message" => Ok(__FieldTag::__state_message),
860                            "createTime" => Ok(__FieldTag::__create_time),
861                            "create_time" => Ok(__FieldTag::__create_time),
862                            "updateTime" => Ok(__FieldTag::__update_time),
863                            "update_time" => Ok(__FieldTag::__update_time),
864                            _ => Ok(__FieldTag::Unknown(value.to_string())),
865                        }
866                    }
867                }
868                deserializer.deserialize_identifier(Visitor)
869            }
870        }
871        struct Visitor;
872        impl<'de> serde::de::Visitor<'de> for Visitor {
873            type Value = AsyncModelMetadata;
874            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
875                formatter.write_str("struct AsyncModelMetadata")
876            }
877            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
878            where
879                A: serde::de::MapAccess<'de>,
880            {
881                #[allow(unused_imports)]
882                use serde::de::Error;
883                use std::option::Option::Some;
884                let mut fields = std::collections::HashSet::new();
885                let mut result = Self::Value::new();
886                while let Some(tag) = map.next_key::<__FieldTag>()? {
887                    #[allow(clippy::match_single_binding)]
888                    match tag {
889                        __FieldTag::__state => {
890                            if !fields.insert(__FieldTag::__state) {
891                                return std::result::Result::Err(A::Error::duplicate_field(
892                                    "multiple values for state",
893                                ));
894                            }
895                            result.state = map.next_value::<std::option::Option<crate::model::async_model_metadata::State>>()?.unwrap_or_default();
896                        }
897                        __FieldTag::__state_message => {
898                            if !fields.insert(__FieldTag::__state_message) {
899                                return std::result::Result::Err(A::Error::duplicate_field(
900                                    "multiple values for state_message",
901                                ));
902                            }
903                            result.state_message = map
904                                .next_value::<std::option::Option<std::string::String>>()?
905                                .unwrap_or_default();
906                        }
907                        __FieldTag::__create_time => {
908                            if !fields.insert(__FieldTag::__create_time) {
909                                return std::result::Result::Err(A::Error::duplicate_field(
910                                    "multiple values for create_time",
911                                ));
912                            }
913                            result.create_time =
914                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
915                        }
916                        __FieldTag::__update_time => {
917                            if !fields.insert(__FieldTag::__update_time) {
918                                return std::result::Result::Err(A::Error::duplicate_field(
919                                    "multiple values for update_time",
920                                ));
921                            }
922                            result.update_time =
923                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
924                        }
925                        __FieldTag::Unknown(key) => {
926                            let value = map.next_value::<serde_json::Value>()?;
927                            result._unknown_fields.insert(key, value);
928                        }
929                    }
930                }
931                std::result::Result::Ok(result)
932            }
933        }
934        deserializer.deserialize_any(Visitor)
935    }
936}
937
938#[doc(hidden)]
939impl serde::ser::Serialize for AsyncModelMetadata {
940    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
941    where
942        S: serde::ser::Serializer,
943    {
944        use serde::ser::SerializeMap;
945        #[allow(unused_imports)]
946        use std::option::Option::Some;
947        let mut state = serializer.serialize_map(std::option::Option::None)?;
948        if !wkt::internal::is_default(&self.state) {
949            state.serialize_entry("state", &self.state)?;
950        }
951        if !self.state_message.is_empty() {
952            state.serialize_entry("stateMessage", &self.state_message)?;
953        }
954        if self.create_time.is_some() {
955            state.serialize_entry("createTime", &self.create_time)?;
956        }
957        if self.update_time.is_some() {
958            state.serialize_entry("updateTime", &self.update_time)?;
959        }
960        if !self._unknown_fields.is_empty() {
961            for (key, value) in self._unknown_fields.iter() {
962                state.serialize_entry(key, &value)?;
963            }
964        }
965        state.end()
966    }
967}
968
969/// Defines additional types related to [AsyncModelMetadata].
970pub mod async_model_metadata {
971    #[allow(unused_imports)]
972    use super::*;
973
974    /// Possible states of the operation.
975    ///
976    /// # Working with unknown values
977    ///
978    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
979    /// additional enum variants at any time. Adding new variants is not considered
980    /// a breaking change. Applications should write their code in anticipation of:
981    ///
982    /// - New values appearing in future releases of the client library, **and**
983    /// - New values received dynamically, without application changes.
984    ///
985    /// Please consult the [Working with enums] section in the user guide for some
986    /// guidelines.
987    ///
988    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
989    #[derive(Clone, Debug, PartialEq)]
990    #[non_exhaustive]
991    pub enum State {
992        /// The default value. This value is used if the state is omitted.
993        Unspecified,
994        /// Request is being processed.
995        Running,
996        /// The operation completed successfully.
997        Succeeded,
998        /// The operation was cancelled.
999        Cancelled,
1000        /// The operation has failed.
1001        Failed,
1002        /// If set, the enum was initialized with an unknown value.
1003        ///
1004        /// Applications can examine the value using [State::value] or
1005        /// [State::name].
1006        UnknownValue(state::UnknownValue),
1007    }
1008
1009    #[doc(hidden)]
1010    pub mod state {
1011        #[allow(unused_imports)]
1012        use super::*;
1013        #[derive(Clone, Debug, PartialEq)]
1014        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1015    }
1016
1017    impl State {
1018        /// Gets the enum value.
1019        ///
1020        /// Returns `None` if the enum contains an unknown value deserialized from
1021        /// the string representation of enums.
1022        pub fn value(&self) -> std::option::Option<i32> {
1023            match self {
1024                Self::Unspecified => std::option::Option::Some(0),
1025                Self::Running => std::option::Option::Some(1),
1026                Self::Succeeded => std::option::Option::Some(2),
1027                Self::Cancelled => std::option::Option::Some(3),
1028                Self::Failed => std::option::Option::Some(4),
1029                Self::UnknownValue(u) => u.0.value(),
1030            }
1031        }
1032
1033        /// Gets the enum value as a string.
1034        ///
1035        /// Returns `None` if the enum contains an unknown value deserialized from
1036        /// the integer representation of enums.
1037        pub fn name(&self) -> std::option::Option<&str> {
1038            match self {
1039                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1040                Self::Running => std::option::Option::Some("RUNNING"),
1041                Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
1042                Self::Cancelled => std::option::Option::Some("CANCELLED"),
1043                Self::Failed => std::option::Option::Some("FAILED"),
1044                Self::UnknownValue(u) => u.0.name(),
1045            }
1046        }
1047    }
1048
1049    impl std::default::Default for State {
1050        fn default() -> Self {
1051            use std::convert::From;
1052            Self::from(0)
1053        }
1054    }
1055
1056    impl std::fmt::Display for State {
1057        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1058            wkt::internal::display_enum(f, self.name(), self.value())
1059        }
1060    }
1061
1062    impl std::convert::From<i32> for State {
1063        fn from(value: i32) -> Self {
1064            match value {
1065                0 => Self::Unspecified,
1066                1 => Self::Running,
1067                2 => Self::Succeeded,
1068                3 => Self::Cancelled,
1069                4 => Self::Failed,
1070                _ => Self::UnknownValue(state::UnknownValue(
1071                    wkt::internal::UnknownEnumValue::Integer(value),
1072                )),
1073            }
1074        }
1075    }
1076
1077    impl std::convert::From<&str> for State {
1078        fn from(value: &str) -> Self {
1079            use std::string::ToString;
1080            match value {
1081                "STATE_UNSPECIFIED" => Self::Unspecified,
1082                "RUNNING" => Self::Running,
1083                "SUCCEEDED" => Self::Succeeded,
1084                "CANCELLED" => Self::Cancelled,
1085                "FAILED" => Self::Failed,
1086                _ => Self::UnknownValue(state::UnknownValue(
1087                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1088                )),
1089            }
1090        }
1091    }
1092
1093    impl serde::ser::Serialize for State {
1094        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1095        where
1096            S: serde::Serializer,
1097        {
1098            match self {
1099                Self::Unspecified => serializer.serialize_i32(0),
1100                Self::Running => serializer.serialize_i32(1),
1101                Self::Succeeded => serializer.serialize_i32(2),
1102                Self::Cancelled => serializer.serialize_i32(3),
1103                Self::Failed => serializer.serialize_i32(4),
1104                Self::UnknownValue(u) => u.0.serialize(serializer),
1105            }
1106        }
1107    }
1108
1109    impl<'de> serde::de::Deserialize<'de> for State {
1110        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1111        where
1112            D: serde::Deserializer<'de>,
1113        {
1114            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1115                ".google.cloud.optimization.v1.AsyncModelMetadata.State",
1116            ))
1117        }
1118    }
1119}
1120
1121/// Request to be given to a tour optimization solver which defines the
1122/// shipment model to solve as well as optimization parameters.
1123#[derive(Clone, Debug, Default, PartialEq)]
1124#[non_exhaustive]
1125pub struct OptimizeToursRequest {
1126    /// Required. Target project and location to make a call.
1127    ///
1128    /// Format: `projects/{project-id}/locations/{location-id}`.
1129    ///
1130    /// If no location is specified, a region will be chosen automatically.
1131    pub parent: std::string::String,
1132
1133    /// If this timeout is set, the server returns a response before the timeout
1134    /// period has elapsed or the server deadline for synchronous requests is
1135    /// reached, whichever is sooner.
1136    ///
1137    /// For asynchronous requests, the server will generate a solution (if
1138    /// possible) before the timeout has elapsed.
1139    pub timeout: std::option::Option<wkt::Duration>,
1140
1141    /// Shipment model to solve.
1142    pub model: std::option::Option<crate::model::ShipmentModel>,
1143
1144    /// By default, the solving mode is `DEFAULT_SOLVE` (0).
1145    pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
1146
1147    /// Search mode used to solve the request.
1148    pub search_mode: crate::model::optimize_tours_request::SearchMode,
1149
1150    /// Guide the optimization algorithm in finding a first solution that is
1151    /// similar to a previous solution.
1152    ///
1153    /// The model is constrained when the first solution is built.
1154    /// Any shipments not performed on a route are implicitly skipped in the first
1155    /// solution, but they may be performed in successive solutions.
1156    ///
1157    /// The solution must satisfy some basic validity assumptions:
1158    ///
1159    /// * for all routes, `vehicle_index` must be in range and not be duplicated.
1160    /// * for all visits, `shipment_index` and `visit_request_index` must be
1161    ///   in range.
1162    /// * a shipment may only be referenced on one route.
1163    /// * the pickup of a pickup-delivery shipment must be performed before
1164    ///   the delivery.
1165    /// * no more than one pickup alternative or delivery alternative of
1166    ///   a shipment may be performed.
1167    /// * for all routes, times are increasing (i.e., `vehicle_start_time
1168    ///   <= visits[0].start_time <= visits[1].start_time ...
1169    ///   <= vehicle_end_time`).
1170    /// * a shipment may only be performed on a vehicle that is allowed. A
1171    ///   vehicle is allowed if
1172    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
1173    ///   is empty or its `vehicle_index` is included in
1174    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
1175    ///
1176    /// If the injected solution is not feasible, a validation error is not
1177    /// necessarily returned and an error indicating infeasibility may be returned
1178    /// instead.
1179    ///
1180    /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
1181    pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
1182
1183    /// Constrain the optimization algorithm to find a final solution that is
1184    /// similar to a previous solution. For example, this may be used to freeze
1185    /// portions of routes which have already been completed or which are to be
1186    /// completed but must not be modified.
1187    ///
1188    /// If the injected solution is not feasible, a validation error is not
1189    /// necessarily returned and an error indicating infeasibility may be returned
1190    /// instead.
1191    pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
1192
1193    /// If non-empty, the given routes will be refreshed, without modifying their
1194    /// underlying sequence of visits or travel times: only other details will be
1195    /// updated. This does not solve the model.
1196    ///
1197    /// As of 2020/11, this only populates the polylines of non-empty routes and
1198    /// requires that `populate_polylines` is true.
1199    ///
1200    /// The `route_polyline` fields of the passed-in routes may be inconsistent
1201    /// with route `transitions`.
1202    ///
1203    /// This field must not be used together with `injected_first_solution_routes`
1204    /// or `injected_solution_constraint`.
1205    ///
1206    /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
1207    /// Polylines are still populated between all visits in all non-empty routes
1208    /// regardless of whether the related shipments or vehicles are ignored.
1209    pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
1210
1211    /// If true:
1212    ///
1213    /// * uses
1214    ///   [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
1215    ///   instead of `vehicle_index` to
1216    ///   match routes in an injected solution with vehicles in the request;
1217    ///   reuses the mapping of original
1218    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
1219    ///   to new
1220    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
1221    ///   to update
1222    ///   [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
1223    ///   if non-empty, but the mapping must be unambiguous (i.e., multiple
1224    ///   `ShipmentRoute`s must not share the same original `vehicle_index`).
1225    /// * uses
1226    ///   [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
1227    ///   instead of `shipment_index`
1228    ///   to match visits in an injected solution with shipments in the request;
1229    /// * uses
1230    ///   [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
1231    ///   instead of
1232    ///   [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
1233    ///   to
1234    ///   match skipped shipments in the injected solution with request
1235    ///   shipments.
1236    ///
1237    /// This interpretation applies to the `injected_first_solution_routes`,
1238    /// `injected_solution_constraint`, and `refresh_details_routes` fields.
1239    /// It can be used when shipment or vehicle indices in the request have
1240    /// changed since the solution was created, perhaps because shipments or
1241    /// vehicles have been removed from or added to the request.
1242    ///
1243    /// If true, labels in the following categories must appear at most once in
1244    /// their category:
1245    ///
1246    /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
1247    ///   request;
1248    /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
1249    ///   request;
1250    /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
1251    /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
1252    ///   the injected solution (except pickup/delivery visit pairs, whose
1253    ///   `shipment_label` must appear twice).
1254    ///
1255    /// If a `vehicle_label` in the injected solution does not correspond to a
1256    /// request vehicle, the corresponding route is removed from the solution
1257    /// along with its visits. If a `shipment_label` in the injected solution does
1258    /// not correspond to a request shipment, the corresponding visit is removed
1259    /// from the solution. If a
1260    /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
1261    /// in the injected solution does not correspond to a request shipment, the
1262    /// `SkippedShipment` is removed from the solution.
1263    ///
1264    /// Removing route visits or entire routes from an injected solution may
1265    /// have an effect on the implied constraints, which may lead to change in
1266    /// solution, validation errors, or infeasibility.
1267    ///
1268    /// NOTE: The caller must ensure that each
1269    /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
1270    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
1271    /// identifies a vehicle (resp. shipment) entity used across the two relevant
1272    /// requests: the past request that produced the `OptimizeToursResponse` used
1273    /// in the injected solution and the current request that includes the injected
1274    /// solution. The uniqueness checks described above are not enough to guarantee
1275    /// this requirement.
1276    ///
1277    /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
1278    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
1279    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
1280    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
1281    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
1282    /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
1283    /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
1284    /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
1285    pub interpret_injected_solutions_using_labels: bool,
1286
1287    /// Consider traffic estimation in calculating `ShipmentRoute` fields
1288    /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
1289    /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
1290    /// and `vehicle_end_time`; in setting the
1291    /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
1292    /// field, and in calculating the
1293    /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
1294    /// field.
1295    ///
1296    /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
1297    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
1298    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
1299    /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
1300    pub consider_road_traffic: bool,
1301
1302    /// If true, polylines will be populated in response `ShipmentRoute`s.
1303    pub populate_polylines: bool,
1304
1305    /// If true, polylines will be populated in response
1306    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
1307    /// Note that in this case, the polylines will also be populated in the
1308    /// deprecated `travel_steps`.
1309    ///
1310    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
1311    pub populate_transition_polylines: bool,
1312
1313    /// If this is set, then the request can have a deadline
1314    /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
1315    /// Otherwise, the maximum deadline is only 30 minutes.
1316    /// Note that long-lived requests have a significantly larger (but still small)
1317    /// risk of interruption.
1318    pub allow_large_deadline_despite_interruption_risk: bool,
1319
1320    /// If true, travel distances will be computed using geodesic distances instead
1321    /// of Google Maps distances, and travel times will be computed using geodesic
1322    /// distances with a speed defined by `geodesic_meters_per_second`.
1323    pub use_geodesic_distances: bool,
1324
1325    /// When `use_geodesic_distances` is true, this field must be set and defines
1326    /// the speed applied to compute travel times. Its value must be at least 1.0
1327    /// meters/seconds.
1328    pub geodesic_meters_per_second: std::option::Option<f64>,
1329
1330    /// Truncates the number of validation errors returned. These errors are
1331    /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
1332    /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
1333    /// unless solving_mode=VALIDATE_ONLY: see the
1334    /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1335    /// field.
1336    /// This defaults to 100 and is capped at 10,000.
1337    ///
1338    /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1339    pub max_validation_errors: std::option::Option<i32>,
1340
1341    /// Label that may be used to identify this request, reported back in the
1342    /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
1343    ///
1344    /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
1345    pub label: std::string::String,
1346
1347    /// Deprecated: Use
1348    /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
1349    /// instead. If true, polylines will be populated in response
1350    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
1351    /// Note that in this case, the polylines will also be populated in the
1352    /// deprecated `travel_steps`.
1353    ///
1354    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
1355    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
1356    #[deprecated]
1357    pub populate_travel_step_polylines: bool,
1358
1359    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1360}
1361
1362impl OptimizeToursRequest {
1363    pub fn new() -> Self {
1364        std::default::Default::default()
1365    }
1366
1367    /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
1368    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1369        self.parent = v.into();
1370        self
1371    }
1372
1373    /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
1374    pub fn set_timeout<T>(mut self, v: T) -> Self
1375    where
1376        T: std::convert::Into<wkt::Duration>,
1377    {
1378        self.timeout = std::option::Option::Some(v.into());
1379        self
1380    }
1381
1382    /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
1383    pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
1384    where
1385        T: std::convert::Into<wkt::Duration>,
1386    {
1387        self.timeout = v.map(|x| x.into());
1388        self
1389    }
1390
1391    /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
1392    pub fn set_model<T>(mut self, v: T) -> Self
1393    where
1394        T: std::convert::Into<crate::model::ShipmentModel>,
1395    {
1396        self.model = std::option::Option::Some(v.into());
1397        self
1398    }
1399
1400    /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
1401    pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
1402    where
1403        T: std::convert::Into<crate::model::ShipmentModel>,
1404    {
1405        self.model = v.map(|x| x.into());
1406        self
1407    }
1408
1409    /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
1410    pub fn set_solving_mode<
1411        T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
1412    >(
1413        mut self,
1414        v: T,
1415    ) -> Self {
1416        self.solving_mode = v.into();
1417        self
1418    }
1419
1420    /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
1421    pub fn set_search_mode<
1422        T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
1423    >(
1424        mut self,
1425        v: T,
1426    ) -> Self {
1427        self.search_mode = v.into();
1428        self
1429    }
1430
1431    /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
1432    pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
1433    where
1434        T: std::iter::IntoIterator<Item = V>,
1435        V: std::convert::Into<crate::model::ShipmentRoute>,
1436    {
1437        use std::iter::Iterator;
1438        self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
1439        self
1440    }
1441
1442    /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1443    pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
1444    where
1445        T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1446    {
1447        self.injected_solution_constraint = std::option::Option::Some(v.into());
1448        self
1449    }
1450
1451    /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1452    pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
1453    where
1454        T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1455    {
1456        self.injected_solution_constraint = v.map(|x| x.into());
1457        self
1458    }
1459
1460    /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
1461    pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
1462    where
1463        T: std::iter::IntoIterator<Item = V>,
1464        V: std::convert::Into<crate::model::ShipmentRoute>,
1465    {
1466        use std::iter::Iterator;
1467        self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
1468        self
1469    }
1470
1471    /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
1472    pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
1473        mut self,
1474        v: T,
1475    ) -> Self {
1476        self.interpret_injected_solutions_using_labels = v.into();
1477        self
1478    }
1479
1480    /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
1481    pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1482        self.consider_road_traffic = v.into();
1483        self
1484    }
1485
1486    /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
1487    pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1488        self.populate_polylines = v.into();
1489        self
1490    }
1491
1492    /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
1493    pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1494        self.populate_transition_polylines = v.into();
1495        self
1496    }
1497
1498    /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
1499    pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1500        mut self,
1501        v: T,
1502    ) -> Self {
1503        self.allow_large_deadline_despite_interruption_risk = v.into();
1504        self
1505    }
1506
1507    /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
1508    pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1509        self.use_geodesic_distances = v.into();
1510        self
1511    }
1512
1513    /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1514    pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1515    where
1516        T: std::convert::Into<f64>,
1517    {
1518        self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1519        self
1520    }
1521
1522    /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1523    pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1524    where
1525        T: std::convert::Into<f64>,
1526    {
1527        self.geodesic_meters_per_second = v.map(|x| x.into());
1528        self
1529    }
1530
1531    /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1532    pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1533    where
1534        T: std::convert::Into<i32>,
1535    {
1536        self.max_validation_errors = std::option::Option::Some(v.into());
1537        self
1538    }
1539
1540    /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1541    pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1542    where
1543        T: std::convert::Into<i32>,
1544    {
1545        self.max_validation_errors = v.map(|x| x.into());
1546        self
1547    }
1548
1549    /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
1550    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1551        self.label = v.into();
1552        self
1553    }
1554
1555    /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
1556    #[deprecated]
1557    pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1558        self.populate_travel_step_polylines = v.into();
1559        self
1560    }
1561}
1562
1563impl wkt::message::Message for OptimizeToursRequest {
1564    fn typename() -> &'static str {
1565        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
1566    }
1567}
1568
1569#[doc(hidden)]
1570impl<'de> serde::de::Deserialize<'de> for OptimizeToursRequest {
1571    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1572    where
1573        D: serde::Deserializer<'de>,
1574    {
1575        #[allow(non_camel_case_types)]
1576        #[doc(hidden)]
1577        #[derive(PartialEq, Eq, Hash)]
1578        enum __FieldTag {
1579            __parent,
1580            __timeout,
1581            __model,
1582            __solving_mode,
1583            __search_mode,
1584            __injected_first_solution_routes,
1585            __injected_solution_constraint,
1586            __refresh_details_routes,
1587            __interpret_injected_solutions_using_labels,
1588            __consider_road_traffic,
1589            __populate_polylines,
1590            __populate_transition_polylines,
1591            __allow_large_deadline_despite_interruption_risk,
1592            __use_geodesic_distances,
1593            __geodesic_meters_per_second,
1594            __max_validation_errors,
1595            __label,
1596            __populate_travel_step_polylines,
1597            Unknown(std::string::String),
1598        }
1599        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1600            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1601            where
1602                D: serde::Deserializer<'de>,
1603            {
1604                struct Visitor;
1605                impl<'de> serde::de::Visitor<'de> for Visitor {
1606                    type Value = __FieldTag;
1607                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1608                        formatter.write_str("a field name for OptimizeToursRequest")
1609                    }
1610                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1611                    where
1612                        E: serde::de::Error,
1613                    {
1614                        use std::result::Result::Ok;
1615                        use std::string::ToString;
1616                        match value {
1617                            "parent" => Ok(__FieldTag::__parent),
1618                            "timeout" => Ok(__FieldTag::__timeout),
1619                            "model" => Ok(__FieldTag::__model),
1620                            "solvingMode" => Ok(__FieldTag::__solving_mode),
1621                            "solving_mode" => Ok(__FieldTag::__solving_mode),
1622                            "searchMode" => Ok(__FieldTag::__search_mode),
1623                            "search_mode" => Ok(__FieldTag::__search_mode),
1624                            "injectedFirstSolutionRoutes" => {
1625                                Ok(__FieldTag::__injected_first_solution_routes)
1626                            }
1627                            "injected_first_solution_routes" => {
1628                                Ok(__FieldTag::__injected_first_solution_routes)
1629                            }
1630                            "injectedSolutionConstraint" => {
1631                                Ok(__FieldTag::__injected_solution_constraint)
1632                            }
1633                            "injected_solution_constraint" => {
1634                                Ok(__FieldTag::__injected_solution_constraint)
1635                            }
1636                            "refreshDetailsRoutes" => Ok(__FieldTag::__refresh_details_routes),
1637                            "refresh_details_routes" => Ok(__FieldTag::__refresh_details_routes),
1638                            "interpretInjectedSolutionsUsingLabels" => {
1639                                Ok(__FieldTag::__interpret_injected_solutions_using_labels)
1640                            }
1641                            "interpret_injected_solutions_using_labels" => {
1642                                Ok(__FieldTag::__interpret_injected_solutions_using_labels)
1643                            }
1644                            "considerRoadTraffic" => Ok(__FieldTag::__consider_road_traffic),
1645                            "consider_road_traffic" => Ok(__FieldTag::__consider_road_traffic),
1646                            "populatePolylines" => Ok(__FieldTag::__populate_polylines),
1647                            "populate_polylines" => Ok(__FieldTag::__populate_polylines),
1648                            "populateTransitionPolylines" => {
1649                                Ok(__FieldTag::__populate_transition_polylines)
1650                            }
1651                            "populate_transition_polylines" => {
1652                                Ok(__FieldTag::__populate_transition_polylines)
1653                            }
1654                            "allowLargeDeadlineDespiteInterruptionRisk" => {
1655                                Ok(__FieldTag::__allow_large_deadline_despite_interruption_risk)
1656                            }
1657                            "allow_large_deadline_despite_interruption_risk" => {
1658                                Ok(__FieldTag::__allow_large_deadline_despite_interruption_risk)
1659                            }
1660                            "useGeodesicDistances" => Ok(__FieldTag::__use_geodesic_distances),
1661                            "use_geodesic_distances" => Ok(__FieldTag::__use_geodesic_distances),
1662                            "geodesicMetersPerSecond" => {
1663                                Ok(__FieldTag::__geodesic_meters_per_second)
1664                            }
1665                            "geodesic_meters_per_second" => {
1666                                Ok(__FieldTag::__geodesic_meters_per_second)
1667                            }
1668                            "maxValidationErrors" => Ok(__FieldTag::__max_validation_errors),
1669                            "max_validation_errors" => Ok(__FieldTag::__max_validation_errors),
1670                            "label" => Ok(__FieldTag::__label),
1671                            "populateTravelStepPolylines" => {
1672                                Ok(__FieldTag::__populate_travel_step_polylines)
1673                            }
1674                            "populate_travel_step_polylines" => {
1675                                Ok(__FieldTag::__populate_travel_step_polylines)
1676                            }
1677                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1678                        }
1679                    }
1680                }
1681                deserializer.deserialize_identifier(Visitor)
1682            }
1683        }
1684        struct Visitor;
1685        impl<'de> serde::de::Visitor<'de> for Visitor {
1686            type Value = OptimizeToursRequest;
1687            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1688                formatter.write_str("struct OptimizeToursRequest")
1689            }
1690            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1691            where
1692                A: serde::de::MapAccess<'de>,
1693            {
1694                #[allow(unused_imports)]
1695                use serde::de::Error;
1696                use std::option::Option::Some;
1697                let mut fields = std::collections::HashSet::new();
1698                let mut result = Self::Value::new();
1699                while let Some(tag) = map.next_key::<__FieldTag>()? {
1700                    #[allow(clippy::match_single_binding)]
1701                    match tag {
1702                        __FieldTag::__parent => {
1703                            if !fields.insert(__FieldTag::__parent) {
1704                                return std::result::Result::Err(A::Error::duplicate_field(
1705                                    "multiple values for parent",
1706                                ));
1707                            }
1708                            result.parent = map
1709                                .next_value::<std::option::Option<std::string::String>>()?
1710                                .unwrap_or_default();
1711                        }
1712                        __FieldTag::__timeout => {
1713                            if !fields.insert(__FieldTag::__timeout) {
1714                                return std::result::Result::Err(A::Error::duplicate_field(
1715                                    "multiple values for timeout",
1716                                ));
1717                            }
1718                            result.timeout =
1719                                map.next_value::<std::option::Option<wkt::Duration>>()?;
1720                        }
1721                        __FieldTag::__model => {
1722                            if !fields.insert(__FieldTag::__model) {
1723                                return std::result::Result::Err(A::Error::duplicate_field(
1724                                    "multiple values for model",
1725                                ));
1726                            }
1727                            result.model = map
1728                                .next_value::<std::option::Option<crate::model::ShipmentModel>>()?;
1729                        }
1730                        __FieldTag::__solving_mode => {
1731                            if !fields.insert(__FieldTag::__solving_mode) {
1732                                return std::result::Result::Err(A::Error::duplicate_field(
1733                                    "multiple values for solving_mode",
1734                                ));
1735                            }
1736                            result.solving_mode = map
1737                                .next_value::<std::option::Option<
1738                                    crate::model::optimize_tours_request::SolvingMode,
1739                                >>()?
1740                                .unwrap_or_default();
1741                        }
1742                        __FieldTag::__search_mode => {
1743                            if !fields.insert(__FieldTag::__search_mode) {
1744                                return std::result::Result::Err(A::Error::duplicate_field(
1745                                    "multiple values for search_mode",
1746                                ));
1747                            }
1748                            result.search_mode = map
1749                                .next_value::<std::option::Option<
1750                                    crate::model::optimize_tours_request::SearchMode,
1751                                >>()?
1752                                .unwrap_or_default();
1753                        }
1754                        __FieldTag::__injected_first_solution_routes => {
1755                            if !fields.insert(__FieldTag::__injected_first_solution_routes) {
1756                                return std::result::Result::Err(A::Error::duplicate_field(
1757                                    "multiple values for injected_first_solution_routes",
1758                                ));
1759                            }
1760                            result.injected_first_solution_routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
1761                        }
1762                        __FieldTag::__injected_solution_constraint => {
1763                            if !fields.insert(__FieldTag::__injected_solution_constraint) {
1764                                return std::result::Result::Err(A::Error::duplicate_field(
1765                                    "multiple values for injected_solution_constraint",
1766                                ));
1767                            }
1768                            result.injected_solution_constraint = map.next_value::<std::option::Option<crate::model::InjectedSolutionConstraint>>()?
1769                                ;
1770                        }
1771                        __FieldTag::__refresh_details_routes => {
1772                            if !fields.insert(__FieldTag::__refresh_details_routes) {
1773                                return std::result::Result::Err(A::Error::duplicate_field(
1774                                    "multiple values for refresh_details_routes",
1775                                ));
1776                            }
1777                            result.refresh_details_routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
1778                        }
1779                        __FieldTag::__interpret_injected_solutions_using_labels => {
1780                            if !fields
1781                                .insert(__FieldTag::__interpret_injected_solutions_using_labels)
1782                            {
1783                                return std::result::Result::Err(A::Error::duplicate_field(
1784                                    "multiple values for interpret_injected_solutions_using_labels",
1785                                ));
1786                            }
1787                            result.interpret_injected_solutions_using_labels = map
1788                                .next_value::<std::option::Option<bool>>()?
1789                                .unwrap_or_default();
1790                        }
1791                        __FieldTag::__consider_road_traffic => {
1792                            if !fields.insert(__FieldTag::__consider_road_traffic) {
1793                                return std::result::Result::Err(A::Error::duplicate_field(
1794                                    "multiple values for consider_road_traffic",
1795                                ));
1796                            }
1797                            result.consider_road_traffic = map
1798                                .next_value::<std::option::Option<bool>>()?
1799                                .unwrap_or_default();
1800                        }
1801                        __FieldTag::__populate_polylines => {
1802                            if !fields.insert(__FieldTag::__populate_polylines) {
1803                                return std::result::Result::Err(A::Error::duplicate_field(
1804                                    "multiple values for populate_polylines",
1805                                ));
1806                            }
1807                            result.populate_polylines = map
1808                                .next_value::<std::option::Option<bool>>()?
1809                                .unwrap_or_default();
1810                        }
1811                        __FieldTag::__populate_transition_polylines => {
1812                            if !fields.insert(__FieldTag::__populate_transition_polylines) {
1813                                return std::result::Result::Err(A::Error::duplicate_field(
1814                                    "multiple values for populate_transition_polylines",
1815                                ));
1816                            }
1817                            result.populate_transition_polylines = map
1818                                .next_value::<std::option::Option<bool>>()?
1819                                .unwrap_or_default();
1820                        }
1821                        __FieldTag::__allow_large_deadline_despite_interruption_risk => {
1822                            if !fields.insert(
1823                                __FieldTag::__allow_large_deadline_despite_interruption_risk,
1824                            ) {
1825                                return std::result::Result::Err(A::Error::duplicate_field(
1826                                    "multiple values for allow_large_deadline_despite_interruption_risk",
1827                                ));
1828                            }
1829                            result.allow_large_deadline_despite_interruption_risk = map
1830                                .next_value::<std::option::Option<bool>>()?
1831                                .unwrap_or_default();
1832                        }
1833                        __FieldTag::__use_geodesic_distances => {
1834                            if !fields.insert(__FieldTag::__use_geodesic_distances) {
1835                                return std::result::Result::Err(A::Error::duplicate_field(
1836                                    "multiple values for use_geodesic_distances",
1837                                ));
1838                            }
1839                            result.use_geodesic_distances = map
1840                                .next_value::<std::option::Option<bool>>()?
1841                                .unwrap_or_default();
1842                        }
1843                        __FieldTag::__geodesic_meters_per_second => {
1844                            if !fields.insert(__FieldTag::__geodesic_meters_per_second) {
1845                                return std::result::Result::Err(A::Error::duplicate_field(
1846                                    "multiple values for geodesic_meters_per_second",
1847                                ));
1848                            }
1849                            struct __With(std::option::Option<f64>);
1850                            impl<'de> serde::de::Deserialize<'de> for __With {
1851                                fn deserialize<D>(
1852                                    deserializer: D,
1853                                ) -> std::result::Result<Self, D::Error>
1854                                where
1855                                    D: serde::de::Deserializer<'de>,
1856                                {
1857                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1858                                }
1859                            }
1860                            result.geodesic_meters_per_second = map.next_value::<__With>()?.0;
1861                        }
1862                        __FieldTag::__max_validation_errors => {
1863                            if !fields.insert(__FieldTag::__max_validation_errors) {
1864                                return std::result::Result::Err(A::Error::duplicate_field(
1865                                    "multiple values for max_validation_errors",
1866                                ));
1867                            }
1868                            struct __With(std::option::Option<i32>);
1869                            impl<'de> serde::de::Deserialize<'de> for __With {
1870                                fn deserialize<D>(
1871                                    deserializer: D,
1872                                ) -> std::result::Result<Self, D::Error>
1873                                where
1874                                    D: serde::de::Deserializer<'de>,
1875                                {
1876                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1877                                }
1878                            }
1879                            result.max_validation_errors = map.next_value::<__With>()?.0;
1880                        }
1881                        __FieldTag::__label => {
1882                            if !fields.insert(__FieldTag::__label) {
1883                                return std::result::Result::Err(A::Error::duplicate_field(
1884                                    "multiple values for label",
1885                                ));
1886                            }
1887                            result.label = map
1888                                .next_value::<std::option::Option<std::string::String>>()?
1889                                .unwrap_or_default();
1890                        }
1891                        __FieldTag::__populate_travel_step_polylines => {
1892                            if !fields.insert(__FieldTag::__populate_travel_step_polylines) {
1893                                return std::result::Result::Err(A::Error::duplicate_field(
1894                                    "multiple values for populate_travel_step_polylines",
1895                                ));
1896                            }
1897                            result.populate_travel_step_polylines = map
1898                                .next_value::<std::option::Option<bool>>()?
1899                                .unwrap_or_default();
1900                        }
1901                        __FieldTag::Unknown(key) => {
1902                            let value = map.next_value::<serde_json::Value>()?;
1903                            result._unknown_fields.insert(key, value);
1904                        }
1905                    }
1906                }
1907                std::result::Result::Ok(result)
1908            }
1909        }
1910        deserializer.deserialize_any(Visitor)
1911    }
1912}
1913
1914#[doc(hidden)]
1915impl serde::ser::Serialize for OptimizeToursRequest {
1916    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1917    where
1918        S: serde::ser::Serializer,
1919    {
1920        use serde::ser::SerializeMap;
1921        #[allow(unused_imports)]
1922        use std::option::Option::Some;
1923        let mut state = serializer.serialize_map(std::option::Option::None)?;
1924        if !self.parent.is_empty() {
1925            state.serialize_entry("parent", &self.parent)?;
1926        }
1927        if self.timeout.is_some() {
1928            state.serialize_entry("timeout", &self.timeout)?;
1929        }
1930        if self.model.is_some() {
1931            state.serialize_entry("model", &self.model)?;
1932        }
1933        if !wkt::internal::is_default(&self.solving_mode) {
1934            state.serialize_entry("solvingMode", &self.solving_mode)?;
1935        }
1936        if !wkt::internal::is_default(&self.search_mode) {
1937            state.serialize_entry("searchMode", &self.search_mode)?;
1938        }
1939        if !self.injected_first_solution_routes.is_empty() {
1940            state.serialize_entry(
1941                "injectedFirstSolutionRoutes",
1942                &self.injected_first_solution_routes,
1943            )?;
1944        }
1945        if self.injected_solution_constraint.is_some() {
1946            state.serialize_entry(
1947                "injectedSolutionConstraint",
1948                &self.injected_solution_constraint,
1949            )?;
1950        }
1951        if !self.refresh_details_routes.is_empty() {
1952            state.serialize_entry("refreshDetailsRoutes", &self.refresh_details_routes)?;
1953        }
1954        if !wkt::internal::is_default(&self.interpret_injected_solutions_using_labels) {
1955            state.serialize_entry(
1956                "interpretInjectedSolutionsUsingLabels",
1957                &self.interpret_injected_solutions_using_labels,
1958            )?;
1959        }
1960        if !wkt::internal::is_default(&self.consider_road_traffic) {
1961            state.serialize_entry("considerRoadTraffic", &self.consider_road_traffic)?;
1962        }
1963        if !wkt::internal::is_default(&self.populate_polylines) {
1964            state.serialize_entry("populatePolylines", &self.populate_polylines)?;
1965        }
1966        if !wkt::internal::is_default(&self.populate_transition_polylines) {
1967            state.serialize_entry(
1968                "populateTransitionPolylines",
1969                &self.populate_transition_polylines,
1970            )?;
1971        }
1972        if !wkt::internal::is_default(&self.allow_large_deadline_despite_interruption_risk) {
1973            state.serialize_entry(
1974                "allowLargeDeadlineDespiteInterruptionRisk",
1975                &self.allow_large_deadline_despite_interruption_risk,
1976            )?;
1977        }
1978        if !wkt::internal::is_default(&self.use_geodesic_distances) {
1979            state.serialize_entry("useGeodesicDistances", &self.use_geodesic_distances)?;
1980        }
1981        if self.geodesic_meters_per_second.is_some() {
1982            struct __With<'a>(&'a std::option::Option<f64>);
1983            impl<'a> serde::ser::Serialize for __With<'a> {
1984                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1985                where
1986                    S: serde::ser::Serializer,
1987                {
1988                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
1989                        self.0, serializer,
1990                    )
1991                }
1992            }
1993            state.serialize_entry(
1994                "geodesicMetersPerSecond",
1995                &__With(&self.geodesic_meters_per_second),
1996            )?;
1997        }
1998        if self.max_validation_errors.is_some() {
1999            struct __With<'a>(&'a std::option::Option<i32>);
2000            impl<'a> serde::ser::Serialize for __With<'a> {
2001                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2002                where
2003                    S: serde::ser::Serializer,
2004                {
2005                    serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
2006                        self.0, serializer,
2007                    )
2008                }
2009            }
2010            state.serialize_entry("maxValidationErrors", &__With(&self.max_validation_errors))?;
2011        }
2012        if !self.label.is_empty() {
2013            state.serialize_entry("label", &self.label)?;
2014        }
2015        if !wkt::internal::is_default(&self.populate_travel_step_polylines) {
2016            state.serialize_entry(
2017                "populateTravelStepPolylines",
2018                &self.populate_travel_step_polylines,
2019            )?;
2020        }
2021        if !self._unknown_fields.is_empty() {
2022            for (key, value) in self._unknown_fields.iter() {
2023                state.serialize_entry(key, &value)?;
2024            }
2025        }
2026        state.end()
2027    }
2028}
2029
2030/// Defines additional types related to [OptimizeToursRequest].
2031pub mod optimize_tours_request {
2032    #[allow(unused_imports)]
2033    use super::*;
2034
2035    /// Defines how the solver should handle the request. In all modes but
2036    /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
2037    /// `INVALID_REQUEST` error. See
2038    /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
2039    /// to cap the number of errors returned.
2040    ///
2041    /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
2042    ///
2043    /// # Working with unknown values
2044    ///
2045    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2046    /// additional enum variants at any time. Adding new variants is not considered
2047    /// a breaking change. Applications should write their code in anticipation of:
2048    ///
2049    /// - New values appearing in future releases of the client library, **and**
2050    /// - New values received dynamically, without application changes.
2051    ///
2052    /// Please consult the [Working with enums] section in the user guide for some
2053    /// guidelines.
2054    ///
2055    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2056    #[derive(Clone, Debug, PartialEq)]
2057    #[non_exhaustive]
2058    pub enum SolvingMode {
2059        /// Solve the model.
2060        DefaultSolve,
2061        /// Only validates the model without solving it: populates as many
2062        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
2063        /// as possible.
2064        ///
2065        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
2066        ValidateOnly,
2067        /// Only populates
2068        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
2069        /// or
2070        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
2071        /// and doesn't actually solve the rest of the request (`status` and `routes`
2072        /// are unset in the response).
2073        /// If infeasibilities in `injected_solution_constraint` routes are detected
2074        /// they are populated in the
2075        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
2076        /// field and
2077        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
2078        /// is left empty.
2079        ///
2080        /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
2081        /// ones that are detected as infeasible during preprocessing.
2082        ///
2083        /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
2084        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
2085        DetectSomeInfeasibleShipments,
2086        /// If set, the enum was initialized with an unknown value.
2087        ///
2088        /// Applications can examine the value using [SolvingMode::value] or
2089        /// [SolvingMode::name].
2090        UnknownValue(solving_mode::UnknownValue),
2091    }
2092
2093    #[doc(hidden)]
2094    pub mod solving_mode {
2095        #[allow(unused_imports)]
2096        use super::*;
2097        #[derive(Clone, Debug, PartialEq)]
2098        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2099    }
2100
2101    impl SolvingMode {
2102        /// Gets the enum value.
2103        ///
2104        /// Returns `None` if the enum contains an unknown value deserialized from
2105        /// the string representation of enums.
2106        pub fn value(&self) -> std::option::Option<i32> {
2107            match self {
2108                Self::DefaultSolve => std::option::Option::Some(0),
2109                Self::ValidateOnly => std::option::Option::Some(1),
2110                Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
2111                Self::UnknownValue(u) => u.0.value(),
2112            }
2113        }
2114
2115        /// Gets the enum value as a string.
2116        ///
2117        /// Returns `None` if the enum contains an unknown value deserialized from
2118        /// the integer representation of enums.
2119        pub fn name(&self) -> std::option::Option<&str> {
2120            match self {
2121                Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
2122                Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
2123                Self::DetectSomeInfeasibleShipments => {
2124                    std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
2125                }
2126                Self::UnknownValue(u) => u.0.name(),
2127            }
2128        }
2129    }
2130
2131    impl std::default::Default for SolvingMode {
2132        fn default() -> Self {
2133            use std::convert::From;
2134            Self::from(0)
2135        }
2136    }
2137
2138    impl std::fmt::Display for SolvingMode {
2139        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2140            wkt::internal::display_enum(f, self.name(), self.value())
2141        }
2142    }
2143
2144    impl std::convert::From<i32> for SolvingMode {
2145        fn from(value: i32) -> Self {
2146            match value {
2147                0 => Self::DefaultSolve,
2148                1 => Self::ValidateOnly,
2149                2 => Self::DetectSomeInfeasibleShipments,
2150                _ => Self::UnknownValue(solving_mode::UnknownValue(
2151                    wkt::internal::UnknownEnumValue::Integer(value),
2152                )),
2153            }
2154        }
2155    }
2156
2157    impl std::convert::From<&str> for SolvingMode {
2158        fn from(value: &str) -> Self {
2159            use std::string::ToString;
2160            match value {
2161                "DEFAULT_SOLVE" => Self::DefaultSolve,
2162                "VALIDATE_ONLY" => Self::ValidateOnly,
2163                "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
2164                _ => Self::UnknownValue(solving_mode::UnknownValue(
2165                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2166                )),
2167            }
2168        }
2169    }
2170
2171    impl serde::ser::Serialize for SolvingMode {
2172        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2173        where
2174            S: serde::Serializer,
2175        {
2176            match self {
2177                Self::DefaultSolve => serializer.serialize_i32(0),
2178                Self::ValidateOnly => serializer.serialize_i32(1),
2179                Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
2180                Self::UnknownValue(u) => u.0.serialize(serializer),
2181            }
2182        }
2183    }
2184
2185    impl<'de> serde::de::Deserialize<'de> for SolvingMode {
2186        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2187        where
2188            D: serde::Deserializer<'de>,
2189        {
2190            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
2191                ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
2192            ))
2193        }
2194    }
2195
2196    /// Mode defining the behavior of the search, trading off latency versus
2197    /// solution quality. In all modes, the global request deadline is enforced.
2198    ///
2199    /// # Working with unknown values
2200    ///
2201    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2202    /// additional enum variants at any time. Adding new variants is not considered
2203    /// a breaking change. Applications should write their code in anticipation of:
2204    ///
2205    /// - New values appearing in future releases of the client library, **and**
2206    /// - New values received dynamically, without application changes.
2207    ///
2208    /// Please consult the [Working with enums] section in the user guide for some
2209    /// guidelines.
2210    ///
2211    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2212    #[derive(Clone, Debug, PartialEq)]
2213    #[non_exhaustive]
2214    pub enum SearchMode {
2215        /// Unspecified search mode, equivalent to `RETURN_FAST`.
2216        Unspecified,
2217        /// Stop the search after finding the first good solution.
2218        ReturnFast,
2219        /// Spend all the available time to search for better solutions.
2220        ConsumeAllAvailableTime,
2221        /// If set, the enum was initialized with an unknown value.
2222        ///
2223        /// Applications can examine the value using [SearchMode::value] or
2224        /// [SearchMode::name].
2225        UnknownValue(search_mode::UnknownValue),
2226    }
2227
2228    #[doc(hidden)]
2229    pub mod search_mode {
2230        #[allow(unused_imports)]
2231        use super::*;
2232        #[derive(Clone, Debug, PartialEq)]
2233        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2234    }
2235
2236    impl SearchMode {
2237        /// Gets the enum value.
2238        ///
2239        /// Returns `None` if the enum contains an unknown value deserialized from
2240        /// the string representation of enums.
2241        pub fn value(&self) -> std::option::Option<i32> {
2242            match self {
2243                Self::Unspecified => std::option::Option::Some(0),
2244                Self::ReturnFast => std::option::Option::Some(1),
2245                Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
2246                Self::UnknownValue(u) => u.0.value(),
2247            }
2248        }
2249
2250        /// Gets the enum value as a string.
2251        ///
2252        /// Returns `None` if the enum contains an unknown value deserialized from
2253        /// the integer representation of enums.
2254        pub fn name(&self) -> std::option::Option<&str> {
2255            match self {
2256                Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
2257                Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
2258                Self::ConsumeAllAvailableTime => {
2259                    std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
2260                }
2261                Self::UnknownValue(u) => u.0.name(),
2262            }
2263        }
2264    }
2265
2266    impl std::default::Default for SearchMode {
2267        fn default() -> Self {
2268            use std::convert::From;
2269            Self::from(0)
2270        }
2271    }
2272
2273    impl std::fmt::Display for SearchMode {
2274        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2275            wkt::internal::display_enum(f, self.name(), self.value())
2276        }
2277    }
2278
2279    impl std::convert::From<i32> for SearchMode {
2280        fn from(value: i32) -> Self {
2281            match value {
2282                0 => Self::Unspecified,
2283                1 => Self::ReturnFast,
2284                2 => Self::ConsumeAllAvailableTime,
2285                _ => Self::UnknownValue(search_mode::UnknownValue(
2286                    wkt::internal::UnknownEnumValue::Integer(value),
2287                )),
2288            }
2289        }
2290    }
2291
2292    impl std::convert::From<&str> for SearchMode {
2293        fn from(value: &str) -> Self {
2294            use std::string::ToString;
2295            match value {
2296                "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
2297                "RETURN_FAST" => Self::ReturnFast,
2298                "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
2299                _ => Self::UnknownValue(search_mode::UnknownValue(
2300                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2301                )),
2302            }
2303        }
2304    }
2305
2306    impl serde::ser::Serialize for SearchMode {
2307        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2308        where
2309            S: serde::Serializer,
2310        {
2311            match self {
2312                Self::Unspecified => serializer.serialize_i32(0),
2313                Self::ReturnFast => serializer.serialize_i32(1),
2314                Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
2315                Self::UnknownValue(u) => u.0.serialize(serializer),
2316            }
2317        }
2318    }
2319
2320    impl<'de> serde::de::Deserialize<'de> for SearchMode {
2321        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2322        where
2323            D: serde::Deserializer<'de>,
2324        {
2325            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
2326                ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
2327            ))
2328        }
2329    }
2330}
2331
2332/// Response after solving a tour optimization problem containing the routes
2333/// followed by each vehicle, the shipments which have been skipped and the
2334/// overall cost of the solution.
2335#[derive(Clone, Debug, Default, PartialEq)]
2336#[non_exhaustive]
2337pub struct OptimizeToursResponse {
2338    /// Routes computed for each vehicle; the i-th route corresponds to the i-th
2339    /// vehicle in the model.
2340    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
2341
2342    /// Copy of the
2343    /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
2344    /// if a label was specified in the request.
2345    ///
2346    /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
2347    pub request_label: std::string::String,
2348
2349    /// The list of all shipments skipped.
2350    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
2351
2352    /// List of all the validation errors that we were able to detect
2353    /// independently. See the "MULTIPLE ERRORS" explanation for the
2354    /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
2355    /// message.
2356    ///
2357    /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
2358    pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
2359
2360    /// Duration, distance and usage metrics for this solution.
2361    pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
2362
2363    /// Deprecated: Use
2364    /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
2365    /// instead. Total cost of the solution. This takes into account all costs:
2366    /// costs per per hour and travel hour, fixed vehicle costs, unperformed
2367    /// shipment penalty costs, global duration cost, etc.
2368    ///
2369    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
2370    #[deprecated]
2371    pub total_cost: f64,
2372
2373    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2374}
2375
2376impl OptimizeToursResponse {
2377    pub fn new() -> Self {
2378        std::default::Default::default()
2379    }
2380
2381    /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
2382    pub fn set_routes<T, V>(mut self, v: T) -> Self
2383    where
2384        T: std::iter::IntoIterator<Item = V>,
2385        V: std::convert::Into<crate::model::ShipmentRoute>,
2386    {
2387        use std::iter::Iterator;
2388        self.routes = v.into_iter().map(|i| i.into()).collect();
2389        self
2390    }
2391
2392    /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
2393    pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2394        self.request_label = v.into();
2395        self
2396    }
2397
2398    /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
2399    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
2400    where
2401        T: std::iter::IntoIterator<Item = V>,
2402        V: std::convert::Into<crate::model::SkippedShipment>,
2403    {
2404        use std::iter::Iterator;
2405        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
2406        self
2407    }
2408
2409    /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
2410    pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
2411    where
2412        T: std::iter::IntoIterator<Item = V>,
2413        V: std::convert::Into<crate::model::OptimizeToursValidationError>,
2414    {
2415        use std::iter::Iterator;
2416        self.validation_errors = v.into_iter().map(|i| i.into()).collect();
2417        self
2418    }
2419
2420    /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
2421    pub fn set_metrics<T>(mut self, v: T) -> Self
2422    where
2423        T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
2424    {
2425        self.metrics = std::option::Option::Some(v.into());
2426        self
2427    }
2428
2429    /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
2430    pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
2431    where
2432        T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
2433    {
2434        self.metrics = v.map(|x| x.into());
2435        self
2436    }
2437
2438    /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
2439    #[deprecated]
2440    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2441        self.total_cost = v.into();
2442        self
2443    }
2444}
2445
2446impl wkt::message::Message for OptimizeToursResponse {
2447    fn typename() -> &'static str {
2448        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
2449    }
2450}
2451
2452#[doc(hidden)]
2453impl<'de> serde::de::Deserialize<'de> for OptimizeToursResponse {
2454    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2455    where
2456        D: serde::Deserializer<'de>,
2457    {
2458        #[allow(non_camel_case_types)]
2459        #[doc(hidden)]
2460        #[derive(PartialEq, Eq, Hash)]
2461        enum __FieldTag {
2462            __routes,
2463            __request_label,
2464            __skipped_shipments,
2465            __validation_errors,
2466            __metrics,
2467            __total_cost,
2468            Unknown(std::string::String),
2469        }
2470        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2471            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2472            where
2473                D: serde::Deserializer<'de>,
2474            {
2475                struct Visitor;
2476                impl<'de> serde::de::Visitor<'de> for Visitor {
2477                    type Value = __FieldTag;
2478                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2479                        formatter.write_str("a field name for OptimizeToursResponse")
2480                    }
2481                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2482                    where
2483                        E: serde::de::Error,
2484                    {
2485                        use std::result::Result::Ok;
2486                        use std::string::ToString;
2487                        match value {
2488                            "routes" => Ok(__FieldTag::__routes),
2489                            "requestLabel" => Ok(__FieldTag::__request_label),
2490                            "request_label" => Ok(__FieldTag::__request_label),
2491                            "skippedShipments" => Ok(__FieldTag::__skipped_shipments),
2492                            "skipped_shipments" => Ok(__FieldTag::__skipped_shipments),
2493                            "validationErrors" => Ok(__FieldTag::__validation_errors),
2494                            "validation_errors" => Ok(__FieldTag::__validation_errors),
2495                            "metrics" => Ok(__FieldTag::__metrics),
2496                            "totalCost" => Ok(__FieldTag::__total_cost),
2497                            "total_cost" => Ok(__FieldTag::__total_cost),
2498                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2499                        }
2500                    }
2501                }
2502                deserializer.deserialize_identifier(Visitor)
2503            }
2504        }
2505        struct Visitor;
2506        impl<'de> serde::de::Visitor<'de> for Visitor {
2507            type Value = OptimizeToursResponse;
2508            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2509                formatter.write_str("struct OptimizeToursResponse")
2510            }
2511            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2512            where
2513                A: serde::de::MapAccess<'de>,
2514            {
2515                #[allow(unused_imports)]
2516                use serde::de::Error;
2517                use std::option::Option::Some;
2518                let mut fields = std::collections::HashSet::new();
2519                let mut result = Self::Value::new();
2520                while let Some(tag) = map.next_key::<__FieldTag>()? {
2521                    #[allow(clippy::match_single_binding)]
2522                    match tag {
2523                        __FieldTag::__routes => {
2524                            if !fields.insert(__FieldTag::__routes) {
2525                                return std::result::Result::Err(A::Error::duplicate_field(
2526                                    "multiple values for routes",
2527                                ));
2528                            }
2529                            result.routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
2530                        }
2531                        __FieldTag::__request_label => {
2532                            if !fields.insert(__FieldTag::__request_label) {
2533                                return std::result::Result::Err(A::Error::duplicate_field(
2534                                    "multiple values for request_label",
2535                                ));
2536                            }
2537                            result.request_label = map
2538                                .next_value::<std::option::Option<std::string::String>>()?
2539                                .unwrap_or_default();
2540                        }
2541                        __FieldTag::__skipped_shipments => {
2542                            if !fields.insert(__FieldTag::__skipped_shipments) {
2543                                return std::result::Result::Err(A::Error::duplicate_field(
2544                                    "multiple values for skipped_shipments",
2545                                ));
2546                            }
2547                            result.skipped_shipments =
2548                                map.next_value::<std::option::Option<
2549                                    std::vec::Vec<crate::model::SkippedShipment>,
2550                                >>()?
2551                                .unwrap_or_default();
2552                        }
2553                        __FieldTag::__validation_errors => {
2554                            if !fields.insert(__FieldTag::__validation_errors) {
2555                                return std::result::Result::Err(A::Error::duplicate_field(
2556                                    "multiple values for validation_errors",
2557                                ));
2558                            }
2559                            result.validation_errors = map
2560                                .next_value::<std::option::Option<
2561                                    std::vec::Vec<crate::model::OptimizeToursValidationError>,
2562                                >>()?
2563                                .unwrap_or_default();
2564                        }
2565                        __FieldTag::__metrics => {
2566                            if !fields.insert(__FieldTag::__metrics) {
2567                                return std::result::Result::Err(A::Error::duplicate_field(
2568                                    "multiple values for metrics",
2569                                ));
2570                            }
2571                            result.metrics = map.next_value::<std::option::Option<
2572                                crate::model::optimize_tours_response::Metrics,
2573                            >>()?;
2574                        }
2575                        __FieldTag::__total_cost => {
2576                            if !fields.insert(__FieldTag::__total_cost) {
2577                                return std::result::Result::Err(A::Error::duplicate_field(
2578                                    "multiple values for total_cost",
2579                                ));
2580                            }
2581                            struct __With(std::option::Option<f64>);
2582                            impl<'de> serde::de::Deserialize<'de> for __With {
2583                                fn deserialize<D>(
2584                                    deserializer: D,
2585                                ) -> std::result::Result<Self, D::Error>
2586                                where
2587                                    D: serde::de::Deserializer<'de>,
2588                                {
2589                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
2590                                }
2591                            }
2592                            result.total_cost = map.next_value::<__With>()?.0.unwrap_or_default();
2593                        }
2594                        __FieldTag::Unknown(key) => {
2595                            let value = map.next_value::<serde_json::Value>()?;
2596                            result._unknown_fields.insert(key, value);
2597                        }
2598                    }
2599                }
2600                std::result::Result::Ok(result)
2601            }
2602        }
2603        deserializer.deserialize_any(Visitor)
2604    }
2605}
2606
2607#[doc(hidden)]
2608impl serde::ser::Serialize for OptimizeToursResponse {
2609    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2610    where
2611        S: serde::ser::Serializer,
2612    {
2613        use serde::ser::SerializeMap;
2614        #[allow(unused_imports)]
2615        use std::option::Option::Some;
2616        let mut state = serializer.serialize_map(std::option::Option::None)?;
2617        if !self.routes.is_empty() {
2618            state.serialize_entry("routes", &self.routes)?;
2619        }
2620        if !self.request_label.is_empty() {
2621            state.serialize_entry("requestLabel", &self.request_label)?;
2622        }
2623        if !self.skipped_shipments.is_empty() {
2624            state.serialize_entry("skippedShipments", &self.skipped_shipments)?;
2625        }
2626        if !self.validation_errors.is_empty() {
2627            state.serialize_entry("validationErrors", &self.validation_errors)?;
2628        }
2629        if self.metrics.is_some() {
2630            state.serialize_entry("metrics", &self.metrics)?;
2631        }
2632        if !wkt::internal::is_default(&self.total_cost) {
2633            struct __With<'a>(&'a f64);
2634            impl<'a> serde::ser::Serialize for __With<'a> {
2635                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2636                where
2637                    S: serde::ser::Serializer,
2638                {
2639                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2640                }
2641            }
2642            state.serialize_entry("totalCost", &__With(&self.total_cost))?;
2643        }
2644        if !self._unknown_fields.is_empty() {
2645            for (key, value) in self._unknown_fields.iter() {
2646                state.serialize_entry(key, &value)?;
2647            }
2648        }
2649        state.end()
2650    }
2651}
2652
2653/// Defines additional types related to [OptimizeToursResponse].
2654pub mod optimize_tours_response {
2655    #[allow(unused_imports)]
2656    use super::*;
2657
2658    /// Overall metrics, aggregated over all routes.
2659    #[derive(Clone, Debug, Default, PartialEq)]
2660    #[non_exhaustive]
2661    pub struct Metrics {
2662        /// Aggregated over the routes. Each metric is the sum (or max, for loads)
2663        /// over all
2664        /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
2665        /// fields of the same name.
2666        ///
2667        /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
2668        pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
2669
2670        /// Number of mandatory shipments skipped.
2671        pub skipped_mandatory_shipment_count: i32,
2672
2673        /// Number of vehicles used. Note: if a vehicle route is empty and
2674        /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
2675        /// is true, the vehicle is considered used.
2676        ///
2677        /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
2678        pub used_vehicle_count: i32,
2679
2680        /// The earliest start time for a used vehicle, computed as the minimum over
2681        /// all used vehicles of
2682        /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
2683        ///
2684        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
2685        pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
2686
2687        /// The latest end time for a used vehicle, computed as the maximum over all
2688        /// used vehicles of
2689        /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
2690        ///
2691        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
2692        pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
2693
2694        /// Cost of the solution, broken down by cost-related request fields.
2695        /// The keys are proto paths, relative to the input OptimizeToursRequest,
2696        /// e.g. "model.shipments.pickups.cost", and the values are the total cost
2697        /// generated by the corresponding cost field, aggregated over the whole
2698        /// solution. In other words, costs["model.shipments.pickups.cost"] is the
2699        /// sum of all pickup costs over the solution. All costs defined in the model
2700        /// are reported in detail here with the exception of costs related to
2701        /// TransitionAttributes that are only reported in an aggregated way as of
2702        /// 2022/01.
2703        pub costs: std::collections::HashMap<std::string::String, f64>,
2704
2705        /// Total cost of the solution. The sum of all values in the costs map.
2706        pub total_cost: f64,
2707
2708        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2709    }
2710
2711    impl Metrics {
2712        pub fn new() -> Self {
2713            std::default::Default::default()
2714        }
2715
2716        /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
2717        pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
2718        where
2719            T: std::convert::Into<crate::model::AggregatedMetrics>,
2720        {
2721            self.aggregated_route_metrics = std::option::Option::Some(v.into());
2722            self
2723        }
2724
2725        /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
2726        pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
2727        where
2728            T: std::convert::Into<crate::model::AggregatedMetrics>,
2729        {
2730            self.aggregated_route_metrics = v.map(|x| x.into());
2731            self
2732        }
2733
2734        /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
2735        pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
2736            mut self,
2737            v: T,
2738        ) -> Self {
2739            self.skipped_mandatory_shipment_count = v.into();
2740            self
2741        }
2742
2743        /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
2744        pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2745            self.used_vehicle_count = v.into();
2746            self
2747        }
2748
2749        /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
2750        pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
2751        where
2752            T: std::convert::Into<wkt::Timestamp>,
2753        {
2754            self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
2755            self
2756        }
2757
2758        /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
2759        pub fn set_or_clear_earliest_vehicle_start_time<T>(
2760            mut self,
2761            v: std::option::Option<T>,
2762        ) -> Self
2763        where
2764            T: std::convert::Into<wkt::Timestamp>,
2765        {
2766            self.earliest_vehicle_start_time = v.map(|x| x.into());
2767            self
2768        }
2769
2770        /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
2771        pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
2772        where
2773            T: std::convert::Into<wkt::Timestamp>,
2774        {
2775            self.latest_vehicle_end_time = std::option::Option::Some(v.into());
2776            self
2777        }
2778
2779        /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
2780        pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2781        where
2782            T: std::convert::Into<wkt::Timestamp>,
2783        {
2784            self.latest_vehicle_end_time = v.map(|x| x.into());
2785            self
2786        }
2787
2788        /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
2789        pub fn set_costs<T, K, V>(mut self, v: T) -> Self
2790        where
2791            T: std::iter::IntoIterator<Item = (K, V)>,
2792            K: std::convert::Into<std::string::String>,
2793            V: std::convert::Into<f64>,
2794        {
2795            use std::iter::Iterator;
2796            self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2797            self
2798        }
2799
2800        /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
2801        pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2802            self.total_cost = v.into();
2803            self
2804        }
2805    }
2806
2807    impl wkt::message::Message for Metrics {
2808        fn typename() -> &'static str {
2809            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
2810        }
2811    }
2812
2813    #[doc(hidden)]
2814    impl<'de> serde::de::Deserialize<'de> for Metrics {
2815        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2816        where
2817            D: serde::Deserializer<'de>,
2818        {
2819            #[allow(non_camel_case_types)]
2820            #[doc(hidden)]
2821            #[derive(PartialEq, Eq, Hash)]
2822            enum __FieldTag {
2823                __aggregated_route_metrics,
2824                __skipped_mandatory_shipment_count,
2825                __used_vehicle_count,
2826                __earliest_vehicle_start_time,
2827                __latest_vehicle_end_time,
2828                __costs,
2829                __total_cost,
2830                Unknown(std::string::String),
2831            }
2832            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2833                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2834                where
2835                    D: serde::Deserializer<'de>,
2836                {
2837                    struct Visitor;
2838                    impl<'de> serde::de::Visitor<'de> for Visitor {
2839                        type Value = __FieldTag;
2840                        fn expecting(
2841                            &self,
2842                            formatter: &mut std::fmt::Formatter,
2843                        ) -> std::fmt::Result {
2844                            formatter.write_str("a field name for Metrics")
2845                        }
2846                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2847                        where
2848                            E: serde::de::Error,
2849                        {
2850                            use std::result::Result::Ok;
2851                            use std::string::ToString;
2852                            match value {
2853                                "aggregatedRouteMetrics" => {
2854                                    Ok(__FieldTag::__aggregated_route_metrics)
2855                                }
2856                                "aggregated_route_metrics" => {
2857                                    Ok(__FieldTag::__aggregated_route_metrics)
2858                                }
2859                                "skippedMandatoryShipmentCount" => {
2860                                    Ok(__FieldTag::__skipped_mandatory_shipment_count)
2861                                }
2862                                "skipped_mandatory_shipment_count" => {
2863                                    Ok(__FieldTag::__skipped_mandatory_shipment_count)
2864                                }
2865                                "usedVehicleCount" => Ok(__FieldTag::__used_vehicle_count),
2866                                "used_vehicle_count" => Ok(__FieldTag::__used_vehicle_count),
2867                                "earliestVehicleStartTime" => {
2868                                    Ok(__FieldTag::__earliest_vehicle_start_time)
2869                                }
2870                                "earliest_vehicle_start_time" => {
2871                                    Ok(__FieldTag::__earliest_vehicle_start_time)
2872                                }
2873                                "latestVehicleEndTime" => Ok(__FieldTag::__latest_vehicle_end_time),
2874                                "latest_vehicle_end_time" => {
2875                                    Ok(__FieldTag::__latest_vehicle_end_time)
2876                                }
2877                                "costs" => Ok(__FieldTag::__costs),
2878                                "totalCost" => Ok(__FieldTag::__total_cost),
2879                                "total_cost" => Ok(__FieldTag::__total_cost),
2880                                _ => Ok(__FieldTag::Unknown(value.to_string())),
2881                            }
2882                        }
2883                    }
2884                    deserializer.deserialize_identifier(Visitor)
2885                }
2886            }
2887            struct Visitor;
2888            impl<'de> serde::de::Visitor<'de> for Visitor {
2889                type Value = Metrics;
2890                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2891                    formatter.write_str("struct Metrics")
2892                }
2893                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2894                where
2895                    A: serde::de::MapAccess<'de>,
2896                {
2897                    #[allow(unused_imports)]
2898                    use serde::de::Error;
2899                    use std::option::Option::Some;
2900                    let mut fields = std::collections::HashSet::new();
2901                    let mut result = Self::Value::new();
2902                    while let Some(tag) = map.next_key::<__FieldTag>()? {
2903                        #[allow(clippy::match_single_binding)]
2904                        match tag {
2905                            __FieldTag::__aggregated_route_metrics => {
2906                                if !fields.insert(__FieldTag::__aggregated_route_metrics) {
2907                                    return std::result::Result::Err(A::Error::duplicate_field(
2908                                        "multiple values for aggregated_route_metrics",
2909                                    ));
2910                                }
2911                                result.aggregated_route_metrics = map.next_value::<std::option::Option<crate::model::AggregatedMetrics>>()?
2912                                    ;
2913                            }
2914                            __FieldTag::__skipped_mandatory_shipment_count => {
2915                                if !fields.insert(__FieldTag::__skipped_mandatory_shipment_count) {
2916                                    return std::result::Result::Err(A::Error::duplicate_field(
2917                                        "multiple values for skipped_mandatory_shipment_count",
2918                                    ));
2919                                }
2920                                struct __With(std::option::Option<i32>);
2921                                impl<'de> serde::de::Deserialize<'de> for __With {
2922                                    fn deserialize<D>(
2923                                        deserializer: D,
2924                                    ) -> std::result::Result<Self, D::Error>
2925                                    where
2926                                        D: serde::de::Deserializer<'de>,
2927                                    {
2928                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2929                                    }
2930                                }
2931                                result.skipped_mandatory_shipment_count =
2932                                    map.next_value::<__With>()?.0.unwrap_or_default();
2933                            }
2934                            __FieldTag::__used_vehicle_count => {
2935                                if !fields.insert(__FieldTag::__used_vehicle_count) {
2936                                    return std::result::Result::Err(A::Error::duplicate_field(
2937                                        "multiple values for used_vehicle_count",
2938                                    ));
2939                                }
2940                                struct __With(std::option::Option<i32>);
2941                                impl<'de> serde::de::Deserialize<'de> for __With {
2942                                    fn deserialize<D>(
2943                                        deserializer: D,
2944                                    ) -> std::result::Result<Self, D::Error>
2945                                    where
2946                                        D: serde::de::Deserializer<'de>,
2947                                    {
2948                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2949                                    }
2950                                }
2951                                result.used_vehicle_count =
2952                                    map.next_value::<__With>()?.0.unwrap_or_default();
2953                            }
2954                            __FieldTag::__earliest_vehicle_start_time => {
2955                                if !fields.insert(__FieldTag::__earliest_vehicle_start_time) {
2956                                    return std::result::Result::Err(A::Error::duplicate_field(
2957                                        "multiple values for earliest_vehicle_start_time",
2958                                    ));
2959                                }
2960                                result.earliest_vehicle_start_time =
2961                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2962                            }
2963                            __FieldTag::__latest_vehicle_end_time => {
2964                                if !fields.insert(__FieldTag::__latest_vehicle_end_time) {
2965                                    return std::result::Result::Err(A::Error::duplicate_field(
2966                                        "multiple values for latest_vehicle_end_time",
2967                                    ));
2968                                }
2969                                result.latest_vehicle_end_time =
2970                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2971                            }
2972                            __FieldTag::__costs => {
2973                                if !fields.insert(__FieldTag::__costs) {
2974                                    return std::result::Result::Err(A::Error::duplicate_field(
2975                                        "multiple values for costs",
2976                                    ));
2977                                }
2978                                struct __With(
2979                                    std::option::Option<
2980                                        std::collections::HashMap<std::string::String, f64>,
2981                                    >,
2982                                );
2983                                impl<'de> serde::de::Deserialize<'de> for __With {
2984                                    fn deserialize<D>(
2985                                        deserializer: D,
2986                                    ) -> std::result::Result<Self, D::Error>
2987                                    where
2988                                        D: serde::de::Deserializer<'de>,
2989                                    {
2990                                        serde_with::As::<
2991                                            std::option::Option<
2992                                                std::collections::HashMap<
2993                                                    serde_with::Same,
2994                                                    wkt::internal::F64,
2995                                                >,
2996                                            >,
2997                                        >::deserialize(
2998                                            deserializer
2999                                        )
3000                                        .map(__With)
3001                                    }
3002                                }
3003                                result.costs = map.next_value::<__With>()?.0.unwrap_or_default();
3004                            }
3005                            __FieldTag::__total_cost => {
3006                                if !fields.insert(__FieldTag::__total_cost) {
3007                                    return std::result::Result::Err(A::Error::duplicate_field(
3008                                        "multiple values for total_cost",
3009                                    ));
3010                                }
3011                                struct __With(std::option::Option<f64>);
3012                                impl<'de> serde::de::Deserialize<'de> for __With {
3013                                    fn deserialize<D>(
3014                                        deserializer: D,
3015                                    ) -> std::result::Result<Self, D::Error>
3016                                    where
3017                                        D: serde::de::Deserializer<'de>,
3018                                    {
3019                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
3020                                    }
3021                                }
3022                                result.total_cost =
3023                                    map.next_value::<__With>()?.0.unwrap_or_default();
3024                            }
3025                            __FieldTag::Unknown(key) => {
3026                                let value = map.next_value::<serde_json::Value>()?;
3027                                result._unknown_fields.insert(key, value);
3028                            }
3029                        }
3030                    }
3031                    std::result::Result::Ok(result)
3032                }
3033            }
3034            deserializer.deserialize_any(Visitor)
3035        }
3036    }
3037
3038    #[doc(hidden)]
3039    impl serde::ser::Serialize for Metrics {
3040        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3041        where
3042            S: serde::ser::Serializer,
3043        {
3044            use serde::ser::SerializeMap;
3045            #[allow(unused_imports)]
3046            use std::option::Option::Some;
3047            let mut state = serializer.serialize_map(std::option::Option::None)?;
3048            if self.aggregated_route_metrics.is_some() {
3049                state.serialize_entry("aggregatedRouteMetrics", &self.aggregated_route_metrics)?;
3050            }
3051            if !wkt::internal::is_default(&self.skipped_mandatory_shipment_count) {
3052                struct __With<'a>(&'a i32);
3053                impl<'a> serde::ser::Serialize for __With<'a> {
3054                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3055                    where
3056                        S: serde::ser::Serializer,
3057                    {
3058                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3059                    }
3060                }
3061                state.serialize_entry(
3062                    "skippedMandatoryShipmentCount",
3063                    &__With(&self.skipped_mandatory_shipment_count),
3064                )?;
3065            }
3066            if !wkt::internal::is_default(&self.used_vehicle_count) {
3067                struct __With<'a>(&'a i32);
3068                impl<'a> serde::ser::Serialize for __With<'a> {
3069                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3070                    where
3071                        S: serde::ser::Serializer,
3072                    {
3073                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3074                    }
3075                }
3076                state.serialize_entry("usedVehicleCount", &__With(&self.used_vehicle_count))?;
3077            }
3078            if self.earliest_vehicle_start_time.is_some() {
3079                state.serialize_entry(
3080                    "earliestVehicleStartTime",
3081                    &self.earliest_vehicle_start_time,
3082                )?;
3083            }
3084            if self.latest_vehicle_end_time.is_some() {
3085                state.serialize_entry("latestVehicleEndTime", &self.latest_vehicle_end_time)?;
3086            }
3087            if !self.costs.is_empty() {
3088                struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
3089                impl<'a> serde::ser::Serialize for __With<'a> {
3090                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3091                    where
3092                        S: serde::ser::Serializer,
3093                    {
3094                        serde_with::As::<
3095                            std::collections::HashMap<serde_with::Same, wkt::internal::F64>,
3096                        >::serialize(self.0, serializer)
3097                    }
3098                }
3099                state.serialize_entry("costs", &__With(&self.costs))?;
3100            }
3101            if !wkt::internal::is_default(&self.total_cost) {
3102                struct __With<'a>(&'a f64);
3103                impl<'a> serde::ser::Serialize for __With<'a> {
3104                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3105                    where
3106                        S: serde::ser::Serializer,
3107                    {
3108                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
3109                    }
3110                }
3111                state.serialize_entry("totalCost", &__With(&self.total_cost))?;
3112            }
3113            if !self._unknown_fields.is_empty() {
3114                for (key, value) in self._unknown_fields.iter() {
3115                    state.serialize_entry(key, &value)?;
3116                }
3117            }
3118            state.end()
3119        }
3120    }
3121}
3122
3123/// Request to batch optimize tours as an asynchronous operation.
3124/// Each input file should contain one `OptimizeToursRequest`, and each output
3125/// file will contain one `OptimizeToursResponse`. The request contains
3126/// information to read/write and parse the files. All the input and output files
3127/// should be under the same project.
3128#[derive(Clone, Debug, Default, PartialEq)]
3129#[non_exhaustive]
3130pub struct BatchOptimizeToursRequest {
3131    /// Required. Target project and location to make a call.
3132    ///
3133    /// Format: `projects/{project-id}/locations/{location-id}`.
3134    ///
3135    /// If no location is specified, a region will be chosen automatically.
3136    pub parent: std::string::String,
3137
3138    /// Required. Input/Output information each purchase model, such as file paths
3139    /// and data formats.
3140    pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
3141
3142    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3143}
3144
3145impl BatchOptimizeToursRequest {
3146    pub fn new() -> Self {
3147        std::default::Default::default()
3148    }
3149
3150    /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
3151    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3152        self.parent = v.into();
3153        self
3154    }
3155
3156    /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
3157    pub fn set_model_configs<T, V>(mut self, v: T) -> Self
3158    where
3159        T: std::iter::IntoIterator<Item = V>,
3160        V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
3161    {
3162        use std::iter::Iterator;
3163        self.model_configs = v.into_iter().map(|i| i.into()).collect();
3164        self
3165    }
3166}
3167
3168impl wkt::message::Message for BatchOptimizeToursRequest {
3169    fn typename() -> &'static str {
3170        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
3171    }
3172}
3173
3174#[doc(hidden)]
3175impl<'de> serde::de::Deserialize<'de> for BatchOptimizeToursRequest {
3176    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3177    where
3178        D: serde::Deserializer<'de>,
3179    {
3180        #[allow(non_camel_case_types)]
3181        #[doc(hidden)]
3182        #[derive(PartialEq, Eq, Hash)]
3183        enum __FieldTag {
3184            __parent,
3185            __model_configs,
3186            Unknown(std::string::String),
3187        }
3188        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3189            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3190            where
3191                D: serde::Deserializer<'de>,
3192            {
3193                struct Visitor;
3194                impl<'de> serde::de::Visitor<'de> for Visitor {
3195                    type Value = __FieldTag;
3196                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3197                        formatter.write_str("a field name for BatchOptimizeToursRequest")
3198                    }
3199                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3200                    where
3201                        E: serde::de::Error,
3202                    {
3203                        use std::result::Result::Ok;
3204                        use std::string::ToString;
3205                        match value {
3206                            "parent" => Ok(__FieldTag::__parent),
3207                            "modelConfigs" => Ok(__FieldTag::__model_configs),
3208                            "model_configs" => Ok(__FieldTag::__model_configs),
3209                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3210                        }
3211                    }
3212                }
3213                deserializer.deserialize_identifier(Visitor)
3214            }
3215        }
3216        struct Visitor;
3217        impl<'de> serde::de::Visitor<'de> for Visitor {
3218            type Value = BatchOptimizeToursRequest;
3219            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3220                formatter.write_str("struct BatchOptimizeToursRequest")
3221            }
3222            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3223            where
3224                A: serde::de::MapAccess<'de>,
3225            {
3226                #[allow(unused_imports)]
3227                use serde::de::Error;
3228                use std::option::Option::Some;
3229                let mut fields = std::collections::HashSet::new();
3230                let mut result = Self::Value::new();
3231                while let Some(tag) = map.next_key::<__FieldTag>()? {
3232                    #[allow(clippy::match_single_binding)]
3233                    match tag {
3234                        __FieldTag::__parent => {
3235                            if !fields.insert(__FieldTag::__parent) {
3236                                return std::result::Result::Err(A::Error::duplicate_field(
3237                                    "multiple values for parent",
3238                                ));
3239                            }
3240                            result.parent = map
3241                                .next_value::<std::option::Option<std::string::String>>()?
3242                                .unwrap_or_default();
3243                        }
3244                        __FieldTag::__model_configs => {
3245                            if !fields.insert(__FieldTag::__model_configs) {
3246                                return std::result::Result::Err(A::Error::duplicate_field(
3247                                    "multiple values for model_configs",
3248                                ));
3249                            }
3250                            result.model_configs = map.next_value::<std::option::Option<std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>>>()?.unwrap_or_default();
3251                        }
3252                        __FieldTag::Unknown(key) => {
3253                            let value = map.next_value::<serde_json::Value>()?;
3254                            result._unknown_fields.insert(key, value);
3255                        }
3256                    }
3257                }
3258                std::result::Result::Ok(result)
3259            }
3260        }
3261        deserializer.deserialize_any(Visitor)
3262    }
3263}
3264
3265#[doc(hidden)]
3266impl serde::ser::Serialize for BatchOptimizeToursRequest {
3267    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3268    where
3269        S: serde::ser::Serializer,
3270    {
3271        use serde::ser::SerializeMap;
3272        #[allow(unused_imports)]
3273        use std::option::Option::Some;
3274        let mut state = serializer.serialize_map(std::option::Option::None)?;
3275        if !self.parent.is_empty() {
3276            state.serialize_entry("parent", &self.parent)?;
3277        }
3278        if !self.model_configs.is_empty() {
3279            state.serialize_entry("modelConfigs", &self.model_configs)?;
3280        }
3281        if !self._unknown_fields.is_empty() {
3282            for (key, value) in self._unknown_fields.iter() {
3283                state.serialize_entry(key, &value)?;
3284            }
3285        }
3286        state.end()
3287    }
3288}
3289
3290/// Defines additional types related to [BatchOptimizeToursRequest].
3291pub mod batch_optimize_tours_request {
3292    #[allow(unused_imports)]
3293    use super::*;
3294
3295    /// Information for solving one optimization model asynchronously.
3296    #[derive(Clone, Debug, Default, PartialEq)]
3297    #[non_exhaustive]
3298    pub struct AsyncModelConfig {
3299        /// User defined model name, can be used as alias by users to keep track of
3300        /// models.
3301        pub display_name: std::string::String,
3302
3303        /// Required. Information about the input model.
3304        pub input_config: std::option::Option<crate::model::InputConfig>,
3305
3306        /// Required. The desired output location information.
3307        pub output_config: std::option::Option<crate::model::OutputConfig>,
3308
3309        /// If this is set, the model will be solved in the checkpoint mode. In this
3310        /// mode, the input model can have a deadline longer than 30 mins without the
3311        /// risk of interruption. The model will be solved in multiple short-running
3312        /// stages. Each stage generates an intermediate checkpoint
3313        /// and stores it in the user's Cloud Storage buckets. The checkpoint
3314        /// mode should be preferred over
3315        /// allow_large_deadline_despite_interruption_risk since it prevents the risk
3316        /// of interruption.
3317        pub enable_checkpoints: bool,
3318
3319        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3320    }
3321
3322    impl AsyncModelConfig {
3323        pub fn new() -> Self {
3324            std::default::Default::default()
3325        }
3326
3327        /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
3328        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
3329            mut self,
3330            v: T,
3331        ) -> Self {
3332            self.display_name = v.into();
3333            self
3334        }
3335
3336        /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
3337        pub fn set_input_config<T>(mut self, v: T) -> Self
3338        where
3339            T: std::convert::Into<crate::model::InputConfig>,
3340        {
3341            self.input_config = std::option::Option::Some(v.into());
3342            self
3343        }
3344
3345        /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
3346        pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
3347        where
3348            T: std::convert::Into<crate::model::InputConfig>,
3349        {
3350            self.input_config = v.map(|x| x.into());
3351            self
3352        }
3353
3354        /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
3355        pub fn set_output_config<T>(mut self, v: T) -> Self
3356        where
3357            T: std::convert::Into<crate::model::OutputConfig>,
3358        {
3359            self.output_config = std::option::Option::Some(v.into());
3360            self
3361        }
3362
3363        /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
3364        pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
3365        where
3366            T: std::convert::Into<crate::model::OutputConfig>,
3367        {
3368            self.output_config = v.map(|x| x.into());
3369            self
3370        }
3371
3372        /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
3373        pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3374            self.enable_checkpoints = v.into();
3375            self
3376        }
3377    }
3378
3379    impl wkt::message::Message for AsyncModelConfig {
3380        fn typename() -> &'static str {
3381            "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
3382        }
3383    }
3384
3385    #[doc(hidden)]
3386    impl<'de> serde::de::Deserialize<'de> for AsyncModelConfig {
3387        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3388        where
3389            D: serde::Deserializer<'de>,
3390        {
3391            #[allow(non_camel_case_types)]
3392            #[doc(hidden)]
3393            #[derive(PartialEq, Eq, Hash)]
3394            enum __FieldTag {
3395                __display_name,
3396                __input_config,
3397                __output_config,
3398                __enable_checkpoints,
3399                Unknown(std::string::String),
3400            }
3401            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3402                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3403                where
3404                    D: serde::Deserializer<'de>,
3405                {
3406                    struct Visitor;
3407                    impl<'de> serde::de::Visitor<'de> for Visitor {
3408                        type Value = __FieldTag;
3409                        fn expecting(
3410                            &self,
3411                            formatter: &mut std::fmt::Formatter,
3412                        ) -> std::fmt::Result {
3413                            formatter.write_str("a field name for AsyncModelConfig")
3414                        }
3415                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3416                        where
3417                            E: serde::de::Error,
3418                        {
3419                            use std::result::Result::Ok;
3420                            use std::string::ToString;
3421                            match value {
3422                                "displayName" => Ok(__FieldTag::__display_name),
3423                                "display_name" => Ok(__FieldTag::__display_name),
3424                                "inputConfig" => Ok(__FieldTag::__input_config),
3425                                "input_config" => Ok(__FieldTag::__input_config),
3426                                "outputConfig" => Ok(__FieldTag::__output_config),
3427                                "output_config" => Ok(__FieldTag::__output_config),
3428                                "enableCheckpoints" => Ok(__FieldTag::__enable_checkpoints),
3429                                "enable_checkpoints" => Ok(__FieldTag::__enable_checkpoints),
3430                                _ => Ok(__FieldTag::Unknown(value.to_string())),
3431                            }
3432                        }
3433                    }
3434                    deserializer.deserialize_identifier(Visitor)
3435                }
3436            }
3437            struct Visitor;
3438            impl<'de> serde::de::Visitor<'de> for Visitor {
3439                type Value = AsyncModelConfig;
3440                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3441                    formatter.write_str("struct AsyncModelConfig")
3442                }
3443                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3444                where
3445                    A: serde::de::MapAccess<'de>,
3446                {
3447                    #[allow(unused_imports)]
3448                    use serde::de::Error;
3449                    use std::option::Option::Some;
3450                    let mut fields = std::collections::HashSet::new();
3451                    let mut result = Self::Value::new();
3452                    while let Some(tag) = map.next_key::<__FieldTag>()? {
3453                        #[allow(clippy::match_single_binding)]
3454                        match tag {
3455                            __FieldTag::__display_name => {
3456                                if !fields.insert(__FieldTag::__display_name) {
3457                                    return std::result::Result::Err(A::Error::duplicate_field(
3458                                        "multiple values for display_name",
3459                                    ));
3460                                }
3461                                result.display_name = map
3462                                    .next_value::<std::option::Option<std::string::String>>()?
3463                                    .unwrap_or_default();
3464                            }
3465                            __FieldTag::__input_config => {
3466                                if !fields.insert(__FieldTag::__input_config) {
3467                                    return std::result::Result::Err(A::Error::duplicate_field(
3468                                        "multiple values for input_config",
3469                                    ));
3470                                }
3471                                result.input_config = map
3472                                    .next_value::<std::option::Option<crate::model::InputConfig>>(
3473                                    )?;
3474                            }
3475                            __FieldTag::__output_config => {
3476                                if !fields.insert(__FieldTag::__output_config) {
3477                                    return std::result::Result::Err(A::Error::duplicate_field(
3478                                        "multiple values for output_config",
3479                                    ));
3480                                }
3481                                result.output_config = map
3482                                    .next_value::<std::option::Option<crate::model::OutputConfig>>(
3483                                    )?;
3484                            }
3485                            __FieldTag::__enable_checkpoints => {
3486                                if !fields.insert(__FieldTag::__enable_checkpoints) {
3487                                    return std::result::Result::Err(A::Error::duplicate_field(
3488                                        "multiple values for enable_checkpoints",
3489                                    ));
3490                                }
3491                                result.enable_checkpoints = map
3492                                    .next_value::<std::option::Option<bool>>()?
3493                                    .unwrap_or_default();
3494                            }
3495                            __FieldTag::Unknown(key) => {
3496                                let value = map.next_value::<serde_json::Value>()?;
3497                                result._unknown_fields.insert(key, value);
3498                            }
3499                        }
3500                    }
3501                    std::result::Result::Ok(result)
3502                }
3503            }
3504            deserializer.deserialize_any(Visitor)
3505        }
3506    }
3507
3508    #[doc(hidden)]
3509    impl serde::ser::Serialize for AsyncModelConfig {
3510        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3511        where
3512            S: serde::ser::Serializer,
3513        {
3514            use serde::ser::SerializeMap;
3515            #[allow(unused_imports)]
3516            use std::option::Option::Some;
3517            let mut state = serializer.serialize_map(std::option::Option::None)?;
3518            if !self.display_name.is_empty() {
3519                state.serialize_entry("displayName", &self.display_name)?;
3520            }
3521            if self.input_config.is_some() {
3522                state.serialize_entry("inputConfig", &self.input_config)?;
3523            }
3524            if self.output_config.is_some() {
3525                state.serialize_entry("outputConfig", &self.output_config)?;
3526            }
3527            if !wkt::internal::is_default(&self.enable_checkpoints) {
3528                state.serialize_entry("enableCheckpoints", &self.enable_checkpoints)?;
3529            }
3530            if !self._unknown_fields.is_empty() {
3531                for (key, value) in self._unknown_fields.iter() {
3532                    state.serialize_entry(key, &value)?;
3533                }
3534            }
3535            state.end()
3536        }
3537    }
3538}
3539
3540/// Response to a `BatchOptimizeToursRequest`. This is returned in
3541/// the LRO Operation after the operation is complete.
3542#[derive(Clone, Debug, Default, PartialEq)]
3543#[non_exhaustive]
3544pub struct BatchOptimizeToursResponse {
3545    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3546}
3547
3548impl BatchOptimizeToursResponse {
3549    pub fn new() -> Self {
3550        std::default::Default::default()
3551    }
3552}
3553
3554impl wkt::message::Message for BatchOptimizeToursResponse {
3555    fn typename() -> &'static str {
3556        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
3557    }
3558}
3559
3560#[doc(hidden)]
3561impl<'de> serde::de::Deserialize<'de> for BatchOptimizeToursResponse {
3562    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3563    where
3564        D: serde::Deserializer<'de>,
3565    {
3566        #[allow(non_camel_case_types)]
3567        #[doc(hidden)]
3568        #[derive(PartialEq, Eq, Hash)]
3569        enum __FieldTag {
3570            Unknown(std::string::String),
3571        }
3572        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3573            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3574            where
3575                D: serde::Deserializer<'de>,
3576            {
3577                struct Visitor;
3578                impl<'de> serde::de::Visitor<'de> for Visitor {
3579                    type Value = __FieldTag;
3580                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3581                        formatter.write_str("a field name for BatchOptimizeToursResponse")
3582                    }
3583                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3584                    where
3585                        E: serde::de::Error,
3586                    {
3587                        use std::result::Result::Ok;
3588                        use std::string::ToString;
3589                        Ok(__FieldTag::Unknown(value.to_string()))
3590                    }
3591                }
3592                deserializer.deserialize_identifier(Visitor)
3593            }
3594        }
3595        struct Visitor;
3596        impl<'de> serde::de::Visitor<'de> for Visitor {
3597            type Value = BatchOptimizeToursResponse;
3598            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3599                formatter.write_str("struct BatchOptimizeToursResponse")
3600            }
3601            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3602            where
3603                A: serde::de::MapAccess<'de>,
3604            {
3605                #[allow(unused_imports)]
3606                use serde::de::Error;
3607                use std::option::Option::Some;
3608                let mut result = Self::Value::new();
3609                while let Some(tag) = map.next_key::<__FieldTag>()? {
3610                    #[allow(clippy::match_single_binding)]
3611                    match tag {
3612                        __FieldTag::Unknown(key) => {
3613                            let value = map.next_value::<serde_json::Value>()?;
3614                            result._unknown_fields.insert(key, value);
3615                        }
3616                    }
3617                }
3618                std::result::Result::Ok(result)
3619            }
3620        }
3621        deserializer.deserialize_any(Visitor)
3622    }
3623}
3624
3625#[doc(hidden)]
3626impl serde::ser::Serialize for BatchOptimizeToursResponse {
3627    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3628    where
3629        S: serde::ser::Serializer,
3630    {
3631        use serde::ser::SerializeMap;
3632        #[allow(unused_imports)]
3633        use std::option::Option::Some;
3634        let mut state = serializer.serialize_map(std::option::Option::None)?;
3635        if !self._unknown_fields.is_empty() {
3636            for (key, value) in self._unknown_fields.iter() {
3637                state.serialize_entry(key, &value)?;
3638            }
3639        }
3640        state.end()
3641    }
3642}
3643
3644/// A shipment model contains a set of shipments which must be performed by a
3645/// set of vehicles, while minimizing the overall cost, which is the sum of:
3646///
3647/// * the cost of routing the vehicles (sum of cost per total time, cost per
3648///   travel time, and fixed cost over all vehicles).
3649/// * the unperformed shipment penalties.
3650/// * the cost of the global duration of the shipments
3651#[derive(Clone, Debug, Default, PartialEq)]
3652#[non_exhaustive]
3653pub struct ShipmentModel {
3654    /// Set of shipments which must be performed in the model.
3655    pub shipments: std::vec::Vec<crate::model::Shipment>,
3656
3657    /// Set of vehicles which can be used to perform visits.
3658    pub vehicles: std::vec::Vec<crate::model::Vehicle>,
3659
3660    /// Constrains the maximum number of active vehicles. A vehicle is active if
3661    /// its route performs at least one shipment. This can be used to limit the
3662    /// number of routes in the case where there are fewer drivers than
3663    /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
3664    /// will then select the best subset of vehicles to use.
3665    /// Must be strictly positive.
3666    pub max_active_vehicles: std::option::Option<i32>,
3667
3668    /// Global start and end time of the model: no times outside of this range
3669    /// can be considered valid.
3670    ///
3671    /// The model's time span must be less than a year, i.e. the `global_end_time`
3672    /// and the `global_start_time` must be within 31536000 seconds of each other.
3673    ///
3674    /// When using `cost_per_*hour` fields, you might want to set this window to a
3675    /// smaller interval to increase performance (eg. if you model a single day,
3676    /// you should set the global time limits to that day).
3677    /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
3678    /// as default.
3679    pub global_start_time: std::option::Option<wkt::Timestamp>,
3680
3681    /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
3682    /// is used as default.
3683    pub global_end_time: std::option::Option<wkt::Timestamp>,
3684
3685    /// The "global duration" of the overall plan is the difference between the
3686    /// earliest effective start time and the latest effective end time of
3687    /// all vehicles. Users can assign a cost per hour to that quantity to try
3688    /// and optimize for earliest job completion, for example. This cost must be in
3689    /// the same unit as
3690    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
3691    ///
3692    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
3693    pub global_duration_cost_per_hour: f64,
3694
3695    /// Specifies duration and distance matrices used in the model. If this field
3696    /// is empty, Google Maps or geodesic distances will be used instead, depending
3697    /// on the value of the `use_geodesic_distances` field. If it is not empty,
3698    /// `use_geodesic_distances` cannot be true and neither
3699    /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
3700    /// can be empty.
3701    ///
3702    /// Usage examples:
3703    ///
3704    /// * There are two locations: locA and locB.
3705    /// * 1 vehicle starting its route at locA and ending it at locA.
3706    /// * 1 pickup visit request at locB.
3707    ///
3708    /// ```norust
3709    /// model {
3710    ///   vehicles { start_tags: "locA"  end_tags: "locA" }
3711    ///   shipments { pickups { tags: "locB" } }
3712    ///   duration_distance_matrix_src_tags: "locA"
3713    ///   duration_distance_matrix_src_tags: "locB"
3714    ///   duration_distance_matrix_dst_tags: "locA"
3715    ///   duration_distance_matrix_dst_tags: "locB"
3716    ///   duration_distance_matrices {
3717    ///     rows {  # from: locA
3718    ///       durations { seconds: 0 }   meters: 0    # to: locA
3719    ///       durations { seconds: 100 } meters: 1000 # to: locB
3720    ///     }
3721    ///     rows {  # from: locB
3722    ///       durations { seconds: 102 } meters: 990 # to: locA
3723    ///       durations { seconds: 0 }   meters: 0   # to: locB
3724    ///     }
3725    ///   }
3726    /// }
3727    /// ```
3728    ///
3729    /// * There are three locations: locA, locB and locC.
3730    /// * 1 vehicle starting its route at locA and ending it at locB, using
3731    ///   matrix "fast".
3732    /// * 1 vehicle starting its route at locB and ending it at locB, using
3733    ///   matrix "slow".
3734    /// * 1 vehicle starting its route at locB and ending it at locB, using
3735    ///   matrix "fast".
3736    /// * 1 pickup visit request at locC.
3737    ///
3738    /// ```norust
3739    /// model {
3740    ///   vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
3741    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
3742    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
3743    ///   shipments { pickups { tags: "locC" } }
3744    ///   duration_distance_matrix_src_tags: "locA"
3745    ///   duration_distance_matrix_src_tags: "locB"
3746    ///   duration_distance_matrix_src_tags: "locC"
3747    ///   duration_distance_matrix_dst_tags: "locB"
3748    ///   duration_distance_matrix_dst_tags: "locC"
3749    ///   duration_distance_matrices {
3750    ///     vehicle_start_tag: "fast"
3751    ///     rows {  # from: locA
3752    ///       durations { seconds: 1000 } meters: 2000 # to: locB
3753    ///       durations { seconds: 600 }  meters: 1000 # to: locC
3754    ///     }
3755    ///     rows {  # from: locB
3756    ///       durations { seconds: 0 }   meters: 0    # to: locB
3757    ///       durations { seconds: 700 } meters: 1200 # to: locC
3758    ///     }
3759    ///     rows {  # from: locC
3760    ///       durations { seconds: 702 } meters: 1190 # to: locB
3761    ///       durations { seconds: 0 }   meters: 0    # to: locC
3762    ///     }
3763    ///   }
3764    ///   duration_distance_matrices {
3765    ///     vehicle_start_tag: "slow"
3766    ///     rows {  # from: locA
3767    ///       durations { seconds: 1800 } meters: 2001 # to: locB
3768    ///       durations { seconds: 900 }  meters: 1002 # to: locC
3769    ///     }
3770    ///     rows {  # from: locB
3771    ///       durations { seconds: 0 }    meters: 0    # to: locB
3772    ///       durations { seconds: 1000 } meters: 1202 # to: locC
3773    ///     }
3774    ///     rows {  # from: locC
3775    ///       durations { seconds: 1001 } meters: 1195 # to: locB
3776    ///       durations { seconds: 0 }    meters: 0    # to: locC
3777    ///     }
3778    ///   }
3779    /// }
3780    /// ```
3781    pub duration_distance_matrices:
3782        std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
3783
3784    /// Tags defining the sources of the duration and distance matrices;
3785    /// `duration_distance_matrices(i).rows(j)` defines durations and distances
3786    /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
3787    /// in matrix i.
3788    ///
3789    /// Tags correspond to
3790    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
3791    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
3792    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
3793    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
3794    /// the same; similarly a `VisitRequest`'s source and destination tags may be
3795    /// the same. All tags must be different and cannot be empty strings. If this
3796    /// field is not empty, then `duration_distance_matrices` must not be empty.
3797    ///
3798    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
3799    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
3800    pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
3801
3802    /// Tags defining the destinations of the duration and distance matrices;
3803    /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
3804    /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
3805    /// (resp. the distance) of the travel from visits with tag
3806    /// `duration_distance_matrix_src_tags(j)` to visits with tag
3807    /// `duration_distance_matrix_dst_tags(k)` in matrix i.
3808    ///
3809    /// Tags correspond to
3810    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
3811    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
3812    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
3813    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
3814    /// the same; similarly a `VisitRequest`'s source and destination tags may be
3815    /// the same. All tags must be different and cannot be empty strings. If this
3816    /// field is not empty, then `duration_distance_matrices` must not be empty.
3817    ///
3818    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
3819    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
3820    pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
3821
3822    /// Transition attributes added to the model.
3823    pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
3824
3825    /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
3826    pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
3827
3828    /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
3829    pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
3830
3831    /// Set of precedence rules which must be enforced in the model.
3832    pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
3833
3834    /// Deprecated: No longer used.
3835    /// Set of break rules used in the model.
3836    /// Each vehicle specifies the `BreakRule` that applies to it via the
3837    /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
3838    /// field (which must be a singleton).
3839    ///
3840    /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
3841    #[deprecated]
3842    pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
3843
3844    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3845}
3846
3847impl ShipmentModel {
3848    pub fn new() -> Self {
3849        std::default::Default::default()
3850    }
3851
3852    /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
3853    pub fn set_shipments<T, V>(mut self, v: T) -> Self
3854    where
3855        T: std::iter::IntoIterator<Item = V>,
3856        V: std::convert::Into<crate::model::Shipment>,
3857    {
3858        use std::iter::Iterator;
3859        self.shipments = v.into_iter().map(|i| i.into()).collect();
3860        self
3861    }
3862
3863    /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
3864    pub fn set_vehicles<T, V>(mut self, v: T) -> Self
3865    where
3866        T: std::iter::IntoIterator<Item = V>,
3867        V: std::convert::Into<crate::model::Vehicle>,
3868    {
3869        use std::iter::Iterator;
3870        self.vehicles = v.into_iter().map(|i| i.into()).collect();
3871        self
3872    }
3873
3874    /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
3875    pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
3876    where
3877        T: std::convert::Into<i32>,
3878    {
3879        self.max_active_vehicles = std::option::Option::Some(v.into());
3880        self
3881    }
3882
3883    /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
3884    pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
3885    where
3886        T: std::convert::Into<i32>,
3887    {
3888        self.max_active_vehicles = v.map(|x| x.into());
3889        self
3890    }
3891
3892    /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
3893    pub fn set_global_start_time<T>(mut self, v: T) -> Self
3894    where
3895        T: std::convert::Into<wkt::Timestamp>,
3896    {
3897        self.global_start_time = std::option::Option::Some(v.into());
3898        self
3899    }
3900
3901    /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
3902    pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3903    where
3904        T: std::convert::Into<wkt::Timestamp>,
3905    {
3906        self.global_start_time = v.map(|x| x.into());
3907        self
3908    }
3909
3910    /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
3911    pub fn set_global_end_time<T>(mut self, v: T) -> Self
3912    where
3913        T: std::convert::Into<wkt::Timestamp>,
3914    {
3915        self.global_end_time = std::option::Option::Some(v.into());
3916        self
3917    }
3918
3919    /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
3920    pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
3921    where
3922        T: std::convert::Into<wkt::Timestamp>,
3923    {
3924        self.global_end_time = v.map(|x| x.into());
3925        self
3926    }
3927
3928    /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
3929    pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3930        self.global_duration_cost_per_hour = v.into();
3931        self
3932    }
3933
3934    /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
3935    pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
3936    where
3937        T: std::iter::IntoIterator<Item = V>,
3938        V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
3939    {
3940        use std::iter::Iterator;
3941        self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
3942        self
3943    }
3944
3945    /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
3946    pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
3947    where
3948        T: std::iter::IntoIterator<Item = V>,
3949        V: std::convert::Into<std::string::String>,
3950    {
3951        use std::iter::Iterator;
3952        self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
3953        self
3954    }
3955
3956    /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
3957    pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
3958    where
3959        T: std::iter::IntoIterator<Item = V>,
3960        V: std::convert::Into<std::string::String>,
3961    {
3962        use std::iter::Iterator;
3963        self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
3964        self
3965    }
3966
3967    /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
3968    pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
3969    where
3970        T: std::iter::IntoIterator<Item = V>,
3971        V: std::convert::Into<crate::model::TransitionAttributes>,
3972    {
3973        use std::iter::Iterator;
3974        self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
3975        self
3976    }
3977
3978    /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
3979    pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
3980    where
3981        T: std::iter::IntoIterator<Item = V>,
3982        V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
3983    {
3984        use std::iter::Iterator;
3985        self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
3986        self
3987    }
3988
3989    /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
3990    pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
3991    where
3992        T: std::iter::IntoIterator<Item = V>,
3993        V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
3994    {
3995        use std::iter::Iterator;
3996        self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
3997        self
3998    }
3999
4000    /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
4001    pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
4002    where
4003        T: std::iter::IntoIterator<Item = V>,
4004        V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
4005    {
4006        use std::iter::Iterator;
4007        self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
4008        self
4009    }
4010
4011    /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
4012    #[deprecated]
4013    pub fn set_break_rules<T, V>(mut self, v: T) -> Self
4014    where
4015        T: std::iter::IntoIterator<Item = V>,
4016        V: std::convert::Into<crate::model::shipment_model::BreakRule>,
4017    {
4018        use std::iter::Iterator;
4019        self.break_rules = v.into_iter().map(|i| i.into()).collect();
4020        self
4021    }
4022}
4023
4024impl wkt::message::Message for ShipmentModel {
4025    fn typename() -> &'static str {
4026        "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
4027    }
4028}
4029
4030#[doc(hidden)]
4031impl<'de> serde::de::Deserialize<'de> for ShipmentModel {
4032    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4033    where
4034        D: serde::Deserializer<'de>,
4035    {
4036        #[allow(non_camel_case_types)]
4037        #[doc(hidden)]
4038        #[derive(PartialEq, Eq, Hash)]
4039        enum __FieldTag {
4040            __shipments,
4041            __vehicles,
4042            __max_active_vehicles,
4043            __global_start_time,
4044            __global_end_time,
4045            __global_duration_cost_per_hour,
4046            __duration_distance_matrices,
4047            __duration_distance_matrix_src_tags,
4048            __duration_distance_matrix_dst_tags,
4049            __transition_attributes,
4050            __shipment_type_incompatibilities,
4051            __shipment_type_requirements,
4052            __precedence_rules,
4053            __break_rules,
4054            Unknown(std::string::String),
4055        }
4056        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4057            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4058            where
4059                D: serde::Deserializer<'de>,
4060            {
4061                struct Visitor;
4062                impl<'de> serde::de::Visitor<'de> for Visitor {
4063                    type Value = __FieldTag;
4064                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4065                        formatter.write_str("a field name for ShipmentModel")
4066                    }
4067                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4068                    where
4069                        E: serde::de::Error,
4070                    {
4071                        use std::result::Result::Ok;
4072                        use std::string::ToString;
4073                        match value {
4074                            "shipments" => Ok(__FieldTag::__shipments),
4075                            "vehicles" => Ok(__FieldTag::__vehicles),
4076                            "maxActiveVehicles" => Ok(__FieldTag::__max_active_vehicles),
4077                            "max_active_vehicles" => Ok(__FieldTag::__max_active_vehicles),
4078                            "globalStartTime" => Ok(__FieldTag::__global_start_time),
4079                            "global_start_time" => Ok(__FieldTag::__global_start_time),
4080                            "globalEndTime" => Ok(__FieldTag::__global_end_time),
4081                            "global_end_time" => Ok(__FieldTag::__global_end_time),
4082                            "globalDurationCostPerHour" => {
4083                                Ok(__FieldTag::__global_duration_cost_per_hour)
4084                            }
4085                            "global_duration_cost_per_hour" => {
4086                                Ok(__FieldTag::__global_duration_cost_per_hour)
4087                            }
4088                            "durationDistanceMatrices" => {
4089                                Ok(__FieldTag::__duration_distance_matrices)
4090                            }
4091                            "duration_distance_matrices" => {
4092                                Ok(__FieldTag::__duration_distance_matrices)
4093                            }
4094                            "durationDistanceMatrixSrcTags" => {
4095                                Ok(__FieldTag::__duration_distance_matrix_src_tags)
4096                            }
4097                            "duration_distance_matrix_src_tags" => {
4098                                Ok(__FieldTag::__duration_distance_matrix_src_tags)
4099                            }
4100                            "durationDistanceMatrixDstTags" => {
4101                                Ok(__FieldTag::__duration_distance_matrix_dst_tags)
4102                            }
4103                            "duration_distance_matrix_dst_tags" => {
4104                                Ok(__FieldTag::__duration_distance_matrix_dst_tags)
4105                            }
4106                            "transitionAttributes" => Ok(__FieldTag::__transition_attributes),
4107                            "transition_attributes" => Ok(__FieldTag::__transition_attributes),
4108                            "shipmentTypeIncompatibilities" => {
4109                                Ok(__FieldTag::__shipment_type_incompatibilities)
4110                            }
4111                            "shipment_type_incompatibilities" => {
4112                                Ok(__FieldTag::__shipment_type_incompatibilities)
4113                            }
4114                            "shipmentTypeRequirements" => {
4115                                Ok(__FieldTag::__shipment_type_requirements)
4116                            }
4117                            "shipment_type_requirements" => {
4118                                Ok(__FieldTag::__shipment_type_requirements)
4119                            }
4120                            "precedenceRules" => Ok(__FieldTag::__precedence_rules),
4121                            "precedence_rules" => Ok(__FieldTag::__precedence_rules),
4122                            "breakRules" => Ok(__FieldTag::__break_rules),
4123                            "break_rules" => Ok(__FieldTag::__break_rules),
4124                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4125                        }
4126                    }
4127                }
4128                deserializer.deserialize_identifier(Visitor)
4129            }
4130        }
4131        struct Visitor;
4132        impl<'de> serde::de::Visitor<'de> for Visitor {
4133            type Value = ShipmentModel;
4134            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4135                formatter.write_str("struct ShipmentModel")
4136            }
4137            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4138            where
4139                A: serde::de::MapAccess<'de>,
4140            {
4141                #[allow(unused_imports)]
4142                use serde::de::Error;
4143                use std::option::Option::Some;
4144                let mut fields = std::collections::HashSet::new();
4145                let mut result = Self::Value::new();
4146                while let Some(tag) = map.next_key::<__FieldTag>()? {
4147                    #[allow(clippy::match_single_binding)]
4148                    match tag {
4149                        __FieldTag::__shipments => {
4150                            if !fields.insert(__FieldTag::__shipments) {
4151                                return std::result::Result::Err(A::Error::duplicate_field(
4152                                    "multiple values for shipments",
4153                                ));
4154                            }
4155                            result.shipments = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Shipment>>>()?.unwrap_or_default();
4156                        }
4157                        __FieldTag::__vehicles => {
4158                            if !fields.insert(__FieldTag::__vehicles) {
4159                                return std::result::Result::Err(A::Error::duplicate_field(
4160                                    "multiple values for vehicles",
4161                                ));
4162                            }
4163                            result.vehicles = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Vehicle>>>()?.unwrap_or_default();
4164                        }
4165                        __FieldTag::__max_active_vehicles => {
4166                            if !fields.insert(__FieldTag::__max_active_vehicles) {
4167                                return std::result::Result::Err(A::Error::duplicate_field(
4168                                    "multiple values for max_active_vehicles",
4169                                ));
4170                            }
4171                            struct __With(std::option::Option<i32>);
4172                            impl<'de> serde::de::Deserialize<'de> for __With {
4173                                fn deserialize<D>(
4174                                    deserializer: D,
4175                                ) -> std::result::Result<Self, D::Error>
4176                                where
4177                                    D: serde::de::Deserializer<'de>,
4178                                {
4179                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
4180                                }
4181                            }
4182                            result.max_active_vehicles = map.next_value::<__With>()?.0;
4183                        }
4184                        __FieldTag::__global_start_time => {
4185                            if !fields.insert(__FieldTag::__global_start_time) {
4186                                return std::result::Result::Err(A::Error::duplicate_field(
4187                                    "multiple values for global_start_time",
4188                                ));
4189                            }
4190                            result.global_start_time =
4191                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4192                        }
4193                        __FieldTag::__global_end_time => {
4194                            if !fields.insert(__FieldTag::__global_end_time) {
4195                                return std::result::Result::Err(A::Error::duplicate_field(
4196                                    "multiple values for global_end_time",
4197                                ));
4198                            }
4199                            result.global_end_time =
4200                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4201                        }
4202                        __FieldTag::__global_duration_cost_per_hour => {
4203                            if !fields.insert(__FieldTag::__global_duration_cost_per_hour) {
4204                                return std::result::Result::Err(A::Error::duplicate_field(
4205                                    "multiple values for global_duration_cost_per_hour",
4206                                ));
4207                            }
4208                            struct __With(std::option::Option<f64>);
4209                            impl<'de> serde::de::Deserialize<'de> for __With {
4210                                fn deserialize<D>(
4211                                    deserializer: D,
4212                                ) -> std::result::Result<Self, D::Error>
4213                                where
4214                                    D: serde::de::Deserializer<'de>,
4215                                {
4216                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
4217                                }
4218                            }
4219                            result.global_duration_cost_per_hour =
4220                                map.next_value::<__With>()?.0.unwrap_or_default();
4221                        }
4222                        __FieldTag::__duration_distance_matrices => {
4223                            if !fields.insert(__FieldTag::__duration_distance_matrices) {
4224                                return std::result::Result::Err(A::Error::duplicate_field(
4225                                    "multiple values for duration_distance_matrices",
4226                                ));
4227                            }
4228                            result.duration_distance_matrices = map
4229                                .next_value::<std::option::Option<
4230                                    std::vec::Vec<
4231                                        crate::model::shipment_model::DurationDistanceMatrix,
4232                                    >,
4233                                >>()?
4234                                .unwrap_or_default();
4235                        }
4236                        __FieldTag::__duration_distance_matrix_src_tags => {
4237                            if !fields.insert(__FieldTag::__duration_distance_matrix_src_tags) {
4238                                return std::result::Result::Err(A::Error::duplicate_field(
4239                                    "multiple values for duration_distance_matrix_src_tags",
4240                                ));
4241                            }
4242                            result.duration_distance_matrix_src_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
4243                        }
4244                        __FieldTag::__duration_distance_matrix_dst_tags => {
4245                            if !fields.insert(__FieldTag::__duration_distance_matrix_dst_tags) {
4246                                return std::result::Result::Err(A::Error::duplicate_field(
4247                                    "multiple values for duration_distance_matrix_dst_tags",
4248                                ));
4249                            }
4250                            result.duration_distance_matrix_dst_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
4251                        }
4252                        __FieldTag::__transition_attributes => {
4253                            if !fields.insert(__FieldTag::__transition_attributes) {
4254                                return std::result::Result::Err(A::Error::duplicate_field(
4255                                    "multiple values for transition_attributes",
4256                                ));
4257                            }
4258                            result.transition_attributes = map
4259                                .next_value::<std::option::Option<
4260                                    std::vec::Vec<crate::model::TransitionAttributes>,
4261                                >>()?
4262                                .unwrap_or_default();
4263                        }
4264                        __FieldTag::__shipment_type_incompatibilities => {
4265                            if !fields.insert(__FieldTag::__shipment_type_incompatibilities) {
4266                                return std::result::Result::Err(A::Error::duplicate_field(
4267                                    "multiple values for shipment_type_incompatibilities",
4268                                ));
4269                            }
4270                            result.shipment_type_incompatibilities = map
4271                                .next_value::<std::option::Option<
4272                                    std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
4273                                >>()?
4274                                .unwrap_or_default();
4275                        }
4276                        __FieldTag::__shipment_type_requirements => {
4277                            if !fields.insert(__FieldTag::__shipment_type_requirements) {
4278                                return std::result::Result::Err(A::Error::duplicate_field(
4279                                    "multiple values for shipment_type_requirements",
4280                                ));
4281                            }
4282                            result.shipment_type_requirements = map
4283                                .next_value::<std::option::Option<
4284                                    std::vec::Vec<crate::model::ShipmentTypeRequirement>,
4285                                >>()?
4286                                .unwrap_or_default();
4287                        }
4288                        __FieldTag::__precedence_rules => {
4289                            if !fields.insert(__FieldTag::__precedence_rules) {
4290                                return std::result::Result::Err(A::Error::duplicate_field(
4291                                    "multiple values for precedence_rules",
4292                                ));
4293                            }
4294                            result.precedence_rules = map
4295                                .next_value::<std::option::Option<
4296                                    std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
4297                                >>()?
4298                                .unwrap_or_default();
4299                        }
4300                        __FieldTag::__break_rules => {
4301                            if !fields.insert(__FieldTag::__break_rules) {
4302                                return std::result::Result::Err(A::Error::duplicate_field(
4303                                    "multiple values for break_rules",
4304                                ));
4305                            }
4306                            result.break_rules = map
4307                                .next_value::<std::option::Option<
4308                                    std::vec::Vec<crate::model::shipment_model::BreakRule>,
4309                                >>()?
4310                                .unwrap_or_default();
4311                        }
4312                        __FieldTag::Unknown(key) => {
4313                            let value = map.next_value::<serde_json::Value>()?;
4314                            result._unknown_fields.insert(key, value);
4315                        }
4316                    }
4317                }
4318                std::result::Result::Ok(result)
4319            }
4320        }
4321        deserializer.deserialize_any(Visitor)
4322    }
4323}
4324
4325#[doc(hidden)]
4326impl serde::ser::Serialize for ShipmentModel {
4327    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4328    where
4329        S: serde::ser::Serializer,
4330    {
4331        use serde::ser::SerializeMap;
4332        #[allow(unused_imports)]
4333        use std::option::Option::Some;
4334        let mut state = serializer.serialize_map(std::option::Option::None)?;
4335        if !self.shipments.is_empty() {
4336            state.serialize_entry("shipments", &self.shipments)?;
4337        }
4338        if !self.vehicles.is_empty() {
4339            state.serialize_entry("vehicles", &self.vehicles)?;
4340        }
4341        if self.max_active_vehicles.is_some() {
4342            struct __With<'a>(&'a std::option::Option<i32>);
4343            impl<'a> serde::ser::Serialize for __With<'a> {
4344                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4345                where
4346                    S: serde::ser::Serializer,
4347                {
4348                    serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
4349                        self.0, serializer,
4350                    )
4351                }
4352            }
4353            state.serialize_entry("maxActiveVehicles", &__With(&self.max_active_vehicles))?;
4354        }
4355        if self.global_start_time.is_some() {
4356            state.serialize_entry("globalStartTime", &self.global_start_time)?;
4357        }
4358        if self.global_end_time.is_some() {
4359            state.serialize_entry("globalEndTime", &self.global_end_time)?;
4360        }
4361        if !wkt::internal::is_default(&self.global_duration_cost_per_hour) {
4362            struct __With<'a>(&'a f64);
4363            impl<'a> serde::ser::Serialize for __With<'a> {
4364                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4365                where
4366                    S: serde::ser::Serializer,
4367                {
4368                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
4369                }
4370            }
4371            state.serialize_entry(
4372                "globalDurationCostPerHour",
4373                &__With(&self.global_duration_cost_per_hour),
4374            )?;
4375        }
4376        if !self.duration_distance_matrices.is_empty() {
4377            state.serialize_entry("durationDistanceMatrices", &self.duration_distance_matrices)?;
4378        }
4379        if !self.duration_distance_matrix_src_tags.is_empty() {
4380            state.serialize_entry(
4381                "durationDistanceMatrixSrcTags",
4382                &self.duration_distance_matrix_src_tags,
4383            )?;
4384        }
4385        if !self.duration_distance_matrix_dst_tags.is_empty() {
4386            state.serialize_entry(
4387                "durationDistanceMatrixDstTags",
4388                &self.duration_distance_matrix_dst_tags,
4389            )?;
4390        }
4391        if !self.transition_attributes.is_empty() {
4392            state.serialize_entry("transitionAttributes", &self.transition_attributes)?;
4393        }
4394        if !self.shipment_type_incompatibilities.is_empty() {
4395            state.serialize_entry(
4396                "shipmentTypeIncompatibilities",
4397                &self.shipment_type_incompatibilities,
4398            )?;
4399        }
4400        if !self.shipment_type_requirements.is_empty() {
4401            state.serialize_entry("shipmentTypeRequirements", &self.shipment_type_requirements)?;
4402        }
4403        if !self.precedence_rules.is_empty() {
4404            state.serialize_entry("precedenceRules", &self.precedence_rules)?;
4405        }
4406        if !self.break_rules.is_empty() {
4407            state.serialize_entry("breakRules", &self.break_rules)?;
4408        }
4409        if !self._unknown_fields.is_empty() {
4410            for (key, value) in self._unknown_fields.iter() {
4411                state.serialize_entry(key, &value)?;
4412            }
4413        }
4414        state.end()
4415    }
4416}
4417
4418/// Defines additional types related to [ShipmentModel].
4419pub mod shipment_model {
4420    #[allow(unused_imports)]
4421    use super::*;
4422
4423    /// Specifies a duration and distance matrix from visit and vehicle start
4424    /// locations to visit and vehicle end locations.
4425    #[derive(Clone, Debug, Default, PartialEq)]
4426    #[non_exhaustive]
4427    pub struct DurationDistanceMatrix {
4428        /// Specifies the rows of the duration and distance matrix. It must have as
4429        /// many elements as
4430        /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
4431        ///
4432        /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
4433        pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
4434
4435        /// Tag defining to which vehicles this duration and distance matrix applies.
4436        /// If empty, this applies to all vehicles, and there can only be a single
4437        /// matrix.
4438        ///
4439        /// Each vehicle start must match exactly one matrix, i.e. exactly one of
4440        /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
4441        /// (and of that matrix only).
4442        ///
4443        /// All matrices must have a different `vehicle_start_tag`.
4444        pub vehicle_start_tag: std::string::String,
4445
4446        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4447    }
4448
4449    impl DurationDistanceMatrix {
4450        pub fn new() -> Self {
4451            std::default::Default::default()
4452        }
4453
4454        /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
4455        pub fn set_rows<T, V>(mut self, v: T) -> Self
4456        where
4457            T: std::iter::IntoIterator<Item = V>,
4458            V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
4459        {
4460            use std::iter::Iterator;
4461            self.rows = v.into_iter().map(|i| i.into()).collect();
4462            self
4463        }
4464
4465        /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
4466        pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
4467            mut self,
4468            v: T,
4469        ) -> Self {
4470            self.vehicle_start_tag = v.into();
4471            self
4472        }
4473    }
4474
4475    impl wkt::message::Message for DurationDistanceMatrix {
4476        fn typename() -> &'static str {
4477            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
4478        }
4479    }
4480
4481    #[doc(hidden)]
4482    impl<'de> serde::de::Deserialize<'de> for DurationDistanceMatrix {
4483        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4484        where
4485            D: serde::Deserializer<'de>,
4486        {
4487            #[allow(non_camel_case_types)]
4488            #[doc(hidden)]
4489            #[derive(PartialEq, Eq, Hash)]
4490            enum __FieldTag {
4491                __rows,
4492                __vehicle_start_tag,
4493                Unknown(std::string::String),
4494            }
4495            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4496                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4497                where
4498                    D: serde::Deserializer<'de>,
4499                {
4500                    struct Visitor;
4501                    impl<'de> serde::de::Visitor<'de> for Visitor {
4502                        type Value = __FieldTag;
4503                        fn expecting(
4504                            &self,
4505                            formatter: &mut std::fmt::Formatter,
4506                        ) -> std::fmt::Result {
4507                            formatter.write_str("a field name for DurationDistanceMatrix")
4508                        }
4509                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4510                        where
4511                            E: serde::de::Error,
4512                        {
4513                            use std::result::Result::Ok;
4514                            use std::string::ToString;
4515                            match value {
4516                                "rows" => Ok(__FieldTag::__rows),
4517                                "vehicleStartTag" => Ok(__FieldTag::__vehicle_start_tag),
4518                                "vehicle_start_tag" => Ok(__FieldTag::__vehicle_start_tag),
4519                                _ => Ok(__FieldTag::Unknown(value.to_string())),
4520                            }
4521                        }
4522                    }
4523                    deserializer.deserialize_identifier(Visitor)
4524                }
4525            }
4526            struct Visitor;
4527            impl<'de> serde::de::Visitor<'de> for Visitor {
4528                type Value = DurationDistanceMatrix;
4529                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4530                    formatter.write_str("struct DurationDistanceMatrix")
4531                }
4532                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4533                where
4534                    A: serde::de::MapAccess<'de>,
4535                {
4536                    #[allow(unused_imports)]
4537                    use serde::de::Error;
4538                    use std::option::Option::Some;
4539                    let mut fields = std::collections::HashSet::new();
4540                    let mut result = Self::Value::new();
4541                    while let Some(tag) = map.next_key::<__FieldTag>()? {
4542                        #[allow(clippy::match_single_binding)]
4543                        match tag {
4544                            __FieldTag::__rows => {
4545                                if !fields.insert(__FieldTag::__rows) {
4546                                    return std::result::Result::Err(A::Error::duplicate_field(
4547                                        "multiple values for rows",
4548                                    ));
4549                                }
4550                                result.rows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>>>()?.unwrap_or_default();
4551                            }
4552                            __FieldTag::__vehicle_start_tag => {
4553                                if !fields.insert(__FieldTag::__vehicle_start_tag) {
4554                                    return std::result::Result::Err(A::Error::duplicate_field(
4555                                        "multiple values for vehicle_start_tag",
4556                                    ));
4557                                }
4558                                result.vehicle_start_tag = map
4559                                    .next_value::<std::option::Option<std::string::String>>()?
4560                                    .unwrap_or_default();
4561                            }
4562                            __FieldTag::Unknown(key) => {
4563                                let value = map.next_value::<serde_json::Value>()?;
4564                                result._unknown_fields.insert(key, value);
4565                            }
4566                        }
4567                    }
4568                    std::result::Result::Ok(result)
4569                }
4570            }
4571            deserializer.deserialize_any(Visitor)
4572        }
4573    }
4574
4575    #[doc(hidden)]
4576    impl serde::ser::Serialize for DurationDistanceMatrix {
4577        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4578        where
4579            S: serde::ser::Serializer,
4580        {
4581            use serde::ser::SerializeMap;
4582            #[allow(unused_imports)]
4583            use std::option::Option::Some;
4584            let mut state = serializer.serialize_map(std::option::Option::None)?;
4585            if !self.rows.is_empty() {
4586                state.serialize_entry("rows", &self.rows)?;
4587            }
4588            if !self.vehicle_start_tag.is_empty() {
4589                state.serialize_entry("vehicleStartTag", &self.vehicle_start_tag)?;
4590            }
4591            if !self._unknown_fields.is_empty() {
4592                for (key, value) in self._unknown_fields.iter() {
4593                    state.serialize_entry(key, &value)?;
4594                }
4595            }
4596            state.end()
4597        }
4598    }
4599
4600    /// Defines additional types related to [DurationDistanceMatrix].
4601    pub mod duration_distance_matrix {
4602        #[allow(unused_imports)]
4603        use super::*;
4604
4605        /// Specifies a row of the duration and distance matrix.
4606        #[derive(Clone, Debug, Default, PartialEq)]
4607        #[non_exhaustive]
4608        pub struct Row {
4609            /// Duration values for a given row. It must have as many elements as
4610            /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
4611            ///
4612            /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
4613            pub durations: std::vec::Vec<wkt::Duration>,
4614
4615            /// Distance values for a given row. If no costs or constraints refer to
4616            /// distances in the model, this can be left empty; otherwise it must have
4617            /// as many elements as `durations`.
4618            pub meters: std::vec::Vec<f64>,
4619
4620            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4621        }
4622
4623        impl Row {
4624            pub fn new() -> Self {
4625                std::default::Default::default()
4626            }
4627
4628            /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
4629            pub fn set_durations<T, V>(mut self, v: T) -> Self
4630            where
4631                T: std::iter::IntoIterator<Item = V>,
4632                V: std::convert::Into<wkt::Duration>,
4633            {
4634                use std::iter::Iterator;
4635                self.durations = v.into_iter().map(|i| i.into()).collect();
4636                self
4637            }
4638
4639            /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
4640            pub fn set_meters<T, V>(mut self, v: T) -> Self
4641            where
4642                T: std::iter::IntoIterator<Item = V>,
4643                V: std::convert::Into<f64>,
4644            {
4645                use std::iter::Iterator;
4646                self.meters = v.into_iter().map(|i| i.into()).collect();
4647                self
4648            }
4649        }
4650
4651        impl wkt::message::Message for Row {
4652            fn typename() -> &'static str {
4653                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
4654            }
4655        }
4656
4657        #[doc(hidden)]
4658        impl<'de> serde::de::Deserialize<'de> for Row {
4659            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4660            where
4661                D: serde::Deserializer<'de>,
4662            {
4663                #[allow(non_camel_case_types)]
4664                #[doc(hidden)]
4665                #[derive(PartialEq, Eq, Hash)]
4666                enum __FieldTag {
4667                    __durations,
4668                    __meters,
4669                    Unknown(std::string::String),
4670                }
4671                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4672                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4673                    where
4674                        D: serde::Deserializer<'de>,
4675                    {
4676                        struct Visitor;
4677                        impl<'de> serde::de::Visitor<'de> for Visitor {
4678                            type Value = __FieldTag;
4679                            fn expecting(
4680                                &self,
4681                                formatter: &mut std::fmt::Formatter,
4682                            ) -> std::fmt::Result {
4683                                formatter.write_str("a field name for Row")
4684                            }
4685                            fn visit_str<E>(
4686                                self,
4687                                value: &str,
4688                            ) -> std::result::Result<Self::Value, E>
4689                            where
4690                                E: serde::de::Error,
4691                            {
4692                                use std::result::Result::Ok;
4693                                use std::string::ToString;
4694                                match value {
4695                                    "durations" => Ok(__FieldTag::__durations),
4696                                    "meters" => Ok(__FieldTag::__meters),
4697                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
4698                                }
4699                            }
4700                        }
4701                        deserializer.deserialize_identifier(Visitor)
4702                    }
4703                }
4704                struct Visitor;
4705                impl<'de> serde::de::Visitor<'de> for Visitor {
4706                    type Value = Row;
4707                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4708                        formatter.write_str("struct Row")
4709                    }
4710                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4711                    where
4712                        A: serde::de::MapAccess<'de>,
4713                    {
4714                        #[allow(unused_imports)]
4715                        use serde::de::Error;
4716                        use std::option::Option::Some;
4717                        let mut fields = std::collections::HashSet::new();
4718                        let mut result = Self::Value::new();
4719                        while let Some(tag) = map.next_key::<__FieldTag>()? {
4720                            #[allow(clippy::match_single_binding)]
4721                            match tag {
4722                                __FieldTag::__durations => {
4723                                    if !fields.insert(__FieldTag::__durations) {
4724                                        return std::result::Result::Err(
4725                                            A::Error::duplicate_field(
4726                                                "multiple values for durations",
4727                                            ),
4728                                        );
4729                                    }
4730                                    result.durations = map.next_value::<std::option::Option<std::vec::Vec<wkt::Duration>>>()?.unwrap_or_default();
4731                                }
4732                                __FieldTag::__meters => {
4733                                    if !fields.insert(__FieldTag::__meters) {
4734                                        return std::result::Result::Err(
4735                                            A::Error::duplicate_field("multiple values for meters"),
4736                                        );
4737                                    }
4738                                    struct __With(std::option::Option<std::vec::Vec<f64>>);
4739                                    impl<'de> serde::de::Deserialize<'de> for __With {
4740                                        fn deserialize<D>(
4741                                            deserializer: D,
4742                                        ) -> std::result::Result<Self, D::Error>
4743                                        where
4744                                            D: serde::de::Deserializer<'de>,
4745                                        {
4746                                            serde_with::As::<
4747                                                std::option::Option<
4748                                                    std::vec::Vec<wkt::internal::F64>,
4749                                                >,
4750                                            >::deserialize(
4751                                                deserializer
4752                                            )
4753                                            .map(__With)
4754                                        }
4755                                    }
4756                                    result.meters =
4757                                        map.next_value::<__With>()?.0.unwrap_or_default();
4758                                }
4759                                __FieldTag::Unknown(key) => {
4760                                    let value = map.next_value::<serde_json::Value>()?;
4761                                    result._unknown_fields.insert(key, value);
4762                                }
4763                            }
4764                        }
4765                        std::result::Result::Ok(result)
4766                    }
4767                }
4768                deserializer.deserialize_any(Visitor)
4769            }
4770        }
4771
4772        #[doc(hidden)]
4773        impl serde::ser::Serialize for Row {
4774            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4775            where
4776                S: serde::ser::Serializer,
4777            {
4778                use serde::ser::SerializeMap;
4779                #[allow(unused_imports)]
4780                use std::option::Option::Some;
4781                let mut state = serializer.serialize_map(std::option::Option::None)?;
4782                if !self.durations.is_empty() {
4783                    state.serialize_entry("durations", &self.durations)?;
4784                }
4785                if !self.meters.is_empty() {
4786                    struct __With<'a>(&'a std::vec::Vec<f64>);
4787                    impl<'a> serde::ser::Serialize for __With<'a> {
4788                        fn serialize<S>(
4789                            &self,
4790                            serializer: S,
4791                        ) -> std::result::Result<S::Ok, S::Error>
4792                        where
4793                            S: serde::ser::Serializer,
4794                        {
4795                            serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
4796                                self.0, serializer,
4797                            )
4798                        }
4799                    }
4800                    state.serialize_entry("meters", &__With(&self.meters))?;
4801                }
4802                if !self._unknown_fields.is_empty() {
4803                    for (key, value) in self._unknown_fields.iter() {
4804                        state.serialize_entry(key, &value)?;
4805                    }
4806                }
4807                state.end()
4808            }
4809        }
4810    }
4811
4812    /// A precedence rule between two events (each event is the pickup or the
4813    /// delivery of a shipment): the "second" event has to start at least
4814    /// `offset_duration` after "first" has started.
4815    ///
4816    /// Several precedences can refer to the same (or related) events, e.g.,
4817    /// "pickup of B happens after delivery of A" and "pickup of C happens after
4818    /// pickup of B".
4819    ///
4820    /// Furthermore, precedences only apply when both shipments are performed and
4821    /// are otherwise ignored.
4822    #[derive(Clone, Debug, Default, PartialEq)]
4823    #[non_exhaustive]
4824    pub struct PrecedenceRule {
4825        /// Shipment index of the "first" event. This field must be specified.
4826        pub first_index: std::option::Option<i32>,
4827
4828        /// Indicates if the "first" event is a delivery.
4829        pub first_is_delivery: bool,
4830
4831        /// Shipment index of the "second" event. This field must be specified.
4832        pub second_index: std::option::Option<i32>,
4833
4834        /// Indicates if the "second" event is a delivery.
4835        pub second_is_delivery: bool,
4836
4837        /// The offset between the "first" and "second" event. It can be negative.
4838        pub offset_duration: std::option::Option<wkt::Duration>,
4839
4840        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4841    }
4842
4843    impl PrecedenceRule {
4844        pub fn new() -> Self {
4845            std::default::Default::default()
4846        }
4847
4848        /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
4849        pub fn set_first_index<T>(mut self, v: T) -> Self
4850        where
4851            T: std::convert::Into<i32>,
4852        {
4853            self.first_index = std::option::Option::Some(v.into());
4854            self
4855        }
4856
4857        /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
4858        pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
4859        where
4860            T: std::convert::Into<i32>,
4861        {
4862            self.first_index = v.map(|x| x.into());
4863            self
4864        }
4865
4866        /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
4867        pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4868            self.first_is_delivery = v.into();
4869            self
4870        }
4871
4872        /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
4873        pub fn set_second_index<T>(mut self, v: T) -> Self
4874        where
4875            T: std::convert::Into<i32>,
4876        {
4877            self.second_index = std::option::Option::Some(v.into());
4878            self
4879        }
4880
4881        /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
4882        pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
4883        where
4884            T: std::convert::Into<i32>,
4885        {
4886            self.second_index = v.map(|x| x.into());
4887            self
4888        }
4889
4890        /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
4891        pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4892            self.second_is_delivery = v.into();
4893            self
4894        }
4895
4896        /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
4897        pub fn set_offset_duration<T>(mut self, v: T) -> Self
4898        where
4899            T: std::convert::Into<wkt::Duration>,
4900        {
4901            self.offset_duration = std::option::Option::Some(v.into());
4902            self
4903        }
4904
4905        /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
4906        pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
4907        where
4908            T: std::convert::Into<wkt::Duration>,
4909        {
4910            self.offset_duration = v.map(|x| x.into());
4911            self
4912        }
4913    }
4914
4915    impl wkt::message::Message for PrecedenceRule {
4916        fn typename() -> &'static str {
4917            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
4918        }
4919    }
4920
4921    #[doc(hidden)]
4922    impl<'de> serde::de::Deserialize<'de> for PrecedenceRule {
4923        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4924        where
4925            D: serde::Deserializer<'de>,
4926        {
4927            #[allow(non_camel_case_types)]
4928            #[doc(hidden)]
4929            #[derive(PartialEq, Eq, Hash)]
4930            enum __FieldTag {
4931                __first_index,
4932                __first_is_delivery,
4933                __second_index,
4934                __second_is_delivery,
4935                __offset_duration,
4936                Unknown(std::string::String),
4937            }
4938            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4939                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4940                where
4941                    D: serde::Deserializer<'de>,
4942                {
4943                    struct Visitor;
4944                    impl<'de> serde::de::Visitor<'de> for Visitor {
4945                        type Value = __FieldTag;
4946                        fn expecting(
4947                            &self,
4948                            formatter: &mut std::fmt::Formatter,
4949                        ) -> std::fmt::Result {
4950                            formatter.write_str("a field name for PrecedenceRule")
4951                        }
4952                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4953                        where
4954                            E: serde::de::Error,
4955                        {
4956                            use std::result::Result::Ok;
4957                            use std::string::ToString;
4958                            match value {
4959                                "firstIndex" => Ok(__FieldTag::__first_index),
4960                                "first_index" => Ok(__FieldTag::__first_index),
4961                                "firstIsDelivery" => Ok(__FieldTag::__first_is_delivery),
4962                                "first_is_delivery" => Ok(__FieldTag::__first_is_delivery),
4963                                "secondIndex" => Ok(__FieldTag::__second_index),
4964                                "second_index" => Ok(__FieldTag::__second_index),
4965                                "secondIsDelivery" => Ok(__FieldTag::__second_is_delivery),
4966                                "second_is_delivery" => Ok(__FieldTag::__second_is_delivery),
4967                                "offsetDuration" => Ok(__FieldTag::__offset_duration),
4968                                "offset_duration" => Ok(__FieldTag::__offset_duration),
4969                                _ => Ok(__FieldTag::Unknown(value.to_string())),
4970                            }
4971                        }
4972                    }
4973                    deserializer.deserialize_identifier(Visitor)
4974                }
4975            }
4976            struct Visitor;
4977            impl<'de> serde::de::Visitor<'de> for Visitor {
4978                type Value = PrecedenceRule;
4979                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4980                    formatter.write_str("struct PrecedenceRule")
4981                }
4982                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4983                where
4984                    A: serde::de::MapAccess<'de>,
4985                {
4986                    #[allow(unused_imports)]
4987                    use serde::de::Error;
4988                    use std::option::Option::Some;
4989                    let mut fields = std::collections::HashSet::new();
4990                    let mut result = Self::Value::new();
4991                    while let Some(tag) = map.next_key::<__FieldTag>()? {
4992                        #[allow(clippy::match_single_binding)]
4993                        match tag {
4994                            __FieldTag::__first_index => {
4995                                if !fields.insert(__FieldTag::__first_index) {
4996                                    return std::result::Result::Err(A::Error::duplicate_field(
4997                                        "multiple values for first_index",
4998                                    ));
4999                                }
5000                                struct __With(std::option::Option<i32>);
5001                                impl<'de> serde::de::Deserialize<'de> for __With {
5002                                    fn deserialize<D>(
5003                                        deserializer: D,
5004                                    ) -> std::result::Result<Self, D::Error>
5005                                    where
5006                                        D: serde::de::Deserializer<'de>,
5007                                    {
5008                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
5009                                    }
5010                                }
5011                                result.first_index = map.next_value::<__With>()?.0;
5012                            }
5013                            __FieldTag::__first_is_delivery => {
5014                                if !fields.insert(__FieldTag::__first_is_delivery) {
5015                                    return std::result::Result::Err(A::Error::duplicate_field(
5016                                        "multiple values for first_is_delivery",
5017                                    ));
5018                                }
5019                                result.first_is_delivery = map
5020                                    .next_value::<std::option::Option<bool>>()?
5021                                    .unwrap_or_default();
5022                            }
5023                            __FieldTag::__second_index => {
5024                                if !fields.insert(__FieldTag::__second_index) {
5025                                    return std::result::Result::Err(A::Error::duplicate_field(
5026                                        "multiple values for second_index",
5027                                    ));
5028                                }
5029                                struct __With(std::option::Option<i32>);
5030                                impl<'de> serde::de::Deserialize<'de> for __With {
5031                                    fn deserialize<D>(
5032                                        deserializer: D,
5033                                    ) -> std::result::Result<Self, D::Error>
5034                                    where
5035                                        D: serde::de::Deserializer<'de>,
5036                                    {
5037                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
5038                                    }
5039                                }
5040                                result.second_index = map.next_value::<__With>()?.0;
5041                            }
5042                            __FieldTag::__second_is_delivery => {
5043                                if !fields.insert(__FieldTag::__second_is_delivery) {
5044                                    return std::result::Result::Err(A::Error::duplicate_field(
5045                                        "multiple values for second_is_delivery",
5046                                    ));
5047                                }
5048                                result.second_is_delivery = map
5049                                    .next_value::<std::option::Option<bool>>()?
5050                                    .unwrap_or_default();
5051                            }
5052                            __FieldTag::__offset_duration => {
5053                                if !fields.insert(__FieldTag::__offset_duration) {
5054                                    return std::result::Result::Err(A::Error::duplicate_field(
5055                                        "multiple values for offset_duration",
5056                                    ));
5057                                }
5058                                result.offset_duration =
5059                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
5060                            }
5061                            __FieldTag::Unknown(key) => {
5062                                let value = map.next_value::<serde_json::Value>()?;
5063                                result._unknown_fields.insert(key, value);
5064                            }
5065                        }
5066                    }
5067                    std::result::Result::Ok(result)
5068                }
5069            }
5070            deserializer.deserialize_any(Visitor)
5071        }
5072    }
5073
5074    #[doc(hidden)]
5075    impl serde::ser::Serialize for PrecedenceRule {
5076        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5077        where
5078            S: serde::ser::Serializer,
5079        {
5080            use serde::ser::SerializeMap;
5081            #[allow(unused_imports)]
5082            use std::option::Option::Some;
5083            let mut state = serializer.serialize_map(std::option::Option::None)?;
5084            if self.first_index.is_some() {
5085                struct __With<'a>(&'a std::option::Option<i32>);
5086                impl<'a> serde::ser::Serialize for __With<'a> {
5087                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5088                    where
5089                        S: serde::ser::Serializer,
5090                    {
5091                        serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
5092                            self.0, serializer,
5093                        )
5094                    }
5095                }
5096                state.serialize_entry("firstIndex", &__With(&self.first_index))?;
5097            }
5098            if !wkt::internal::is_default(&self.first_is_delivery) {
5099                state.serialize_entry("firstIsDelivery", &self.first_is_delivery)?;
5100            }
5101            if self.second_index.is_some() {
5102                struct __With<'a>(&'a std::option::Option<i32>);
5103                impl<'a> serde::ser::Serialize for __With<'a> {
5104                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5105                    where
5106                        S: serde::ser::Serializer,
5107                    {
5108                        serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
5109                            self.0, serializer,
5110                        )
5111                    }
5112                }
5113                state.serialize_entry("secondIndex", &__With(&self.second_index))?;
5114            }
5115            if !wkt::internal::is_default(&self.second_is_delivery) {
5116                state.serialize_entry("secondIsDelivery", &self.second_is_delivery)?;
5117            }
5118            if self.offset_duration.is_some() {
5119                state.serialize_entry("offsetDuration", &self.offset_duration)?;
5120            }
5121            if !self._unknown_fields.is_empty() {
5122                for (key, value) in self._unknown_fields.iter() {
5123                    state.serialize_entry(key, &value)?;
5124                }
5125            }
5126            state.end()
5127        }
5128    }
5129
5130    /// Deprecated: Use top level
5131    /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
5132    /// Rules to generate time breaks for a vehicle (e.g. lunch
5133    /// breaks). A break is a contiguous period of time during which the vehicle
5134    /// remains idle at its current position and cannot perform any visit. A break
5135    /// may occur:
5136    ///
5137    /// * during the travel between two visits (which includes the time right
5138    ///   before or right after a visit, but not in the middle of a visit), in
5139    ///   which case it extends the corresponding transit time between the visits
5140    /// * before the vehicle start (the vehicle may not start in the middle of
5141    ///   a break), in which case it does not affect the vehicle start time.
5142    /// * after the vehicle end (ditto, with the vehicle end time).
5143    ///
5144    /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
5145    #[derive(Clone, Debug, Default, PartialEq)]
5146    #[non_exhaustive]
5147    #[deprecated]
5148    pub struct BreakRule {
5149        /// Sequence of breaks. See the `BreakRequest` message.
5150        pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
5151
5152        /// Several `FrequencyConstraint` may apply. They must all be satisfied by
5153        /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
5154        pub frequency_constraints:
5155            std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
5156
5157        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5158    }
5159
5160    impl BreakRule {
5161        pub fn new() -> Self {
5162            std::default::Default::default()
5163        }
5164
5165        /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
5166        pub fn set_break_requests<T, V>(mut self, v: T) -> Self
5167        where
5168            T: std::iter::IntoIterator<Item = V>,
5169            V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
5170        {
5171            use std::iter::Iterator;
5172            self.break_requests = v.into_iter().map(|i| i.into()).collect();
5173            self
5174        }
5175
5176        /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
5177        pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
5178        where
5179            T: std::iter::IntoIterator<Item = V>,
5180            V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
5181        {
5182            use std::iter::Iterator;
5183            self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
5184            self
5185        }
5186    }
5187
5188    impl wkt::message::Message for BreakRule {
5189        fn typename() -> &'static str {
5190            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
5191        }
5192    }
5193
5194    #[doc(hidden)]
5195    impl<'de> serde::de::Deserialize<'de> for BreakRule {
5196        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5197        where
5198            D: serde::Deserializer<'de>,
5199        {
5200            #[allow(non_camel_case_types)]
5201            #[doc(hidden)]
5202            #[derive(PartialEq, Eq, Hash)]
5203            enum __FieldTag {
5204                __break_requests,
5205                __frequency_constraints,
5206                Unknown(std::string::String),
5207            }
5208            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5209                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5210                where
5211                    D: serde::Deserializer<'de>,
5212                {
5213                    struct Visitor;
5214                    impl<'de> serde::de::Visitor<'de> for Visitor {
5215                        type Value = __FieldTag;
5216                        fn expecting(
5217                            &self,
5218                            formatter: &mut std::fmt::Formatter,
5219                        ) -> std::fmt::Result {
5220                            formatter.write_str("a field name for BreakRule")
5221                        }
5222                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5223                        where
5224                            E: serde::de::Error,
5225                        {
5226                            use std::result::Result::Ok;
5227                            use std::string::ToString;
5228                            match value {
5229                                "breakRequests" => Ok(__FieldTag::__break_requests),
5230                                "break_requests" => Ok(__FieldTag::__break_requests),
5231                                "frequencyConstraints" => Ok(__FieldTag::__frequency_constraints),
5232                                "frequency_constraints" => Ok(__FieldTag::__frequency_constraints),
5233                                _ => Ok(__FieldTag::Unknown(value.to_string())),
5234                            }
5235                        }
5236                    }
5237                    deserializer.deserialize_identifier(Visitor)
5238                }
5239            }
5240            struct Visitor;
5241            impl<'de> serde::de::Visitor<'de> for Visitor {
5242                type Value = BreakRule;
5243                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5244                    formatter.write_str("struct BreakRule")
5245                }
5246                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5247                where
5248                    A: serde::de::MapAccess<'de>,
5249                {
5250                    #[allow(unused_imports)]
5251                    use serde::de::Error;
5252                    use std::option::Option::Some;
5253                    let mut fields = std::collections::HashSet::new();
5254                    let mut result = Self::Value::new();
5255                    while let Some(tag) = map.next_key::<__FieldTag>()? {
5256                        #[allow(clippy::match_single_binding)]
5257                        match tag {
5258                            __FieldTag::__break_requests => {
5259                                if !fields.insert(__FieldTag::__break_requests) {
5260                                    return std::result::Result::Err(A::Error::duplicate_field(
5261                                        "multiple values for break_requests",
5262                                    ));
5263                                }
5264                                result.break_requests = map
5265                                    .next_value::<std::option::Option<
5266                                        std::vec::Vec<
5267                                            crate::model::shipment_model::break_rule::BreakRequest,
5268                                        >,
5269                                    >>()?
5270                                    .unwrap_or_default();
5271                            }
5272                            __FieldTag::__frequency_constraints => {
5273                                if !fields.insert(__FieldTag::__frequency_constraints) {
5274                                    return std::result::Result::Err(A::Error::duplicate_field(
5275                                        "multiple values for frequency_constraints",
5276                                    ));
5277                                }
5278                                result.frequency_constraints = map.next_value::<std::option::Option<std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>>>()?.unwrap_or_default();
5279                            }
5280                            __FieldTag::Unknown(key) => {
5281                                let value = map.next_value::<serde_json::Value>()?;
5282                                result._unknown_fields.insert(key, value);
5283                            }
5284                        }
5285                    }
5286                    std::result::Result::Ok(result)
5287                }
5288            }
5289            deserializer.deserialize_any(Visitor)
5290        }
5291    }
5292
5293    #[doc(hidden)]
5294    impl serde::ser::Serialize for BreakRule {
5295        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5296        where
5297            S: serde::ser::Serializer,
5298        {
5299            use serde::ser::SerializeMap;
5300            #[allow(unused_imports)]
5301            use std::option::Option::Some;
5302            let mut state = serializer.serialize_map(std::option::Option::None)?;
5303            if !self.break_requests.is_empty() {
5304                state.serialize_entry("breakRequests", &self.break_requests)?;
5305            }
5306            if !self.frequency_constraints.is_empty() {
5307                state.serialize_entry("frequencyConstraints", &self.frequency_constraints)?;
5308            }
5309            if !self._unknown_fields.is_empty() {
5310                for (key, value) in self._unknown_fields.iter() {
5311                    state.serialize_entry(key, &value)?;
5312                }
5313            }
5314            state.end()
5315        }
5316    }
5317
5318    /// Defines additional types related to [BreakRule].
5319    pub mod break_rule {
5320        #[allow(unused_imports)]
5321        use super::*;
5322
5323        /// The sequence of breaks (i.e. their number and order) that apply to each
5324        /// vehicle must be known beforehand. The repeated `BreakRequest`s define
5325        /// that sequence, in the order in which they must occur. Their time windows
5326        /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
5327        /// be compatible with the order (this is checked).
5328        #[derive(Clone, Debug, Default, PartialEq)]
5329        #[non_exhaustive]
5330        pub struct BreakRequest {
5331            /// Required. Lower bound (inclusive) on the start of the break.
5332            pub earliest_start_time: std::option::Option<wkt::Timestamp>,
5333
5334            /// Required. Upper bound (inclusive) on the start of the break.
5335            pub latest_start_time: std::option::Option<wkt::Timestamp>,
5336
5337            /// Required. Minimum duration of the break. Must be positive.
5338            pub min_duration: std::option::Option<wkt::Duration>,
5339
5340            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5341        }
5342
5343        impl BreakRequest {
5344            pub fn new() -> Self {
5345                std::default::Default::default()
5346            }
5347
5348            /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
5349            pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
5350            where
5351                T: std::convert::Into<wkt::Timestamp>,
5352            {
5353                self.earliest_start_time = std::option::Option::Some(v.into());
5354                self
5355            }
5356
5357            /// Sets or clears the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
5358            pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5359            where
5360                T: std::convert::Into<wkt::Timestamp>,
5361            {
5362                self.earliest_start_time = v.map(|x| x.into());
5363                self
5364            }
5365
5366            /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
5367            pub fn set_latest_start_time<T>(mut self, v: T) -> Self
5368            where
5369                T: std::convert::Into<wkt::Timestamp>,
5370            {
5371                self.latest_start_time = std::option::Option::Some(v.into());
5372                self
5373            }
5374
5375            /// Sets or clears the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
5376            pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5377            where
5378                T: std::convert::Into<wkt::Timestamp>,
5379            {
5380                self.latest_start_time = v.map(|x| x.into());
5381                self
5382            }
5383
5384            /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
5385            pub fn set_min_duration<T>(mut self, v: T) -> Self
5386            where
5387                T: std::convert::Into<wkt::Duration>,
5388            {
5389                self.min_duration = std::option::Option::Some(v.into());
5390                self
5391            }
5392
5393            /// Sets or clears the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
5394            pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
5395            where
5396                T: std::convert::Into<wkt::Duration>,
5397            {
5398                self.min_duration = v.map(|x| x.into());
5399                self
5400            }
5401        }
5402
5403        impl wkt::message::Message for BreakRequest {
5404            fn typename() -> &'static str {
5405                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
5406            }
5407        }
5408
5409        #[doc(hidden)]
5410        impl<'de> serde::de::Deserialize<'de> for BreakRequest {
5411            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5412            where
5413                D: serde::Deserializer<'de>,
5414            {
5415                #[allow(non_camel_case_types)]
5416                #[doc(hidden)]
5417                #[derive(PartialEq, Eq, Hash)]
5418                enum __FieldTag {
5419                    __earliest_start_time,
5420                    __latest_start_time,
5421                    __min_duration,
5422                    Unknown(std::string::String),
5423                }
5424                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5425                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5426                    where
5427                        D: serde::Deserializer<'de>,
5428                    {
5429                        struct Visitor;
5430                        impl<'de> serde::de::Visitor<'de> for Visitor {
5431                            type Value = __FieldTag;
5432                            fn expecting(
5433                                &self,
5434                                formatter: &mut std::fmt::Formatter,
5435                            ) -> std::fmt::Result {
5436                                formatter.write_str("a field name for BreakRequest")
5437                            }
5438                            fn visit_str<E>(
5439                                self,
5440                                value: &str,
5441                            ) -> std::result::Result<Self::Value, E>
5442                            where
5443                                E: serde::de::Error,
5444                            {
5445                                use std::result::Result::Ok;
5446                                use std::string::ToString;
5447                                match value {
5448                                    "earliestStartTime" => Ok(__FieldTag::__earliest_start_time),
5449                                    "earliest_start_time" => Ok(__FieldTag::__earliest_start_time),
5450                                    "latestStartTime" => Ok(__FieldTag::__latest_start_time),
5451                                    "latest_start_time" => Ok(__FieldTag::__latest_start_time),
5452                                    "minDuration" => Ok(__FieldTag::__min_duration),
5453                                    "min_duration" => Ok(__FieldTag::__min_duration),
5454                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
5455                                }
5456                            }
5457                        }
5458                        deserializer.deserialize_identifier(Visitor)
5459                    }
5460                }
5461                struct Visitor;
5462                impl<'de> serde::de::Visitor<'de> for Visitor {
5463                    type Value = BreakRequest;
5464                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5465                        formatter.write_str("struct BreakRequest")
5466                    }
5467                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5468                    where
5469                        A: serde::de::MapAccess<'de>,
5470                    {
5471                        #[allow(unused_imports)]
5472                        use serde::de::Error;
5473                        use std::option::Option::Some;
5474                        let mut fields = std::collections::HashSet::new();
5475                        let mut result = Self::Value::new();
5476                        while let Some(tag) = map.next_key::<__FieldTag>()? {
5477                            #[allow(clippy::match_single_binding)]
5478                            match tag {
5479                                __FieldTag::__earliest_start_time => {
5480                                    if !fields.insert(__FieldTag::__earliest_start_time) {
5481                                        return std::result::Result::Err(
5482                                            A::Error::duplicate_field(
5483                                                "multiple values for earliest_start_time",
5484                                            ),
5485                                        );
5486                                    }
5487                                    result.earliest_start_time =
5488                                        map.next_value::<std::option::Option<wkt::Timestamp>>()?;
5489                                }
5490                                __FieldTag::__latest_start_time => {
5491                                    if !fields.insert(__FieldTag::__latest_start_time) {
5492                                        return std::result::Result::Err(
5493                                            A::Error::duplicate_field(
5494                                                "multiple values for latest_start_time",
5495                                            ),
5496                                        );
5497                                    }
5498                                    result.latest_start_time =
5499                                        map.next_value::<std::option::Option<wkt::Timestamp>>()?;
5500                                }
5501                                __FieldTag::__min_duration => {
5502                                    if !fields.insert(__FieldTag::__min_duration) {
5503                                        return std::result::Result::Err(
5504                                            A::Error::duplicate_field(
5505                                                "multiple values for min_duration",
5506                                            ),
5507                                        );
5508                                    }
5509                                    result.min_duration =
5510                                        map.next_value::<std::option::Option<wkt::Duration>>()?;
5511                                }
5512                                __FieldTag::Unknown(key) => {
5513                                    let value = map.next_value::<serde_json::Value>()?;
5514                                    result._unknown_fields.insert(key, value);
5515                                }
5516                            }
5517                        }
5518                        std::result::Result::Ok(result)
5519                    }
5520                }
5521                deserializer.deserialize_any(Visitor)
5522            }
5523        }
5524
5525        #[doc(hidden)]
5526        impl serde::ser::Serialize for BreakRequest {
5527            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5528            where
5529                S: serde::ser::Serializer,
5530            {
5531                use serde::ser::SerializeMap;
5532                #[allow(unused_imports)]
5533                use std::option::Option::Some;
5534                let mut state = serializer.serialize_map(std::option::Option::None)?;
5535                if self.earliest_start_time.is_some() {
5536                    state.serialize_entry("earliestStartTime", &self.earliest_start_time)?;
5537                }
5538                if self.latest_start_time.is_some() {
5539                    state.serialize_entry("latestStartTime", &self.latest_start_time)?;
5540                }
5541                if self.min_duration.is_some() {
5542                    state.serialize_entry("minDuration", &self.min_duration)?;
5543                }
5544                if !self._unknown_fields.is_empty() {
5545                    for (key, value) in self._unknown_fields.iter() {
5546                        state.serialize_entry(key, &value)?;
5547                    }
5548                }
5549                state.end()
5550            }
5551        }
5552
5553        /// One may further constrain the frequency and duration of the breaks
5554        /// specified above, by enforcing a minimum break frequency, such as
5555        /// "There must be a break of at least 1 hour every 12 hours". Assuming that
5556        /// this can be interpreted as "Within any sliding time window of 12h, there
5557        /// must be at least one break of at least one hour", that example would
5558        /// translate to the following `FrequencyConstraint`:
5559        ///
5560        /// ```norust
5561        /// {
5562        ///    min_break_duration { seconds: 3600 }         # 1 hour.
5563        ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
5564        /// }
5565        /// ```
5566        ///
5567        /// The timing and duration of the breaks in the solution will respect all
5568        /// such constraints, in addition to the time windows and minimum durations
5569        /// already specified in the `BreakRequest`.
5570        ///
5571        /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
5572        /// For example, the following schedule honors the "1h every 12h" example:
5573        ///
5574        /// ```norust
5575        ///   04:00 vehicle start
5576        ///    .. performing travel and visits ..
5577        ///   09:00 1 hour break
5578        ///   10:00 end of the break
5579        ///    .. performing travel and visits ..
5580        ///   12:00 20-min lunch break
5581        ///   12:20 end of the break
5582        ///    .. performing travel and visits ..
5583        ///   21:00 1 hour break
5584        ///   22:00 end of the break
5585        ///    .. performing travel and visits ..
5586        ///   23:59 vehicle end
5587        /// ```
5588        #[derive(Clone, Debug, Default, PartialEq)]
5589        #[non_exhaustive]
5590        pub struct FrequencyConstraint {
5591            /// Required. Minimum break duration for this constraint. Nonnegative.
5592            /// See description of `FrequencyConstraint`.
5593            pub min_break_duration: std::option::Option<wkt::Duration>,
5594
5595            /// Required. Maximum allowed span of any interval of time in the route
5596            /// that does not include at least partially a break of `duration >=
5597            /// min_break_duration`. Must be positive.
5598            pub max_inter_break_duration: std::option::Option<wkt::Duration>,
5599
5600            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5601        }
5602
5603        impl FrequencyConstraint {
5604            pub fn new() -> Self {
5605                std::default::Default::default()
5606            }
5607
5608            /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
5609            pub fn set_min_break_duration<T>(mut self, v: T) -> Self
5610            where
5611                T: std::convert::Into<wkt::Duration>,
5612            {
5613                self.min_break_duration = std::option::Option::Some(v.into());
5614                self
5615            }
5616
5617            /// Sets or clears the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
5618            pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
5619            where
5620                T: std::convert::Into<wkt::Duration>,
5621            {
5622                self.min_break_duration = v.map(|x| x.into());
5623                self
5624            }
5625
5626            /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
5627            pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
5628            where
5629                T: std::convert::Into<wkt::Duration>,
5630            {
5631                self.max_inter_break_duration = std::option::Option::Some(v.into());
5632                self
5633            }
5634
5635            /// Sets or clears the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
5636            pub fn set_or_clear_max_inter_break_duration<T>(
5637                mut self,
5638                v: std::option::Option<T>,
5639            ) -> Self
5640            where
5641                T: std::convert::Into<wkt::Duration>,
5642            {
5643                self.max_inter_break_duration = v.map(|x| x.into());
5644                self
5645            }
5646        }
5647
5648        impl wkt::message::Message for FrequencyConstraint {
5649            fn typename() -> &'static str {
5650                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
5651            }
5652        }
5653
5654        #[doc(hidden)]
5655        impl<'de> serde::de::Deserialize<'de> for FrequencyConstraint {
5656            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5657            where
5658                D: serde::Deserializer<'de>,
5659            {
5660                #[allow(non_camel_case_types)]
5661                #[doc(hidden)]
5662                #[derive(PartialEq, Eq, Hash)]
5663                enum __FieldTag {
5664                    __min_break_duration,
5665                    __max_inter_break_duration,
5666                    Unknown(std::string::String),
5667                }
5668                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5669                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5670                    where
5671                        D: serde::Deserializer<'de>,
5672                    {
5673                        struct Visitor;
5674                        impl<'de> serde::de::Visitor<'de> for Visitor {
5675                            type Value = __FieldTag;
5676                            fn expecting(
5677                                &self,
5678                                formatter: &mut std::fmt::Formatter,
5679                            ) -> std::fmt::Result {
5680                                formatter.write_str("a field name for FrequencyConstraint")
5681                            }
5682                            fn visit_str<E>(
5683                                self,
5684                                value: &str,
5685                            ) -> std::result::Result<Self::Value, E>
5686                            where
5687                                E: serde::de::Error,
5688                            {
5689                                use std::result::Result::Ok;
5690                                use std::string::ToString;
5691                                match value {
5692                                    "minBreakDuration" => Ok(__FieldTag::__min_break_duration),
5693                                    "min_break_duration" => Ok(__FieldTag::__min_break_duration),
5694                                    "maxInterBreakDuration" => {
5695                                        Ok(__FieldTag::__max_inter_break_duration)
5696                                    }
5697                                    "max_inter_break_duration" => {
5698                                        Ok(__FieldTag::__max_inter_break_duration)
5699                                    }
5700                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
5701                                }
5702                            }
5703                        }
5704                        deserializer.deserialize_identifier(Visitor)
5705                    }
5706                }
5707                struct Visitor;
5708                impl<'de> serde::de::Visitor<'de> for Visitor {
5709                    type Value = FrequencyConstraint;
5710                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5711                        formatter.write_str("struct FrequencyConstraint")
5712                    }
5713                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5714                    where
5715                        A: serde::de::MapAccess<'de>,
5716                    {
5717                        #[allow(unused_imports)]
5718                        use serde::de::Error;
5719                        use std::option::Option::Some;
5720                        let mut fields = std::collections::HashSet::new();
5721                        let mut result = Self::Value::new();
5722                        while let Some(tag) = map.next_key::<__FieldTag>()? {
5723                            #[allow(clippy::match_single_binding)]
5724                            match tag {
5725                                __FieldTag::__min_break_duration => {
5726                                    if !fields.insert(__FieldTag::__min_break_duration) {
5727                                        return std::result::Result::Err(
5728                                            A::Error::duplicate_field(
5729                                                "multiple values for min_break_duration",
5730                                            ),
5731                                        );
5732                                    }
5733                                    result.min_break_duration =
5734                                        map.next_value::<std::option::Option<wkt::Duration>>()?;
5735                                }
5736                                __FieldTag::__max_inter_break_duration => {
5737                                    if !fields.insert(__FieldTag::__max_inter_break_duration) {
5738                                        return std::result::Result::Err(
5739                                            A::Error::duplicate_field(
5740                                                "multiple values for max_inter_break_duration",
5741                                            ),
5742                                        );
5743                                    }
5744                                    result.max_inter_break_duration =
5745                                        map.next_value::<std::option::Option<wkt::Duration>>()?;
5746                                }
5747                                __FieldTag::Unknown(key) => {
5748                                    let value = map.next_value::<serde_json::Value>()?;
5749                                    result._unknown_fields.insert(key, value);
5750                                }
5751                            }
5752                        }
5753                        std::result::Result::Ok(result)
5754                    }
5755                }
5756                deserializer.deserialize_any(Visitor)
5757            }
5758        }
5759
5760        #[doc(hidden)]
5761        impl serde::ser::Serialize for FrequencyConstraint {
5762            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5763            where
5764                S: serde::ser::Serializer,
5765            {
5766                use serde::ser::SerializeMap;
5767                #[allow(unused_imports)]
5768                use std::option::Option::Some;
5769                let mut state = serializer.serialize_map(std::option::Option::None)?;
5770                if self.min_break_duration.is_some() {
5771                    state.serialize_entry("minBreakDuration", &self.min_break_duration)?;
5772                }
5773                if self.max_inter_break_duration.is_some() {
5774                    state
5775                        .serialize_entry("maxInterBreakDuration", &self.max_inter_break_duration)?;
5776                }
5777                if !self._unknown_fields.is_empty() {
5778                    for (key, value) in self._unknown_fields.iter() {
5779                        state.serialize_entry(key, &value)?;
5780                    }
5781                }
5782                state.end()
5783            }
5784        }
5785    }
5786}
5787
5788/// The shipment of a single item, from one of its pickups to one of its
5789/// deliveries. For the shipment to be considered as performed, a unique vehicle
5790/// must visit one of its pickup locations (and decrease its spare capacities
5791/// accordingly), then visit one of its delivery locations later on (and
5792/// therefore re-increase its spare capacities accordingly).
5793#[derive(Clone, Debug, Default, PartialEq)]
5794#[non_exhaustive]
5795pub struct Shipment {
5796    /// Set of pickup alternatives associated to the shipment. If not specified,
5797    /// the vehicle only needs to visit a location corresponding to the deliveries.
5798    pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
5799
5800    /// Set of delivery alternatives associated to the shipment. If not specified,
5801    /// the vehicle only needs to visit a location corresponding to the pickups.
5802    pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
5803
5804    /// Load demands of the shipment (for example weight, volume, number of
5805    /// pallets etc). The keys in the map should be identifiers describing the type
5806    /// of the corresponding load, ideally also including the units.
5807    /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
5808    /// If a given key does not appear in the map, the corresponding load is
5809    /// considered as null.
5810    pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
5811
5812    /// If the shipment is not completed, this penalty is added to the overall
5813    /// cost of the routes. A shipment is considered completed if one of its pickup
5814    /// and delivery alternatives is visited. The cost may be expressed in the
5815    /// same unit used for all other cost-related fields in the model and must be
5816    /// positive.
5817    ///
5818    /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
5819    /// i.e. the shipment must be completed.
5820    pub penalty_cost: std::option::Option<f64>,
5821
5822    /// The set of vehicles that may perform this shipment. If empty, all vehicles
5823    /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
5824    /// `vehicles` list.
5825    pub allowed_vehicle_indices: std::vec::Vec<i32>,
5826
5827    /// Specifies the cost that is incurred when this shipment is delivered by each
5828    /// vehicle. If specified, it must have EITHER:
5829    ///
5830    /// * the same number of elements as `costs_per_vehicle_indices`.
5831    ///   `costs_per_vehicle[i]` corresponds to vehicle
5832    ///   `costs_per_vehicle_indices[i]` of the model.
5833    /// * the same number of elements as there are vehicles in the model. The
5834    ///   i-th element corresponds to vehicle #i of the model.
5835    ///
5836    /// These costs must be in the same unit as `penalty_cost` and must not be
5837    /// negative. Leave this field empty, if there are no such costs.
5838    pub costs_per_vehicle: std::vec::Vec<f64>,
5839
5840    /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
5841    /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
5842    /// index may not be specified more than once. If a vehicle is excluded from
5843    /// `costs_per_vehicle_indices`, its cost is zero.
5844    pub costs_per_vehicle_indices: std::vec::Vec<i32>,
5845
5846    /// Specifies the maximum relative detour time compared to the shortest path
5847    /// from pickup to delivery. If specified, it must be nonnegative, and the
5848    /// shipment must contain at least a pickup and a delivery.
5849    ///
5850    /// For example, let t be the shortest time taken to go from the selected
5851    /// pickup alternative directly to the selected delivery alternative. Then
5852    /// setting `pickup_to_delivery_relative_detour_limit` enforces:
5853    ///
5854    /// ```norust
5855    /// start_time(delivery) - start_time(pickup) <=
5856    /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
5857    /// ```
5858    ///
5859    /// If both relative and absolute limits are specified on the same shipment,
5860    /// the more constraining limit is used for each possible pickup/delivery pair.
5861    /// As of 2017/10, detours are only supported when travel durations do not
5862    /// depend on vehicles.
5863    pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
5864
5865    /// Specifies the maximum absolute detour time compared to the shortest path
5866    /// from pickup to delivery. If specified, it must be nonnegative, and the
5867    /// shipment must contain at least a pickup and a delivery.
5868    ///
5869    /// For example, let t be the shortest time taken to go from the selected
5870    /// pickup alternative directly to the selected delivery alternative. Then
5871    /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
5872    ///
5873    /// ```norust
5874    /// start_time(delivery) - start_time(pickup) <=
5875    /// t + pickup_to_delivery_absolute_detour_limit
5876    /// ```
5877    ///
5878    /// If both relative and absolute limits are specified on the same shipment,
5879    /// the more constraining limit is used for each possible pickup/delivery pair.
5880    /// As of 2017/10, detours are only supported when travel durations do not
5881    /// depend on vehicles.
5882    pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
5883
5884    /// Specifies the maximum duration from start of pickup to start of delivery of
5885    /// a shipment. If specified, it must be nonnegative, and the shipment must
5886    /// contain at least a pickup and a delivery. This does not depend on which
5887    /// alternatives are selected for pickup and delivery, nor on vehicle speed.
5888    /// This can be specified alongside maximum detour constraints: the solution
5889    /// will respect both specifications.
5890    pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
5891
5892    /// Non-empty string specifying a "type" for this shipment.
5893    /// This feature can be used to define incompatibilities or requirements
5894    /// between `shipment_types` (see `shipment_type_incompatibilities` and
5895    /// `shipment_type_requirements` in `ShipmentModel`).
5896    ///
5897    /// Differs from `visit_types` which is specified for a single visit: All
5898    /// pickup/deliveries belonging to the same shipment share the same
5899    /// `shipment_type`.
5900    pub shipment_type: std::string::String,
5901
5902    /// Specifies a label for this shipment. This label is reported in the response
5903    /// in the `shipment_label` of the corresponding
5904    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
5905    ///
5906    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
5907    pub label: std::string::String,
5908
5909    /// If true, skip this shipment, but don't apply a `penalty_cost`.
5910    ///
5911    /// Ignoring a shipment results in a validation error when there are any
5912    /// `shipment_type_requirements` in the model.
5913    ///
5914    /// Ignoring a shipment that is performed in `injected_first_solution_routes`
5915    /// or `injected_solution_constraint` is permitted; the solver removes the
5916    /// related pickup/delivery visits from the performing route.
5917    /// `precedence_rules` that reference ignored shipments will also be ignored.
5918    pub ignore: bool,
5919
5920    /// Deprecated: Use
5921    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
5922    /// instead.
5923    ///
5924    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
5925    #[deprecated]
5926    pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
5927
5928    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5929}
5930
5931impl Shipment {
5932    pub fn new() -> Self {
5933        std::default::Default::default()
5934    }
5935
5936    /// Sets the value of [pickups][crate::model::Shipment::pickups].
5937    pub fn set_pickups<T, V>(mut self, v: T) -> Self
5938    where
5939        T: std::iter::IntoIterator<Item = V>,
5940        V: std::convert::Into<crate::model::shipment::VisitRequest>,
5941    {
5942        use std::iter::Iterator;
5943        self.pickups = v.into_iter().map(|i| i.into()).collect();
5944        self
5945    }
5946
5947    /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
5948    pub fn set_deliveries<T, V>(mut self, v: T) -> Self
5949    where
5950        T: std::iter::IntoIterator<Item = V>,
5951        V: std::convert::Into<crate::model::shipment::VisitRequest>,
5952    {
5953        use std::iter::Iterator;
5954        self.deliveries = v.into_iter().map(|i| i.into()).collect();
5955        self
5956    }
5957
5958    /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
5959    pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
5960    where
5961        T: std::iter::IntoIterator<Item = (K, V)>,
5962        K: std::convert::Into<std::string::String>,
5963        V: std::convert::Into<crate::model::shipment::Load>,
5964    {
5965        use std::iter::Iterator;
5966        self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5967        self
5968    }
5969
5970    /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
5971    pub fn set_penalty_cost<T>(mut self, v: T) -> Self
5972    where
5973        T: std::convert::Into<f64>,
5974    {
5975        self.penalty_cost = std::option::Option::Some(v.into());
5976        self
5977    }
5978
5979    /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
5980    pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
5981    where
5982        T: std::convert::Into<f64>,
5983    {
5984        self.penalty_cost = v.map(|x| x.into());
5985        self
5986    }
5987
5988    /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
5989    pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
5990    where
5991        T: std::iter::IntoIterator<Item = V>,
5992        V: std::convert::Into<i32>,
5993    {
5994        use std::iter::Iterator;
5995        self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
5996        self
5997    }
5998
5999    /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
6000    pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
6001    where
6002        T: std::iter::IntoIterator<Item = V>,
6003        V: std::convert::Into<f64>,
6004    {
6005        use std::iter::Iterator;
6006        self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
6007        self
6008    }
6009
6010    /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
6011    pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
6012    where
6013        T: std::iter::IntoIterator<Item = V>,
6014        V: std::convert::Into<i32>,
6015    {
6016        use std::iter::Iterator;
6017        self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
6018        self
6019    }
6020
6021    /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
6022    pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
6023    where
6024        T: std::convert::Into<f64>,
6025    {
6026        self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
6027        self
6028    }
6029
6030    /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
6031    pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
6032        mut self,
6033        v: std::option::Option<T>,
6034    ) -> Self
6035    where
6036        T: std::convert::Into<f64>,
6037    {
6038        self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
6039        self
6040    }
6041
6042    /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
6043    pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
6044    where
6045        T: std::convert::Into<wkt::Duration>,
6046    {
6047        self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
6048        self
6049    }
6050
6051    /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
6052    pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
6053        mut self,
6054        v: std::option::Option<T>,
6055    ) -> Self
6056    where
6057        T: std::convert::Into<wkt::Duration>,
6058    {
6059        self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
6060        self
6061    }
6062
6063    /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
6064    pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
6065    where
6066        T: std::convert::Into<wkt::Duration>,
6067    {
6068        self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
6069        self
6070    }
6071
6072    /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
6073    pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
6074        mut self,
6075        v: std::option::Option<T>,
6076    ) -> Self
6077    where
6078        T: std::convert::Into<wkt::Duration>,
6079    {
6080        self.pickup_to_delivery_time_limit = v.map(|x| x.into());
6081        self
6082    }
6083
6084    /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
6085    pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6086        self.shipment_type = v.into();
6087        self
6088    }
6089
6090    /// Sets the value of [label][crate::model::Shipment::label].
6091    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6092        self.label = v.into();
6093        self
6094    }
6095
6096    /// Sets the value of [ignore][crate::model::Shipment::ignore].
6097    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6098        self.ignore = v.into();
6099        self
6100    }
6101
6102    /// Sets the value of [demands][crate::model::Shipment::demands].
6103    #[deprecated]
6104    pub fn set_demands<T, V>(mut self, v: T) -> Self
6105    where
6106        T: std::iter::IntoIterator<Item = V>,
6107        V: std::convert::Into<crate::model::CapacityQuantity>,
6108    {
6109        use std::iter::Iterator;
6110        self.demands = v.into_iter().map(|i| i.into()).collect();
6111        self
6112    }
6113}
6114
6115impl wkt::message::Message for Shipment {
6116    fn typename() -> &'static str {
6117        "type.googleapis.com/google.cloud.optimization.v1.Shipment"
6118    }
6119}
6120
6121#[doc(hidden)]
6122impl<'de> serde::de::Deserialize<'de> for Shipment {
6123    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6124    where
6125        D: serde::Deserializer<'de>,
6126    {
6127        #[allow(non_camel_case_types)]
6128        #[doc(hidden)]
6129        #[derive(PartialEq, Eq, Hash)]
6130        enum __FieldTag {
6131            __pickups,
6132            __deliveries,
6133            __load_demands,
6134            __penalty_cost,
6135            __allowed_vehicle_indices,
6136            __costs_per_vehicle,
6137            __costs_per_vehicle_indices,
6138            __pickup_to_delivery_relative_detour_limit,
6139            __pickup_to_delivery_absolute_detour_limit,
6140            __pickup_to_delivery_time_limit,
6141            __shipment_type,
6142            __label,
6143            __ignore,
6144            __demands,
6145            Unknown(std::string::String),
6146        }
6147        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6148            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6149            where
6150                D: serde::Deserializer<'de>,
6151            {
6152                struct Visitor;
6153                impl<'de> serde::de::Visitor<'de> for Visitor {
6154                    type Value = __FieldTag;
6155                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6156                        formatter.write_str("a field name for Shipment")
6157                    }
6158                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6159                    where
6160                        E: serde::de::Error,
6161                    {
6162                        use std::result::Result::Ok;
6163                        use std::string::ToString;
6164                        match value {
6165                            "pickups" => Ok(__FieldTag::__pickups),
6166                            "deliveries" => Ok(__FieldTag::__deliveries),
6167                            "loadDemands" => Ok(__FieldTag::__load_demands),
6168                            "load_demands" => Ok(__FieldTag::__load_demands),
6169                            "penaltyCost" => Ok(__FieldTag::__penalty_cost),
6170                            "penalty_cost" => Ok(__FieldTag::__penalty_cost),
6171                            "allowedVehicleIndices" => Ok(__FieldTag::__allowed_vehicle_indices),
6172                            "allowed_vehicle_indices" => Ok(__FieldTag::__allowed_vehicle_indices),
6173                            "costsPerVehicle" => Ok(__FieldTag::__costs_per_vehicle),
6174                            "costs_per_vehicle" => Ok(__FieldTag::__costs_per_vehicle),
6175                            "costsPerVehicleIndices" => Ok(__FieldTag::__costs_per_vehicle_indices),
6176                            "costs_per_vehicle_indices" => {
6177                                Ok(__FieldTag::__costs_per_vehicle_indices)
6178                            }
6179                            "pickupToDeliveryRelativeDetourLimit" => {
6180                                Ok(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6181                            }
6182                            "pickup_to_delivery_relative_detour_limit" => {
6183                                Ok(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6184                            }
6185                            "pickupToDeliveryAbsoluteDetourLimit" => {
6186                                Ok(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6187                            }
6188                            "pickup_to_delivery_absolute_detour_limit" => {
6189                                Ok(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6190                            }
6191                            "pickupToDeliveryTimeLimit" => {
6192                                Ok(__FieldTag::__pickup_to_delivery_time_limit)
6193                            }
6194                            "pickup_to_delivery_time_limit" => {
6195                                Ok(__FieldTag::__pickup_to_delivery_time_limit)
6196                            }
6197                            "shipmentType" => Ok(__FieldTag::__shipment_type),
6198                            "shipment_type" => Ok(__FieldTag::__shipment_type),
6199                            "label" => Ok(__FieldTag::__label),
6200                            "ignore" => Ok(__FieldTag::__ignore),
6201                            "demands" => Ok(__FieldTag::__demands),
6202                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6203                        }
6204                    }
6205                }
6206                deserializer.deserialize_identifier(Visitor)
6207            }
6208        }
6209        struct Visitor;
6210        impl<'de> serde::de::Visitor<'de> for Visitor {
6211            type Value = Shipment;
6212            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6213                formatter.write_str("struct Shipment")
6214            }
6215            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6216            where
6217                A: serde::de::MapAccess<'de>,
6218            {
6219                #[allow(unused_imports)]
6220                use serde::de::Error;
6221                use std::option::Option::Some;
6222                let mut fields = std::collections::HashSet::new();
6223                let mut result = Self::Value::new();
6224                while let Some(tag) = map.next_key::<__FieldTag>()? {
6225                    #[allow(clippy::match_single_binding)]
6226                    match tag {
6227                        __FieldTag::__pickups => {
6228                            if !fields.insert(__FieldTag::__pickups) {
6229                                return std::result::Result::Err(A::Error::duplicate_field(
6230                                    "multiple values for pickups",
6231                                ));
6232                            }
6233                            result.pickups = map
6234                                .next_value::<std::option::Option<
6235                                    std::vec::Vec<crate::model::shipment::VisitRequest>,
6236                                >>()?
6237                                .unwrap_or_default();
6238                        }
6239                        __FieldTag::__deliveries => {
6240                            if !fields.insert(__FieldTag::__deliveries) {
6241                                return std::result::Result::Err(A::Error::duplicate_field(
6242                                    "multiple values for deliveries",
6243                                ));
6244                            }
6245                            result.deliveries = map
6246                                .next_value::<std::option::Option<
6247                                    std::vec::Vec<crate::model::shipment::VisitRequest>,
6248                                >>()?
6249                                .unwrap_or_default();
6250                        }
6251                        __FieldTag::__load_demands => {
6252                            if !fields.insert(__FieldTag::__load_demands) {
6253                                return std::result::Result::Err(A::Error::duplicate_field(
6254                                    "multiple values for load_demands",
6255                                ));
6256                            }
6257                            result.load_demands = map
6258                                .next_value::<std::option::Option<
6259                                    std::collections::HashMap<
6260                                        std::string::String,
6261                                        crate::model::shipment::Load,
6262                                    >,
6263                                >>()?
6264                                .unwrap_or_default();
6265                        }
6266                        __FieldTag::__penalty_cost => {
6267                            if !fields.insert(__FieldTag::__penalty_cost) {
6268                                return std::result::Result::Err(A::Error::duplicate_field(
6269                                    "multiple values for penalty_cost",
6270                                ));
6271                            }
6272                            struct __With(std::option::Option<f64>);
6273                            impl<'de> serde::de::Deserialize<'de> for __With {
6274                                fn deserialize<D>(
6275                                    deserializer: D,
6276                                ) -> std::result::Result<Self, D::Error>
6277                                where
6278                                    D: serde::de::Deserializer<'de>,
6279                                {
6280                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
6281                                }
6282                            }
6283                            result.penalty_cost = map.next_value::<__With>()?.0;
6284                        }
6285                        __FieldTag::__allowed_vehicle_indices => {
6286                            if !fields.insert(__FieldTag::__allowed_vehicle_indices) {
6287                                return std::result::Result::Err(A::Error::duplicate_field(
6288                                    "multiple values for allowed_vehicle_indices",
6289                                ));
6290                            }
6291                            struct __With(std::option::Option<std::vec::Vec<i32>>);
6292                            impl<'de> serde::de::Deserialize<'de> for __With {
6293                                fn deserialize<D>(
6294                                    deserializer: D,
6295                                ) -> std::result::Result<Self, D::Error>
6296                                where
6297                                    D: serde::de::Deserializer<'de>,
6298                                {
6299                                    serde_with::As::<
6300                                        std::option::Option<std::vec::Vec<wkt::internal::I32>>,
6301                                    >::deserialize(deserializer)
6302                                    .map(__With)
6303                                }
6304                            }
6305                            result.allowed_vehicle_indices =
6306                                map.next_value::<__With>()?.0.unwrap_or_default();
6307                        }
6308                        __FieldTag::__costs_per_vehicle => {
6309                            if !fields.insert(__FieldTag::__costs_per_vehicle) {
6310                                return std::result::Result::Err(A::Error::duplicate_field(
6311                                    "multiple values for costs_per_vehicle",
6312                                ));
6313                            }
6314                            struct __With(std::option::Option<std::vec::Vec<f64>>);
6315                            impl<'de> serde::de::Deserialize<'de> for __With {
6316                                fn deserialize<D>(
6317                                    deserializer: D,
6318                                ) -> std::result::Result<Self, D::Error>
6319                                where
6320                                    D: serde::de::Deserializer<'de>,
6321                                {
6322                                    serde_with::As::<
6323                                        std::option::Option<std::vec::Vec<wkt::internal::F64>>,
6324                                    >::deserialize(deserializer)
6325                                    .map(__With)
6326                                }
6327                            }
6328                            result.costs_per_vehicle =
6329                                map.next_value::<__With>()?.0.unwrap_or_default();
6330                        }
6331                        __FieldTag::__costs_per_vehicle_indices => {
6332                            if !fields.insert(__FieldTag::__costs_per_vehicle_indices) {
6333                                return std::result::Result::Err(A::Error::duplicate_field(
6334                                    "multiple values for costs_per_vehicle_indices",
6335                                ));
6336                            }
6337                            struct __With(std::option::Option<std::vec::Vec<i32>>);
6338                            impl<'de> serde::de::Deserialize<'de> for __With {
6339                                fn deserialize<D>(
6340                                    deserializer: D,
6341                                ) -> std::result::Result<Self, D::Error>
6342                                where
6343                                    D: serde::de::Deserializer<'de>,
6344                                {
6345                                    serde_with::As::<
6346                                        std::option::Option<std::vec::Vec<wkt::internal::I32>>,
6347                                    >::deserialize(deserializer)
6348                                    .map(__With)
6349                                }
6350                            }
6351                            result.costs_per_vehicle_indices =
6352                                map.next_value::<__With>()?.0.unwrap_or_default();
6353                        }
6354                        __FieldTag::__pickup_to_delivery_relative_detour_limit => {
6355                            if !fields
6356                                .insert(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6357                            {
6358                                return std::result::Result::Err(A::Error::duplicate_field(
6359                                    "multiple values for pickup_to_delivery_relative_detour_limit",
6360                                ));
6361                            }
6362                            struct __With(std::option::Option<f64>);
6363                            impl<'de> serde::de::Deserialize<'de> for __With {
6364                                fn deserialize<D>(
6365                                    deserializer: D,
6366                                ) -> std::result::Result<Self, D::Error>
6367                                where
6368                                    D: serde::de::Deserializer<'de>,
6369                                {
6370                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
6371                                }
6372                            }
6373                            result.pickup_to_delivery_relative_detour_limit =
6374                                map.next_value::<__With>()?.0;
6375                        }
6376                        __FieldTag::__pickup_to_delivery_absolute_detour_limit => {
6377                            if !fields
6378                                .insert(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6379                            {
6380                                return std::result::Result::Err(A::Error::duplicate_field(
6381                                    "multiple values for pickup_to_delivery_absolute_detour_limit",
6382                                ));
6383                            }
6384                            result.pickup_to_delivery_absolute_detour_limit =
6385                                map.next_value::<std::option::Option<wkt::Duration>>()?;
6386                        }
6387                        __FieldTag::__pickup_to_delivery_time_limit => {
6388                            if !fields.insert(__FieldTag::__pickup_to_delivery_time_limit) {
6389                                return std::result::Result::Err(A::Error::duplicate_field(
6390                                    "multiple values for pickup_to_delivery_time_limit",
6391                                ));
6392                            }
6393                            result.pickup_to_delivery_time_limit =
6394                                map.next_value::<std::option::Option<wkt::Duration>>()?;
6395                        }
6396                        __FieldTag::__shipment_type => {
6397                            if !fields.insert(__FieldTag::__shipment_type) {
6398                                return std::result::Result::Err(A::Error::duplicate_field(
6399                                    "multiple values for shipment_type",
6400                                ));
6401                            }
6402                            result.shipment_type = map
6403                                .next_value::<std::option::Option<std::string::String>>()?
6404                                .unwrap_or_default();
6405                        }
6406                        __FieldTag::__label => {
6407                            if !fields.insert(__FieldTag::__label) {
6408                                return std::result::Result::Err(A::Error::duplicate_field(
6409                                    "multiple values for label",
6410                                ));
6411                            }
6412                            result.label = map
6413                                .next_value::<std::option::Option<std::string::String>>()?
6414                                .unwrap_or_default();
6415                        }
6416                        __FieldTag::__ignore => {
6417                            if !fields.insert(__FieldTag::__ignore) {
6418                                return std::result::Result::Err(A::Error::duplicate_field(
6419                                    "multiple values for ignore",
6420                                ));
6421                            }
6422                            result.ignore = map
6423                                .next_value::<std::option::Option<bool>>()?
6424                                .unwrap_or_default();
6425                        }
6426                        __FieldTag::__demands => {
6427                            if !fields.insert(__FieldTag::__demands) {
6428                                return std::result::Result::Err(A::Error::duplicate_field(
6429                                    "multiple values for demands",
6430                                ));
6431                            }
6432                            result.demands =
6433                                map.next_value::<std::option::Option<
6434                                    std::vec::Vec<crate::model::CapacityQuantity>,
6435                                >>()?
6436                                .unwrap_or_default();
6437                        }
6438                        __FieldTag::Unknown(key) => {
6439                            let value = map.next_value::<serde_json::Value>()?;
6440                            result._unknown_fields.insert(key, value);
6441                        }
6442                    }
6443                }
6444                std::result::Result::Ok(result)
6445            }
6446        }
6447        deserializer.deserialize_any(Visitor)
6448    }
6449}
6450
6451#[doc(hidden)]
6452impl serde::ser::Serialize for Shipment {
6453    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6454    where
6455        S: serde::ser::Serializer,
6456    {
6457        use serde::ser::SerializeMap;
6458        #[allow(unused_imports)]
6459        use std::option::Option::Some;
6460        let mut state = serializer.serialize_map(std::option::Option::None)?;
6461        if !self.pickups.is_empty() {
6462            state.serialize_entry("pickups", &self.pickups)?;
6463        }
6464        if !self.deliveries.is_empty() {
6465            state.serialize_entry("deliveries", &self.deliveries)?;
6466        }
6467        if !self.load_demands.is_empty() {
6468            state.serialize_entry("loadDemands", &self.load_demands)?;
6469        }
6470        if self.penalty_cost.is_some() {
6471            struct __With<'a>(&'a std::option::Option<f64>);
6472            impl<'a> serde::ser::Serialize for __With<'a> {
6473                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6474                where
6475                    S: serde::ser::Serializer,
6476                {
6477                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
6478                        self.0, serializer,
6479                    )
6480                }
6481            }
6482            state.serialize_entry("penaltyCost", &__With(&self.penalty_cost))?;
6483        }
6484        if !self.allowed_vehicle_indices.is_empty() {
6485            struct __With<'a>(&'a std::vec::Vec<i32>);
6486            impl<'a> serde::ser::Serialize for __With<'a> {
6487                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6488                where
6489                    S: serde::ser::Serializer,
6490                {
6491                    serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
6492                        self.0, serializer,
6493                    )
6494                }
6495            }
6496            state.serialize_entry(
6497                "allowedVehicleIndices",
6498                &__With(&self.allowed_vehicle_indices),
6499            )?;
6500        }
6501        if !self.costs_per_vehicle.is_empty() {
6502            struct __With<'a>(&'a std::vec::Vec<f64>);
6503            impl<'a> serde::ser::Serialize for __With<'a> {
6504                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6505                where
6506                    S: serde::ser::Serializer,
6507                {
6508                    serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
6509                        self.0, serializer,
6510                    )
6511                }
6512            }
6513            state.serialize_entry("costsPerVehicle", &__With(&self.costs_per_vehicle))?;
6514        }
6515        if !self.costs_per_vehicle_indices.is_empty() {
6516            struct __With<'a>(&'a std::vec::Vec<i32>);
6517            impl<'a> serde::ser::Serialize for __With<'a> {
6518                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6519                where
6520                    S: serde::ser::Serializer,
6521                {
6522                    serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
6523                        self.0, serializer,
6524                    )
6525                }
6526            }
6527            state.serialize_entry(
6528                "costsPerVehicleIndices",
6529                &__With(&self.costs_per_vehicle_indices),
6530            )?;
6531        }
6532        if self.pickup_to_delivery_relative_detour_limit.is_some() {
6533            struct __With<'a>(&'a std::option::Option<f64>);
6534            impl<'a> serde::ser::Serialize for __With<'a> {
6535                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6536                where
6537                    S: serde::ser::Serializer,
6538                {
6539                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
6540                        self.0, serializer,
6541                    )
6542                }
6543            }
6544            state.serialize_entry(
6545                "pickupToDeliveryRelativeDetourLimit",
6546                &__With(&self.pickup_to_delivery_relative_detour_limit),
6547            )?;
6548        }
6549        if self.pickup_to_delivery_absolute_detour_limit.is_some() {
6550            state.serialize_entry(
6551                "pickupToDeliveryAbsoluteDetourLimit",
6552                &self.pickup_to_delivery_absolute_detour_limit,
6553            )?;
6554        }
6555        if self.pickup_to_delivery_time_limit.is_some() {
6556            state.serialize_entry(
6557                "pickupToDeliveryTimeLimit",
6558                &self.pickup_to_delivery_time_limit,
6559            )?;
6560        }
6561        if !self.shipment_type.is_empty() {
6562            state.serialize_entry("shipmentType", &self.shipment_type)?;
6563        }
6564        if !self.label.is_empty() {
6565            state.serialize_entry("label", &self.label)?;
6566        }
6567        if !wkt::internal::is_default(&self.ignore) {
6568            state.serialize_entry("ignore", &self.ignore)?;
6569        }
6570        if !self.demands.is_empty() {
6571            state.serialize_entry("demands", &self.demands)?;
6572        }
6573        if !self._unknown_fields.is_empty() {
6574            for (key, value) in self._unknown_fields.iter() {
6575                state.serialize_entry(key, &value)?;
6576            }
6577        }
6578        state.end()
6579    }
6580}
6581
6582/// Defines additional types related to [Shipment].
6583pub mod shipment {
6584    #[allow(unused_imports)]
6585    use super::*;
6586
6587    /// Request for a visit which can be done by a vehicle: it has a geo-location
6588    /// (or two, see below), opening and closing times represented by time windows,
6589    /// and a service duration time (time spent by the vehicle once it has arrived
6590    /// to pickup or drop off goods).
6591    #[derive(Clone, Debug, Default, PartialEq)]
6592    #[non_exhaustive]
6593    pub struct VisitRequest {
6594        /// The geo-location where the vehicle arrives when performing this
6595        /// `VisitRequest`. If the shipment model has duration distance matrices,
6596        /// `arrival_location` must not be specified.
6597        pub arrival_location: std::option::Option<gtype::model::LatLng>,
6598
6599        /// The waypoint where the vehicle arrives when performing this
6600        /// `VisitRequest`. If the shipment model has duration distance matrices,
6601        /// `arrival_waypoint` must not be specified.
6602        pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
6603
6604        /// The geo-location where the vehicle departs after completing this
6605        /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
6606        /// If the shipment model has duration distance matrices,
6607        /// `departure_location` must not be specified.
6608        pub departure_location: std::option::Option<gtype::model::LatLng>,
6609
6610        /// The waypoint where the vehicle departs after completing this
6611        /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
6612        /// If the shipment model has duration distance matrices,
6613        /// `departure_waypoint` must not be specified.
6614        pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
6615
6616        /// Specifies tags attached to the visit request.
6617        /// Empty or duplicate strings are not allowed.
6618        pub tags: std::vec::Vec<std::string::String>,
6619
6620        /// Time windows which constrain the arrival time at a visit.
6621        /// Note that a vehicle may depart outside of the arrival time window, i.e.
6622        /// arrival time + duration do not need to be inside a time window. This can
6623        /// result in waiting time if the vehicle arrives before
6624        /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
6625        ///
6626        /// The absence of `TimeWindow` means that the vehicle can perform this visit
6627        /// at any time.
6628        ///
6629        /// Time windows must be disjoint, i.e. no time window must overlap with or
6630        /// be adjacent to another, and they must be in increasing order.
6631        ///
6632        /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
6633        /// be set if there is a single time window.
6634        ///
6635        /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
6636        pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
6637
6638        /// Duration of the visit, i.e. time spent by the vehicle between arrival
6639        /// and departure (to be added to the possible waiting time; see
6640        /// `time_windows`).
6641        pub duration: std::option::Option<wkt::Duration>,
6642
6643        /// Cost to service this visit request on a vehicle route. This can be used
6644        /// to pay different costs for each alternative pickup or delivery of a
6645        /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
6646        /// and must not be negative.
6647        pub cost: f64,
6648
6649        /// Load demands of this visit request. This is just like
6650        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
6651        /// field, except that it only applies to this
6652        /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
6653        /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
6654        /// The demands listed here are added to the demands listed in
6655        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
6656        ///
6657        /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
6658        /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
6659        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
6660        pub load_demands:
6661            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
6662
6663        /// Specifies the types of the visit. This may be used to allocate additional
6664        /// time required for a vehicle to complete this visit (see
6665        /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
6666        ///
6667        /// A type can only appear once.
6668        ///
6669        /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
6670        pub visit_types: std::vec::Vec<std::string::String>,
6671
6672        /// Specifies a label for this `VisitRequest`. This label is reported in the
6673        /// response as `visit_label` in the corresponding
6674        /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
6675        ///
6676        /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
6677        pub label: std::string::String,
6678
6679        /// Deprecated: Use
6680        /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
6681        /// instead.
6682        ///
6683        /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
6684        #[deprecated]
6685        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
6686
6687        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6688    }
6689
6690    impl VisitRequest {
6691        pub fn new() -> Self {
6692            std::default::Default::default()
6693        }
6694
6695        /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
6696        pub fn set_arrival_location<T>(mut self, v: T) -> Self
6697        where
6698            T: std::convert::Into<gtype::model::LatLng>,
6699        {
6700            self.arrival_location = std::option::Option::Some(v.into());
6701            self
6702        }
6703
6704        /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
6705        pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
6706        where
6707            T: std::convert::Into<gtype::model::LatLng>,
6708        {
6709            self.arrival_location = v.map(|x| x.into());
6710            self
6711        }
6712
6713        /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
6714        pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
6715        where
6716            T: std::convert::Into<crate::model::Waypoint>,
6717        {
6718            self.arrival_waypoint = std::option::Option::Some(v.into());
6719            self
6720        }
6721
6722        /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
6723        pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
6724        where
6725            T: std::convert::Into<crate::model::Waypoint>,
6726        {
6727            self.arrival_waypoint = v.map(|x| x.into());
6728            self
6729        }
6730
6731        /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
6732        pub fn set_departure_location<T>(mut self, v: T) -> Self
6733        where
6734            T: std::convert::Into<gtype::model::LatLng>,
6735        {
6736            self.departure_location = std::option::Option::Some(v.into());
6737            self
6738        }
6739
6740        /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
6741        pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
6742        where
6743            T: std::convert::Into<gtype::model::LatLng>,
6744        {
6745            self.departure_location = v.map(|x| x.into());
6746            self
6747        }
6748
6749        /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
6750        pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
6751        where
6752            T: std::convert::Into<crate::model::Waypoint>,
6753        {
6754            self.departure_waypoint = std::option::Option::Some(v.into());
6755            self
6756        }
6757
6758        /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
6759        pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
6760        where
6761            T: std::convert::Into<crate::model::Waypoint>,
6762        {
6763            self.departure_waypoint = v.map(|x| x.into());
6764            self
6765        }
6766
6767        /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
6768        pub fn set_tags<T, V>(mut self, v: T) -> Self
6769        where
6770            T: std::iter::IntoIterator<Item = V>,
6771            V: std::convert::Into<std::string::String>,
6772        {
6773            use std::iter::Iterator;
6774            self.tags = v.into_iter().map(|i| i.into()).collect();
6775            self
6776        }
6777
6778        /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
6779        pub fn set_time_windows<T, V>(mut self, v: T) -> Self
6780        where
6781            T: std::iter::IntoIterator<Item = V>,
6782            V: std::convert::Into<crate::model::TimeWindow>,
6783        {
6784            use std::iter::Iterator;
6785            self.time_windows = v.into_iter().map(|i| i.into()).collect();
6786            self
6787        }
6788
6789        /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
6790        pub fn set_duration<T>(mut self, v: T) -> Self
6791        where
6792            T: std::convert::Into<wkt::Duration>,
6793        {
6794            self.duration = std::option::Option::Some(v.into());
6795            self
6796        }
6797
6798        /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
6799        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
6800        where
6801            T: std::convert::Into<wkt::Duration>,
6802        {
6803            self.duration = v.map(|x| x.into());
6804            self
6805        }
6806
6807        /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
6808        pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
6809            self.cost = v.into();
6810            self
6811        }
6812
6813        /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
6814        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
6815        where
6816            T: std::iter::IntoIterator<Item = (K, V)>,
6817            K: std::convert::Into<std::string::String>,
6818            V: std::convert::Into<crate::model::shipment::Load>,
6819        {
6820            use std::iter::Iterator;
6821            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6822            self
6823        }
6824
6825        /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
6826        pub fn set_visit_types<T, V>(mut self, v: T) -> Self
6827        where
6828            T: std::iter::IntoIterator<Item = V>,
6829            V: std::convert::Into<std::string::String>,
6830        {
6831            use std::iter::Iterator;
6832            self.visit_types = v.into_iter().map(|i| i.into()).collect();
6833            self
6834        }
6835
6836        /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
6837        pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6838            self.label = v.into();
6839            self
6840        }
6841
6842        /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
6843        #[deprecated]
6844        pub fn set_demands<T, V>(mut self, v: T) -> Self
6845        where
6846            T: std::iter::IntoIterator<Item = V>,
6847            V: std::convert::Into<crate::model::CapacityQuantity>,
6848        {
6849            use std::iter::Iterator;
6850            self.demands = v.into_iter().map(|i| i.into()).collect();
6851            self
6852        }
6853    }
6854
6855    impl wkt::message::Message for VisitRequest {
6856        fn typename() -> &'static str {
6857            "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
6858        }
6859    }
6860
6861    #[doc(hidden)]
6862    impl<'de> serde::de::Deserialize<'de> for VisitRequest {
6863        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6864        where
6865            D: serde::Deserializer<'de>,
6866        {
6867            #[allow(non_camel_case_types)]
6868            #[doc(hidden)]
6869            #[derive(PartialEq, Eq, Hash)]
6870            enum __FieldTag {
6871                __arrival_location,
6872                __arrival_waypoint,
6873                __departure_location,
6874                __departure_waypoint,
6875                __tags,
6876                __time_windows,
6877                __duration,
6878                __cost,
6879                __load_demands,
6880                __visit_types,
6881                __label,
6882                __demands,
6883                Unknown(std::string::String),
6884            }
6885            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6886                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6887                where
6888                    D: serde::Deserializer<'de>,
6889                {
6890                    struct Visitor;
6891                    impl<'de> serde::de::Visitor<'de> for Visitor {
6892                        type Value = __FieldTag;
6893                        fn expecting(
6894                            &self,
6895                            formatter: &mut std::fmt::Formatter,
6896                        ) -> std::fmt::Result {
6897                            formatter.write_str("a field name for VisitRequest")
6898                        }
6899                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6900                        where
6901                            E: serde::de::Error,
6902                        {
6903                            use std::result::Result::Ok;
6904                            use std::string::ToString;
6905                            match value {
6906                                "arrivalLocation" => Ok(__FieldTag::__arrival_location),
6907                                "arrival_location" => Ok(__FieldTag::__arrival_location),
6908                                "arrivalWaypoint" => Ok(__FieldTag::__arrival_waypoint),
6909                                "arrival_waypoint" => Ok(__FieldTag::__arrival_waypoint),
6910                                "departureLocation" => Ok(__FieldTag::__departure_location),
6911                                "departure_location" => Ok(__FieldTag::__departure_location),
6912                                "departureWaypoint" => Ok(__FieldTag::__departure_waypoint),
6913                                "departure_waypoint" => Ok(__FieldTag::__departure_waypoint),
6914                                "tags" => Ok(__FieldTag::__tags),
6915                                "timeWindows" => Ok(__FieldTag::__time_windows),
6916                                "time_windows" => Ok(__FieldTag::__time_windows),
6917                                "duration" => Ok(__FieldTag::__duration),
6918                                "cost" => Ok(__FieldTag::__cost),
6919                                "loadDemands" => Ok(__FieldTag::__load_demands),
6920                                "load_demands" => Ok(__FieldTag::__load_demands),
6921                                "visitTypes" => Ok(__FieldTag::__visit_types),
6922                                "visit_types" => Ok(__FieldTag::__visit_types),
6923                                "label" => Ok(__FieldTag::__label),
6924                                "demands" => Ok(__FieldTag::__demands),
6925                                _ => Ok(__FieldTag::Unknown(value.to_string())),
6926                            }
6927                        }
6928                    }
6929                    deserializer.deserialize_identifier(Visitor)
6930                }
6931            }
6932            struct Visitor;
6933            impl<'de> serde::de::Visitor<'de> for Visitor {
6934                type Value = VisitRequest;
6935                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6936                    formatter.write_str("struct VisitRequest")
6937                }
6938                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6939                where
6940                    A: serde::de::MapAccess<'de>,
6941                {
6942                    #[allow(unused_imports)]
6943                    use serde::de::Error;
6944                    use std::option::Option::Some;
6945                    let mut fields = std::collections::HashSet::new();
6946                    let mut result = Self::Value::new();
6947                    while let Some(tag) = map.next_key::<__FieldTag>()? {
6948                        #[allow(clippy::match_single_binding)]
6949                        match tag {
6950                            __FieldTag::__arrival_location => {
6951                                if !fields.insert(__FieldTag::__arrival_location) {
6952                                    return std::result::Result::Err(A::Error::duplicate_field(
6953                                        "multiple values for arrival_location",
6954                                    ));
6955                                }
6956                                result.arrival_location =
6957                                    map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
6958                            }
6959                            __FieldTag::__arrival_waypoint => {
6960                                if !fields.insert(__FieldTag::__arrival_waypoint) {
6961                                    return std::result::Result::Err(A::Error::duplicate_field(
6962                                        "multiple values for arrival_waypoint",
6963                                    ));
6964                                }
6965                                result.arrival_waypoint = map
6966                                    .next_value::<std::option::Option<crate::model::Waypoint>>()?;
6967                            }
6968                            __FieldTag::__departure_location => {
6969                                if !fields.insert(__FieldTag::__departure_location) {
6970                                    return std::result::Result::Err(A::Error::duplicate_field(
6971                                        "multiple values for departure_location",
6972                                    ));
6973                                }
6974                                result.departure_location =
6975                                    map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
6976                            }
6977                            __FieldTag::__departure_waypoint => {
6978                                if !fields.insert(__FieldTag::__departure_waypoint) {
6979                                    return std::result::Result::Err(A::Error::duplicate_field(
6980                                        "multiple values for departure_waypoint",
6981                                    ));
6982                                }
6983                                result.departure_waypoint = map
6984                                    .next_value::<std::option::Option<crate::model::Waypoint>>()?;
6985                            }
6986                            __FieldTag::__tags => {
6987                                if !fields.insert(__FieldTag::__tags) {
6988                                    return std::result::Result::Err(A::Error::duplicate_field(
6989                                        "multiple values for tags",
6990                                    ));
6991                                }
6992                                result.tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
6993                            }
6994                            __FieldTag::__time_windows => {
6995                                if !fields.insert(__FieldTag::__time_windows) {
6996                                    return std::result::Result::Err(A::Error::duplicate_field(
6997                                        "multiple values for time_windows",
6998                                    ));
6999                                }
7000                                result.time_windows =
7001                                    map.next_value::<std::option::Option<
7002                                        std::vec::Vec<crate::model::TimeWindow>,
7003                                    >>()?
7004                                    .unwrap_or_default();
7005                            }
7006                            __FieldTag::__duration => {
7007                                if !fields.insert(__FieldTag::__duration) {
7008                                    return std::result::Result::Err(A::Error::duplicate_field(
7009                                        "multiple values for duration",
7010                                    ));
7011                                }
7012                                result.duration =
7013                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
7014                            }
7015                            __FieldTag::__cost => {
7016                                if !fields.insert(__FieldTag::__cost) {
7017                                    return std::result::Result::Err(A::Error::duplicate_field(
7018                                        "multiple values for cost",
7019                                    ));
7020                                }
7021                                struct __With(std::option::Option<f64>);
7022                                impl<'de> serde::de::Deserialize<'de> for __With {
7023                                    fn deserialize<D>(
7024                                        deserializer: D,
7025                                    ) -> std::result::Result<Self, D::Error>
7026                                    where
7027                                        D: serde::de::Deserializer<'de>,
7028                                    {
7029                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
7030                                    }
7031                                }
7032                                result.cost = map.next_value::<__With>()?.0.unwrap_or_default();
7033                            }
7034                            __FieldTag::__load_demands => {
7035                                if !fields.insert(__FieldTag::__load_demands) {
7036                                    return std::result::Result::Err(A::Error::duplicate_field(
7037                                        "multiple values for load_demands",
7038                                    ));
7039                                }
7040                                result.load_demands = map
7041                                    .next_value::<std::option::Option<
7042                                        std::collections::HashMap<
7043                                            std::string::String,
7044                                            crate::model::shipment::Load,
7045                                        >,
7046                                    >>()?
7047                                    .unwrap_or_default();
7048                            }
7049                            __FieldTag::__visit_types => {
7050                                if !fields.insert(__FieldTag::__visit_types) {
7051                                    return std::result::Result::Err(A::Error::duplicate_field(
7052                                        "multiple values for visit_types",
7053                                    ));
7054                                }
7055                                result.visit_types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7056                            }
7057                            __FieldTag::__label => {
7058                                if !fields.insert(__FieldTag::__label) {
7059                                    return std::result::Result::Err(A::Error::duplicate_field(
7060                                        "multiple values for label",
7061                                    ));
7062                                }
7063                                result.label = map
7064                                    .next_value::<std::option::Option<std::string::String>>()?
7065                                    .unwrap_or_default();
7066                            }
7067                            __FieldTag::__demands => {
7068                                if !fields.insert(__FieldTag::__demands) {
7069                                    return std::result::Result::Err(A::Error::duplicate_field(
7070                                        "multiple values for demands",
7071                                    ));
7072                                }
7073                                result.demands = map
7074                                    .next_value::<std::option::Option<
7075                                        std::vec::Vec<crate::model::CapacityQuantity>,
7076                                    >>()?
7077                                    .unwrap_or_default();
7078                            }
7079                            __FieldTag::Unknown(key) => {
7080                                let value = map.next_value::<serde_json::Value>()?;
7081                                result._unknown_fields.insert(key, value);
7082                            }
7083                        }
7084                    }
7085                    std::result::Result::Ok(result)
7086                }
7087            }
7088            deserializer.deserialize_any(Visitor)
7089        }
7090    }
7091
7092    #[doc(hidden)]
7093    impl serde::ser::Serialize for VisitRequest {
7094        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7095        where
7096            S: serde::ser::Serializer,
7097        {
7098            use serde::ser::SerializeMap;
7099            #[allow(unused_imports)]
7100            use std::option::Option::Some;
7101            let mut state = serializer.serialize_map(std::option::Option::None)?;
7102            if self.arrival_location.is_some() {
7103                state.serialize_entry("arrivalLocation", &self.arrival_location)?;
7104            }
7105            if self.arrival_waypoint.is_some() {
7106                state.serialize_entry("arrivalWaypoint", &self.arrival_waypoint)?;
7107            }
7108            if self.departure_location.is_some() {
7109                state.serialize_entry("departureLocation", &self.departure_location)?;
7110            }
7111            if self.departure_waypoint.is_some() {
7112                state.serialize_entry("departureWaypoint", &self.departure_waypoint)?;
7113            }
7114            if !self.tags.is_empty() {
7115                state.serialize_entry("tags", &self.tags)?;
7116            }
7117            if !self.time_windows.is_empty() {
7118                state.serialize_entry("timeWindows", &self.time_windows)?;
7119            }
7120            if self.duration.is_some() {
7121                state.serialize_entry("duration", &self.duration)?;
7122            }
7123            if !wkt::internal::is_default(&self.cost) {
7124                struct __With<'a>(&'a f64);
7125                impl<'a> serde::ser::Serialize for __With<'a> {
7126                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7127                    where
7128                        S: serde::ser::Serializer,
7129                    {
7130                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
7131                    }
7132                }
7133                state.serialize_entry("cost", &__With(&self.cost))?;
7134            }
7135            if !self.load_demands.is_empty() {
7136                state.serialize_entry("loadDemands", &self.load_demands)?;
7137            }
7138            if !self.visit_types.is_empty() {
7139                state.serialize_entry("visitTypes", &self.visit_types)?;
7140            }
7141            if !self.label.is_empty() {
7142                state.serialize_entry("label", &self.label)?;
7143            }
7144            if !self.demands.is_empty() {
7145                state.serialize_entry("demands", &self.demands)?;
7146            }
7147            if !self._unknown_fields.is_empty() {
7148                for (key, value) in self._unknown_fields.iter() {
7149                    state.serialize_entry(key, &value)?;
7150                }
7151            }
7152            state.end()
7153        }
7154    }
7155
7156    /// When performing a visit, a predefined amount may be added to the vehicle
7157    /// load if it's a pickup, or subtracted if it's a delivery. This message
7158    /// defines such amount. See
7159    /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
7160    ///
7161    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
7162    #[derive(Clone, Debug, Default, PartialEq)]
7163    #[non_exhaustive]
7164    pub struct Load {
7165        /// The amount by which the load of the vehicle performing the corresponding
7166        /// visit will vary. Since it is an integer, users are advised to choose an
7167        /// appropriate unit to avoid loss of precision. Must be ≥ 0.
7168        pub amount: i64,
7169
7170        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7171    }
7172
7173    impl Load {
7174        pub fn new() -> Self {
7175            std::default::Default::default()
7176        }
7177
7178        /// Sets the value of [amount][crate::model::shipment::Load::amount].
7179        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7180            self.amount = v.into();
7181            self
7182        }
7183    }
7184
7185    impl wkt::message::Message for Load {
7186        fn typename() -> &'static str {
7187            "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
7188        }
7189    }
7190
7191    #[doc(hidden)]
7192    impl<'de> serde::de::Deserialize<'de> for Load {
7193        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7194        where
7195            D: serde::Deserializer<'de>,
7196        {
7197            #[allow(non_camel_case_types)]
7198            #[doc(hidden)]
7199            #[derive(PartialEq, Eq, Hash)]
7200            enum __FieldTag {
7201                __amount,
7202                Unknown(std::string::String),
7203            }
7204            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7205                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7206                where
7207                    D: serde::Deserializer<'de>,
7208                {
7209                    struct Visitor;
7210                    impl<'de> serde::de::Visitor<'de> for Visitor {
7211                        type Value = __FieldTag;
7212                        fn expecting(
7213                            &self,
7214                            formatter: &mut std::fmt::Formatter,
7215                        ) -> std::fmt::Result {
7216                            formatter.write_str("a field name for Load")
7217                        }
7218                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7219                        where
7220                            E: serde::de::Error,
7221                        {
7222                            use std::result::Result::Ok;
7223                            use std::string::ToString;
7224                            match value {
7225                                "amount" => Ok(__FieldTag::__amount),
7226                                _ => Ok(__FieldTag::Unknown(value.to_string())),
7227                            }
7228                        }
7229                    }
7230                    deserializer.deserialize_identifier(Visitor)
7231                }
7232            }
7233            struct Visitor;
7234            impl<'de> serde::de::Visitor<'de> for Visitor {
7235                type Value = Load;
7236                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7237                    formatter.write_str("struct Load")
7238                }
7239                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7240                where
7241                    A: serde::de::MapAccess<'de>,
7242                {
7243                    #[allow(unused_imports)]
7244                    use serde::de::Error;
7245                    use std::option::Option::Some;
7246                    let mut fields = std::collections::HashSet::new();
7247                    let mut result = Self::Value::new();
7248                    while let Some(tag) = map.next_key::<__FieldTag>()? {
7249                        #[allow(clippy::match_single_binding)]
7250                        match tag {
7251                            __FieldTag::__amount => {
7252                                if !fields.insert(__FieldTag::__amount) {
7253                                    return std::result::Result::Err(A::Error::duplicate_field(
7254                                        "multiple values for amount",
7255                                    ));
7256                                }
7257                                struct __With(std::option::Option<i64>);
7258                                impl<'de> serde::de::Deserialize<'de> for __With {
7259                                    fn deserialize<D>(
7260                                        deserializer: D,
7261                                    ) -> std::result::Result<Self, D::Error>
7262                                    where
7263                                        D: serde::de::Deserializer<'de>,
7264                                    {
7265                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
7266                                    }
7267                                }
7268                                result.amount = map.next_value::<__With>()?.0.unwrap_or_default();
7269                            }
7270                            __FieldTag::Unknown(key) => {
7271                                let value = map.next_value::<serde_json::Value>()?;
7272                                result._unknown_fields.insert(key, value);
7273                            }
7274                        }
7275                    }
7276                    std::result::Result::Ok(result)
7277                }
7278            }
7279            deserializer.deserialize_any(Visitor)
7280        }
7281    }
7282
7283    #[doc(hidden)]
7284    impl serde::ser::Serialize for Load {
7285        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7286        where
7287            S: serde::ser::Serializer,
7288        {
7289            use serde::ser::SerializeMap;
7290            #[allow(unused_imports)]
7291            use std::option::Option::Some;
7292            let mut state = serializer.serialize_map(std::option::Option::None)?;
7293            if !wkt::internal::is_default(&self.amount) {
7294                struct __With<'a>(&'a i64);
7295                impl<'a> serde::ser::Serialize for __With<'a> {
7296                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7297                    where
7298                        S: serde::ser::Serializer,
7299                    {
7300                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
7301                    }
7302                }
7303                state.serialize_entry("amount", &__With(&self.amount))?;
7304            }
7305            if !self._unknown_fields.is_empty() {
7306                for (key, value) in self._unknown_fields.iter() {
7307                    state.serialize_entry(key, &value)?;
7308                }
7309            }
7310            state.end()
7311        }
7312    }
7313}
7314
7315/// Specifies incompatibilties between shipments depending on their
7316/// shipment_type. The appearance of incompatible shipments on the same route is
7317/// restricted based on the incompatibility mode.
7318#[derive(Clone, Debug, Default, PartialEq)]
7319#[non_exhaustive]
7320pub struct ShipmentTypeIncompatibility {
7321    /// List of incompatible types. Two shipments having different `shipment_types`
7322    /// among those listed are "incompatible".
7323    pub types: std::vec::Vec<std::string::String>,
7324
7325    /// Mode applied to the incompatibility.
7326    pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
7327
7328    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7329}
7330
7331impl ShipmentTypeIncompatibility {
7332    pub fn new() -> Self {
7333        std::default::Default::default()
7334    }
7335
7336    /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
7337    pub fn set_types<T, V>(mut self, v: T) -> Self
7338    where
7339        T: std::iter::IntoIterator<Item = V>,
7340        V: std::convert::Into<std::string::String>,
7341    {
7342        use std::iter::Iterator;
7343        self.types = v.into_iter().map(|i| i.into()).collect();
7344        self
7345    }
7346
7347    /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
7348    pub fn set_incompatibility_mode<
7349        T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
7350    >(
7351        mut self,
7352        v: T,
7353    ) -> Self {
7354        self.incompatibility_mode = v.into();
7355        self
7356    }
7357}
7358
7359impl wkt::message::Message for ShipmentTypeIncompatibility {
7360    fn typename() -> &'static str {
7361        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
7362    }
7363}
7364
7365#[doc(hidden)]
7366impl<'de> serde::de::Deserialize<'de> for ShipmentTypeIncompatibility {
7367    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7368    where
7369        D: serde::Deserializer<'de>,
7370    {
7371        #[allow(non_camel_case_types)]
7372        #[doc(hidden)]
7373        #[derive(PartialEq, Eq, Hash)]
7374        enum __FieldTag {
7375            __types,
7376            __incompatibility_mode,
7377            Unknown(std::string::String),
7378        }
7379        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7380            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7381            where
7382                D: serde::Deserializer<'de>,
7383            {
7384                struct Visitor;
7385                impl<'de> serde::de::Visitor<'de> for Visitor {
7386                    type Value = __FieldTag;
7387                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7388                        formatter.write_str("a field name for ShipmentTypeIncompatibility")
7389                    }
7390                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7391                    where
7392                        E: serde::de::Error,
7393                    {
7394                        use std::result::Result::Ok;
7395                        use std::string::ToString;
7396                        match value {
7397                            "types" => Ok(__FieldTag::__types),
7398                            "incompatibilityMode" => Ok(__FieldTag::__incompatibility_mode),
7399                            "incompatibility_mode" => Ok(__FieldTag::__incompatibility_mode),
7400                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7401                        }
7402                    }
7403                }
7404                deserializer.deserialize_identifier(Visitor)
7405            }
7406        }
7407        struct Visitor;
7408        impl<'de> serde::de::Visitor<'de> for Visitor {
7409            type Value = ShipmentTypeIncompatibility;
7410            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7411                formatter.write_str("struct ShipmentTypeIncompatibility")
7412            }
7413            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7414            where
7415                A: serde::de::MapAccess<'de>,
7416            {
7417                #[allow(unused_imports)]
7418                use serde::de::Error;
7419                use std::option::Option::Some;
7420                let mut fields = std::collections::HashSet::new();
7421                let mut result = Self::Value::new();
7422                while let Some(tag) = map.next_key::<__FieldTag>()? {
7423                    #[allow(clippy::match_single_binding)]
7424                    match tag {
7425                        __FieldTag::__types => {
7426                            if !fields.insert(__FieldTag::__types) {
7427                                return std::result::Result::Err(A::Error::duplicate_field(
7428                                    "multiple values for types",
7429                                ));
7430                            }
7431                            result.types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7432                        }
7433                        __FieldTag::__incompatibility_mode => {
7434                            if !fields.insert(__FieldTag::__incompatibility_mode) {
7435                                return std::result::Result::Err(A::Error::duplicate_field(
7436                                    "multiple values for incompatibility_mode",
7437                                ));
7438                            }
7439                            result.incompatibility_mode = map.next_value::<std::option::Option<crate::model::shipment_type_incompatibility::IncompatibilityMode>>()?.unwrap_or_default();
7440                        }
7441                        __FieldTag::Unknown(key) => {
7442                            let value = map.next_value::<serde_json::Value>()?;
7443                            result._unknown_fields.insert(key, value);
7444                        }
7445                    }
7446                }
7447                std::result::Result::Ok(result)
7448            }
7449        }
7450        deserializer.deserialize_any(Visitor)
7451    }
7452}
7453
7454#[doc(hidden)]
7455impl serde::ser::Serialize for ShipmentTypeIncompatibility {
7456    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7457    where
7458        S: serde::ser::Serializer,
7459    {
7460        use serde::ser::SerializeMap;
7461        #[allow(unused_imports)]
7462        use std::option::Option::Some;
7463        let mut state = serializer.serialize_map(std::option::Option::None)?;
7464        if !self.types.is_empty() {
7465            state.serialize_entry("types", &self.types)?;
7466        }
7467        if !wkt::internal::is_default(&self.incompatibility_mode) {
7468            state.serialize_entry("incompatibilityMode", &self.incompatibility_mode)?;
7469        }
7470        if !self._unknown_fields.is_empty() {
7471            for (key, value) in self._unknown_fields.iter() {
7472                state.serialize_entry(key, &value)?;
7473            }
7474        }
7475        state.end()
7476    }
7477}
7478
7479/// Defines additional types related to [ShipmentTypeIncompatibility].
7480pub mod shipment_type_incompatibility {
7481    #[allow(unused_imports)]
7482    use super::*;
7483
7484    /// Modes defining how the appearance of incompatible shipments are restricted
7485    /// on the same route.
7486    ///
7487    /// # Working with unknown values
7488    ///
7489    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7490    /// additional enum variants at any time. Adding new variants is not considered
7491    /// a breaking change. Applications should write their code in anticipation of:
7492    ///
7493    /// - New values appearing in future releases of the client library, **and**
7494    /// - New values received dynamically, without application changes.
7495    ///
7496    /// Please consult the [Working with enums] section in the user guide for some
7497    /// guidelines.
7498    ///
7499    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
7500    #[derive(Clone, Debug, PartialEq)]
7501    #[non_exhaustive]
7502    pub enum IncompatibilityMode {
7503        /// Unspecified incompatibility mode. This value should never be used.
7504        Unspecified,
7505        /// In this mode, two shipments with incompatible types can never share the
7506        /// same vehicle.
7507        NotPerformedBySameVehicle,
7508        /// For two shipments with incompatible types with the
7509        /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
7510        ///
7511        /// * If both are pickups only (no deliveries) or deliveries only (no
7512        ///   pickups), they cannot share the same vehicle at all.
7513        /// * If one of the shipments has a delivery and the other a pickup, the two
7514        ///   shipments can share the same vehicle iff the former shipment is
7515        ///   delivered before the latter is picked up.
7516        NotInSameVehicleSimultaneously,
7517        /// If set, the enum was initialized with an unknown value.
7518        ///
7519        /// Applications can examine the value using [IncompatibilityMode::value] or
7520        /// [IncompatibilityMode::name].
7521        UnknownValue(incompatibility_mode::UnknownValue),
7522    }
7523
7524    #[doc(hidden)]
7525    pub mod incompatibility_mode {
7526        #[allow(unused_imports)]
7527        use super::*;
7528        #[derive(Clone, Debug, PartialEq)]
7529        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7530    }
7531
7532    impl IncompatibilityMode {
7533        /// Gets the enum value.
7534        ///
7535        /// Returns `None` if the enum contains an unknown value deserialized from
7536        /// the string representation of enums.
7537        pub fn value(&self) -> std::option::Option<i32> {
7538            match self {
7539                Self::Unspecified => std::option::Option::Some(0),
7540                Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
7541                Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
7542                Self::UnknownValue(u) => u.0.value(),
7543            }
7544        }
7545
7546        /// Gets the enum value as a string.
7547        ///
7548        /// Returns `None` if the enum contains an unknown value deserialized from
7549        /// the integer representation of enums.
7550        pub fn name(&self) -> std::option::Option<&str> {
7551            match self {
7552                Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
7553                Self::NotPerformedBySameVehicle => {
7554                    std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
7555                }
7556                Self::NotInSameVehicleSimultaneously => {
7557                    std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
7558                }
7559                Self::UnknownValue(u) => u.0.name(),
7560            }
7561        }
7562    }
7563
7564    impl std::default::Default for IncompatibilityMode {
7565        fn default() -> Self {
7566            use std::convert::From;
7567            Self::from(0)
7568        }
7569    }
7570
7571    impl std::fmt::Display for IncompatibilityMode {
7572        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7573            wkt::internal::display_enum(f, self.name(), self.value())
7574        }
7575    }
7576
7577    impl std::convert::From<i32> for IncompatibilityMode {
7578        fn from(value: i32) -> Self {
7579            match value {
7580                0 => Self::Unspecified,
7581                1 => Self::NotPerformedBySameVehicle,
7582                2 => Self::NotInSameVehicleSimultaneously,
7583                _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
7584                    wkt::internal::UnknownEnumValue::Integer(value),
7585                )),
7586            }
7587        }
7588    }
7589
7590    impl std::convert::From<&str> for IncompatibilityMode {
7591        fn from(value: &str) -> Self {
7592            use std::string::ToString;
7593            match value {
7594                "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
7595                "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
7596                "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
7597                _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
7598                    wkt::internal::UnknownEnumValue::String(value.to_string()),
7599                )),
7600            }
7601        }
7602    }
7603
7604    impl serde::ser::Serialize for IncompatibilityMode {
7605        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7606        where
7607            S: serde::Serializer,
7608        {
7609            match self {
7610                Self::Unspecified => serializer.serialize_i32(0),
7611                Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
7612                Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
7613                Self::UnknownValue(u) => u.0.serialize(serializer),
7614            }
7615        }
7616    }
7617
7618    impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
7619        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7620        where
7621            D: serde::Deserializer<'de>,
7622        {
7623            deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
7624                ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
7625            ))
7626        }
7627    }
7628}
7629
7630/// Specifies requirements between shipments based on their shipment_type.
7631/// The specifics of the requirement are defined by the requirement mode.
7632#[derive(Clone, Debug, Default, PartialEq)]
7633#[non_exhaustive]
7634pub struct ShipmentTypeRequirement {
7635    /// List of alternative shipment types required by the
7636    /// `dependent_shipment_types`.
7637    pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
7638
7639    /// All shipments with a type in the `dependent_shipment_types` field require
7640    /// at least one shipment of type `required_shipment_type_alternatives` to be
7641    /// visited on the same route.
7642    ///
7643    /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
7644    /// are not allowed.
7645    pub dependent_shipment_types: std::vec::Vec<std::string::String>,
7646
7647    /// Mode applied to the requirement.
7648    pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
7649
7650    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7651}
7652
7653impl ShipmentTypeRequirement {
7654    pub fn new() -> Self {
7655        std::default::Default::default()
7656    }
7657
7658    /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
7659    pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
7660    where
7661        T: std::iter::IntoIterator<Item = V>,
7662        V: std::convert::Into<std::string::String>,
7663    {
7664        use std::iter::Iterator;
7665        self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
7666        self
7667    }
7668
7669    /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
7670    pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
7671    where
7672        T: std::iter::IntoIterator<Item = V>,
7673        V: std::convert::Into<std::string::String>,
7674    {
7675        use std::iter::Iterator;
7676        self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
7677        self
7678    }
7679
7680    /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
7681    pub fn set_requirement_mode<
7682        T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
7683    >(
7684        mut self,
7685        v: T,
7686    ) -> Self {
7687        self.requirement_mode = v.into();
7688        self
7689    }
7690}
7691
7692impl wkt::message::Message for ShipmentTypeRequirement {
7693    fn typename() -> &'static str {
7694        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
7695    }
7696}
7697
7698#[doc(hidden)]
7699impl<'de> serde::de::Deserialize<'de> for ShipmentTypeRequirement {
7700    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7701    where
7702        D: serde::Deserializer<'de>,
7703    {
7704        #[allow(non_camel_case_types)]
7705        #[doc(hidden)]
7706        #[derive(PartialEq, Eq, Hash)]
7707        enum __FieldTag {
7708            __required_shipment_type_alternatives,
7709            __dependent_shipment_types,
7710            __requirement_mode,
7711            Unknown(std::string::String),
7712        }
7713        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7714            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7715            where
7716                D: serde::Deserializer<'de>,
7717            {
7718                struct Visitor;
7719                impl<'de> serde::de::Visitor<'de> for Visitor {
7720                    type Value = __FieldTag;
7721                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7722                        formatter.write_str("a field name for ShipmentTypeRequirement")
7723                    }
7724                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7725                    where
7726                        E: serde::de::Error,
7727                    {
7728                        use std::result::Result::Ok;
7729                        use std::string::ToString;
7730                        match value {
7731                            "requiredShipmentTypeAlternatives" => {
7732                                Ok(__FieldTag::__required_shipment_type_alternatives)
7733                            }
7734                            "required_shipment_type_alternatives" => {
7735                                Ok(__FieldTag::__required_shipment_type_alternatives)
7736                            }
7737                            "dependentShipmentTypes" => Ok(__FieldTag::__dependent_shipment_types),
7738                            "dependent_shipment_types" => {
7739                                Ok(__FieldTag::__dependent_shipment_types)
7740                            }
7741                            "requirementMode" => Ok(__FieldTag::__requirement_mode),
7742                            "requirement_mode" => Ok(__FieldTag::__requirement_mode),
7743                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7744                        }
7745                    }
7746                }
7747                deserializer.deserialize_identifier(Visitor)
7748            }
7749        }
7750        struct Visitor;
7751        impl<'de> serde::de::Visitor<'de> for Visitor {
7752            type Value = ShipmentTypeRequirement;
7753            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7754                formatter.write_str("struct ShipmentTypeRequirement")
7755            }
7756            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7757            where
7758                A: serde::de::MapAccess<'de>,
7759            {
7760                #[allow(unused_imports)]
7761                use serde::de::Error;
7762                use std::option::Option::Some;
7763                let mut fields = std::collections::HashSet::new();
7764                let mut result = Self::Value::new();
7765                while let Some(tag) = map.next_key::<__FieldTag>()? {
7766                    #[allow(clippy::match_single_binding)]
7767                    match tag {
7768                        __FieldTag::__required_shipment_type_alternatives => {
7769                            if !fields.insert(__FieldTag::__required_shipment_type_alternatives) {
7770                                return std::result::Result::Err(A::Error::duplicate_field(
7771                                    "multiple values for required_shipment_type_alternatives",
7772                                ));
7773                            }
7774                            result.required_shipment_type_alternatives = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7775                        }
7776                        __FieldTag::__dependent_shipment_types => {
7777                            if !fields.insert(__FieldTag::__dependent_shipment_types) {
7778                                return std::result::Result::Err(A::Error::duplicate_field(
7779                                    "multiple values for dependent_shipment_types",
7780                                ));
7781                            }
7782                            result.dependent_shipment_types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7783                        }
7784                        __FieldTag::__requirement_mode => {
7785                            if !fields.insert(__FieldTag::__requirement_mode) {
7786                                return std::result::Result::Err(A::Error::duplicate_field(
7787                                    "multiple values for requirement_mode",
7788                                ));
7789                            }
7790                            result.requirement_mode = map
7791                                .next_value::<std::option::Option<
7792                                    crate::model::shipment_type_requirement::RequirementMode,
7793                                >>()?
7794                                .unwrap_or_default();
7795                        }
7796                        __FieldTag::Unknown(key) => {
7797                            let value = map.next_value::<serde_json::Value>()?;
7798                            result._unknown_fields.insert(key, value);
7799                        }
7800                    }
7801                }
7802                std::result::Result::Ok(result)
7803            }
7804        }
7805        deserializer.deserialize_any(Visitor)
7806    }
7807}
7808
7809#[doc(hidden)]
7810impl serde::ser::Serialize for ShipmentTypeRequirement {
7811    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7812    where
7813        S: serde::ser::Serializer,
7814    {
7815        use serde::ser::SerializeMap;
7816        #[allow(unused_imports)]
7817        use std::option::Option::Some;
7818        let mut state = serializer.serialize_map(std::option::Option::None)?;
7819        if !self.required_shipment_type_alternatives.is_empty() {
7820            state.serialize_entry(
7821                "requiredShipmentTypeAlternatives",
7822                &self.required_shipment_type_alternatives,
7823            )?;
7824        }
7825        if !self.dependent_shipment_types.is_empty() {
7826            state.serialize_entry("dependentShipmentTypes", &self.dependent_shipment_types)?;
7827        }
7828        if !wkt::internal::is_default(&self.requirement_mode) {
7829            state.serialize_entry("requirementMode", &self.requirement_mode)?;
7830        }
7831        if !self._unknown_fields.is_empty() {
7832            for (key, value) in self._unknown_fields.iter() {
7833                state.serialize_entry(key, &value)?;
7834            }
7835        }
7836        state.end()
7837    }
7838}
7839
7840/// Defines additional types related to [ShipmentTypeRequirement].
7841pub mod shipment_type_requirement {
7842    #[allow(unused_imports)]
7843    use super::*;
7844
7845    /// Modes defining the appearance of dependent shipments on a route.
7846    ///
7847    /// # Working with unknown values
7848    ///
7849    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7850    /// additional enum variants at any time. Adding new variants is not considered
7851    /// a breaking change. Applications should write their code in anticipation of:
7852    ///
7853    /// - New values appearing in future releases of the client library, **and**
7854    /// - New values received dynamically, without application changes.
7855    ///
7856    /// Please consult the [Working with enums] section in the user guide for some
7857    /// guidelines.
7858    ///
7859    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
7860    #[derive(Clone, Debug, PartialEq)]
7861    #[non_exhaustive]
7862    pub enum RequirementMode {
7863        /// Unspecified requirement mode. This value should never be used.
7864        Unspecified,
7865        /// In this mode, all "dependent" shipments must share the same vehicle as at
7866        /// least one of their "required" shipments.
7867        PerformedBySameVehicle,
7868        /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
7869        /// shipments need to have at least one "required" shipment on their vehicle
7870        /// at the time of their pickup.
7871        ///
7872        /// A "dependent" shipment pickup must therefore have either:
7873        ///
7874        /// * A delivery-only "required" shipment delivered on the route after, or
7875        /// * A "required" shipment picked up on the route before it, and if the
7876        ///   "required" shipment has a delivery, this delivery must be performed
7877        ///   after the "dependent" shipment's pickup.
7878        InSameVehicleAtPickupTime,
7879        /// Same as before, except the "dependent" shipments need to have a
7880        /// "required" shipment on their vehicle at the time of their *delivery*.
7881        InSameVehicleAtDeliveryTime,
7882        /// If set, the enum was initialized with an unknown value.
7883        ///
7884        /// Applications can examine the value using [RequirementMode::value] or
7885        /// [RequirementMode::name].
7886        UnknownValue(requirement_mode::UnknownValue),
7887    }
7888
7889    #[doc(hidden)]
7890    pub mod requirement_mode {
7891        #[allow(unused_imports)]
7892        use super::*;
7893        #[derive(Clone, Debug, PartialEq)]
7894        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7895    }
7896
7897    impl RequirementMode {
7898        /// Gets the enum value.
7899        ///
7900        /// Returns `None` if the enum contains an unknown value deserialized from
7901        /// the string representation of enums.
7902        pub fn value(&self) -> std::option::Option<i32> {
7903            match self {
7904                Self::Unspecified => std::option::Option::Some(0),
7905                Self::PerformedBySameVehicle => std::option::Option::Some(1),
7906                Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
7907                Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
7908                Self::UnknownValue(u) => u.0.value(),
7909            }
7910        }
7911
7912        /// Gets the enum value as a string.
7913        ///
7914        /// Returns `None` if the enum contains an unknown value deserialized from
7915        /// the integer representation of enums.
7916        pub fn name(&self) -> std::option::Option<&str> {
7917            match self {
7918                Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
7919                Self::PerformedBySameVehicle => {
7920                    std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
7921                }
7922                Self::InSameVehicleAtPickupTime => {
7923                    std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
7924                }
7925                Self::InSameVehicleAtDeliveryTime => {
7926                    std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
7927                }
7928                Self::UnknownValue(u) => u.0.name(),
7929            }
7930        }
7931    }
7932
7933    impl std::default::Default for RequirementMode {
7934        fn default() -> Self {
7935            use std::convert::From;
7936            Self::from(0)
7937        }
7938    }
7939
7940    impl std::fmt::Display for RequirementMode {
7941        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7942            wkt::internal::display_enum(f, self.name(), self.value())
7943        }
7944    }
7945
7946    impl std::convert::From<i32> for RequirementMode {
7947        fn from(value: i32) -> Self {
7948            match value {
7949                0 => Self::Unspecified,
7950                1 => Self::PerformedBySameVehicle,
7951                2 => Self::InSameVehicleAtPickupTime,
7952                3 => Self::InSameVehicleAtDeliveryTime,
7953                _ => Self::UnknownValue(requirement_mode::UnknownValue(
7954                    wkt::internal::UnknownEnumValue::Integer(value),
7955                )),
7956            }
7957        }
7958    }
7959
7960    impl std::convert::From<&str> for RequirementMode {
7961        fn from(value: &str) -> Self {
7962            use std::string::ToString;
7963            match value {
7964                "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
7965                "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
7966                "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
7967                "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
7968                _ => Self::UnknownValue(requirement_mode::UnknownValue(
7969                    wkt::internal::UnknownEnumValue::String(value.to_string()),
7970                )),
7971            }
7972        }
7973    }
7974
7975    impl serde::ser::Serialize for RequirementMode {
7976        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7977        where
7978            S: serde::Serializer,
7979        {
7980            match self {
7981                Self::Unspecified => serializer.serialize_i32(0),
7982                Self::PerformedBySameVehicle => serializer.serialize_i32(1),
7983                Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
7984                Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
7985                Self::UnknownValue(u) => u.0.serialize(serializer),
7986            }
7987        }
7988    }
7989
7990    impl<'de> serde::de::Deserialize<'de> for RequirementMode {
7991        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7992        where
7993            D: serde::Deserializer<'de>,
7994        {
7995            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
7996                ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
7997            ))
7998        }
7999    }
8000}
8001
8002/// Encapsulates a set of optional conditions to satisfy when calculating
8003/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
8004/// Platform API; see:
8005/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
8006#[derive(Clone, Debug, Default, PartialEq)]
8007#[non_exhaustive]
8008pub struct RouteModifiers {
8009    /// Specifies whether to avoid toll roads where reasonable. Preference will be
8010    /// given to routes not containing toll roads. Applies only to motorized travel
8011    /// modes.
8012    pub avoid_tolls: bool,
8013
8014    /// Specifies whether to avoid highways where reasonable. Preference will be
8015    /// given to routes not containing highways. Applies only to motorized travel
8016    /// modes.
8017    pub avoid_highways: bool,
8018
8019    /// Specifies whether to avoid ferries where reasonable. Preference will be
8020    /// given to routes not containing travel by ferries. Applies only to motorized
8021    /// travel modes.
8022    pub avoid_ferries: bool,
8023
8024    /// Optional. Specifies whether to avoid navigating indoors where reasonable.
8025    /// Preference will be given to routes not containing indoor navigation.
8026    /// Applies only to the `WALKING` travel mode.
8027    pub avoid_indoor: bool,
8028
8029    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8030}
8031
8032impl RouteModifiers {
8033    pub fn new() -> Self {
8034        std::default::Default::default()
8035    }
8036
8037    /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
8038    pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8039        self.avoid_tolls = v.into();
8040        self
8041    }
8042
8043    /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
8044    pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8045        self.avoid_highways = v.into();
8046        self
8047    }
8048
8049    /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
8050    pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8051        self.avoid_ferries = v.into();
8052        self
8053    }
8054
8055    /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
8056    pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8057        self.avoid_indoor = v.into();
8058        self
8059    }
8060}
8061
8062impl wkt::message::Message for RouteModifiers {
8063    fn typename() -> &'static str {
8064        "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
8065    }
8066}
8067
8068#[doc(hidden)]
8069impl<'de> serde::de::Deserialize<'de> for RouteModifiers {
8070    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8071    where
8072        D: serde::Deserializer<'de>,
8073    {
8074        #[allow(non_camel_case_types)]
8075        #[doc(hidden)]
8076        #[derive(PartialEq, Eq, Hash)]
8077        enum __FieldTag {
8078            __avoid_tolls,
8079            __avoid_highways,
8080            __avoid_ferries,
8081            __avoid_indoor,
8082            Unknown(std::string::String),
8083        }
8084        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8085            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8086            where
8087                D: serde::Deserializer<'de>,
8088            {
8089                struct Visitor;
8090                impl<'de> serde::de::Visitor<'de> for Visitor {
8091                    type Value = __FieldTag;
8092                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8093                        formatter.write_str("a field name for RouteModifiers")
8094                    }
8095                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8096                    where
8097                        E: serde::de::Error,
8098                    {
8099                        use std::result::Result::Ok;
8100                        use std::string::ToString;
8101                        match value {
8102                            "avoidTolls" => Ok(__FieldTag::__avoid_tolls),
8103                            "avoid_tolls" => Ok(__FieldTag::__avoid_tolls),
8104                            "avoidHighways" => Ok(__FieldTag::__avoid_highways),
8105                            "avoid_highways" => Ok(__FieldTag::__avoid_highways),
8106                            "avoidFerries" => Ok(__FieldTag::__avoid_ferries),
8107                            "avoid_ferries" => Ok(__FieldTag::__avoid_ferries),
8108                            "avoidIndoor" => Ok(__FieldTag::__avoid_indoor),
8109                            "avoid_indoor" => Ok(__FieldTag::__avoid_indoor),
8110                            _ => Ok(__FieldTag::Unknown(value.to_string())),
8111                        }
8112                    }
8113                }
8114                deserializer.deserialize_identifier(Visitor)
8115            }
8116        }
8117        struct Visitor;
8118        impl<'de> serde::de::Visitor<'de> for Visitor {
8119            type Value = RouteModifiers;
8120            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8121                formatter.write_str("struct RouteModifiers")
8122            }
8123            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8124            where
8125                A: serde::de::MapAccess<'de>,
8126            {
8127                #[allow(unused_imports)]
8128                use serde::de::Error;
8129                use std::option::Option::Some;
8130                let mut fields = std::collections::HashSet::new();
8131                let mut result = Self::Value::new();
8132                while let Some(tag) = map.next_key::<__FieldTag>()? {
8133                    #[allow(clippy::match_single_binding)]
8134                    match tag {
8135                        __FieldTag::__avoid_tolls => {
8136                            if !fields.insert(__FieldTag::__avoid_tolls) {
8137                                return std::result::Result::Err(A::Error::duplicate_field(
8138                                    "multiple values for avoid_tolls",
8139                                ));
8140                            }
8141                            result.avoid_tolls = map
8142                                .next_value::<std::option::Option<bool>>()?
8143                                .unwrap_or_default();
8144                        }
8145                        __FieldTag::__avoid_highways => {
8146                            if !fields.insert(__FieldTag::__avoid_highways) {
8147                                return std::result::Result::Err(A::Error::duplicate_field(
8148                                    "multiple values for avoid_highways",
8149                                ));
8150                            }
8151                            result.avoid_highways = map
8152                                .next_value::<std::option::Option<bool>>()?
8153                                .unwrap_or_default();
8154                        }
8155                        __FieldTag::__avoid_ferries => {
8156                            if !fields.insert(__FieldTag::__avoid_ferries) {
8157                                return std::result::Result::Err(A::Error::duplicate_field(
8158                                    "multiple values for avoid_ferries",
8159                                ));
8160                            }
8161                            result.avoid_ferries = map
8162                                .next_value::<std::option::Option<bool>>()?
8163                                .unwrap_or_default();
8164                        }
8165                        __FieldTag::__avoid_indoor => {
8166                            if !fields.insert(__FieldTag::__avoid_indoor) {
8167                                return std::result::Result::Err(A::Error::duplicate_field(
8168                                    "multiple values for avoid_indoor",
8169                                ));
8170                            }
8171                            result.avoid_indoor = map
8172                                .next_value::<std::option::Option<bool>>()?
8173                                .unwrap_or_default();
8174                        }
8175                        __FieldTag::Unknown(key) => {
8176                            let value = map.next_value::<serde_json::Value>()?;
8177                            result._unknown_fields.insert(key, value);
8178                        }
8179                    }
8180                }
8181                std::result::Result::Ok(result)
8182            }
8183        }
8184        deserializer.deserialize_any(Visitor)
8185    }
8186}
8187
8188#[doc(hidden)]
8189impl serde::ser::Serialize for RouteModifiers {
8190    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8191    where
8192        S: serde::ser::Serializer,
8193    {
8194        use serde::ser::SerializeMap;
8195        #[allow(unused_imports)]
8196        use std::option::Option::Some;
8197        let mut state = serializer.serialize_map(std::option::Option::None)?;
8198        if !wkt::internal::is_default(&self.avoid_tolls) {
8199            state.serialize_entry("avoidTolls", &self.avoid_tolls)?;
8200        }
8201        if !wkt::internal::is_default(&self.avoid_highways) {
8202            state.serialize_entry("avoidHighways", &self.avoid_highways)?;
8203        }
8204        if !wkt::internal::is_default(&self.avoid_ferries) {
8205            state.serialize_entry("avoidFerries", &self.avoid_ferries)?;
8206        }
8207        if !wkt::internal::is_default(&self.avoid_indoor) {
8208            state.serialize_entry("avoidIndoor", &self.avoid_indoor)?;
8209        }
8210        if !self._unknown_fields.is_empty() {
8211            for (key, value) in self._unknown_fields.iter() {
8212                state.serialize_entry(key, &value)?;
8213            }
8214        }
8215        state.end()
8216    }
8217}
8218
8219/// Models a vehicle in a shipment problem. Solving a shipment problem will
8220/// build a route starting from `start_location` and ending at `end_location`
8221/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
8222#[derive(Clone, Debug, Default, PartialEq)]
8223#[non_exhaustive]
8224pub struct Vehicle {
8225    /// The travel mode which affects the roads usable by the vehicle and its
8226    /// speed. See also `travel_duration_multiple`.
8227    pub travel_mode: crate::model::vehicle::TravelMode,
8228
8229    /// Optional. A set of conditions to satisfy that affect the way routes are
8230    /// calculated for the given vehicle.
8231    pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
8232
8233    /// Geographic location where the vehicle starts before picking up any
8234    /// shipments. If not specified, the vehicle starts at its first pickup.
8235    /// If the shipment model has duration and distance matrices, `start_location`
8236    /// must not be specified.
8237    pub start_location: std::option::Option<gtype::model::LatLng>,
8238
8239    /// Waypoint representing a geographic location where the vehicle starts before
8240    /// picking up any shipments. If neither `start_waypoint` nor `start_location`
8241    /// is specified, the vehicle starts at its first pickup.
8242    /// If the shipment model has duration and distance matrices, `start_waypoint`
8243    /// must not be specified.
8244    pub start_waypoint: std::option::Option<crate::model::Waypoint>,
8245
8246    /// Geographic location where the vehicle ends after it has completed its last
8247    /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
8248    /// immediately when it completes its last `VisitRequest`.
8249    /// If the shipment model has duration and distance matrices, `end_location`
8250    /// must not be specified.
8251    pub end_location: std::option::Option<gtype::model::LatLng>,
8252
8253    /// Waypoint representing a geographic location where the vehicle ends after
8254    /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
8255    /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
8256    /// when it completes its last `VisitRequest`.
8257    /// If the shipment model has duration and distance matrices, `end_waypoint`
8258    /// must not be specified.
8259    pub end_waypoint: std::option::Option<crate::model::Waypoint>,
8260
8261    /// Specifies tags attached to the start of the vehicle's route.
8262    ///
8263    /// Empty or duplicate strings are not allowed.
8264    pub start_tags: std::vec::Vec<std::string::String>,
8265
8266    /// Specifies tags attached to the end of the vehicle's route.
8267    ///
8268    /// Empty or duplicate strings are not allowed.
8269    pub end_tags: std::vec::Vec<std::string::String>,
8270
8271    /// Time windows during which the vehicle may depart its start location.
8272    /// They must be within the global time limits (see
8273    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
8274    /// fields). If unspecified, there is no limitation besides those global time
8275    /// limits.
8276    ///
8277    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
8278    /// time window can overlap with or be adjacent to another, and they must be in
8279    /// chronological order.
8280    ///
8281    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
8282    /// there is a single time window.
8283    ///
8284    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
8285    pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
8286
8287    /// Time windows during which the vehicle may arrive at its end location.
8288    /// They must be within the global time limits (see
8289    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
8290    /// fields). If unspecified, there is no limitation besides those global time
8291    /// limits.
8292    ///
8293    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
8294    /// time window can overlap with or be adjacent to another, and they must be in
8295    /// chronological order.
8296    ///
8297    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
8298    /// there is a single time window.
8299    ///
8300    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
8301    pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
8302
8303    /// Specifies a multiplicative factor that can be used to increase or decrease
8304    /// travel times of this vehicle. For example, setting this to 2.0 means
8305    /// that this vehicle is slower and has travel times that are twice what they
8306    /// are for standard vehicles. This multiple does not affect visit durations.
8307    /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
8308    /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
8309    /// is standard, and this multiple is considered 1.0.
8310    ///
8311    /// WARNING: Travel times will be rounded to the nearest second after this
8312    /// multiple is applied but before performing any numerical operations, thus,
8313    /// a small multiple may result in a loss of precision.
8314    ///
8315    /// See also `extra_visit_duration_for_visit_type` below.
8316    pub travel_duration_multiple: std::option::Option<f64>,
8317
8318    /// Unloading policy enforced on the vehicle.
8319    pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
8320
8321    /// Capacities of the vehicle (weight, volume, # of pallets for example).
8322    /// The keys in the map are the identifiers of the type of load, consistent
8323    /// with the keys of the
8324    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
8325    /// field. If a given key is absent from this map, the corresponding capacity
8326    /// is considered to be limitless.
8327    ///
8328    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
8329    pub load_limits:
8330        std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
8331
8332    /// Vehicle costs: all costs add up and must be in the same unit as
8333    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
8334    ///
8335    /// Cost per hour of the vehicle route. This cost is applied to the total time
8336    /// taken by the route, and includes travel time, waiting time, and visit time.
8337    /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
8338    /// in additional latency.
8339    ///
8340    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
8341    pub cost_per_hour: f64,
8342
8343    /// Cost per traveled hour of the vehicle route. This cost is applied only to
8344    /// travel time taken by the route (i.e., that reported in
8345    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
8346    /// and excludes waiting time and visit time.
8347    ///
8348    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8349    pub cost_per_traveled_hour: f64,
8350
8351    /// Cost per kilometer of the vehicle route. This cost is applied to the
8352    /// distance reported in the
8353    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8354    /// and does not apply to any distance implicitly traveled from the
8355    /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
8356    ///
8357    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8358    pub cost_per_kilometer: f64,
8359
8360    /// Fixed cost applied if this vehicle is used to handle a shipment.
8361    pub fixed_cost: f64,
8362
8363    /// This field only applies to vehicles when their route does not serve any
8364    /// shipments. It indicates if the vehicle should be considered as used or not
8365    /// in this case.
8366    ///
8367    /// If true, the vehicle goes from its start to its end location even if it
8368    /// doesn't serve any shipments, and time and distance costs resulting from its
8369    /// start --> end travel are taken into account.
8370    ///
8371    /// Otherwise, it doesn't travel from its start to its end location, and no
8372    /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
8373    /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
8374    /// information except for the vehicle index and label.
8375    pub used_if_route_is_empty: bool,
8376
8377    /// Limit applied to the total duration of the vehicle's route. In a given
8378    /// `OptimizeToursResponse`, the route duration of a vehicle is the
8379    /// difference between its `vehicle_end_time` and `vehicle_start_time`.
8380    pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
8381
8382    /// Limit applied to the travel duration of the vehicle's route. In a given
8383    /// `OptimizeToursResponse`, the route travel duration is the sum of all its
8384    /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
8385    ///
8386    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
8387    pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
8388
8389    /// Limit applied to the total distance of the vehicle's route. In a given
8390    /// `OptimizeToursResponse`, the route distance is the sum of all its
8391    /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
8392    ///
8393    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
8394    pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
8395
8396    /// Specifies a map from visit_types strings to durations. The duration is time
8397    /// in addition to
8398    /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
8399    /// to be taken at visits with the specified `visit_types`. This extra visit
8400    /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
8401    /// `visit_types`) cannot be empty strings.
8402    ///
8403    /// If a visit request has multiple types, a duration will be added for each
8404    /// type in the map.
8405    ///
8406    /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
8407    pub extra_visit_duration_for_visit_type:
8408        std::collections::HashMap<std::string::String, wkt::Duration>,
8409
8410    /// Describes the break schedule to be enforced on this vehicle.
8411    /// If empty, no breaks will be scheduled for this vehicle.
8412    pub break_rule: std::option::Option<crate::model::BreakRule>,
8413
8414    /// Specifies a label for this vehicle. This label is reported in the response
8415    /// as the `vehicle_label` of the corresponding
8416    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
8417    ///
8418    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
8419    pub label: std::string::String,
8420
8421    /// If true, `used_if_route_is_empty` must be false, and this vehicle will
8422    /// remain unused.
8423    ///
8424    /// If a shipment is performed by an ignored vehicle in
8425    /// `injected_first_solution_routes`, it is skipped in the first solution but
8426    /// is free to be performed in the response.
8427    ///
8428    /// If a shipment is performed by an ignored vehicle in
8429    /// `injected_solution_constraint` and any related pickup/delivery is
8430    /// constrained to remain on the vehicle (i.e., not relaxed to level
8431    /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
8432    /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
8433    /// the allowed vehicles are ignored, it is skipped in the response.
8434    pub ignore: bool,
8435
8436    /// Deprecated: No longer used.
8437    /// Indices in the `break_rule` field in the source
8438    /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
8439    /// correspond to break rules enforced on the vehicle.
8440    ///
8441    /// As of 2018/03, at most one rule index per vehicle can be specified.
8442    ///
8443    /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
8444    #[deprecated]
8445    pub break_rule_indices: std::vec::Vec<i32>,
8446
8447    /// Deprecated: Use
8448    /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
8449    /// instead.
8450    ///
8451    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
8452    #[deprecated]
8453    pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
8454
8455    /// Deprecated: Use
8456    /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
8457    /// instead.
8458    ///
8459    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
8460    #[deprecated]
8461    pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
8462
8463    /// Deprecated: Use
8464    /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
8465    /// instead.
8466    ///
8467    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
8468    #[deprecated]
8469    pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
8470
8471    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8472}
8473
8474impl Vehicle {
8475    pub fn new() -> Self {
8476        std::default::Default::default()
8477    }
8478
8479    /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
8480    pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
8481        mut self,
8482        v: T,
8483    ) -> Self {
8484        self.travel_mode = v.into();
8485        self
8486    }
8487
8488    /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
8489    pub fn set_route_modifiers<T>(mut self, v: T) -> Self
8490    where
8491        T: std::convert::Into<crate::model::RouteModifiers>,
8492    {
8493        self.route_modifiers = std::option::Option::Some(v.into());
8494        self
8495    }
8496
8497    /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
8498    pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
8499    where
8500        T: std::convert::Into<crate::model::RouteModifiers>,
8501    {
8502        self.route_modifiers = v.map(|x| x.into());
8503        self
8504    }
8505
8506    /// Sets the value of [start_location][crate::model::Vehicle::start_location].
8507    pub fn set_start_location<T>(mut self, v: T) -> Self
8508    where
8509        T: std::convert::Into<gtype::model::LatLng>,
8510    {
8511        self.start_location = std::option::Option::Some(v.into());
8512        self
8513    }
8514
8515    /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
8516    pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
8517    where
8518        T: std::convert::Into<gtype::model::LatLng>,
8519    {
8520        self.start_location = v.map(|x| x.into());
8521        self
8522    }
8523
8524    /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
8525    pub fn set_start_waypoint<T>(mut self, v: T) -> Self
8526    where
8527        T: std::convert::Into<crate::model::Waypoint>,
8528    {
8529        self.start_waypoint = std::option::Option::Some(v.into());
8530        self
8531    }
8532
8533    /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
8534    pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
8535    where
8536        T: std::convert::Into<crate::model::Waypoint>,
8537    {
8538        self.start_waypoint = v.map(|x| x.into());
8539        self
8540    }
8541
8542    /// Sets the value of [end_location][crate::model::Vehicle::end_location].
8543    pub fn set_end_location<T>(mut self, v: T) -> Self
8544    where
8545        T: std::convert::Into<gtype::model::LatLng>,
8546    {
8547        self.end_location = std::option::Option::Some(v.into());
8548        self
8549    }
8550
8551    /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
8552    pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
8553    where
8554        T: std::convert::Into<gtype::model::LatLng>,
8555    {
8556        self.end_location = v.map(|x| x.into());
8557        self
8558    }
8559
8560    /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
8561    pub fn set_end_waypoint<T>(mut self, v: T) -> Self
8562    where
8563        T: std::convert::Into<crate::model::Waypoint>,
8564    {
8565        self.end_waypoint = std::option::Option::Some(v.into());
8566        self
8567    }
8568
8569    /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
8570    pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
8571    where
8572        T: std::convert::Into<crate::model::Waypoint>,
8573    {
8574        self.end_waypoint = v.map(|x| x.into());
8575        self
8576    }
8577
8578    /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
8579    pub fn set_start_tags<T, V>(mut self, v: T) -> Self
8580    where
8581        T: std::iter::IntoIterator<Item = V>,
8582        V: std::convert::Into<std::string::String>,
8583    {
8584        use std::iter::Iterator;
8585        self.start_tags = v.into_iter().map(|i| i.into()).collect();
8586        self
8587    }
8588
8589    /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
8590    pub fn set_end_tags<T, V>(mut self, v: T) -> Self
8591    where
8592        T: std::iter::IntoIterator<Item = V>,
8593        V: std::convert::Into<std::string::String>,
8594    {
8595        use std::iter::Iterator;
8596        self.end_tags = v.into_iter().map(|i| i.into()).collect();
8597        self
8598    }
8599
8600    /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
8601    pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
8602    where
8603        T: std::iter::IntoIterator<Item = V>,
8604        V: std::convert::Into<crate::model::TimeWindow>,
8605    {
8606        use std::iter::Iterator;
8607        self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
8608        self
8609    }
8610
8611    /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
8612    pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
8613    where
8614        T: std::iter::IntoIterator<Item = V>,
8615        V: std::convert::Into<crate::model::TimeWindow>,
8616    {
8617        use std::iter::Iterator;
8618        self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
8619        self
8620    }
8621
8622    /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
8623    pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
8624    where
8625        T: std::convert::Into<f64>,
8626    {
8627        self.travel_duration_multiple = std::option::Option::Some(v.into());
8628        self
8629    }
8630
8631    /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
8632    pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
8633    where
8634        T: std::convert::Into<f64>,
8635    {
8636        self.travel_duration_multiple = v.map(|x| x.into());
8637        self
8638    }
8639
8640    /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
8641    pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
8642        mut self,
8643        v: T,
8644    ) -> Self {
8645        self.unloading_policy = v.into();
8646        self
8647    }
8648
8649    /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
8650    pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
8651    where
8652        T: std::iter::IntoIterator<Item = (K, V)>,
8653        K: std::convert::Into<std::string::String>,
8654        V: std::convert::Into<crate::model::vehicle::LoadLimit>,
8655    {
8656        use std::iter::Iterator;
8657        self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8658        self
8659    }
8660
8661    /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
8662    pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8663        self.cost_per_hour = v.into();
8664        self
8665    }
8666
8667    /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
8668    pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8669        self.cost_per_traveled_hour = v.into();
8670        self
8671    }
8672
8673    /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
8674    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8675        self.cost_per_kilometer = v.into();
8676        self
8677    }
8678
8679    /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
8680    pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8681        self.fixed_cost = v.into();
8682        self
8683    }
8684
8685    /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
8686    pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8687        self.used_if_route_is_empty = v.into();
8688        self
8689    }
8690
8691    /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
8692    pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
8693    where
8694        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
8695    {
8696        self.route_duration_limit = std::option::Option::Some(v.into());
8697        self
8698    }
8699
8700    /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
8701    pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
8702    where
8703        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
8704    {
8705        self.route_duration_limit = v.map(|x| x.into());
8706        self
8707    }
8708
8709    /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
8710    pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
8711    where
8712        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
8713    {
8714        self.travel_duration_limit = std::option::Option::Some(v.into());
8715        self
8716    }
8717
8718    /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
8719    pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
8720    where
8721        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
8722    {
8723        self.travel_duration_limit = v.map(|x| x.into());
8724        self
8725    }
8726
8727    /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
8728    pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
8729    where
8730        T: std::convert::Into<crate::model::DistanceLimit>,
8731    {
8732        self.route_distance_limit = std::option::Option::Some(v.into());
8733        self
8734    }
8735
8736    /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
8737    pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
8738    where
8739        T: std::convert::Into<crate::model::DistanceLimit>,
8740    {
8741        self.route_distance_limit = v.map(|x| x.into());
8742        self
8743    }
8744
8745    /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
8746    pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
8747    where
8748        T: std::iter::IntoIterator<Item = (K, V)>,
8749        K: std::convert::Into<std::string::String>,
8750        V: std::convert::Into<wkt::Duration>,
8751    {
8752        use std::iter::Iterator;
8753        self.extra_visit_duration_for_visit_type =
8754            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8755        self
8756    }
8757
8758    /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
8759    pub fn set_break_rule<T>(mut self, v: T) -> Self
8760    where
8761        T: std::convert::Into<crate::model::BreakRule>,
8762    {
8763        self.break_rule = std::option::Option::Some(v.into());
8764        self
8765    }
8766
8767    /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
8768    pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
8769    where
8770        T: std::convert::Into<crate::model::BreakRule>,
8771    {
8772        self.break_rule = v.map(|x| x.into());
8773        self
8774    }
8775
8776    /// Sets the value of [label][crate::model::Vehicle::label].
8777    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8778        self.label = v.into();
8779        self
8780    }
8781
8782    /// Sets the value of [ignore][crate::model::Vehicle::ignore].
8783    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8784        self.ignore = v.into();
8785        self
8786    }
8787
8788    /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
8789    #[deprecated]
8790    pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
8791    where
8792        T: std::iter::IntoIterator<Item = V>,
8793        V: std::convert::Into<i32>,
8794    {
8795        use std::iter::Iterator;
8796        self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
8797        self
8798    }
8799
8800    /// Sets the value of [capacities][crate::model::Vehicle::capacities].
8801    #[deprecated]
8802    pub fn set_capacities<T, V>(mut self, v: T) -> Self
8803    where
8804        T: std::iter::IntoIterator<Item = V>,
8805        V: std::convert::Into<crate::model::CapacityQuantity>,
8806    {
8807        use std::iter::Iterator;
8808        self.capacities = v.into_iter().map(|i| i.into()).collect();
8809        self
8810    }
8811
8812    /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
8813    #[deprecated]
8814    pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
8815    where
8816        T: std::iter::IntoIterator<Item = V>,
8817        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
8818    {
8819        use std::iter::Iterator;
8820        self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
8821        self
8822    }
8823
8824    /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
8825    #[deprecated]
8826    pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
8827    where
8828        T: std::iter::IntoIterator<Item = V>,
8829        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
8830    {
8831        use std::iter::Iterator;
8832        self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
8833        self
8834    }
8835}
8836
8837impl wkt::message::Message for Vehicle {
8838    fn typename() -> &'static str {
8839        "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
8840    }
8841}
8842
8843#[doc(hidden)]
8844impl<'de> serde::de::Deserialize<'de> for Vehicle {
8845    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8846    where
8847        D: serde::Deserializer<'de>,
8848    {
8849        #[allow(non_camel_case_types)]
8850        #[doc(hidden)]
8851        #[derive(PartialEq, Eq, Hash)]
8852        enum __FieldTag {
8853            __travel_mode,
8854            __route_modifiers,
8855            __start_location,
8856            __start_waypoint,
8857            __end_location,
8858            __end_waypoint,
8859            __start_tags,
8860            __end_tags,
8861            __start_time_windows,
8862            __end_time_windows,
8863            __travel_duration_multiple,
8864            __unloading_policy,
8865            __load_limits,
8866            __cost_per_hour,
8867            __cost_per_traveled_hour,
8868            __cost_per_kilometer,
8869            __fixed_cost,
8870            __used_if_route_is_empty,
8871            __route_duration_limit,
8872            __travel_duration_limit,
8873            __route_distance_limit,
8874            __extra_visit_duration_for_visit_type,
8875            __break_rule,
8876            __label,
8877            __ignore,
8878            __break_rule_indices,
8879            __capacities,
8880            __start_load_intervals,
8881            __end_load_intervals,
8882            Unknown(std::string::String),
8883        }
8884        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8885            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8886            where
8887                D: serde::Deserializer<'de>,
8888            {
8889                struct Visitor;
8890                impl<'de> serde::de::Visitor<'de> for Visitor {
8891                    type Value = __FieldTag;
8892                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8893                        formatter.write_str("a field name for Vehicle")
8894                    }
8895                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8896                    where
8897                        E: serde::de::Error,
8898                    {
8899                        use std::result::Result::Ok;
8900                        use std::string::ToString;
8901                        match value {
8902                            "travelMode" => Ok(__FieldTag::__travel_mode),
8903                            "travel_mode" => Ok(__FieldTag::__travel_mode),
8904                            "routeModifiers" => Ok(__FieldTag::__route_modifiers),
8905                            "route_modifiers" => Ok(__FieldTag::__route_modifiers),
8906                            "startLocation" => Ok(__FieldTag::__start_location),
8907                            "start_location" => Ok(__FieldTag::__start_location),
8908                            "startWaypoint" => Ok(__FieldTag::__start_waypoint),
8909                            "start_waypoint" => Ok(__FieldTag::__start_waypoint),
8910                            "endLocation" => Ok(__FieldTag::__end_location),
8911                            "end_location" => Ok(__FieldTag::__end_location),
8912                            "endWaypoint" => Ok(__FieldTag::__end_waypoint),
8913                            "end_waypoint" => Ok(__FieldTag::__end_waypoint),
8914                            "startTags" => Ok(__FieldTag::__start_tags),
8915                            "start_tags" => Ok(__FieldTag::__start_tags),
8916                            "endTags" => Ok(__FieldTag::__end_tags),
8917                            "end_tags" => Ok(__FieldTag::__end_tags),
8918                            "startTimeWindows" => Ok(__FieldTag::__start_time_windows),
8919                            "start_time_windows" => Ok(__FieldTag::__start_time_windows),
8920                            "endTimeWindows" => Ok(__FieldTag::__end_time_windows),
8921                            "end_time_windows" => Ok(__FieldTag::__end_time_windows),
8922                            "travelDurationMultiple" => Ok(__FieldTag::__travel_duration_multiple),
8923                            "travel_duration_multiple" => {
8924                                Ok(__FieldTag::__travel_duration_multiple)
8925                            }
8926                            "unloadingPolicy" => Ok(__FieldTag::__unloading_policy),
8927                            "unloading_policy" => Ok(__FieldTag::__unloading_policy),
8928                            "loadLimits" => Ok(__FieldTag::__load_limits),
8929                            "load_limits" => Ok(__FieldTag::__load_limits),
8930                            "costPerHour" => Ok(__FieldTag::__cost_per_hour),
8931                            "cost_per_hour" => Ok(__FieldTag::__cost_per_hour),
8932                            "costPerTraveledHour" => Ok(__FieldTag::__cost_per_traveled_hour),
8933                            "cost_per_traveled_hour" => Ok(__FieldTag::__cost_per_traveled_hour),
8934                            "costPerKilometer" => Ok(__FieldTag::__cost_per_kilometer),
8935                            "cost_per_kilometer" => Ok(__FieldTag::__cost_per_kilometer),
8936                            "fixedCost" => Ok(__FieldTag::__fixed_cost),
8937                            "fixed_cost" => Ok(__FieldTag::__fixed_cost),
8938                            "usedIfRouteIsEmpty" => Ok(__FieldTag::__used_if_route_is_empty),
8939                            "used_if_route_is_empty" => Ok(__FieldTag::__used_if_route_is_empty),
8940                            "routeDurationLimit" => Ok(__FieldTag::__route_duration_limit),
8941                            "route_duration_limit" => Ok(__FieldTag::__route_duration_limit),
8942                            "travelDurationLimit" => Ok(__FieldTag::__travel_duration_limit),
8943                            "travel_duration_limit" => Ok(__FieldTag::__travel_duration_limit),
8944                            "routeDistanceLimit" => Ok(__FieldTag::__route_distance_limit),
8945                            "route_distance_limit" => Ok(__FieldTag::__route_distance_limit),
8946                            "extraVisitDurationForVisitType" => {
8947                                Ok(__FieldTag::__extra_visit_duration_for_visit_type)
8948                            }
8949                            "extra_visit_duration_for_visit_type" => {
8950                                Ok(__FieldTag::__extra_visit_duration_for_visit_type)
8951                            }
8952                            "breakRule" => Ok(__FieldTag::__break_rule),
8953                            "break_rule" => Ok(__FieldTag::__break_rule),
8954                            "label" => Ok(__FieldTag::__label),
8955                            "ignore" => Ok(__FieldTag::__ignore),
8956                            "breakRuleIndices" => Ok(__FieldTag::__break_rule_indices),
8957                            "break_rule_indices" => Ok(__FieldTag::__break_rule_indices),
8958                            "capacities" => Ok(__FieldTag::__capacities),
8959                            "startLoadIntervals" => Ok(__FieldTag::__start_load_intervals),
8960                            "start_load_intervals" => Ok(__FieldTag::__start_load_intervals),
8961                            "endLoadIntervals" => Ok(__FieldTag::__end_load_intervals),
8962                            "end_load_intervals" => Ok(__FieldTag::__end_load_intervals),
8963                            _ => Ok(__FieldTag::Unknown(value.to_string())),
8964                        }
8965                    }
8966                }
8967                deserializer.deserialize_identifier(Visitor)
8968            }
8969        }
8970        struct Visitor;
8971        impl<'de> serde::de::Visitor<'de> for Visitor {
8972            type Value = Vehicle;
8973            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8974                formatter.write_str("struct Vehicle")
8975            }
8976            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8977            where
8978                A: serde::de::MapAccess<'de>,
8979            {
8980                #[allow(unused_imports)]
8981                use serde::de::Error;
8982                use std::option::Option::Some;
8983                let mut fields = std::collections::HashSet::new();
8984                let mut result = Self::Value::new();
8985                while let Some(tag) = map.next_key::<__FieldTag>()? {
8986                    #[allow(clippy::match_single_binding)]
8987                    match tag {
8988                        __FieldTag::__travel_mode => {
8989                            if !fields.insert(__FieldTag::__travel_mode) {
8990                                return std::result::Result::Err(A::Error::duplicate_field(
8991                                    "multiple values for travel_mode",
8992                                ));
8993                            }
8994                            result.travel_mode = map.next_value::<std::option::Option<crate::model::vehicle::TravelMode>>()?.unwrap_or_default();
8995                        }
8996                        __FieldTag::__route_modifiers => {
8997                            if !fields.insert(__FieldTag::__route_modifiers) {
8998                                return std::result::Result::Err(A::Error::duplicate_field(
8999                                    "multiple values for route_modifiers",
9000                                ));
9001                            }
9002                            result.route_modifiers = map
9003                                .next_value::<std::option::Option<crate::model::RouteModifiers>>(
9004                                )?;
9005                        }
9006                        __FieldTag::__start_location => {
9007                            if !fields.insert(__FieldTag::__start_location) {
9008                                return std::result::Result::Err(A::Error::duplicate_field(
9009                                    "multiple values for start_location",
9010                                ));
9011                            }
9012                            result.start_location =
9013                                map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
9014                        }
9015                        __FieldTag::__start_waypoint => {
9016                            if !fields.insert(__FieldTag::__start_waypoint) {
9017                                return std::result::Result::Err(A::Error::duplicate_field(
9018                                    "multiple values for start_waypoint",
9019                                ));
9020                            }
9021                            result.start_waypoint =
9022                                map.next_value::<std::option::Option<crate::model::Waypoint>>()?;
9023                        }
9024                        __FieldTag::__end_location => {
9025                            if !fields.insert(__FieldTag::__end_location) {
9026                                return std::result::Result::Err(A::Error::duplicate_field(
9027                                    "multiple values for end_location",
9028                                ));
9029                            }
9030                            result.end_location =
9031                                map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
9032                        }
9033                        __FieldTag::__end_waypoint => {
9034                            if !fields.insert(__FieldTag::__end_waypoint) {
9035                                return std::result::Result::Err(A::Error::duplicate_field(
9036                                    "multiple values for end_waypoint",
9037                                ));
9038                            }
9039                            result.end_waypoint =
9040                                map.next_value::<std::option::Option<crate::model::Waypoint>>()?;
9041                        }
9042                        __FieldTag::__start_tags => {
9043                            if !fields.insert(__FieldTag::__start_tags) {
9044                                return std::result::Result::Err(A::Error::duplicate_field(
9045                                    "multiple values for start_tags",
9046                                ));
9047                            }
9048                            result.start_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
9049                        }
9050                        __FieldTag::__end_tags => {
9051                            if !fields.insert(__FieldTag::__end_tags) {
9052                                return std::result::Result::Err(A::Error::duplicate_field(
9053                                    "multiple values for end_tags",
9054                                ));
9055                            }
9056                            result.end_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
9057                        }
9058                        __FieldTag::__start_time_windows => {
9059                            if !fields.insert(__FieldTag::__start_time_windows) {
9060                                return std::result::Result::Err(A::Error::duplicate_field(
9061                                    "multiple values for start_time_windows",
9062                                ));
9063                            }
9064                            result.start_time_windows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::TimeWindow>>>()?.unwrap_or_default();
9065                        }
9066                        __FieldTag::__end_time_windows => {
9067                            if !fields.insert(__FieldTag::__end_time_windows) {
9068                                return std::result::Result::Err(A::Error::duplicate_field(
9069                                    "multiple values for end_time_windows",
9070                                ));
9071                            }
9072                            result.end_time_windows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::TimeWindow>>>()?.unwrap_or_default();
9073                        }
9074                        __FieldTag::__travel_duration_multiple => {
9075                            if !fields.insert(__FieldTag::__travel_duration_multiple) {
9076                                return std::result::Result::Err(A::Error::duplicate_field(
9077                                    "multiple values for travel_duration_multiple",
9078                                ));
9079                            }
9080                            struct __With(std::option::Option<f64>);
9081                            impl<'de> serde::de::Deserialize<'de> for __With {
9082                                fn deserialize<D>(
9083                                    deserializer: D,
9084                                ) -> std::result::Result<Self, D::Error>
9085                                where
9086                                    D: serde::de::Deserializer<'de>,
9087                                {
9088                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9089                                }
9090                            }
9091                            result.travel_duration_multiple = map.next_value::<__With>()?.0;
9092                        }
9093                        __FieldTag::__unloading_policy => {
9094                            if !fields.insert(__FieldTag::__unloading_policy) {
9095                                return std::result::Result::Err(A::Error::duplicate_field(
9096                                    "multiple values for unloading_policy",
9097                                ));
9098                            }
9099                            result.unloading_policy = map.next_value::<std::option::Option<crate::model::vehicle::UnloadingPolicy>>()?.unwrap_or_default();
9100                        }
9101                        __FieldTag::__load_limits => {
9102                            if !fields.insert(__FieldTag::__load_limits) {
9103                                return std::result::Result::Err(A::Error::duplicate_field(
9104                                    "multiple values for load_limits",
9105                                ));
9106                            }
9107                            result.load_limits = map
9108                                .next_value::<std::option::Option<
9109                                    std::collections::HashMap<
9110                                        std::string::String,
9111                                        crate::model::vehicle::LoadLimit,
9112                                    >,
9113                                >>()?
9114                                .unwrap_or_default();
9115                        }
9116                        __FieldTag::__cost_per_hour => {
9117                            if !fields.insert(__FieldTag::__cost_per_hour) {
9118                                return std::result::Result::Err(A::Error::duplicate_field(
9119                                    "multiple values for cost_per_hour",
9120                                ));
9121                            }
9122                            struct __With(std::option::Option<f64>);
9123                            impl<'de> serde::de::Deserialize<'de> for __With {
9124                                fn deserialize<D>(
9125                                    deserializer: D,
9126                                ) -> std::result::Result<Self, D::Error>
9127                                where
9128                                    D: serde::de::Deserializer<'de>,
9129                                {
9130                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9131                                }
9132                            }
9133                            result.cost_per_hour =
9134                                map.next_value::<__With>()?.0.unwrap_or_default();
9135                        }
9136                        __FieldTag::__cost_per_traveled_hour => {
9137                            if !fields.insert(__FieldTag::__cost_per_traveled_hour) {
9138                                return std::result::Result::Err(A::Error::duplicate_field(
9139                                    "multiple values for cost_per_traveled_hour",
9140                                ));
9141                            }
9142                            struct __With(std::option::Option<f64>);
9143                            impl<'de> serde::de::Deserialize<'de> for __With {
9144                                fn deserialize<D>(
9145                                    deserializer: D,
9146                                ) -> std::result::Result<Self, D::Error>
9147                                where
9148                                    D: serde::de::Deserializer<'de>,
9149                                {
9150                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9151                                }
9152                            }
9153                            result.cost_per_traveled_hour =
9154                                map.next_value::<__With>()?.0.unwrap_or_default();
9155                        }
9156                        __FieldTag::__cost_per_kilometer => {
9157                            if !fields.insert(__FieldTag::__cost_per_kilometer) {
9158                                return std::result::Result::Err(A::Error::duplicate_field(
9159                                    "multiple values for cost_per_kilometer",
9160                                ));
9161                            }
9162                            struct __With(std::option::Option<f64>);
9163                            impl<'de> serde::de::Deserialize<'de> for __With {
9164                                fn deserialize<D>(
9165                                    deserializer: D,
9166                                ) -> std::result::Result<Self, D::Error>
9167                                where
9168                                    D: serde::de::Deserializer<'de>,
9169                                {
9170                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9171                                }
9172                            }
9173                            result.cost_per_kilometer =
9174                                map.next_value::<__With>()?.0.unwrap_or_default();
9175                        }
9176                        __FieldTag::__fixed_cost => {
9177                            if !fields.insert(__FieldTag::__fixed_cost) {
9178                                return std::result::Result::Err(A::Error::duplicate_field(
9179                                    "multiple values for fixed_cost",
9180                                ));
9181                            }
9182                            struct __With(std::option::Option<f64>);
9183                            impl<'de> serde::de::Deserialize<'de> for __With {
9184                                fn deserialize<D>(
9185                                    deserializer: D,
9186                                ) -> std::result::Result<Self, D::Error>
9187                                where
9188                                    D: serde::de::Deserializer<'de>,
9189                                {
9190                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9191                                }
9192                            }
9193                            result.fixed_cost = map.next_value::<__With>()?.0.unwrap_or_default();
9194                        }
9195                        __FieldTag::__used_if_route_is_empty => {
9196                            if !fields.insert(__FieldTag::__used_if_route_is_empty) {
9197                                return std::result::Result::Err(A::Error::duplicate_field(
9198                                    "multiple values for used_if_route_is_empty",
9199                                ));
9200                            }
9201                            result.used_if_route_is_empty = map
9202                                .next_value::<std::option::Option<bool>>()?
9203                                .unwrap_or_default();
9204                        }
9205                        __FieldTag::__route_duration_limit => {
9206                            if !fields.insert(__FieldTag::__route_duration_limit) {
9207                                return std::result::Result::Err(A::Error::duplicate_field(
9208                                    "multiple values for route_duration_limit",
9209                                ));
9210                            }
9211                            result.route_duration_limit = map.next_value::<std::option::Option<crate::model::vehicle::DurationLimit>>()?
9212                                ;
9213                        }
9214                        __FieldTag::__travel_duration_limit => {
9215                            if !fields.insert(__FieldTag::__travel_duration_limit) {
9216                                return std::result::Result::Err(A::Error::duplicate_field(
9217                                    "multiple values for travel_duration_limit",
9218                                ));
9219                            }
9220                            result.travel_duration_limit = map.next_value::<std::option::Option<crate::model::vehicle::DurationLimit>>()?
9221                                ;
9222                        }
9223                        __FieldTag::__route_distance_limit => {
9224                            if !fields.insert(__FieldTag::__route_distance_limit) {
9225                                return std::result::Result::Err(A::Error::duplicate_field(
9226                                    "multiple values for route_distance_limit",
9227                                ));
9228                            }
9229                            result.route_distance_limit = map
9230                                .next_value::<std::option::Option<crate::model::DistanceLimit>>()?;
9231                        }
9232                        __FieldTag::__extra_visit_duration_for_visit_type => {
9233                            if !fields.insert(__FieldTag::__extra_visit_duration_for_visit_type) {
9234                                return std::result::Result::Err(A::Error::duplicate_field(
9235                                    "multiple values for extra_visit_duration_for_visit_type",
9236                                ));
9237                            }
9238                            result.extra_visit_duration_for_visit_type = map
9239                                .next_value::<std::option::Option<
9240                                    std::collections::HashMap<std::string::String, wkt::Duration>,
9241                                >>()?
9242                                .unwrap_or_default();
9243                        }
9244                        __FieldTag::__break_rule => {
9245                            if !fields.insert(__FieldTag::__break_rule) {
9246                                return std::result::Result::Err(A::Error::duplicate_field(
9247                                    "multiple values for break_rule",
9248                                ));
9249                            }
9250                            result.break_rule =
9251                                map.next_value::<std::option::Option<crate::model::BreakRule>>()?;
9252                        }
9253                        __FieldTag::__label => {
9254                            if !fields.insert(__FieldTag::__label) {
9255                                return std::result::Result::Err(A::Error::duplicate_field(
9256                                    "multiple values for label",
9257                                ));
9258                            }
9259                            result.label = map
9260                                .next_value::<std::option::Option<std::string::String>>()?
9261                                .unwrap_or_default();
9262                        }
9263                        __FieldTag::__ignore => {
9264                            if !fields.insert(__FieldTag::__ignore) {
9265                                return std::result::Result::Err(A::Error::duplicate_field(
9266                                    "multiple values for ignore",
9267                                ));
9268                            }
9269                            result.ignore = map
9270                                .next_value::<std::option::Option<bool>>()?
9271                                .unwrap_or_default();
9272                        }
9273                        __FieldTag::__break_rule_indices => {
9274                            if !fields.insert(__FieldTag::__break_rule_indices) {
9275                                return std::result::Result::Err(A::Error::duplicate_field(
9276                                    "multiple values for break_rule_indices",
9277                                ));
9278                            }
9279                            struct __With(std::option::Option<std::vec::Vec<i32>>);
9280                            impl<'de> serde::de::Deserialize<'de> for __With {
9281                                fn deserialize<D>(
9282                                    deserializer: D,
9283                                ) -> std::result::Result<Self, D::Error>
9284                                where
9285                                    D: serde::de::Deserializer<'de>,
9286                                {
9287                                    serde_with::As::<
9288                                        std::option::Option<std::vec::Vec<wkt::internal::I32>>,
9289                                    >::deserialize(deserializer)
9290                                    .map(__With)
9291                                }
9292                            }
9293                            result.break_rule_indices =
9294                                map.next_value::<__With>()?.0.unwrap_or_default();
9295                        }
9296                        __FieldTag::__capacities => {
9297                            if !fields.insert(__FieldTag::__capacities) {
9298                                return std::result::Result::Err(A::Error::duplicate_field(
9299                                    "multiple values for capacities",
9300                                ));
9301                            }
9302                            result.capacities =
9303                                map.next_value::<std::option::Option<
9304                                    std::vec::Vec<crate::model::CapacityQuantity>,
9305                                >>()?
9306                                .unwrap_or_default();
9307                        }
9308                        __FieldTag::__start_load_intervals => {
9309                            if !fields.insert(__FieldTag::__start_load_intervals) {
9310                                return std::result::Result::Err(A::Error::duplicate_field(
9311                                    "multiple values for start_load_intervals",
9312                                ));
9313                            }
9314                            result.start_load_intervals = map
9315                                .next_value::<std::option::Option<
9316                                    std::vec::Vec<crate::model::CapacityQuantityInterval>,
9317                                >>()?
9318                                .unwrap_or_default();
9319                        }
9320                        __FieldTag::__end_load_intervals => {
9321                            if !fields.insert(__FieldTag::__end_load_intervals) {
9322                                return std::result::Result::Err(A::Error::duplicate_field(
9323                                    "multiple values for end_load_intervals",
9324                                ));
9325                            }
9326                            result.end_load_intervals = map
9327                                .next_value::<std::option::Option<
9328                                    std::vec::Vec<crate::model::CapacityQuantityInterval>,
9329                                >>()?
9330                                .unwrap_or_default();
9331                        }
9332                        __FieldTag::Unknown(key) => {
9333                            let value = map.next_value::<serde_json::Value>()?;
9334                            result._unknown_fields.insert(key, value);
9335                        }
9336                    }
9337                }
9338                std::result::Result::Ok(result)
9339            }
9340        }
9341        deserializer.deserialize_any(Visitor)
9342    }
9343}
9344
9345#[doc(hidden)]
9346impl serde::ser::Serialize for Vehicle {
9347    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9348    where
9349        S: serde::ser::Serializer,
9350    {
9351        use serde::ser::SerializeMap;
9352        #[allow(unused_imports)]
9353        use std::option::Option::Some;
9354        let mut state = serializer.serialize_map(std::option::Option::None)?;
9355        if !wkt::internal::is_default(&self.travel_mode) {
9356            state.serialize_entry("travelMode", &self.travel_mode)?;
9357        }
9358        if self.route_modifiers.is_some() {
9359            state.serialize_entry("routeModifiers", &self.route_modifiers)?;
9360        }
9361        if self.start_location.is_some() {
9362            state.serialize_entry("startLocation", &self.start_location)?;
9363        }
9364        if self.start_waypoint.is_some() {
9365            state.serialize_entry("startWaypoint", &self.start_waypoint)?;
9366        }
9367        if self.end_location.is_some() {
9368            state.serialize_entry("endLocation", &self.end_location)?;
9369        }
9370        if self.end_waypoint.is_some() {
9371            state.serialize_entry("endWaypoint", &self.end_waypoint)?;
9372        }
9373        if !self.start_tags.is_empty() {
9374            state.serialize_entry("startTags", &self.start_tags)?;
9375        }
9376        if !self.end_tags.is_empty() {
9377            state.serialize_entry("endTags", &self.end_tags)?;
9378        }
9379        if !self.start_time_windows.is_empty() {
9380            state.serialize_entry("startTimeWindows", &self.start_time_windows)?;
9381        }
9382        if !self.end_time_windows.is_empty() {
9383            state.serialize_entry("endTimeWindows", &self.end_time_windows)?;
9384        }
9385        if self.travel_duration_multiple.is_some() {
9386            struct __With<'a>(&'a std::option::Option<f64>);
9387            impl<'a> serde::ser::Serialize for __With<'a> {
9388                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9389                where
9390                    S: serde::ser::Serializer,
9391                {
9392                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
9393                        self.0, serializer,
9394                    )
9395                }
9396            }
9397            state.serialize_entry(
9398                "travelDurationMultiple",
9399                &__With(&self.travel_duration_multiple),
9400            )?;
9401        }
9402        if !wkt::internal::is_default(&self.unloading_policy) {
9403            state.serialize_entry("unloadingPolicy", &self.unloading_policy)?;
9404        }
9405        if !self.load_limits.is_empty() {
9406            state.serialize_entry("loadLimits", &self.load_limits)?;
9407        }
9408        if !wkt::internal::is_default(&self.cost_per_hour) {
9409            struct __With<'a>(&'a f64);
9410            impl<'a> serde::ser::Serialize for __With<'a> {
9411                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9412                where
9413                    S: serde::ser::Serializer,
9414                {
9415                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9416                }
9417            }
9418            state.serialize_entry("costPerHour", &__With(&self.cost_per_hour))?;
9419        }
9420        if !wkt::internal::is_default(&self.cost_per_traveled_hour) {
9421            struct __With<'a>(&'a f64);
9422            impl<'a> serde::ser::Serialize for __With<'a> {
9423                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9424                where
9425                    S: serde::ser::Serializer,
9426                {
9427                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9428                }
9429            }
9430            state.serialize_entry("costPerTraveledHour", &__With(&self.cost_per_traveled_hour))?;
9431        }
9432        if !wkt::internal::is_default(&self.cost_per_kilometer) {
9433            struct __With<'a>(&'a f64);
9434            impl<'a> serde::ser::Serialize for __With<'a> {
9435                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9436                where
9437                    S: serde::ser::Serializer,
9438                {
9439                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9440                }
9441            }
9442            state.serialize_entry("costPerKilometer", &__With(&self.cost_per_kilometer))?;
9443        }
9444        if !wkt::internal::is_default(&self.fixed_cost) {
9445            struct __With<'a>(&'a f64);
9446            impl<'a> serde::ser::Serialize for __With<'a> {
9447                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9448                where
9449                    S: serde::ser::Serializer,
9450                {
9451                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9452                }
9453            }
9454            state.serialize_entry("fixedCost", &__With(&self.fixed_cost))?;
9455        }
9456        if !wkt::internal::is_default(&self.used_if_route_is_empty) {
9457            state.serialize_entry("usedIfRouteIsEmpty", &self.used_if_route_is_empty)?;
9458        }
9459        if self.route_duration_limit.is_some() {
9460            state.serialize_entry("routeDurationLimit", &self.route_duration_limit)?;
9461        }
9462        if self.travel_duration_limit.is_some() {
9463            state.serialize_entry("travelDurationLimit", &self.travel_duration_limit)?;
9464        }
9465        if self.route_distance_limit.is_some() {
9466            state.serialize_entry("routeDistanceLimit", &self.route_distance_limit)?;
9467        }
9468        if !self.extra_visit_duration_for_visit_type.is_empty() {
9469            state.serialize_entry(
9470                "extraVisitDurationForVisitType",
9471                &self.extra_visit_duration_for_visit_type,
9472            )?;
9473        }
9474        if self.break_rule.is_some() {
9475            state.serialize_entry("breakRule", &self.break_rule)?;
9476        }
9477        if !self.label.is_empty() {
9478            state.serialize_entry("label", &self.label)?;
9479        }
9480        if !wkt::internal::is_default(&self.ignore) {
9481            state.serialize_entry("ignore", &self.ignore)?;
9482        }
9483        if !self.break_rule_indices.is_empty() {
9484            struct __With<'a>(&'a std::vec::Vec<i32>);
9485            impl<'a> serde::ser::Serialize for __With<'a> {
9486                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9487                where
9488                    S: serde::ser::Serializer,
9489                {
9490                    serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
9491                        self.0, serializer,
9492                    )
9493                }
9494            }
9495            state.serialize_entry("breakRuleIndices", &__With(&self.break_rule_indices))?;
9496        }
9497        if !self.capacities.is_empty() {
9498            state.serialize_entry("capacities", &self.capacities)?;
9499        }
9500        if !self.start_load_intervals.is_empty() {
9501            state.serialize_entry("startLoadIntervals", &self.start_load_intervals)?;
9502        }
9503        if !self.end_load_intervals.is_empty() {
9504            state.serialize_entry("endLoadIntervals", &self.end_load_intervals)?;
9505        }
9506        if !self._unknown_fields.is_empty() {
9507            for (key, value) in self._unknown_fields.iter() {
9508                state.serialize_entry(key, &value)?;
9509            }
9510        }
9511        state.end()
9512    }
9513}
9514
9515/// Defines additional types related to [Vehicle].
9516pub mod vehicle {
9517    #[allow(unused_imports)]
9518    use super::*;
9519
9520    /// Defines a load limit applying to a vehicle, e.g. "this truck may only
9521    /// carry up to 3500 kg". See
9522    /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
9523    ///
9524    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
9525    #[derive(Clone, Debug, Default, PartialEq)]
9526    #[non_exhaustive]
9527    pub struct LoadLimit {
9528        /// The maximum acceptable amount of load.
9529        pub max_load: std::option::Option<i64>,
9530
9531        /// A soft limit of the load. See
9532        /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
9533        ///
9534        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
9535        pub soft_max_load: i64,
9536
9537        /// If the load ever exceeds
9538        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
9539        /// along this vehicle's route, the following cost penalty applies (only once
9540        /// per vehicle): (load -
9541        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
9542        ///
9543        /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
9544        ///   add up and must be in the same unit as
9545        ///   [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
9546        ///
9547        /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
9548        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
9549        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
9550        pub cost_per_unit_above_soft_max: f64,
9551
9552        /// The acceptable load interval of the vehicle at the start of the route.
9553        pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
9554
9555        /// The acceptable load interval of the vehicle at the end of the route.
9556        pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
9557
9558        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9559    }
9560
9561    impl LoadLimit {
9562        pub fn new() -> Self {
9563            std::default::Default::default()
9564        }
9565
9566        /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
9567        pub fn set_max_load<T>(mut self, v: T) -> Self
9568        where
9569            T: std::convert::Into<i64>,
9570        {
9571            self.max_load = std::option::Option::Some(v.into());
9572            self
9573        }
9574
9575        /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
9576        pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
9577        where
9578            T: std::convert::Into<i64>,
9579        {
9580            self.max_load = v.map(|x| x.into());
9581            self
9582        }
9583
9584        /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
9585        pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9586            self.soft_max_load = v.into();
9587            self
9588        }
9589
9590        /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
9591        pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
9592            mut self,
9593            v: T,
9594        ) -> Self {
9595            self.cost_per_unit_above_soft_max = v.into();
9596            self
9597        }
9598
9599        /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
9600        pub fn set_start_load_interval<T>(mut self, v: T) -> Self
9601        where
9602            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
9603        {
9604            self.start_load_interval = std::option::Option::Some(v.into());
9605            self
9606        }
9607
9608        /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
9609        pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
9610        where
9611            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
9612        {
9613            self.start_load_interval = v.map(|x| x.into());
9614            self
9615        }
9616
9617        /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
9618        pub fn set_end_load_interval<T>(mut self, v: T) -> Self
9619        where
9620            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
9621        {
9622            self.end_load_interval = std::option::Option::Some(v.into());
9623            self
9624        }
9625
9626        /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
9627        pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
9628        where
9629            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
9630        {
9631            self.end_load_interval = v.map(|x| x.into());
9632            self
9633        }
9634    }
9635
9636    impl wkt::message::Message for LoadLimit {
9637        fn typename() -> &'static str {
9638            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
9639        }
9640    }
9641
9642    #[doc(hidden)]
9643    impl<'de> serde::de::Deserialize<'de> for LoadLimit {
9644        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9645        where
9646            D: serde::Deserializer<'de>,
9647        {
9648            #[allow(non_camel_case_types)]
9649            #[doc(hidden)]
9650            #[derive(PartialEq, Eq, Hash)]
9651            enum __FieldTag {
9652                __max_load,
9653                __soft_max_load,
9654                __cost_per_unit_above_soft_max,
9655                __start_load_interval,
9656                __end_load_interval,
9657                Unknown(std::string::String),
9658            }
9659            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9660                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9661                where
9662                    D: serde::Deserializer<'de>,
9663                {
9664                    struct Visitor;
9665                    impl<'de> serde::de::Visitor<'de> for Visitor {
9666                        type Value = __FieldTag;
9667                        fn expecting(
9668                            &self,
9669                            formatter: &mut std::fmt::Formatter,
9670                        ) -> std::fmt::Result {
9671                            formatter.write_str("a field name for LoadLimit")
9672                        }
9673                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
9674                        where
9675                            E: serde::de::Error,
9676                        {
9677                            use std::result::Result::Ok;
9678                            use std::string::ToString;
9679                            match value {
9680                                "maxLoad" => Ok(__FieldTag::__max_load),
9681                                "max_load" => Ok(__FieldTag::__max_load),
9682                                "softMaxLoad" => Ok(__FieldTag::__soft_max_load),
9683                                "soft_max_load" => Ok(__FieldTag::__soft_max_load),
9684                                "costPerUnitAboveSoftMax" => {
9685                                    Ok(__FieldTag::__cost_per_unit_above_soft_max)
9686                                }
9687                                "cost_per_unit_above_soft_max" => {
9688                                    Ok(__FieldTag::__cost_per_unit_above_soft_max)
9689                                }
9690                                "startLoadInterval" => Ok(__FieldTag::__start_load_interval),
9691                                "start_load_interval" => Ok(__FieldTag::__start_load_interval),
9692                                "endLoadInterval" => Ok(__FieldTag::__end_load_interval),
9693                                "end_load_interval" => Ok(__FieldTag::__end_load_interval),
9694                                _ => Ok(__FieldTag::Unknown(value.to_string())),
9695                            }
9696                        }
9697                    }
9698                    deserializer.deserialize_identifier(Visitor)
9699                }
9700            }
9701            struct Visitor;
9702            impl<'de> serde::de::Visitor<'de> for Visitor {
9703                type Value = LoadLimit;
9704                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9705                    formatter.write_str("struct LoadLimit")
9706                }
9707                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9708                where
9709                    A: serde::de::MapAccess<'de>,
9710                {
9711                    #[allow(unused_imports)]
9712                    use serde::de::Error;
9713                    use std::option::Option::Some;
9714                    let mut fields = std::collections::HashSet::new();
9715                    let mut result = Self::Value::new();
9716                    while let Some(tag) = map.next_key::<__FieldTag>()? {
9717                        #[allow(clippy::match_single_binding)]
9718                        match tag {
9719                            __FieldTag::__max_load => {
9720                                if !fields.insert(__FieldTag::__max_load) {
9721                                    return std::result::Result::Err(A::Error::duplicate_field(
9722                                        "multiple values for max_load",
9723                                    ));
9724                                }
9725                                struct __With(std::option::Option<i64>);
9726                                impl<'de> serde::de::Deserialize<'de> for __With {
9727                                    fn deserialize<D>(
9728                                        deserializer: D,
9729                                    ) -> std::result::Result<Self, D::Error>
9730                                    where
9731                                        D: serde::de::Deserializer<'de>,
9732                                    {
9733                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
9734                                    }
9735                                }
9736                                result.max_load = map.next_value::<__With>()?.0;
9737                            }
9738                            __FieldTag::__soft_max_load => {
9739                                if !fields.insert(__FieldTag::__soft_max_load) {
9740                                    return std::result::Result::Err(A::Error::duplicate_field(
9741                                        "multiple values for soft_max_load",
9742                                    ));
9743                                }
9744                                struct __With(std::option::Option<i64>);
9745                                impl<'de> serde::de::Deserialize<'de> for __With {
9746                                    fn deserialize<D>(
9747                                        deserializer: D,
9748                                    ) -> std::result::Result<Self, D::Error>
9749                                    where
9750                                        D: serde::de::Deserializer<'de>,
9751                                    {
9752                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
9753                                    }
9754                                }
9755                                result.soft_max_load =
9756                                    map.next_value::<__With>()?.0.unwrap_or_default();
9757                            }
9758                            __FieldTag::__cost_per_unit_above_soft_max => {
9759                                if !fields.insert(__FieldTag::__cost_per_unit_above_soft_max) {
9760                                    return std::result::Result::Err(A::Error::duplicate_field(
9761                                        "multiple values for cost_per_unit_above_soft_max",
9762                                    ));
9763                                }
9764                                struct __With(std::option::Option<f64>);
9765                                impl<'de> serde::de::Deserialize<'de> for __With {
9766                                    fn deserialize<D>(
9767                                        deserializer: D,
9768                                    ) -> std::result::Result<Self, D::Error>
9769                                    where
9770                                        D: serde::de::Deserializer<'de>,
9771                                    {
9772                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9773                                    }
9774                                }
9775                                result.cost_per_unit_above_soft_max =
9776                                    map.next_value::<__With>()?.0.unwrap_or_default();
9777                            }
9778                            __FieldTag::__start_load_interval => {
9779                                if !fields.insert(__FieldTag::__start_load_interval) {
9780                                    return std::result::Result::Err(A::Error::duplicate_field(
9781                                        "multiple values for start_load_interval",
9782                                    ));
9783                                }
9784                                result.start_load_interval = map
9785                                    .next_value::<std::option::Option<
9786                                        crate::model::vehicle::load_limit::Interval,
9787                                    >>()?;
9788                            }
9789                            __FieldTag::__end_load_interval => {
9790                                if !fields.insert(__FieldTag::__end_load_interval) {
9791                                    return std::result::Result::Err(A::Error::duplicate_field(
9792                                        "multiple values for end_load_interval",
9793                                    ));
9794                                }
9795                                result.end_load_interval = map
9796                                    .next_value::<std::option::Option<
9797                                        crate::model::vehicle::load_limit::Interval,
9798                                    >>()?;
9799                            }
9800                            __FieldTag::Unknown(key) => {
9801                                let value = map.next_value::<serde_json::Value>()?;
9802                                result._unknown_fields.insert(key, value);
9803                            }
9804                        }
9805                    }
9806                    std::result::Result::Ok(result)
9807                }
9808            }
9809            deserializer.deserialize_any(Visitor)
9810        }
9811    }
9812
9813    #[doc(hidden)]
9814    impl serde::ser::Serialize for LoadLimit {
9815        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9816        where
9817            S: serde::ser::Serializer,
9818        {
9819            use serde::ser::SerializeMap;
9820            #[allow(unused_imports)]
9821            use std::option::Option::Some;
9822            let mut state = serializer.serialize_map(std::option::Option::None)?;
9823            if self.max_load.is_some() {
9824                struct __With<'a>(&'a std::option::Option<i64>);
9825                impl<'a> serde::ser::Serialize for __With<'a> {
9826                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9827                    where
9828                        S: serde::ser::Serializer,
9829                    {
9830                        serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
9831                            self.0, serializer,
9832                        )
9833                    }
9834                }
9835                state.serialize_entry("maxLoad", &__With(&self.max_load))?;
9836            }
9837            if !wkt::internal::is_default(&self.soft_max_load) {
9838                struct __With<'a>(&'a i64);
9839                impl<'a> serde::ser::Serialize for __With<'a> {
9840                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9841                    where
9842                        S: serde::ser::Serializer,
9843                    {
9844                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
9845                    }
9846                }
9847                state.serialize_entry("softMaxLoad", &__With(&self.soft_max_load))?;
9848            }
9849            if !wkt::internal::is_default(&self.cost_per_unit_above_soft_max) {
9850                struct __With<'a>(&'a f64);
9851                impl<'a> serde::ser::Serialize for __With<'a> {
9852                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9853                    where
9854                        S: serde::ser::Serializer,
9855                    {
9856                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9857                    }
9858                }
9859                state.serialize_entry(
9860                    "costPerUnitAboveSoftMax",
9861                    &__With(&self.cost_per_unit_above_soft_max),
9862                )?;
9863            }
9864            if self.start_load_interval.is_some() {
9865                state.serialize_entry("startLoadInterval", &self.start_load_interval)?;
9866            }
9867            if self.end_load_interval.is_some() {
9868                state.serialize_entry("endLoadInterval", &self.end_load_interval)?;
9869            }
9870            if !self._unknown_fields.is_empty() {
9871                for (key, value) in self._unknown_fields.iter() {
9872                    state.serialize_entry(key, &value)?;
9873                }
9874            }
9875            state.end()
9876        }
9877    }
9878
9879    /// Defines additional types related to [LoadLimit].
9880    pub mod load_limit {
9881        #[allow(unused_imports)]
9882        use super::*;
9883
9884        /// Interval of acceptable load amounts.
9885        #[derive(Clone, Debug, Default, PartialEq)]
9886        #[non_exhaustive]
9887        pub struct Interval {
9888            /// A minimum acceptable load. Must be ≥ 0.
9889            /// If they're both specified,
9890            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
9891            /// be ≤
9892            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
9893            ///
9894            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
9895            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
9896            pub min: i64,
9897
9898            /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
9899            /// load is unrestricted by this message.
9900            /// If they're both specified,
9901            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
9902            /// be ≤
9903            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
9904            ///
9905            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
9906            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
9907            pub max: std::option::Option<i64>,
9908
9909            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9910        }
9911
9912        impl Interval {
9913            pub fn new() -> Self {
9914                std::default::Default::default()
9915            }
9916
9917            /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
9918            pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9919                self.min = v.into();
9920                self
9921            }
9922
9923            /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
9924            pub fn set_max<T>(mut self, v: T) -> Self
9925            where
9926                T: std::convert::Into<i64>,
9927            {
9928                self.max = std::option::Option::Some(v.into());
9929                self
9930            }
9931
9932            /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
9933            pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
9934            where
9935                T: std::convert::Into<i64>,
9936            {
9937                self.max = v.map(|x| x.into());
9938                self
9939            }
9940        }
9941
9942        impl wkt::message::Message for Interval {
9943            fn typename() -> &'static str {
9944                "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
9945            }
9946        }
9947
9948        #[doc(hidden)]
9949        impl<'de> serde::de::Deserialize<'de> for Interval {
9950            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9951            where
9952                D: serde::Deserializer<'de>,
9953            {
9954                #[allow(non_camel_case_types)]
9955                #[doc(hidden)]
9956                #[derive(PartialEq, Eq, Hash)]
9957                enum __FieldTag {
9958                    __min,
9959                    __max,
9960                    Unknown(std::string::String),
9961                }
9962                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9963                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9964                    where
9965                        D: serde::Deserializer<'de>,
9966                    {
9967                        struct Visitor;
9968                        impl<'de> serde::de::Visitor<'de> for Visitor {
9969                            type Value = __FieldTag;
9970                            fn expecting(
9971                                &self,
9972                                formatter: &mut std::fmt::Formatter,
9973                            ) -> std::fmt::Result {
9974                                formatter.write_str("a field name for Interval")
9975                            }
9976                            fn visit_str<E>(
9977                                self,
9978                                value: &str,
9979                            ) -> std::result::Result<Self::Value, E>
9980                            where
9981                                E: serde::de::Error,
9982                            {
9983                                use std::result::Result::Ok;
9984                                use std::string::ToString;
9985                                match value {
9986                                    "min" => Ok(__FieldTag::__min),
9987                                    "max" => Ok(__FieldTag::__max),
9988                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
9989                                }
9990                            }
9991                        }
9992                        deserializer.deserialize_identifier(Visitor)
9993                    }
9994                }
9995                struct Visitor;
9996                impl<'de> serde::de::Visitor<'de> for Visitor {
9997                    type Value = Interval;
9998                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9999                        formatter.write_str("struct Interval")
10000                    }
10001                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10002                    where
10003                        A: serde::de::MapAccess<'de>,
10004                    {
10005                        #[allow(unused_imports)]
10006                        use serde::de::Error;
10007                        use std::option::Option::Some;
10008                        let mut fields = std::collections::HashSet::new();
10009                        let mut result = Self::Value::new();
10010                        while let Some(tag) = map.next_key::<__FieldTag>()? {
10011                            #[allow(clippy::match_single_binding)]
10012                            match tag {
10013                                __FieldTag::__min => {
10014                                    if !fields.insert(__FieldTag::__min) {
10015                                        return std::result::Result::Err(
10016                                            A::Error::duplicate_field("multiple values for min"),
10017                                        );
10018                                    }
10019                                    struct __With(std::option::Option<i64>);
10020                                    impl<'de> serde::de::Deserialize<'de> for __With {
10021                                        fn deserialize<D>(
10022                                            deserializer: D,
10023                                        ) -> std::result::Result<Self, D::Error>
10024                                        where
10025                                            D: serde::de::Deserializer<'de>,
10026                                        {
10027                                            serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
10028                                        }
10029                                    }
10030                                    result.min = map.next_value::<__With>()?.0.unwrap_or_default();
10031                                }
10032                                __FieldTag::__max => {
10033                                    if !fields.insert(__FieldTag::__max) {
10034                                        return std::result::Result::Err(
10035                                            A::Error::duplicate_field("multiple values for max"),
10036                                        );
10037                                    }
10038                                    struct __With(std::option::Option<i64>);
10039                                    impl<'de> serde::de::Deserialize<'de> for __With {
10040                                        fn deserialize<D>(
10041                                            deserializer: D,
10042                                        ) -> std::result::Result<Self, D::Error>
10043                                        where
10044                                            D: serde::de::Deserializer<'de>,
10045                                        {
10046                                            serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
10047                                        }
10048                                    }
10049                                    result.max = map.next_value::<__With>()?.0;
10050                                }
10051                                __FieldTag::Unknown(key) => {
10052                                    let value = map.next_value::<serde_json::Value>()?;
10053                                    result._unknown_fields.insert(key, value);
10054                                }
10055                            }
10056                        }
10057                        std::result::Result::Ok(result)
10058                    }
10059                }
10060                deserializer.deserialize_any(Visitor)
10061            }
10062        }
10063
10064        #[doc(hidden)]
10065        impl serde::ser::Serialize for Interval {
10066            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10067            where
10068                S: serde::ser::Serializer,
10069            {
10070                use serde::ser::SerializeMap;
10071                #[allow(unused_imports)]
10072                use std::option::Option::Some;
10073                let mut state = serializer.serialize_map(std::option::Option::None)?;
10074                if !wkt::internal::is_default(&self.min) {
10075                    struct __With<'a>(&'a i64);
10076                    impl<'a> serde::ser::Serialize for __With<'a> {
10077                        fn serialize<S>(
10078                            &self,
10079                            serializer: S,
10080                        ) -> std::result::Result<S::Ok, S::Error>
10081                        where
10082                            S: serde::ser::Serializer,
10083                        {
10084                            serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
10085                        }
10086                    }
10087                    state.serialize_entry("min", &__With(&self.min))?;
10088                }
10089                if self.max.is_some() {
10090                    struct __With<'a>(&'a std::option::Option<i64>);
10091                    impl<'a> serde::ser::Serialize for __With<'a> {
10092                        fn serialize<S>(
10093                            &self,
10094                            serializer: S,
10095                        ) -> std::result::Result<S::Ok, S::Error>
10096                        where
10097                            S: serde::ser::Serializer,
10098                        {
10099                            serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
10100                                self.0, serializer,
10101                            )
10102                        }
10103                    }
10104                    state.serialize_entry("max", &__With(&self.max))?;
10105                }
10106                if !self._unknown_fields.is_empty() {
10107                    for (key, value) in self._unknown_fields.iter() {
10108                        state.serialize_entry(key, &value)?;
10109                    }
10110                }
10111                state.end()
10112            }
10113        }
10114    }
10115
10116    /// A limit defining a maximum duration of the route of a vehicle. It can be
10117    /// either hard or soft.
10118    ///
10119    /// When a soft limit field is defined, both the soft max threshold and its
10120    /// associated cost must be defined together.
10121    #[derive(Clone, Debug, Default, PartialEq)]
10122    #[non_exhaustive]
10123    pub struct DurationLimit {
10124        /// A hard limit constraining the duration to be at most max_duration.
10125        pub max_duration: std::option::Option<wkt::Duration>,
10126
10127        /// A soft limit not enforcing a maximum duration limit, but when violated
10128        /// makes the route incur a cost. This cost adds up to other costs defined in
10129        /// the model, with the same unit.
10130        ///
10131        /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
10132        /// also defined, `soft_max_duration` must be less than max_duration.
10133        pub soft_max_duration: std::option::Option<wkt::Duration>,
10134
10135        /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
10136        /// The additional cost is 0 if the duration is under the threshold,
10137        /// otherwise the cost depends on the duration as follows:
10138        ///
10139        /// ```norust
10140        ///   cost_per_hour_after_soft_max * (duration - soft_max_duration)
10141        /// ```
10142        ///
10143        /// The cost must be nonnegative.
10144        pub cost_per_hour_after_soft_max: std::option::Option<f64>,
10145
10146        /// A soft limit not enforcing a maximum duration limit, but when violated
10147        /// makes the route incur a cost, quadratic in the duration. This cost adds
10148        /// up to other costs defined in the model, with the same unit.
10149        ///
10150        /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
10151        /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
10152        /// less than `max_duration`, and the difference must be no larger than one
10153        /// day:
10154        ///
10155        /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
10156        pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
10157
10158        /// Cost per square hour incurred if the
10159        /// `quadratic_soft_max_duration` threshold is violated.
10160        ///
10161        /// The additional cost is 0 if the duration is under the threshold,
10162        /// otherwise the cost depends on the duration as follows:
10163        ///
10164        /// ```norust
10165        ///   cost_per_square_hour_after_quadratic_soft_max *
10166        ///   (duration - quadratic_soft_max_duration)^2
10167        /// ```
10168        ///
10169        /// The cost must be nonnegative.
10170        pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
10171
10172        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10173    }
10174
10175    impl DurationLimit {
10176        pub fn new() -> Self {
10177            std::default::Default::default()
10178        }
10179
10180        /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
10181        pub fn set_max_duration<T>(mut self, v: T) -> Self
10182        where
10183            T: std::convert::Into<wkt::Duration>,
10184        {
10185            self.max_duration = std::option::Option::Some(v.into());
10186            self
10187        }
10188
10189        /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
10190        pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
10191        where
10192            T: std::convert::Into<wkt::Duration>,
10193        {
10194            self.max_duration = v.map(|x| x.into());
10195            self
10196        }
10197
10198        /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
10199        pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
10200        where
10201            T: std::convert::Into<wkt::Duration>,
10202        {
10203            self.soft_max_duration = std::option::Option::Some(v.into());
10204            self
10205        }
10206
10207        /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
10208        pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
10209        where
10210            T: std::convert::Into<wkt::Duration>,
10211        {
10212            self.soft_max_duration = v.map(|x| x.into());
10213            self
10214        }
10215
10216        /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
10217        pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
10218        where
10219            T: std::convert::Into<f64>,
10220        {
10221            self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
10222            self
10223        }
10224
10225        /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
10226        pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
10227            mut self,
10228            v: std::option::Option<T>,
10229        ) -> Self
10230        where
10231            T: std::convert::Into<f64>,
10232        {
10233            self.cost_per_hour_after_soft_max = v.map(|x| x.into());
10234            self
10235        }
10236
10237        /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
10238        pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
10239        where
10240            T: std::convert::Into<wkt::Duration>,
10241        {
10242            self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
10243            self
10244        }
10245
10246        /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
10247        pub fn set_or_clear_quadratic_soft_max_duration<T>(
10248            mut self,
10249            v: std::option::Option<T>,
10250        ) -> Self
10251        where
10252            T: std::convert::Into<wkt::Duration>,
10253        {
10254            self.quadratic_soft_max_duration = v.map(|x| x.into());
10255            self
10256        }
10257
10258        /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
10259        pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
10260        where
10261            T: std::convert::Into<f64>,
10262        {
10263            self.cost_per_square_hour_after_quadratic_soft_max =
10264                std::option::Option::Some(v.into());
10265            self
10266        }
10267
10268        /// 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].
10269        pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
10270            mut self,
10271            v: std::option::Option<T>,
10272        ) -> Self
10273        where
10274            T: std::convert::Into<f64>,
10275        {
10276            self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
10277            self
10278        }
10279    }
10280
10281    impl wkt::message::Message for DurationLimit {
10282        fn typename() -> &'static str {
10283            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
10284        }
10285    }
10286
10287    #[doc(hidden)]
10288    impl<'de> serde::de::Deserialize<'de> for DurationLimit {
10289        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10290        where
10291            D: serde::Deserializer<'de>,
10292        {
10293            #[allow(non_camel_case_types)]
10294            #[doc(hidden)]
10295            #[derive(PartialEq, Eq, Hash)]
10296            enum __FieldTag {
10297                __max_duration,
10298                __soft_max_duration,
10299                __cost_per_hour_after_soft_max,
10300                __quadratic_soft_max_duration,
10301                __cost_per_square_hour_after_quadratic_soft_max,
10302                Unknown(std::string::String),
10303            }
10304            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10305                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10306                where
10307                    D: serde::Deserializer<'de>,
10308                {
10309                    struct Visitor;
10310                    impl<'de> serde::de::Visitor<'de> for Visitor {
10311                        type Value = __FieldTag;
10312                        fn expecting(
10313                            &self,
10314                            formatter: &mut std::fmt::Formatter,
10315                        ) -> std::fmt::Result {
10316                            formatter.write_str("a field name for DurationLimit")
10317                        }
10318                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10319                        where
10320                            E: serde::de::Error,
10321                        {
10322                            use std::result::Result::Ok;
10323                            use std::string::ToString;
10324                            match value {
10325                                "maxDuration" => Ok(__FieldTag::__max_duration),
10326                                "max_duration" => Ok(__FieldTag::__max_duration),
10327                                "softMaxDuration" => Ok(__FieldTag::__soft_max_duration),
10328                                "soft_max_duration" => Ok(__FieldTag::__soft_max_duration),
10329                                "costPerHourAfterSoftMax" => {
10330                                    Ok(__FieldTag::__cost_per_hour_after_soft_max)
10331                                }
10332                                "cost_per_hour_after_soft_max" => {
10333                                    Ok(__FieldTag::__cost_per_hour_after_soft_max)
10334                                }
10335                                "quadraticSoftMaxDuration" => {
10336                                    Ok(__FieldTag::__quadratic_soft_max_duration)
10337                                }
10338                                "quadratic_soft_max_duration" => {
10339                                    Ok(__FieldTag::__quadratic_soft_max_duration)
10340                                }
10341                                "costPerSquareHourAfterQuadraticSoftMax" => {
10342                                    Ok(__FieldTag::__cost_per_square_hour_after_quadratic_soft_max)
10343                                }
10344                                "cost_per_square_hour_after_quadratic_soft_max" => {
10345                                    Ok(__FieldTag::__cost_per_square_hour_after_quadratic_soft_max)
10346                                }
10347                                _ => Ok(__FieldTag::Unknown(value.to_string())),
10348                            }
10349                        }
10350                    }
10351                    deserializer.deserialize_identifier(Visitor)
10352                }
10353            }
10354            struct Visitor;
10355            impl<'de> serde::de::Visitor<'de> for Visitor {
10356                type Value = DurationLimit;
10357                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10358                    formatter.write_str("struct DurationLimit")
10359                }
10360                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10361                where
10362                    A: serde::de::MapAccess<'de>,
10363                {
10364                    #[allow(unused_imports)]
10365                    use serde::de::Error;
10366                    use std::option::Option::Some;
10367                    let mut fields = std::collections::HashSet::new();
10368                    let mut result = Self::Value::new();
10369                    while let Some(tag) = map.next_key::<__FieldTag>()? {
10370                        #[allow(clippy::match_single_binding)]
10371                        match tag {
10372                            __FieldTag::__max_duration => {
10373                                if !fields.insert(__FieldTag::__max_duration) {
10374                                    return std::result::Result::Err(A::Error::duplicate_field(
10375                                        "multiple values for max_duration",
10376                                    ));
10377                                }
10378                                result.max_duration =
10379                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
10380                            }
10381                            __FieldTag::__soft_max_duration => {
10382                                if !fields.insert(__FieldTag::__soft_max_duration) {
10383                                    return std::result::Result::Err(A::Error::duplicate_field(
10384                                        "multiple values for soft_max_duration",
10385                                    ));
10386                                }
10387                                result.soft_max_duration =
10388                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
10389                            }
10390                            __FieldTag::__cost_per_hour_after_soft_max => {
10391                                if !fields.insert(__FieldTag::__cost_per_hour_after_soft_max) {
10392                                    return std::result::Result::Err(A::Error::duplicate_field(
10393                                        "multiple values for cost_per_hour_after_soft_max",
10394                                    ));
10395                                }
10396                                struct __With(std::option::Option<f64>);
10397                                impl<'de> serde::de::Deserialize<'de> for __With {
10398                                    fn deserialize<D>(
10399                                        deserializer: D,
10400                                    ) -> std::result::Result<Self, D::Error>
10401                                    where
10402                                        D: serde::de::Deserializer<'de>,
10403                                    {
10404                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
10405                                    }
10406                                }
10407                                result.cost_per_hour_after_soft_max = map.next_value::<__With>()?.0;
10408                            }
10409                            __FieldTag::__quadratic_soft_max_duration => {
10410                                if !fields.insert(__FieldTag::__quadratic_soft_max_duration) {
10411                                    return std::result::Result::Err(A::Error::duplicate_field(
10412                                        "multiple values for quadratic_soft_max_duration",
10413                                    ));
10414                                }
10415                                result.quadratic_soft_max_duration =
10416                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
10417                            }
10418                            __FieldTag::__cost_per_square_hour_after_quadratic_soft_max => {
10419                                if !fields.insert(
10420                                    __FieldTag::__cost_per_square_hour_after_quadratic_soft_max,
10421                                ) {
10422                                    return std::result::Result::Err(A::Error::duplicate_field(
10423                                        "multiple values for cost_per_square_hour_after_quadratic_soft_max",
10424                                    ));
10425                                }
10426                                struct __With(std::option::Option<f64>);
10427                                impl<'de> serde::de::Deserialize<'de> for __With {
10428                                    fn deserialize<D>(
10429                                        deserializer: D,
10430                                    ) -> std::result::Result<Self, D::Error>
10431                                    where
10432                                        D: serde::de::Deserializer<'de>,
10433                                    {
10434                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
10435                                    }
10436                                }
10437                                result.cost_per_square_hour_after_quadratic_soft_max =
10438                                    map.next_value::<__With>()?.0;
10439                            }
10440                            __FieldTag::Unknown(key) => {
10441                                let value = map.next_value::<serde_json::Value>()?;
10442                                result._unknown_fields.insert(key, value);
10443                            }
10444                        }
10445                    }
10446                    std::result::Result::Ok(result)
10447                }
10448            }
10449            deserializer.deserialize_any(Visitor)
10450        }
10451    }
10452
10453    #[doc(hidden)]
10454    impl serde::ser::Serialize for DurationLimit {
10455        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10456        where
10457            S: serde::ser::Serializer,
10458        {
10459            use serde::ser::SerializeMap;
10460            #[allow(unused_imports)]
10461            use std::option::Option::Some;
10462            let mut state = serializer.serialize_map(std::option::Option::None)?;
10463            if self.max_duration.is_some() {
10464                state.serialize_entry("maxDuration", &self.max_duration)?;
10465            }
10466            if self.soft_max_duration.is_some() {
10467                state.serialize_entry("softMaxDuration", &self.soft_max_duration)?;
10468            }
10469            if self.cost_per_hour_after_soft_max.is_some() {
10470                struct __With<'a>(&'a std::option::Option<f64>);
10471                impl<'a> serde::ser::Serialize for __With<'a> {
10472                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10473                    where
10474                        S: serde::ser::Serializer,
10475                    {
10476                        serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
10477                            self.0, serializer,
10478                        )
10479                    }
10480                }
10481                state.serialize_entry(
10482                    "costPerHourAfterSoftMax",
10483                    &__With(&self.cost_per_hour_after_soft_max),
10484                )?;
10485            }
10486            if self.quadratic_soft_max_duration.is_some() {
10487                state.serialize_entry(
10488                    "quadraticSoftMaxDuration",
10489                    &self.quadratic_soft_max_duration,
10490                )?;
10491            }
10492            if self.cost_per_square_hour_after_quadratic_soft_max.is_some() {
10493                struct __With<'a>(&'a std::option::Option<f64>);
10494                impl<'a> serde::ser::Serialize for __With<'a> {
10495                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10496                    where
10497                        S: serde::ser::Serializer,
10498                    {
10499                        serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
10500                            self.0, serializer,
10501                        )
10502                    }
10503                }
10504                state.serialize_entry(
10505                    "costPerSquareHourAfterQuadraticSoftMax",
10506                    &__With(&self.cost_per_square_hour_after_quadratic_soft_max),
10507                )?;
10508            }
10509            if !self._unknown_fields.is_empty() {
10510                for (key, value) in self._unknown_fields.iter() {
10511                    state.serialize_entry(key, &value)?;
10512                }
10513            }
10514            state.end()
10515        }
10516    }
10517
10518    /// Travel modes which can be used by vehicles.
10519    ///
10520    /// These should be a subset of the Google Maps Platform Routes Preferred API
10521    /// travel modes, see:
10522    /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
10523    ///
10524    /// # Working with unknown values
10525    ///
10526    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10527    /// additional enum variants at any time. Adding new variants is not considered
10528    /// a breaking change. Applications should write their code in anticipation of:
10529    ///
10530    /// - New values appearing in future releases of the client library, **and**
10531    /// - New values received dynamically, without application changes.
10532    ///
10533    /// Please consult the [Working with enums] section in the user guide for some
10534    /// guidelines.
10535    ///
10536    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
10537    #[derive(Clone, Debug, PartialEq)]
10538    #[non_exhaustive]
10539    pub enum TravelMode {
10540        /// Unspecified travel mode, equivalent to `DRIVING`.
10541        Unspecified,
10542        /// Travel mode corresponding to driving directions (car, ...).
10543        Driving,
10544        /// Travel mode corresponding to walking directions.
10545        Walking,
10546        /// If set, the enum was initialized with an unknown value.
10547        ///
10548        /// Applications can examine the value using [TravelMode::value] or
10549        /// [TravelMode::name].
10550        UnknownValue(travel_mode::UnknownValue),
10551    }
10552
10553    #[doc(hidden)]
10554    pub mod travel_mode {
10555        #[allow(unused_imports)]
10556        use super::*;
10557        #[derive(Clone, Debug, PartialEq)]
10558        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10559    }
10560
10561    impl TravelMode {
10562        /// Gets the enum value.
10563        ///
10564        /// Returns `None` if the enum contains an unknown value deserialized from
10565        /// the string representation of enums.
10566        pub fn value(&self) -> std::option::Option<i32> {
10567            match self {
10568                Self::Unspecified => std::option::Option::Some(0),
10569                Self::Driving => std::option::Option::Some(1),
10570                Self::Walking => std::option::Option::Some(2),
10571                Self::UnknownValue(u) => u.0.value(),
10572            }
10573        }
10574
10575        /// Gets the enum value as a string.
10576        ///
10577        /// Returns `None` if the enum contains an unknown value deserialized from
10578        /// the integer representation of enums.
10579        pub fn name(&self) -> std::option::Option<&str> {
10580            match self {
10581                Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
10582                Self::Driving => std::option::Option::Some("DRIVING"),
10583                Self::Walking => std::option::Option::Some("WALKING"),
10584                Self::UnknownValue(u) => u.0.name(),
10585            }
10586        }
10587    }
10588
10589    impl std::default::Default for TravelMode {
10590        fn default() -> Self {
10591            use std::convert::From;
10592            Self::from(0)
10593        }
10594    }
10595
10596    impl std::fmt::Display for TravelMode {
10597        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10598            wkt::internal::display_enum(f, self.name(), self.value())
10599        }
10600    }
10601
10602    impl std::convert::From<i32> for TravelMode {
10603        fn from(value: i32) -> Self {
10604            match value {
10605                0 => Self::Unspecified,
10606                1 => Self::Driving,
10607                2 => Self::Walking,
10608                _ => Self::UnknownValue(travel_mode::UnknownValue(
10609                    wkt::internal::UnknownEnumValue::Integer(value),
10610                )),
10611            }
10612        }
10613    }
10614
10615    impl std::convert::From<&str> for TravelMode {
10616        fn from(value: &str) -> Self {
10617            use std::string::ToString;
10618            match value {
10619                "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
10620                "DRIVING" => Self::Driving,
10621                "WALKING" => Self::Walking,
10622                _ => Self::UnknownValue(travel_mode::UnknownValue(
10623                    wkt::internal::UnknownEnumValue::String(value.to_string()),
10624                )),
10625            }
10626        }
10627    }
10628
10629    impl serde::ser::Serialize for TravelMode {
10630        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10631        where
10632            S: serde::Serializer,
10633        {
10634            match self {
10635                Self::Unspecified => serializer.serialize_i32(0),
10636                Self::Driving => serializer.serialize_i32(1),
10637                Self::Walking => serializer.serialize_i32(2),
10638                Self::UnknownValue(u) => u.0.serialize(serializer),
10639            }
10640        }
10641    }
10642
10643    impl<'de> serde::de::Deserialize<'de> for TravelMode {
10644        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10645        where
10646            D: serde::Deserializer<'de>,
10647        {
10648            deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
10649                ".google.cloud.optimization.v1.Vehicle.TravelMode",
10650            ))
10651        }
10652    }
10653
10654    /// Policy on how a vehicle can be unloaded. Applies only to shipments having
10655    /// both a pickup and a delivery.
10656    ///
10657    /// Other shipments are free to occur anywhere on the route independent of
10658    /// `unloading_policy`.
10659    ///
10660    /// # Working with unknown values
10661    ///
10662    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10663    /// additional enum variants at any time. Adding new variants is not considered
10664    /// a breaking change. Applications should write their code in anticipation of:
10665    ///
10666    /// - New values appearing in future releases of the client library, **and**
10667    /// - New values received dynamically, without application changes.
10668    ///
10669    /// Please consult the [Working with enums] section in the user guide for some
10670    /// guidelines.
10671    ///
10672    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
10673    #[derive(Clone, Debug, PartialEq)]
10674    #[non_exhaustive]
10675    pub enum UnloadingPolicy {
10676        /// Unspecified unloading policy; deliveries must just occur after their
10677        /// corresponding pickups.
10678        Unspecified,
10679        /// Deliveries must occur in reverse order of pickups
10680        LastInFirstOut,
10681        /// Deliveries must occur in the same order as pickups
10682        FirstInFirstOut,
10683        /// If set, the enum was initialized with an unknown value.
10684        ///
10685        /// Applications can examine the value using [UnloadingPolicy::value] or
10686        /// [UnloadingPolicy::name].
10687        UnknownValue(unloading_policy::UnknownValue),
10688    }
10689
10690    #[doc(hidden)]
10691    pub mod unloading_policy {
10692        #[allow(unused_imports)]
10693        use super::*;
10694        #[derive(Clone, Debug, PartialEq)]
10695        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10696    }
10697
10698    impl UnloadingPolicy {
10699        /// Gets the enum value.
10700        ///
10701        /// Returns `None` if the enum contains an unknown value deserialized from
10702        /// the string representation of enums.
10703        pub fn value(&self) -> std::option::Option<i32> {
10704            match self {
10705                Self::Unspecified => std::option::Option::Some(0),
10706                Self::LastInFirstOut => std::option::Option::Some(1),
10707                Self::FirstInFirstOut => std::option::Option::Some(2),
10708                Self::UnknownValue(u) => u.0.value(),
10709            }
10710        }
10711
10712        /// Gets the enum value as a string.
10713        ///
10714        /// Returns `None` if the enum contains an unknown value deserialized from
10715        /// the integer representation of enums.
10716        pub fn name(&self) -> std::option::Option<&str> {
10717            match self {
10718                Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
10719                Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
10720                Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
10721                Self::UnknownValue(u) => u.0.name(),
10722            }
10723        }
10724    }
10725
10726    impl std::default::Default for UnloadingPolicy {
10727        fn default() -> Self {
10728            use std::convert::From;
10729            Self::from(0)
10730        }
10731    }
10732
10733    impl std::fmt::Display for UnloadingPolicy {
10734        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10735            wkt::internal::display_enum(f, self.name(), self.value())
10736        }
10737    }
10738
10739    impl std::convert::From<i32> for UnloadingPolicy {
10740        fn from(value: i32) -> Self {
10741            match value {
10742                0 => Self::Unspecified,
10743                1 => Self::LastInFirstOut,
10744                2 => Self::FirstInFirstOut,
10745                _ => Self::UnknownValue(unloading_policy::UnknownValue(
10746                    wkt::internal::UnknownEnumValue::Integer(value),
10747                )),
10748            }
10749        }
10750    }
10751
10752    impl std::convert::From<&str> for UnloadingPolicy {
10753        fn from(value: &str) -> Self {
10754            use std::string::ToString;
10755            match value {
10756                "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
10757                "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
10758                "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
10759                _ => Self::UnknownValue(unloading_policy::UnknownValue(
10760                    wkt::internal::UnknownEnumValue::String(value.to_string()),
10761                )),
10762            }
10763        }
10764    }
10765
10766    impl serde::ser::Serialize for UnloadingPolicy {
10767        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10768        where
10769            S: serde::Serializer,
10770        {
10771            match self {
10772                Self::Unspecified => serializer.serialize_i32(0),
10773                Self::LastInFirstOut => serializer.serialize_i32(1),
10774                Self::FirstInFirstOut => serializer.serialize_i32(2),
10775                Self::UnknownValue(u) => u.0.serialize(serializer),
10776            }
10777        }
10778    }
10779
10780    impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
10781        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10782        where
10783            D: serde::Deserializer<'de>,
10784        {
10785            deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
10786                ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
10787            ))
10788        }
10789    }
10790}
10791
10792/// Time windows constrain the time of an event, such as the arrival time at a
10793/// visit, or the start and end time of a vehicle.
10794///
10795/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
10796/// and latest time of the event, such that `start_time <= event_time <=
10797/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
10798/// preference for the event to happen at or after `soft_start_time` by incurring
10799/// a cost proportional to how long before soft_start_time the event occurs. The
10800/// soft time window upper bound, `soft_end_time`, expresses a preference for the
10801/// event to happen at or before `soft_end_time` by incurring a cost proportional
10802/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
10803/// `soft_start_time` and `soft_end_time` should be within the global time limits
10804/// (see
10805/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
10806/// and
10807/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
10808/// and should respect:
10809///
10810/// ```norust
10811///   0 <= `start_time` <= `soft_start_time` <= `end_time` and
10812///   0 <= `start_time` <= `soft_end_time` <= `end_time`.
10813/// ```
10814///
10815/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
10816/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
10817#[derive(Clone, Debug, Default, PartialEq)]
10818#[non_exhaustive]
10819pub struct TimeWindow {
10820    /// The hard time window start time. If unspecified it will be set to
10821    /// `ShipmentModel.global_start_time`.
10822    pub start_time: std::option::Option<wkt::Timestamp>,
10823
10824    /// The hard time window end time. If unspecified it will be set to
10825    /// `ShipmentModel.global_end_time`.
10826    pub end_time: std::option::Option<wkt::Timestamp>,
10827
10828    /// The soft start time of the time window.
10829    pub soft_start_time: std::option::Option<wkt::Timestamp>,
10830
10831    /// The soft end time of the time window.
10832    pub soft_end_time: std::option::Option<wkt::Timestamp>,
10833
10834    /// A cost per hour added to other costs in the model if the event occurs
10835    /// before soft_start_time, computed as:
10836    ///
10837    /// ```norust
10838    ///    max(0, soft_start_time - t.seconds)
10839    ///                           * cost_per_hour_before_soft_start_time / 3600,
10840    /// t being the time of the event.
10841    /// ```
10842    ///
10843    /// This cost must be positive, and the field can only be set if
10844    /// soft_start_time has been set.
10845    pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
10846
10847    /// A cost per hour added to other costs in the model if the event occurs after
10848    /// `soft_end_time`, computed as:
10849    ///
10850    /// ```norust
10851    ///    max(0, t.seconds - soft_end_time.seconds)
10852    ///                     * cost_per_hour_after_soft_end_time / 3600,
10853    /// t being the time of the event.
10854    /// ```
10855    ///
10856    /// This cost must be positive, and the field can only be set if
10857    /// `soft_end_time` has been set.
10858    pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
10859
10860    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10861}
10862
10863impl TimeWindow {
10864    pub fn new() -> Self {
10865        std::default::Default::default()
10866    }
10867
10868    /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
10869    pub fn set_start_time<T>(mut self, v: T) -> Self
10870    where
10871        T: std::convert::Into<wkt::Timestamp>,
10872    {
10873        self.start_time = std::option::Option::Some(v.into());
10874        self
10875    }
10876
10877    /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
10878    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
10879    where
10880        T: std::convert::Into<wkt::Timestamp>,
10881    {
10882        self.start_time = v.map(|x| x.into());
10883        self
10884    }
10885
10886    /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
10887    pub fn set_end_time<T>(mut self, v: T) -> Self
10888    where
10889        T: std::convert::Into<wkt::Timestamp>,
10890    {
10891        self.end_time = std::option::Option::Some(v.into());
10892        self
10893    }
10894
10895    /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
10896    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
10897    where
10898        T: std::convert::Into<wkt::Timestamp>,
10899    {
10900        self.end_time = v.map(|x| x.into());
10901        self
10902    }
10903
10904    /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
10905    pub fn set_soft_start_time<T>(mut self, v: T) -> Self
10906    where
10907        T: std::convert::Into<wkt::Timestamp>,
10908    {
10909        self.soft_start_time = std::option::Option::Some(v.into());
10910        self
10911    }
10912
10913    /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
10914    pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
10915    where
10916        T: std::convert::Into<wkt::Timestamp>,
10917    {
10918        self.soft_start_time = v.map(|x| x.into());
10919        self
10920    }
10921
10922    /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
10923    pub fn set_soft_end_time<T>(mut self, v: T) -> Self
10924    where
10925        T: std::convert::Into<wkt::Timestamp>,
10926    {
10927        self.soft_end_time = std::option::Option::Some(v.into());
10928        self
10929    }
10930
10931    /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
10932    pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
10933    where
10934        T: std::convert::Into<wkt::Timestamp>,
10935    {
10936        self.soft_end_time = v.map(|x| x.into());
10937        self
10938    }
10939
10940    /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
10941    pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
10942    where
10943        T: std::convert::Into<f64>,
10944    {
10945        self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
10946        self
10947    }
10948
10949    /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
10950    pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
10951        mut self,
10952        v: std::option::Option<T>,
10953    ) -> Self
10954    where
10955        T: std::convert::Into<f64>,
10956    {
10957        self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
10958        self
10959    }
10960
10961    /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
10962    pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
10963    where
10964        T: std::convert::Into<f64>,
10965    {
10966        self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
10967        self
10968    }
10969
10970    /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
10971    pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
10972        mut self,
10973        v: std::option::Option<T>,
10974    ) -> Self
10975    where
10976        T: std::convert::Into<f64>,
10977    {
10978        self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
10979        self
10980    }
10981}
10982
10983impl wkt::message::Message for TimeWindow {
10984    fn typename() -> &'static str {
10985        "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
10986    }
10987}
10988
10989#[doc(hidden)]
10990impl<'de> serde::de::Deserialize<'de> for TimeWindow {
10991    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10992    where
10993        D: serde::Deserializer<'de>,
10994    {
10995        #[allow(non_camel_case_types)]
10996        #[doc(hidden)]
10997        #[derive(PartialEq, Eq, Hash)]
10998        enum __FieldTag {
10999            __start_time,
11000            __end_time,
11001            __soft_start_time,
11002            __soft_end_time,
11003            __cost_per_hour_before_soft_start_time,
11004            __cost_per_hour_after_soft_end_time,
11005            Unknown(std::string::String),
11006        }
11007        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11008            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11009            where
11010                D: serde::Deserializer<'de>,
11011            {
11012                struct Visitor;
11013                impl<'de> serde::de::Visitor<'de> for Visitor {
11014                    type Value = __FieldTag;
11015                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11016                        formatter.write_str("a field name for TimeWindow")
11017                    }
11018                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11019                    where
11020                        E: serde::de::Error,
11021                    {
11022                        use std::result::Result::Ok;
11023                        use std::string::ToString;
11024                        match value {
11025                            "startTime" => Ok(__FieldTag::__start_time),
11026                            "start_time" => Ok(__FieldTag::__start_time),
11027                            "endTime" => Ok(__FieldTag::__end_time),
11028                            "end_time" => Ok(__FieldTag::__end_time),
11029                            "softStartTime" => Ok(__FieldTag::__soft_start_time),
11030                            "soft_start_time" => Ok(__FieldTag::__soft_start_time),
11031                            "softEndTime" => Ok(__FieldTag::__soft_end_time),
11032                            "soft_end_time" => Ok(__FieldTag::__soft_end_time),
11033                            "costPerHourBeforeSoftStartTime" => {
11034                                Ok(__FieldTag::__cost_per_hour_before_soft_start_time)
11035                            }
11036                            "cost_per_hour_before_soft_start_time" => {
11037                                Ok(__FieldTag::__cost_per_hour_before_soft_start_time)
11038                            }
11039                            "costPerHourAfterSoftEndTime" => {
11040                                Ok(__FieldTag::__cost_per_hour_after_soft_end_time)
11041                            }
11042                            "cost_per_hour_after_soft_end_time" => {
11043                                Ok(__FieldTag::__cost_per_hour_after_soft_end_time)
11044                            }
11045                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11046                        }
11047                    }
11048                }
11049                deserializer.deserialize_identifier(Visitor)
11050            }
11051        }
11052        struct Visitor;
11053        impl<'de> serde::de::Visitor<'de> for Visitor {
11054            type Value = TimeWindow;
11055            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11056                formatter.write_str("struct TimeWindow")
11057            }
11058            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11059            where
11060                A: serde::de::MapAccess<'de>,
11061            {
11062                #[allow(unused_imports)]
11063                use serde::de::Error;
11064                use std::option::Option::Some;
11065                let mut fields = std::collections::HashSet::new();
11066                let mut result = Self::Value::new();
11067                while let Some(tag) = map.next_key::<__FieldTag>()? {
11068                    #[allow(clippy::match_single_binding)]
11069                    match tag {
11070                        __FieldTag::__start_time => {
11071                            if !fields.insert(__FieldTag::__start_time) {
11072                                return std::result::Result::Err(A::Error::duplicate_field(
11073                                    "multiple values for start_time",
11074                                ));
11075                            }
11076                            result.start_time =
11077                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11078                        }
11079                        __FieldTag::__end_time => {
11080                            if !fields.insert(__FieldTag::__end_time) {
11081                                return std::result::Result::Err(A::Error::duplicate_field(
11082                                    "multiple values for end_time",
11083                                ));
11084                            }
11085                            result.end_time =
11086                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11087                        }
11088                        __FieldTag::__soft_start_time => {
11089                            if !fields.insert(__FieldTag::__soft_start_time) {
11090                                return std::result::Result::Err(A::Error::duplicate_field(
11091                                    "multiple values for soft_start_time",
11092                                ));
11093                            }
11094                            result.soft_start_time =
11095                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11096                        }
11097                        __FieldTag::__soft_end_time => {
11098                            if !fields.insert(__FieldTag::__soft_end_time) {
11099                                return std::result::Result::Err(A::Error::duplicate_field(
11100                                    "multiple values for soft_end_time",
11101                                ));
11102                            }
11103                            result.soft_end_time =
11104                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11105                        }
11106                        __FieldTag::__cost_per_hour_before_soft_start_time => {
11107                            if !fields.insert(__FieldTag::__cost_per_hour_before_soft_start_time) {
11108                                return std::result::Result::Err(A::Error::duplicate_field(
11109                                    "multiple values for cost_per_hour_before_soft_start_time",
11110                                ));
11111                            }
11112                            struct __With(std::option::Option<f64>);
11113                            impl<'de> serde::de::Deserialize<'de> for __With {
11114                                fn deserialize<D>(
11115                                    deserializer: D,
11116                                ) -> std::result::Result<Self, D::Error>
11117                                where
11118                                    D: serde::de::Deserializer<'de>,
11119                                {
11120                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11121                                }
11122                            }
11123                            result.cost_per_hour_before_soft_start_time =
11124                                map.next_value::<__With>()?.0;
11125                        }
11126                        __FieldTag::__cost_per_hour_after_soft_end_time => {
11127                            if !fields.insert(__FieldTag::__cost_per_hour_after_soft_end_time) {
11128                                return std::result::Result::Err(A::Error::duplicate_field(
11129                                    "multiple values for cost_per_hour_after_soft_end_time",
11130                                ));
11131                            }
11132                            struct __With(std::option::Option<f64>);
11133                            impl<'de> serde::de::Deserialize<'de> for __With {
11134                                fn deserialize<D>(
11135                                    deserializer: D,
11136                                ) -> std::result::Result<Self, D::Error>
11137                                where
11138                                    D: serde::de::Deserializer<'de>,
11139                                {
11140                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11141                                }
11142                            }
11143                            result.cost_per_hour_after_soft_end_time =
11144                                map.next_value::<__With>()?.0;
11145                        }
11146                        __FieldTag::Unknown(key) => {
11147                            let value = map.next_value::<serde_json::Value>()?;
11148                            result._unknown_fields.insert(key, value);
11149                        }
11150                    }
11151                }
11152                std::result::Result::Ok(result)
11153            }
11154        }
11155        deserializer.deserialize_any(Visitor)
11156    }
11157}
11158
11159#[doc(hidden)]
11160impl serde::ser::Serialize for TimeWindow {
11161    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11162    where
11163        S: serde::ser::Serializer,
11164    {
11165        use serde::ser::SerializeMap;
11166        #[allow(unused_imports)]
11167        use std::option::Option::Some;
11168        let mut state = serializer.serialize_map(std::option::Option::None)?;
11169        if self.start_time.is_some() {
11170            state.serialize_entry("startTime", &self.start_time)?;
11171        }
11172        if self.end_time.is_some() {
11173            state.serialize_entry("endTime", &self.end_time)?;
11174        }
11175        if self.soft_start_time.is_some() {
11176            state.serialize_entry("softStartTime", &self.soft_start_time)?;
11177        }
11178        if self.soft_end_time.is_some() {
11179            state.serialize_entry("softEndTime", &self.soft_end_time)?;
11180        }
11181        if self.cost_per_hour_before_soft_start_time.is_some() {
11182            struct __With<'a>(&'a std::option::Option<f64>);
11183            impl<'a> serde::ser::Serialize for __With<'a> {
11184                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11185                where
11186                    S: serde::ser::Serializer,
11187                {
11188                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
11189                        self.0, serializer,
11190                    )
11191                }
11192            }
11193            state.serialize_entry(
11194                "costPerHourBeforeSoftStartTime",
11195                &__With(&self.cost_per_hour_before_soft_start_time),
11196            )?;
11197        }
11198        if self.cost_per_hour_after_soft_end_time.is_some() {
11199            struct __With<'a>(&'a std::option::Option<f64>);
11200            impl<'a> serde::ser::Serialize for __With<'a> {
11201                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11202                where
11203                    S: serde::ser::Serializer,
11204                {
11205                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
11206                        self.0, serializer,
11207                    )
11208                }
11209            }
11210            state.serialize_entry(
11211                "costPerHourAfterSoftEndTime",
11212                &__With(&self.cost_per_hour_after_soft_end_time),
11213            )?;
11214        }
11215        if !self._unknown_fields.is_empty() {
11216            for (key, value) in self._unknown_fields.iter() {
11217                state.serialize_entry(key, &value)?;
11218            }
11219        }
11220        state.end()
11221    }
11222}
11223
11224/// Deprecated: Use
11225/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
11226/// instead.
11227///
11228/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
11229#[derive(Clone, Debug, Default, PartialEq)]
11230#[non_exhaustive]
11231#[deprecated]
11232pub struct CapacityQuantity {
11233    pub r#type: std::string::String,
11234
11235    pub value: i64,
11236
11237    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11238}
11239
11240impl CapacityQuantity {
11241    pub fn new() -> Self {
11242        std::default::Default::default()
11243    }
11244
11245    /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
11246    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11247        self.r#type = v.into();
11248        self
11249    }
11250
11251    /// Sets the value of [value][crate::model::CapacityQuantity::value].
11252    pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
11253        self.value = v.into();
11254        self
11255    }
11256}
11257
11258impl wkt::message::Message for CapacityQuantity {
11259    fn typename() -> &'static str {
11260        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
11261    }
11262}
11263
11264#[doc(hidden)]
11265impl<'de> serde::de::Deserialize<'de> for CapacityQuantity {
11266    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11267    where
11268        D: serde::Deserializer<'de>,
11269    {
11270        #[allow(non_camel_case_types)]
11271        #[doc(hidden)]
11272        #[derive(PartialEq, Eq, Hash)]
11273        enum __FieldTag {
11274            __type,
11275            __value,
11276            Unknown(std::string::String),
11277        }
11278        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11279            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11280            where
11281                D: serde::Deserializer<'de>,
11282            {
11283                struct Visitor;
11284                impl<'de> serde::de::Visitor<'de> for Visitor {
11285                    type Value = __FieldTag;
11286                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11287                        formatter.write_str("a field name for CapacityQuantity")
11288                    }
11289                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11290                    where
11291                        E: serde::de::Error,
11292                    {
11293                        use std::result::Result::Ok;
11294                        use std::string::ToString;
11295                        match value {
11296                            "type" => Ok(__FieldTag::__type),
11297                            "value" => Ok(__FieldTag::__value),
11298                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11299                        }
11300                    }
11301                }
11302                deserializer.deserialize_identifier(Visitor)
11303            }
11304        }
11305        struct Visitor;
11306        impl<'de> serde::de::Visitor<'de> for Visitor {
11307            type Value = CapacityQuantity;
11308            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11309                formatter.write_str("struct CapacityQuantity")
11310            }
11311            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11312            where
11313                A: serde::de::MapAccess<'de>,
11314            {
11315                #[allow(unused_imports)]
11316                use serde::de::Error;
11317                use std::option::Option::Some;
11318                let mut fields = std::collections::HashSet::new();
11319                let mut result = Self::Value::new();
11320                while let Some(tag) = map.next_key::<__FieldTag>()? {
11321                    #[allow(clippy::match_single_binding)]
11322                    match tag {
11323                        __FieldTag::__type => {
11324                            if !fields.insert(__FieldTag::__type) {
11325                                return std::result::Result::Err(A::Error::duplicate_field(
11326                                    "multiple values for type",
11327                                ));
11328                            }
11329                            result.r#type = map
11330                                .next_value::<std::option::Option<std::string::String>>()?
11331                                .unwrap_or_default();
11332                        }
11333                        __FieldTag::__value => {
11334                            if !fields.insert(__FieldTag::__value) {
11335                                return std::result::Result::Err(A::Error::duplicate_field(
11336                                    "multiple values for value",
11337                                ));
11338                            }
11339                            struct __With(std::option::Option<i64>);
11340                            impl<'de> serde::de::Deserialize<'de> for __With {
11341                                fn deserialize<D>(
11342                                    deserializer: D,
11343                                ) -> std::result::Result<Self, D::Error>
11344                                where
11345                                    D: serde::de::Deserializer<'de>,
11346                                {
11347                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11348                                }
11349                            }
11350                            result.value = map.next_value::<__With>()?.0.unwrap_or_default();
11351                        }
11352                        __FieldTag::Unknown(key) => {
11353                            let value = map.next_value::<serde_json::Value>()?;
11354                            result._unknown_fields.insert(key, value);
11355                        }
11356                    }
11357                }
11358                std::result::Result::Ok(result)
11359            }
11360        }
11361        deserializer.deserialize_any(Visitor)
11362    }
11363}
11364
11365#[doc(hidden)]
11366impl serde::ser::Serialize for CapacityQuantity {
11367    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11368    where
11369        S: serde::ser::Serializer,
11370    {
11371        use serde::ser::SerializeMap;
11372        #[allow(unused_imports)]
11373        use std::option::Option::Some;
11374        let mut state = serializer.serialize_map(std::option::Option::None)?;
11375        if !self.r#type.is_empty() {
11376            state.serialize_entry("type", &self.r#type)?;
11377        }
11378        if !wkt::internal::is_default(&self.value) {
11379            struct __With<'a>(&'a i64);
11380            impl<'a> serde::ser::Serialize for __With<'a> {
11381                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11382                where
11383                    S: serde::ser::Serializer,
11384                {
11385                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
11386                }
11387            }
11388            state.serialize_entry("value", &__With(&self.value))?;
11389        }
11390        if !self._unknown_fields.is_empty() {
11391            for (key, value) in self._unknown_fields.iter() {
11392                state.serialize_entry(key, &value)?;
11393            }
11394        }
11395        state.end()
11396    }
11397}
11398
11399/// Deprecated: Use
11400/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
11401/// instead.
11402///
11403/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
11404#[derive(Clone, Debug, Default, PartialEq)]
11405#[non_exhaustive]
11406#[deprecated]
11407pub struct CapacityQuantityInterval {
11408    pub r#type: std::string::String,
11409
11410    pub min_value: std::option::Option<i64>,
11411
11412    pub max_value: std::option::Option<i64>,
11413
11414    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11415}
11416
11417impl CapacityQuantityInterval {
11418    pub fn new() -> Self {
11419        std::default::Default::default()
11420    }
11421
11422    /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
11423    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11424        self.r#type = v.into();
11425        self
11426    }
11427
11428    /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
11429    pub fn set_min_value<T>(mut self, v: T) -> Self
11430    where
11431        T: std::convert::Into<i64>,
11432    {
11433        self.min_value = std::option::Option::Some(v.into());
11434        self
11435    }
11436
11437    /// Sets or clears the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
11438    pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
11439    where
11440        T: std::convert::Into<i64>,
11441    {
11442        self.min_value = v.map(|x| x.into());
11443        self
11444    }
11445
11446    /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
11447    pub fn set_max_value<T>(mut self, v: T) -> Self
11448    where
11449        T: std::convert::Into<i64>,
11450    {
11451        self.max_value = std::option::Option::Some(v.into());
11452        self
11453    }
11454
11455    /// Sets or clears the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
11456    pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
11457    where
11458        T: std::convert::Into<i64>,
11459    {
11460        self.max_value = v.map(|x| x.into());
11461        self
11462    }
11463}
11464
11465impl wkt::message::Message for CapacityQuantityInterval {
11466    fn typename() -> &'static str {
11467        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
11468    }
11469}
11470
11471#[doc(hidden)]
11472impl<'de> serde::de::Deserialize<'de> for CapacityQuantityInterval {
11473    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11474    where
11475        D: serde::Deserializer<'de>,
11476    {
11477        #[allow(non_camel_case_types)]
11478        #[doc(hidden)]
11479        #[derive(PartialEq, Eq, Hash)]
11480        enum __FieldTag {
11481            __type,
11482            __min_value,
11483            __max_value,
11484            Unknown(std::string::String),
11485        }
11486        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11487            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11488            where
11489                D: serde::Deserializer<'de>,
11490            {
11491                struct Visitor;
11492                impl<'de> serde::de::Visitor<'de> for Visitor {
11493                    type Value = __FieldTag;
11494                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11495                        formatter.write_str("a field name for CapacityQuantityInterval")
11496                    }
11497                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11498                    where
11499                        E: serde::de::Error,
11500                    {
11501                        use std::result::Result::Ok;
11502                        use std::string::ToString;
11503                        match value {
11504                            "type" => Ok(__FieldTag::__type),
11505                            "minValue" => Ok(__FieldTag::__min_value),
11506                            "min_value" => Ok(__FieldTag::__min_value),
11507                            "maxValue" => Ok(__FieldTag::__max_value),
11508                            "max_value" => Ok(__FieldTag::__max_value),
11509                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11510                        }
11511                    }
11512                }
11513                deserializer.deserialize_identifier(Visitor)
11514            }
11515        }
11516        struct Visitor;
11517        impl<'de> serde::de::Visitor<'de> for Visitor {
11518            type Value = CapacityQuantityInterval;
11519            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11520                formatter.write_str("struct CapacityQuantityInterval")
11521            }
11522            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11523            where
11524                A: serde::de::MapAccess<'de>,
11525            {
11526                #[allow(unused_imports)]
11527                use serde::de::Error;
11528                use std::option::Option::Some;
11529                let mut fields = std::collections::HashSet::new();
11530                let mut result = Self::Value::new();
11531                while let Some(tag) = map.next_key::<__FieldTag>()? {
11532                    #[allow(clippy::match_single_binding)]
11533                    match tag {
11534                        __FieldTag::__type => {
11535                            if !fields.insert(__FieldTag::__type) {
11536                                return std::result::Result::Err(A::Error::duplicate_field(
11537                                    "multiple values for type",
11538                                ));
11539                            }
11540                            result.r#type = map
11541                                .next_value::<std::option::Option<std::string::String>>()?
11542                                .unwrap_or_default();
11543                        }
11544                        __FieldTag::__min_value => {
11545                            if !fields.insert(__FieldTag::__min_value) {
11546                                return std::result::Result::Err(A::Error::duplicate_field(
11547                                    "multiple values for min_value",
11548                                ));
11549                            }
11550                            struct __With(std::option::Option<i64>);
11551                            impl<'de> serde::de::Deserialize<'de> for __With {
11552                                fn deserialize<D>(
11553                                    deserializer: D,
11554                                ) -> std::result::Result<Self, D::Error>
11555                                where
11556                                    D: serde::de::Deserializer<'de>,
11557                                {
11558                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11559                                }
11560                            }
11561                            result.min_value = map.next_value::<__With>()?.0;
11562                        }
11563                        __FieldTag::__max_value => {
11564                            if !fields.insert(__FieldTag::__max_value) {
11565                                return std::result::Result::Err(A::Error::duplicate_field(
11566                                    "multiple values for max_value",
11567                                ));
11568                            }
11569                            struct __With(std::option::Option<i64>);
11570                            impl<'de> serde::de::Deserialize<'de> for __With {
11571                                fn deserialize<D>(
11572                                    deserializer: D,
11573                                ) -> std::result::Result<Self, D::Error>
11574                                where
11575                                    D: serde::de::Deserializer<'de>,
11576                                {
11577                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11578                                }
11579                            }
11580                            result.max_value = map.next_value::<__With>()?.0;
11581                        }
11582                        __FieldTag::Unknown(key) => {
11583                            let value = map.next_value::<serde_json::Value>()?;
11584                            result._unknown_fields.insert(key, value);
11585                        }
11586                    }
11587                }
11588                std::result::Result::Ok(result)
11589            }
11590        }
11591        deserializer.deserialize_any(Visitor)
11592    }
11593}
11594
11595#[doc(hidden)]
11596impl serde::ser::Serialize for CapacityQuantityInterval {
11597    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11598    where
11599        S: serde::ser::Serializer,
11600    {
11601        use serde::ser::SerializeMap;
11602        #[allow(unused_imports)]
11603        use std::option::Option::Some;
11604        let mut state = serializer.serialize_map(std::option::Option::None)?;
11605        if !self.r#type.is_empty() {
11606            state.serialize_entry("type", &self.r#type)?;
11607        }
11608        if self.min_value.is_some() {
11609            struct __With<'a>(&'a std::option::Option<i64>);
11610            impl<'a> serde::ser::Serialize for __With<'a> {
11611                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11612                where
11613                    S: serde::ser::Serializer,
11614                {
11615                    serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
11616                        self.0, serializer,
11617                    )
11618                }
11619            }
11620            state.serialize_entry("minValue", &__With(&self.min_value))?;
11621        }
11622        if self.max_value.is_some() {
11623            struct __With<'a>(&'a std::option::Option<i64>);
11624            impl<'a> serde::ser::Serialize for __With<'a> {
11625                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11626                where
11627                    S: serde::ser::Serializer,
11628                {
11629                    serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
11630                        self.0, serializer,
11631                    )
11632                }
11633            }
11634            state.serialize_entry("maxValue", &__With(&self.max_value))?;
11635        }
11636        if !self._unknown_fields.is_empty() {
11637            for (key, value) in self._unknown_fields.iter() {
11638                state.serialize_entry(key, &value)?;
11639            }
11640        }
11641        state.end()
11642    }
11643}
11644
11645/// A limit defining a maximum distance which can be traveled. It can be either
11646/// hard or soft.
11647///
11648/// If a soft limit is defined, both `soft_max_meters` and
11649/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
11650#[derive(Clone, Debug, Default, PartialEq)]
11651#[non_exhaustive]
11652pub struct DistanceLimit {
11653    /// A hard limit constraining the distance to be at most max_meters. The limit
11654    /// must be nonnegative.
11655    pub max_meters: std::option::Option<i64>,
11656
11657    /// A soft limit not enforcing a maximum distance limit, but when violated
11658    /// results in a cost which adds up to other costs defined in the model,
11659    /// with the same unit.
11660    ///
11661    /// If defined soft_max_meters must be less than max_meters and must be
11662    /// nonnegative.
11663    pub soft_max_meters: std::option::Option<i64>,
11664
11665    /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
11666    /// formula:
11667    ///
11668    /// ```norust
11669    ///   min(distance_meters, soft_max_meters) / 1000.0 *
11670    ///   cost_per_kilometer_below_soft_max.
11671    /// ```
11672    ///
11673    /// This cost is not supported in `route_distance_limit`.
11674    pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
11675
11676    /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
11677    /// The additional cost is 0 if the distance is under the limit, otherwise the
11678    /// formula used to compute the cost is the following:
11679    ///
11680    /// ```norust
11681    ///   (distance_meters - soft_max_meters) / 1000.0 *
11682    ///   cost_per_kilometer_above_soft_max.
11683    /// ```
11684    ///
11685    /// The cost must be nonnegative.
11686    pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
11687
11688    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11689}
11690
11691impl DistanceLimit {
11692    pub fn new() -> Self {
11693        std::default::Default::default()
11694    }
11695
11696    /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
11697    pub fn set_max_meters<T>(mut self, v: T) -> Self
11698    where
11699        T: std::convert::Into<i64>,
11700    {
11701        self.max_meters = std::option::Option::Some(v.into());
11702        self
11703    }
11704
11705    /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
11706    pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
11707    where
11708        T: std::convert::Into<i64>,
11709    {
11710        self.max_meters = v.map(|x| x.into());
11711        self
11712    }
11713
11714    /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
11715    pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
11716    where
11717        T: std::convert::Into<i64>,
11718    {
11719        self.soft_max_meters = std::option::Option::Some(v.into());
11720        self
11721    }
11722
11723    /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
11724    pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
11725    where
11726        T: std::convert::Into<i64>,
11727    {
11728        self.soft_max_meters = v.map(|x| x.into());
11729        self
11730    }
11731
11732    /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
11733    pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
11734    where
11735        T: std::convert::Into<f64>,
11736    {
11737        self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
11738        self
11739    }
11740
11741    /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
11742    pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
11743        mut self,
11744        v: std::option::Option<T>,
11745    ) -> Self
11746    where
11747        T: std::convert::Into<f64>,
11748    {
11749        self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
11750        self
11751    }
11752
11753    /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
11754    pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
11755    where
11756        T: std::convert::Into<f64>,
11757    {
11758        self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
11759        self
11760    }
11761
11762    /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
11763    pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
11764        mut self,
11765        v: std::option::Option<T>,
11766    ) -> Self
11767    where
11768        T: std::convert::Into<f64>,
11769    {
11770        self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
11771        self
11772    }
11773}
11774
11775impl wkt::message::Message for DistanceLimit {
11776    fn typename() -> &'static str {
11777        "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
11778    }
11779}
11780
11781#[doc(hidden)]
11782impl<'de> serde::de::Deserialize<'de> for DistanceLimit {
11783    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11784    where
11785        D: serde::Deserializer<'de>,
11786    {
11787        #[allow(non_camel_case_types)]
11788        #[doc(hidden)]
11789        #[derive(PartialEq, Eq, Hash)]
11790        enum __FieldTag {
11791            __max_meters,
11792            __soft_max_meters,
11793            __cost_per_kilometer_below_soft_max,
11794            __cost_per_kilometer_above_soft_max,
11795            Unknown(std::string::String),
11796        }
11797        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11798            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11799            where
11800                D: serde::Deserializer<'de>,
11801            {
11802                struct Visitor;
11803                impl<'de> serde::de::Visitor<'de> for Visitor {
11804                    type Value = __FieldTag;
11805                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11806                        formatter.write_str("a field name for DistanceLimit")
11807                    }
11808                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11809                    where
11810                        E: serde::de::Error,
11811                    {
11812                        use std::result::Result::Ok;
11813                        use std::string::ToString;
11814                        match value {
11815                            "maxMeters" => Ok(__FieldTag::__max_meters),
11816                            "max_meters" => Ok(__FieldTag::__max_meters),
11817                            "softMaxMeters" => Ok(__FieldTag::__soft_max_meters),
11818                            "soft_max_meters" => Ok(__FieldTag::__soft_max_meters),
11819                            "costPerKilometerBelowSoftMax" => {
11820                                Ok(__FieldTag::__cost_per_kilometer_below_soft_max)
11821                            }
11822                            "cost_per_kilometer_below_soft_max" => {
11823                                Ok(__FieldTag::__cost_per_kilometer_below_soft_max)
11824                            }
11825                            "costPerKilometerAboveSoftMax" => {
11826                                Ok(__FieldTag::__cost_per_kilometer_above_soft_max)
11827                            }
11828                            "cost_per_kilometer_above_soft_max" => {
11829                                Ok(__FieldTag::__cost_per_kilometer_above_soft_max)
11830                            }
11831                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11832                        }
11833                    }
11834                }
11835                deserializer.deserialize_identifier(Visitor)
11836            }
11837        }
11838        struct Visitor;
11839        impl<'de> serde::de::Visitor<'de> for Visitor {
11840            type Value = DistanceLimit;
11841            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11842                formatter.write_str("struct DistanceLimit")
11843            }
11844            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11845            where
11846                A: serde::de::MapAccess<'de>,
11847            {
11848                #[allow(unused_imports)]
11849                use serde::de::Error;
11850                use std::option::Option::Some;
11851                let mut fields = std::collections::HashSet::new();
11852                let mut result = Self::Value::new();
11853                while let Some(tag) = map.next_key::<__FieldTag>()? {
11854                    #[allow(clippy::match_single_binding)]
11855                    match tag {
11856                        __FieldTag::__max_meters => {
11857                            if !fields.insert(__FieldTag::__max_meters) {
11858                                return std::result::Result::Err(A::Error::duplicate_field(
11859                                    "multiple values for max_meters",
11860                                ));
11861                            }
11862                            struct __With(std::option::Option<i64>);
11863                            impl<'de> serde::de::Deserialize<'de> for __With {
11864                                fn deserialize<D>(
11865                                    deserializer: D,
11866                                ) -> std::result::Result<Self, D::Error>
11867                                where
11868                                    D: serde::de::Deserializer<'de>,
11869                                {
11870                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11871                                }
11872                            }
11873                            result.max_meters = map.next_value::<__With>()?.0;
11874                        }
11875                        __FieldTag::__soft_max_meters => {
11876                            if !fields.insert(__FieldTag::__soft_max_meters) {
11877                                return std::result::Result::Err(A::Error::duplicate_field(
11878                                    "multiple values for soft_max_meters",
11879                                ));
11880                            }
11881                            struct __With(std::option::Option<i64>);
11882                            impl<'de> serde::de::Deserialize<'de> for __With {
11883                                fn deserialize<D>(
11884                                    deserializer: D,
11885                                ) -> std::result::Result<Self, D::Error>
11886                                where
11887                                    D: serde::de::Deserializer<'de>,
11888                                {
11889                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11890                                }
11891                            }
11892                            result.soft_max_meters = map.next_value::<__With>()?.0;
11893                        }
11894                        __FieldTag::__cost_per_kilometer_below_soft_max => {
11895                            if !fields.insert(__FieldTag::__cost_per_kilometer_below_soft_max) {
11896                                return std::result::Result::Err(A::Error::duplicate_field(
11897                                    "multiple values for cost_per_kilometer_below_soft_max",
11898                                ));
11899                            }
11900                            struct __With(std::option::Option<f64>);
11901                            impl<'de> serde::de::Deserialize<'de> for __With {
11902                                fn deserialize<D>(
11903                                    deserializer: D,
11904                                ) -> std::result::Result<Self, D::Error>
11905                                where
11906                                    D: serde::de::Deserializer<'de>,
11907                                {
11908                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11909                                }
11910                            }
11911                            result.cost_per_kilometer_below_soft_max =
11912                                map.next_value::<__With>()?.0;
11913                        }
11914                        __FieldTag::__cost_per_kilometer_above_soft_max => {
11915                            if !fields.insert(__FieldTag::__cost_per_kilometer_above_soft_max) {
11916                                return std::result::Result::Err(A::Error::duplicate_field(
11917                                    "multiple values for cost_per_kilometer_above_soft_max",
11918                                ));
11919                            }
11920                            struct __With(std::option::Option<f64>);
11921                            impl<'de> serde::de::Deserialize<'de> for __With {
11922                                fn deserialize<D>(
11923                                    deserializer: D,
11924                                ) -> std::result::Result<Self, D::Error>
11925                                where
11926                                    D: serde::de::Deserializer<'de>,
11927                                {
11928                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11929                                }
11930                            }
11931                            result.cost_per_kilometer_above_soft_max =
11932                                map.next_value::<__With>()?.0;
11933                        }
11934                        __FieldTag::Unknown(key) => {
11935                            let value = map.next_value::<serde_json::Value>()?;
11936                            result._unknown_fields.insert(key, value);
11937                        }
11938                    }
11939                }
11940                std::result::Result::Ok(result)
11941            }
11942        }
11943        deserializer.deserialize_any(Visitor)
11944    }
11945}
11946
11947#[doc(hidden)]
11948impl serde::ser::Serialize for DistanceLimit {
11949    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11950    where
11951        S: serde::ser::Serializer,
11952    {
11953        use serde::ser::SerializeMap;
11954        #[allow(unused_imports)]
11955        use std::option::Option::Some;
11956        let mut state = serializer.serialize_map(std::option::Option::None)?;
11957        if self.max_meters.is_some() {
11958            struct __With<'a>(&'a std::option::Option<i64>);
11959            impl<'a> serde::ser::Serialize for __With<'a> {
11960                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11961                where
11962                    S: serde::ser::Serializer,
11963                {
11964                    serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
11965                        self.0, serializer,
11966                    )
11967                }
11968            }
11969            state.serialize_entry("maxMeters", &__With(&self.max_meters))?;
11970        }
11971        if self.soft_max_meters.is_some() {
11972            struct __With<'a>(&'a std::option::Option<i64>);
11973            impl<'a> serde::ser::Serialize for __With<'a> {
11974                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11975                where
11976                    S: serde::ser::Serializer,
11977                {
11978                    serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
11979                        self.0, serializer,
11980                    )
11981                }
11982            }
11983            state.serialize_entry("softMaxMeters", &__With(&self.soft_max_meters))?;
11984        }
11985        if self.cost_per_kilometer_below_soft_max.is_some() {
11986            struct __With<'a>(&'a std::option::Option<f64>);
11987            impl<'a> serde::ser::Serialize for __With<'a> {
11988                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11989                where
11990                    S: serde::ser::Serializer,
11991                {
11992                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
11993                        self.0, serializer,
11994                    )
11995                }
11996            }
11997            state.serialize_entry(
11998                "costPerKilometerBelowSoftMax",
11999                &__With(&self.cost_per_kilometer_below_soft_max),
12000            )?;
12001        }
12002        if self.cost_per_kilometer_above_soft_max.is_some() {
12003            struct __With<'a>(&'a std::option::Option<f64>);
12004            impl<'a> serde::ser::Serialize for __With<'a> {
12005                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12006                where
12007                    S: serde::ser::Serializer,
12008                {
12009                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
12010                        self.0, serializer,
12011                    )
12012                }
12013            }
12014            state.serialize_entry(
12015                "costPerKilometerAboveSoftMax",
12016                &__With(&self.cost_per_kilometer_above_soft_max),
12017            )?;
12018        }
12019        if !self._unknown_fields.is_empty() {
12020            for (key, value) in self._unknown_fields.iter() {
12021                state.serialize_entry(key, &value)?;
12022            }
12023        }
12024        state.end()
12025    }
12026}
12027
12028/// Specifies attributes of transitions between two consecutive visits on a
12029/// route. Several `TransitionAttributes` may apply to the same transition: in
12030/// that case, all extra costs add up and the strictest constraint or limit
12031/// applies (following natural "AND" semantics).
12032#[derive(Clone, Debug, Default, PartialEq)]
12033#[non_exhaustive]
12034pub struct TransitionAttributes {
12035    /// Tags defining the set of (src->dst) transitions these attributes apply to.
12036    ///
12037    /// A source visit or vehicle start matches iff its
12038    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
12039    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
12040    /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
12041    /// on which of these two fields is non-empty).
12042    ///
12043    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
12044    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
12045    pub src_tag: std::string::String,
12046
12047    /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
12048    /// non-empty.
12049    pub excluded_src_tag: std::string::String,
12050
12051    /// A destination visit or vehicle end matches iff its
12052    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
12053    /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
12054    /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
12055    /// which of these two fields is non-empty).
12056    ///
12057    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
12058    /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
12059    pub dst_tag: std::string::String,
12060
12061    /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
12062    /// non-empty.
12063    pub excluded_dst_tag: std::string::String,
12064
12065    /// Specifies a cost for performing this transition. This is in the same unit
12066    /// as all other costs in the model and must not be negative. It is applied on
12067    /// top of all other existing costs.
12068    pub cost: f64,
12069
12070    /// Specifies a cost per kilometer applied to the distance traveled while
12071    /// performing this transition. It adds up to any
12072    /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
12073    /// specified on vehicles.
12074    ///
12075    /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
12076    pub cost_per_kilometer: f64,
12077
12078    /// Specifies a limit on the distance traveled while performing this
12079    /// transition.
12080    ///
12081    /// As of 2021/06, only soft limits are supported.
12082    pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
12083
12084    /// Specifies a delay incurred when performing this transition.
12085    ///
12086    /// This delay always occurs *after* finishing the source visit and *before*
12087    /// starting the destination visit.
12088    pub delay: std::option::Option<wkt::Duration>,
12089
12090    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12091}
12092
12093impl TransitionAttributes {
12094    pub fn new() -> Self {
12095        std::default::Default::default()
12096    }
12097
12098    /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
12099    pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12100        self.src_tag = v.into();
12101        self
12102    }
12103
12104    /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
12105    pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
12106        mut self,
12107        v: T,
12108    ) -> Self {
12109        self.excluded_src_tag = v.into();
12110        self
12111    }
12112
12113    /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
12114    pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12115        self.dst_tag = v.into();
12116        self
12117    }
12118
12119    /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
12120    pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
12121        mut self,
12122        v: T,
12123    ) -> Self {
12124        self.excluded_dst_tag = v.into();
12125        self
12126    }
12127
12128    /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
12129    pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
12130        self.cost = v.into();
12131        self
12132    }
12133
12134    /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
12135    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
12136        self.cost_per_kilometer = v.into();
12137        self
12138    }
12139
12140    /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
12141    pub fn set_distance_limit<T>(mut self, v: T) -> Self
12142    where
12143        T: std::convert::Into<crate::model::DistanceLimit>,
12144    {
12145        self.distance_limit = std::option::Option::Some(v.into());
12146        self
12147    }
12148
12149    /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
12150    pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
12151    where
12152        T: std::convert::Into<crate::model::DistanceLimit>,
12153    {
12154        self.distance_limit = v.map(|x| x.into());
12155        self
12156    }
12157
12158    /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
12159    pub fn set_delay<T>(mut self, v: T) -> Self
12160    where
12161        T: std::convert::Into<wkt::Duration>,
12162    {
12163        self.delay = std::option::Option::Some(v.into());
12164        self
12165    }
12166
12167    /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
12168    pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
12169    where
12170        T: std::convert::Into<wkt::Duration>,
12171    {
12172        self.delay = v.map(|x| x.into());
12173        self
12174    }
12175}
12176
12177impl wkt::message::Message for TransitionAttributes {
12178    fn typename() -> &'static str {
12179        "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
12180    }
12181}
12182
12183#[doc(hidden)]
12184impl<'de> serde::de::Deserialize<'de> for TransitionAttributes {
12185    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12186    where
12187        D: serde::Deserializer<'de>,
12188    {
12189        #[allow(non_camel_case_types)]
12190        #[doc(hidden)]
12191        #[derive(PartialEq, Eq, Hash)]
12192        enum __FieldTag {
12193            __src_tag,
12194            __excluded_src_tag,
12195            __dst_tag,
12196            __excluded_dst_tag,
12197            __cost,
12198            __cost_per_kilometer,
12199            __distance_limit,
12200            __delay,
12201            Unknown(std::string::String),
12202        }
12203        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12204            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12205            where
12206                D: serde::Deserializer<'de>,
12207            {
12208                struct Visitor;
12209                impl<'de> serde::de::Visitor<'de> for Visitor {
12210                    type Value = __FieldTag;
12211                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12212                        formatter.write_str("a field name for TransitionAttributes")
12213                    }
12214                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12215                    where
12216                        E: serde::de::Error,
12217                    {
12218                        use std::result::Result::Ok;
12219                        use std::string::ToString;
12220                        match value {
12221                            "srcTag" => Ok(__FieldTag::__src_tag),
12222                            "src_tag" => Ok(__FieldTag::__src_tag),
12223                            "excludedSrcTag" => Ok(__FieldTag::__excluded_src_tag),
12224                            "excluded_src_tag" => Ok(__FieldTag::__excluded_src_tag),
12225                            "dstTag" => Ok(__FieldTag::__dst_tag),
12226                            "dst_tag" => Ok(__FieldTag::__dst_tag),
12227                            "excludedDstTag" => Ok(__FieldTag::__excluded_dst_tag),
12228                            "excluded_dst_tag" => Ok(__FieldTag::__excluded_dst_tag),
12229                            "cost" => Ok(__FieldTag::__cost),
12230                            "costPerKilometer" => Ok(__FieldTag::__cost_per_kilometer),
12231                            "cost_per_kilometer" => Ok(__FieldTag::__cost_per_kilometer),
12232                            "distanceLimit" => Ok(__FieldTag::__distance_limit),
12233                            "distance_limit" => Ok(__FieldTag::__distance_limit),
12234                            "delay" => Ok(__FieldTag::__delay),
12235                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12236                        }
12237                    }
12238                }
12239                deserializer.deserialize_identifier(Visitor)
12240            }
12241        }
12242        struct Visitor;
12243        impl<'de> serde::de::Visitor<'de> for Visitor {
12244            type Value = TransitionAttributes;
12245            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12246                formatter.write_str("struct TransitionAttributes")
12247            }
12248            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12249            where
12250                A: serde::de::MapAccess<'de>,
12251            {
12252                #[allow(unused_imports)]
12253                use serde::de::Error;
12254                use std::option::Option::Some;
12255                let mut fields = std::collections::HashSet::new();
12256                let mut result = Self::Value::new();
12257                while let Some(tag) = map.next_key::<__FieldTag>()? {
12258                    #[allow(clippy::match_single_binding)]
12259                    match tag {
12260                        __FieldTag::__src_tag => {
12261                            if !fields.insert(__FieldTag::__src_tag) {
12262                                return std::result::Result::Err(A::Error::duplicate_field(
12263                                    "multiple values for src_tag",
12264                                ));
12265                            }
12266                            result.src_tag = map
12267                                .next_value::<std::option::Option<std::string::String>>()?
12268                                .unwrap_or_default();
12269                        }
12270                        __FieldTag::__excluded_src_tag => {
12271                            if !fields.insert(__FieldTag::__excluded_src_tag) {
12272                                return std::result::Result::Err(A::Error::duplicate_field(
12273                                    "multiple values for excluded_src_tag",
12274                                ));
12275                            }
12276                            result.excluded_src_tag = map
12277                                .next_value::<std::option::Option<std::string::String>>()?
12278                                .unwrap_or_default();
12279                        }
12280                        __FieldTag::__dst_tag => {
12281                            if !fields.insert(__FieldTag::__dst_tag) {
12282                                return std::result::Result::Err(A::Error::duplicate_field(
12283                                    "multiple values for dst_tag",
12284                                ));
12285                            }
12286                            result.dst_tag = map
12287                                .next_value::<std::option::Option<std::string::String>>()?
12288                                .unwrap_or_default();
12289                        }
12290                        __FieldTag::__excluded_dst_tag => {
12291                            if !fields.insert(__FieldTag::__excluded_dst_tag) {
12292                                return std::result::Result::Err(A::Error::duplicate_field(
12293                                    "multiple values for excluded_dst_tag",
12294                                ));
12295                            }
12296                            result.excluded_dst_tag = map
12297                                .next_value::<std::option::Option<std::string::String>>()?
12298                                .unwrap_or_default();
12299                        }
12300                        __FieldTag::__cost => {
12301                            if !fields.insert(__FieldTag::__cost) {
12302                                return std::result::Result::Err(A::Error::duplicate_field(
12303                                    "multiple values for cost",
12304                                ));
12305                            }
12306                            struct __With(std::option::Option<f64>);
12307                            impl<'de> serde::de::Deserialize<'de> for __With {
12308                                fn deserialize<D>(
12309                                    deserializer: D,
12310                                ) -> std::result::Result<Self, D::Error>
12311                                where
12312                                    D: serde::de::Deserializer<'de>,
12313                                {
12314                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
12315                                }
12316                            }
12317                            result.cost = map.next_value::<__With>()?.0.unwrap_or_default();
12318                        }
12319                        __FieldTag::__cost_per_kilometer => {
12320                            if !fields.insert(__FieldTag::__cost_per_kilometer) {
12321                                return std::result::Result::Err(A::Error::duplicate_field(
12322                                    "multiple values for cost_per_kilometer",
12323                                ));
12324                            }
12325                            struct __With(std::option::Option<f64>);
12326                            impl<'de> serde::de::Deserialize<'de> for __With {
12327                                fn deserialize<D>(
12328                                    deserializer: D,
12329                                ) -> std::result::Result<Self, D::Error>
12330                                where
12331                                    D: serde::de::Deserializer<'de>,
12332                                {
12333                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
12334                                }
12335                            }
12336                            result.cost_per_kilometer =
12337                                map.next_value::<__With>()?.0.unwrap_or_default();
12338                        }
12339                        __FieldTag::__distance_limit => {
12340                            if !fields.insert(__FieldTag::__distance_limit) {
12341                                return std::result::Result::Err(A::Error::duplicate_field(
12342                                    "multiple values for distance_limit",
12343                                ));
12344                            }
12345                            result.distance_limit = map
12346                                .next_value::<std::option::Option<crate::model::DistanceLimit>>()?;
12347                        }
12348                        __FieldTag::__delay => {
12349                            if !fields.insert(__FieldTag::__delay) {
12350                                return std::result::Result::Err(A::Error::duplicate_field(
12351                                    "multiple values for delay",
12352                                ));
12353                            }
12354                            result.delay =
12355                                map.next_value::<std::option::Option<wkt::Duration>>()?;
12356                        }
12357                        __FieldTag::Unknown(key) => {
12358                            let value = map.next_value::<serde_json::Value>()?;
12359                            result._unknown_fields.insert(key, value);
12360                        }
12361                    }
12362                }
12363                std::result::Result::Ok(result)
12364            }
12365        }
12366        deserializer.deserialize_any(Visitor)
12367    }
12368}
12369
12370#[doc(hidden)]
12371impl serde::ser::Serialize for TransitionAttributes {
12372    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12373    where
12374        S: serde::ser::Serializer,
12375    {
12376        use serde::ser::SerializeMap;
12377        #[allow(unused_imports)]
12378        use std::option::Option::Some;
12379        let mut state = serializer.serialize_map(std::option::Option::None)?;
12380        if !self.src_tag.is_empty() {
12381            state.serialize_entry("srcTag", &self.src_tag)?;
12382        }
12383        if !self.excluded_src_tag.is_empty() {
12384            state.serialize_entry("excludedSrcTag", &self.excluded_src_tag)?;
12385        }
12386        if !self.dst_tag.is_empty() {
12387            state.serialize_entry("dstTag", &self.dst_tag)?;
12388        }
12389        if !self.excluded_dst_tag.is_empty() {
12390            state.serialize_entry("excludedDstTag", &self.excluded_dst_tag)?;
12391        }
12392        if !wkt::internal::is_default(&self.cost) {
12393            struct __With<'a>(&'a f64);
12394            impl<'a> serde::ser::Serialize for __With<'a> {
12395                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12396                where
12397                    S: serde::ser::Serializer,
12398                {
12399                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
12400                }
12401            }
12402            state.serialize_entry("cost", &__With(&self.cost))?;
12403        }
12404        if !wkt::internal::is_default(&self.cost_per_kilometer) {
12405            struct __With<'a>(&'a f64);
12406            impl<'a> serde::ser::Serialize for __With<'a> {
12407                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12408                where
12409                    S: serde::ser::Serializer,
12410                {
12411                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
12412                }
12413            }
12414            state.serialize_entry("costPerKilometer", &__With(&self.cost_per_kilometer))?;
12415        }
12416        if self.distance_limit.is_some() {
12417            state.serialize_entry("distanceLimit", &self.distance_limit)?;
12418        }
12419        if self.delay.is_some() {
12420            state.serialize_entry("delay", &self.delay)?;
12421        }
12422        if !self._unknown_fields.is_empty() {
12423            for (key, value) in self._unknown_fields.iter() {
12424                state.serialize_entry(key, &value)?;
12425            }
12426        }
12427        state.end()
12428    }
12429}
12430
12431/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
12432/// VisitRequests, and start and end locations of Vehicles.
12433#[derive(Clone, Debug, Default, PartialEq)]
12434#[non_exhaustive]
12435pub struct Waypoint {
12436    /// Indicates that the location of this waypoint is meant to have a preference
12437    /// for the vehicle to stop at a particular side of road. When you set this
12438    /// value, the route will pass through the location so that the vehicle can
12439    /// stop at the side of road that the location is biased towards from the
12440    /// center of the road. This option works only for the 'DRIVING' travel mode,
12441    /// and when the 'location_type' is set to 'location'.
12442    pub side_of_road: bool,
12443
12444    /// Different ways to represent a location.
12445    pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
12446
12447    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12448}
12449
12450impl Waypoint {
12451    pub fn new() -> Self {
12452        std::default::Default::default()
12453    }
12454
12455    /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
12456    pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
12457        self.side_of_road = v.into();
12458        self
12459    }
12460
12461    /// Sets the value of [location_type][crate::model::Waypoint::location_type].
12462    ///
12463    /// Note that all the setters affecting `location_type` are mutually
12464    /// exclusive.
12465    pub fn set_location_type<
12466        T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
12467    >(
12468        mut self,
12469        v: T,
12470    ) -> Self {
12471        self.location_type = v.into();
12472        self
12473    }
12474
12475    /// The value of [location_type][crate::model::Waypoint::location_type]
12476    /// if it holds a `Location`, `None` if the field is not set or
12477    /// holds a different branch.
12478    pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
12479        #[allow(unreachable_patterns)]
12480        self.location_type.as_ref().and_then(|v| match v {
12481            crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
12482            _ => std::option::Option::None,
12483        })
12484    }
12485
12486    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
12487    /// to hold a `Location`.
12488    ///
12489    /// Note that all the setters affecting `location_type` are
12490    /// mutually exclusive.
12491    pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
12492        mut self,
12493        v: T,
12494    ) -> Self {
12495        self.location_type =
12496            std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
12497        self
12498    }
12499
12500    /// The value of [location_type][crate::model::Waypoint::location_type]
12501    /// if it holds a `PlaceId`, `None` if the field is not set or
12502    /// holds a different branch.
12503    pub fn place_id(&self) -> std::option::Option<&std::string::String> {
12504        #[allow(unreachable_patterns)]
12505        self.location_type.as_ref().and_then(|v| match v {
12506            crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
12507            _ => std::option::Option::None,
12508        })
12509    }
12510
12511    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
12512    /// to hold a `PlaceId`.
12513    ///
12514    /// Note that all the setters affecting `location_type` are
12515    /// mutually exclusive.
12516    pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12517        self.location_type =
12518            std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
12519        self
12520    }
12521}
12522
12523impl wkt::message::Message for Waypoint {
12524    fn typename() -> &'static str {
12525        "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
12526    }
12527}
12528
12529#[doc(hidden)]
12530impl<'de> serde::de::Deserialize<'de> for Waypoint {
12531    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12532    where
12533        D: serde::Deserializer<'de>,
12534    {
12535        #[allow(non_camel_case_types)]
12536        #[doc(hidden)]
12537        #[derive(PartialEq, Eq, Hash)]
12538        enum __FieldTag {
12539            __location,
12540            __place_id,
12541            __side_of_road,
12542            Unknown(std::string::String),
12543        }
12544        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12545            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12546            where
12547                D: serde::Deserializer<'de>,
12548            {
12549                struct Visitor;
12550                impl<'de> serde::de::Visitor<'de> for Visitor {
12551                    type Value = __FieldTag;
12552                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12553                        formatter.write_str("a field name for Waypoint")
12554                    }
12555                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12556                    where
12557                        E: serde::de::Error,
12558                    {
12559                        use std::result::Result::Ok;
12560                        use std::string::ToString;
12561                        match value {
12562                            "location" => Ok(__FieldTag::__location),
12563                            "placeId" => Ok(__FieldTag::__place_id),
12564                            "place_id" => Ok(__FieldTag::__place_id),
12565                            "sideOfRoad" => Ok(__FieldTag::__side_of_road),
12566                            "side_of_road" => Ok(__FieldTag::__side_of_road),
12567                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12568                        }
12569                    }
12570                }
12571                deserializer.deserialize_identifier(Visitor)
12572            }
12573        }
12574        struct Visitor;
12575        impl<'de> serde::de::Visitor<'de> for Visitor {
12576            type Value = Waypoint;
12577            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12578                formatter.write_str("struct Waypoint")
12579            }
12580            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12581            where
12582                A: serde::de::MapAccess<'de>,
12583            {
12584                #[allow(unused_imports)]
12585                use serde::de::Error;
12586                use std::option::Option::Some;
12587                let mut fields = std::collections::HashSet::new();
12588                let mut result = Self::Value::new();
12589                while let Some(tag) = map.next_key::<__FieldTag>()? {
12590                    #[allow(clippy::match_single_binding)]
12591                    match tag {
12592                        __FieldTag::__location => {
12593                            if !fields.insert(__FieldTag::__location) {
12594                                return std::result::Result::Err(A::Error::duplicate_field(
12595                                    "multiple values for location",
12596                                ));
12597                            }
12598                            if result.location_type.is_some() {
12599                                return std::result::Result::Err(A::Error::duplicate_field(
12600                                    "multiple values for `location_type`, a oneof with full ID .google.cloud.optimization.v1.Waypoint.location, latest field was location",
12601                                ));
12602                            }
12603                            result.location_type = std::option::Option::Some(
12604                                crate::model::waypoint::LocationType::Location(
12605                                    map.next_value::<std::option::Option<
12606                                        std::boxed::Box<crate::model::Location>,
12607                                    >>()?
12608                                    .unwrap_or_default(),
12609                                ),
12610                            );
12611                        }
12612                        __FieldTag::__place_id => {
12613                            if !fields.insert(__FieldTag::__place_id) {
12614                                return std::result::Result::Err(A::Error::duplicate_field(
12615                                    "multiple values for place_id",
12616                                ));
12617                            }
12618                            if result.location_type.is_some() {
12619                                return std::result::Result::Err(A::Error::duplicate_field(
12620                                    "multiple values for `location_type`, a oneof with full ID .google.cloud.optimization.v1.Waypoint.place_id, latest field was placeId",
12621                                ));
12622                            }
12623                            result.location_type = std::option::Option::Some(
12624                                crate::model::waypoint::LocationType::PlaceId(
12625                                    map.next_value::<std::option::Option<std::string::String>>()?
12626                                        .unwrap_or_default(),
12627                                ),
12628                            );
12629                        }
12630                        __FieldTag::__side_of_road => {
12631                            if !fields.insert(__FieldTag::__side_of_road) {
12632                                return std::result::Result::Err(A::Error::duplicate_field(
12633                                    "multiple values for side_of_road",
12634                                ));
12635                            }
12636                            result.side_of_road = map
12637                                .next_value::<std::option::Option<bool>>()?
12638                                .unwrap_or_default();
12639                        }
12640                        __FieldTag::Unknown(key) => {
12641                            let value = map.next_value::<serde_json::Value>()?;
12642                            result._unknown_fields.insert(key, value);
12643                        }
12644                    }
12645                }
12646                std::result::Result::Ok(result)
12647            }
12648        }
12649        deserializer.deserialize_any(Visitor)
12650    }
12651}
12652
12653#[doc(hidden)]
12654impl serde::ser::Serialize for Waypoint {
12655    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12656    where
12657        S: serde::ser::Serializer,
12658    {
12659        use serde::ser::SerializeMap;
12660        #[allow(unused_imports)]
12661        use std::option::Option::Some;
12662        let mut state = serializer.serialize_map(std::option::Option::None)?;
12663        if let Some(value) = self.location() {
12664            state.serialize_entry("location", value)?;
12665        }
12666        if let Some(value) = self.place_id() {
12667            state.serialize_entry("placeId", value)?;
12668        }
12669        if !wkt::internal::is_default(&self.side_of_road) {
12670            state.serialize_entry("sideOfRoad", &self.side_of_road)?;
12671        }
12672        if !self._unknown_fields.is_empty() {
12673            for (key, value) in self._unknown_fields.iter() {
12674                state.serialize_entry(key, &value)?;
12675            }
12676        }
12677        state.end()
12678    }
12679}
12680
12681/// Defines additional types related to [Waypoint].
12682pub mod waypoint {
12683    #[allow(unused_imports)]
12684    use super::*;
12685
12686    /// Different ways to represent a location.
12687    #[derive(Clone, Debug, PartialEq)]
12688    #[non_exhaustive]
12689    pub enum LocationType {
12690        /// A point specified using geographic coordinates, including an optional
12691        /// heading.
12692        Location(std::boxed::Box<crate::model::Location>),
12693        /// The POI Place ID associated with the waypoint.
12694        PlaceId(std::string::String),
12695    }
12696}
12697
12698/// Encapsulates a location (a geographic point, and an optional heading).
12699#[derive(Clone, Debug, Default, PartialEq)]
12700#[non_exhaustive]
12701pub struct Location {
12702    /// The waypoint's geographic coordinates.
12703    pub lat_lng: std::option::Option<gtype::model::LatLng>,
12704
12705    /// The compass heading associated with the direction of the flow of traffic.
12706    /// This value is used to specify the side of the road to use for pickup and
12707    /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
12708    /// of due North, 90 specifies a heading of due East, etc.
12709    pub heading: std::option::Option<i32>,
12710
12711    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12712}
12713
12714impl Location {
12715    pub fn new() -> Self {
12716        std::default::Default::default()
12717    }
12718
12719    /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
12720    pub fn set_lat_lng<T>(mut self, v: T) -> Self
12721    where
12722        T: std::convert::Into<gtype::model::LatLng>,
12723    {
12724        self.lat_lng = std::option::Option::Some(v.into());
12725        self
12726    }
12727
12728    /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
12729    pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
12730    where
12731        T: std::convert::Into<gtype::model::LatLng>,
12732    {
12733        self.lat_lng = v.map(|x| x.into());
12734        self
12735    }
12736
12737    /// Sets the value of [heading][crate::model::Location::heading].
12738    pub fn set_heading<T>(mut self, v: T) -> Self
12739    where
12740        T: std::convert::Into<i32>,
12741    {
12742        self.heading = std::option::Option::Some(v.into());
12743        self
12744    }
12745
12746    /// Sets or clears the value of [heading][crate::model::Location::heading].
12747    pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
12748    where
12749        T: std::convert::Into<i32>,
12750    {
12751        self.heading = v.map(|x| x.into());
12752        self
12753    }
12754}
12755
12756impl wkt::message::Message for Location {
12757    fn typename() -> &'static str {
12758        "type.googleapis.com/google.cloud.optimization.v1.Location"
12759    }
12760}
12761
12762#[doc(hidden)]
12763impl<'de> serde::de::Deserialize<'de> for Location {
12764    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12765    where
12766        D: serde::Deserializer<'de>,
12767    {
12768        #[allow(non_camel_case_types)]
12769        #[doc(hidden)]
12770        #[derive(PartialEq, Eq, Hash)]
12771        enum __FieldTag {
12772            __lat_lng,
12773            __heading,
12774            Unknown(std::string::String),
12775        }
12776        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12777            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12778            where
12779                D: serde::Deserializer<'de>,
12780            {
12781                struct Visitor;
12782                impl<'de> serde::de::Visitor<'de> for Visitor {
12783                    type Value = __FieldTag;
12784                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12785                        formatter.write_str("a field name for Location")
12786                    }
12787                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12788                    where
12789                        E: serde::de::Error,
12790                    {
12791                        use std::result::Result::Ok;
12792                        use std::string::ToString;
12793                        match value {
12794                            "latLng" => Ok(__FieldTag::__lat_lng),
12795                            "lat_lng" => Ok(__FieldTag::__lat_lng),
12796                            "heading" => Ok(__FieldTag::__heading),
12797                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12798                        }
12799                    }
12800                }
12801                deserializer.deserialize_identifier(Visitor)
12802            }
12803        }
12804        struct Visitor;
12805        impl<'de> serde::de::Visitor<'de> for Visitor {
12806            type Value = Location;
12807            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12808                formatter.write_str("struct Location")
12809            }
12810            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12811            where
12812                A: serde::de::MapAccess<'de>,
12813            {
12814                #[allow(unused_imports)]
12815                use serde::de::Error;
12816                use std::option::Option::Some;
12817                let mut fields = std::collections::HashSet::new();
12818                let mut result = Self::Value::new();
12819                while let Some(tag) = map.next_key::<__FieldTag>()? {
12820                    #[allow(clippy::match_single_binding)]
12821                    match tag {
12822                        __FieldTag::__lat_lng => {
12823                            if !fields.insert(__FieldTag::__lat_lng) {
12824                                return std::result::Result::Err(A::Error::duplicate_field(
12825                                    "multiple values for lat_lng",
12826                                ));
12827                            }
12828                            result.lat_lng =
12829                                map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
12830                        }
12831                        __FieldTag::__heading => {
12832                            if !fields.insert(__FieldTag::__heading) {
12833                                return std::result::Result::Err(A::Error::duplicate_field(
12834                                    "multiple values for heading",
12835                                ));
12836                            }
12837                            struct __With(std::option::Option<i32>);
12838                            impl<'de> serde::de::Deserialize<'de> for __With {
12839                                fn deserialize<D>(
12840                                    deserializer: D,
12841                                ) -> std::result::Result<Self, D::Error>
12842                                where
12843                                    D: serde::de::Deserializer<'de>,
12844                                {
12845                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
12846                                }
12847                            }
12848                            result.heading = map.next_value::<__With>()?.0;
12849                        }
12850                        __FieldTag::Unknown(key) => {
12851                            let value = map.next_value::<serde_json::Value>()?;
12852                            result._unknown_fields.insert(key, value);
12853                        }
12854                    }
12855                }
12856                std::result::Result::Ok(result)
12857            }
12858        }
12859        deserializer.deserialize_any(Visitor)
12860    }
12861}
12862
12863#[doc(hidden)]
12864impl serde::ser::Serialize for Location {
12865    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12866    where
12867        S: serde::ser::Serializer,
12868    {
12869        use serde::ser::SerializeMap;
12870        #[allow(unused_imports)]
12871        use std::option::Option::Some;
12872        let mut state = serializer.serialize_map(std::option::Option::None)?;
12873        if self.lat_lng.is_some() {
12874            state.serialize_entry("latLng", &self.lat_lng)?;
12875        }
12876        if self.heading.is_some() {
12877            struct __With<'a>(&'a std::option::Option<i32>);
12878            impl<'a> serde::ser::Serialize for __With<'a> {
12879                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12880                where
12881                    S: serde::ser::Serializer,
12882                {
12883                    serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
12884                        self.0, serializer,
12885                    )
12886                }
12887            }
12888            state.serialize_entry("heading", &__With(&self.heading))?;
12889        }
12890        if !self._unknown_fields.is_empty() {
12891            for (key, value) in self._unknown_fields.iter() {
12892                state.serialize_entry(key, &value)?;
12893            }
12894        }
12895        state.end()
12896    }
12897}
12898
12899/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
12900/// is a contiguous period of time during which the vehicle remains idle at its
12901/// current position and cannot perform any visit. A break may occur:
12902///
12903/// * during the travel between two visits (which includes the time right
12904///   before or right after a visit, but not in the middle of a visit), in
12905///   which case it extends the corresponding transit time between the visits,
12906/// * or before the vehicle start (the vehicle may not start in the middle of
12907///   a break), in which case it does not affect the vehicle start time.
12908/// * or after the vehicle end (ditto, with the vehicle end time).
12909#[derive(Clone, Debug, Default, PartialEq)]
12910#[non_exhaustive]
12911pub struct BreakRule {
12912    /// Sequence of breaks. See the `BreakRequest` message.
12913    pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
12914
12915    /// Several `FrequencyConstraint` may apply. They must all be satisfied by
12916    /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
12917    pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
12918
12919    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12920}
12921
12922impl BreakRule {
12923    pub fn new() -> Self {
12924        std::default::Default::default()
12925    }
12926
12927    /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
12928    pub fn set_break_requests<T, V>(mut self, v: T) -> Self
12929    where
12930        T: std::iter::IntoIterator<Item = V>,
12931        V: std::convert::Into<crate::model::break_rule::BreakRequest>,
12932    {
12933        use std::iter::Iterator;
12934        self.break_requests = v.into_iter().map(|i| i.into()).collect();
12935        self
12936    }
12937
12938    /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
12939    pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
12940    where
12941        T: std::iter::IntoIterator<Item = V>,
12942        V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
12943    {
12944        use std::iter::Iterator;
12945        self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
12946        self
12947    }
12948}
12949
12950impl wkt::message::Message for BreakRule {
12951    fn typename() -> &'static str {
12952        "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
12953    }
12954}
12955
12956#[doc(hidden)]
12957impl<'de> serde::de::Deserialize<'de> for BreakRule {
12958    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12959    where
12960        D: serde::Deserializer<'de>,
12961    {
12962        #[allow(non_camel_case_types)]
12963        #[doc(hidden)]
12964        #[derive(PartialEq, Eq, Hash)]
12965        enum __FieldTag {
12966            __break_requests,
12967            __frequency_constraints,
12968            Unknown(std::string::String),
12969        }
12970        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12971            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12972            where
12973                D: serde::Deserializer<'de>,
12974            {
12975                struct Visitor;
12976                impl<'de> serde::de::Visitor<'de> for Visitor {
12977                    type Value = __FieldTag;
12978                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12979                        formatter.write_str("a field name for BreakRule")
12980                    }
12981                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12982                    where
12983                        E: serde::de::Error,
12984                    {
12985                        use std::result::Result::Ok;
12986                        use std::string::ToString;
12987                        match value {
12988                            "breakRequests" => Ok(__FieldTag::__break_requests),
12989                            "break_requests" => Ok(__FieldTag::__break_requests),
12990                            "frequencyConstraints" => Ok(__FieldTag::__frequency_constraints),
12991                            "frequency_constraints" => Ok(__FieldTag::__frequency_constraints),
12992                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12993                        }
12994                    }
12995                }
12996                deserializer.deserialize_identifier(Visitor)
12997            }
12998        }
12999        struct Visitor;
13000        impl<'de> serde::de::Visitor<'de> for Visitor {
13001            type Value = BreakRule;
13002            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13003                formatter.write_str("struct BreakRule")
13004            }
13005            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13006            where
13007                A: serde::de::MapAccess<'de>,
13008            {
13009                #[allow(unused_imports)]
13010                use serde::de::Error;
13011                use std::option::Option::Some;
13012                let mut fields = std::collections::HashSet::new();
13013                let mut result = Self::Value::new();
13014                while let Some(tag) = map.next_key::<__FieldTag>()? {
13015                    #[allow(clippy::match_single_binding)]
13016                    match tag {
13017                        __FieldTag::__break_requests => {
13018                            if !fields.insert(__FieldTag::__break_requests) {
13019                                return std::result::Result::Err(A::Error::duplicate_field(
13020                                    "multiple values for break_requests",
13021                                ));
13022                            }
13023                            result.break_requests = map
13024                                .next_value::<std::option::Option<
13025                                    std::vec::Vec<crate::model::break_rule::BreakRequest>,
13026                                >>()?
13027                                .unwrap_or_default();
13028                        }
13029                        __FieldTag::__frequency_constraints => {
13030                            if !fields.insert(__FieldTag::__frequency_constraints) {
13031                                return std::result::Result::Err(A::Error::duplicate_field(
13032                                    "multiple values for frequency_constraints",
13033                                ));
13034                            }
13035                            result.frequency_constraints = map
13036                                .next_value::<std::option::Option<
13037                                    std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
13038                                >>()?
13039                                .unwrap_or_default();
13040                        }
13041                        __FieldTag::Unknown(key) => {
13042                            let value = map.next_value::<serde_json::Value>()?;
13043                            result._unknown_fields.insert(key, value);
13044                        }
13045                    }
13046                }
13047                std::result::Result::Ok(result)
13048            }
13049        }
13050        deserializer.deserialize_any(Visitor)
13051    }
13052}
13053
13054#[doc(hidden)]
13055impl serde::ser::Serialize for BreakRule {
13056    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13057    where
13058        S: serde::ser::Serializer,
13059    {
13060        use serde::ser::SerializeMap;
13061        #[allow(unused_imports)]
13062        use std::option::Option::Some;
13063        let mut state = serializer.serialize_map(std::option::Option::None)?;
13064        if !self.break_requests.is_empty() {
13065            state.serialize_entry("breakRequests", &self.break_requests)?;
13066        }
13067        if !self.frequency_constraints.is_empty() {
13068            state.serialize_entry("frequencyConstraints", &self.frequency_constraints)?;
13069        }
13070        if !self._unknown_fields.is_empty() {
13071            for (key, value) in self._unknown_fields.iter() {
13072                state.serialize_entry(key, &value)?;
13073            }
13074        }
13075        state.end()
13076    }
13077}
13078
13079/// Defines additional types related to [BreakRule].
13080pub mod break_rule {
13081    #[allow(unused_imports)]
13082    use super::*;
13083
13084    /// The sequence of breaks (i.e. their number and order) that apply to each
13085    /// vehicle must be known beforehand. The repeated `BreakRequest`s define
13086    /// that sequence, in the order in which they must occur. Their time windows
13087    /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
13088    /// be compatible with the order (this is checked).
13089    #[derive(Clone, Debug, Default, PartialEq)]
13090    #[non_exhaustive]
13091    pub struct BreakRequest {
13092        /// Required. Lower bound (inclusive) on the start of the break.
13093        pub earliest_start_time: std::option::Option<wkt::Timestamp>,
13094
13095        /// Required. Upper bound (inclusive) on the start of the break.
13096        pub latest_start_time: std::option::Option<wkt::Timestamp>,
13097
13098        /// Required. Minimum duration of the break. Must be positive.
13099        pub min_duration: std::option::Option<wkt::Duration>,
13100
13101        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13102    }
13103
13104    impl BreakRequest {
13105        pub fn new() -> Self {
13106            std::default::Default::default()
13107        }
13108
13109        /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
13110        pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
13111        where
13112            T: std::convert::Into<wkt::Timestamp>,
13113        {
13114            self.earliest_start_time = std::option::Option::Some(v.into());
13115            self
13116        }
13117
13118        /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
13119        pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
13120        where
13121            T: std::convert::Into<wkt::Timestamp>,
13122        {
13123            self.earliest_start_time = v.map(|x| x.into());
13124            self
13125        }
13126
13127        /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
13128        pub fn set_latest_start_time<T>(mut self, v: T) -> Self
13129        where
13130            T: std::convert::Into<wkt::Timestamp>,
13131        {
13132            self.latest_start_time = std::option::Option::Some(v.into());
13133            self
13134        }
13135
13136        /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
13137        pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
13138        where
13139            T: std::convert::Into<wkt::Timestamp>,
13140        {
13141            self.latest_start_time = v.map(|x| x.into());
13142            self
13143        }
13144
13145        /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
13146        pub fn set_min_duration<T>(mut self, v: T) -> Self
13147        where
13148            T: std::convert::Into<wkt::Duration>,
13149        {
13150            self.min_duration = std::option::Option::Some(v.into());
13151            self
13152        }
13153
13154        /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
13155        pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
13156        where
13157            T: std::convert::Into<wkt::Duration>,
13158        {
13159            self.min_duration = v.map(|x| x.into());
13160            self
13161        }
13162    }
13163
13164    impl wkt::message::Message for BreakRequest {
13165        fn typename() -> &'static str {
13166            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
13167        }
13168    }
13169
13170    #[doc(hidden)]
13171    impl<'de> serde::de::Deserialize<'de> for BreakRequest {
13172        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13173        where
13174            D: serde::Deserializer<'de>,
13175        {
13176            #[allow(non_camel_case_types)]
13177            #[doc(hidden)]
13178            #[derive(PartialEq, Eq, Hash)]
13179            enum __FieldTag {
13180                __earliest_start_time,
13181                __latest_start_time,
13182                __min_duration,
13183                Unknown(std::string::String),
13184            }
13185            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13186                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13187                where
13188                    D: serde::Deserializer<'de>,
13189                {
13190                    struct Visitor;
13191                    impl<'de> serde::de::Visitor<'de> for Visitor {
13192                        type Value = __FieldTag;
13193                        fn expecting(
13194                            &self,
13195                            formatter: &mut std::fmt::Formatter,
13196                        ) -> std::fmt::Result {
13197                            formatter.write_str("a field name for BreakRequest")
13198                        }
13199                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13200                        where
13201                            E: serde::de::Error,
13202                        {
13203                            use std::result::Result::Ok;
13204                            use std::string::ToString;
13205                            match value {
13206                                "earliestStartTime" => Ok(__FieldTag::__earliest_start_time),
13207                                "earliest_start_time" => Ok(__FieldTag::__earliest_start_time),
13208                                "latestStartTime" => Ok(__FieldTag::__latest_start_time),
13209                                "latest_start_time" => Ok(__FieldTag::__latest_start_time),
13210                                "minDuration" => Ok(__FieldTag::__min_duration),
13211                                "min_duration" => Ok(__FieldTag::__min_duration),
13212                                _ => Ok(__FieldTag::Unknown(value.to_string())),
13213                            }
13214                        }
13215                    }
13216                    deserializer.deserialize_identifier(Visitor)
13217                }
13218            }
13219            struct Visitor;
13220            impl<'de> serde::de::Visitor<'de> for Visitor {
13221                type Value = BreakRequest;
13222                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13223                    formatter.write_str("struct BreakRequest")
13224                }
13225                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13226                where
13227                    A: serde::de::MapAccess<'de>,
13228                {
13229                    #[allow(unused_imports)]
13230                    use serde::de::Error;
13231                    use std::option::Option::Some;
13232                    let mut fields = std::collections::HashSet::new();
13233                    let mut result = Self::Value::new();
13234                    while let Some(tag) = map.next_key::<__FieldTag>()? {
13235                        #[allow(clippy::match_single_binding)]
13236                        match tag {
13237                            __FieldTag::__earliest_start_time => {
13238                                if !fields.insert(__FieldTag::__earliest_start_time) {
13239                                    return std::result::Result::Err(A::Error::duplicate_field(
13240                                        "multiple values for earliest_start_time",
13241                                    ));
13242                                }
13243                                result.earliest_start_time =
13244                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
13245                            }
13246                            __FieldTag::__latest_start_time => {
13247                                if !fields.insert(__FieldTag::__latest_start_time) {
13248                                    return std::result::Result::Err(A::Error::duplicate_field(
13249                                        "multiple values for latest_start_time",
13250                                    ));
13251                                }
13252                                result.latest_start_time =
13253                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
13254                            }
13255                            __FieldTag::__min_duration => {
13256                                if !fields.insert(__FieldTag::__min_duration) {
13257                                    return std::result::Result::Err(A::Error::duplicate_field(
13258                                        "multiple values for min_duration",
13259                                    ));
13260                                }
13261                                result.min_duration =
13262                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
13263                            }
13264                            __FieldTag::Unknown(key) => {
13265                                let value = map.next_value::<serde_json::Value>()?;
13266                                result._unknown_fields.insert(key, value);
13267                            }
13268                        }
13269                    }
13270                    std::result::Result::Ok(result)
13271                }
13272            }
13273            deserializer.deserialize_any(Visitor)
13274        }
13275    }
13276
13277    #[doc(hidden)]
13278    impl serde::ser::Serialize for BreakRequest {
13279        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13280        where
13281            S: serde::ser::Serializer,
13282        {
13283            use serde::ser::SerializeMap;
13284            #[allow(unused_imports)]
13285            use std::option::Option::Some;
13286            let mut state = serializer.serialize_map(std::option::Option::None)?;
13287            if self.earliest_start_time.is_some() {
13288                state.serialize_entry("earliestStartTime", &self.earliest_start_time)?;
13289            }
13290            if self.latest_start_time.is_some() {
13291                state.serialize_entry("latestStartTime", &self.latest_start_time)?;
13292            }
13293            if self.min_duration.is_some() {
13294                state.serialize_entry("minDuration", &self.min_duration)?;
13295            }
13296            if !self._unknown_fields.is_empty() {
13297                for (key, value) in self._unknown_fields.iter() {
13298                    state.serialize_entry(key, &value)?;
13299                }
13300            }
13301            state.end()
13302        }
13303    }
13304
13305    /// One may further constrain the frequency and duration of the breaks
13306    /// specified above, by enforcing a minimum break frequency, such as
13307    /// "There must be a break of at least 1 hour every 12 hours". Assuming that
13308    /// this can be interpreted as "Within any sliding time window of 12h, there
13309    /// must be at least one break of at least one hour", that example would
13310    /// translate to the following `FrequencyConstraint`:
13311    ///
13312    /// ```norust
13313    /// {
13314    ///    min_break_duration { seconds: 3600 }         # 1 hour.
13315    ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
13316    /// }
13317    /// ```
13318    ///
13319    /// The timing and duration of the breaks in the solution will respect all
13320    /// such constraints, in addition to the time windows and minimum durations
13321    /// already specified in the `BreakRequest`.
13322    ///
13323    /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
13324    /// For example, the following schedule honors the "1h every 12h" example:
13325    ///
13326    /// ```norust
13327    ///   04:00 vehicle start
13328    ///    .. performing travel and visits ..
13329    ///   09:00 1 hour break
13330    ///   10:00 end of the break
13331    ///    .. performing travel and visits ..
13332    ///   12:00 20-min lunch break
13333    ///   12:20 end of the break
13334    ///    .. performing travel and visits ..
13335    ///   21:00 1 hour break
13336    ///   22:00 end of the break
13337    ///    .. performing travel and visits ..
13338    ///   23:59 vehicle end
13339    /// ```
13340    #[derive(Clone, Debug, Default, PartialEq)]
13341    #[non_exhaustive]
13342    pub struct FrequencyConstraint {
13343        /// Required. Minimum break duration for this constraint. Nonnegative.
13344        /// See description of `FrequencyConstraint`.
13345        pub min_break_duration: std::option::Option<wkt::Duration>,
13346
13347        /// Required. Maximum allowed span of any interval of time in the route that
13348        /// does not include at least partially a break of `duration >=
13349        /// min_break_duration`. Must be positive.
13350        pub max_inter_break_duration: std::option::Option<wkt::Duration>,
13351
13352        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13353    }
13354
13355    impl FrequencyConstraint {
13356        pub fn new() -> Self {
13357            std::default::Default::default()
13358        }
13359
13360        /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
13361        pub fn set_min_break_duration<T>(mut self, v: T) -> Self
13362        where
13363            T: std::convert::Into<wkt::Duration>,
13364        {
13365            self.min_break_duration = std::option::Option::Some(v.into());
13366            self
13367        }
13368
13369        /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
13370        pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
13371        where
13372            T: std::convert::Into<wkt::Duration>,
13373        {
13374            self.min_break_duration = v.map(|x| x.into());
13375            self
13376        }
13377
13378        /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
13379        pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
13380        where
13381            T: std::convert::Into<wkt::Duration>,
13382        {
13383            self.max_inter_break_duration = std::option::Option::Some(v.into());
13384            self
13385        }
13386
13387        /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
13388        pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
13389        where
13390            T: std::convert::Into<wkt::Duration>,
13391        {
13392            self.max_inter_break_duration = v.map(|x| x.into());
13393            self
13394        }
13395    }
13396
13397    impl wkt::message::Message for FrequencyConstraint {
13398        fn typename() -> &'static str {
13399            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
13400        }
13401    }
13402
13403    #[doc(hidden)]
13404    impl<'de> serde::de::Deserialize<'de> for FrequencyConstraint {
13405        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13406        where
13407            D: serde::Deserializer<'de>,
13408        {
13409            #[allow(non_camel_case_types)]
13410            #[doc(hidden)]
13411            #[derive(PartialEq, Eq, Hash)]
13412            enum __FieldTag {
13413                __min_break_duration,
13414                __max_inter_break_duration,
13415                Unknown(std::string::String),
13416            }
13417            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13418                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13419                where
13420                    D: serde::Deserializer<'de>,
13421                {
13422                    struct Visitor;
13423                    impl<'de> serde::de::Visitor<'de> for Visitor {
13424                        type Value = __FieldTag;
13425                        fn expecting(
13426                            &self,
13427                            formatter: &mut std::fmt::Formatter,
13428                        ) -> std::fmt::Result {
13429                            formatter.write_str("a field name for FrequencyConstraint")
13430                        }
13431                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13432                        where
13433                            E: serde::de::Error,
13434                        {
13435                            use std::result::Result::Ok;
13436                            use std::string::ToString;
13437                            match value {
13438                                "minBreakDuration" => Ok(__FieldTag::__min_break_duration),
13439                                "min_break_duration" => Ok(__FieldTag::__min_break_duration),
13440                                "maxInterBreakDuration" => {
13441                                    Ok(__FieldTag::__max_inter_break_duration)
13442                                }
13443                                "max_inter_break_duration" => {
13444                                    Ok(__FieldTag::__max_inter_break_duration)
13445                                }
13446                                _ => Ok(__FieldTag::Unknown(value.to_string())),
13447                            }
13448                        }
13449                    }
13450                    deserializer.deserialize_identifier(Visitor)
13451                }
13452            }
13453            struct Visitor;
13454            impl<'de> serde::de::Visitor<'de> for Visitor {
13455                type Value = FrequencyConstraint;
13456                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13457                    formatter.write_str("struct FrequencyConstraint")
13458                }
13459                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13460                where
13461                    A: serde::de::MapAccess<'de>,
13462                {
13463                    #[allow(unused_imports)]
13464                    use serde::de::Error;
13465                    use std::option::Option::Some;
13466                    let mut fields = std::collections::HashSet::new();
13467                    let mut result = Self::Value::new();
13468                    while let Some(tag) = map.next_key::<__FieldTag>()? {
13469                        #[allow(clippy::match_single_binding)]
13470                        match tag {
13471                            __FieldTag::__min_break_duration => {
13472                                if !fields.insert(__FieldTag::__min_break_duration) {
13473                                    return std::result::Result::Err(A::Error::duplicate_field(
13474                                        "multiple values for min_break_duration",
13475                                    ));
13476                                }
13477                                result.min_break_duration =
13478                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
13479                            }
13480                            __FieldTag::__max_inter_break_duration => {
13481                                if !fields.insert(__FieldTag::__max_inter_break_duration) {
13482                                    return std::result::Result::Err(A::Error::duplicate_field(
13483                                        "multiple values for max_inter_break_duration",
13484                                    ));
13485                                }
13486                                result.max_inter_break_duration =
13487                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
13488                            }
13489                            __FieldTag::Unknown(key) => {
13490                                let value = map.next_value::<serde_json::Value>()?;
13491                                result._unknown_fields.insert(key, value);
13492                            }
13493                        }
13494                    }
13495                    std::result::Result::Ok(result)
13496                }
13497            }
13498            deserializer.deserialize_any(Visitor)
13499        }
13500    }
13501
13502    #[doc(hidden)]
13503    impl serde::ser::Serialize for FrequencyConstraint {
13504        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13505        where
13506            S: serde::ser::Serializer,
13507        {
13508            use serde::ser::SerializeMap;
13509            #[allow(unused_imports)]
13510            use std::option::Option::Some;
13511            let mut state = serializer.serialize_map(std::option::Option::None)?;
13512            if self.min_break_duration.is_some() {
13513                state.serialize_entry("minBreakDuration", &self.min_break_duration)?;
13514            }
13515            if self.max_inter_break_duration.is_some() {
13516                state.serialize_entry("maxInterBreakDuration", &self.max_inter_break_duration)?;
13517            }
13518            if !self._unknown_fields.is_empty() {
13519                for (key, value) in self._unknown_fields.iter() {
13520                    state.serialize_entry(key, &value)?;
13521                }
13522            }
13523            state.end()
13524        }
13525    }
13526}
13527
13528/// A vehicle's route can be decomposed, along the time axis, like this (we
13529/// assume there are n visits):
13530///
13531/// ```norust
13532///   |            |            |          |       |  T[2], |        |      |
13533///   | Transition |  Visit #0  |          |       |  V[2], |        |      |
13534///   |     #0     |    aka     |   T[1]   |  V[1] |  ...   | V[n-1] | T[n] |
13535///   |  aka T[0]  |    V[0]    |          |       | V[n-2],|        |      |
13536///   |            |            |          |       | T[n-1] |        |      |
13537///   ^            ^            ^          ^       ^        ^        ^      ^
13538/// vehicle    V[0].start   V[0].end     V[1].   V[1].    V[n].    V[n]. vehicle
13539///  start     (arrival)   (departure)   start   end      start    end     end
13540/// ```
13541///
13542/// Note that we make a difference between:
13543///
13544/// * "punctual events", such as the vehicle start and end and each visit's start
13545///   and end (aka arrival and departure). They happen at a given second.
13546/// * "time intervals", such as the visits themselves, and the transition between
13547///   visits. Though time intervals can sometimes have zero duration, i.e. start
13548///   and end at the same second, they often have a positive duration.
13549///
13550/// Invariants:
13551///
13552/// * If there are n visits, there are n+1 transitions.
13553/// * A visit is always surrounded by a transition before it (same index) and a
13554///   transition after it (index + 1).
13555/// * The vehicle start is always followed by transition #0.
13556/// * The vehicle end is always preceded by transition #n.
13557///
13558/// Zooming in, here is what happens during a `Transition` and a `Visit`:
13559///
13560/// ```norust
13561/// ---+-------------------------------------+-----------------------------+-->
13562///    |           TRANSITION[i]             |           VISIT[i]          |
13563///    |                                     |                             |
13564///    |  * TRAVEL: the vehicle moves from   |      PERFORM the visit:     |
13565///    |    VISIT[i-1].departure_location to |                             |
13566///    |    VISIT[i].arrival_location, which |  * Spend some time:         |
13567///    |    takes a given travel duration    |    the "visit duration".    |
13568///    |    and distance                     |                             |
13569///    |                                     |  * Load or unload           |
13570///    |  * BREAKS: the driver may have      |    some quantities from the |
13571///    |    breaks (e.g. lunch break).       |    vehicle: the "demand".   |
13572///    |                                     |                             |
13573///    |  * WAIT: the driver/vehicle does    |                             |
13574///    |    nothing. This can happen for     |                             |
13575///    |    many reasons, for example when   |                             |
13576///    |    the vehicle reaches the next     |                             |
13577///    |    event's destination before the   |                             |
13578///    |    start of its time window         |                             |
13579///    |                                     |                             |
13580///    |  * DELAY: *right before* the next   |                             |
13581///    |    arrival. E.g. the vehicle and/or |                             |
13582///    |    driver spends time unloading.    |                             |
13583///    |                                     |                             |
13584/// ---+-------------------------------------+-----------------------------+-->
13585///    ^                                     ^                             ^
13586/// V[i-1].end                           V[i].start                    V[i].end
13587/// ```
13588///
13589/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
13590/// during a transition.
13591///
13592/// * They don't overlap.
13593/// * The DELAY is unique and *must* be a contiguous period of time right
13594///   before the next visit (or vehicle end). Thus, it suffice to know the
13595///   delay duration to know its start and end time.
13596/// * The BREAKS are contiguous, non-overlapping periods of time. The
13597///   response specifies the start time and duration of each break.
13598/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
13599///   during this transition. Clients can assume that travel happens "as soon as
13600///   possible" and that "wait" fills the remaining time.
13601///
13602/// A (complex) example:
13603///
13604/// ```norust
13605///                                TRANSITION[i]
13606/// --++-----+-----------------------------------------------------------++-->
13607///   ||     |       |           |       |           |         |         ||
13608///   ||  T  |   B   |     T     |       |     B     |         |    D    ||
13609///   ||  r  |   r   |     r     |   W   |     r     |    W    |    e    ||
13610///   ||  a  |   e   |     a     |   a   |     e     |    a    |    l    ||
13611///   ||  v  |   a   |     v     |   i   |     a     |    i    |    a    ||
13612///   ||  e  |   k   |     e     |   t   |     k     |    t    |    y    ||
13613///   ||  l  |       |     l     |       |           |         |         ||
13614///   ||     |       |           |       |           |         |         ||
13615/// --++-----------------------------------------------------------------++-->
13616/// ```
13617#[derive(Clone, Debug, Default, PartialEq)]
13618#[non_exhaustive]
13619pub struct ShipmentRoute {
13620    /// Vehicle performing the route, identified by its index in the source
13621    /// `ShipmentModel`.
13622    pub vehicle_index: i32,
13623
13624    /// Label of the vehicle performing this route, equal to
13625    /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
13626    pub vehicle_label: std::string::String,
13627
13628    /// Time at which the vehicle starts its route.
13629    pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
13630
13631    /// Time at which the vehicle finishes its route.
13632    pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
13633
13634    /// Ordered sequence of visits representing a route.
13635    /// visits[i] is the i-th visit in the route.
13636    /// If this field is empty, the vehicle is considered as unused.
13637    pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
13638
13639    /// Ordered list of transitions for the route.
13640    pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
13641
13642    /// When
13643    /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
13644    /// is set to true, this field indicates that inconsistencies in route timings
13645    /// are predicted using traffic-based travel duration estimates. There may be
13646    /// insufficient time to complete traffic-adjusted travel, delays, and breaks
13647    /// between visits, before the first visit, or after the last visit, while
13648    /// still satisfying the visit and vehicle time windows. For example,
13649    ///
13650    /// ```norust
13651    ///   start_time(previous_visit) + duration(previous_visit) +
13652    ///   travel_duration(previous_visit, next_visit) > start_time(next_visit)
13653    /// ```
13654    ///
13655    /// Arrival at next_visit will likely happen later than its current
13656    /// time window due the increased estimate of travel time
13657    /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
13658    /// may be forced to overlap with a visit due to an increase in travel time
13659    /// estimates and visit or break time window restrictions.
13660    ///
13661    /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
13662    pub has_traffic_infeasibilities: bool,
13663
13664    /// The encoded polyline representation of the route.
13665    /// This field is only populated if
13666    /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
13667    /// is set to true.
13668    ///
13669    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
13670    pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
13671
13672    /// Breaks scheduled for the vehicle performing this route.
13673    /// The `breaks` sequence represents time intervals, each starting at the
13674    /// corresponding `start_time` and lasting `duration` seconds.
13675    pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
13676
13677    /// Duration, distance and load metrics for this route. The fields of
13678    /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
13679    /// summed over all
13680    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
13681    /// or
13682    /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
13683    /// depending on the context.
13684    ///
13685    /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
13686    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
13687    /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
13688    pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
13689
13690    /// Cost of the route, broken down by cost-related request fields.
13691    /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
13692    /// "model.shipments.pickups.cost", and the values are the total cost
13693    /// generated by the corresponding cost field, aggregated over the whole route.
13694    /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
13695    /// pickup costs over the route. All costs defined in the model are reported in
13696    /// detail here with the exception of costs related to TransitionAttributes
13697    /// that are only reported in an aggregated way as of 2022/01.
13698    pub route_costs: std::collections::HashMap<std::string::String, f64>,
13699
13700    /// Total cost of the route. The sum of all costs in the cost map.
13701    pub route_total_cost: f64,
13702
13703    /// Deprecated: Use
13704    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
13705    /// instead. Vehicle loads upon arrival at its end location, for each type
13706    /// specified in
13707    /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
13708    /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
13709    /// loads for quantity types unconstrained by intervals and that don't have any
13710    /// non-zero demand on the route.
13711    ///
13712    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
13713    /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
13714    #[deprecated]
13715    pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
13716
13717    /// Deprecated: Use
13718    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
13719    /// instead. Ordered list of travel steps for the route.
13720    ///
13721    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
13722    #[deprecated]
13723    pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
13724
13725    /// Deprecated: No longer used.
13726    /// This field will only be populated at the
13727    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
13728    /// level.
13729    ///
13730    /// This field is the extra detour time due to the shipments visited on the
13731    /// route.
13732    ///
13733    /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
13734    /// from the vehicle's start_location to its `end_location`.
13735    ///
13736    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
13737    #[deprecated]
13738    pub vehicle_detour: std::option::Option<wkt::Duration>,
13739
13740    /// Deprecated: Delay occurring before the vehicle end. See
13741    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
13742    ///
13743    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
13744    #[deprecated]
13745    pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
13746
13747    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13748}
13749
13750impl ShipmentRoute {
13751    pub fn new() -> Self {
13752        std::default::Default::default()
13753    }
13754
13755    /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
13756    pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
13757        self.vehicle_index = v.into();
13758        self
13759    }
13760
13761    /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
13762    pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13763        self.vehicle_label = v.into();
13764        self
13765    }
13766
13767    /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
13768    pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
13769    where
13770        T: std::convert::Into<wkt::Timestamp>,
13771    {
13772        self.vehicle_start_time = std::option::Option::Some(v.into());
13773        self
13774    }
13775
13776    /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
13777    pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
13778    where
13779        T: std::convert::Into<wkt::Timestamp>,
13780    {
13781        self.vehicle_start_time = v.map(|x| x.into());
13782        self
13783    }
13784
13785    /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
13786    pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
13787    where
13788        T: std::convert::Into<wkt::Timestamp>,
13789    {
13790        self.vehicle_end_time = std::option::Option::Some(v.into());
13791        self
13792    }
13793
13794    /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
13795    pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
13796    where
13797        T: std::convert::Into<wkt::Timestamp>,
13798    {
13799        self.vehicle_end_time = v.map(|x| x.into());
13800        self
13801    }
13802
13803    /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
13804    pub fn set_visits<T, V>(mut self, v: T) -> Self
13805    where
13806        T: std::iter::IntoIterator<Item = V>,
13807        V: std::convert::Into<crate::model::shipment_route::Visit>,
13808    {
13809        use std::iter::Iterator;
13810        self.visits = v.into_iter().map(|i| i.into()).collect();
13811        self
13812    }
13813
13814    /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
13815    pub fn set_transitions<T, V>(mut self, v: T) -> Self
13816    where
13817        T: std::iter::IntoIterator<Item = V>,
13818        V: std::convert::Into<crate::model::shipment_route::Transition>,
13819    {
13820        use std::iter::Iterator;
13821        self.transitions = v.into_iter().map(|i| i.into()).collect();
13822        self
13823    }
13824
13825    /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
13826    pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
13827        self.has_traffic_infeasibilities = v.into();
13828        self
13829    }
13830
13831    /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
13832    pub fn set_route_polyline<T>(mut self, v: T) -> Self
13833    where
13834        T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
13835    {
13836        self.route_polyline = std::option::Option::Some(v.into());
13837        self
13838    }
13839
13840    /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
13841    pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
13842    where
13843        T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
13844    {
13845        self.route_polyline = v.map(|x| x.into());
13846        self
13847    }
13848
13849    /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
13850    pub fn set_breaks<T, V>(mut self, v: T) -> Self
13851    where
13852        T: std::iter::IntoIterator<Item = V>,
13853        V: std::convert::Into<crate::model::shipment_route::Break>,
13854    {
13855        use std::iter::Iterator;
13856        self.breaks = v.into_iter().map(|i| i.into()).collect();
13857        self
13858    }
13859
13860    /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
13861    pub fn set_metrics<T>(mut self, v: T) -> Self
13862    where
13863        T: std::convert::Into<crate::model::AggregatedMetrics>,
13864    {
13865        self.metrics = std::option::Option::Some(v.into());
13866        self
13867    }
13868
13869    /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
13870    pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
13871    where
13872        T: std::convert::Into<crate::model::AggregatedMetrics>,
13873    {
13874        self.metrics = v.map(|x| x.into());
13875        self
13876    }
13877
13878    /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
13879    pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
13880    where
13881        T: std::iter::IntoIterator<Item = (K, V)>,
13882        K: std::convert::Into<std::string::String>,
13883        V: std::convert::Into<f64>,
13884    {
13885        use std::iter::Iterator;
13886        self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
13887        self
13888    }
13889
13890    /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
13891    pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
13892        self.route_total_cost = v.into();
13893        self
13894    }
13895
13896    /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
13897    #[deprecated]
13898    pub fn set_end_loads<T, V>(mut self, v: T) -> Self
13899    where
13900        T: std::iter::IntoIterator<Item = V>,
13901        V: std::convert::Into<crate::model::CapacityQuantity>,
13902    {
13903        use std::iter::Iterator;
13904        self.end_loads = v.into_iter().map(|i| i.into()).collect();
13905        self
13906    }
13907
13908    /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
13909    #[deprecated]
13910    pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
13911    where
13912        T: std::iter::IntoIterator<Item = V>,
13913        V: std::convert::Into<crate::model::shipment_route::TravelStep>,
13914    {
13915        use std::iter::Iterator;
13916        self.travel_steps = v.into_iter().map(|i| i.into()).collect();
13917        self
13918    }
13919
13920    /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
13921    #[deprecated]
13922    pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
13923    where
13924        T: std::convert::Into<wkt::Duration>,
13925    {
13926        self.vehicle_detour = std::option::Option::Some(v.into());
13927        self
13928    }
13929
13930    /// Sets or clears the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
13931    #[deprecated]
13932    pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
13933    where
13934        T: std::convert::Into<wkt::Duration>,
13935    {
13936        self.vehicle_detour = v.map(|x| x.into());
13937        self
13938    }
13939
13940    /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
13941    #[deprecated]
13942    pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
13943    where
13944        T: std::convert::Into<crate::model::shipment_route::Delay>,
13945    {
13946        self.delay_before_vehicle_end = std::option::Option::Some(v.into());
13947        self
13948    }
13949
13950    /// Sets or clears the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
13951    #[deprecated]
13952    pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
13953    where
13954        T: std::convert::Into<crate::model::shipment_route::Delay>,
13955    {
13956        self.delay_before_vehicle_end = v.map(|x| x.into());
13957        self
13958    }
13959}
13960
13961impl wkt::message::Message for ShipmentRoute {
13962    fn typename() -> &'static str {
13963        "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
13964    }
13965}
13966
13967#[doc(hidden)]
13968impl<'de> serde::de::Deserialize<'de> for ShipmentRoute {
13969    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13970    where
13971        D: serde::Deserializer<'de>,
13972    {
13973        #[allow(non_camel_case_types)]
13974        #[doc(hidden)]
13975        #[derive(PartialEq, Eq, Hash)]
13976        enum __FieldTag {
13977            __vehicle_index,
13978            __vehicle_label,
13979            __vehicle_start_time,
13980            __vehicle_end_time,
13981            __visits,
13982            __transitions,
13983            __has_traffic_infeasibilities,
13984            __route_polyline,
13985            __breaks,
13986            __metrics,
13987            __route_costs,
13988            __route_total_cost,
13989            __end_loads,
13990            __travel_steps,
13991            __vehicle_detour,
13992            __delay_before_vehicle_end,
13993            Unknown(std::string::String),
13994        }
13995        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13996            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13997            where
13998                D: serde::Deserializer<'de>,
13999            {
14000                struct Visitor;
14001                impl<'de> serde::de::Visitor<'de> for Visitor {
14002                    type Value = __FieldTag;
14003                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14004                        formatter.write_str("a field name for ShipmentRoute")
14005                    }
14006                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14007                    where
14008                        E: serde::de::Error,
14009                    {
14010                        use std::result::Result::Ok;
14011                        use std::string::ToString;
14012                        match value {
14013                            "vehicleIndex" => Ok(__FieldTag::__vehicle_index),
14014                            "vehicle_index" => Ok(__FieldTag::__vehicle_index),
14015                            "vehicleLabel" => Ok(__FieldTag::__vehicle_label),
14016                            "vehicle_label" => Ok(__FieldTag::__vehicle_label),
14017                            "vehicleStartTime" => Ok(__FieldTag::__vehicle_start_time),
14018                            "vehicle_start_time" => Ok(__FieldTag::__vehicle_start_time),
14019                            "vehicleEndTime" => Ok(__FieldTag::__vehicle_end_time),
14020                            "vehicle_end_time" => Ok(__FieldTag::__vehicle_end_time),
14021                            "visits" => Ok(__FieldTag::__visits),
14022                            "transitions" => Ok(__FieldTag::__transitions),
14023                            "hasTrafficInfeasibilities" => {
14024                                Ok(__FieldTag::__has_traffic_infeasibilities)
14025                            }
14026                            "has_traffic_infeasibilities" => {
14027                                Ok(__FieldTag::__has_traffic_infeasibilities)
14028                            }
14029                            "routePolyline" => Ok(__FieldTag::__route_polyline),
14030                            "route_polyline" => Ok(__FieldTag::__route_polyline),
14031                            "breaks" => Ok(__FieldTag::__breaks),
14032                            "metrics" => Ok(__FieldTag::__metrics),
14033                            "routeCosts" => Ok(__FieldTag::__route_costs),
14034                            "route_costs" => Ok(__FieldTag::__route_costs),
14035                            "routeTotalCost" => Ok(__FieldTag::__route_total_cost),
14036                            "route_total_cost" => Ok(__FieldTag::__route_total_cost),
14037                            "endLoads" => Ok(__FieldTag::__end_loads),
14038                            "end_loads" => Ok(__FieldTag::__end_loads),
14039                            "travelSteps" => Ok(__FieldTag::__travel_steps),
14040                            "travel_steps" => Ok(__FieldTag::__travel_steps),
14041                            "vehicleDetour" => Ok(__FieldTag::__vehicle_detour),
14042                            "vehicle_detour" => Ok(__FieldTag::__vehicle_detour),
14043                            "delayBeforeVehicleEnd" => Ok(__FieldTag::__delay_before_vehicle_end),
14044                            "delay_before_vehicle_end" => {
14045                                Ok(__FieldTag::__delay_before_vehicle_end)
14046                            }
14047                            _ => Ok(__FieldTag::Unknown(value.to_string())),
14048                        }
14049                    }
14050                }
14051                deserializer.deserialize_identifier(Visitor)
14052            }
14053        }
14054        struct Visitor;
14055        impl<'de> serde::de::Visitor<'de> for Visitor {
14056            type Value = ShipmentRoute;
14057            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14058                formatter.write_str("struct ShipmentRoute")
14059            }
14060            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14061            where
14062                A: serde::de::MapAccess<'de>,
14063            {
14064                #[allow(unused_imports)]
14065                use serde::de::Error;
14066                use std::option::Option::Some;
14067                let mut fields = std::collections::HashSet::new();
14068                let mut result = Self::Value::new();
14069                while let Some(tag) = map.next_key::<__FieldTag>()? {
14070                    #[allow(clippy::match_single_binding)]
14071                    match tag {
14072                        __FieldTag::__vehicle_index => {
14073                            if !fields.insert(__FieldTag::__vehicle_index) {
14074                                return std::result::Result::Err(A::Error::duplicate_field(
14075                                    "multiple values for vehicle_index",
14076                                ));
14077                            }
14078                            struct __With(std::option::Option<i32>);
14079                            impl<'de> serde::de::Deserialize<'de> for __With {
14080                                fn deserialize<D>(
14081                                    deserializer: D,
14082                                ) -> std::result::Result<Self, D::Error>
14083                                where
14084                                    D: serde::de::Deserializer<'de>,
14085                                {
14086                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
14087                                }
14088                            }
14089                            result.vehicle_index =
14090                                map.next_value::<__With>()?.0.unwrap_or_default();
14091                        }
14092                        __FieldTag::__vehicle_label => {
14093                            if !fields.insert(__FieldTag::__vehicle_label) {
14094                                return std::result::Result::Err(A::Error::duplicate_field(
14095                                    "multiple values for vehicle_label",
14096                                ));
14097                            }
14098                            result.vehicle_label = map
14099                                .next_value::<std::option::Option<std::string::String>>()?
14100                                .unwrap_or_default();
14101                        }
14102                        __FieldTag::__vehicle_start_time => {
14103                            if !fields.insert(__FieldTag::__vehicle_start_time) {
14104                                return std::result::Result::Err(A::Error::duplicate_field(
14105                                    "multiple values for vehicle_start_time",
14106                                ));
14107                            }
14108                            result.vehicle_start_time =
14109                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14110                        }
14111                        __FieldTag::__vehicle_end_time => {
14112                            if !fields.insert(__FieldTag::__vehicle_end_time) {
14113                                return std::result::Result::Err(A::Error::duplicate_field(
14114                                    "multiple values for vehicle_end_time",
14115                                ));
14116                            }
14117                            result.vehicle_end_time =
14118                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14119                        }
14120                        __FieldTag::__visits => {
14121                            if !fields.insert(__FieldTag::__visits) {
14122                                return std::result::Result::Err(A::Error::duplicate_field(
14123                                    "multiple values for visits",
14124                                ));
14125                            }
14126                            result.visits = map
14127                                .next_value::<std::option::Option<
14128                                    std::vec::Vec<crate::model::shipment_route::Visit>,
14129                                >>()?
14130                                .unwrap_or_default();
14131                        }
14132                        __FieldTag::__transitions => {
14133                            if !fields.insert(__FieldTag::__transitions) {
14134                                return std::result::Result::Err(A::Error::duplicate_field(
14135                                    "multiple values for transitions",
14136                                ));
14137                            }
14138                            result.transitions = map
14139                                .next_value::<std::option::Option<
14140                                    std::vec::Vec<crate::model::shipment_route::Transition>,
14141                                >>()?
14142                                .unwrap_or_default();
14143                        }
14144                        __FieldTag::__has_traffic_infeasibilities => {
14145                            if !fields.insert(__FieldTag::__has_traffic_infeasibilities) {
14146                                return std::result::Result::Err(A::Error::duplicate_field(
14147                                    "multiple values for has_traffic_infeasibilities",
14148                                ));
14149                            }
14150                            result.has_traffic_infeasibilities = map
14151                                .next_value::<std::option::Option<bool>>()?
14152                                .unwrap_or_default();
14153                        }
14154                        __FieldTag::__route_polyline => {
14155                            if !fields.insert(__FieldTag::__route_polyline) {
14156                                return std::result::Result::Err(A::Error::duplicate_field(
14157                                    "multiple values for route_polyline",
14158                                ));
14159                            }
14160                            result.route_polyline = map.next_value::<std::option::Option<
14161                                crate::model::shipment_route::EncodedPolyline,
14162                            >>()?;
14163                        }
14164                        __FieldTag::__breaks => {
14165                            if !fields.insert(__FieldTag::__breaks) {
14166                                return std::result::Result::Err(A::Error::duplicate_field(
14167                                    "multiple values for breaks",
14168                                ));
14169                            }
14170                            result.breaks = map
14171                                .next_value::<std::option::Option<
14172                                    std::vec::Vec<crate::model::shipment_route::Break>,
14173                                >>()?
14174                                .unwrap_or_default();
14175                        }
14176                        __FieldTag::__metrics => {
14177                            if !fields.insert(__FieldTag::__metrics) {
14178                                return std::result::Result::Err(A::Error::duplicate_field(
14179                                    "multiple values for metrics",
14180                                ));
14181                            }
14182                            result.metrics = map
14183                                .next_value::<std::option::Option<crate::model::AggregatedMetrics>>(
14184                                )?;
14185                        }
14186                        __FieldTag::__route_costs => {
14187                            if !fields.insert(__FieldTag::__route_costs) {
14188                                return std::result::Result::Err(A::Error::duplicate_field(
14189                                    "multiple values for route_costs",
14190                                ));
14191                            }
14192                            struct __With(
14193                                std::option::Option<
14194                                    std::collections::HashMap<std::string::String, f64>,
14195                                >,
14196                            );
14197                            impl<'de> serde::de::Deserialize<'de> for __With {
14198                                fn deserialize<D>(
14199                                    deserializer: D,
14200                                ) -> std::result::Result<Self, D::Error>
14201                                where
14202                                    D: serde::de::Deserializer<'de>,
14203                                {
14204                                    serde_with::As::<
14205                                        std::option::Option<
14206                                            std::collections::HashMap<
14207                                                serde_with::Same,
14208                                                wkt::internal::F64,
14209                                            >,
14210                                        >,
14211                                    >::deserialize(deserializer)
14212                                    .map(__With)
14213                                }
14214                            }
14215                            result.route_costs = map.next_value::<__With>()?.0.unwrap_or_default();
14216                        }
14217                        __FieldTag::__route_total_cost => {
14218                            if !fields.insert(__FieldTag::__route_total_cost) {
14219                                return std::result::Result::Err(A::Error::duplicate_field(
14220                                    "multiple values for route_total_cost",
14221                                ));
14222                            }
14223                            struct __With(std::option::Option<f64>);
14224                            impl<'de> serde::de::Deserialize<'de> for __With {
14225                                fn deserialize<D>(
14226                                    deserializer: D,
14227                                ) -> std::result::Result<Self, D::Error>
14228                                where
14229                                    D: serde::de::Deserializer<'de>,
14230                                {
14231                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
14232                                }
14233                            }
14234                            result.route_total_cost =
14235                                map.next_value::<__With>()?.0.unwrap_or_default();
14236                        }
14237                        __FieldTag::__end_loads => {
14238                            if !fields.insert(__FieldTag::__end_loads) {
14239                                return std::result::Result::Err(A::Error::duplicate_field(
14240                                    "multiple values for end_loads",
14241                                ));
14242                            }
14243                            result.end_loads =
14244                                map.next_value::<std::option::Option<
14245                                    std::vec::Vec<crate::model::CapacityQuantity>,
14246                                >>()?
14247                                .unwrap_or_default();
14248                        }
14249                        __FieldTag::__travel_steps => {
14250                            if !fields.insert(__FieldTag::__travel_steps) {
14251                                return std::result::Result::Err(A::Error::duplicate_field(
14252                                    "multiple values for travel_steps",
14253                                ));
14254                            }
14255                            result.travel_steps = map
14256                                .next_value::<std::option::Option<
14257                                    std::vec::Vec<crate::model::shipment_route::TravelStep>,
14258                                >>()?
14259                                .unwrap_or_default();
14260                        }
14261                        __FieldTag::__vehicle_detour => {
14262                            if !fields.insert(__FieldTag::__vehicle_detour) {
14263                                return std::result::Result::Err(A::Error::duplicate_field(
14264                                    "multiple values for vehicle_detour",
14265                                ));
14266                            }
14267                            result.vehicle_detour =
14268                                map.next_value::<std::option::Option<wkt::Duration>>()?;
14269                        }
14270                        __FieldTag::__delay_before_vehicle_end => {
14271                            if !fields.insert(__FieldTag::__delay_before_vehicle_end) {
14272                                return std::result::Result::Err(A::Error::duplicate_field(
14273                                    "multiple values for delay_before_vehicle_end",
14274                                ));
14275                            }
14276                            result.delay_before_vehicle_end = map.next_value::<std::option::Option<crate::model::shipment_route::Delay>>()?
14277                                ;
14278                        }
14279                        __FieldTag::Unknown(key) => {
14280                            let value = map.next_value::<serde_json::Value>()?;
14281                            result._unknown_fields.insert(key, value);
14282                        }
14283                    }
14284                }
14285                std::result::Result::Ok(result)
14286            }
14287        }
14288        deserializer.deserialize_any(Visitor)
14289    }
14290}
14291
14292#[doc(hidden)]
14293impl serde::ser::Serialize for ShipmentRoute {
14294    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14295    where
14296        S: serde::ser::Serializer,
14297    {
14298        use serde::ser::SerializeMap;
14299        #[allow(unused_imports)]
14300        use std::option::Option::Some;
14301        let mut state = serializer.serialize_map(std::option::Option::None)?;
14302        if !wkt::internal::is_default(&self.vehicle_index) {
14303            struct __With<'a>(&'a i32);
14304            impl<'a> serde::ser::Serialize for __With<'a> {
14305                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14306                where
14307                    S: serde::ser::Serializer,
14308                {
14309                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
14310                }
14311            }
14312            state.serialize_entry("vehicleIndex", &__With(&self.vehicle_index))?;
14313        }
14314        if !self.vehicle_label.is_empty() {
14315            state.serialize_entry("vehicleLabel", &self.vehicle_label)?;
14316        }
14317        if self.vehicle_start_time.is_some() {
14318            state.serialize_entry("vehicleStartTime", &self.vehicle_start_time)?;
14319        }
14320        if self.vehicle_end_time.is_some() {
14321            state.serialize_entry("vehicleEndTime", &self.vehicle_end_time)?;
14322        }
14323        if !self.visits.is_empty() {
14324            state.serialize_entry("visits", &self.visits)?;
14325        }
14326        if !self.transitions.is_empty() {
14327            state.serialize_entry("transitions", &self.transitions)?;
14328        }
14329        if !wkt::internal::is_default(&self.has_traffic_infeasibilities) {
14330            state.serialize_entry(
14331                "hasTrafficInfeasibilities",
14332                &self.has_traffic_infeasibilities,
14333            )?;
14334        }
14335        if self.route_polyline.is_some() {
14336            state.serialize_entry("routePolyline", &self.route_polyline)?;
14337        }
14338        if !self.breaks.is_empty() {
14339            state.serialize_entry("breaks", &self.breaks)?;
14340        }
14341        if self.metrics.is_some() {
14342            state.serialize_entry("metrics", &self.metrics)?;
14343        }
14344        if !self.route_costs.is_empty() {
14345            struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
14346            impl<'a> serde::ser::Serialize for __With<'a> {
14347                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14348                where
14349                    S: serde::ser::Serializer,
14350                {
14351                    serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::F64> >::serialize(self.0, serializer)
14352                }
14353            }
14354            state.serialize_entry("routeCosts", &__With(&self.route_costs))?;
14355        }
14356        if !wkt::internal::is_default(&self.route_total_cost) {
14357            struct __With<'a>(&'a f64);
14358            impl<'a> serde::ser::Serialize for __With<'a> {
14359                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14360                where
14361                    S: serde::ser::Serializer,
14362                {
14363                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
14364                }
14365            }
14366            state.serialize_entry("routeTotalCost", &__With(&self.route_total_cost))?;
14367        }
14368        if !self.end_loads.is_empty() {
14369            state.serialize_entry("endLoads", &self.end_loads)?;
14370        }
14371        if !self.travel_steps.is_empty() {
14372            state.serialize_entry("travelSteps", &self.travel_steps)?;
14373        }
14374        if self.vehicle_detour.is_some() {
14375            state.serialize_entry("vehicleDetour", &self.vehicle_detour)?;
14376        }
14377        if self.delay_before_vehicle_end.is_some() {
14378            state.serialize_entry("delayBeforeVehicleEnd", &self.delay_before_vehicle_end)?;
14379        }
14380        if !self._unknown_fields.is_empty() {
14381            for (key, value) in self._unknown_fields.iter() {
14382                state.serialize_entry(key, &value)?;
14383            }
14384        }
14385        state.end()
14386    }
14387}
14388
14389/// Defines additional types related to [ShipmentRoute].
14390pub mod shipment_route {
14391    #[allow(unused_imports)]
14392    use super::*;
14393
14394    /// Deprecated: Use
14395    /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
14396    /// instead. Time interval spent on the route resulting from a
14397    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
14398    ///
14399    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
14400    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
14401    #[derive(Clone, Debug, Default, PartialEq)]
14402    #[non_exhaustive]
14403    #[deprecated]
14404    pub struct Delay {
14405        /// Start of the delay.
14406        pub start_time: std::option::Option<wkt::Timestamp>,
14407
14408        /// Duration of the delay.
14409        pub duration: std::option::Option<wkt::Duration>,
14410
14411        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14412    }
14413
14414    impl Delay {
14415        pub fn new() -> Self {
14416            std::default::Default::default()
14417        }
14418
14419        /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
14420        pub fn set_start_time<T>(mut self, v: T) -> Self
14421        where
14422            T: std::convert::Into<wkt::Timestamp>,
14423        {
14424            self.start_time = std::option::Option::Some(v.into());
14425            self
14426        }
14427
14428        /// Sets or clears the value of [start_time][crate::model::shipment_route::Delay::start_time].
14429        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
14430        where
14431            T: std::convert::Into<wkt::Timestamp>,
14432        {
14433            self.start_time = v.map(|x| x.into());
14434            self
14435        }
14436
14437        /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
14438        pub fn set_duration<T>(mut self, v: T) -> Self
14439        where
14440            T: std::convert::Into<wkt::Duration>,
14441        {
14442            self.duration = std::option::Option::Some(v.into());
14443            self
14444        }
14445
14446        /// Sets or clears the value of [duration][crate::model::shipment_route::Delay::duration].
14447        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
14448        where
14449            T: std::convert::Into<wkt::Duration>,
14450        {
14451            self.duration = v.map(|x| x.into());
14452            self
14453        }
14454    }
14455
14456    impl wkt::message::Message for Delay {
14457        fn typename() -> &'static str {
14458            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
14459        }
14460    }
14461
14462    #[doc(hidden)]
14463    impl<'de> serde::de::Deserialize<'de> for Delay {
14464        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14465        where
14466            D: serde::Deserializer<'de>,
14467        {
14468            #[allow(non_camel_case_types)]
14469            #[doc(hidden)]
14470            #[derive(PartialEq, Eq, Hash)]
14471            enum __FieldTag {
14472                __start_time,
14473                __duration,
14474                Unknown(std::string::String),
14475            }
14476            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14477                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14478                where
14479                    D: serde::Deserializer<'de>,
14480                {
14481                    struct Visitor;
14482                    impl<'de> serde::de::Visitor<'de> for Visitor {
14483                        type Value = __FieldTag;
14484                        fn expecting(
14485                            &self,
14486                            formatter: &mut std::fmt::Formatter,
14487                        ) -> std::fmt::Result {
14488                            formatter.write_str("a field name for Delay")
14489                        }
14490                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14491                        where
14492                            E: serde::de::Error,
14493                        {
14494                            use std::result::Result::Ok;
14495                            use std::string::ToString;
14496                            match value {
14497                                "startTime" => Ok(__FieldTag::__start_time),
14498                                "start_time" => Ok(__FieldTag::__start_time),
14499                                "duration" => Ok(__FieldTag::__duration),
14500                                _ => Ok(__FieldTag::Unknown(value.to_string())),
14501                            }
14502                        }
14503                    }
14504                    deserializer.deserialize_identifier(Visitor)
14505                }
14506            }
14507            struct Visitor;
14508            impl<'de> serde::de::Visitor<'de> for Visitor {
14509                type Value = Delay;
14510                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14511                    formatter.write_str("struct Delay")
14512                }
14513                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14514                where
14515                    A: serde::de::MapAccess<'de>,
14516                {
14517                    #[allow(unused_imports)]
14518                    use serde::de::Error;
14519                    use std::option::Option::Some;
14520                    let mut fields = std::collections::HashSet::new();
14521                    let mut result = Self::Value::new();
14522                    while let Some(tag) = map.next_key::<__FieldTag>()? {
14523                        #[allow(clippy::match_single_binding)]
14524                        match tag {
14525                            __FieldTag::__start_time => {
14526                                if !fields.insert(__FieldTag::__start_time) {
14527                                    return std::result::Result::Err(A::Error::duplicate_field(
14528                                        "multiple values for start_time",
14529                                    ));
14530                                }
14531                                result.start_time =
14532                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14533                            }
14534                            __FieldTag::__duration => {
14535                                if !fields.insert(__FieldTag::__duration) {
14536                                    return std::result::Result::Err(A::Error::duplicate_field(
14537                                        "multiple values for duration",
14538                                    ));
14539                                }
14540                                result.duration =
14541                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
14542                            }
14543                            __FieldTag::Unknown(key) => {
14544                                let value = map.next_value::<serde_json::Value>()?;
14545                                result._unknown_fields.insert(key, value);
14546                            }
14547                        }
14548                    }
14549                    std::result::Result::Ok(result)
14550                }
14551            }
14552            deserializer.deserialize_any(Visitor)
14553        }
14554    }
14555
14556    #[doc(hidden)]
14557    impl serde::ser::Serialize for Delay {
14558        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14559        where
14560            S: serde::ser::Serializer,
14561        {
14562            use serde::ser::SerializeMap;
14563            #[allow(unused_imports)]
14564            use std::option::Option::Some;
14565            let mut state = serializer.serialize_map(std::option::Option::None)?;
14566            if self.start_time.is_some() {
14567                state.serialize_entry("startTime", &self.start_time)?;
14568            }
14569            if self.duration.is_some() {
14570                state.serialize_entry("duration", &self.duration)?;
14571            }
14572            if !self._unknown_fields.is_empty() {
14573                for (key, value) in self._unknown_fields.iter() {
14574                    state.serialize_entry(key, &value)?;
14575                }
14576            }
14577            state.end()
14578        }
14579    }
14580
14581    /// A visit performed during a route. This visit corresponds to a pickup or a
14582    /// delivery of a `Shipment`.
14583    #[derive(Clone, Debug, Default, PartialEq)]
14584    #[non_exhaustive]
14585    pub struct Visit {
14586        /// Index of the `shipments` field in the source
14587        /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
14588        ///
14589        /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
14590        pub shipment_index: i32,
14591
14592        /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
14593        /// corresponds to a delivery.
14594        pub is_pickup: bool,
14595
14596        /// Index of `VisitRequest` in either the pickup or delivery field of the
14597        /// `Shipment` (see `is_pickup`).
14598        pub visit_request_index: i32,
14599
14600        /// Time at which the visit starts. Note that the vehicle may arrive earlier
14601        /// than this at the visit location. Times are consistent with the
14602        /// `ShipmentModel`.
14603        pub start_time: std::option::Option<wkt::Timestamp>,
14604
14605        /// Total visit load demand as the sum of the shipment and the visit request
14606        /// `load_demands`. The values are negative if the visit is a delivery.
14607        /// Demands are reported for the same types as the
14608        /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
14609        /// (see this field).
14610        ///
14611        /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
14612        pub load_demands:
14613            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
14614
14615        /// Extra detour time due to the shipments visited on the route before the
14616        /// visit and to the potential waiting time induced by time windows.
14617        /// If the visit is a delivery, the detour is computed from the corresponding
14618        /// pickup visit and is equal to:
14619        ///
14620        /// ```norust
14621        /// start_time(delivery) - start_time(pickup)
14622        /// - (duration(pickup) + travel duration from the pickup location
14623        /// to the delivery location).
14624        /// ```
14625        ///
14626        /// Otherwise, it is computed from the vehicle `start_location` and is equal
14627        /// to:
14628        ///
14629        /// ```norust
14630        /// start_time - vehicle_start_time - travel duration from
14631        /// the vehicle's `start_location` to the visit.
14632        /// ```
14633        pub detour: std::option::Option<wkt::Duration>,
14634
14635        /// Copy of the corresponding `Shipment.label`, if specified in the
14636        /// `Shipment`.
14637        pub shipment_label: std::string::String,
14638
14639        /// Copy of the corresponding
14640        /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
14641        /// if specified in the `VisitRequest`.
14642        ///
14643        /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
14644        pub visit_label: std::string::String,
14645
14646        /// Deprecated: Use
14647        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
14648        /// instead. Vehicle loads upon arrival at the visit location, for each type
14649        /// specified in
14650        /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
14651        /// `start_load_intervals`, `end_load_intervals` or `demands`.
14652        ///
14653        /// Exception: we omit loads for quantity types unconstrained by intervals
14654        /// and that don't have any non-zero demand on the route.
14655        ///
14656        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
14657        /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
14658        #[deprecated]
14659        pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
14660
14661        /// Deprecated: Use
14662        /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
14663        /// instead. Delay occurring before the visit starts.
14664        ///
14665        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
14666        #[deprecated]
14667        pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
14668
14669        /// Deprecated: Use
14670        /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
14671        /// instead.
14672        ///
14673        /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
14674        #[deprecated]
14675        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
14676
14677        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14678    }
14679
14680    impl Visit {
14681        pub fn new() -> Self {
14682            std::default::Default::default()
14683        }
14684
14685        /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
14686        pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
14687            self.shipment_index = v.into();
14688            self
14689        }
14690
14691        /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
14692        pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
14693            self.is_pickup = v.into();
14694            self
14695        }
14696
14697        /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
14698        pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
14699            self.visit_request_index = v.into();
14700            self
14701        }
14702
14703        /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
14704        pub fn set_start_time<T>(mut self, v: T) -> Self
14705        where
14706            T: std::convert::Into<wkt::Timestamp>,
14707        {
14708            self.start_time = std::option::Option::Some(v.into());
14709            self
14710        }
14711
14712        /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
14713        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
14714        where
14715            T: std::convert::Into<wkt::Timestamp>,
14716        {
14717            self.start_time = v.map(|x| x.into());
14718            self
14719        }
14720
14721        /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
14722        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
14723        where
14724            T: std::iter::IntoIterator<Item = (K, V)>,
14725            K: std::convert::Into<std::string::String>,
14726            V: std::convert::Into<crate::model::shipment::Load>,
14727        {
14728            use std::iter::Iterator;
14729            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
14730            self
14731        }
14732
14733        /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
14734        pub fn set_detour<T>(mut self, v: T) -> Self
14735        where
14736            T: std::convert::Into<wkt::Duration>,
14737        {
14738            self.detour = std::option::Option::Some(v.into());
14739            self
14740        }
14741
14742        /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
14743        pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
14744        where
14745            T: std::convert::Into<wkt::Duration>,
14746        {
14747            self.detour = v.map(|x| x.into());
14748            self
14749        }
14750
14751        /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
14752        pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
14753            mut self,
14754            v: T,
14755        ) -> Self {
14756            self.shipment_label = v.into();
14757            self
14758        }
14759
14760        /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
14761        pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14762            self.visit_label = v.into();
14763            self
14764        }
14765
14766        /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
14767        #[deprecated]
14768        pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
14769        where
14770            T: std::iter::IntoIterator<Item = V>,
14771            V: std::convert::Into<crate::model::CapacityQuantity>,
14772        {
14773            use std::iter::Iterator;
14774            self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
14775            self
14776        }
14777
14778        /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
14779        #[deprecated]
14780        pub fn set_delay_before_start<T>(mut self, v: T) -> Self
14781        where
14782            T: std::convert::Into<crate::model::shipment_route::Delay>,
14783        {
14784            self.delay_before_start = std::option::Option::Some(v.into());
14785            self
14786        }
14787
14788        /// Sets or clears the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
14789        #[deprecated]
14790        pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
14791        where
14792            T: std::convert::Into<crate::model::shipment_route::Delay>,
14793        {
14794            self.delay_before_start = v.map(|x| x.into());
14795            self
14796        }
14797
14798        /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
14799        #[deprecated]
14800        pub fn set_demands<T, V>(mut self, v: T) -> Self
14801        where
14802            T: std::iter::IntoIterator<Item = V>,
14803            V: std::convert::Into<crate::model::CapacityQuantity>,
14804        {
14805            use std::iter::Iterator;
14806            self.demands = v.into_iter().map(|i| i.into()).collect();
14807            self
14808        }
14809    }
14810
14811    impl wkt::message::Message for Visit {
14812        fn typename() -> &'static str {
14813            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
14814        }
14815    }
14816
14817    #[doc(hidden)]
14818    impl<'de> serde::de::Deserialize<'de> for Visit {
14819        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14820        where
14821            D: serde::Deserializer<'de>,
14822        {
14823            #[allow(non_camel_case_types)]
14824            #[doc(hidden)]
14825            #[derive(PartialEq, Eq, Hash)]
14826            enum __FieldTag {
14827                __shipment_index,
14828                __is_pickup,
14829                __visit_request_index,
14830                __start_time,
14831                __load_demands,
14832                __detour,
14833                __shipment_label,
14834                __visit_label,
14835                __arrival_loads,
14836                __delay_before_start,
14837                __demands,
14838                Unknown(std::string::String),
14839            }
14840            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14841                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14842                where
14843                    D: serde::Deserializer<'de>,
14844                {
14845                    struct Visitor;
14846                    impl<'de> serde::de::Visitor<'de> for Visitor {
14847                        type Value = __FieldTag;
14848                        fn expecting(
14849                            &self,
14850                            formatter: &mut std::fmt::Formatter,
14851                        ) -> std::fmt::Result {
14852                            formatter.write_str("a field name for Visit")
14853                        }
14854                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14855                        where
14856                            E: serde::de::Error,
14857                        {
14858                            use std::result::Result::Ok;
14859                            use std::string::ToString;
14860                            match value {
14861                                "shipmentIndex" => Ok(__FieldTag::__shipment_index),
14862                                "shipment_index" => Ok(__FieldTag::__shipment_index),
14863                                "isPickup" => Ok(__FieldTag::__is_pickup),
14864                                "is_pickup" => Ok(__FieldTag::__is_pickup),
14865                                "visitRequestIndex" => Ok(__FieldTag::__visit_request_index),
14866                                "visit_request_index" => Ok(__FieldTag::__visit_request_index),
14867                                "startTime" => Ok(__FieldTag::__start_time),
14868                                "start_time" => Ok(__FieldTag::__start_time),
14869                                "loadDemands" => Ok(__FieldTag::__load_demands),
14870                                "load_demands" => Ok(__FieldTag::__load_demands),
14871                                "detour" => Ok(__FieldTag::__detour),
14872                                "shipmentLabel" => Ok(__FieldTag::__shipment_label),
14873                                "shipment_label" => Ok(__FieldTag::__shipment_label),
14874                                "visitLabel" => Ok(__FieldTag::__visit_label),
14875                                "visit_label" => Ok(__FieldTag::__visit_label),
14876                                "arrivalLoads" => Ok(__FieldTag::__arrival_loads),
14877                                "arrival_loads" => Ok(__FieldTag::__arrival_loads),
14878                                "delayBeforeStart" => Ok(__FieldTag::__delay_before_start),
14879                                "delay_before_start" => Ok(__FieldTag::__delay_before_start),
14880                                "demands" => Ok(__FieldTag::__demands),
14881                                _ => Ok(__FieldTag::Unknown(value.to_string())),
14882                            }
14883                        }
14884                    }
14885                    deserializer.deserialize_identifier(Visitor)
14886                }
14887            }
14888            struct Visitor;
14889            impl<'de> serde::de::Visitor<'de> for Visitor {
14890                type Value = Visit;
14891                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14892                    formatter.write_str("struct Visit")
14893                }
14894                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14895                where
14896                    A: serde::de::MapAccess<'de>,
14897                {
14898                    #[allow(unused_imports)]
14899                    use serde::de::Error;
14900                    use std::option::Option::Some;
14901                    let mut fields = std::collections::HashSet::new();
14902                    let mut result = Self::Value::new();
14903                    while let Some(tag) = map.next_key::<__FieldTag>()? {
14904                        #[allow(clippy::match_single_binding)]
14905                        match tag {
14906                            __FieldTag::__shipment_index => {
14907                                if !fields.insert(__FieldTag::__shipment_index) {
14908                                    return std::result::Result::Err(A::Error::duplicate_field(
14909                                        "multiple values for shipment_index",
14910                                    ));
14911                                }
14912                                struct __With(std::option::Option<i32>);
14913                                impl<'de> serde::de::Deserialize<'de> for __With {
14914                                    fn deserialize<D>(
14915                                        deserializer: D,
14916                                    ) -> std::result::Result<Self, D::Error>
14917                                    where
14918                                        D: serde::de::Deserializer<'de>,
14919                                    {
14920                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
14921                                    }
14922                                }
14923                                result.shipment_index =
14924                                    map.next_value::<__With>()?.0.unwrap_or_default();
14925                            }
14926                            __FieldTag::__is_pickup => {
14927                                if !fields.insert(__FieldTag::__is_pickup) {
14928                                    return std::result::Result::Err(A::Error::duplicate_field(
14929                                        "multiple values for is_pickup",
14930                                    ));
14931                                }
14932                                result.is_pickup = map
14933                                    .next_value::<std::option::Option<bool>>()?
14934                                    .unwrap_or_default();
14935                            }
14936                            __FieldTag::__visit_request_index => {
14937                                if !fields.insert(__FieldTag::__visit_request_index) {
14938                                    return std::result::Result::Err(A::Error::duplicate_field(
14939                                        "multiple values for visit_request_index",
14940                                    ));
14941                                }
14942                                struct __With(std::option::Option<i32>);
14943                                impl<'de> serde::de::Deserialize<'de> for __With {
14944                                    fn deserialize<D>(
14945                                        deserializer: D,
14946                                    ) -> std::result::Result<Self, D::Error>
14947                                    where
14948                                        D: serde::de::Deserializer<'de>,
14949                                    {
14950                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
14951                                    }
14952                                }
14953                                result.visit_request_index =
14954                                    map.next_value::<__With>()?.0.unwrap_or_default();
14955                            }
14956                            __FieldTag::__start_time => {
14957                                if !fields.insert(__FieldTag::__start_time) {
14958                                    return std::result::Result::Err(A::Error::duplicate_field(
14959                                        "multiple values for start_time",
14960                                    ));
14961                                }
14962                                result.start_time =
14963                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14964                            }
14965                            __FieldTag::__load_demands => {
14966                                if !fields.insert(__FieldTag::__load_demands) {
14967                                    return std::result::Result::Err(A::Error::duplicate_field(
14968                                        "multiple values for load_demands",
14969                                    ));
14970                                }
14971                                result.load_demands = map
14972                                    .next_value::<std::option::Option<
14973                                        std::collections::HashMap<
14974                                            std::string::String,
14975                                            crate::model::shipment::Load,
14976                                        >,
14977                                    >>()?
14978                                    .unwrap_or_default();
14979                            }
14980                            __FieldTag::__detour => {
14981                                if !fields.insert(__FieldTag::__detour) {
14982                                    return std::result::Result::Err(A::Error::duplicate_field(
14983                                        "multiple values for detour",
14984                                    ));
14985                                }
14986                                result.detour =
14987                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
14988                            }
14989                            __FieldTag::__shipment_label => {
14990                                if !fields.insert(__FieldTag::__shipment_label) {
14991                                    return std::result::Result::Err(A::Error::duplicate_field(
14992                                        "multiple values for shipment_label",
14993                                    ));
14994                                }
14995                                result.shipment_label = map
14996                                    .next_value::<std::option::Option<std::string::String>>()?
14997                                    .unwrap_or_default();
14998                            }
14999                            __FieldTag::__visit_label => {
15000                                if !fields.insert(__FieldTag::__visit_label) {
15001                                    return std::result::Result::Err(A::Error::duplicate_field(
15002                                        "multiple values for visit_label",
15003                                    ));
15004                                }
15005                                result.visit_label = map
15006                                    .next_value::<std::option::Option<std::string::String>>()?
15007                                    .unwrap_or_default();
15008                            }
15009                            __FieldTag::__arrival_loads => {
15010                                if !fields.insert(__FieldTag::__arrival_loads) {
15011                                    return std::result::Result::Err(A::Error::duplicate_field(
15012                                        "multiple values for arrival_loads",
15013                                    ));
15014                                }
15015                                result.arrival_loads = map
15016                                    .next_value::<std::option::Option<
15017                                        std::vec::Vec<crate::model::CapacityQuantity>,
15018                                    >>()?
15019                                    .unwrap_or_default();
15020                            }
15021                            __FieldTag::__delay_before_start => {
15022                                if !fields.insert(__FieldTag::__delay_before_start) {
15023                                    return std::result::Result::Err(A::Error::duplicate_field(
15024                                        "multiple values for delay_before_start",
15025                                    ));
15026                                }
15027                                result.delay_before_start = map.next_value::<std::option::Option<crate::model::shipment_route::Delay>>()?
15028                                    ;
15029                            }
15030                            __FieldTag::__demands => {
15031                                if !fields.insert(__FieldTag::__demands) {
15032                                    return std::result::Result::Err(A::Error::duplicate_field(
15033                                        "multiple values for demands",
15034                                    ));
15035                                }
15036                                result.demands = map
15037                                    .next_value::<std::option::Option<
15038                                        std::vec::Vec<crate::model::CapacityQuantity>,
15039                                    >>()?
15040                                    .unwrap_or_default();
15041                            }
15042                            __FieldTag::Unknown(key) => {
15043                                let value = map.next_value::<serde_json::Value>()?;
15044                                result._unknown_fields.insert(key, value);
15045                            }
15046                        }
15047                    }
15048                    std::result::Result::Ok(result)
15049                }
15050            }
15051            deserializer.deserialize_any(Visitor)
15052        }
15053    }
15054
15055    #[doc(hidden)]
15056    impl serde::ser::Serialize for Visit {
15057        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15058        where
15059            S: serde::ser::Serializer,
15060        {
15061            use serde::ser::SerializeMap;
15062            #[allow(unused_imports)]
15063            use std::option::Option::Some;
15064            let mut state = serializer.serialize_map(std::option::Option::None)?;
15065            if !wkt::internal::is_default(&self.shipment_index) {
15066                struct __With<'a>(&'a i32);
15067                impl<'a> serde::ser::Serialize for __With<'a> {
15068                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15069                    where
15070                        S: serde::ser::Serializer,
15071                    {
15072                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
15073                    }
15074                }
15075                state.serialize_entry("shipmentIndex", &__With(&self.shipment_index))?;
15076            }
15077            if !wkt::internal::is_default(&self.is_pickup) {
15078                state.serialize_entry("isPickup", &self.is_pickup)?;
15079            }
15080            if !wkt::internal::is_default(&self.visit_request_index) {
15081                struct __With<'a>(&'a i32);
15082                impl<'a> serde::ser::Serialize for __With<'a> {
15083                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15084                    where
15085                        S: serde::ser::Serializer,
15086                    {
15087                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
15088                    }
15089                }
15090                state.serialize_entry("visitRequestIndex", &__With(&self.visit_request_index))?;
15091            }
15092            if self.start_time.is_some() {
15093                state.serialize_entry("startTime", &self.start_time)?;
15094            }
15095            if !self.load_demands.is_empty() {
15096                state.serialize_entry("loadDemands", &self.load_demands)?;
15097            }
15098            if self.detour.is_some() {
15099                state.serialize_entry("detour", &self.detour)?;
15100            }
15101            if !self.shipment_label.is_empty() {
15102                state.serialize_entry("shipmentLabel", &self.shipment_label)?;
15103            }
15104            if !self.visit_label.is_empty() {
15105                state.serialize_entry("visitLabel", &self.visit_label)?;
15106            }
15107            if !self.arrival_loads.is_empty() {
15108                state.serialize_entry("arrivalLoads", &self.arrival_loads)?;
15109            }
15110            if self.delay_before_start.is_some() {
15111                state.serialize_entry("delayBeforeStart", &self.delay_before_start)?;
15112            }
15113            if !self.demands.is_empty() {
15114                state.serialize_entry("demands", &self.demands)?;
15115            }
15116            if !self._unknown_fields.is_empty() {
15117                for (key, value) in self._unknown_fields.iter() {
15118                    state.serialize_entry(key, &value)?;
15119                }
15120            }
15121            state.end()
15122        }
15123    }
15124
15125    /// Transition between two events on the route. See the description of
15126    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
15127    ///
15128    /// If the vehicle does not have a `start_location` and/or `end_location`, the
15129    /// corresponding travel metrics are 0.
15130    ///
15131    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
15132    #[derive(Clone, Debug, Default, PartialEq)]
15133    #[non_exhaustive]
15134    pub struct Transition {
15135        /// Travel duration during this transition.
15136        pub travel_duration: std::option::Option<wkt::Duration>,
15137
15138        /// Distance traveled during the transition.
15139        pub travel_distance_meters: f64,
15140
15141        /// When traffic is requested via
15142        /// [OptimizeToursRequest.consider_road_traffic]
15143        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
15144        /// and the traffic info couldn't be retrieved for a `Transition`, this
15145        /// boolean is set to true. This may be temporary (rare hiccup in the
15146        /// realtime traffic servers) or permanent (no data for this location).
15147        pub traffic_info_unavailable: bool,
15148
15149        /// Sum of the delay durations applied to this transition. If any, the delay
15150        /// starts exactly `delay_duration` seconds before the next event (visit or
15151        /// vehicle end). See
15152        /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
15153        ///
15154        /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
15155        pub delay_duration: std::option::Option<wkt::Duration>,
15156
15157        /// Sum of the duration of the breaks occurring during this transition, if
15158        /// any. Details about each break's start time and duration are stored in
15159        /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
15160        ///
15161        /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
15162        pub break_duration: std::option::Option<wkt::Duration>,
15163
15164        /// Time spent waiting during this transition. Wait duration corresponds to
15165        /// idle time and does not include break time. Also note that this wait time
15166        /// may be split into several non-contiguous intervals.
15167        pub wait_duration: std::option::Option<wkt::Duration>,
15168
15169        /// Total duration of the transition, provided for convenience. It is equal
15170        /// to:
15171        ///
15172        /// * next visit `start_time` (or `vehicle_end_time` if this is the last
15173        ///   transition) - this transition's `start_time`;
15174        /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
15175        ///   additionally holds: `total_duration = travel_duration + delay_duration
15176        ///
15177        /// + break_duration + wait_duration`.
15178        pub total_duration: std::option::Option<wkt::Duration>,
15179
15180        /// Start time of this transition.
15181        pub start_time: std::option::Option<wkt::Timestamp>,
15182
15183        /// The encoded polyline representation of the route followed during the
15184        /// transition.
15185        /// This field is only populated if [populate_transition_polylines]
15186        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
15187        /// is set to true.
15188        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
15189
15190        /// Vehicle loads during this transition, for each type that either appears
15191        /// in this vehicle's
15192        /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
15193        /// or that have non-zero
15194        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
15195        /// on some shipment performed on this route.
15196        ///
15197        /// The loads during the first transition are the starting loads of the
15198        /// vehicle route. Then, after each visit, the visit's `load_demands` are
15199        /// either added or subtracted to get the next transition's loads, depending
15200        /// on whether the visit was a pickup or a delivery.
15201        ///
15202        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
15203        /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
15204        pub vehicle_loads: std::collections::HashMap<
15205            std::string::String,
15206            crate::model::shipment_route::VehicleLoad,
15207        >,
15208
15209        /// Deprecated: Use
15210        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
15211        /// instead.
15212        ///
15213        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
15214        #[deprecated]
15215        pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
15216
15217        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15218    }
15219
15220    impl Transition {
15221        pub fn new() -> Self {
15222            std::default::Default::default()
15223        }
15224
15225        /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
15226        pub fn set_travel_duration<T>(mut self, v: T) -> Self
15227        where
15228            T: std::convert::Into<wkt::Duration>,
15229        {
15230            self.travel_duration = std::option::Option::Some(v.into());
15231            self
15232        }
15233
15234        /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
15235        pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
15236        where
15237            T: std::convert::Into<wkt::Duration>,
15238        {
15239            self.travel_duration = v.map(|x| x.into());
15240            self
15241        }
15242
15243        /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
15244        pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
15245            self.travel_distance_meters = v.into();
15246            self
15247        }
15248
15249        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
15250        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
15251            self.traffic_info_unavailable = v.into();
15252            self
15253        }
15254
15255        /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
15256        pub fn set_delay_duration<T>(mut self, v: T) -> Self
15257        where
15258            T: std::convert::Into<wkt::Duration>,
15259        {
15260            self.delay_duration = std::option::Option::Some(v.into());
15261            self
15262        }
15263
15264        /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
15265        pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
15266        where
15267            T: std::convert::Into<wkt::Duration>,
15268        {
15269            self.delay_duration = v.map(|x| x.into());
15270            self
15271        }
15272
15273        /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
15274        pub fn set_break_duration<T>(mut self, v: T) -> Self
15275        where
15276            T: std::convert::Into<wkt::Duration>,
15277        {
15278            self.break_duration = std::option::Option::Some(v.into());
15279            self
15280        }
15281
15282        /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
15283        pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
15284        where
15285            T: std::convert::Into<wkt::Duration>,
15286        {
15287            self.break_duration = v.map(|x| x.into());
15288            self
15289        }
15290
15291        /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
15292        pub fn set_wait_duration<T>(mut self, v: T) -> Self
15293        where
15294            T: std::convert::Into<wkt::Duration>,
15295        {
15296            self.wait_duration = std::option::Option::Some(v.into());
15297            self
15298        }
15299
15300        /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
15301        pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
15302        where
15303            T: std::convert::Into<wkt::Duration>,
15304        {
15305            self.wait_duration = v.map(|x| x.into());
15306            self
15307        }
15308
15309        /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
15310        pub fn set_total_duration<T>(mut self, v: T) -> Self
15311        where
15312            T: std::convert::Into<wkt::Duration>,
15313        {
15314            self.total_duration = std::option::Option::Some(v.into());
15315            self
15316        }
15317
15318        /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
15319        pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
15320        where
15321            T: std::convert::Into<wkt::Duration>,
15322        {
15323            self.total_duration = v.map(|x| x.into());
15324            self
15325        }
15326
15327        /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
15328        pub fn set_start_time<T>(mut self, v: T) -> Self
15329        where
15330            T: std::convert::Into<wkt::Timestamp>,
15331        {
15332            self.start_time = std::option::Option::Some(v.into());
15333            self
15334        }
15335
15336        /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
15337        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
15338        where
15339            T: std::convert::Into<wkt::Timestamp>,
15340        {
15341            self.start_time = v.map(|x| x.into());
15342            self
15343        }
15344
15345        /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
15346        pub fn set_route_polyline<T>(mut self, v: T) -> Self
15347        where
15348            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
15349        {
15350            self.route_polyline = std::option::Option::Some(v.into());
15351            self
15352        }
15353
15354        /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
15355        pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
15356        where
15357            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
15358        {
15359            self.route_polyline = v.map(|x| x.into());
15360            self
15361        }
15362
15363        /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
15364        pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
15365        where
15366            T: std::iter::IntoIterator<Item = (K, V)>,
15367            K: std::convert::Into<std::string::String>,
15368            V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
15369        {
15370            use std::iter::Iterator;
15371            self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
15372            self
15373        }
15374
15375        /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
15376        #[deprecated]
15377        pub fn set_loads<T, V>(mut self, v: T) -> Self
15378        where
15379            T: std::iter::IntoIterator<Item = V>,
15380            V: std::convert::Into<crate::model::CapacityQuantity>,
15381        {
15382            use std::iter::Iterator;
15383            self.loads = v.into_iter().map(|i| i.into()).collect();
15384            self
15385        }
15386    }
15387
15388    impl wkt::message::Message for Transition {
15389        fn typename() -> &'static str {
15390            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
15391        }
15392    }
15393
15394    #[doc(hidden)]
15395    impl<'de> serde::de::Deserialize<'de> for Transition {
15396        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15397        where
15398            D: serde::Deserializer<'de>,
15399        {
15400            #[allow(non_camel_case_types)]
15401            #[doc(hidden)]
15402            #[derive(PartialEq, Eq, Hash)]
15403            enum __FieldTag {
15404                __travel_duration,
15405                __travel_distance_meters,
15406                __traffic_info_unavailable,
15407                __delay_duration,
15408                __break_duration,
15409                __wait_duration,
15410                __total_duration,
15411                __start_time,
15412                __route_polyline,
15413                __vehicle_loads,
15414                __loads,
15415                Unknown(std::string::String),
15416            }
15417            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15418                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15419                where
15420                    D: serde::Deserializer<'de>,
15421                {
15422                    struct Visitor;
15423                    impl<'de> serde::de::Visitor<'de> for Visitor {
15424                        type Value = __FieldTag;
15425                        fn expecting(
15426                            &self,
15427                            formatter: &mut std::fmt::Formatter,
15428                        ) -> std::fmt::Result {
15429                            formatter.write_str("a field name for Transition")
15430                        }
15431                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15432                        where
15433                            E: serde::de::Error,
15434                        {
15435                            use std::result::Result::Ok;
15436                            use std::string::ToString;
15437                            match value {
15438                                "travelDuration" => Ok(__FieldTag::__travel_duration),
15439                                "travel_duration" => Ok(__FieldTag::__travel_duration),
15440                                "travelDistanceMeters" => Ok(__FieldTag::__travel_distance_meters),
15441                                "travel_distance_meters" => {
15442                                    Ok(__FieldTag::__travel_distance_meters)
15443                                }
15444                                "trafficInfoUnavailable" => {
15445                                    Ok(__FieldTag::__traffic_info_unavailable)
15446                                }
15447                                "traffic_info_unavailable" => {
15448                                    Ok(__FieldTag::__traffic_info_unavailable)
15449                                }
15450                                "delayDuration" => Ok(__FieldTag::__delay_duration),
15451                                "delay_duration" => Ok(__FieldTag::__delay_duration),
15452                                "breakDuration" => Ok(__FieldTag::__break_duration),
15453                                "break_duration" => Ok(__FieldTag::__break_duration),
15454                                "waitDuration" => Ok(__FieldTag::__wait_duration),
15455                                "wait_duration" => Ok(__FieldTag::__wait_duration),
15456                                "totalDuration" => Ok(__FieldTag::__total_duration),
15457                                "total_duration" => Ok(__FieldTag::__total_duration),
15458                                "startTime" => Ok(__FieldTag::__start_time),
15459                                "start_time" => Ok(__FieldTag::__start_time),
15460                                "routePolyline" => Ok(__FieldTag::__route_polyline),
15461                                "route_polyline" => Ok(__FieldTag::__route_polyline),
15462                                "vehicleLoads" => Ok(__FieldTag::__vehicle_loads),
15463                                "vehicle_loads" => Ok(__FieldTag::__vehicle_loads),
15464                                "loads" => Ok(__FieldTag::__loads),
15465                                _ => Ok(__FieldTag::Unknown(value.to_string())),
15466                            }
15467                        }
15468                    }
15469                    deserializer.deserialize_identifier(Visitor)
15470                }
15471            }
15472            struct Visitor;
15473            impl<'de> serde::de::Visitor<'de> for Visitor {
15474                type Value = Transition;
15475                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15476                    formatter.write_str("struct Transition")
15477                }
15478                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15479                where
15480                    A: serde::de::MapAccess<'de>,
15481                {
15482                    #[allow(unused_imports)]
15483                    use serde::de::Error;
15484                    use std::option::Option::Some;
15485                    let mut fields = std::collections::HashSet::new();
15486                    let mut result = Self::Value::new();
15487                    while let Some(tag) = map.next_key::<__FieldTag>()? {
15488                        #[allow(clippy::match_single_binding)]
15489                        match tag {
15490                            __FieldTag::__travel_duration => {
15491                                if !fields.insert(__FieldTag::__travel_duration) {
15492                                    return std::result::Result::Err(A::Error::duplicate_field(
15493                                        "multiple values for travel_duration",
15494                                    ));
15495                                }
15496                                result.travel_duration =
15497                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
15498                            }
15499                            __FieldTag::__travel_distance_meters => {
15500                                if !fields.insert(__FieldTag::__travel_distance_meters) {
15501                                    return std::result::Result::Err(A::Error::duplicate_field(
15502                                        "multiple values for travel_distance_meters",
15503                                    ));
15504                                }
15505                                struct __With(std::option::Option<f64>);
15506                                impl<'de> serde::de::Deserialize<'de> for __With {
15507                                    fn deserialize<D>(
15508                                        deserializer: D,
15509                                    ) -> std::result::Result<Self, D::Error>
15510                                    where
15511                                        D: serde::de::Deserializer<'de>,
15512                                    {
15513                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
15514                                    }
15515                                }
15516                                result.travel_distance_meters =
15517                                    map.next_value::<__With>()?.0.unwrap_or_default();
15518                            }
15519                            __FieldTag::__traffic_info_unavailable => {
15520                                if !fields.insert(__FieldTag::__traffic_info_unavailable) {
15521                                    return std::result::Result::Err(A::Error::duplicate_field(
15522                                        "multiple values for traffic_info_unavailable",
15523                                    ));
15524                                }
15525                                result.traffic_info_unavailable = map
15526                                    .next_value::<std::option::Option<bool>>()?
15527                                    .unwrap_or_default();
15528                            }
15529                            __FieldTag::__delay_duration => {
15530                                if !fields.insert(__FieldTag::__delay_duration) {
15531                                    return std::result::Result::Err(A::Error::duplicate_field(
15532                                        "multiple values for delay_duration",
15533                                    ));
15534                                }
15535                                result.delay_duration =
15536                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
15537                            }
15538                            __FieldTag::__break_duration => {
15539                                if !fields.insert(__FieldTag::__break_duration) {
15540                                    return std::result::Result::Err(A::Error::duplicate_field(
15541                                        "multiple values for break_duration",
15542                                    ));
15543                                }
15544                                result.break_duration =
15545                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
15546                            }
15547                            __FieldTag::__wait_duration => {
15548                                if !fields.insert(__FieldTag::__wait_duration) {
15549                                    return std::result::Result::Err(A::Error::duplicate_field(
15550                                        "multiple values for wait_duration",
15551                                    ));
15552                                }
15553                                result.wait_duration =
15554                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
15555                            }
15556                            __FieldTag::__total_duration => {
15557                                if !fields.insert(__FieldTag::__total_duration) {
15558                                    return std::result::Result::Err(A::Error::duplicate_field(
15559                                        "multiple values for total_duration",
15560                                    ));
15561                                }
15562                                result.total_duration =
15563                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
15564                            }
15565                            __FieldTag::__start_time => {
15566                                if !fields.insert(__FieldTag::__start_time) {
15567                                    return std::result::Result::Err(A::Error::duplicate_field(
15568                                        "multiple values for start_time",
15569                                    ));
15570                                }
15571                                result.start_time =
15572                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
15573                            }
15574                            __FieldTag::__route_polyline => {
15575                                if !fields.insert(__FieldTag::__route_polyline) {
15576                                    return std::result::Result::Err(A::Error::duplicate_field(
15577                                        "multiple values for route_polyline",
15578                                    ));
15579                                }
15580                                result.route_polyline = map.next_value::<std::option::Option<
15581                                    crate::model::shipment_route::EncodedPolyline,
15582                                >>()?;
15583                            }
15584                            __FieldTag::__vehicle_loads => {
15585                                if !fields.insert(__FieldTag::__vehicle_loads) {
15586                                    return std::result::Result::Err(A::Error::duplicate_field(
15587                                        "multiple values for vehicle_loads",
15588                                    ));
15589                                }
15590                                result.vehicle_loads = map
15591                                    .next_value::<std::option::Option<
15592                                        std::collections::HashMap<
15593                                            std::string::String,
15594                                            crate::model::shipment_route::VehicleLoad,
15595                                        >,
15596                                    >>()?
15597                                    .unwrap_or_default();
15598                            }
15599                            __FieldTag::__loads => {
15600                                if !fields.insert(__FieldTag::__loads) {
15601                                    return std::result::Result::Err(A::Error::duplicate_field(
15602                                        "multiple values for loads",
15603                                    ));
15604                                }
15605                                result.loads = map
15606                                    .next_value::<std::option::Option<
15607                                        std::vec::Vec<crate::model::CapacityQuantity>,
15608                                    >>()?
15609                                    .unwrap_or_default();
15610                            }
15611                            __FieldTag::Unknown(key) => {
15612                                let value = map.next_value::<serde_json::Value>()?;
15613                                result._unknown_fields.insert(key, value);
15614                            }
15615                        }
15616                    }
15617                    std::result::Result::Ok(result)
15618                }
15619            }
15620            deserializer.deserialize_any(Visitor)
15621        }
15622    }
15623
15624    #[doc(hidden)]
15625    impl serde::ser::Serialize for Transition {
15626        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15627        where
15628            S: serde::ser::Serializer,
15629        {
15630            use serde::ser::SerializeMap;
15631            #[allow(unused_imports)]
15632            use std::option::Option::Some;
15633            let mut state = serializer.serialize_map(std::option::Option::None)?;
15634            if self.travel_duration.is_some() {
15635                state.serialize_entry("travelDuration", &self.travel_duration)?;
15636            }
15637            if !wkt::internal::is_default(&self.travel_distance_meters) {
15638                struct __With<'a>(&'a f64);
15639                impl<'a> serde::ser::Serialize for __With<'a> {
15640                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15641                    where
15642                        S: serde::ser::Serializer,
15643                    {
15644                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
15645                    }
15646                }
15647                state.serialize_entry(
15648                    "travelDistanceMeters",
15649                    &__With(&self.travel_distance_meters),
15650                )?;
15651            }
15652            if !wkt::internal::is_default(&self.traffic_info_unavailable) {
15653                state.serialize_entry("trafficInfoUnavailable", &self.traffic_info_unavailable)?;
15654            }
15655            if self.delay_duration.is_some() {
15656                state.serialize_entry("delayDuration", &self.delay_duration)?;
15657            }
15658            if self.break_duration.is_some() {
15659                state.serialize_entry("breakDuration", &self.break_duration)?;
15660            }
15661            if self.wait_duration.is_some() {
15662                state.serialize_entry("waitDuration", &self.wait_duration)?;
15663            }
15664            if self.total_duration.is_some() {
15665                state.serialize_entry("totalDuration", &self.total_duration)?;
15666            }
15667            if self.start_time.is_some() {
15668                state.serialize_entry("startTime", &self.start_time)?;
15669            }
15670            if self.route_polyline.is_some() {
15671                state.serialize_entry("routePolyline", &self.route_polyline)?;
15672            }
15673            if !self.vehicle_loads.is_empty() {
15674                state.serialize_entry("vehicleLoads", &self.vehicle_loads)?;
15675            }
15676            if !self.loads.is_empty() {
15677                state.serialize_entry("loads", &self.loads)?;
15678            }
15679            if !self._unknown_fields.is_empty() {
15680                for (key, value) in self._unknown_fields.iter() {
15681                    state.serialize_entry(key, &value)?;
15682                }
15683            }
15684            state.end()
15685        }
15686    }
15687
15688    /// Reports the actual load of the vehicle at some point along the route,
15689    /// for a given type (see
15690    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
15691    ///
15692    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
15693    #[derive(Clone, Debug, Default, PartialEq)]
15694    #[non_exhaustive]
15695    pub struct VehicleLoad {
15696        /// The amount of load on the vehicle, for the given type. The unit of load
15697        /// is usually indicated by the type. See
15698        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
15699        ///
15700        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
15701        pub amount: i64,
15702
15703        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15704    }
15705
15706    impl VehicleLoad {
15707        pub fn new() -> Self {
15708            std::default::Default::default()
15709        }
15710
15711        /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
15712        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
15713            self.amount = v.into();
15714            self
15715        }
15716    }
15717
15718    impl wkt::message::Message for VehicleLoad {
15719        fn typename() -> &'static str {
15720            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
15721        }
15722    }
15723
15724    #[doc(hidden)]
15725    impl<'de> serde::de::Deserialize<'de> for VehicleLoad {
15726        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15727        where
15728            D: serde::Deserializer<'de>,
15729        {
15730            #[allow(non_camel_case_types)]
15731            #[doc(hidden)]
15732            #[derive(PartialEq, Eq, Hash)]
15733            enum __FieldTag {
15734                __amount,
15735                Unknown(std::string::String),
15736            }
15737            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15738                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15739                where
15740                    D: serde::Deserializer<'de>,
15741                {
15742                    struct Visitor;
15743                    impl<'de> serde::de::Visitor<'de> for Visitor {
15744                        type Value = __FieldTag;
15745                        fn expecting(
15746                            &self,
15747                            formatter: &mut std::fmt::Formatter,
15748                        ) -> std::fmt::Result {
15749                            formatter.write_str("a field name for VehicleLoad")
15750                        }
15751                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15752                        where
15753                            E: serde::de::Error,
15754                        {
15755                            use std::result::Result::Ok;
15756                            use std::string::ToString;
15757                            match value {
15758                                "amount" => Ok(__FieldTag::__amount),
15759                                _ => Ok(__FieldTag::Unknown(value.to_string())),
15760                            }
15761                        }
15762                    }
15763                    deserializer.deserialize_identifier(Visitor)
15764                }
15765            }
15766            struct Visitor;
15767            impl<'de> serde::de::Visitor<'de> for Visitor {
15768                type Value = VehicleLoad;
15769                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15770                    formatter.write_str("struct VehicleLoad")
15771                }
15772                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15773                where
15774                    A: serde::de::MapAccess<'de>,
15775                {
15776                    #[allow(unused_imports)]
15777                    use serde::de::Error;
15778                    use std::option::Option::Some;
15779                    let mut fields = std::collections::HashSet::new();
15780                    let mut result = Self::Value::new();
15781                    while let Some(tag) = map.next_key::<__FieldTag>()? {
15782                        #[allow(clippy::match_single_binding)]
15783                        match tag {
15784                            __FieldTag::__amount => {
15785                                if !fields.insert(__FieldTag::__amount) {
15786                                    return std::result::Result::Err(A::Error::duplicate_field(
15787                                        "multiple values for amount",
15788                                    ));
15789                                }
15790                                struct __With(std::option::Option<i64>);
15791                                impl<'de> serde::de::Deserialize<'de> for __With {
15792                                    fn deserialize<D>(
15793                                        deserializer: D,
15794                                    ) -> std::result::Result<Self, D::Error>
15795                                    where
15796                                        D: serde::de::Deserializer<'de>,
15797                                    {
15798                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
15799                                    }
15800                                }
15801                                result.amount = map.next_value::<__With>()?.0.unwrap_or_default();
15802                            }
15803                            __FieldTag::Unknown(key) => {
15804                                let value = map.next_value::<serde_json::Value>()?;
15805                                result._unknown_fields.insert(key, value);
15806                            }
15807                        }
15808                    }
15809                    std::result::Result::Ok(result)
15810                }
15811            }
15812            deserializer.deserialize_any(Visitor)
15813        }
15814    }
15815
15816    #[doc(hidden)]
15817    impl serde::ser::Serialize for VehicleLoad {
15818        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15819        where
15820            S: serde::ser::Serializer,
15821        {
15822            use serde::ser::SerializeMap;
15823            #[allow(unused_imports)]
15824            use std::option::Option::Some;
15825            let mut state = serializer.serialize_map(std::option::Option::None)?;
15826            if !wkt::internal::is_default(&self.amount) {
15827                struct __With<'a>(&'a i64);
15828                impl<'a> serde::ser::Serialize for __With<'a> {
15829                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15830                    where
15831                        S: serde::ser::Serializer,
15832                    {
15833                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
15834                    }
15835                }
15836                state.serialize_entry("amount", &__With(&self.amount))?;
15837            }
15838            if !self._unknown_fields.is_empty() {
15839                for (key, value) in self._unknown_fields.iter() {
15840                    state.serialize_entry(key, &value)?;
15841                }
15842            }
15843            state.end()
15844        }
15845    }
15846
15847    /// The encoded representation of a polyline. More information on polyline
15848    /// encoding can be found here:
15849    /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
15850    /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
15851    #[derive(Clone, Debug, Default, PartialEq)]
15852    #[non_exhaustive]
15853    pub struct EncodedPolyline {
15854        /// String representing encoded points of the polyline.
15855        pub points: std::string::String,
15856
15857        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15858    }
15859
15860    impl EncodedPolyline {
15861        pub fn new() -> Self {
15862            std::default::Default::default()
15863        }
15864
15865        /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
15866        pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15867            self.points = v.into();
15868            self
15869        }
15870    }
15871
15872    impl wkt::message::Message for EncodedPolyline {
15873        fn typename() -> &'static str {
15874            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
15875        }
15876    }
15877
15878    #[doc(hidden)]
15879    impl<'de> serde::de::Deserialize<'de> for EncodedPolyline {
15880        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15881        where
15882            D: serde::Deserializer<'de>,
15883        {
15884            #[allow(non_camel_case_types)]
15885            #[doc(hidden)]
15886            #[derive(PartialEq, Eq, Hash)]
15887            enum __FieldTag {
15888                __points,
15889                Unknown(std::string::String),
15890            }
15891            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15892                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15893                where
15894                    D: serde::Deserializer<'de>,
15895                {
15896                    struct Visitor;
15897                    impl<'de> serde::de::Visitor<'de> for Visitor {
15898                        type Value = __FieldTag;
15899                        fn expecting(
15900                            &self,
15901                            formatter: &mut std::fmt::Formatter,
15902                        ) -> std::fmt::Result {
15903                            formatter.write_str("a field name for EncodedPolyline")
15904                        }
15905                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15906                        where
15907                            E: serde::de::Error,
15908                        {
15909                            use std::result::Result::Ok;
15910                            use std::string::ToString;
15911                            match value {
15912                                "points" => Ok(__FieldTag::__points),
15913                                _ => Ok(__FieldTag::Unknown(value.to_string())),
15914                            }
15915                        }
15916                    }
15917                    deserializer.deserialize_identifier(Visitor)
15918                }
15919            }
15920            struct Visitor;
15921            impl<'de> serde::de::Visitor<'de> for Visitor {
15922                type Value = EncodedPolyline;
15923                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15924                    formatter.write_str("struct EncodedPolyline")
15925                }
15926                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15927                where
15928                    A: serde::de::MapAccess<'de>,
15929                {
15930                    #[allow(unused_imports)]
15931                    use serde::de::Error;
15932                    use std::option::Option::Some;
15933                    let mut fields = std::collections::HashSet::new();
15934                    let mut result = Self::Value::new();
15935                    while let Some(tag) = map.next_key::<__FieldTag>()? {
15936                        #[allow(clippy::match_single_binding)]
15937                        match tag {
15938                            __FieldTag::__points => {
15939                                if !fields.insert(__FieldTag::__points) {
15940                                    return std::result::Result::Err(A::Error::duplicate_field(
15941                                        "multiple values for points",
15942                                    ));
15943                                }
15944                                result.points = map
15945                                    .next_value::<std::option::Option<std::string::String>>()?
15946                                    .unwrap_or_default();
15947                            }
15948                            __FieldTag::Unknown(key) => {
15949                                let value = map.next_value::<serde_json::Value>()?;
15950                                result._unknown_fields.insert(key, value);
15951                            }
15952                        }
15953                    }
15954                    std::result::Result::Ok(result)
15955                }
15956            }
15957            deserializer.deserialize_any(Visitor)
15958        }
15959    }
15960
15961    #[doc(hidden)]
15962    impl serde::ser::Serialize for EncodedPolyline {
15963        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15964        where
15965            S: serde::ser::Serializer,
15966        {
15967            use serde::ser::SerializeMap;
15968            #[allow(unused_imports)]
15969            use std::option::Option::Some;
15970            let mut state = serializer.serialize_map(std::option::Option::None)?;
15971            if !self.points.is_empty() {
15972                state.serialize_entry("points", &self.points)?;
15973            }
15974            if !self._unknown_fields.is_empty() {
15975                for (key, value) in self._unknown_fields.iter() {
15976                    state.serialize_entry(key, &value)?;
15977                }
15978            }
15979            state.end()
15980        }
15981    }
15982
15983    /// Data representing the execution of a break.
15984    #[derive(Clone, Debug, Default, PartialEq)]
15985    #[non_exhaustive]
15986    pub struct Break {
15987        /// Start time of a break.
15988        pub start_time: std::option::Option<wkt::Timestamp>,
15989
15990        /// Duration of a break.
15991        pub duration: std::option::Option<wkt::Duration>,
15992
15993        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15994    }
15995
15996    impl Break {
15997        pub fn new() -> Self {
15998            std::default::Default::default()
15999        }
16000
16001        /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
16002        pub fn set_start_time<T>(mut self, v: T) -> Self
16003        where
16004            T: std::convert::Into<wkt::Timestamp>,
16005        {
16006            self.start_time = std::option::Option::Some(v.into());
16007            self
16008        }
16009
16010        /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
16011        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
16012        where
16013            T: std::convert::Into<wkt::Timestamp>,
16014        {
16015            self.start_time = v.map(|x| x.into());
16016            self
16017        }
16018
16019        /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
16020        pub fn set_duration<T>(mut self, v: T) -> Self
16021        where
16022            T: std::convert::Into<wkt::Duration>,
16023        {
16024            self.duration = std::option::Option::Some(v.into());
16025            self
16026        }
16027
16028        /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
16029        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
16030        where
16031            T: std::convert::Into<wkt::Duration>,
16032        {
16033            self.duration = v.map(|x| x.into());
16034            self
16035        }
16036    }
16037
16038    impl wkt::message::Message for Break {
16039        fn typename() -> &'static str {
16040            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
16041        }
16042    }
16043
16044    #[doc(hidden)]
16045    impl<'de> serde::de::Deserialize<'de> for Break {
16046        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16047        where
16048            D: serde::Deserializer<'de>,
16049        {
16050            #[allow(non_camel_case_types)]
16051            #[doc(hidden)]
16052            #[derive(PartialEq, Eq, Hash)]
16053            enum __FieldTag {
16054                __start_time,
16055                __duration,
16056                Unknown(std::string::String),
16057            }
16058            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16059                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16060                where
16061                    D: serde::Deserializer<'de>,
16062                {
16063                    struct Visitor;
16064                    impl<'de> serde::de::Visitor<'de> for Visitor {
16065                        type Value = __FieldTag;
16066                        fn expecting(
16067                            &self,
16068                            formatter: &mut std::fmt::Formatter,
16069                        ) -> std::fmt::Result {
16070                            formatter.write_str("a field name for Break")
16071                        }
16072                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16073                        where
16074                            E: serde::de::Error,
16075                        {
16076                            use std::result::Result::Ok;
16077                            use std::string::ToString;
16078                            match value {
16079                                "startTime" => Ok(__FieldTag::__start_time),
16080                                "start_time" => Ok(__FieldTag::__start_time),
16081                                "duration" => Ok(__FieldTag::__duration),
16082                                _ => Ok(__FieldTag::Unknown(value.to_string())),
16083                            }
16084                        }
16085                    }
16086                    deserializer.deserialize_identifier(Visitor)
16087                }
16088            }
16089            struct Visitor;
16090            impl<'de> serde::de::Visitor<'de> for Visitor {
16091                type Value = Break;
16092                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16093                    formatter.write_str("struct Break")
16094                }
16095                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16096                where
16097                    A: serde::de::MapAccess<'de>,
16098                {
16099                    #[allow(unused_imports)]
16100                    use serde::de::Error;
16101                    use std::option::Option::Some;
16102                    let mut fields = std::collections::HashSet::new();
16103                    let mut result = Self::Value::new();
16104                    while let Some(tag) = map.next_key::<__FieldTag>()? {
16105                        #[allow(clippy::match_single_binding)]
16106                        match tag {
16107                            __FieldTag::__start_time => {
16108                                if !fields.insert(__FieldTag::__start_time) {
16109                                    return std::result::Result::Err(A::Error::duplicate_field(
16110                                        "multiple values for start_time",
16111                                    ));
16112                                }
16113                                result.start_time =
16114                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
16115                            }
16116                            __FieldTag::__duration => {
16117                                if !fields.insert(__FieldTag::__duration) {
16118                                    return std::result::Result::Err(A::Error::duplicate_field(
16119                                        "multiple values for duration",
16120                                    ));
16121                                }
16122                                result.duration =
16123                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
16124                            }
16125                            __FieldTag::Unknown(key) => {
16126                                let value = map.next_value::<serde_json::Value>()?;
16127                                result._unknown_fields.insert(key, value);
16128                            }
16129                        }
16130                    }
16131                    std::result::Result::Ok(result)
16132                }
16133            }
16134            deserializer.deserialize_any(Visitor)
16135        }
16136    }
16137
16138    #[doc(hidden)]
16139    impl serde::ser::Serialize for Break {
16140        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16141        where
16142            S: serde::ser::Serializer,
16143        {
16144            use serde::ser::SerializeMap;
16145            #[allow(unused_imports)]
16146            use std::option::Option::Some;
16147            let mut state = serializer.serialize_map(std::option::Option::None)?;
16148            if self.start_time.is_some() {
16149                state.serialize_entry("startTime", &self.start_time)?;
16150            }
16151            if self.duration.is_some() {
16152                state.serialize_entry("duration", &self.duration)?;
16153            }
16154            if !self._unknown_fields.is_empty() {
16155                for (key, value) in self._unknown_fields.iter() {
16156                    state.serialize_entry(key, &value)?;
16157                }
16158            }
16159            state.end()
16160        }
16161    }
16162
16163    /// Deprecated: Use
16164    /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
16165    /// instead. Travel between each visit along the route: from the vehicle's
16166    /// `start_location` to the first visit's `arrival_location`, then from the
16167    /// first visit's `departure_location` to the second visit's
16168    /// `arrival_location`, and so on until the vehicle's `end_location`. This
16169    /// accounts only for the actual travel between visits, not counting the
16170    /// waiting time, the time spent performing a visit, nor the distance covered
16171    /// during a visit.
16172    ///
16173    /// Invariant: `travel_steps_size() == visits_size() + 1`.
16174    ///
16175    /// If the vehicle does not have a start_ and/or end_location, the
16176    /// corresponding travel metrics are 0 and/or empty.
16177    ///
16178    /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
16179    #[derive(Clone, Debug, Default, PartialEq)]
16180    #[non_exhaustive]
16181    #[deprecated]
16182    pub struct TravelStep {
16183        /// Duration of the travel step.
16184        pub duration: std::option::Option<wkt::Duration>,
16185
16186        /// Distance traveled during the step.
16187        pub distance_meters: f64,
16188
16189        /// When traffic is requested via
16190        /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
16191        /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
16192        /// is set to true. This may be temporary (rare hiccup in the realtime
16193        /// traffic servers) or permanent (no data for this location).
16194        ///
16195        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
16196        pub traffic_info_unavailable: bool,
16197
16198        /// The encoded polyline representation of the route followed during the
16199        /// step.
16200        ///
16201        /// This field is only populated if
16202        /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
16203        /// is set to true.
16204        ///
16205        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
16206        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
16207
16208        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16209    }
16210
16211    impl TravelStep {
16212        pub fn new() -> Self {
16213            std::default::Default::default()
16214        }
16215
16216        /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
16217        pub fn set_duration<T>(mut self, v: T) -> Self
16218        where
16219            T: std::convert::Into<wkt::Duration>,
16220        {
16221            self.duration = std::option::Option::Some(v.into());
16222            self
16223        }
16224
16225        /// Sets or clears the value of [duration][crate::model::shipment_route::TravelStep::duration].
16226        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
16227        where
16228            T: std::convert::Into<wkt::Duration>,
16229        {
16230            self.duration = v.map(|x| x.into());
16231            self
16232        }
16233
16234        /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
16235        pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
16236            self.distance_meters = v.into();
16237            self
16238        }
16239
16240        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
16241        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
16242            self.traffic_info_unavailable = v.into();
16243            self
16244        }
16245
16246        /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
16247        pub fn set_route_polyline<T>(mut self, v: T) -> Self
16248        where
16249            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
16250        {
16251            self.route_polyline = std::option::Option::Some(v.into());
16252            self
16253        }
16254
16255        /// Sets or clears the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
16256        pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
16257        where
16258            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
16259        {
16260            self.route_polyline = v.map(|x| x.into());
16261            self
16262        }
16263    }
16264
16265    impl wkt::message::Message for TravelStep {
16266        fn typename() -> &'static str {
16267            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
16268        }
16269    }
16270
16271    #[doc(hidden)]
16272    impl<'de> serde::de::Deserialize<'de> for TravelStep {
16273        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16274        where
16275            D: serde::Deserializer<'de>,
16276        {
16277            #[allow(non_camel_case_types)]
16278            #[doc(hidden)]
16279            #[derive(PartialEq, Eq, Hash)]
16280            enum __FieldTag {
16281                __duration,
16282                __distance_meters,
16283                __traffic_info_unavailable,
16284                __route_polyline,
16285                Unknown(std::string::String),
16286            }
16287            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16288                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16289                where
16290                    D: serde::Deserializer<'de>,
16291                {
16292                    struct Visitor;
16293                    impl<'de> serde::de::Visitor<'de> for Visitor {
16294                        type Value = __FieldTag;
16295                        fn expecting(
16296                            &self,
16297                            formatter: &mut std::fmt::Formatter,
16298                        ) -> std::fmt::Result {
16299                            formatter.write_str("a field name for TravelStep")
16300                        }
16301                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16302                        where
16303                            E: serde::de::Error,
16304                        {
16305                            use std::result::Result::Ok;
16306                            use std::string::ToString;
16307                            match value {
16308                                "duration" => Ok(__FieldTag::__duration),
16309                                "distanceMeters" => Ok(__FieldTag::__distance_meters),
16310                                "distance_meters" => Ok(__FieldTag::__distance_meters),
16311                                "trafficInfoUnavailable" => {
16312                                    Ok(__FieldTag::__traffic_info_unavailable)
16313                                }
16314                                "traffic_info_unavailable" => {
16315                                    Ok(__FieldTag::__traffic_info_unavailable)
16316                                }
16317                                "routePolyline" => Ok(__FieldTag::__route_polyline),
16318                                "route_polyline" => Ok(__FieldTag::__route_polyline),
16319                                _ => Ok(__FieldTag::Unknown(value.to_string())),
16320                            }
16321                        }
16322                    }
16323                    deserializer.deserialize_identifier(Visitor)
16324                }
16325            }
16326            struct Visitor;
16327            impl<'de> serde::de::Visitor<'de> for Visitor {
16328                type Value = TravelStep;
16329                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16330                    formatter.write_str("struct TravelStep")
16331                }
16332                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16333                where
16334                    A: serde::de::MapAccess<'de>,
16335                {
16336                    #[allow(unused_imports)]
16337                    use serde::de::Error;
16338                    use std::option::Option::Some;
16339                    let mut fields = std::collections::HashSet::new();
16340                    let mut result = Self::Value::new();
16341                    while let Some(tag) = map.next_key::<__FieldTag>()? {
16342                        #[allow(clippy::match_single_binding)]
16343                        match tag {
16344                            __FieldTag::__duration => {
16345                                if !fields.insert(__FieldTag::__duration) {
16346                                    return std::result::Result::Err(A::Error::duplicate_field(
16347                                        "multiple values for duration",
16348                                    ));
16349                                }
16350                                result.duration =
16351                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
16352                            }
16353                            __FieldTag::__distance_meters => {
16354                                if !fields.insert(__FieldTag::__distance_meters) {
16355                                    return std::result::Result::Err(A::Error::duplicate_field(
16356                                        "multiple values for distance_meters",
16357                                    ));
16358                                }
16359                                struct __With(std::option::Option<f64>);
16360                                impl<'de> serde::de::Deserialize<'de> for __With {
16361                                    fn deserialize<D>(
16362                                        deserializer: D,
16363                                    ) -> std::result::Result<Self, D::Error>
16364                                    where
16365                                        D: serde::de::Deserializer<'de>,
16366                                    {
16367                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
16368                                    }
16369                                }
16370                                result.distance_meters =
16371                                    map.next_value::<__With>()?.0.unwrap_or_default();
16372                            }
16373                            __FieldTag::__traffic_info_unavailable => {
16374                                if !fields.insert(__FieldTag::__traffic_info_unavailable) {
16375                                    return std::result::Result::Err(A::Error::duplicate_field(
16376                                        "multiple values for traffic_info_unavailable",
16377                                    ));
16378                                }
16379                                result.traffic_info_unavailable = map
16380                                    .next_value::<std::option::Option<bool>>()?
16381                                    .unwrap_or_default();
16382                            }
16383                            __FieldTag::__route_polyline => {
16384                                if !fields.insert(__FieldTag::__route_polyline) {
16385                                    return std::result::Result::Err(A::Error::duplicate_field(
16386                                        "multiple values for route_polyline",
16387                                    ));
16388                                }
16389                                result.route_polyline = map.next_value::<std::option::Option<
16390                                    crate::model::shipment_route::EncodedPolyline,
16391                                >>()?;
16392                            }
16393                            __FieldTag::Unknown(key) => {
16394                                let value = map.next_value::<serde_json::Value>()?;
16395                                result._unknown_fields.insert(key, value);
16396                            }
16397                        }
16398                    }
16399                    std::result::Result::Ok(result)
16400                }
16401            }
16402            deserializer.deserialize_any(Visitor)
16403        }
16404    }
16405
16406    #[doc(hidden)]
16407    impl serde::ser::Serialize for TravelStep {
16408        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16409        where
16410            S: serde::ser::Serializer,
16411        {
16412            use serde::ser::SerializeMap;
16413            #[allow(unused_imports)]
16414            use std::option::Option::Some;
16415            let mut state = serializer.serialize_map(std::option::Option::None)?;
16416            if self.duration.is_some() {
16417                state.serialize_entry("duration", &self.duration)?;
16418            }
16419            if !wkt::internal::is_default(&self.distance_meters) {
16420                struct __With<'a>(&'a f64);
16421                impl<'a> serde::ser::Serialize for __With<'a> {
16422                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16423                    where
16424                        S: serde::ser::Serializer,
16425                    {
16426                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
16427                    }
16428                }
16429                state.serialize_entry("distanceMeters", &__With(&self.distance_meters))?;
16430            }
16431            if !wkt::internal::is_default(&self.traffic_info_unavailable) {
16432                state.serialize_entry("trafficInfoUnavailable", &self.traffic_info_unavailable)?;
16433            }
16434            if self.route_polyline.is_some() {
16435                state.serialize_entry("routePolyline", &self.route_polyline)?;
16436            }
16437            if !self._unknown_fields.is_empty() {
16438                for (key, value) in self._unknown_fields.iter() {
16439                    state.serialize_entry(key, &value)?;
16440                }
16441            }
16442            state.end()
16443        }
16444    }
16445}
16446
16447/// Specifies details of unperformed shipments in a solution. For trivial cases
16448/// and/or if we are able to identify the cause for skipping, we report the
16449/// reason here.
16450#[derive(Clone, Debug, Default, PartialEq)]
16451#[non_exhaustive]
16452pub struct SkippedShipment {
16453    /// The index corresponds to the index of the shipment in the source
16454    /// `ShipmentModel`.
16455    pub index: i32,
16456
16457    /// Copy of the corresponding
16458    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
16459    /// in the `Shipment`.
16460    ///
16461    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
16462    pub label: std::string::String,
16463
16464    /// A list of reasons that explain why the shipment was skipped. See comment
16465    /// above `Reason`.
16466    pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
16467
16468    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16469}
16470
16471impl SkippedShipment {
16472    pub fn new() -> Self {
16473        std::default::Default::default()
16474    }
16475
16476    /// Sets the value of [index][crate::model::SkippedShipment::index].
16477    pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
16478        self.index = v.into();
16479        self
16480    }
16481
16482    /// Sets the value of [label][crate::model::SkippedShipment::label].
16483    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16484        self.label = v.into();
16485        self
16486    }
16487
16488    /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
16489    pub fn set_reasons<T, V>(mut self, v: T) -> Self
16490    where
16491        T: std::iter::IntoIterator<Item = V>,
16492        V: std::convert::Into<crate::model::skipped_shipment::Reason>,
16493    {
16494        use std::iter::Iterator;
16495        self.reasons = v.into_iter().map(|i| i.into()).collect();
16496        self
16497    }
16498}
16499
16500impl wkt::message::Message for SkippedShipment {
16501    fn typename() -> &'static str {
16502        "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
16503    }
16504}
16505
16506#[doc(hidden)]
16507impl<'de> serde::de::Deserialize<'de> for SkippedShipment {
16508    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16509    where
16510        D: serde::Deserializer<'de>,
16511    {
16512        #[allow(non_camel_case_types)]
16513        #[doc(hidden)]
16514        #[derive(PartialEq, Eq, Hash)]
16515        enum __FieldTag {
16516            __index,
16517            __label,
16518            __reasons,
16519            Unknown(std::string::String),
16520        }
16521        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16522            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16523            where
16524                D: serde::Deserializer<'de>,
16525            {
16526                struct Visitor;
16527                impl<'de> serde::de::Visitor<'de> for Visitor {
16528                    type Value = __FieldTag;
16529                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16530                        formatter.write_str("a field name for SkippedShipment")
16531                    }
16532                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16533                    where
16534                        E: serde::de::Error,
16535                    {
16536                        use std::result::Result::Ok;
16537                        use std::string::ToString;
16538                        match value {
16539                            "index" => Ok(__FieldTag::__index),
16540                            "label" => Ok(__FieldTag::__label),
16541                            "reasons" => Ok(__FieldTag::__reasons),
16542                            _ => Ok(__FieldTag::Unknown(value.to_string())),
16543                        }
16544                    }
16545                }
16546                deserializer.deserialize_identifier(Visitor)
16547            }
16548        }
16549        struct Visitor;
16550        impl<'de> serde::de::Visitor<'de> for Visitor {
16551            type Value = SkippedShipment;
16552            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16553                formatter.write_str("struct SkippedShipment")
16554            }
16555            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16556            where
16557                A: serde::de::MapAccess<'de>,
16558            {
16559                #[allow(unused_imports)]
16560                use serde::de::Error;
16561                use std::option::Option::Some;
16562                let mut fields = std::collections::HashSet::new();
16563                let mut result = Self::Value::new();
16564                while let Some(tag) = map.next_key::<__FieldTag>()? {
16565                    #[allow(clippy::match_single_binding)]
16566                    match tag {
16567                        __FieldTag::__index => {
16568                            if !fields.insert(__FieldTag::__index) {
16569                                return std::result::Result::Err(A::Error::duplicate_field(
16570                                    "multiple values for index",
16571                                ));
16572                            }
16573                            struct __With(std::option::Option<i32>);
16574                            impl<'de> serde::de::Deserialize<'de> for __With {
16575                                fn deserialize<D>(
16576                                    deserializer: D,
16577                                ) -> std::result::Result<Self, D::Error>
16578                                where
16579                                    D: serde::de::Deserializer<'de>,
16580                                {
16581                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
16582                                }
16583                            }
16584                            result.index = map.next_value::<__With>()?.0.unwrap_or_default();
16585                        }
16586                        __FieldTag::__label => {
16587                            if !fields.insert(__FieldTag::__label) {
16588                                return std::result::Result::Err(A::Error::duplicate_field(
16589                                    "multiple values for label",
16590                                ));
16591                            }
16592                            result.label = map
16593                                .next_value::<std::option::Option<std::string::String>>()?
16594                                .unwrap_or_default();
16595                        }
16596                        __FieldTag::__reasons => {
16597                            if !fields.insert(__FieldTag::__reasons) {
16598                                return std::result::Result::Err(A::Error::duplicate_field(
16599                                    "multiple values for reasons",
16600                                ));
16601                            }
16602                            result.reasons = map
16603                                .next_value::<std::option::Option<
16604                                    std::vec::Vec<crate::model::skipped_shipment::Reason>,
16605                                >>()?
16606                                .unwrap_or_default();
16607                        }
16608                        __FieldTag::Unknown(key) => {
16609                            let value = map.next_value::<serde_json::Value>()?;
16610                            result._unknown_fields.insert(key, value);
16611                        }
16612                    }
16613                }
16614                std::result::Result::Ok(result)
16615            }
16616        }
16617        deserializer.deserialize_any(Visitor)
16618    }
16619}
16620
16621#[doc(hidden)]
16622impl serde::ser::Serialize for SkippedShipment {
16623    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16624    where
16625        S: serde::ser::Serializer,
16626    {
16627        use serde::ser::SerializeMap;
16628        #[allow(unused_imports)]
16629        use std::option::Option::Some;
16630        let mut state = serializer.serialize_map(std::option::Option::None)?;
16631        if !wkt::internal::is_default(&self.index) {
16632            struct __With<'a>(&'a i32);
16633            impl<'a> serde::ser::Serialize for __With<'a> {
16634                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16635                where
16636                    S: serde::ser::Serializer,
16637                {
16638                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
16639                }
16640            }
16641            state.serialize_entry("index", &__With(&self.index))?;
16642        }
16643        if !self.label.is_empty() {
16644            state.serialize_entry("label", &self.label)?;
16645        }
16646        if !self.reasons.is_empty() {
16647            state.serialize_entry("reasons", &self.reasons)?;
16648        }
16649        if !self._unknown_fields.is_empty() {
16650            for (key, value) in self._unknown_fields.iter() {
16651                state.serialize_entry(key, &value)?;
16652            }
16653        }
16654        state.end()
16655    }
16656}
16657
16658/// Defines additional types related to [SkippedShipment].
16659pub mod skipped_shipment {
16660    #[allow(unused_imports)]
16661    use super::*;
16662
16663    /// If we can explain why the shipment was skipped, reasons will be listed
16664    /// here. If the reason is not the same for all vehicles, `reason` will have
16665    /// more than 1 element. A skipped shipment cannot have duplicate reasons,
16666    /// i.e. where all fields are the same except for `example_vehicle_index`.
16667    /// Example:
16668    ///
16669    /// ```norust
16670    /// reasons {
16671    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
16672    ///   example_vehicle_index: 1
16673    ///   example_exceeded_capacity_type: "Apples"
16674    /// }
16675    /// reasons {
16676    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
16677    ///   example_vehicle_index: 3
16678    ///   example_exceeded_capacity_type: "Pears"
16679    /// }
16680    /// reasons {
16681    ///   code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
16682    ///   example_vehicle_index: 1
16683    /// }
16684    /// ```
16685    ///
16686    /// The skipped shipment is incompatible with all vehicles. The reasons may
16687    /// be different for all vehicles but at least one vehicle's "Apples"
16688    /// capacity would be exceeded (including vehicle 1), at least one vehicle's
16689    /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
16690    /// vehicle's distance limit would be exceeded (including vehicle 1).
16691    #[derive(Clone, Debug, Default, PartialEq)]
16692    #[non_exhaustive]
16693    pub struct Reason {
16694        /// Refer to the comments of Code.
16695        pub code: crate::model::skipped_shipment::reason::Code,
16696
16697        /// If the reason is related to a shipment-vehicle incompatibility, this
16698        /// field provides the index of one relevant vehicle.
16699        pub example_vehicle_index: std::option::Option<i32>,
16700
16701        /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
16702        /// capacity type that is exceeded.
16703        pub example_exceeded_capacity_type: std::string::String,
16704
16705        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16706    }
16707
16708    impl Reason {
16709        pub fn new() -> Self {
16710            std::default::Default::default()
16711        }
16712
16713        /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
16714        pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
16715            mut self,
16716            v: T,
16717        ) -> Self {
16718            self.code = v.into();
16719            self
16720        }
16721
16722        /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
16723        pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
16724        where
16725            T: std::convert::Into<i32>,
16726        {
16727            self.example_vehicle_index = std::option::Option::Some(v.into());
16728            self
16729        }
16730
16731        /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
16732        pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
16733        where
16734            T: std::convert::Into<i32>,
16735        {
16736            self.example_vehicle_index = v.map(|x| x.into());
16737            self
16738        }
16739
16740        /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
16741        pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
16742            mut self,
16743            v: T,
16744        ) -> Self {
16745            self.example_exceeded_capacity_type = v.into();
16746            self
16747        }
16748    }
16749
16750    impl wkt::message::Message for Reason {
16751        fn typename() -> &'static str {
16752            "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
16753        }
16754    }
16755
16756    #[doc(hidden)]
16757    impl<'de> serde::de::Deserialize<'de> for Reason {
16758        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16759        where
16760            D: serde::Deserializer<'de>,
16761        {
16762            #[allow(non_camel_case_types)]
16763            #[doc(hidden)]
16764            #[derive(PartialEq, Eq, Hash)]
16765            enum __FieldTag {
16766                __code,
16767                __example_vehicle_index,
16768                __example_exceeded_capacity_type,
16769                Unknown(std::string::String),
16770            }
16771            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16772                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16773                where
16774                    D: serde::Deserializer<'de>,
16775                {
16776                    struct Visitor;
16777                    impl<'de> serde::de::Visitor<'de> for Visitor {
16778                        type Value = __FieldTag;
16779                        fn expecting(
16780                            &self,
16781                            formatter: &mut std::fmt::Formatter,
16782                        ) -> std::fmt::Result {
16783                            formatter.write_str("a field name for Reason")
16784                        }
16785                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16786                        where
16787                            E: serde::de::Error,
16788                        {
16789                            use std::result::Result::Ok;
16790                            use std::string::ToString;
16791                            match value {
16792                                "code" => Ok(__FieldTag::__code),
16793                                "exampleVehicleIndex" => Ok(__FieldTag::__example_vehicle_index),
16794                                "example_vehicle_index" => Ok(__FieldTag::__example_vehicle_index),
16795                                "exampleExceededCapacityType" => {
16796                                    Ok(__FieldTag::__example_exceeded_capacity_type)
16797                                }
16798                                "example_exceeded_capacity_type" => {
16799                                    Ok(__FieldTag::__example_exceeded_capacity_type)
16800                                }
16801                                _ => Ok(__FieldTag::Unknown(value.to_string())),
16802                            }
16803                        }
16804                    }
16805                    deserializer.deserialize_identifier(Visitor)
16806                }
16807            }
16808            struct Visitor;
16809            impl<'de> serde::de::Visitor<'de> for Visitor {
16810                type Value = Reason;
16811                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16812                    formatter.write_str("struct Reason")
16813                }
16814                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16815                where
16816                    A: serde::de::MapAccess<'de>,
16817                {
16818                    #[allow(unused_imports)]
16819                    use serde::de::Error;
16820                    use std::option::Option::Some;
16821                    let mut fields = std::collections::HashSet::new();
16822                    let mut result = Self::Value::new();
16823                    while let Some(tag) = map.next_key::<__FieldTag>()? {
16824                        #[allow(clippy::match_single_binding)]
16825                        match tag {
16826                            __FieldTag::__code => {
16827                                if !fields.insert(__FieldTag::__code) {
16828                                    return std::result::Result::Err(A::Error::duplicate_field(
16829                                        "multiple values for code",
16830                                    ));
16831                                }
16832                                result.code = map
16833                                    .next_value::<std::option::Option<
16834                                        crate::model::skipped_shipment::reason::Code,
16835                                    >>()?
16836                                    .unwrap_or_default();
16837                            }
16838                            __FieldTag::__example_vehicle_index => {
16839                                if !fields.insert(__FieldTag::__example_vehicle_index) {
16840                                    return std::result::Result::Err(A::Error::duplicate_field(
16841                                        "multiple values for example_vehicle_index",
16842                                    ));
16843                                }
16844                                struct __With(std::option::Option<i32>);
16845                                impl<'de> serde::de::Deserialize<'de> for __With {
16846                                    fn deserialize<D>(
16847                                        deserializer: D,
16848                                    ) -> std::result::Result<Self, D::Error>
16849                                    where
16850                                        D: serde::de::Deserializer<'de>,
16851                                    {
16852                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
16853                                    }
16854                                }
16855                                result.example_vehicle_index = map.next_value::<__With>()?.0;
16856                            }
16857                            __FieldTag::__example_exceeded_capacity_type => {
16858                                if !fields.insert(__FieldTag::__example_exceeded_capacity_type) {
16859                                    return std::result::Result::Err(A::Error::duplicate_field(
16860                                        "multiple values for example_exceeded_capacity_type",
16861                                    ));
16862                                }
16863                                result.example_exceeded_capacity_type = map
16864                                    .next_value::<std::option::Option<std::string::String>>()?
16865                                    .unwrap_or_default();
16866                            }
16867                            __FieldTag::Unknown(key) => {
16868                                let value = map.next_value::<serde_json::Value>()?;
16869                                result._unknown_fields.insert(key, value);
16870                            }
16871                        }
16872                    }
16873                    std::result::Result::Ok(result)
16874                }
16875            }
16876            deserializer.deserialize_any(Visitor)
16877        }
16878    }
16879
16880    #[doc(hidden)]
16881    impl serde::ser::Serialize for Reason {
16882        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16883        where
16884            S: serde::ser::Serializer,
16885        {
16886            use serde::ser::SerializeMap;
16887            #[allow(unused_imports)]
16888            use std::option::Option::Some;
16889            let mut state = serializer.serialize_map(std::option::Option::None)?;
16890            if !wkt::internal::is_default(&self.code) {
16891                state.serialize_entry("code", &self.code)?;
16892            }
16893            if self.example_vehicle_index.is_some() {
16894                struct __With<'a>(&'a std::option::Option<i32>);
16895                impl<'a> serde::ser::Serialize for __With<'a> {
16896                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16897                    where
16898                        S: serde::ser::Serializer,
16899                    {
16900                        serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
16901                            self.0, serializer,
16902                        )
16903                    }
16904                }
16905                state
16906                    .serialize_entry("exampleVehicleIndex", &__With(&self.example_vehicle_index))?;
16907            }
16908            if !self.example_exceeded_capacity_type.is_empty() {
16909                state.serialize_entry(
16910                    "exampleExceededCapacityType",
16911                    &self.example_exceeded_capacity_type,
16912                )?;
16913            }
16914            if !self._unknown_fields.is_empty() {
16915                for (key, value) in self._unknown_fields.iter() {
16916                    state.serialize_entry(key, &value)?;
16917                }
16918            }
16919            state.end()
16920        }
16921    }
16922
16923    /// Defines additional types related to [Reason].
16924    pub mod reason {
16925        #[allow(unused_imports)]
16926        use super::*;
16927
16928        /// Code identifying the reason type. The order here is meaningless. In
16929        /// particular, it gives no indication of whether a given reason will
16930        /// appear before another in the solution, if both apply.
16931        ///
16932        /// # Working with unknown values
16933        ///
16934        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
16935        /// additional enum variants at any time. Adding new variants is not considered
16936        /// a breaking change. Applications should write their code in anticipation of:
16937        ///
16938        /// - New values appearing in future releases of the client library, **and**
16939        /// - New values received dynamically, without application changes.
16940        ///
16941        /// Please consult the [Working with enums] section in the user guide for some
16942        /// guidelines.
16943        ///
16944        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
16945        #[derive(Clone, Debug, PartialEq)]
16946        #[non_exhaustive]
16947        pub enum Code {
16948            /// This should never be used. If we are unable to understand why a
16949            /// shipment was skipped, we simply return an empty set of reasons.
16950            Unspecified,
16951            /// There is no vehicle in the model making all shipments infeasible.
16952            NoVehicle,
16953            /// The demand of the shipment exceeds a vehicle's capacity for some
16954            /// capacity types, one of which is `example_exceeded_capacity_type`.
16955            DemandExceedsVehicleCapacity,
16956            /// The minimum distance necessary to perform this shipment, i.e. from
16957            /// the vehicle's `start_location` to the shipment's pickup and/or delivery
16958            /// locations and to the vehicle's end location exceeds the vehicle's
16959            /// `route_distance_limit`.
16960            ///
16961            /// Note that for this computation we use the geodesic distances.
16962            CannotBePerformedWithinVehicleDistanceLimit,
16963            /// The minimum time necessary to perform this shipment, including travel
16964            /// time, wait time and service time exceeds the vehicle's
16965            /// `route_duration_limit`.
16966            ///
16967            /// Note: travel time is computed in the best-case scenario, namely as
16968            /// geodesic distance x 36 m/s (roughly 130 km/hour).
16969            CannotBePerformedWithinVehicleDurationLimit,
16970            /// Same as above but we only compare minimum travel time and the
16971            /// vehicle's `travel_duration_limit`.
16972            CannotBePerformedWithinVehicleTravelDurationLimit,
16973            /// The vehicle cannot perform this shipment in the best-case scenario
16974            /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
16975            /// computation) if it starts at its earliest start time: the total time
16976            /// would make the vehicle end after its latest end time.
16977            CannotBePerformedWithinVehicleTimeWindows,
16978            /// The `allowed_vehicle_indices` field of the shipment is not empty and
16979            /// this vehicle does not belong to it.
16980            VehicleNotAllowed,
16981            /// If set, the enum was initialized with an unknown value.
16982            ///
16983            /// Applications can examine the value using [Code::value] or
16984            /// [Code::name].
16985            UnknownValue(code::UnknownValue),
16986        }
16987
16988        #[doc(hidden)]
16989        pub mod code {
16990            #[allow(unused_imports)]
16991            use super::*;
16992            #[derive(Clone, Debug, PartialEq)]
16993            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
16994        }
16995
16996        impl Code {
16997            /// Gets the enum value.
16998            ///
16999            /// Returns `None` if the enum contains an unknown value deserialized from
17000            /// the string representation of enums.
17001            pub fn value(&self) -> std::option::Option<i32> {
17002                match self {
17003                    Self::Unspecified => std::option::Option::Some(0),
17004                    Self::NoVehicle => std::option::Option::Some(1),
17005                    Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
17006                    Self::CannotBePerformedWithinVehicleDistanceLimit => {
17007                        std::option::Option::Some(3)
17008                    }
17009                    Self::CannotBePerformedWithinVehicleDurationLimit => {
17010                        std::option::Option::Some(4)
17011                    }
17012                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17013                        std::option::Option::Some(5)
17014                    }
17015                    Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
17016                    Self::VehicleNotAllowed => std::option::Option::Some(7),
17017                    Self::UnknownValue(u) => u.0.value(),
17018                }
17019            }
17020
17021            /// Gets the enum value as a string.
17022            ///
17023            /// Returns `None` if the enum contains an unknown value deserialized from
17024            /// the integer representation of enums.
17025            pub fn name(&self) -> std::option::Option<&str> {
17026                match self {
17027                    Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
17028                    Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
17029                    Self::DemandExceedsVehicleCapacity => {
17030                        std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
17031                    }
17032                    Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
17033                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
17034                    ),
17035                    Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
17036                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
17037                    ),
17038                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17039                        std::option::Option::Some(
17040                            "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
17041                        )
17042                    }
17043                    Self::CannotBePerformedWithinVehicleTimeWindows => {
17044                        std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
17045                    }
17046                    Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
17047                    Self::UnknownValue(u) => u.0.name(),
17048                }
17049            }
17050        }
17051
17052        impl std::default::Default for Code {
17053            fn default() -> Self {
17054                use std::convert::From;
17055                Self::from(0)
17056            }
17057        }
17058
17059        impl std::fmt::Display for Code {
17060            fn fmt(
17061                &self,
17062                f: &mut std::fmt::Formatter<'_>,
17063            ) -> std::result::Result<(), std::fmt::Error> {
17064                wkt::internal::display_enum(f, self.name(), self.value())
17065            }
17066        }
17067
17068        impl std::convert::From<i32> for Code {
17069            fn from(value: i32) -> Self {
17070                match value {
17071                    0 => Self::Unspecified,
17072                    1 => Self::NoVehicle,
17073                    2 => Self::DemandExceedsVehicleCapacity,
17074                    3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
17075                    4 => Self::CannotBePerformedWithinVehicleDurationLimit,
17076                    5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
17077                    6 => Self::CannotBePerformedWithinVehicleTimeWindows,
17078                    7 => Self::VehicleNotAllowed,
17079                    _ => Self::UnknownValue(code::UnknownValue(
17080                        wkt::internal::UnknownEnumValue::Integer(value),
17081                    )),
17082                }
17083            }
17084        }
17085
17086        impl std::convert::From<&str> for Code {
17087            fn from(value: &str) -> Self {
17088                use std::string::ToString;
17089                match value {
17090                    "CODE_UNSPECIFIED" => Self::Unspecified,
17091                    "NO_VEHICLE" => Self::NoVehicle,
17092                    "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
17093                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
17094                        Self::CannotBePerformedWithinVehicleDistanceLimit
17095                    }
17096                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
17097                        Self::CannotBePerformedWithinVehicleDurationLimit
17098                    }
17099                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
17100                        Self::CannotBePerformedWithinVehicleTravelDurationLimit
17101                    }
17102                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
17103                        Self::CannotBePerformedWithinVehicleTimeWindows
17104                    }
17105                    "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
17106                    _ => Self::UnknownValue(code::UnknownValue(
17107                        wkt::internal::UnknownEnumValue::String(value.to_string()),
17108                    )),
17109                }
17110            }
17111        }
17112
17113        impl serde::ser::Serialize for Code {
17114            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17115            where
17116                S: serde::Serializer,
17117            {
17118                match self {
17119                    Self::Unspecified => serializer.serialize_i32(0),
17120                    Self::NoVehicle => serializer.serialize_i32(1),
17121                    Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
17122                    Self::CannotBePerformedWithinVehicleDistanceLimit => {
17123                        serializer.serialize_i32(3)
17124                    }
17125                    Self::CannotBePerformedWithinVehicleDurationLimit => {
17126                        serializer.serialize_i32(4)
17127                    }
17128                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17129                        serializer.serialize_i32(5)
17130                    }
17131                    Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
17132                    Self::VehicleNotAllowed => serializer.serialize_i32(7),
17133                    Self::UnknownValue(u) => u.0.serialize(serializer),
17134                }
17135            }
17136        }
17137
17138        impl<'de> serde::de::Deserialize<'de> for Code {
17139            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17140            where
17141                D: serde::Deserializer<'de>,
17142            {
17143                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
17144                    ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
17145                ))
17146            }
17147        }
17148    }
17149}
17150
17151/// Aggregated metrics for
17152/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
17153/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
17154/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
17155/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
17156/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
17157///
17158/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
17159/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
17160/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
17161/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
17162#[derive(Clone, Debug, Default, PartialEq)]
17163#[non_exhaustive]
17164pub struct AggregatedMetrics {
17165    /// Number of shipments performed. Note that a pickup and delivery pair only
17166    /// counts once.
17167    pub performed_shipment_count: i32,
17168
17169    /// Total travel duration for a route or a solution.
17170    pub travel_duration: std::option::Option<wkt::Duration>,
17171
17172    /// Total wait duration for a route or a solution.
17173    pub wait_duration: std::option::Option<wkt::Duration>,
17174
17175    /// Total delay duration for a route or a solution.
17176    pub delay_duration: std::option::Option<wkt::Duration>,
17177
17178    /// Total break duration for a route or a solution.
17179    pub break_duration: std::option::Option<wkt::Duration>,
17180
17181    /// Total visit duration for a route or a solution.
17182    pub visit_duration: std::option::Option<wkt::Duration>,
17183
17184    /// The total duration should be equal to the sum of all durations above.
17185    /// For routes, it also corresponds to:
17186    /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
17187    /// `-`
17188    /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
17189    ///
17190    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
17191    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
17192    pub total_duration: std::option::Option<wkt::Duration>,
17193
17194    /// Total travel distance for a route or a solution.
17195    pub travel_distance_meters: f64,
17196
17197    /// Maximum load achieved over the entire route (resp. solution), for each of
17198    /// the quantities on this route (resp. solution), computed as the maximum over
17199    /// all
17200    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
17201    /// (resp.
17202    /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
17203    ///
17204    /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
17205    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
17206    pub max_loads:
17207        std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
17208
17209    /// Deprecated: Use
17210    /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
17211    /// and
17212    /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
17213    /// instead.
17214    ///
17215    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
17216    /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
17217    #[deprecated]
17218    pub costs: std::collections::HashMap<std::string::String, f64>,
17219
17220    /// Deprecated: Use
17221    /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
17222    /// and
17223    /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
17224    /// instead.
17225    ///
17226    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
17227    /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
17228    #[deprecated]
17229    pub total_cost: f64,
17230
17231    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17232}
17233
17234impl AggregatedMetrics {
17235    pub fn new() -> Self {
17236        std::default::Default::default()
17237    }
17238
17239    /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
17240    pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
17241        self.performed_shipment_count = v.into();
17242        self
17243    }
17244
17245    /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
17246    pub fn set_travel_duration<T>(mut self, v: T) -> Self
17247    where
17248        T: std::convert::Into<wkt::Duration>,
17249    {
17250        self.travel_duration = std::option::Option::Some(v.into());
17251        self
17252    }
17253
17254    /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
17255    pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
17256    where
17257        T: std::convert::Into<wkt::Duration>,
17258    {
17259        self.travel_duration = v.map(|x| x.into());
17260        self
17261    }
17262
17263    /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
17264    pub fn set_wait_duration<T>(mut self, v: T) -> Self
17265    where
17266        T: std::convert::Into<wkt::Duration>,
17267    {
17268        self.wait_duration = std::option::Option::Some(v.into());
17269        self
17270    }
17271
17272    /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
17273    pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
17274    where
17275        T: std::convert::Into<wkt::Duration>,
17276    {
17277        self.wait_duration = v.map(|x| x.into());
17278        self
17279    }
17280
17281    /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
17282    pub fn set_delay_duration<T>(mut self, v: T) -> Self
17283    where
17284        T: std::convert::Into<wkt::Duration>,
17285    {
17286        self.delay_duration = std::option::Option::Some(v.into());
17287        self
17288    }
17289
17290    /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
17291    pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
17292    where
17293        T: std::convert::Into<wkt::Duration>,
17294    {
17295        self.delay_duration = v.map(|x| x.into());
17296        self
17297    }
17298
17299    /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
17300    pub fn set_break_duration<T>(mut self, v: T) -> Self
17301    where
17302        T: std::convert::Into<wkt::Duration>,
17303    {
17304        self.break_duration = std::option::Option::Some(v.into());
17305        self
17306    }
17307
17308    /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
17309    pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
17310    where
17311        T: std::convert::Into<wkt::Duration>,
17312    {
17313        self.break_duration = v.map(|x| x.into());
17314        self
17315    }
17316
17317    /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
17318    pub fn set_visit_duration<T>(mut self, v: T) -> Self
17319    where
17320        T: std::convert::Into<wkt::Duration>,
17321    {
17322        self.visit_duration = std::option::Option::Some(v.into());
17323        self
17324    }
17325
17326    /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
17327    pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
17328    where
17329        T: std::convert::Into<wkt::Duration>,
17330    {
17331        self.visit_duration = v.map(|x| x.into());
17332        self
17333    }
17334
17335    /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
17336    pub fn set_total_duration<T>(mut self, v: T) -> Self
17337    where
17338        T: std::convert::Into<wkt::Duration>,
17339    {
17340        self.total_duration = std::option::Option::Some(v.into());
17341        self
17342    }
17343
17344    /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
17345    pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
17346    where
17347        T: std::convert::Into<wkt::Duration>,
17348    {
17349        self.total_duration = v.map(|x| x.into());
17350        self
17351    }
17352
17353    /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
17354    pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
17355        self.travel_distance_meters = v.into();
17356        self
17357    }
17358
17359    /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
17360    pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
17361    where
17362        T: std::iter::IntoIterator<Item = (K, V)>,
17363        K: std::convert::Into<std::string::String>,
17364        V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
17365    {
17366        use std::iter::Iterator;
17367        self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
17368        self
17369    }
17370
17371    /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
17372    #[deprecated]
17373    pub fn set_costs<T, K, V>(mut self, v: T) -> Self
17374    where
17375        T: std::iter::IntoIterator<Item = (K, V)>,
17376        K: std::convert::Into<std::string::String>,
17377        V: std::convert::Into<f64>,
17378    {
17379        use std::iter::Iterator;
17380        self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
17381        self
17382    }
17383
17384    /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
17385    #[deprecated]
17386    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
17387        self.total_cost = v.into();
17388        self
17389    }
17390}
17391
17392impl wkt::message::Message for AggregatedMetrics {
17393    fn typename() -> &'static str {
17394        "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
17395    }
17396}
17397
17398#[doc(hidden)]
17399impl<'de> serde::de::Deserialize<'de> for AggregatedMetrics {
17400    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17401    where
17402        D: serde::Deserializer<'de>,
17403    {
17404        #[allow(non_camel_case_types)]
17405        #[doc(hidden)]
17406        #[derive(PartialEq, Eq, Hash)]
17407        enum __FieldTag {
17408            __performed_shipment_count,
17409            __travel_duration,
17410            __wait_duration,
17411            __delay_duration,
17412            __break_duration,
17413            __visit_duration,
17414            __total_duration,
17415            __travel_distance_meters,
17416            __max_loads,
17417            __costs,
17418            __total_cost,
17419            Unknown(std::string::String),
17420        }
17421        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17422            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17423            where
17424                D: serde::Deserializer<'de>,
17425            {
17426                struct Visitor;
17427                impl<'de> serde::de::Visitor<'de> for Visitor {
17428                    type Value = __FieldTag;
17429                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17430                        formatter.write_str("a field name for AggregatedMetrics")
17431                    }
17432                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17433                    where
17434                        E: serde::de::Error,
17435                    {
17436                        use std::result::Result::Ok;
17437                        use std::string::ToString;
17438                        match value {
17439                            "performedShipmentCount" => Ok(__FieldTag::__performed_shipment_count),
17440                            "performed_shipment_count" => {
17441                                Ok(__FieldTag::__performed_shipment_count)
17442                            }
17443                            "travelDuration" => Ok(__FieldTag::__travel_duration),
17444                            "travel_duration" => Ok(__FieldTag::__travel_duration),
17445                            "waitDuration" => Ok(__FieldTag::__wait_duration),
17446                            "wait_duration" => Ok(__FieldTag::__wait_duration),
17447                            "delayDuration" => Ok(__FieldTag::__delay_duration),
17448                            "delay_duration" => Ok(__FieldTag::__delay_duration),
17449                            "breakDuration" => Ok(__FieldTag::__break_duration),
17450                            "break_duration" => Ok(__FieldTag::__break_duration),
17451                            "visitDuration" => Ok(__FieldTag::__visit_duration),
17452                            "visit_duration" => Ok(__FieldTag::__visit_duration),
17453                            "totalDuration" => Ok(__FieldTag::__total_duration),
17454                            "total_duration" => Ok(__FieldTag::__total_duration),
17455                            "travelDistanceMeters" => Ok(__FieldTag::__travel_distance_meters),
17456                            "travel_distance_meters" => Ok(__FieldTag::__travel_distance_meters),
17457                            "maxLoads" => Ok(__FieldTag::__max_loads),
17458                            "max_loads" => Ok(__FieldTag::__max_loads),
17459                            "costs" => Ok(__FieldTag::__costs),
17460                            "totalCost" => Ok(__FieldTag::__total_cost),
17461                            "total_cost" => Ok(__FieldTag::__total_cost),
17462                            _ => Ok(__FieldTag::Unknown(value.to_string())),
17463                        }
17464                    }
17465                }
17466                deserializer.deserialize_identifier(Visitor)
17467            }
17468        }
17469        struct Visitor;
17470        impl<'de> serde::de::Visitor<'de> for Visitor {
17471            type Value = AggregatedMetrics;
17472            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17473                formatter.write_str("struct AggregatedMetrics")
17474            }
17475            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17476            where
17477                A: serde::de::MapAccess<'de>,
17478            {
17479                #[allow(unused_imports)]
17480                use serde::de::Error;
17481                use std::option::Option::Some;
17482                let mut fields = std::collections::HashSet::new();
17483                let mut result = Self::Value::new();
17484                while let Some(tag) = map.next_key::<__FieldTag>()? {
17485                    #[allow(clippy::match_single_binding)]
17486                    match tag {
17487                        __FieldTag::__performed_shipment_count => {
17488                            if !fields.insert(__FieldTag::__performed_shipment_count) {
17489                                return std::result::Result::Err(A::Error::duplicate_field(
17490                                    "multiple values for performed_shipment_count",
17491                                ));
17492                            }
17493                            struct __With(std::option::Option<i32>);
17494                            impl<'de> serde::de::Deserialize<'de> for __With {
17495                                fn deserialize<D>(
17496                                    deserializer: D,
17497                                ) -> std::result::Result<Self, D::Error>
17498                                where
17499                                    D: serde::de::Deserializer<'de>,
17500                                {
17501                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
17502                                }
17503                            }
17504                            result.performed_shipment_count =
17505                                map.next_value::<__With>()?.0.unwrap_or_default();
17506                        }
17507                        __FieldTag::__travel_duration => {
17508                            if !fields.insert(__FieldTag::__travel_duration) {
17509                                return std::result::Result::Err(A::Error::duplicate_field(
17510                                    "multiple values for travel_duration",
17511                                ));
17512                            }
17513                            result.travel_duration =
17514                                map.next_value::<std::option::Option<wkt::Duration>>()?;
17515                        }
17516                        __FieldTag::__wait_duration => {
17517                            if !fields.insert(__FieldTag::__wait_duration) {
17518                                return std::result::Result::Err(A::Error::duplicate_field(
17519                                    "multiple values for wait_duration",
17520                                ));
17521                            }
17522                            result.wait_duration =
17523                                map.next_value::<std::option::Option<wkt::Duration>>()?;
17524                        }
17525                        __FieldTag::__delay_duration => {
17526                            if !fields.insert(__FieldTag::__delay_duration) {
17527                                return std::result::Result::Err(A::Error::duplicate_field(
17528                                    "multiple values for delay_duration",
17529                                ));
17530                            }
17531                            result.delay_duration =
17532                                map.next_value::<std::option::Option<wkt::Duration>>()?;
17533                        }
17534                        __FieldTag::__break_duration => {
17535                            if !fields.insert(__FieldTag::__break_duration) {
17536                                return std::result::Result::Err(A::Error::duplicate_field(
17537                                    "multiple values for break_duration",
17538                                ));
17539                            }
17540                            result.break_duration =
17541                                map.next_value::<std::option::Option<wkt::Duration>>()?;
17542                        }
17543                        __FieldTag::__visit_duration => {
17544                            if !fields.insert(__FieldTag::__visit_duration) {
17545                                return std::result::Result::Err(A::Error::duplicate_field(
17546                                    "multiple values for visit_duration",
17547                                ));
17548                            }
17549                            result.visit_duration =
17550                                map.next_value::<std::option::Option<wkt::Duration>>()?;
17551                        }
17552                        __FieldTag::__total_duration => {
17553                            if !fields.insert(__FieldTag::__total_duration) {
17554                                return std::result::Result::Err(A::Error::duplicate_field(
17555                                    "multiple values for total_duration",
17556                                ));
17557                            }
17558                            result.total_duration =
17559                                map.next_value::<std::option::Option<wkt::Duration>>()?;
17560                        }
17561                        __FieldTag::__travel_distance_meters => {
17562                            if !fields.insert(__FieldTag::__travel_distance_meters) {
17563                                return std::result::Result::Err(A::Error::duplicate_field(
17564                                    "multiple values for travel_distance_meters",
17565                                ));
17566                            }
17567                            struct __With(std::option::Option<f64>);
17568                            impl<'de> serde::de::Deserialize<'de> for __With {
17569                                fn deserialize<D>(
17570                                    deserializer: D,
17571                                ) -> std::result::Result<Self, D::Error>
17572                                where
17573                                    D: serde::de::Deserializer<'de>,
17574                                {
17575                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
17576                                }
17577                            }
17578                            result.travel_distance_meters =
17579                                map.next_value::<__With>()?.0.unwrap_or_default();
17580                        }
17581                        __FieldTag::__max_loads => {
17582                            if !fields.insert(__FieldTag::__max_loads) {
17583                                return std::result::Result::Err(A::Error::duplicate_field(
17584                                    "multiple values for max_loads",
17585                                ));
17586                            }
17587                            result.max_loads = map
17588                                .next_value::<std::option::Option<
17589                                    std::collections::HashMap<
17590                                        std::string::String,
17591                                        crate::model::shipment_route::VehicleLoad,
17592                                    >,
17593                                >>()?
17594                                .unwrap_or_default();
17595                        }
17596                        __FieldTag::__costs => {
17597                            if !fields.insert(__FieldTag::__costs) {
17598                                return std::result::Result::Err(A::Error::duplicate_field(
17599                                    "multiple values for costs",
17600                                ));
17601                            }
17602                            struct __With(
17603                                std::option::Option<
17604                                    std::collections::HashMap<std::string::String, f64>,
17605                                >,
17606                            );
17607                            impl<'de> serde::de::Deserialize<'de> for __With {
17608                                fn deserialize<D>(
17609                                    deserializer: D,
17610                                ) -> std::result::Result<Self, D::Error>
17611                                where
17612                                    D: serde::de::Deserializer<'de>,
17613                                {
17614                                    serde_with::As::<
17615                                        std::option::Option<
17616                                            std::collections::HashMap<
17617                                                serde_with::Same,
17618                                                wkt::internal::F64,
17619                                            >,
17620                                        >,
17621                                    >::deserialize(deserializer)
17622                                    .map(__With)
17623                                }
17624                            }
17625                            result.costs = map.next_value::<__With>()?.0.unwrap_or_default();
17626                        }
17627                        __FieldTag::__total_cost => {
17628                            if !fields.insert(__FieldTag::__total_cost) {
17629                                return std::result::Result::Err(A::Error::duplicate_field(
17630                                    "multiple values for total_cost",
17631                                ));
17632                            }
17633                            struct __With(std::option::Option<f64>);
17634                            impl<'de> serde::de::Deserialize<'de> for __With {
17635                                fn deserialize<D>(
17636                                    deserializer: D,
17637                                ) -> std::result::Result<Self, D::Error>
17638                                where
17639                                    D: serde::de::Deserializer<'de>,
17640                                {
17641                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
17642                                }
17643                            }
17644                            result.total_cost = map.next_value::<__With>()?.0.unwrap_or_default();
17645                        }
17646                        __FieldTag::Unknown(key) => {
17647                            let value = map.next_value::<serde_json::Value>()?;
17648                            result._unknown_fields.insert(key, value);
17649                        }
17650                    }
17651                }
17652                std::result::Result::Ok(result)
17653            }
17654        }
17655        deserializer.deserialize_any(Visitor)
17656    }
17657}
17658
17659#[doc(hidden)]
17660impl serde::ser::Serialize for AggregatedMetrics {
17661    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17662    where
17663        S: serde::ser::Serializer,
17664    {
17665        use serde::ser::SerializeMap;
17666        #[allow(unused_imports)]
17667        use std::option::Option::Some;
17668        let mut state = serializer.serialize_map(std::option::Option::None)?;
17669        if !wkt::internal::is_default(&self.performed_shipment_count) {
17670            struct __With<'a>(&'a i32);
17671            impl<'a> serde::ser::Serialize for __With<'a> {
17672                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17673                where
17674                    S: serde::ser::Serializer,
17675                {
17676                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
17677                }
17678            }
17679            state.serialize_entry(
17680                "performedShipmentCount",
17681                &__With(&self.performed_shipment_count),
17682            )?;
17683        }
17684        if self.travel_duration.is_some() {
17685            state.serialize_entry("travelDuration", &self.travel_duration)?;
17686        }
17687        if self.wait_duration.is_some() {
17688            state.serialize_entry("waitDuration", &self.wait_duration)?;
17689        }
17690        if self.delay_duration.is_some() {
17691            state.serialize_entry("delayDuration", &self.delay_duration)?;
17692        }
17693        if self.break_duration.is_some() {
17694            state.serialize_entry("breakDuration", &self.break_duration)?;
17695        }
17696        if self.visit_duration.is_some() {
17697            state.serialize_entry("visitDuration", &self.visit_duration)?;
17698        }
17699        if self.total_duration.is_some() {
17700            state.serialize_entry("totalDuration", &self.total_duration)?;
17701        }
17702        if !wkt::internal::is_default(&self.travel_distance_meters) {
17703            struct __With<'a>(&'a f64);
17704            impl<'a> serde::ser::Serialize for __With<'a> {
17705                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17706                where
17707                    S: serde::ser::Serializer,
17708                {
17709                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
17710                }
17711            }
17712            state.serialize_entry(
17713                "travelDistanceMeters",
17714                &__With(&self.travel_distance_meters),
17715            )?;
17716        }
17717        if !self.max_loads.is_empty() {
17718            state.serialize_entry("maxLoads", &self.max_loads)?;
17719        }
17720        if !self.costs.is_empty() {
17721            struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
17722            impl<'a> serde::ser::Serialize for __With<'a> {
17723                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17724                where
17725                    S: serde::ser::Serializer,
17726                {
17727                    serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::F64> >::serialize(self.0, serializer)
17728                }
17729            }
17730            state.serialize_entry("costs", &__With(&self.costs))?;
17731        }
17732        if !wkt::internal::is_default(&self.total_cost) {
17733            struct __With<'a>(&'a f64);
17734            impl<'a> serde::ser::Serialize for __With<'a> {
17735                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17736                where
17737                    S: serde::ser::Serializer,
17738                {
17739                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
17740                }
17741            }
17742            state.serialize_entry("totalCost", &__With(&self.total_cost))?;
17743        }
17744        if !self._unknown_fields.is_empty() {
17745            for (key, value) in self._unknown_fields.iter() {
17746                state.serialize_entry(key, &value)?;
17747            }
17748        }
17749        state.end()
17750    }
17751}
17752
17753/// Solution injected in the request including information about which visits
17754/// must be constrained and how they must be constrained.
17755#[derive(Clone, Debug, Default, PartialEq)]
17756#[non_exhaustive]
17757pub struct InjectedSolutionConstraint {
17758    /// Routes of the solution to inject. Some routes may be omitted from the
17759    /// original solution. The routes and skipped shipments must satisfy the basic
17760    /// validity assumptions listed for `injected_first_solution_routes`.
17761    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
17762
17763    /// Skipped shipments of the solution to inject. Some may be omitted from the
17764    /// original solution. See the `routes` field.
17765    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
17766
17767    /// For zero or more groups of vehicles, specifies when and how much to relax
17768    /// constraints. If this field is empty, all non-empty vehicle routes are
17769    /// fully constrained.
17770    pub constraint_relaxations:
17771        std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
17772
17773    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17774}
17775
17776impl InjectedSolutionConstraint {
17777    pub fn new() -> Self {
17778        std::default::Default::default()
17779    }
17780
17781    /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
17782    pub fn set_routes<T, V>(mut self, v: T) -> Self
17783    where
17784        T: std::iter::IntoIterator<Item = V>,
17785        V: std::convert::Into<crate::model::ShipmentRoute>,
17786    {
17787        use std::iter::Iterator;
17788        self.routes = v.into_iter().map(|i| i.into()).collect();
17789        self
17790    }
17791
17792    /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
17793    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
17794    where
17795        T: std::iter::IntoIterator<Item = V>,
17796        V: std::convert::Into<crate::model::SkippedShipment>,
17797    {
17798        use std::iter::Iterator;
17799        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
17800        self
17801    }
17802
17803    /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
17804    pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
17805    where
17806        T: std::iter::IntoIterator<Item = V>,
17807        V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
17808    {
17809        use std::iter::Iterator;
17810        self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
17811        self
17812    }
17813}
17814
17815impl wkt::message::Message for InjectedSolutionConstraint {
17816    fn typename() -> &'static str {
17817        "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
17818    }
17819}
17820
17821#[doc(hidden)]
17822impl<'de> serde::de::Deserialize<'de> for InjectedSolutionConstraint {
17823    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17824    where
17825        D: serde::Deserializer<'de>,
17826    {
17827        #[allow(non_camel_case_types)]
17828        #[doc(hidden)]
17829        #[derive(PartialEq, Eq, Hash)]
17830        enum __FieldTag {
17831            __routes,
17832            __skipped_shipments,
17833            __constraint_relaxations,
17834            Unknown(std::string::String),
17835        }
17836        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17837            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17838            where
17839                D: serde::Deserializer<'de>,
17840            {
17841                struct Visitor;
17842                impl<'de> serde::de::Visitor<'de> for Visitor {
17843                    type Value = __FieldTag;
17844                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17845                        formatter.write_str("a field name for InjectedSolutionConstraint")
17846                    }
17847                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17848                    where
17849                        E: serde::de::Error,
17850                    {
17851                        use std::result::Result::Ok;
17852                        use std::string::ToString;
17853                        match value {
17854                            "routes" => Ok(__FieldTag::__routes),
17855                            "skippedShipments" => Ok(__FieldTag::__skipped_shipments),
17856                            "skipped_shipments" => Ok(__FieldTag::__skipped_shipments),
17857                            "constraintRelaxations" => Ok(__FieldTag::__constraint_relaxations),
17858                            "constraint_relaxations" => Ok(__FieldTag::__constraint_relaxations),
17859                            _ => Ok(__FieldTag::Unknown(value.to_string())),
17860                        }
17861                    }
17862                }
17863                deserializer.deserialize_identifier(Visitor)
17864            }
17865        }
17866        struct Visitor;
17867        impl<'de> serde::de::Visitor<'de> for Visitor {
17868            type Value = InjectedSolutionConstraint;
17869            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17870                formatter.write_str("struct InjectedSolutionConstraint")
17871            }
17872            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17873            where
17874                A: serde::de::MapAccess<'de>,
17875            {
17876                #[allow(unused_imports)]
17877                use serde::de::Error;
17878                use std::option::Option::Some;
17879                let mut fields = std::collections::HashSet::new();
17880                let mut result = Self::Value::new();
17881                while let Some(tag) = map.next_key::<__FieldTag>()? {
17882                    #[allow(clippy::match_single_binding)]
17883                    match tag {
17884                        __FieldTag::__routes => {
17885                            if !fields.insert(__FieldTag::__routes) {
17886                                return std::result::Result::Err(A::Error::duplicate_field(
17887                                    "multiple values for routes",
17888                                ));
17889                            }
17890                            result.routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
17891                        }
17892                        __FieldTag::__skipped_shipments => {
17893                            if !fields.insert(__FieldTag::__skipped_shipments) {
17894                                return std::result::Result::Err(A::Error::duplicate_field(
17895                                    "multiple values for skipped_shipments",
17896                                ));
17897                            }
17898                            result.skipped_shipments =
17899                                map.next_value::<std::option::Option<
17900                                    std::vec::Vec<crate::model::SkippedShipment>,
17901                                >>()?
17902                                .unwrap_or_default();
17903                        }
17904                        __FieldTag::__constraint_relaxations => {
17905                            if !fields.insert(__FieldTag::__constraint_relaxations) {
17906                                return std::result::Result::Err(A::Error::duplicate_field(
17907                                    "multiple values for constraint_relaxations",
17908                                ));
17909                            }
17910                            result.constraint_relaxations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>>>()?.unwrap_or_default();
17911                        }
17912                        __FieldTag::Unknown(key) => {
17913                            let value = map.next_value::<serde_json::Value>()?;
17914                            result._unknown_fields.insert(key, value);
17915                        }
17916                    }
17917                }
17918                std::result::Result::Ok(result)
17919            }
17920        }
17921        deserializer.deserialize_any(Visitor)
17922    }
17923}
17924
17925#[doc(hidden)]
17926impl serde::ser::Serialize for InjectedSolutionConstraint {
17927    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17928    where
17929        S: serde::ser::Serializer,
17930    {
17931        use serde::ser::SerializeMap;
17932        #[allow(unused_imports)]
17933        use std::option::Option::Some;
17934        let mut state = serializer.serialize_map(std::option::Option::None)?;
17935        if !self.routes.is_empty() {
17936            state.serialize_entry("routes", &self.routes)?;
17937        }
17938        if !self.skipped_shipments.is_empty() {
17939            state.serialize_entry("skippedShipments", &self.skipped_shipments)?;
17940        }
17941        if !self.constraint_relaxations.is_empty() {
17942            state.serialize_entry("constraintRelaxations", &self.constraint_relaxations)?;
17943        }
17944        if !self._unknown_fields.is_empty() {
17945            for (key, value) in self._unknown_fields.iter() {
17946                state.serialize_entry(key, &value)?;
17947            }
17948        }
17949        state.end()
17950    }
17951}
17952
17953/// Defines additional types related to [InjectedSolutionConstraint].
17954pub mod injected_solution_constraint {
17955    #[allow(unused_imports)]
17956    use super::*;
17957
17958    /// For a group of vehicles, specifies at what threshold(s) constraints on
17959    /// visits will be relaxed and to which level. Shipments listed in
17960    /// the `skipped_shipment` field are constrained to be skipped; i.e., they
17961    /// cannot be performed.
17962    #[derive(Clone, Debug, Default, PartialEq)]
17963    #[non_exhaustive]
17964    pub struct ConstraintRelaxation {
17965        /// All the visit constraint relaxations that will apply to visits on
17966        /// routes with vehicles in `vehicle_indices`.
17967        pub relaxations: std::vec::Vec<
17968            crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
17969        >,
17970
17971        /// Specifies the vehicle indices to which the visit constraint
17972        /// `relaxations` apply. If empty, this is considered the default and the
17973        /// `relaxations` apply to all vehicles that are not specified in other
17974        /// `constraint_relaxations`. There can be at most one default, i.e., at
17975        /// most one constraint relaxation field is allowed empty
17976        /// `vehicle_indices`. A vehicle index can only be listed once, even within
17977        /// several `constraint_relaxations`.
17978        ///
17979        /// A vehicle index is mapped the same as
17980        /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
17981        /// if `interpret_injected_solutions_using_labels` is true (see `fields`
17982        /// comment).
17983        ///
17984        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
17985        pub vehicle_indices: std::vec::Vec<i32>,
17986
17987        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17988    }
17989
17990    impl ConstraintRelaxation {
17991        pub fn new() -> Self {
17992            std::default::Default::default()
17993        }
17994
17995        /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
17996        pub fn set_relaxations<T, V>(mut self, v: T) -> Self
17997        where
17998            T: std::iter::IntoIterator<Item = V>,
17999            V: std::convert::Into<
18000                    crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
18001                >,
18002        {
18003            use std::iter::Iterator;
18004            self.relaxations = v.into_iter().map(|i| i.into()).collect();
18005            self
18006        }
18007
18008        /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
18009        pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
18010        where
18011            T: std::iter::IntoIterator<Item = V>,
18012            V: std::convert::Into<i32>,
18013        {
18014            use std::iter::Iterator;
18015            self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
18016            self
18017        }
18018    }
18019
18020    impl wkt::message::Message for ConstraintRelaxation {
18021        fn typename() -> &'static str {
18022            "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
18023        }
18024    }
18025
18026    #[doc(hidden)]
18027    impl<'de> serde::de::Deserialize<'de> for ConstraintRelaxation {
18028        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18029        where
18030            D: serde::Deserializer<'de>,
18031        {
18032            #[allow(non_camel_case_types)]
18033            #[doc(hidden)]
18034            #[derive(PartialEq, Eq, Hash)]
18035            enum __FieldTag {
18036                __relaxations,
18037                __vehicle_indices,
18038                Unknown(std::string::String),
18039            }
18040            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18041                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18042                where
18043                    D: serde::Deserializer<'de>,
18044                {
18045                    struct Visitor;
18046                    impl<'de> serde::de::Visitor<'de> for Visitor {
18047                        type Value = __FieldTag;
18048                        fn expecting(
18049                            &self,
18050                            formatter: &mut std::fmt::Formatter,
18051                        ) -> std::fmt::Result {
18052                            formatter.write_str("a field name for ConstraintRelaxation")
18053                        }
18054                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18055                        where
18056                            E: serde::de::Error,
18057                        {
18058                            use std::result::Result::Ok;
18059                            use std::string::ToString;
18060                            match value {
18061                                "relaxations" => Ok(__FieldTag::__relaxations),
18062                                "vehicleIndices" => Ok(__FieldTag::__vehicle_indices),
18063                                "vehicle_indices" => Ok(__FieldTag::__vehicle_indices),
18064                                _ => Ok(__FieldTag::Unknown(value.to_string())),
18065                            }
18066                        }
18067                    }
18068                    deserializer.deserialize_identifier(Visitor)
18069                }
18070            }
18071            struct Visitor;
18072            impl<'de> serde::de::Visitor<'de> for Visitor {
18073                type Value = ConstraintRelaxation;
18074                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18075                    formatter.write_str("struct ConstraintRelaxation")
18076                }
18077                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18078                where
18079                    A: serde::de::MapAccess<'de>,
18080                {
18081                    #[allow(unused_imports)]
18082                    use serde::de::Error;
18083                    use std::option::Option::Some;
18084                    let mut fields = std::collections::HashSet::new();
18085                    let mut result = Self::Value::new();
18086                    while let Some(tag) = map.next_key::<__FieldTag>()? {
18087                        #[allow(clippy::match_single_binding)]
18088                        match tag {
18089                            __FieldTag::__relaxations => {
18090                                if !fields.insert(__FieldTag::__relaxations) {
18091                                    return std::result::Result::Err(A::Error::duplicate_field(
18092                                        "multiple values for relaxations",
18093                                    ));
18094                                }
18095                                result.relaxations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::injected_solution_constraint::constraint_relaxation::Relaxation>>>()?.unwrap_or_default();
18096                            }
18097                            __FieldTag::__vehicle_indices => {
18098                                if !fields.insert(__FieldTag::__vehicle_indices) {
18099                                    return std::result::Result::Err(A::Error::duplicate_field(
18100                                        "multiple values for vehicle_indices",
18101                                    ));
18102                                }
18103                                struct __With(std::option::Option<std::vec::Vec<i32>>);
18104                                impl<'de> serde::de::Deserialize<'de> for __With {
18105                                    fn deserialize<D>(
18106                                        deserializer: D,
18107                                    ) -> std::result::Result<Self, D::Error>
18108                                    where
18109                                        D: serde::de::Deserializer<'de>,
18110                                    {
18111                                        serde_with::As::<
18112                                            std::option::Option<std::vec::Vec<wkt::internal::I32>>,
18113                                        >::deserialize(
18114                                            deserializer
18115                                        )
18116                                        .map(__With)
18117                                    }
18118                                }
18119                                result.vehicle_indices =
18120                                    map.next_value::<__With>()?.0.unwrap_or_default();
18121                            }
18122                            __FieldTag::Unknown(key) => {
18123                                let value = map.next_value::<serde_json::Value>()?;
18124                                result._unknown_fields.insert(key, value);
18125                            }
18126                        }
18127                    }
18128                    std::result::Result::Ok(result)
18129                }
18130            }
18131            deserializer.deserialize_any(Visitor)
18132        }
18133    }
18134
18135    #[doc(hidden)]
18136    impl serde::ser::Serialize for ConstraintRelaxation {
18137        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18138        where
18139            S: serde::ser::Serializer,
18140        {
18141            use serde::ser::SerializeMap;
18142            #[allow(unused_imports)]
18143            use std::option::Option::Some;
18144            let mut state = serializer.serialize_map(std::option::Option::None)?;
18145            if !self.relaxations.is_empty() {
18146                state.serialize_entry("relaxations", &self.relaxations)?;
18147            }
18148            if !self.vehicle_indices.is_empty() {
18149                struct __With<'a>(&'a std::vec::Vec<i32>);
18150                impl<'a> serde::ser::Serialize for __With<'a> {
18151                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18152                    where
18153                        S: serde::ser::Serializer,
18154                    {
18155                        serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
18156                            self.0, serializer,
18157                        )
18158                    }
18159                }
18160                state.serialize_entry("vehicleIndices", &__With(&self.vehicle_indices))?;
18161            }
18162            if !self._unknown_fields.is_empty() {
18163                for (key, value) in self._unknown_fields.iter() {
18164                    state.serialize_entry(key, &value)?;
18165                }
18166            }
18167            state.end()
18168        }
18169    }
18170
18171    /// Defines additional types related to [ConstraintRelaxation].
18172    pub mod constraint_relaxation {
18173        #[allow(unused_imports)]
18174        use super::*;
18175
18176        /// If `relaxations` is empty, the start time and sequence of all visits
18177        /// on `routes` are fully constrained and no new visits may be inserted or
18178        /// added to those routes. Also, a vehicle's start and end time in
18179        /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
18180        /// visits and has `used_if_route_is_empty` set to false in the model).
18181        ///
18182        /// `relaxations(i).level` specifies the constraint relaxation level applied
18183        /// to a visit #j that satisfies:
18184        ///
18185        /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
18186        /// * `j + 1 >= relaxations(i).threshold_visit_count`
18187        ///
18188        /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
18189        /// satisfies:
18190        ///
18191        /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
18192        /// * `relaxations(i).threshold_visit_count == 0`
18193        ///   and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
18194        /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
18195        /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
18196        ///
18197        /// To apply a relaxation level if a visit meets the `threshold_visit_count`
18198        /// OR the `threshold_time` add two `relaxations` with the same `level`:
18199        /// one with only `threshold_visit_count` set and the other with only
18200        /// `threshold_time` set. If a visit satisfies the conditions of multiple
18201        /// `relaxations`, the most relaxed level applies. As a result, from the
18202        /// vehicle start through the route visits in order to the vehicle end, the
18203        /// relaxation level becomes more relaxed: i.e., the relaxation level is
18204        /// non-decreasing as the route progresses.
18205        ///
18206        /// The timing and sequence of route visits that do not satisfy the
18207        /// threshold conditions of any `relaxations` are fully constrained
18208        /// and no visits may be inserted into these sequences. Also, if a
18209        /// vehicle start or end does not satisfy the conditions of any
18210        /// relaxation the time is fixed, unless the vehicle is empty.
18211        #[derive(Clone, Debug, Default, PartialEq)]
18212        #[non_exhaustive]
18213        pub struct Relaxation {
18214
18215            /// The constraint relaxation level that applies when the conditions
18216            /// at or after `threshold_time` AND at least `threshold_visit_count` are
18217            /// satisfied.
18218            pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
18219
18220            /// The time at or after which the relaxation `level` may be applied.
18221            pub threshold_time: std::option::Option<wkt::Timestamp>,
18222
18223            /// The number of visits at or after which the relaxation `level` may be
18224            /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
18225            /// applied directly at the vehicle start.
18226            ///
18227            /// If it is `route.visits_size() + 1`, the `level` may only be applied to
18228            /// the vehicle end. If it is more than `route.visits_size() + 1`,
18229            /// `level` is not applied at all for that route.
18230            pub threshold_visit_count: i32,
18231
18232            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18233        }
18234
18235        impl Relaxation {
18236            pub fn new() -> Self {
18237                std::default::Default::default()
18238            }
18239
18240            /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
18241            pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
18242                self.level = v.into();
18243                self
18244            }
18245
18246            /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
18247            pub fn set_threshold_time<T>(mut self, v: T) -> Self
18248            where
18249                T: std::convert::Into<wkt::Timestamp>,
18250            {
18251                self.threshold_time = std::option::Option::Some(v.into());
18252                self
18253            }
18254
18255            /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
18256            pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
18257            where
18258                T: std::convert::Into<wkt::Timestamp>,
18259            {
18260                self.threshold_time = v.map(|x| x.into());
18261                self
18262            }
18263
18264            /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
18265            pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
18266                self.threshold_visit_count = v.into();
18267                self
18268            }
18269        }
18270
18271        impl wkt::message::Message for Relaxation {
18272            fn typename() -> &'static str {
18273                "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
18274            }
18275        }
18276
18277        #[doc(hidden)]
18278        impl<'de> serde::de::Deserialize<'de> for Relaxation {
18279            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18280            where
18281                D: serde::Deserializer<'de>,
18282            {
18283                #[allow(non_camel_case_types)]
18284                #[doc(hidden)]
18285                #[derive(PartialEq, Eq, Hash)]
18286                enum __FieldTag {
18287                    __level,
18288                    __threshold_time,
18289                    __threshold_visit_count,
18290                    Unknown(std::string::String),
18291                }
18292                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18293                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18294                    where
18295                        D: serde::Deserializer<'de>,
18296                    {
18297                        struct Visitor;
18298                        impl<'de> serde::de::Visitor<'de> for Visitor {
18299                            type Value = __FieldTag;
18300                            fn expecting(
18301                                &self,
18302                                formatter: &mut std::fmt::Formatter,
18303                            ) -> std::fmt::Result {
18304                                formatter.write_str("a field name for Relaxation")
18305                            }
18306                            fn visit_str<E>(
18307                                self,
18308                                value: &str,
18309                            ) -> std::result::Result<Self::Value, E>
18310                            where
18311                                E: serde::de::Error,
18312                            {
18313                                use std::result::Result::Ok;
18314                                use std::string::ToString;
18315                                match value {
18316                                    "level" => Ok(__FieldTag::__level),
18317                                    "thresholdTime" => Ok(__FieldTag::__threshold_time),
18318                                    "threshold_time" => Ok(__FieldTag::__threshold_time),
18319                                    "thresholdVisitCount" => {
18320                                        Ok(__FieldTag::__threshold_visit_count)
18321                                    }
18322                                    "threshold_visit_count" => {
18323                                        Ok(__FieldTag::__threshold_visit_count)
18324                                    }
18325                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
18326                                }
18327                            }
18328                        }
18329                        deserializer.deserialize_identifier(Visitor)
18330                    }
18331                }
18332                struct Visitor;
18333                impl<'de> serde::de::Visitor<'de> for Visitor {
18334                    type Value = Relaxation;
18335                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18336                        formatter.write_str("struct Relaxation")
18337                    }
18338                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18339                    where
18340                        A: serde::de::MapAccess<'de>,
18341                    {
18342                        #[allow(unused_imports)]
18343                        use serde::de::Error;
18344                        use std::option::Option::Some;
18345                        let mut fields = std::collections::HashSet::new();
18346                        let mut result = Self::Value::new();
18347                        while let Some(tag) = map.next_key::<__FieldTag>()? {
18348                            #[allow(clippy::match_single_binding)]
18349                            match tag {
18350                                __FieldTag::__level => {
18351                                    if !fields.insert(__FieldTag::__level) {
18352                                        return std::result::Result::Err(
18353                                            A::Error::duplicate_field("multiple values for level"),
18354                                        );
18355                                    }
18356                                    result.level = map.next_value::<std::option::Option<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>()?.unwrap_or_default();
18357                                }
18358                                __FieldTag::__threshold_time => {
18359                                    if !fields.insert(__FieldTag::__threshold_time) {
18360                                        return std::result::Result::Err(
18361                                            A::Error::duplicate_field(
18362                                                "multiple values for threshold_time",
18363                                            ),
18364                                        );
18365                                    }
18366                                    result.threshold_time =
18367                                        map.next_value::<std::option::Option<wkt::Timestamp>>()?;
18368                                }
18369                                __FieldTag::__threshold_visit_count => {
18370                                    if !fields.insert(__FieldTag::__threshold_visit_count) {
18371                                        return std::result::Result::Err(
18372                                            A::Error::duplicate_field(
18373                                                "multiple values for threshold_visit_count",
18374                                            ),
18375                                        );
18376                                    }
18377                                    struct __With(std::option::Option<i32>);
18378                                    impl<'de> serde::de::Deserialize<'de> for __With {
18379                                        fn deserialize<D>(
18380                                            deserializer: D,
18381                                        ) -> std::result::Result<Self, D::Error>
18382                                        where
18383                                            D: serde::de::Deserializer<'de>,
18384                                        {
18385                                            serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
18386                                        }
18387                                    }
18388                                    result.threshold_visit_count =
18389                                        map.next_value::<__With>()?.0.unwrap_or_default();
18390                                }
18391                                __FieldTag::Unknown(key) => {
18392                                    let value = map.next_value::<serde_json::Value>()?;
18393                                    result._unknown_fields.insert(key, value);
18394                                }
18395                            }
18396                        }
18397                        std::result::Result::Ok(result)
18398                    }
18399                }
18400                deserializer.deserialize_any(Visitor)
18401            }
18402        }
18403
18404        #[doc(hidden)]
18405        impl serde::ser::Serialize for Relaxation {
18406            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18407            where
18408                S: serde::ser::Serializer,
18409            {
18410                use serde::ser::SerializeMap;
18411                #[allow(unused_imports)]
18412                use std::option::Option::Some;
18413                let mut state = serializer.serialize_map(std::option::Option::None)?;
18414                if !wkt::internal::is_default(&self.level) {
18415                    state.serialize_entry("level", &self.level)?;
18416                }
18417                if self.threshold_time.is_some() {
18418                    state.serialize_entry("thresholdTime", &self.threshold_time)?;
18419                }
18420                if !wkt::internal::is_default(&self.threshold_visit_count) {
18421                    struct __With<'a>(&'a i32);
18422                    impl<'a> serde::ser::Serialize for __With<'a> {
18423                        fn serialize<S>(
18424                            &self,
18425                            serializer: S,
18426                        ) -> std::result::Result<S::Ok, S::Error>
18427                        where
18428                            S: serde::ser::Serializer,
18429                        {
18430                            serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
18431                        }
18432                    }
18433                    state.serialize_entry(
18434                        "thresholdVisitCount",
18435                        &__With(&self.threshold_visit_count),
18436                    )?;
18437                }
18438                if !self._unknown_fields.is_empty() {
18439                    for (key, value) in self._unknown_fields.iter() {
18440                        state.serialize_entry(key, &value)?;
18441                    }
18442                }
18443                state.end()
18444            }
18445        }
18446
18447        /// Defines additional types related to [Relaxation].
18448        pub mod relaxation {
18449            #[allow(unused_imports)]
18450            use super::*;
18451
18452            /// Expresses the different constraint relaxation levels, which are
18453            /// applied for a visit and those that follow when it satisfies the
18454            /// threshold conditions.
18455            ///
18456            /// The enumeration below is in order of increasing relaxation.
18457            ///
18458            /// # Working with unknown values
18459            ///
18460            /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
18461            /// additional enum variants at any time. Adding new variants is not considered
18462            /// a breaking change. Applications should write their code in anticipation of:
18463            ///
18464            /// - New values appearing in future releases of the client library, **and**
18465            /// - New values received dynamically, without application changes.
18466            ///
18467            /// Please consult the [Working with enums] section in the user guide for some
18468            /// guidelines.
18469            ///
18470            /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
18471            #[derive(Clone, Debug, PartialEq)]
18472            #[non_exhaustive]
18473            pub enum Level {
18474                /// Implicit default relaxation level: no constraints are relaxed,
18475                /// i.e., all visits are fully constrained.
18476                ///
18477                /// This value must not be explicitly used in `level`.
18478                Unspecified,
18479                /// Visit start times and vehicle start/end times will be relaxed, but
18480                /// each visit remains bound to the same vehicle and the visit sequence
18481                /// must be observed: no visit can be inserted between them or before
18482                /// them.
18483                RelaxVisitTimesAfterThreshold,
18484                /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
18485                /// is also relaxed: visits can only be performed by this vehicle, but
18486                /// can potentially become unperformed.
18487                RelaxVisitTimesAndSequenceAfterThreshold,
18488                /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
18489                /// vehicle is also relaxed: visits are completely free at or after the
18490                /// threshold time and can potentially become unperformed.
18491                RelaxAllAfterThreshold,
18492                /// If set, the enum was initialized with an unknown value.
18493                ///
18494                /// Applications can examine the value using [Level::value] or
18495                /// [Level::name].
18496                UnknownValue(level::UnknownValue),
18497            }
18498
18499            #[doc(hidden)]
18500            pub mod level {
18501                #[allow(unused_imports)]
18502                use super::*;
18503                #[derive(Clone, Debug, PartialEq)]
18504                pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
18505            }
18506
18507            impl Level {
18508                /// Gets the enum value.
18509                ///
18510                /// Returns `None` if the enum contains an unknown value deserialized from
18511                /// the string representation of enums.
18512                pub fn value(&self) -> std::option::Option<i32> {
18513                    match self {
18514                        Self::Unspecified => std::option::Option::Some(0),
18515                        Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
18516                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
18517                            std::option::Option::Some(2)
18518                        }
18519                        Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
18520                        Self::UnknownValue(u) => u.0.value(),
18521                    }
18522                }
18523
18524                /// Gets the enum value as a string.
18525                ///
18526                /// Returns `None` if the enum contains an unknown value deserialized from
18527                /// the integer representation of enums.
18528                pub fn name(&self) -> std::option::Option<&str> {
18529                    match self {
18530                        Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
18531                        Self::RelaxVisitTimesAfterThreshold => {
18532                            std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
18533                        }
18534                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
18535                            std::option::Option::Some(
18536                                "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
18537                            )
18538                        }
18539                        Self::RelaxAllAfterThreshold => {
18540                            std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
18541                        }
18542                        Self::UnknownValue(u) => u.0.name(),
18543                    }
18544                }
18545            }
18546
18547            impl std::default::Default for Level {
18548                fn default() -> Self {
18549                    use std::convert::From;
18550                    Self::from(0)
18551                }
18552            }
18553
18554            impl std::fmt::Display for Level {
18555                fn fmt(
18556                    &self,
18557                    f: &mut std::fmt::Formatter<'_>,
18558                ) -> std::result::Result<(), std::fmt::Error> {
18559                    wkt::internal::display_enum(f, self.name(), self.value())
18560                }
18561            }
18562
18563            impl std::convert::From<i32> for Level {
18564                fn from(value: i32) -> Self {
18565                    match value {
18566                        0 => Self::Unspecified,
18567                        1 => Self::RelaxVisitTimesAfterThreshold,
18568                        2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
18569                        3 => Self::RelaxAllAfterThreshold,
18570                        _ => Self::UnknownValue(level::UnknownValue(
18571                            wkt::internal::UnknownEnumValue::Integer(value),
18572                        )),
18573                    }
18574                }
18575            }
18576
18577            impl std::convert::From<&str> for Level {
18578                fn from(value: &str) -> Self {
18579                    use std::string::ToString;
18580                    match value {
18581                        "LEVEL_UNSPECIFIED" => Self::Unspecified,
18582                        "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
18583                        "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
18584                            Self::RelaxVisitTimesAndSequenceAfterThreshold
18585                        }
18586                        "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
18587                        _ => Self::UnknownValue(level::UnknownValue(
18588                            wkt::internal::UnknownEnumValue::String(value.to_string()),
18589                        )),
18590                    }
18591                }
18592            }
18593
18594            impl serde::ser::Serialize for Level {
18595                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18596                where
18597                    S: serde::Serializer,
18598                {
18599                    match self {
18600                        Self::Unspecified => serializer.serialize_i32(0),
18601                        Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
18602                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
18603                            serializer.serialize_i32(2)
18604                        }
18605                        Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
18606                        Self::UnknownValue(u) => u.0.serialize(serializer),
18607                    }
18608                }
18609            }
18610
18611            impl<'de> serde::de::Deserialize<'de> for Level {
18612                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18613                where
18614                    D: serde::Deserializer<'de>,
18615                {
18616                    deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
18617                        ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
18618                }
18619            }
18620        }
18621    }
18622}
18623
18624/// Describes an error encountered when validating an `OptimizeToursRequest`.
18625#[derive(Clone, Debug, Default, PartialEq)]
18626#[non_exhaustive]
18627pub struct OptimizeToursValidationError {
18628    /// A validation error is defined by the pair (`code`, `display_name`) which
18629    /// are always present.
18630    ///
18631    /// Other fields (below) provide more context about the error.
18632    ///
18633    /// *MULTIPLE ERRORS*:
18634    /// When there are multiple errors, the validation process tries to output
18635    /// several of them. Much like a compiler, this is an imperfect process. Some
18636    /// validation errors will be "fatal", meaning that they stop the entire
18637    /// validation process. This is the case for `display_name="UNSPECIFIED"`
18638    /// errors, among others. Some may cause the validation process to skip other
18639    /// errors.
18640    ///
18641    /// *STABILITY*:
18642    /// `code` and `display_name` should be very stable. But new codes and
18643    /// display names may appear over time, which may cause a given (invalid)
18644    /// request to yield a different (`code`, `display_name`) pair because the new
18645    /// error hid the old one (see "MULTIPLE ERRORS").
18646    ///
18647    /// *REFERENCE*: A list of all (code, name) pairs:
18648    ///
18649    /// * UNSPECIFIED = 0;
18650    ///
18651    /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
18652    ///   the deadline.
18653    ///
18654    /// * REQUEST_OPTIONS_ERROR = 12;
18655    ///
18656    ///   * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
18657    ///   * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
18658    ///   * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
18659    ///   * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
18660    ///   * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
18661    ///   * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
18662    ///     = 1207;
18663    ///   * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
18664    ///   * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
18665    ///   * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
18666    ///   * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
18667    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
18668    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
18669    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
18670    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
18671    /// * INJECTED_SOLUTION_ERROR = 20;
18672    ///
18673    ///   * INJECTED_SOLUTION_MISSING_LABEL = 2000;
18674    ///   * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
18675    ///   * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
18676    ///   * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
18677    ///   * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
18678    ///   * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
18679    ///   * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
18680    ///   * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
18681    ///   * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
18682    /// * SHIPMENT_MODEL_ERROR = 22;
18683    ///
18684    ///   * SHIPMENT_MODEL_TOO_LARGE = 2200;
18685    ///   * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
18686    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
18687    ///   * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
18688    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
18689    ///   * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
18690    ///   * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
18691    ///   * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
18692    /// * INDEX_ERROR = 24;
18693    ///
18694    /// * TAG_ERROR = 26;
18695    ///
18696    /// * TIME_WINDOW_ERROR = 28;
18697    ///
18698    ///   * TIME_WINDOW_INVALID_START_TIME = 2800;
18699    ///   * TIME_WINDOW_INVALID_END_TIME = 2801;
18700    ///   * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
18701    ///   * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
18702    ///   * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
18703    ///   * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
18704    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
18705    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
18706    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
18707    ///     = 2808;
18708    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
18709    ///   * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
18710    ///     = 2810;
18711    ///   * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
18712    ///   * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
18713    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
18714    ///   * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
18715    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
18716    ///   * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
18717    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
18718    ///     = 2817;
18719    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
18720    ///   * TRANSITION_ATTRIBUTES_ERROR = 30;
18721    ///   * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
18722    ///   * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
18723    ///   * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
18724    ///   * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
18725    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
18726    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
18727    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
18728    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
18729    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
18730    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
18731    /// * AMOUNT_ERROR = 31;
18732    ///
18733    ///   * AMOUNT_NEGATIVE_VALUE = 3100;
18734    /// * LOAD_LIMIT_ERROR = 33;
18735    ///
18736    ///   * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
18737    ///   * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
18738    ///   * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
18739    ///   * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
18740    ///   * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
18741    ///   * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
18742    ///   * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
18743    /// * INTERVAL_ERROR = 34;
18744    ///
18745    ///   * INTERVAL_MIN_EXCEEDS_MAX = 3401;
18746    ///   * INTERVAL_NEGATIVE_MIN = 3402;
18747    ///   * INTERVAL_NEGATIVE_MAX = 3403;
18748    ///   * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
18749    ///   * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
18750    /// * DISTANCE_LIMIT_ERROR = 36;
18751    ///
18752    ///   * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
18753    ///   * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
18754    ///   * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
18755    ///   * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
18756    ///   * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
18757    ///   * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
18758    /// * DURATION_LIMIT_ERROR = 38;
18759    ///
18760    ///   * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
18761    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
18762    ///   * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
18763    ///   * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
18764    ///   * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
18765    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
18766    ///   * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
18767    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
18768    ///     = 3807;
18769    ///   * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
18770    ///     = 3808;
18771    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
18772    ///   * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
18773    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
18774    ///   * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
18775    ///     = 3812;
18776    ///   * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
18777    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
18778    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
18779    ///     = 3815;
18780    /// * SHIPMENT_ERROR = 40;
18781    ///
18782    ///   * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
18783    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
18784    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
18785    ///     = 4001;
18786    ///   * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
18787    ///   * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
18788    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
18789    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
18790    ///   * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
18791    ///   * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
18792    ///   * SHIPMENT_INVALID_PENALTY_COST = 4006;
18793    ///   * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
18794    ///   * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
18795    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
18796    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
18797    ///   * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
18798    ///   * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
18799    ///   * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
18800    /// * VEHICLE_ERROR = 42;
18801    ///
18802    ///   * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
18803    ///   * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
18804    ///   * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
18805    ///   * VEHICLE_EMPTY_START_TAG = 4203;
18806    ///   * VEHICLE_DUPLICATE_START_TAG = 4204;
18807    ///   * VEHICLE_EMPTY_END_TAG = 4205;
18808    ///   * VEHICLE_DUPLICATE_END_TAG = 4206;
18809    ///   * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
18810    ///   * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
18811    ///   * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
18812    ///   * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
18813    ///   * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
18814    ///   * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
18815    ///   * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
18816    ///   * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
18817    ///   * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
18818    ///   * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
18819    ///   * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
18820    ///   * VEHICLE_INVALID_COST_PER_HOUR = 4218;
18821    ///   * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
18822    ///   * VEHICLE_INVALID_FIXED_COST = 4220;
18823    ///   * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
18824    ///   * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
18825    ///     = 4223;
18826    ///   * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
18827    ///   * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
18828    /// * VISIT_REQUEST_ERROR = 44;
18829    ///
18830    ///   * VISIT_REQUEST_EMPTY_TAG = 4400;
18831    ///   * VISIT_REQUEST_DUPLICATE_TAG = 4401;
18832    ///   * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
18833    ///   * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
18834    /// * PRECEDENCE_ERROR = 46;
18835    ///
18836    ///   * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
18837    ///   * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
18838    ///   * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
18839    ///   * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
18840    ///   * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
18841    ///   * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
18842    ///   * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
18843    /// * BREAK_ERROR = 48;
18844    ///
18845    ///   * BREAK_RULE_EMPTY = 4800;
18846    ///   * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
18847    ///   * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
18848    ///   * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
18849    ///   * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
18850    ///   * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
18851    ///   * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
18852    ///   * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
18853    ///   * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
18854    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
18855    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
18856    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
18857    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
18858    ///     = 4812;
18859    ///   * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
18860    ///   * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
18861    ///   * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
18862    /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
18863    ///
18864    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
18865    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
18866    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
18867    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
18868    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
18869    /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
18870    ///
18871    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
18872    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
18873    ///   * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
18874    ///   * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
18875    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
18876    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
18877    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
18878    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
18879    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
18880    ///   * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
18881    ///   * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
18882    /// * VEHICLE_OPERATOR_ERROR = 54;
18883    ///
18884    ///   * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
18885    ///   * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
18886    ///   * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
18887    ///   * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
18888    ///   * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
18889    /// * DURATION_SECONDS_MATRIX_ERROR = 56;
18890    ///
18891    ///   * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
18892    ///   * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
18893    pub code: i32,
18894
18895    /// The error display name.
18896    pub display_name: std::string::String,
18897
18898    /// An error context may involve 0, 1 (most of the time) or more fields. For
18899    /// example, referring to vehicle #4 and shipment #2's first pickup can be
18900    /// done as follows:
18901    ///
18902    /// ```norust
18903    /// fields { name: "vehicles" index: 4}
18904    /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
18905    /// ```
18906    ///
18907    /// Note, however, that the cardinality of `fields` should not change for a
18908    /// given error code.
18909    pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
18910
18911    /// Human-readable string describing the error. There is a 1:1 mapping
18912    /// between `code` and `error_message` (when code != "UNSPECIFIED").
18913    ///
18914    /// *STABILITY*: Not stable: the error message associated to a given `code` may
18915    /// change (hopefully to clarify it) over time. Please rely on the
18916    /// `display_name` and `code` instead.
18917    pub error_message: std::string::String,
18918
18919    /// May contain the value(s) of the field(s). This is not always available. You
18920    /// should absolutely not rely on it and use it only for manual model
18921    /// debugging.
18922    pub offending_values: std::string::String,
18923
18924    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18925}
18926
18927impl OptimizeToursValidationError {
18928    pub fn new() -> Self {
18929        std::default::Default::default()
18930    }
18931
18932    /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
18933    pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
18934        self.code = v.into();
18935        self
18936    }
18937
18938    /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
18939    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18940        self.display_name = v.into();
18941        self
18942    }
18943
18944    /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
18945    pub fn set_fields<T, V>(mut self, v: T) -> Self
18946    where
18947        T: std::iter::IntoIterator<Item = V>,
18948        V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
18949    {
18950        use std::iter::Iterator;
18951        self.fields = v.into_iter().map(|i| i.into()).collect();
18952        self
18953    }
18954
18955    /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
18956    pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18957        self.error_message = v.into();
18958        self
18959    }
18960
18961    /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
18962    pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
18963        mut self,
18964        v: T,
18965    ) -> Self {
18966        self.offending_values = v.into();
18967        self
18968    }
18969}
18970
18971impl wkt::message::Message for OptimizeToursValidationError {
18972    fn typename() -> &'static str {
18973        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
18974    }
18975}
18976
18977#[doc(hidden)]
18978impl<'de> serde::de::Deserialize<'de> for OptimizeToursValidationError {
18979    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18980    where
18981        D: serde::Deserializer<'de>,
18982    {
18983        #[allow(non_camel_case_types)]
18984        #[doc(hidden)]
18985        #[derive(PartialEq, Eq, Hash)]
18986        enum __FieldTag {
18987            __code,
18988            __display_name,
18989            __fields,
18990            __error_message,
18991            __offending_values,
18992            Unknown(std::string::String),
18993        }
18994        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18995            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18996            where
18997                D: serde::Deserializer<'de>,
18998            {
18999                struct Visitor;
19000                impl<'de> serde::de::Visitor<'de> for Visitor {
19001                    type Value = __FieldTag;
19002                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19003                        formatter.write_str("a field name for OptimizeToursValidationError")
19004                    }
19005                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19006                    where
19007                        E: serde::de::Error,
19008                    {
19009                        use std::result::Result::Ok;
19010                        use std::string::ToString;
19011                        match value {
19012                            "code" => Ok(__FieldTag::__code),
19013                            "displayName" => Ok(__FieldTag::__display_name),
19014                            "display_name" => Ok(__FieldTag::__display_name),
19015                            "fields" => Ok(__FieldTag::__fields),
19016                            "errorMessage" => Ok(__FieldTag::__error_message),
19017                            "error_message" => Ok(__FieldTag::__error_message),
19018                            "offendingValues" => Ok(__FieldTag::__offending_values),
19019                            "offending_values" => Ok(__FieldTag::__offending_values),
19020                            _ => Ok(__FieldTag::Unknown(value.to_string())),
19021                        }
19022                    }
19023                }
19024                deserializer.deserialize_identifier(Visitor)
19025            }
19026        }
19027        struct Visitor;
19028        impl<'de> serde::de::Visitor<'de> for Visitor {
19029            type Value = OptimizeToursValidationError;
19030            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19031                formatter.write_str("struct OptimizeToursValidationError")
19032            }
19033            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19034            where
19035                A: serde::de::MapAccess<'de>,
19036            {
19037                #[allow(unused_imports)]
19038                use serde::de::Error;
19039                use std::option::Option::Some;
19040                let mut fields = std::collections::HashSet::new();
19041                let mut result = Self::Value::new();
19042                while let Some(tag) = map.next_key::<__FieldTag>()? {
19043                    #[allow(clippy::match_single_binding)]
19044                    match tag {
19045                        __FieldTag::__code => {
19046                            if !fields.insert(__FieldTag::__code) {
19047                                return std::result::Result::Err(A::Error::duplicate_field(
19048                                    "multiple values for code",
19049                                ));
19050                            }
19051                            struct __With(std::option::Option<i32>);
19052                            impl<'de> serde::de::Deserialize<'de> for __With {
19053                                fn deserialize<D>(
19054                                    deserializer: D,
19055                                ) -> std::result::Result<Self, D::Error>
19056                                where
19057                                    D: serde::de::Deserializer<'de>,
19058                                {
19059                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
19060                                }
19061                            }
19062                            result.code = map.next_value::<__With>()?.0.unwrap_or_default();
19063                        }
19064                        __FieldTag::__display_name => {
19065                            if !fields.insert(__FieldTag::__display_name) {
19066                                return std::result::Result::Err(A::Error::duplicate_field(
19067                                    "multiple values for display_name",
19068                                ));
19069                            }
19070                            result.display_name = map
19071                                .next_value::<std::option::Option<std::string::String>>()?
19072                                .unwrap_or_default();
19073                        }
19074                        __FieldTag::__fields => {
19075                            if !fields.insert(__FieldTag::__fields) {
19076                                return std::result::Result::Err(A::Error::duplicate_field(
19077                                    "multiple values for fields",
19078                                ));
19079                            }
19080                            result.fields = map.next_value::<std::option::Option<std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>>>()?.unwrap_or_default();
19081                        }
19082                        __FieldTag::__error_message => {
19083                            if !fields.insert(__FieldTag::__error_message) {
19084                                return std::result::Result::Err(A::Error::duplicate_field(
19085                                    "multiple values for error_message",
19086                                ));
19087                            }
19088                            result.error_message = map
19089                                .next_value::<std::option::Option<std::string::String>>()?
19090                                .unwrap_or_default();
19091                        }
19092                        __FieldTag::__offending_values => {
19093                            if !fields.insert(__FieldTag::__offending_values) {
19094                                return std::result::Result::Err(A::Error::duplicate_field(
19095                                    "multiple values for offending_values",
19096                                ));
19097                            }
19098                            result.offending_values = map
19099                                .next_value::<std::option::Option<std::string::String>>()?
19100                                .unwrap_or_default();
19101                        }
19102                        __FieldTag::Unknown(key) => {
19103                            let value = map.next_value::<serde_json::Value>()?;
19104                            result._unknown_fields.insert(key, value);
19105                        }
19106                    }
19107                }
19108                std::result::Result::Ok(result)
19109            }
19110        }
19111        deserializer.deserialize_any(Visitor)
19112    }
19113}
19114
19115#[doc(hidden)]
19116impl serde::ser::Serialize for OptimizeToursValidationError {
19117    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19118    where
19119        S: serde::ser::Serializer,
19120    {
19121        use serde::ser::SerializeMap;
19122        #[allow(unused_imports)]
19123        use std::option::Option::Some;
19124        let mut state = serializer.serialize_map(std::option::Option::None)?;
19125        if !wkt::internal::is_default(&self.code) {
19126            struct __With<'a>(&'a i32);
19127            impl<'a> serde::ser::Serialize for __With<'a> {
19128                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19129                where
19130                    S: serde::ser::Serializer,
19131                {
19132                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
19133                }
19134            }
19135            state.serialize_entry("code", &__With(&self.code))?;
19136        }
19137        if !self.display_name.is_empty() {
19138            state.serialize_entry("displayName", &self.display_name)?;
19139        }
19140        if !self.fields.is_empty() {
19141            state.serialize_entry("fields", &self.fields)?;
19142        }
19143        if !self.error_message.is_empty() {
19144            state.serialize_entry("errorMessage", &self.error_message)?;
19145        }
19146        if !self.offending_values.is_empty() {
19147            state.serialize_entry("offendingValues", &self.offending_values)?;
19148        }
19149        if !self._unknown_fields.is_empty() {
19150            for (key, value) in self._unknown_fields.iter() {
19151                state.serialize_entry(key, &value)?;
19152            }
19153        }
19154        state.end()
19155    }
19156}
19157
19158/// Defines additional types related to [OptimizeToursValidationError].
19159pub mod optimize_tours_validation_error {
19160    #[allow(unused_imports)]
19161    use super::*;
19162
19163    /// Specifies a context for the validation error. A `FieldReference` always
19164    /// refers to a given field in this file and follows the same hierarchical
19165    /// structure. For example, we may specify element #2 of `start_time_windows`
19166    /// of vehicle #5 using:
19167    ///
19168    /// ```norust
19169    /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
19170    /// ```
19171    ///
19172    /// We however omit top-level entities such as `OptimizeToursRequest` or
19173    /// `ShipmentModel` to avoid crowding the message.
19174    #[derive(Clone, Debug, Default, PartialEq)]
19175    #[non_exhaustive]
19176    pub struct FieldReference {
19177        /// Name of the field, e.g., "vehicles".
19178        pub name: std::string::String,
19179
19180        /// Recursively nested sub-field, if needed.
19181        pub sub_field: std::option::Option<
19182            std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
19183        >,
19184
19185        pub index_or_key: std::option::Option<
19186            crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
19187        >,
19188
19189        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19190    }
19191
19192    impl FieldReference {
19193        pub fn new() -> Self {
19194            std::default::Default::default()
19195        }
19196
19197        /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
19198        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19199            self.name = v.into();
19200            self
19201        }
19202
19203        /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
19204        pub fn set_sub_field<T>(mut self, v: T) -> Self
19205        where
19206            T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
19207        {
19208            self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
19209            self
19210        }
19211
19212        /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
19213        pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
19214        where
19215            T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
19216        {
19217            self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
19218            self
19219        }
19220
19221        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
19222        ///
19223        /// Note that all the setters affecting `index_or_key` are mutually
19224        /// exclusive.
19225        pub fn set_index_or_key<
19226            T: std::convert::Into<
19227                    std::option::Option<
19228                        crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
19229                    >,
19230                >,
19231        >(
19232            mut self,
19233            v: T,
19234        ) -> Self {
19235            self.index_or_key = v.into();
19236            self
19237        }
19238
19239        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
19240        /// if it holds a `Index`, `None` if the field is not set or
19241        /// holds a different branch.
19242        pub fn index(&self) -> std::option::Option<&i32> {
19243            #[allow(unreachable_patterns)]
19244            self.index_or_key.as_ref().and_then(|v| match v {
19245                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
19246                _ => std::option::Option::None,
19247            })
19248        }
19249
19250        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
19251        /// to hold a `Index`.
19252        ///
19253        /// Note that all the setters affecting `index_or_key` are
19254        /// mutually exclusive.
19255        pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
19256            self.index_or_key = std::option::Option::Some(
19257                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
19258                    v.into(),
19259                ),
19260            );
19261            self
19262        }
19263
19264        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
19265        /// if it holds a `Key`, `None` if the field is not set or
19266        /// holds a different branch.
19267        pub fn key(&self) -> std::option::Option<&std::string::String> {
19268            #[allow(unreachable_patterns)]
19269            self.index_or_key.as_ref().and_then(|v| match v {
19270                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
19271                    v,
19272                ) => std::option::Option::Some(v),
19273                _ => std::option::Option::None,
19274            })
19275        }
19276
19277        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
19278        /// to hold a `Key`.
19279        ///
19280        /// Note that all the setters affecting `index_or_key` are
19281        /// mutually exclusive.
19282        pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19283            self.index_or_key = std::option::Option::Some(
19284                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
19285                    v.into(),
19286                ),
19287            );
19288            self
19289        }
19290    }
19291
19292    impl wkt::message::Message for FieldReference {
19293        fn typename() -> &'static str {
19294            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
19295        }
19296    }
19297
19298    #[doc(hidden)]
19299    impl<'de> serde::de::Deserialize<'de> for FieldReference {
19300        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19301        where
19302            D: serde::Deserializer<'de>,
19303        {
19304            #[allow(non_camel_case_types)]
19305            #[doc(hidden)]
19306            #[derive(PartialEq, Eq, Hash)]
19307            enum __FieldTag {
19308                __name,
19309                __index,
19310                __key,
19311                __sub_field,
19312                Unknown(std::string::String),
19313            }
19314            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
19315                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19316                where
19317                    D: serde::Deserializer<'de>,
19318                {
19319                    struct Visitor;
19320                    impl<'de> serde::de::Visitor<'de> for Visitor {
19321                        type Value = __FieldTag;
19322                        fn expecting(
19323                            &self,
19324                            formatter: &mut std::fmt::Formatter,
19325                        ) -> std::fmt::Result {
19326                            formatter.write_str("a field name for FieldReference")
19327                        }
19328                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19329                        where
19330                            E: serde::de::Error,
19331                        {
19332                            use std::result::Result::Ok;
19333                            use std::string::ToString;
19334                            match value {
19335                                "name" => Ok(__FieldTag::__name),
19336                                "index" => Ok(__FieldTag::__index),
19337                                "key" => Ok(__FieldTag::__key),
19338                                "subField" => Ok(__FieldTag::__sub_field),
19339                                "sub_field" => Ok(__FieldTag::__sub_field),
19340                                _ => Ok(__FieldTag::Unknown(value.to_string())),
19341                            }
19342                        }
19343                    }
19344                    deserializer.deserialize_identifier(Visitor)
19345                }
19346            }
19347            struct Visitor;
19348            impl<'de> serde::de::Visitor<'de> for Visitor {
19349                type Value = FieldReference;
19350                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19351                    formatter.write_str("struct FieldReference")
19352                }
19353                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19354                where
19355                    A: serde::de::MapAccess<'de>,
19356                {
19357                    #[allow(unused_imports)]
19358                    use serde::de::Error;
19359                    use std::option::Option::Some;
19360                    let mut fields = std::collections::HashSet::new();
19361                    let mut result = Self::Value::new();
19362                    while let Some(tag) = map.next_key::<__FieldTag>()? {
19363                        #[allow(clippy::match_single_binding)]
19364                        match tag {
19365                            __FieldTag::__name => {
19366                                if !fields.insert(__FieldTag::__name) {
19367                                    return std::result::Result::Err(A::Error::duplicate_field(
19368                                        "multiple values for name",
19369                                    ));
19370                                }
19371                                result.name = map
19372                                    .next_value::<std::option::Option<std::string::String>>()?
19373                                    .unwrap_or_default();
19374                            }
19375                            __FieldTag::__index => {
19376                                if !fields.insert(__FieldTag::__index) {
19377                                    return std::result::Result::Err(A::Error::duplicate_field(
19378                                        "multiple values for index",
19379                                    ));
19380                                }
19381                                struct __With(std::option::Option<i32>);
19382                                impl<'de> serde::de::Deserialize<'de> for __With {
19383                                    fn deserialize<D>(
19384                                        deserializer: D,
19385                                    ) -> std::result::Result<Self, D::Error>
19386                                    where
19387                                        D: serde::de::Deserializer<'de>,
19388                                    {
19389                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
19390                                    }
19391                                }
19392                                if result.index_or_key.is_some() {
19393                                    return std::result::Result::Err(A::Error::duplicate_field(
19394                                        "multiple values for `index_or_key`, a oneof with full ID .google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference.index, latest field was index",
19395                                    ));
19396                                }
19397                                result.index_or_key = std::option::Option::Some(
19398                                    crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
19399                                        map.next_value::<__With>()?.0.unwrap_or_default()
19400                                    ),
19401                                );
19402                            }
19403                            __FieldTag::__key => {
19404                                if !fields.insert(__FieldTag::__key) {
19405                                    return std::result::Result::Err(A::Error::duplicate_field(
19406                                        "multiple values for key",
19407                                    ));
19408                                }
19409                                if result.index_or_key.is_some() {
19410                                    return std::result::Result::Err(A::Error::duplicate_field(
19411                                        "multiple values for `index_or_key`, a oneof with full ID .google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference.key, latest field was key",
19412                                    ));
19413                                }
19414                                result.index_or_key = std::option::Option::Some(
19415                                    crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
19416                                        map.next_value::<std::option::Option<std::string::String>>()?.unwrap_or_default()
19417                                    ),
19418                                );
19419                            }
19420                            __FieldTag::__sub_field => {
19421                                if !fields.insert(__FieldTag::__sub_field) {
19422                                    return std::result::Result::Err(A::Error::duplicate_field(
19423                                        "multiple values for sub_field",
19424                                    ));
19425                                }
19426                                result.sub_field = map.next_value::<std::option::Option<std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>>>()?
19427                                    ;
19428                            }
19429                            __FieldTag::Unknown(key) => {
19430                                let value = map.next_value::<serde_json::Value>()?;
19431                                result._unknown_fields.insert(key, value);
19432                            }
19433                        }
19434                    }
19435                    std::result::Result::Ok(result)
19436                }
19437            }
19438            deserializer.deserialize_any(Visitor)
19439        }
19440    }
19441
19442    #[doc(hidden)]
19443    impl serde::ser::Serialize for FieldReference {
19444        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19445        where
19446            S: serde::ser::Serializer,
19447        {
19448            use serde::ser::SerializeMap;
19449            #[allow(unused_imports)]
19450            use std::option::Option::Some;
19451            let mut state = serializer.serialize_map(std::option::Option::None)?;
19452            if !self.name.is_empty() {
19453                state.serialize_entry("name", &self.name)?;
19454            }
19455            if let Some(value) = self.index() {
19456                struct __With<'a>(&'a i32);
19457                impl<'a> serde::ser::Serialize for __With<'a> {
19458                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19459                    where
19460                        S: serde::ser::Serializer,
19461                    {
19462                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
19463                    }
19464                }
19465                state.serialize_entry("index", &__With(value))?;
19466            }
19467            if let Some(value) = self.key() {
19468                state.serialize_entry("key", value)?;
19469            }
19470            if self.sub_field.is_some() {
19471                state.serialize_entry("subField", &self.sub_field)?;
19472            }
19473            if !self._unknown_fields.is_empty() {
19474                for (key, value) in self._unknown_fields.iter() {
19475                    state.serialize_entry(key, &value)?;
19476                }
19477            }
19478            state.end()
19479        }
19480    }
19481
19482    /// Defines additional types related to [FieldReference].
19483    pub mod field_reference {
19484        #[allow(unused_imports)]
19485        use super::*;
19486
19487        #[derive(Clone, Debug, PartialEq)]
19488        #[non_exhaustive]
19489        pub enum IndexOrKey {
19490            /// Index of the field if repeated.
19491            Index(i32),
19492            /// Key if the field is a map.
19493            Key(std::string::String),
19494        }
19495    }
19496}
19497
19498/// Data formats for input and output files.
19499///
19500/// # Working with unknown values
19501///
19502/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
19503/// additional enum variants at any time. Adding new variants is not considered
19504/// a breaking change. Applications should write their code in anticipation of:
19505///
19506/// - New values appearing in future releases of the client library, **and**
19507/// - New values received dynamically, without application changes.
19508///
19509/// Please consult the [Working with enums] section in the user guide for some
19510/// guidelines.
19511///
19512/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
19513#[derive(Clone, Debug, PartialEq)]
19514#[non_exhaustive]
19515pub enum DataFormat {
19516    /// Default value.
19517    Unspecified,
19518    /// Input data in json format.
19519    Json,
19520    /// Input data in string format.
19521    String,
19522    /// If set, the enum was initialized with an unknown value.
19523    ///
19524    /// Applications can examine the value using [DataFormat::value] or
19525    /// [DataFormat::name].
19526    UnknownValue(data_format::UnknownValue),
19527}
19528
19529#[doc(hidden)]
19530pub mod data_format {
19531    #[allow(unused_imports)]
19532    use super::*;
19533    #[derive(Clone, Debug, PartialEq)]
19534    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
19535}
19536
19537impl DataFormat {
19538    /// Gets the enum value.
19539    ///
19540    /// Returns `None` if the enum contains an unknown value deserialized from
19541    /// the string representation of enums.
19542    pub fn value(&self) -> std::option::Option<i32> {
19543        match self {
19544            Self::Unspecified => std::option::Option::Some(0),
19545            Self::Json => std::option::Option::Some(1),
19546            Self::String => std::option::Option::Some(2),
19547            Self::UnknownValue(u) => u.0.value(),
19548        }
19549    }
19550
19551    /// Gets the enum value as a string.
19552    ///
19553    /// Returns `None` if the enum contains an unknown value deserialized from
19554    /// the integer representation of enums.
19555    pub fn name(&self) -> std::option::Option<&str> {
19556        match self {
19557            Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
19558            Self::Json => std::option::Option::Some("JSON"),
19559            Self::String => std::option::Option::Some("STRING"),
19560            Self::UnknownValue(u) => u.0.name(),
19561        }
19562    }
19563}
19564
19565impl std::default::Default for DataFormat {
19566    fn default() -> Self {
19567        use std::convert::From;
19568        Self::from(0)
19569    }
19570}
19571
19572impl std::fmt::Display for DataFormat {
19573    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
19574        wkt::internal::display_enum(f, self.name(), self.value())
19575    }
19576}
19577
19578impl std::convert::From<i32> for DataFormat {
19579    fn from(value: i32) -> Self {
19580        match value {
19581            0 => Self::Unspecified,
19582            1 => Self::Json,
19583            2 => Self::String,
19584            _ => Self::UnknownValue(data_format::UnknownValue(
19585                wkt::internal::UnknownEnumValue::Integer(value),
19586            )),
19587        }
19588    }
19589}
19590
19591impl std::convert::From<&str> for DataFormat {
19592    fn from(value: &str) -> Self {
19593        use std::string::ToString;
19594        match value {
19595            "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
19596            "JSON" => Self::Json,
19597            "STRING" => Self::String,
19598            _ => Self::UnknownValue(data_format::UnknownValue(
19599                wkt::internal::UnknownEnumValue::String(value.to_string()),
19600            )),
19601        }
19602    }
19603}
19604
19605impl serde::ser::Serialize for DataFormat {
19606    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19607    where
19608        S: serde::Serializer,
19609    {
19610        match self {
19611            Self::Unspecified => serializer.serialize_i32(0),
19612            Self::Json => serializer.serialize_i32(1),
19613            Self::String => serializer.serialize_i32(2),
19614            Self::UnknownValue(u) => u.0.serialize(serializer),
19615        }
19616    }
19617}
19618
19619impl<'de> serde::de::Deserialize<'de> for DataFormat {
19620    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19621    where
19622        D: serde::Deserializer<'de>,
19623    {
19624        deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
19625            ".google.cloud.optimization.v1.DataFormat",
19626        ))
19627    }
19628}