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, 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
239impl std::fmt::Debug for InputConfig {
240    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
241        let mut debug_struct = f.debug_struct("InputConfig");
242        debug_struct.field("data_format", &self.data_format);
243        debug_struct.field("source", &self.source);
244        if !self._unknown_fields.is_empty() {
245            debug_struct.field("_unknown_fields", &self._unknown_fields);
246        }
247        debug_struct.finish()
248    }
249}
250
251/// Defines additional types related to [InputConfig].
252pub mod input_config {
253    #[allow(unused_imports)]
254    use super::*;
255
256    /// The location of the input model in cloud storage.
257    /// Required.
258    #[derive(Clone, Debug, PartialEq)]
259    #[non_exhaustive]
260    pub enum Source {
261        /// The Google Cloud Storage location to read the input from. This must be a
262        /// single file.
263        GcsSource(std::boxed::Box<crate::model::GcsSource>),
264    }
265}
266
267/// The desired output location.
268#[derive(Clone, Default, PartialEq)]
269#[non_exhaustive]
270pub struct OutputConfig {
271    /// The output data format that used to store the results in Cloud Storage.
272    pub data_format: crate::model::DataFormat,
273
274    /// The location of the output result in cloud storage.
275    /// Required.
276    pub destination: std::option::Option<crate::model::output_config::Destination>,
277
278    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
279}
280
281impl OutputConfig {
282    pub fn new() -> Self {
283        std::default::Default::default()
284    }
285
286    /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
287    pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
288        mut self,
289        v: T,
290    ) -> Self {
291        self.data_format = v.into();
292        self
293    }
294
295    /// Sets the value of [destination][crate::model::OutputConfig::destination].
296    ///
297    /// Note that all the setters affecting `destination` are mutually
298    /// exclusive.
299    pub fn set_destination<
300        T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
301    >(
302        mut self,
303        v: T,
304    ) -> Self {
305        self.destination = v.into();
306        self
307    }
308
309    /// The value of [destination][crate::model::OutputConfig::destination]
310    /// if it holds a `GcsDestination`, `None` if the field is not set or
311    /// holds a different branch.
312    pub fn gcs_destination(
313        &self,
314    ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
315        #[allow(unreachable_patterns)]
316        self.destination.as_ref().and_then(|v| match v {
317            crate::model::output_config::Destination::GcsDestination(v) => {
318                std::option::Option::Some(v)
319            }
320            _ => std::option::Option::None,
321        })
322    }
323
324    /// Sets the value of [destination][crate::model::OutputConfig::destination]
325    /// to hold a `GcsDestination`.
326    ///
327    /// Note that all the setters affecting `destination` are
328    /// mutually exclusive.
329    pub fn set_gcs_destination<
330        T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
331    >(
332        mut self,
333        v: T,
334    ) -> Self {
335        self.destination = std::option::Option::Some(
336            crate::model::output_config::Destination::GcsDestination(v.into()),
337        );
338        self
339    }
340}
341
342impl wkt::message::Message for OutputConfig {
343    fn typename() -> &'static str {
344        "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
345    }
346}
347
348#[doc(hidden)]
349impl<'de> serde::de::Deserialize<'de> for OutputConfig {
350    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
351    where
352        D: serde::Deserializer<'de>,
353    {
354        #[allow(non_camel_case_types)]
355        #[doc(hidden)]
356        #[derive(PartialEq, Eq, Hash)]
357        enum __FieldTag {
358            __gcs_destination,
359            __data_format,
360            Unknown(std::string::String),
361        }
362        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
363            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
364            where
365                D: serde::Deserializer<'de>,
366            {
367                struct Visitor;
368                impl<'de> serde::de::Visitor<'de> for Visitor {
369                    type Value = __FieldTag;
370                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
371                        formatter.write_str("a field name for OutputConfig")
372                    }
373                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
374                    where
375                        E: serde::de::Error,
376                    {
377                        use std::result::Result::Ok;
378                        use std::string::ToString;
379                        match value {
380                            "gcsDestination" => Ok(__FieldTag::__gcs_destination),
381                            "gcs_destination" => Ok(__FieldTag::__gcs_destination),
382                            "dataFormat" => Ok(__FieldTag::__data_format),
383                            "data_format" => Ok(__FieldTag::__data_format),
384                            _ => Ok(__FieldTag::Unknown(value.to_string())),
385                        }
386                    }
387                }
388                deserializer.deserialize_identifier(Visitor)
389            }
390        }
391        struct Visitor;
392        impl<'de> serde::de::Visitor<'de> for Visitor {
393            type Value = OutputConfig;
394            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
395                formatter.write_str("struct OutputConfig")
396            }
397            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
398            where
399                A: serde::de::MapAccess<'de>,
400            {
401                #[allow(unused_imports)]
402                use serde::de::Error;
403                use std::option::Option::Some;
404                let mut fields = std::collections::HashSet::new();
405                let mut result = Self::Value::new();
406                while let Some(tag) = map.next_key::<__FieldTag>()? {
407                    #[allow(clippy::match_single_binding)]
408                    match tag {
409                        __FieldTag::__gcs_destination => {
410                            if !fields.insert(__FieldTag::__gcs_destination) {
411                                return std::result::Result::Err(A::Error::duplicate_field(
412                                    "multiple values for gcs_destination",
413                                ));
414                            }
415                            if result.destination.is_some() {
416                                return std::result::Result::Err(A::Error::duplicate_field(
417                                    "multiple values for `destination`, a oneof with full ID .google.cloud.optimization.v1.OutputConfig.gcs_destination, latest field was gcsDestination",
418                                ));
419                            }
420                            result.destination = std::option::Option::Some(
421                                crate::model::output_config::Destination::GcsDestination(
422                                    map.next_value::<std::option::Option<
423                                        std::boxed::Box<crate::model::GcsDestination>,
424                                    >>()?
425                                    .unwrap_or_default(),
426                                ),
427                            );
428                        }
429                        __FieldTag::__data_format => {
430                            if !fields.insert(__FieldTag::__data_format) {
431                                return std::result::Result::Err(A::Error::duplicate_field(
432                                    "multiple values for data_format",
433                                ));
434                            }
435                            result.data_format = map
436                                .next_value::<std::option::Option<crate::model::DataFormat>>()?
437                                .unwrap_or_default();
438                        }
439                        __FieldTag::Unknown(key) => {
440                            let value = map.next_value::<serde_json::Value>()?;
441                            result._unknown_fields.insert(key, value);
442                        }
443                    }
444                }
445                std::result::Result::Ok(result)
446            }
447        }
448        deserializer.deserialize_any(Visitor)
449    }
450}
451
452#[doc(hidden)]
453impl serde::ser::Serialize for OutputConfig {
454    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
455    where
456        S: serde::ser::Serializer,
457    {
458        use serde::ser::SerializeMap;
459        #[allow(unused_imports)]
460        use std::option::Option::Some;
461        let mut state = serializer.serialize_map(std::option::Option::None)?;
462        if let Some(value) = self.gcs_destination() {
463            state.serialize_entry("gcsDestination", value)?;
464        }
465        if !wkt::internal::is_default(&self.data_format) {
466            state.serialize_entry("dataFormat", &self.data_format)?;
467        }
468        if !self._unknown_fields.is_empty() {
469            for (key, value) in self._unknown_fields.iter() {
470                state.serialize_entry(key, &value)?;
471            }
472        }
473        state.end()
474    }
475}
476
477impl std::fmt::Debug for OutputConfig {
478    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
479        let mut debug_struct = f.debug_struct("OutputConfig");
480        debug_struct.field("data_format", &self.data_format);
481        debug_struct.field("destination", &self.destination);
482        if !self._unknown_fields.is_empty() {
483            debug_struct.field("_unknown_fields", &self._unknown_fields);
484        }
485        debug_struct.finish()
486    }
487}
488
489/// Defines additional types related to [OutputConfig].
490pub mod output_config {
491    #[allow(unused_imports)]
492    use super::*;
493
494    /// The location of the output result in cloud storage.
495    /// Required.
496    #[derive(Clone, Debug, PartialEq)]
497    #[non_exhaustive]
498    pub enum Destination {
499        /// The Google Cloud Storage location to write the output to.
500        GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
501    }
502}
503
504/// The Google Cloud Storage location where the input file will be read from.
505#[derive(Clone, Default, PartialEq)]
506#[non_exhaustive]
507pub struct GcsSource {
508    /// Required. URI of the Google Cloud Storage location.
509    pub uri: std::string::String,
510
511    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
512}
513
514impl GcsSource {
515    pub fn new() -> Self {
516        std::default::Default::default()
517    }
518
519    /// Sets the value of [uri][crate::model::GcsSource::uri].
520    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
521        self.uri = v.into();
522        self
523    }
524}
525
526impl wkt::message::Message for GcsSource {
527    fn typename() -> &'static str {
528        "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
529    }
530}
531
532#[doc(hidden)]
533impl<'de> serde::de::Deserialize<'de> for GcsSource {
534    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
535    where
536        D: serde::Deserializer<'de>,
537    {
538        #[allow(non_camel_case_types)]
539        #[doc(hidden)]
540        #[derive(PartialEq, Eq, Hash)]
541        enum __FieldTag {
542            __uri,
543            Unknown(std::string::String),
544        }
545        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
546            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
547            where
548                D: serde::Deserializer<'de>,
549            {
550                struct Visitor;
551                impl<'de> serde::de::Visitor<'de> for Visitor {
552                    type Value = __FieldTag;
553                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
554                        formatter.write_str("a field name for GcsSource")
555                    }
556                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
557                    where
558                        E: serde::de::Error,
559                    {
560                        use std::result::Result::Ok;
561                        use std::string::ToString;
562                        match value {
563                            "uri" => Ok(__FieldTag::__uri),
564                            _ => Ok(__FieldTag::Unknown(value.to_string())),
565                        }
566                    }
567                }
568                deserializer.deserialize_identifier(Visitor)
569            }
570        }
571        struct Visitor;
572        impl<'de> serde::de::Visitor<'de> for Visitor {
573            type Value = GcsSource;
574            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
575                formatter.write_str("struct GcsSource")
576            }
577            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
578            where
579                A: serde::de::MapAccess<'de>,
580            {
581                #[allow(unused_imports)]
582                use serde::de::Error;
583                use std::option::Option::Some;
584                let mut fields = std::collections::HashSet::new();
585                let mut result = Self::Value::new();
586                while let Some(tag) = map.next_key::<__FieldTag>()? {
587                    #[allow(clippy::match_single_binding)]
588                    match tag {
589                        __FieldTag::__uri => {
590                            if !fields.insert(__FieldTag::__uri) {
591                                return std::result::Result::Err(A::Error::duplicate_field(
592                                    "multiple values for uri",
593                                ));
594                            }
595                            result.uri = map
596                                .next_value::<std::option::Option<std::string::String>>()?
597                                .unwrap_or_default();
598                        }
599                        __FieldTag::Unknown(key) => {
600                            let value = map.next_value::<serde_json::Value>()?;
601                            result._unknown_fields.insert(key, value);
602                        }
603                    }
604                }
605                std::result::Result::Ok(result)
606            }
607        }
608        deserializer.deserialize_any(Visitor)
609    }
610}
611
612#[doc(hidden)]
613impl serde::ser::Serialize for GcsSource {
614    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
615    where
616        S: serde::ser::Serializer,
617    {
618        use serde::ser::SerializeMap;
619        #[allow(unused_imports)]
620        use std::option::Option::Some;
621        let mut state = serializer.serialize_map(std::option::Option::None)?;
622        if !self.uri.is_empty() {
623            state.serialize_entry("uri", &self.uri)?;
624        }
625        if !self._unknown_fields.is_empty() {
626            for (key, value) in self._unknown_fields.iter() {
627                state.serialize_entry(key, &value)?;
628            }
629        }
630        state.end()
631    }
632}
633
634impl std::fmt::Debug for GcsSource {
635    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
636        let mut debug_struct = f.debug_struct("GcsSource");
637        debug_struct.field("uri", &self.uri);
638        if !self._unknown_fields.is_empty() {
639            debug_struct.field("_unknown_fields", &self._unknown_fields);
640        }
641        debug_struct.finish()
642    }
643}
644
645/// The Google Cloud Storage location where the output file will be written to.
646#[derive(Clone, Default, PartialEq)]
647#[non_exhaustive]
648pub struct GcsDestination {
649    /// Required. URI of the Google Cloud Storage location.
650    pub uri: std::string::String,
651
652    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
653}
654
655impl GcsDestination {
656    pub fn new() -> Self {
657        std::default::Default::default()
658    }
659
660    /// Sets the value of [uri][crate::model::GcsDestination::uri].
661    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
662        self.uri = v.into();
663        self
664    }
665}
666
667impl wkt::message::Message for GcsDestination {
668    fn typename() -> &'static str {
669        "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
670    }
671}
672
673#[doc(hidden)]
674impl<'de> serde::de::Deserialize<'de> for GcsDestination {
675    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
676    where
677        D: serde::Deserializer<'de>,
678    {
679        #[allow(non_camel_case_types)]
680        #[doc(hidden)]
681        #[derive(PartialEq, Eq, Hash)]
682        enum __FieldTag {
683            __uri,
684            Unknown(std::string::String),
685        }
686        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
687            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
688            where
689                D: serde::Deserializer<'de>,
690            {
691                struct Visitor;
692                impl<'de> serde::de::Visitor<'de> for Visitor {
693                    type Value = __FieldTag;
694                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
695                        formatter.write_str("a field name for GcsDestination")
696                    }
697                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
698                    where
699                        E: serde::de::Error,
700                    {
701                        use std::result::Result::Ok;
702                        use std::string::ToString;
703                        match value {
704                            "uri" => Ok(__FieldTag::__uri),
705                            _ => Ok(__FieldTag::Unknown(value.to_string())),
706                        }
707                    }
708                }
709                deserializer.deserialize_identifier(Visitor)
710            }
711        }
712        struct Visitor;
713        impl<'de> serde::de::Visitor<'de> for Visitor {
714            type Value = GcsDestination;
715            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
716                formatter.write_str("struct GcsDestination")
717            }
718            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
719            where
720                A: serde::de::MapAccess<'de>,
721            {
722                #[allow(unused_imports)]
723                use serde::de::Error;
724                use std::option::Option::Some;
725                let mut fields = std::collections::HashSet::new();
726                let mut result = Self::Value::new();
727                while let Some(tag) = map.next_key::<__FieldTag>()? {
728                    #[allow(clippy::match_single_binding)]
729                    match tag {
730                        __FieldTag::__uri => {
731                            if !fields.insert(__FieldTag::__uri) {
732                                return std::result::Result::Err(A::Error::duplicate_field(
733                                    "multiple values for uri",
734                                ));
735                            }
736                            result.uri = map
737                                .next_value::<std::option::Option<std::string::String>>()?
738                                .unwrap_or_default();
739                        }
740                        __FieldTag::Unknown(key) => {
741                            let value = map.next_value::<serde_json::Value>()?;
742                            result._unknown_fields.insert(key, value);
743                        }
744                    }
745                }
746                std::result::Result::Ok(result)
747            }
748        }
749        deserializer.deserialize_any(Visitor)
750    }
751}
752
753#[doc(hidden)]
754impl serde::ser::Serialize for GcsDestination {
755    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
756    where
757        S: serde::ser::Serializer,
758    {
759        use serde::ser::SerializeMap;
760        #[allow(unused_imports)]
761        use std::option::Option::Some;
762        let mut state = serializer.serialize_map(std::option::Option::None)?;
763        if !self.uri.is_empty() {
764            state.serialize_entry("uri", &self.uri)?;
765        }
766        if !self._unknown_fields.is_empty() {
767            for (key, value) in self._unknown_fields.iter() {
768                state.serialize_entry(key, &value)?;
769            }
770        }
771        state.end()
772    }
773}
774
775impl std::fmt::Debug for GcsDestination {
776    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
777        let mut debug_struct = f.debug_struct("GcsDestination");
778        debug_struct.field("uri", &self.uri);
779        if !self._unknown_fields.is_empty() {
780            debug_struct.field("_unknown_fields", &self._unknown_fields);
781        }
782        debug_struct.finish()
783    }
784}
785
786/// The long running operation metadata for async model related methods.
787#[derive(Clone, Default, PartialEq)]
788#[non_exhaustive]
789pub struct AsyncModelMetadata {
790    /// The state of the current operation.
791    pub state: crate::model::async_model_metadata::State,
792
793    /// A message providing more details about the current state of the operation.
794    /// For example, the error message if the operation is failed.
795    pub state_message: std::string::String,
796
797    /// The creation time of the operation.
798    pub create_time: std::option::Option<wkt::Timestamp>,
799
800    /// The last update time of the operation.
801    pub update_time: std::option::Option<wkt::Timestamp>,
802
803    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
804}
805
806impl AsyncModelMetadata {
807    pub fn new() -> Self {
808        std::default::Default::default()
809    }
810
811    /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
812    pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
813        mut self,
814        v: T,
815    ) -> Self {
816        self.state = v.into();
817        self
818    }
819
820    /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
821    pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
822        self.state_message = v.into();
823        self
824    }
825
826    /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
827    pub fn set_create_time<T>(mut self, v: T) -> Self
828    where
829        T: std::convert::Into<wkt::Timestamp>,
830    {
831        self.create_time = std::option::Option::Some(v.into());
832        self
833    }
834
835    /// Sets or clears the value of [create_time][crate::model::AsyncModelMetadata::create_time].
836    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
837    where
838        T: std::convert::Into<wkt::Timestamp>,
839    {
840        self.create_time = v.map(|x| x.into());
841        self
842    }
843
844    /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
845    pub fn set_update_time<T>(mut self, v: T) -> Self
846    where
847        T: std::convert::Into<wkt::Timestamp>,
848    {
849        self.update_time = std::option::Option::Some(v.into());
850        self
851    }
852
853    /// Sets or clears the value of [update_time][crate::model::AsyncModelMetadata::update_time].
854    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
855    where
856        T: std::convert::Into<wkt::Timestamp>,
857    {
858        self.update_time = v.map(|x| x.into());
859        self
860    }
861}
862
863impl wkt::message::Message for AsyncModelMetadata {
864    fn typename() -> &'static str {
865        "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
866    }
867}
868
869#[doc(hidden)]
870impl<'de> serde::de::Deserialize<'de> for AsyncModelMetadata {
871    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
872    where
873        D: serde::Deserializer<'de>,
874    {
875        #[allow(non_camel_case_types)]
876        #[doc(hidden)]
877        #[derive(PartialEq, Eq, Hash)]
878        enum __FieldTag {
879            __state,
880            __state_message,
881            __create_time,
882            __update_time,
883            Unknown(std::string::String),
884        }
885        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
886            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
887            where
888                D: serde::Deserializer<'de>,
889            {
890                struct Visitor;
891                impl<'de> serde::de::Visitor<'de> for Visitor {
892                    type Value = __FieldTag;
893                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
894                        formatter.write_str("a field name for AsyncModelMetadata")
895                    }
896                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
897                    where
898                        E: serde::de::Error,
899                    {
900                        use std::result::Result::Ok;
901                        use std::string::ToString;
902                        match value {
903                            "state" => Ok(__FieldTag::__state),
904                            "stateMessage" => Ok(__FieldTag::__state_message),
905                            "state_message" => Ok(__FieldTag::__state_message),
906                            "createTime" => Ok(__FieldTag::__create_time),
907                            "create_time" => Ok(__FieldTag::__create_time),
908                            "updateTime" => Ok(__FieldTag::__update_time),
909                            "update_time" => Ok(__FieldTag::__update_time),
910                            _ => Ok(__FieldTag::Unknown(value.to_string())),
911                        }
912                    }
913                }
914                deserializer.deserialize_identifier(Visitor)
915            }
916        }
917        struct Visitor;
918        impl<'de> serde::de::Visitor<'de> for Visitor {
919            type Value = AsyncModelMetadata;
920            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
921                formatter.write_str("struct AsyncModelMetadata")
922            }
923            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
924            where
925                A: serde::de::MapAccess<'de>,
926            {
927                #[allow(unused_imports)]
928                use serde::de::Error;
929                use std::option::Option::Some;
930                let mut fields = std::collections::HashSet::new();
931                let mut result = Self::Value::new();
932                while let Some(tag) = map.next_key::<__FieldTag>()? {
933                    #[allow(clippy::match_single_binding)]
934                    match tag {
935                        __FieldTag::__state => {
936                            if !fields.insert(__FieldTag::__state) {
937                                return std::result::Result::Err(A::Error::duplicate_field(
938                                    "multiple values for state",
939                                ));
940                            }
941                            result.state = map.next_value::<std::option::Option<crate::model::async_model_metadata::State>>()?.unwrap_or_default();
942                        }
943                        __FieldTag::__state_message => {
944                            if !fields.insert(__FieldTag::__state_message) {
945                                return std::result::Result::Err(A::Error::duplicate_field(
946                                    "multiple values for state_message",
947                                ));
948                            }
949                            result.state_message = map
950                                .next_value::<std::option::Option<std::string::String>>()?
951                                .unwrap_or_default();
952                        }
953                        __FieldTag::__create_time => {
954                            if !fields.insert(__FieldTag::__create_time) {
955                                return std::result::Result::Err(A::Error::duplicate_field(
956                                    "multiple values for create_time",
957                                ));
958                            }
959                            result.create_time =
960                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
961                        }
962                        __FieldTag::__update_time => {
963                            if !fields.insert(__FieldTag::__update_time) {
964                                return std::result::Result::Err(A::Error::duplicate_field(
965                                    "multiple values for update_time",
966                                ));
967                            }
968                            result.update_time =
969                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
970                        }
971                        __FieldTag::Unknown(key) => {
972                            let value = map.next_value::<serde_json::Value>()?;
973                            result._unknown_fields.insert(key, value);
974                        }
975                    }
976                }
977                std::result::Result::Ok(result)
978            }
979        }
980        deserializer.deserialize_any(Visitor)
981    }
982}
983
984#[doc(hidden)]
985impl serde::ser::Serialize for AsyncModelMetadata {
986    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
987    where
988        S: serde::ser::Serializer,
989    {
990        use serde::ser::SerializeMap;
991        #[allow(unused_imports)]
992        use std::option::Option::Some;
993        let mut state = serializer.serialize_map(std::option::Option::None)?;
994        if !wkt::internal::is_default(&self.state) {
995            state.serialize_entry("state", &self.state)?;
996        }
997        if !self.state_message.is_empty() {
998            state.serialize_entry("stateMessage", &self.state_message)?;
999        }
1000        if self.create_time.is_some() {
1001            state.serialize_entry("createTime", &self.create_time)?;
1002        }
1003        if self.update_time.is_some() {
1004            state.serialize_entry("updateTime", &self.update_time)?;
1005        }
1006        if !self._unknown_fields.is_empty() {
1007            for (key, value) in self._unknown_fields.iter() {
1008                state.serialize_entry(key, &value)?;
1009            }
1010        }
1011        state.end()
1012    }
1013}
1014
1015impl std::fmt::Debug for AsyncModelMetadata {
1016    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1017        let mut debug_struct = f.debug_struct("AsyncModelMetadata");
1018        debug_struct.field("state", &self.state);
1019        debug_struct.field("state_message", &self.state_message);
1020        debug_struct.field("create_time", &self.create_time);
1021        debug_struct.field("update_time", &self.update_time);
1022        if !self._unknown_fields.is_empty() {
1023            debug_struct.field("_unknown_fields", &self._unknown_fields);
1024        }
1025        debug_struct.finish()
1026    }
1027}
1028
1029/// Defines additional types related to [AsyncModelMetadata].
1030pub mod async_model_metadata {
1031    #[allow(unused_imports)]
1032    use super::*;
1033
1034    /// Possible states of the operation.
1035    ///
1036    /// # Working with unknown values
1037    ///
1038    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1039    /// additional enum variants at any time. Adding new variants is not considered
1040    /// a breaking change. Applications should write their code in anticipation of:
1041    ///
1042    /// - New values appearing in future releases of the client library, **and**
1043    /// - New values received dynamically, without application changes.
1044    ///
1045    /// Please consult the [Working with enums] section in the user guide for some
1046    /// guidelines.
1047    ///
1048    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1049    #[derive(Clone, Debug, PartialEq)]
1050    #[non_exhaustive]
1051    pub enum State {
1052        /// The default value. This value is used if the state is omitted.
1053        Unspecified,
1054        /// Request is being processed.
1055        Running,
1056        /// The operation completed successfully.
1057        Succeeded,
1058        /// The operation was cancelled.
1059        Cancelled,
1060        /// The operation has failed.
1061        Failed,
1062        /// If set, the enum was initialized with an unknown value.
1063        ///
1064        /// Applications can examine the value using [State::value] or
1065        /// [State::name].
1066        UnknownValue(state::UnknownValue),
1067    }
1068
1069    #[doc(hidden)]
1070    pub mod state {
1071        #[allow(unused_imports)]
1072        use super::*;
1073        #[derive(Clone, Debug, PartialEq)]
1074        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1075    }
1076
1077    impl State {
1078        /// Gets the enum value.
1079        ///
1080        /// Returns `None` if the enum contains an unknown value deserialized from
1081        /// the string representation of enums.
1082        pub fn value(&self) -> std::option::Option<i32> {
1083            match self {
1084                Self::Unspecified => std::option::Option::Some(0),
1085                Self::Running => std::option::Option::Some(1),
1086                Self::Succeeded => std::option::Option::Some(2),
1087                Self::Cancelled => std::option::Option::Some(3),
1088                Self::Failed => std::option::Option::Some(4),
1089                Self::UnknownValue(u) => u.0.value(),
1090            }
1091        }
1092
1093        /// Gets the enum value as a string.
1094        ///
1095        /// Returns `None` if the enum contains an unknown value deserialized from
1096        /// the integer representation of enums.
1097        pub fn name(&self) -> std::option::Option<&str> {
1098            match self {
1099                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1100                Self::Running => std::option::Option::Some("RUNNING"),
1101                Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
1102                Self::Cancelled => std::option::Option::Some("CANCELLED"),
1103                Self::Failed => std::option::Option::Some("FAILED"),
1104                Self::UnknownValue(u) => u.0.name(),
1105            }
1106        }
1107    }
1108
1109    impl std::default::Default for State {
1110        fn default() -> Self {
1111            use std::convert::From;
1112            Self::from(0)
1113        }
1114    }
1115
1116    impl std::fmt::Display for State {
1117        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1118            wkt::internal::display_enum(f, self.name(), self.value())
1119        }
1120    }
1121
1122    impl std::convert::From<i32> for State {
1123        fn from(value: i32) -> Self {
1124            match value {
1125                0 => Self::Unspecified,
1126                1 => Self::Running,
1127                2 => Self::Succeeded,
1128                3 => Self::Cancelled,
1129                4 => Self::Failed,
1130                _ => Self::UnknownValue(state::UnknownValue(
1131                    wkt::internal::UnknownEnumValue::Integer(value),
1132                )),
1133            }
1134        }
1135    }
1136
1137    impl std::convert::From<&str> for State {
1138        fn from(value: &str) -> Self {
1139            use std::string::ToString;
1140            match value {
1141                "STATE_UNSPECIFIED" => Self::Unspecified,
1142                "RUNNING" => Self::Running,
1143                "SUCCEEDED" => Self::Succeeded,
1144                "CANCELLED" => Self::Cancelled,
1145                "FAILED" => Self::Failed,
1146                _ => Self::UnknownValue(state::UnknownValue(
1147                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1148                )),
1149            }
1150        }
1151    }
1152
1153    impl serde::ser::Serialize for State {
1154        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1155        where
1156            S: serde::Serializer,
1157        {
1158            match self {
1159                Self::Unspecified => serializer.serialize_i32(0),
1160                Self::Running => serializer.serialize_i32(1),
1161                Self::Succeeded => serializer.serialize_i32(2),
1162                Self::Cancelled => serializer.serialize_i32(3),
1163                Self::Failed => serializer.serialize_i32(4),
1164                Self::UnknownValue(u) => u.0.serialize(serializer),
1165            }
1166        }
1167    }
1168
1169    impl<'de> serde::de::Deserialize<'de> for State {
1170        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1171        where
1172            D: serde::Deserializer<'de>,
1173        {
1174            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1175                ".google.cloud.optimization.v1.AsyncModelMetadata.State",
1176            ))
1177        }
1178    }
1179}
1180
1181/// Request to be given to a tour optimization solver which defines the
1182/// shipment model to solve as well as optimization parameters.
1183#[derive(Clone, Default, PartialEq)]
1184#[non_exhaustive]
1185pub struct OptimizeToursRequest {
1186    /// Required. Target project and location to make a call.
1187    ///
1188    /// Format: `projects/{project-id}/locations/{location-id}`.
1189    ///
1190    /// If no location is specified, a region will be chosen automatically.
1191    pub parent: std::string::String,
1192
1193    /// If this timeout is set, the server returns a response before the timeout
1194    /// period has elapsed or the server deadline for synchronous requests is
1195    /// reached, whichever is sooner.
1196    ///
1197    /// For asynchronous requests, the server will generate a solution (if
1198    /// possible) before the timeout has elapsed.
1199    pub timeout: std::option::Option<wkt::Duration>,
1200
1201    /// Shipment model to solve.
1202    pub model: std::option::Option<crate::model::ShipmentModel>,
1203
1204    /// By default, the solving mode is `DEFAULT_SOLVE` (0).
1205    pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
1206
1207    /// Search mode used to solve the request.
1208    pub search_mode: crate::model::optimize_tours_request::SearchMode,
1209
1210    /// Guide the optimization algorithm in finding a first solution that is
1211    /// similar to a previous solution.
1212    ///
1213    /// The model is constrained when the first solution is built.
1214    /// Any shipments not performed on a route are implicitly skipped in the first
1215    /// solution, but they may be performed in successive solutions.
1216    ///
1217    /// The solution must satisfy some basic validity assumptions:
1218    ///
1219    /// * for all routes, `vehicle_index` must be in range and not be duplicated.
1220    /// * for all visits, `shipment_index` and `visit_request_index` must be
1221    ///   in range.
1222    /// * a shipment may only be referenced on one route.
1223    /// * the pickup of a pickup-delivery shipment must be performed before
1224    ///   the delivery.
1225    /// * no more than one pickup alternative or delivery alternative of
1226    ///   a shipment may be performed.
1227    /// * for all routes, times are increasing (i.e., `vehicle_start_time
1228    ///   <= visits[0].start_time <= visits[1].start_time ...
1229    ///   <= vehicle_end_time`).
1230    /// * a shipment may only be performed on a vehicle that is allowed. A
1231    ///   vehicle is allowed if
1232    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
1233    ///   is empty or its `vehicle_index` is included in
1234    ///   [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
1235    ///
1236    /// If the injected solution is not feasible, a validation error is not
1237    /// necessarily returned and an error indicating infeasibility may be returned
1238    /// instead.
1239    ///
1240    /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
1241    pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
1242
1243    /// Constrain the optimization algorithm to find a final solution that is
1244    /// similar to a previous solution. For example, this may be used to freeze
1245    /// portions of routes which have already been completed or which are to be
1246    /// completed but must not be modified.
1247    ///
1248    /// If the injected solution is not feasible, a validation error is not
1249    /// necessarily returned and an error indicating infeasibility may be returned
1250    /// instead.
1251    pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
1252
1253    /// If non-empty, the given routes will be refreshed, without modifying their
1254    /// underlying sequence of visits or travel times: only other details will be
1255    /// updated. This does not solve the model.
1256    ///
1257    /// As of 2020/11, this only populates the polylines of non-empty routes and
1258    /// requires that `populate_polylines` is true.
1259    ///
1260    /// The `route_polyline` fields of the passed-in routes may be inconsistent
1261    /// with route `transitions`.
1262    ///
1263    /// This field must not be used together with `injected_first_solution_routes`
1264    /// or `injected_solution_constraint`.
1265    ///
1266    /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
1267    /// Polylines are still populated between all visits in all non-empty routes
1268    /// regardless of whether the related shipments or vehicles are ignored.
1269    pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
1270
1271    /// If true:
1272    ///
1273    /// * uses
1274    ///   [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
1275    ///   instead of `vehicle_index` to
1276    ///   match routes in an injected solution with vehicles in the request;
1277    ///   reuses the mapping of original
1278    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
1279    ///   to new
1280    ///   [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
1281    ///   to update
1282    ///   [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
1283    ///   if non-empty, but the mapping must be unambiguous (i.e., multiple
1284    ///   `ShipmentRoute`s must not share the same original `vehicle_index`).
1285    /// * uses
1286    ///   [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
1287    ///   instead of `shipment_index`
1288    ///   to match visits in an injected solution with shipments in the request;
1289    /// * uses
1290    ///   [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
1291    ///   instead of
1292    ///   [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
1293    ///   to
1294    ///   match skipped shipments in the injected solution with request
1295    ///   shipments.
1296    ///
1297    /// This interpretation applies to the `injected_first_solution_routes`,
1298    /// `injected_solution_constraint`, and `refresh_details_routes` fields.
1299    /// It can be used when shipment or vehicle indices in the request have
1300    /// changed since the solution was created, perhaps because shipments or
1301    /// vehicles have been removed from or added to the request.
1302    ///
1303    /// If true, labels in the following categories must appear at most once in
1304    /// their category:
1305    ///
1306    /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
1307    ///   request;
1308    /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
1309    ///   request;
1310    /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
1311    /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
1312    ///   the injected solution (except pickup/delivery visit pairs, whose
1313    ///   `shipment_label` must appear twice).
1314    ///
1315    /// If a `vehicle_label` in the injected solution does not correspond to a
1316    /// request vehicle, the corresponding route is removed from the solution
1317    /// along with its visits. If a `shipment_label` in the injected solution does
1318    /// not correspond to a request shipment, the corresponding visit is removed
1319    /// from the solution. If a
1320    /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
1321    /// in the injected solution does not correspond to a request shipment, the
1322    /// `SkippedShipment` is removed from the solution.
1323    ///
1324    /// Removing route visits or entire routes from an injected solution may
1325    /// have an effect on the implied constraints, which may lead to change in
1326    /// solution, validation errors, or infeasibility.
1327    ///
1328    /// NOTE: The caller must ensure that each
1329    /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
1330    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
1331    /// identifies a vehicle (resp. shipment) entity used across the two relevant
1332    /// requests: the past request that produced the `OptimizeToursResponse` used
1333    /// in the injected solution and the current request that includes the injected
1334    /// solution. The uniqueness checks described above are not enough to guarantee
1335    /// this requirement.
1336    ///
1337    /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
1338    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
1339    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
1340    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
1341    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
1342    /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
1343    /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
1344    /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
1345    pub interpret_injected_solutions_using_labels: bool,
1346
1347    /// Consider traffic estimation in calculating `ShipmentRoute` fields
1348    /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
1349    /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
1350    /// and `vehicle_end_time`; in setting the
1351    /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
1352    /// field, and in calculating the
1353    /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
1354    /// field.
1355    ///
1356    /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
1357    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
1358    /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
1359    /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
1360    pub consider_road_traffic: bool,
1361
1362    /// If true, polylines will be populated in response `ShipmentRoute`s.
1363    pub populate_polylines: bool,
1364
1365    /// If true, polylines will be populated in response
1366    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
1367    /// Note that in this case, the polylines will also be populated in the
1368    /// deprecated `travel_steps`.
1369    ///
1370    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
1371    pub populate_transition_polylines: bool,
1372
1373    /// If this is set, then the request can have a deadline
1374    /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
1375    /// Otherwise, the maximum deadline is only 30 minutes.
1376    /// Note that long-lived requests have a significantly larger (but still small)
1377    /// risk of interruption.
1378    pub allow_large_deadline_despite_interruption_risk: bool,
1379
1380    /// If true, travel distances will be computed using geodesic distances instead
1381    /// of Google Maps distances, and travel times will be computed using geodesic
1382    /// distances with a speed defined by `geodesic_meters_per_second`.
1383    pub use_geodesic_distances: bool,
1384
1385    /// When `use_geodesic_distances` is true, this field must be set and defines
1386    /// the speed applied to compute travel times. Its value must be at least 1.0
1387    /// meters/seconds.
1388    pub geodesic_meters_per_second: std::option::Option<f64>,
1389
1390    /// Truncates the number of validation errors returned. These errors are
1391    /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
1392    /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
1393    /// unless solving_mode=VALIDATE_ONLY: see the
1394    /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1395    /// field.
1396    /// This defaults to 100 and is capped at 10,000.
1397    ///
1398    /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1399    pub max_validation_errors: std::option::Option<i32>,
1400
1401    /// Label that may be used to identify this request, reported back in the
1402    /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
1403    ///
1404    /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
1405    pub label: std::string::String,
1406
1407    /// Deprecated: Use
1408    /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
1409    /// instead. If true, polylines will be populated in response
1410    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
1411    /// Note that in this case, the polylines will also be populated in the
1412    /// deprecated `travel_steps`.
1413    ///
1414    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
1415    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
1416    #[deprecated]
1417    pub populate_travel_step_polylines: bool,
1418
1419    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1420}
1421
1422impl OptimizeToursRequest {
1423    pub fn new() -> Self {
1424        std::default::Default::default()
1425    }
1426
1427    /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
1428    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1429        self.parent = v.into();
1430        self
1431    }
1432
1433    /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
1434    pub fn set_timeout<T>(mut self, v: T) -> Self
1435    where
1436        T: std::convert::Into<wkt::Duration>,
1437    {
1438        self.timeout = std::option::Option::Some(v.into());
1439        self
1440    }
1441
1442    /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
1443    pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
1444    where
1445        T: std::convert::Into<wkt::Duration>,
1446    {
1447        self.timeout = v.map(|x| x.into());
1448        self
1449    }
1450
1451    /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
1452    pub fn set_model<T>(mut self, v: T) -> Self
1453    where
1454        T: std::convert::Into<crate::model::ShipmentModel>,
1455    {
1456        self.model = std::option::Option::Some(v.into());
1457        self
1458    }
1459
1460    /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
1461    pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
1462    where
1463        T: std::convert::Into<crate::model::ShipmentModel>,
1464    {
1465        self.model = v.map(|x| x.into());
1466        self
1467    }
1468
1469    /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
1470    pub fn set_solving_mode<
1471        T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
1472    >(
1473        mut self,
1474        v: T,
1475    ) -> Self {
1476        self.solving_mode = v.into();
1477        self
1478    }
1479
1480    /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
1481    pub fn set_search_mode<
1482        T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
1483    >(
1484        mut self,
1485        v: T,
1486    ) -> Self {
1487        self.search_mode = v.into();
1488        self
1489    }
1490
1491    /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
1492    pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
1493    where
1494        T: std::iter::IntoIterator<Item = V>,
1495        V: std::convert::Into<crate::model::ShipmentRoute>,
1496    {
1497        use std::iter::Iterator;
1498        self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
1499        self
1500    }
1501
1502    /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1503    pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
1504    where
1505        T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1506    {
1507        self.injected_solution_constraint = std::option::Option::Some(v.into());
1508        self
1509    }
1510
1511    /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1512    pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
1513    where
1514        T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1515    {
1516        self.injected_solution_constraint = v.map(|x| x.into());
1517        self
1518    }
1519
1520    /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
1521    pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
1522    where
1523        T: std::iter::IntoIterator<Item = V>,
1524        V: std::convert::Into<crate::model::ShipmentRoute>,
1525    {
1526        use std::iter::Iterator;
1527        self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
1528        self
1529    }
1530
1531    /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
1532    pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
1533        mut self,
1534        v: T,
1535    ) -> Self {
1536        self.interpret_injected_solutions_using_labels = v.into();
1537        self
1538    }
1539
1540    /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
1541    pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1542        self.consider_road_traffic = v.into();
1543        self
1544    }
1545
1546    /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
1547    pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1548        self.populate_polylines = v.into();
1549        self
1550    }
1551
1552    /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
1553    pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1554        self.populate_transition_polylines = v.into();
1555        self
1556    }
1557
1558    /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
1559    pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1560        mut self,
1561        v: T,
1562    ) -> Self {
1563        self.allow_large_deadline_despite_interruption_risk = v.into();
1564        self
1565    }
1566
1567    /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
1568    pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1569        self.use_geodesic_distances = v.into();
1570        self
1571    }
1572
1573    /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1574    pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1575    where
1576        T: std::convert::Into<f64>,
1577    {
1578        self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1579        self
1580    }
1581
1582    /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1583    pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1584    where
1585        T: std::convert::Into<f64>,
1586    {
1587        self.geodesic_meters_per_second = v.map(|x| x.into());
1588        self
1589    }
1590
1591    /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1592    pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1593    where
1594        T: std::convert::Into<i32>,
1595    {
1596        self.max_validation_errors = std::option::Option::Some(v.into());
1597        self
1598    }
1599
1600    /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1601    pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1602    where
1603        T: std::convert::Into<i32>,
1604    {
1605        self.max_validation_errors = v.map(|x| x.into());
1606        self
1607    }
1608
1609    /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
1610    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1611        self.label = v.into();
1612        self
1613    }
1614
1615    /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
1616    #[deprecated]
1617    pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1618        self.populate_travel_step_polylines = v.into();
1619        self
1620    }
1621}
1622
1623impl wkt::message::Message for OptimizeToursRequest {
1624    fn typename() -> &'static str {
1625        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
1626    }
1627}
1628
1629#[doc(hidden)]
1630impl<'de> serde::de::Deserialize<'de> for OptimizeToursRequest {
1631    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1632    where
1633        D: serde::Deserializer<'de>,
1634    {
1635        #[allow(non_camel_case_types)]
1636        #[doc(hidden)]
1637        #[derive(PartialEq, Eq, Hash)]
1638        enum __FieldTag {
1639            __parent,
1640            __timeout,
1641            __model,
1642            __solving_mode,
1643            __search_mode,
1644            __injected_first_solution_routes,
1645            __injected_solution_constraint,
1646            __refresh_details_routes,
1647            __interpret_injected_solutions_using_labels,
1648            __consider_road_traffic,
1649            __populate_polylines,
1650            __populate_transition_polylines,
1651            __allow_large_deadline_despite_interruption_risk,
1652            __use_geodesic_distances,
1653            __geodesic_meters_per_second,
1654            __max_validation_errors,
1655            __label,
1656            __populate_travel_step_polylines,
1657            Unknown(std::string::String),
1658        }
1659        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1660            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1661            where
1662                D: serde::Deserializer<'de>,
1663            {
1664                struct Visitor;
1665                impl<'de> serde::de::Visitor<'de> for Visitor {
1666                    type Value = __FieldTag;
1667                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1668                        formatter.write_str("a field name for OptimizeToursRequest")
1669                    }
1670                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1671                    where
1672                        E: serde::de::Error,
1673                    {
1674                        use std::result::Result::Ok;
1675                        use std::string::ToString;
1676                        match value {
1677                            "parent" => Ok(__FieldTag::__parent),
1678                            "timeout" => Ok(__FieldTag::__timeout),
1679                            "model" => Ok(__FieldTag::__model),
1680                            "solvingMode" => Ok(__FieldTag::__solving_mode),
1681                            "solving_mode" => Ok(__FieldTag::__solving_mode),
1682                            "searchMode" => Ok(__FieldTag::__search_mode),
1683                            "search_mode" => Ok(__FieldTag::__search_mode),
1684                            "injectedFirstSolutionRoutes" => {
1685                                Ok(__FieldTag::__injected_first_solution_routes)
1686                            }
1687                            "injected_first_solution_routes" => {
1688                                Ok(__FieldTag::__injected_first_solution_routes)
1689                            }
1690                            "injectedSolutionConstraint" => {
1691                                Ok(__FieldTag::__injected_solution_constraint)
1692                            }
1693                            "injected_solution_constraint" => {
1694                                Ok(__FieldTag::__injected_solution_constraint)
1695                            }
1696                            "refreshDetailsRoutes" => Ok(__FieldTag::__refresh_details_routes),
1697                            "refresh_details_routes" => Ok(__FieldTag::__refresh_details_routes),
1698                            "interpretInjectedSolutionsUsingLabels" => {
1699                                Ok(__FieldTag::__interpret_injected_solutions_using_labels)
1700                            }
1701                            "interpret_injected_solutions_using_labels" => {
1702                                Ok(__FieldTag::__interpret_injected_solutions_using_labels)
1703                            }
1704                            "considerRoadTraffic" => Ok(__FieldTag::__consider_road_traffic),
1705                            "consider_road_traffic" => Ok(__FieldTag::__consider_road_traffic),
1706                            "populatePolylines" => Ok(__FieldTag::__populate_polylines),
1707                            "populate_polylines" => Ok(__FieldTag::__populate_polylines),
1708                            "populateTransitionPolylines" => {
1709                                Ok(__FieldTag::__populate_transition_polylines)
1710                            }
1711                            "populate_transition_polylines" => {
1712                                Ok(__FieldTag::__populate_transition_polylines)
1713                            }
1714                            "allowLargeDeadlineDespiteInterruptionRisk" => {
1715                                Ok(__FieldTag::__allow_large_deadline_despite_interruption_risk)
1716                            }
1717                            "allow_large_deadline_despite_interruption_risk" => {
1718                                Ok(__FieldTag::__allow_large_deadline_despite_interruption_risk)
1719                            }
1720                            "useGeodesicDistances" => Ok(__FieldTag::__use_geodesic_distances),
1721                            "use_geodesic_distances" => Ok(__FieldTag::__use_geodesic_distances),
1722                            "geodesicMetersPerSecond" => {
1723                                Ok(__FieldTag::__geodesic_meters_per_second)
1724                            }
1725                            "geodesic_meters_per_second" => {
1726                                Ok(__FieldTag::__geodesic_meters_per_second)
1727                            }
1728                            "maxValidationErrors" => Ok(__FieldTag::__max_validation_errors),
1729                            "max_validation_errors" => Ok(__FieldTag::__max_validation_errors),
1730                            "label" => Ok(__FieldTag::__label),
1731                            "populateTravelStepPolylines" => {
1732                                Ok(__FieldTag::__populate_travel_step_polylines)
1733                            }
1734                            "populate_travel_step_polylines" => {
1735                                Ok(__FieldTag::__populate_travel_step_polylines)
1736                            }
1737                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1738                        }
1739                    }
1740                }
1741                deserializer.deserialize_identifier(Visitor)
1742            }
1743        }
1744        struct Visitor;
1745        impl<'de> serde::de::Visitor<'de> for Visitor {
1746            type Value = OptimizeToursRequest;
1747            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1748                formatter.write_str("struct OptimizeToursRequest")
1749            }
1750            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1751            where
1752                A: serde::de::MapAccess<'de>,
1753            {
1754                #[allow(unused_imports)]
1755                use serde::de::Error;
1756                use std::option::Option::Some;
1757                let mut fields = std::collections::HashSet::new();
1758                let mut result = Self::Value::new();
1759                while let Some(tag) = map.next_key::<__FieldTag>()? {
1760                    #[allow(clippy::match_single_binding)]
1761                    match tag {
1762                        __FieldTag::__parent => {
1763                            if !fields.insert(__FieldTag::__parent) {
1764                                return std::result::Result::Err(A::Error::duplicate_field(
1765                                    "multiple values for parent",
1766                                ));
1767                            }
1768                            result.parent = map
1769                                .next_value::<std::option::Option<std::string::String>>()?
1770                                .unwrap_or_default();
1771                        }
1772                        __FieldTag::__timeout => {
1773                            if !fields.insert(__FieldTag::__timeout) {
1774                                return std::result::Result::Err(A::Error::duplicate_field(
1775                                    "multiple values for timeout",
1776                                ));
1777                            }
1778                            result.timeout =
1779                                map.next_value::<std::option::Option<wkt::Duration>>()?;
1780                        }
1781                        __FieldTag::__model => {
1782                            if !fields.insert(__FieldTag::__model) {
1783                                return std::result::Result::Err(A::Error::duplicate_field(
1784                                    "multiple values for model",
1785                                ));
1786                            }
1787                            result.model = map
1788                                .next_value::<std::option::Option<crate::model::ShipmentModel>>()?;
1789                        }
1790                        __FieldTag::__solving_mode => {
1791                            if !fields.insert(__FieldTag::__solving_mode) {
1792                                return std::result::Result::Err(A::Error::duplicate_field(
1793                                    "multiple values for solving_mode",
1794                                ));
1795                            }
1796                            result.solving_mode = map
1797                                .next_value::<std::option::Option<
1798                                    crate::model::optimize_tours_request::SolvingMode,
1799                                >>()?
1800                                .unwrap_or_default();
1801                        }
1802                        __FieldTag::__search_mode => {
1803                            if !fields.insert(__FieldTag::__search_mode) {
1804                                return std::result::Result::Err(A::Error::duplicate_field(
1805                                    "multiple values for search_mode",
1806                                ));
1807                            }
1808                            result.search_mode = map
1809                                .next_value::<std::option::Option<
1810                                    crate::model::optimize_tours_request::SearchMode,
1811                                >>()?
1812                                .unwrap_or_default();
1813                        }
1814                        __FieldTag::__injected_first_solution_routes => {
1815                            if !fields.insert(__FieldTag::__injected_first_solution_routes) {
1816                                return std::result::Result::Err(A::Error::duplicate_field(
1817                                    "multiple values for injected_first_solution_routes",
1818                                ));
1819                            }
1820                            result.injected_first_solution_routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
1821                        }
1822                        __FieldTag::__injected_solution_constraint => {
1823                            if !fields.insert(__FieldTag::__injected_solution_constraint) {
1824                                return std::result::Result::Err(A::Error::duplicate_field(
1825                                    "multiple values for injected_solution_constraint",
1826                                ));
1827                            }
1828                            result.injected_solution_constraint = map.next_value::<std::option::Option<crate::model::InjectedSolutionConstraint>>()?
1829                                ;
1830                        }
1831                        __FieldTag::__refresh_details_routes => {
1832                            if !fields.insert(__FieldTag::__refresh_details_routes) {
1833                                return std::result::Result::Err(A::Error::duplicate_field(
1834                                    "multiple values for refresh_details_routes",
1835                                ));
1836                            }
1837                            result.refresh_details_routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
1838                        }
1839                        __FieldTag::__interpret_injected_solutions_using_labels => {
1840                            if !fields
1841                                .insert(__FieldTag::__interpret_injected_solutions_using_labels)
1842                            {
1843                                return std::result::Result::Err(A::Error::duplicate_field(
1844                                    "multiple values for interpret_injected_solutions_using_labels",
1845                                ));
1846                            }
1847                            result.interpret_injected_solutions_using_labels = map
1848                                .next_value::<std::option::Option<bool>>()?
1849                                .unwrap_or_default();
1850                        }
1851                        __FieldTag::__consider_road_traffic => {
1852                            if !fields.insert(__FieldTag::__consider_road_traffic) {
1853                                return std::result::Result::Err(A::Error::duplicate_field(
1854                                    "multiple values for consider_road_traffic",
1855                                ));
1856                            }
1857                            result.consider_road_traffic = map
1858                                .next_value::<std::option::Option<bool>>()?
1859                                .unwrap_or_default();
1860                        }
1861                        __FieldTag::__populate_polylines => {
1862                            if !fields.insert(__FieldTag::__populate_polylines) {
1863                                return std::result::Result::Err(A::Error::duplicate_field(
1864                                    "multiple values for populate_polylines",
1865                                ));
1866                            }
1867                            result.populate_polylines = map
1868                                .next_value::<std::option::Option<bool>>()?
1869                                .unwrap_or_default();
1870                        }
1871                        __FieldTag::__populate_transition_polylines => {
1872                            if !fields.insert(__FieldTag::__populate_transition_polylines) {
1873                                return std::result::Result::Err(A::Error::duplicate_field(
1874                                    "multiple values for populate_transition_polylines",
1875                                ));
1876                            }
1877                            result.populate_transition_polylines = map
1878                                .next_value::<std::option::Option<bool>>()?
1879                                .unwrap_or_default();
1880                        }
1881                        __FieldTag::__allow_large_deadline_despite_interruption_risk => {
1882                            if !fields.insert(
1883                                __FieldTag::__allow_large_deadline_despite_interruption_risk,
1884                            ) {
1885                                return std::result::Result::Err(A::Error::duplicate_field(
1886                                    "multiple values for allow_large_deadline_despite_interruption_risk",
1887                                ));
1888                            }
1889                            result.allow_large_deadline_despite_interruption_risk = map
1890                                .next_value::<std::option::Option<bool>>()?
1891                                .unwrap_or_default();
1892                        }
1893                        __FieldTag::__use_geodesic_distances => {
1894                            if !fields.insert(__FieldTag::__use_geodesic_distances) {
1895                                return std::result::Result::Err(A::Error::duplicate_field(
1896                                    "multiple values for use_geodesic_distances",
1897                                ));
1898                            }
1899                            result.use_geodesic_distances = map
1900                                .next_value::<std::option::Option<bool>>()?
1901                                .unwrap_or_default();
1902                        }
1903                        __FieldTag::__geodesic_meters_per_second => {
1904                            if !fields.insert(__FieldTag::__geodesic_meters_per_second) {
1905                                return std::result::Result::Err(A::Error::duplicate_field(
1906                                    "multiple values for geodesic_meters_per_second",
1907                                ));
1908                            }
1909                            struct __With(std::option::Option<f64>);
1910                            impl<'de> serde::de::Deserialize<'de> for __With {
1911                                fn deserialize<D>(
1912                                    deserializer: D,
1913                                ) -> std::result::Result<Self, D::Error>
1914                                where
1915                                    D: serde::de::Deserializer<'de>,
1916                                {
1917                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1918                                }
1919                            }
1920                            result.geodesic_meters_per_second = map.next_value::<__With>()?.0;
1921                        }
1922                        __FieldTag::__max_validation_errors => {
1923                            if !fields.insert(__FieldTag::__max_validation_errors) {
1924                                return std::result::Result::Err(A::Error::duplicate_field(
1925                                    "multiple values for max_validation_errors",
1926                                ));
1927                            }
1928                            struct __With(std::option::Option<i32>);
1929                            impl<'de> serde::de::Deserialize<'de> for __With {
1930                                fn deserialize<D>(
1931                                    deserializer: D,
1932                                ) -> std::result::Result<Self, D::Error>
1933                                where
1934                                    D: serde::de::Deserializer<'de>,
1935                                {
1936                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1937                                }
1938                            }
1939                            result.max_validation_errors = map.next_value::<__With>()?.0;
1940                        }
1941                        __FieldTag::__label => {
1942                            if !fields.insert(__FieldTag::__label) {
1943                                return std::result::Result::Err(A::Error::duplicate_field(
1944                                    "multiple values for label",
1945                                ));
1946                            }
1947                            result.label = map
1948                                .next_value::<std::option::Option<std::string::String>>()?
1949                                .unwrap_or_default();
1950                        }
1951                        __FieldTag::__populate_travel_step_polylines => {
1952                            if !fields.insert(__FieldTag::__populate_travel_step_polylines) {
1953                                return std::result::Result::Err(A::Error::duplicate_field(
1954                                    "multiple values for populate_travel_step_polylines",
1955                                ));
1956                            }
1957                            result.populate_travel_step_polylines = map
1958                                .next_value::<std::option::Option<bool>>()?
1959                                .unwrap_or_default();
1960                        }
1961                        __FieldTag::Unknown(key) => {
1962                            let value = map.next_value::<serde_json::Value>()?;
1963                            result._unknown_fields.insert(key, value);
1964                        }
1965                    }
1966                }
1967                std::result::Result::Ok(result)
1968            }
1969        }
1970        deserializer.deserialize_any(Visitor)
1971    }
1972}
1973
1974#[doc(hidden)]
1975impl serde::ser::Serialize for OptimizeToursRequest {
1976    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1977    where
1978        S: serde::ser::Serializer,
1979    {
1980        use serde::ser::SerializeMap;
1981        #[allow(unused_imports)]
1982        use std::option::Option::Some;
1983        let mut state = serializer.serialize_map(std::option::Option::None)?;
1984        if !self.parent.is_empty() {
1985            state.serialize_entry("parent", &self.parent)?;
1986        }
1987        if self.timeout.is_some() {
1988            state.serialize_entry("timeout", &self.timeout)?;
1989        }
1990        if self.model.is_some() {
1991            state.serialize_entry("model", &self.model)?;
1992        }
1993        if !wkt::internal::is_default(&self.solving_mode) {
1994            state.serialize_entry("solvingMode", &self.solving_mode)?;
1995        }
1996        if !wkt::internal::is_default(&self.search_mode) {
1997            state.serialize_entry("searchMode", &self.search_mode)?;
1998        }
1999        if !self.injected_first_solution_routes.is_empty() {
2000            state.serialize_entry(
2001                "injectedFirstSolutionRoutes",
2002                &self.injected_first_solution_routes,
2003            )?;
2004        }
2005        if self.injected_solution_constraint.is_some() {
2006            state.serialize_entry(
2007                "injectedSolutionConstraint",
2008                &self.injected_solution_constraint,
2009            )?;
2010        }
2011        if !self.refresh_details_routes.is_empty() {
2012            state.serialize_entry("refreshDetailsRoutes", &self.refresh_details_routes)?;
2013        }
2014        if !wkt::internal::is_default(&self.interpret_injected_solutions_using_labels) {
2015            state.serialize_entry(
2016                "interpretInjectedSolutionsUsingLabels",
2017                &self.interpret_injected_solutions_using_labels,
2018            )?;
2019        }
2020        if !wkt::internal::is_default(&self.consider_road_traffic) {
2021            state.serialize_entry("considerRoadTraffic", &self.consider_road_traffic)?;
2022        }
2023        if !wkt::internal::is_default(&self.populate_polylines) {
2024            state.serialize_entry("populatePolylines", &self.populate_polylines)?;
2025        }
2026        if !wkt::internal::is_default(&self.populate_transition_polylines) {
2027            state.serialize_entry(
2028                "populateTransitionPolylines",
2029                &self.populate_transition_polylines,
2030            )?;
2031        }
2032        if !wkt::internal::is_default(&self.allow_large_deadline_despite_interruption_risk) {
2033            state.serialize_entry(
2034                "allowLargeDeadlineDespiteInterruptionRisk",
2035                &self.allow_large_deadline_despite_interruption_risk,
2036            )?;
2037        }
2038        if !wkt::internal::is_default(&self.use_geodesic_distances) {
2039            state.serialize_entry("useGeodesicDistances", &self.use_geodesic_distances)?;
2040        }
2041        if self.geodesic_meters_per_second.is_some() {
2042            struct __With<'a>(&'a std::option::Option<f64>);
2043            impl<'a> serde::ser::Serialize for __With<'a> {
2044                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2045                where
2046                    S: serde::ser::Serializer,
2047                {
2048                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
2049                        self.0, serializer,
2050                    )
2051                }
2052            }
2053            state.serialize_entry(
2054                "geodesicMetersPerSecond",
2055                &__With(&self.geodesic_meters_per_second),
2056            )?;
2057        }
2058        if self.max_validation_errors.is_some() {
2059            struct __With<'a>(&'a std::option::Option<i32>);
2060            impl<'a> serde::ser::Serialize for __With<'a> {
2061                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2062                where
2063                    S: serde::ser::Serializer,
2064                {
2065                    serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
2066                        self.0, serializer,
2067                    )
2068                }
2069            }
2070            state.serialize_entry("maxValidationErrors", &__With(&self.max_validation_errors))?;
2071        }
2072        if !self.label.is_empty() {
2073            state.serialize_entry("label", &self.label)?;
2074        }
2075        if !wkt::internal::is_default(&self.populate_travel_step_polylines) {
2076            state.serialize_entry(
2077                "populateTravelStepPolylines",
2078                &self.populate_travel_step_polylines,
2079            )?;
2080        }
2081        if !self._unknown_fields.is_empty() {
2082            for (key, value) in self._unknown_fields.iter() {
2083                state.serialize_entry(key, &value)?;
2084            }
2085        }
2086        state.end()
2087    }
2088}
2089
2090impl std::fmt::Debug for OptimizeToursRequest {
2091    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2092        let mut debug_struct = f.debug_struct("OptimizeToursRequest");
2093        debug_struct.field("parent", &self.parent);
2094        debug_struct.field("timeout", &self.timeout);
2095        debug_struct.field("model", &self.model);
2096        debug_struct.field("solving_mode", &self.solving_mode);
2097        debug_struct.field("search_mode", &self.search_mode);
2098        debug_struct.field(
2099            "injected_first_solution_routes",
2100            &self.injected_first_solution_routes,
2101        );
2102        debug_struct.field(
2103            "injected_solution_constraint",
2104            &self.injected_solution_constraint,
2105        );
2106        debug_struct.field("refresh_details_routes", &self.refresh_details_routes);
2107        debug_struct.field(
2108            "interpret_injected_solutions_using_labels",
2109            &self.interpret_injected_solutions_using_labels,
2110        );
2111        debug_struct.field("consider_road_traffic", &self.consider_road_traffic);
2112        debug_struct.field("populate_polylines", &self.populate_polylines);
2113        debug_struct.field(
2114            "populate_transition_polylines",
2115            &self.populate_transition_polylines,
2116        );
2117        debug_struct.field(
2118            "allow_large_deadline_despite_interruption_risk",
2119            &self.allow_large_deadline_despite_interruption_risk,
2120        );
2121        debug_struct.field("use_geodesic_distances", &self.use_geodesic_distances);
2122        debug_struct.field(
2123            "geodesic_meters_per_second",
2124            &self.geodesic_meters_per_second,
2125        );
2126        debug_struct.field("max_validation_errors", &self.max_validation_errors);
2127        debug_struct.field("label", &self.label);
2128        debug_struct.field(
2129            "populate_travel_step_polylines",
2130            &self.populate_travel_step_polylines,
2131        );
2132        if !self._unknown_fields.is_empty() {
2133            debug_struct.field("_unknown_fields", &self._unknown_fields);
2134        }
2135        debug_struct.finish()
2136    }
2137}
2138
2139/// Defines additional types related to [OptimizeToursRequest].
2140pub mod optimize_tours_request {
2141    #[allow(unused_imports)]
2142    use super::*;
2143
2144    /// Defines how the solver should handle the request. In all modes but
2145    /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
2146    /// `INVALID_REQUEST` error. See
2147    /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
2148    /// to cap the number of errors returned.
2149    ///
2150    /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
2151    ///
2152    /// # Working with unknown values
2153    ///
2154    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2155    /// additional enum variants at any time. Adding new variants is not considered
2156    /// a breaking change. Applications should write their code in anticipation of:
2157    ///
2158    /// - New values appearing in future releases of the client library, **and**
2159    /// - New values received dynamically, without application changes.
2160    ///
2161    /// Please consult the [Working with enums] section in the user guide for some
2162    /// guidelines.
2163    ///
2164    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2165    #[derive(Clone, Debug, PartialEq)]
2166    #[non_exhaustive]
2167    pub enum SolvingMode {
2168        /// Solve the model.
2169        DefaultSolve,
2170        /// Only validates the model without solving it: populates as many
2171        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
2172        /// as possible.
2173        ///
2174        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
2175        ValidateOnly,
2176        /// Only populates
2177        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
2178        /// or
2179        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
2180        /// and doesn't actually solve the rest of the request (`status` and `routes`
2181        /// are unset in the response).
2182        /// If infeasibilities in `injected_solution_constraint` routes are detected
2183        /// they are populated in the
2184        /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
2185        /// field and
2186        /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
2187        /// is left empty.
2188        ///
2189        /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
2190        /// ones that are detected as infeasible during preprocessing.
2191        ///
2192        /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
2193        /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
2194        DetectSomeInfeasibleShipments,
2195        /// If set, the enum was initialized with an unknown value.
2196        ///
2197        /// Applications can examine the value using [SolvingMode::value] or
2198        /// [SolvingMode::name].
2199        UnknownValue(solving_mode::UnknownValue),
2200    }
2201
2202    #[doc(hidden)]
2203    pub mod solving_mode {
2204        #[allow(unused_imports)]
2205        use super::*;
2206        #[derive(Clone, Debug, PartialEq)]
2207        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2208    }
2209
2210    impl SolvingMode {
2211        /// Gets the enum value.
2212        ///
2213        /// Returns `None` if the enum contains an unknown value deserialized from
2214        /// the string representation of enums.
2215        pub fn value(&self) -> std::option::Option<i32> {
2216            match self {
2217                Self::DefaultSolve => std::option::Option::Some(0),
2218                Self::ValidateOnly => std::option::Option::Some(1),
2219                Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
2220                Self::UnknownValue(u) => u.0.value(),
2221            }
2222        }
2223
2224        /// Gets the enum value as a string.
2225        ///
2226        /// Returns `None` if the enum contains an unknown value deserialized from
2227        /// the integer representation of enums.
2228        pub fn name(&self) -> std::option::Option<&str> {
2229            match self {
2230                Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
2231                Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
2232                Self::DetectSomeInfeasibleShipments => {
2233                    std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
2234                }
2235                Self::UnknownValue(u) => u.0.name(),
2236            }
2237        }
2238    }
2239
2240    impl std::default::Default for SolvingMode {
2241        fn default() -> Self {
2242            use std::convert::From;
2243            Self::from(0)
2244        }
2245    }
2246
2247    impl std::fmt::Display for SolvingMode {
2248        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2249            wkt::internal::display_enum(f, self.name(), self.value())
2250        }
2251    }
2252
2253    impl std::convert::From<i32> for SolvingMode {
2254        fn from(value: i32) -> Self {
2255            match value {
2256                0 => Self::DefaultSolve,
2257                1 => Self::ValidateOnly,
2258                2 => Self::DetectSomeInfeasibleShipments,
2259                _ => Self::UnknownValue(solving_mode::UnknownValue(
2260                    wkt::internal::UnknownEnumValue::Integer(value),
2261                )),
2262            }
2263        }
2264    }
2265
2266    impl std::convert::From<&str> for SolvingMode {
2267        fn from(value: &str) -> Self {
2268            use std::string::ToString;
2269            match value {
2270                "DEFAULT_SOLVE" => Self::DefaultSolve,
2271                "VALIDATE_ONLY" => Self::ValidateOnly,
2272                "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
2273                _ => Self::UnknownValue(solving_mode::UnknownValue(
2274                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2275                )),
2276            }
2277        }
2278    }
2279
2280    impl serde::ser::Serialize for SolvingMode {
2281        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2282        where
2283            S: serde::Serializer,
2284        {
2285            match self {
2286                Self::DefaultSolve => serializer.serialize_i32(0),
2287                Self::ValidateOnly => serializer.serialize_i32(1),
2288                Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
2289                Self::UnknownValue(u) => u.0.serialize(serializer),
2290            }
2291        }
2292    }
2293
2294    impl<'de> serde::de::Deserialize<'de> for SolvingMode {
2295        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2296        where
2297            D: serde::Deserializer<'de>,
2298        {
2299            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
2300                ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
2301            ))
2302        }
2303    }
2304
2305    /// Mode defining the behavior of the search, trading off latency versus
2306    /// solution quality. In all modes, the global request deadline is enforced.
2307    ///
2308    /// # Working with unknown values
2309    ///
2310    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2311    /// additional enum variants at any time. Adding new variants is not considered
2312    /// a breaking change. Applications should write their code in anticipation of:
2313    ///
2314    /// - New values appearing in future releases of the client library, **and**
2315    /// - New values received dynamically, without application changes.
2316    ///
2317    /// Please consult the [Working with enums] section in the user guide for some
2318    /// guidelines.
2319    ///
2320    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2321    #[derive(Clone, Debug, PartialEq)]
2322    #[non_exhaustive]
2323    pub enum SearchMode {
2324        /// Unspecified search mode, equivalent to `RETURN_FAST`.
2325        Unspecified,
2326        /// Stop the search after finding the first good solution.
2327        ReturnFast,
2328        /// Spend all the available time to search for better solutions.
2329        ConsumeAllAvailableTime,
2330        /// If set, the enum was initialized with an unknown value.
2331        ///
2332        /// Applications can examine the value using [SearchMode::value] or
2333        /// [SearchMode::name].
2334        UnknownValue(search_mode::UnknownValue),
2335    }
2336
2337    #[doc(hidden)]
2338    pub mod search_mode {
2339        #[allow(unused_imports)]
2340        use super::*;
2341        #[derive(Clone, Debug, PartialEq)]
2342        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2343    }
2344
2345    impl SearchMode {
2346        /// Gets the enum value.
2347        ///
2348        /// Returns `None` if the enum contains an unknown value deserialized from
2349        /// the string representation of enums.
2350        pub fn value(&self) -> std::option::Option<i32> {
2351            match self {
2352                Self::Unspecified => std::option::Option::Some(0),
2353                Self::ReturnFast => std::option::Option::Some(1),
2354                Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
2355                Self::UnknownValue(u) => u.0.value(),
2356            }
2357        }
2358
2359        /// Gets the enum value as a string.
2360        ///
2361        /// Returns `None` if the enum contains an unknown value deserialized from
2362        /// the integer representation of enums.
2363        pub fn name(&self) -> std::option::Option<&str> {
2364            match self {
2365                Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
2366                Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
2367                Self::ConsumeAllAvailableTime => {
2368                    std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
2369                }
2370                Self::UnknownValue(u) => u.0.name(),
2371            }
2372        }
2373    }
2374
2375    impl std::default::Default for SearchMode {
2376        fn default() -> Self {
2377            use std::convert::From;
2378            Self::from(0)
2379        }
2380    }
2381
2382    impl std::fmt::Display for SearchMode {
2383        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2384            wkt::internal::display_enum(f, self.name(), self.value())
2385        }
2386    }
2387
2388    impl std::convert::From<i32> for SearchMode {
2389        fn from(value: i32) -> Self {
2390            match value {
2391                0 => Self::Unspecified,
2392                1 => Self::ReturnFast,
2393                2 => Self::ConsumeAllAvailableTime,
2394                _ => Self::UnknownValue(search_mode::UnknownValue(
2395                    wkt::internal::UnknownEnumValue::Integer(value),
2396                )),
2397            }
2398        }
2399    }
2400
2401    impl std::convert::From<&str> for SearchMode {
2402        fn from(value: &str) -> Self {
2403            use std::string::ToString;
2404            match value {
2405                "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
2406                "RETURN_FAST" => Self::ReturnFast,
2407                "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
2408                _ => Self::UnknownValue(search_mode::UnknownValue(
2409                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2410                )),
2411            }
2412        }
2413    }
2414
2415    impl serde::ser::Serialize for SearchMode {
2416        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2417        where
2418            S: serde::Serializer,
2419        {
2420            match self {
2421                Self::Unspecified => serializer.serialize_i32(0),
2422                Self::ReturnFast => serializer.serialize_i32(1),
2423                Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
2424                Self::UnknownValue(u) => u.0.serialize(serializer),
2425            }
2426        }
2427    }
2428
2429    impl<'de> serde::de::Deserialize<'de> for SearchMode {
2430        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2431        where
2432            D: serde::Deserializer<'de>,
2433        {
2434            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
2435                ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
2436            ))
2437        }
2438    }
2439}
2440
2441/// Response after solving a tour optimization problem containing the routes
2442/// followed by each vehicle, the shipments which have been skipped and the
2443/// overall cost of the solution.
2444#[derive(Clone, Default, PartialEq)]
2445#[non_exhaustive]
2446pub struct OptimizeToursResponse {
2447    /// Routes computed for each vehicle; the i-th route corresponds to the i-th
2448    /// vehicle in the model.
2449    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
2450
2451    /// Copy of the
2452    /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
2453    /// if a label was specified in the request.
2454    ///
2455    /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
2456    pub request_label: std::string::String,
2457
2458    /// The list of all shipments skipped.
2459    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
2460
2461    /// List of all the validation errors that we were able to detect
2462    /// independently. See the "MULTIPLE ERRORS" explanation for the
2463    /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
2464    /// message.
2465    ///
2466    /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
2467    pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
2468
2469    /// Duration, distance and usage metrics for this solution.
2470    pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
2471
2472    /// Deprecated: Use
2473    /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
2474    /// instead. Total cost of the solution. This takes into account all costs:
2475    /// costs per per hour and travel hour, fixed vehicle costs, unperformed
2476    /// shipment penalty costs, global duration cost, etc.
2477    ///
2478    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
2479    #[deprecated]
2480    pub total_cost: f64,
2481
2482    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2483}
2484
2485impl OptimizeToursResponse {
2486    pub fn new() -> Self {
2487        std::default::Default::default()
2488    }
2489
2490    /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
2491    pub fn set_routes<T, V>(mut self, v: T) -> Self
2492    where
2493        T: std::iter::IntoIterator<Item = V>,
2494        V: std::convert::Into<crate::model::ShipmentRoute>,
2495    {
2496        use std::iter::Iterator;
2497        self.routes = v.into_iter().map(|i| i.into()).collect();
2498        self
2499    }
2500
2501    /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
2502    pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2503        self.request_label = v.into();
2504        self
2505    }
2506
2507    /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
2508    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
2509    where
2510        T: std::iter::IntoIterator<Item = V>,
2511        V: std::convert::Into<crate::model::SkippedShipment>,
2512    {
2513        use std::iter::Iterator;
2514        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
2515        self
2516    }
2517
2518    /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
2519    pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
2520    where
2521        T: std::iter::IntoIterator<Item = V>,
2522        V: std::convert::Into<crate::model::OptimizeToursValidationError>,
2523    {
2524        use std::iter::Iterator;
2525        self.validation_errors = v.into_iter().map(|i| i.into()).collect();
2526        self
2527    }
2528
2529    /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
2530    pub fn set_metrics<T>(mut self, v: T) -> Self
2531    where
2532        T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
2533    {
2534        self.metrics = std::option::Option::Some(v.into());
2535        self
2536    }
2537
2538    /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
2539    pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
2540    where
2541        T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
2542    {
2543        self.metrics = v.map(|x| x.into());
2544        self
2545    }
2546
2547    /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
2548    #[deprecated]
2549    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2550        self.total_cost = v.into();
2551        self
2552    }
2553}
2554
2555impl wkt::message::Message for OptimizeToursResponse {
2556    fn typename() -> &'static str {
2557        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
2558    }
2559}
2560
2561#[doc(hidden)]
2562impl<'de> serde::de::Deserialize<'de> for OptimizeToursResponse {
2563    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2564    where
2565        D: serde::Deserializer<'de>,
2566    {
2567        #[allow(non_camel_case_types)]
2568        #[doc(hidden)]
2569        #[derive(PartialEq, Eq, Hash)]
2570        enum __FieldTag {
2571            __routes,
2572            __request_label,
2573            __skipped_shipments,
2574            __validation_errors,
2575            __metrics,
2576            __total_cost,
2577            Unknown(std::string::String),
2578        }
2579        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2580            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2581            where
2582                D: serde::Deserializer<'de>,
2583            {
2584                struct Visitor;
2585                impl<'de> serde::de::Visitor<'de> for Visitor {
2586                    type Value = __FieldTag;
2587                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2588                        formatter.write_str("a field name for OptimizeToursResponse")
2589                    }
2590                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2591                    where
2592                        E: serde::de::Error,
2593                    {
2594                        use std::result::Result::Ok;
2595                        use std::string::ToString;
2596                        match value {
2597                            "routes" => Ok(__FieldTag::__routes),
2598                            "requestLabel" => Ok(__FieldTag::__request_label),
2599                            "request_label" => Ok(__FieldTag::__request_label),
2600                            "skippedShipments" => Ok(__FieldTag::__skipped_shipments),
2601                            "skipped_shipments" => Ok(__FieldTag::__skipped_shipments),
2602                            "validationErrors" => Ok(__FieldTag::__validation_errors),
2603                            "validation_errors" => Ok(__FieldTag::__validation_errors),
2604                            "metrics" => Ok(__FieldTag::__metrics),
2605                            "totalCost" => Ok(__FieldTag::__total_cost),
2606                            "total_cost" => Ok(__FieldTag::__total_cost),
2607                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2608                        }
2609                    }
2610                }
2611                deserializer.deserialize_identifier(Visitor)
2612            }
2613        }
2614        struct Visitor;
2615        impl<'de> serde::de::Visitor<'de> for Visitor {
2616            type Value = OptimizeToursResponse;
2617            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2618                formatter.write_str("struct OptimizeToursResponse")
2619            }
2620            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2621            where
2622                A: serde::de::MapAccess<'de>,
2623            {
2624                #[allow(unused_imports)]
2625                use serde::de::Error;
2626                use std::option::Option::Some;
2627                let mut fields = std::collections::HashSet::new();
2628                let mut result = Self::Value::new();
2629                while let Some(tag) = map.next_key::<__FieldTag>()? {
2630                    #[allow(clippy::match_single_binding)]
2631                    match tag {
2632                        __FieldTag::__routes => {
2633                            if !fields.insert(__FieldTag::__routes) {
2634                                return std::result::Result::Err(A::Error::duplicate_field(
2635                                    "multiple values for routes",
2636                                ));
2637                            }
2638                            result.routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
2639                        }
2640                        __FieldTag::__request_label => {
2641                            if !fields.insert(__FieldTag::__request_label) {
2642                                return std::result::Result::Err(A::Error::duplicate_field(
2643                                    "multiple values for request_label",
2644                                ));
2645                            }
2646                            result.request_label = map
2647                                .next_value::<std::option::Option<std::string::String>>()?
2648                                .unwrap_or_default();
2649                        }
2650                        __FieldTag::__skipped_shipments => {
2651                            if !fields.insert(__FieldTag::__skipped_shipments) {
2652                                return std::result::Result::Err(A::Error::duplicate_field(
2653                                    "multiple values for skipped_shipments",
2654                                ));
2655                            }
2656                            result.skipped_shipments =
2657                                map.next_value::<std::option::Option<
2658                                    std::vec::Vec<crate::model::SkippedShipment>,
2659                                >>()?
2660                                .unwrap_or_default();
2661                        }
2662                        __FieldTag::__validation_errors => {
2663                            if !fields.insert(__FieldTag::__validation_errors) {
2664                                return std::result::Result::Err(A::Error::duplicate_field(
2665                                    "multiple values for validation_errors",
2666                                ));
2667                            }
2668                            result.validation_errors = map
2669                                .next_value::<std::option::Option<
2670                                    std::vec::Vec<crate::model::OptimizeToursValidationError>,
2671                                >>()?
2672                                .unwrap_or_default();
2673                        }
2674                        __FieldTag::__metrics => {
2675                            if !fields.insert(__FieldTag::__metrics) {
2676                                return std::result::Result::Err(A::Error::duplicate_field(
2677                                    "multiple values for metrics",
2678                                ));
2679                            }
2680                            result.metrics = map.next_value::<std::option::Option<
2681                                crate::model::optimize_tours_response::Metrics,
2682                            >>()?;
2683                        }
2684                        __FieldTag::__total_cost => {
2685                            if !fields.insert(__FieldTag::__total_cost) {
2686                                return std::result::Result::Err(A::Error::duplicate_field(
2687                                    "multiple values for total_cost",
2688                                ));
2689                            }
2690                            struct __With(std::option::Option<f64>);
2691                            impl<'de> serde::de::Deserialize<'de> for __With {
2692                                fn deserialize<D>(
2693                                    deserializer: D,
2694                                ) -> std::result::Result<Self, D::Error>
2695                                where
2696                                    D: serde::de::Deserializer<'de>,
2697                                {
2698                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
2699                                }
2700                            }
2701                            result.total_cost = map.next_value::<__With>()?.0.unwrap_or_default();
2702                        }
2703                        __FieldTag::Unknown(key) => {
2704                            let value = map.next_value::<serde_json::Value>()?;
2705                            result._unknown_fields.insert(key, value);
2706                        }
2707                    }
2708                }
2709                std::result::Result::Ok(result)
2710            }
2711        }
2712        deserializer.deserialize_any(Visitor)
2713    }
2714}
2715
2716#[doc(hidden)]
2717impl serde::ser::Serialize for OptimizeToursResponse {
2718    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2719    where
2720        S: serde::ser::Serializer,
2721    {
2722        use serde::ser::SerializeMap;
2723        #[allow(unused_imports)]
2724        use std::option::Option::Some;
2725        let mut state = serializer.serialize_map(std::option::Option::None)?;
2726        if !self.routes.is_empty() {
2727            state.serialize_entry("routes", &self.routes)?;
2728        }
2729        if !self.request_label.is_empty() {
2730            state.serialize_entry("requestLabel", &self.request_label)?;
2731        }
2732        if !self.skipped_shipments.is_empty() {
2733            state.serialize_entry("skippedShipments", &self.skipped_shipments)?;
2734        }
2735        if !self.validation_errors.is_empty() {
2736            state.serialize_entry("validationErrors", &self.validation_errors)?;
2737        }
2738        if self.metrics.is_some() {
2739            state.serialize_entry("metrics", &self.metrics)?;
2740        }
2741        if !wkt::internal::is_default(&self.total_cost) {
2742            struct __With<'a>(&'a f64);
2743            impl<'a> serde::ser::Serialize for __With<'a> {
2744                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2745                where
2746                    S: serde::ser::Serializer,
2747                {
2748                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2749                }
2750            }
2751            state.serialize_entry("totalCost", &__With(&self.total_cost))?;
2752        }
2753        if !self._unknown_fields.is_empty() {
2754            for (key, value) in self._unknown_fields.iter() {
2755                state.serialize_entry(key, &value)?;
2756            }
2757        }
2758        state.end()
2759    }
2760}
2761
2762impl std::fmt::Debug for OptimizeToursResponse {
2763    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2764        let mut debug_struct = f.debug_struct("OptimizeToursResponse");
2765        debug_struct.field("routes", &self.routes);
2766        debug_struct.field("request_label", &self.request_label);
2767        debug_struct.field("skipped_shipments", &self.skipped_shipments);
2768        debug_struct.field("validation_errors", &self.validation_errors);
2769        debug_struct.field("metrics", &self.metrics);
2770        debug_struct.field("total_cost", &self.total_cost);
2771        if !self._unknown_fields.is_empty() {
2772            debug_struct.field("_unknown_fields", &self._unknown_fields);
2773        }
2774        debug_struct.finish()
2775    }
2776}
2777
2778/// Defines additional types related to [OptimizeToursResponse].
2779pub mod optimize_tours_response {
2780    #[allow(unused_imports)]
2781    use super::*;
2782
2783    /// Overall metrics, aggregated over all routes.
2784    #[derive(Clone, Default, PartialEq)]
2785    #[non_exhaustive]
2786    pub struct Metrics {
2787        /// Aggregated over the routes. Each metric is the sum (or max, for loads)
2788        /// over all
2789        /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
2790        /// fields of the same name.
2791        ///
2792        /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
2793        pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
2794
2795        /// Number of mandatory shipments skipped.
2796        pub skipped_mandatory_shipment_count: i32,
2797
2798        /// Number of vehicles used. Note: if a vehicle route is empty and
2799        /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
2800        /// is true, the vehicle is considered used.
2801        ///
2802        /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
2803        pub used_vehicle_count: i32,
2804
2805        /// The earliest start time for a used vehicle, computed as the minimum over
2806        /// all used vehicles of
2807        /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
2808        ///
2809        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
2810        pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
2811
2812        /// The latest end time for a used vehicle, computed as the maximum over all
2813        /// used vehicles of
2814        /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
2815        ///
2816        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
2817        pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
2818
2819        /// Cost of the solution, broken down by cost-related request fields.
2820        /// The keys are proto paths, relative to the input OptimizeToursRequest,
2821        /// e.g. "model.shipments.pickups.cost", and the values are the total cost
2822        /// generated by the corresponding cost field, aggregated over the whole
2823        /// solution. In other words, costs["model.shipments.pickups.cost"] is the
2824        /// sum of all pickup costs over the solution. All costs defined in the model
2825        /// are reported in detail here with the exception of costs related to
2826        /// TransitionAttributes that are only reported in an aggregated way as of
2827        /// 2022/01.
2828        pub costs: std::collections::HashMap<std::string::String, f64>,
2829
2830        /// Total cost of the solution. The sum of all values in the costs map.
2831        pub total_cost: f64,
2832
2833        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2834    }
2835
2836    impl Metrics {
2837        pub fn new() -> Self {
2838            std::default::Default::default()
2839        }
2840
2841        /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
2842        pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
2843        where
2844            T: std::convert::Into<crate::model::AggregatedMetrics>,
2845        {
2846            self.aggregated_route_metrics = std::option::Option::Some(v.into());
2847            self
2848        }
2849
2850        /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
2851        pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
2852        where
2853            T: std::convert::Into<crate::model::AggregatedMetrics>,
2854        {
2855            self.aggregated_route_metrics = v.map(|x| x.into());
2856            self
2857        }
2858
2859        /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
2860        pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
2861            mut self,
2862            v: T,
2863        ) -> Self {
2864            self.skipped_mandatory_shipment_count = v.into();
2865            self
2866        }
2867
2868        /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
2869        pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2870            self.used_vehicle_count = v.into();
2871            self
2872        }
2873
2874        /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
2875        pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
2876        where
2877            T: std::convert::Into<wkt::Timestamp>,
2878        {
2879            self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
2880            self
2881        }
2882
2883        /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
2884        pub fn set_or_clear_earliest_vehicle_start_time<T>(
2885            mut self,
2886            v: std::option::Option<T>,
2887        ) -> Self
2888        where
2889            T: std::convert::Into<wkt::Timestamp>,
2890        {
2891            self.earliest_vehicle_start_time = v.map(|x| x.into());
2892            self
2893        }
2894
2895        /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
2896        pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
2897        where
2898            T: std::convert::Into<wkt::Timestamp>,
2899        {
2900            self.latest_vehicle_end_time = std::option::Option::Some(v.into());
2901            self
2902        }
2903
2904        /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
2905        pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2906        where
2907            T: std::convert::Into<wkt::Timestamp>,
2908        {
2909            self.latest_vehicle_end_time = v.map(|x| x.into());
2910            self
2911        }
2912
2913        /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
2914        pub fn set_costs<T, K, V>(mut self, v: T) -> Self
2915        where
2916            T: std::iter::IntoIterator<Item = (K, V)>,
2917            K: std::convert::Into<std::string::String>,
2918            V: std::convert::Into<f64>,
2919        {
2920            use std::iter::Iterator;
2921            self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2922            self
2923        }
2924
2925        /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
2926        pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2927            self.total_cost = v.into();
2928            self
2929        }
2930    }
2931
2932    impl wkt::message::Message for Metrics {
2933        fn typename() -> &'static str {
2934            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
2935        }
2936    }
2937
2938    #[doc(hidden)]
2939    impl<'de> serde::de::Deserialize<'de> for Metrics {
2940        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2941        where
2942            D: serde::Deserializer<'de>,
2943        {
2944            #[allow(non_camel_case_types)]
2945            #[doc(hidden)]
2946            #[derive(PartialEq, Eq, Hash)]
2947            enum __FieldTag {
2948                __aggregated_route_metrics,
2949                __skipped_mandatory_shipment_count,
2950                __used_vehicle_count,
2951                __earliest_vehicle_start_time,
2952                __latest_vehicle_end_time,
2953                __costs,
2954                __total_cost,
2955                Unknown(std::string::String),
2956            }
2957            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2958                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2959                where
2960                    D: serde::Deserializer<'de>,
2961                {
2962                    struct Visitor;
2963                    impl<'de> serde::de::Visitor<'de> for Visitor {
2964                        type Value = __FieldTag;
2965                        fn expecting(
2966                            &self,
2967                            formatter: &mut std::fmt::Formatter,
2968                        ) -> std::fmt::Result {
2969                            formatter.write_str("a field name for Metrics")
2970                        }
2971                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2972                        where
2973                            E: serde::de::Error,
2974                        {
2975                            use std::result::Result::Ok;
2976                            use std::string::ToString;
2977                            match value {
2978                                "aggregatedRouteMetrics" => {
2979                                    Ok(__FieldTag::__aggregated_route_metrics)
2980                                }
2981                                "aggregated_route_metrics" => {
2982                                    Ok(__FieldTag::__aggregated_route_metrics)
2983                                }
2984                                "skippedMandatoryShipmentCount" => {
2985                                    Ok(__FieldTag::__skipped_mandatory_shipment_count)
2986                                }
2987                                "skipped_mandatory_shipment_count" => {
2988                                    Ok(__FieldTag::__skipped_mandatory_shipment_count)
2989                                }
2990                                "usedVehicleCount" => Ok(__FieldTag::__used_vehicle_count),
2991                                "used_vehicle_count" => Ok(__FieldTag::__used_vehicle_count),
2992                                "earliestVehicleStartTime" => {
2993                                    Ok(__FieldTag::__earliest_vehicle_start_time)
2994                                }
2995                                "earliest_vehicle_start_time" => {
2996                                    Ok(__FieldTag::__earliest_vehicle_start_time)
2997                                }
2998                                "latestVehicleEndTime" => Ok(__FieldTag::__latest_vehicle_end_time),
2999                                "latest_vehicle_end_time" => {
3000                                    Ok(__FieldTag::__latest_vehicle_end_time)
3001                                }
3002                                "costs" => Ok(__FieldTag::__costs),
3003                                "totalCost" => Ok(__FieldTag::__total_cost),
3004                                "total_cost" => Ok(__FieldTag::__total_cost),
3005                                _ => Ok(__FieldTag::Unknown(value.to_string())),
3006                            }
3007                        }
3008                    }
3009                    deserializer.deserialize_identifier(Visitor)
3010                }
3011            }
3012            struct Visitor;
3013            impl<'de> serde::de::Visitor<'de> for Visitor {
3014                type Value = Metrics;
3015                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3016                    formatter.write_str("struct Metrics")
3017                }
3018                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3019                where
3020                    A: serde::de::MapAccess<'de>,
3021                {
3022                    #[allow(unused_imports)]
3023                    use serde::de::Error;
3024                    use std::option::Option::Some;
3025                    let mut fields = std::collections::HashSet::new();
3026                    let mut result = Self::Value::new();
3027                    while let Some(tag) = map.next_key::<__FieldTag>()? {
3028                        #[allow(clippy::match_single_binding)]
3029                        match tag {
3030                            __FieldTag::__aggregated_route_metrics => {
3031                                if !fields.insert(__FieldTag::__aggregated_route_metrics) {
3032                                    return std::result::Result::Err(A::Error::duplicate_field(
3033                                        "multiple values for aggregated_route_metrics",
3034                                    ));
3035                                }
3036                                result.aggregated_route_metrics = map.next_value::<std::option::Option<crate::model::AggregatedMetrics>>()?
3037                                    ;
3038                            }
3039                            __FieldTag::__skipped_mandatory_shipment_count => {
3040                                if !fields.insert(__FieldTag::__skipped_mandatory_shipment_count) {
3041                                    return std::result::Result::Err(A::Error::duplicate_field(
3042                                        "multiple values for skipped_mandatory_shipment_count",
3043                                    ));
3044                                }
3045                                struct __With(std::option::Option<i32>);
3046                                impl<'de> serde::de::Deserialize<'de> for __With {
3047                                    fn deserialize<D>(
3048                                        deserializer: D,
3049                                    ) -> std::result::Result<Self, D::Error>
3050                                    where
3051                                        D: serde::de::Deserializer<'de>,
3052                                    {
3053                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
3054                                    }
3055                                }
3056                                result.skipped_mandatory_shipment_count =
3057                                    map.next_value::<__With>()?.0.unwrap_or_default();
3058                            }
3059                            __FieldTag::__used_vehicle_count => {
3060                                if !fields.insert(__FieldTag::__used_vehicle_count) {
3061                                    return std::result::Result::Err(A::Error::duplicate_field(
3062                                        "multiple values for used_vehicle_count",
3063                                    ));
3064                                }
3065                                struct __With(std::option::Option<i32>);
3066                                impl<'de> serde::de::Deserialize<'de> for __With {
3067                                    fn deserialize<D>(
3068                                        deserializer: D,
3069                                    ) -> std::result::Result<Self, D::Error>
3070                                    where
3071                                        D: serde::de::Deserializer<'de>,
3072                                    {
3073                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
3074                                    }
3075                                }
3076                                result.used_vehicle_count =
3077                                    map.next_value::<__With>()?.0.unwrap_or_default();
3078                            }
3079                            __FieldTag::__earliest_vehicle_start_time => {
3080                                if !fields.insert(__FieldTag::__earliest_vehicle_start_time) {
3081                                    return std::result::Result::Err(A::Error::duplicate_field(
3082                                        "multiple values for earliest_vehicle_start_time",
3083                                    ));
3084                                }
3085                                result.earliest_vehicle_start_time =
3086                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3087                            }
3088                            __FieldTag::__latest_vehicle_end_time => {
3089                                if !fields.insert(__FieldTag::__latest_vehicle_end_time) {
3090                                    return std::result::Result::Err(A::Error::duplicate_field(
3091                                        "multiple values for latest_vehicle_end_time",
3092                                    ));
3093                                }
3094                                result.latest_vehicle_end_time =
3095                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3096                            }
3097                            __FieldTag::__costs => {
3098                                if !fields.insert(__FieldTag::__costs) {
3099                                    return std::result::Result::Err(A::Error::duplicate_field(
3100                                        "multiple values for costs",
3101                                    ));
3102                                }
3103                                struct __With(
3104                                    std::option::Option<
3105                                        std::collections::HashMap<std::string::String, f64>,
3106                                    >,
3107                                );
3108                                impl<'de> serde::de::Deserialize<'de> for __With {
3109                                    fn deserialize<D>(
3110                                        deserializer: D,
3111                                    ) -> std::result::Result<Self, D::Error>
3112                                    where
3113                                        D: serde::de::Deserializer<'de>,
3114                                    {
3115                                        serde_with::As::<
3116                                            std::option::Option<
3117                                                std::collections::HashMap<
3118                                                    serde_with::Same,
3119                                                    wkt::internal::F64,
3120                                                >,
3121                                            >,
3122                                        >::deserialize(
3123                                            deserializer
3124                                        )
3125                                        .map(__With)
3126                                    }
3127                                }
3128                                result.costs = map.next_value::<__With>()?.0.unwrap_or_default();
3129                            }
3130                            __FieldTag::__total_cost => {
3131                                if !fields.insert(__FieldTag::__total_cost) {
3132                                    return std::result::Result::Err(A::Error::duplicate_field(
3133                                        "multiple values for total_cost",
3134                                    ));
3135                                }
3136                                struct __With(std::option::Option<f64>);
3137                                impl<'de> serde::de::Deserialize<'de> for __With {
3138                                    fn deserialize<D>(
3139                                        deserializer: D,
3140                                    ) -> std::result::Result<Self, D::Error>
3141                                    where
3142                                        D: serde::de::Deserializer<'de>,
3143                                    {
3144                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
3145                                    }
3146                                }
3147                                result.total_cost =
3148                                    map.next_value::<__With>()?.0.unwrap_or_default();
3149                            }
3150                            __FieldTag::Unknown(key) => {
3151                                let value = map.next_value::<serde_json::Value>()?;
3152                                result._unknown_fields.insert(key, value);
3153                            }
3154                        }
3155                    }
3156                    std::result::Result::Ok(result)
3157                }
3158            }
3159            deserializer.deserialize_any(Visitor)
3160        }
3161    }
3162
3163    #[doc(hidden)]
3164    impl serde::ser::Serialize for Metrics {
3165        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3166        where
3167            S: serde::ser::Serializer,
3168        {
3169            use serde::ser::SerializeMap;
3170            #[allow(unused_imports)]
3171            use std::option::Option::Some;
3172            let mut state = serializer.serialize_map(std::option::Option::None)?;
3173            if self.aggregated_route_metrics.is_some() {
3174                state.serialize_entry("aggregatedRouteMetrics", &self.aggregated_route_metrics)?;
3175            }
3176            if !wkt::internal::is_default(&self.skipped_mandatory_shipment_count) {
3177                struct __With<'a>(&'a i32);
3178                impl<'a> serde::ser::Serialize for __With<'a> {
3179                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3180                    where
3181                        S: serde::ser::Serializer,
3182                    {
3183                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3184                    }
3185                }
3186                state.serialize_entry(
3187                    "skippedMandatoryShipmentCount",
3188                    &__With(&self.skipped_mandatory_shipment_count),
3189                )?;
3190            }
3191            if !wkt::internal::is_default(&self.used_vehicle_count) {
3192                struct __With<'a>(&'a i32);
3193                impl<'a> serde::ser::Serialize for __With<'a> {
3194                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3195                    where
3196                        S: serde::ser::Serializer,
3197                    {
3198                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3199                    }
3200                }
3201                state.serialize_entry("usedVehicleCount", &__With(&self.used_vehicle_count))?;
3202            }
3203            if self.earliest_vehicle_start_time.is_some() {
3204                state.serialize_entry(
3205                    "earliestVehicleStartTime",
3206                    &self.earliest_vehicle_start_time,
3207                )?;
3208            }
3209            if self.latest_vehicle_end_time.is_some() {
3210                state.serialize_entry("latestVehicleEndTime", &self.latest_vehicle_end_time)?;
3211            }
3212            if !self.costs.is_empty() {
3213                struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
3214                impl<'a> serde::ser::Serialize for __With<'a> {
3215                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3216                    where
3217                        S: serde::ser::Serializer,
3218                    {
3219                        serde_with::As::<
3220                            std::collections::HashMap<serde_with::Same, wkt::internal::F64>,
3221                        >::serialize(self.0, serializer)
3222                    }
3223                }
3224                state.serialize_entry("costs", &__With(&self.costs))?;
3225            }
3226            if !wkt::internal::is_default(&self.total_cost) {
3227                struct __With<'a>(&'a f64);
3228                impl<'a> serde::ser::Serialize for __With<'a> {
3229                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3230                    where
3231                        S: serde::ser::Serializer,
3232                    {
3233                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
3234                    }
3235                }
3236                state.serialize_entry("totalCost", &__With(&self.total_cost))?;
3237            }
3238            if !self._unknown_fields.is_empty() {
3239                for (key, value) in self._unknown_fields.iter() {
3240                    state.serialize_entry(key, &value)?;
3241                }
3242            }
3243            state.end()
3244        }
3245    }
3246
3247    impl std::fmt::Debug for Metrics {
3248        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3249            let mut debug_struct = f.debug_struct("Metrics");
3250            debug_struct.field("aggregated_route_metrics", &self.aggregated_route_metrics);
3251            debug_struct.field(
3252                "skipped_mandatory_shipment_count",
3253                &self.skipped_mandatory_shipment_count,
3254            );
3255            debug_struct.field("used_vehicle_count", &self.used_vehicle_count);
3256            debug_struct.field(
3257                "earliest_vehicle_start_time",
3258                &self.earliest_vehicle_start_time,
3259            );
3260            debug_struct.field("latest_vehicle_end_time", &self.latest_vehicle_end_time);
3261            debug_struct.field("costs", &self.costs);
3262            debug_struct.field("total_cost", &self.total_cost);
3263            if !self._unknown_fields.is_empty() {
3264                debug_struct.field("_unknown_fields", &self._unknown_fields);
3265            }
3266            debug_struct.finish()
3267        }
3268    }
3269}
3270
3271/// Request to batch optimize tours as an asynchronous operation.
3272/// Each input file should contain one `OptimizeToursRequest`, and each output
3273/// file will contain one `OptimizeToursResponse`. The request contains
3274/// information to read/write and parse the files. All the input and output files
3275/// should be under the same project.
3276#[derive(Clone, Default, PartialEq)]
3277#[non_exhaustive]
3278pub struct BatchOptimizeToursRequest {
3279    /// Required. Target project and location to make a call.
3280    ///
3281    /// Format: `projects/{project-id}/locations/{location-id}`.
3282    ///
3283    /// If no location is specified, a region will be chosen automatically.
3284    pub parent: std::string::String,
3285
3286    /// Required. Input/Output information each purchase model, such as file paths
3287    /// and data formats.
3288    pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
3289
3290    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3291}
3292
3293impl BatchOptimizeToursRequest {
3294    pub fn new() -> Self {
3295        std::default::Default::default()
3296    }
3297
3298    /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
3299    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3300        self.parent = v.into();
3301        self
3302    }
3303
3304    /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
3305    pub fn set_model_configs<T, V>(mut self, v: T) -> Self
3306    where
3307        T: std::iter::IntoIterator<Item = V>,
3308        V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
3309    {
3310        use std::iter::Iterator;
3311        self.model_configs = v.into_iter().map(|i| i.into()).collect();
3312        self
3313    }
3314}
3315
3316impl wkt::message::Message for BatchOptimizeToursRequest {
3317    fn typename() -> &'static str {
3318        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
3319    }
3320}
3321
3322#[doc(hidden)]
3323impl<'de> serde::de::Deserialize<'de> for BatchOptimizeToursRequest {
3324    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3325    where
3326        D: serde::Deserializer<'de>,
3327    {
3328        #[allow(non_camel_case_types)]
3329        #[doc(hidden)]
3330        #[derive(PartialEq, Eq, Hash)]
3331        enum __FieldTag {
3332            __parent,
3333            __model_configs,
3334            Unknown(std::string::String),
3335        }
3336        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3337            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3338            where
3339                D: serde::Deserializer<'de>,
3340            {
3341                struct Visitor;
3342                impl<'de> serde::de::Visitor<'de> for Visitor {
3343                    type Value = __FieldTag;
3344                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3345                        formatter.write_str("a field name for BatchOptimizeToursRequest")
3346                    }
3347                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3348                    where
3349                        E: serde::de::Error,
3350                    {
3351                        use std::result::Result::Ok;
3352                        use std::string::ToString;
3353                        match value {
3354                            "parent" => Ok(__FieldTag::__parent),
3355                            "modelConfigs" => Ok(__FieldTag::__model_configs),
3356                            "model_configs" => Ok(__FieldTag::__model_configs),
3357                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3358                        }
3359                    }
3360                }
3361                deserializer.deserialize_identifier(Visitor)
3362            }
3363        }
3364        struct Visitor;
3365        impl<'de> serde::de::Visitor<'de> for Visitor {
3366            type Value = BatchOptimizeToursRequest;
3367            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3368                formatter.write_str("struct BatchOptimizeToursRequest")
3369            }
3370            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3371            where
3372                A: serde::de::MapAccess<'de>,
3373            {
3374                #[allow(unused_imports)]
3375                use serde::de::Error;
3376                use std::option::Option::Some;
3377                let mut fields = std::collections::HashSet::new();
3378                let mut result = Self::Value::new();
3379                while let Some(tag) = map.next_key::<__FieldTag>()? {
3380                    #[allow(clippy::match_single_binding)]
3381                    match tag {
3382                        __FieldTag::__parent => {
3383                            if !fields.insert(__FieldTag::__parent) {
3384                                return std::result::Result::Err(A::Error::duplicate_field(
3385                                    "multiple values for parent",
3386                                ));
3387                            }
3388                            result.parent = map
3389                                .next_value::<std::option::Option<std::string::String>>()?
3390                                .unwrap_or_default();
3391                        }
3392                        __FieldTag::__model_configs => {
3393                            if !fields.insert(__FieldTag::__model_configs) {
3394                                return std::result::Result::Err(A::Error::duplicate_field(
3395                                    "multiple values for model_configs",
3396                                ));
3397                            }
3398                            result.model_configs = map.next_value::<std::option::Option<std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>>>()?.unwrap_or_default();
3399                        }
3400                        __FieldTag::Unknown(key) => {
3401                            let value = map.next_value::<serde_json::Value>()?;
3402                            result._unknown_fields.insert(key, value);
3403                        }
3404                    }
3405                }
3406                std::result::Result::Ok(result)
3407            }
3408        }
3409        deserializer.deserialize_any(Visitor)
3410    }
3411}
3412
3413#[doc(hidden)]
3414impl serde::ser::Serialize for BatchOptimizeToursRequest {
3415    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3416    where
3417        S: serde::ser::Serializer,
3418    {
3419        use serde::ser::SerializeMap;
3420        #[allow(unused_imports)]
3421        use std::option::Option::Some;
3422        let mut state = serializer.serialize_map(std::option::Option::None)?;
3423        if !self.parent.is_empty() {
3424            state.serialize_entry("parent", &self.parent)?;
3425        }
3426        if !self.model_configs.is_empty() {
3427            state.serialize_entry("modelConfigs", &self.model_configs)?;
3428        }
3429        if !self._unknown_fields.is_empty() {
3430            for (key, value) in self._unknown_fields.iter() {
3431                state.serialize_entry(key, &value)?;
3432            }
3433        }
3434        state.end()
3435    }
3436}
3437
3438impl std::fmt::Debug for BatchOptimizeToursRequest {
3439    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3440        let mut debug_struct = f.debug_struct("BatchOptimizeToursRequest");
3441        debug_struct.field("parent", &self.parent);
3442        debug_struct.field("model_configs", &self.model_configs);
3443        if !self._unknown_fields.is_empty() {
3444            debug_struct.field("_unknown_fields", &self._unknown_fields);
3445        }
3446        debug_struct.finish()
3447    }
3448}
3449
3450/// Defines additional types related to [BatchOptimizeToursRequest].
3451pub mod batch_optimize_tours_request {
3452    #[allow(unused_imports)]
3453    use super::*;
3454
3455    /// Information for solving one optimization model asynchronously.
3456    #[derive(Clone, Default, PartialEq)]
3457    #[non_exhaustive]
3458    pub struct AsyncModelConfig {
3459        /// User defined model name, can be used as alias by users to keep track of
3460        /// models.
3461        pub display_name: std::string::String,
3462
3463        /// Required. Information about the input model.
3464        pub input_config: std::option::Option<crate::model::InputConfig>,
3465
3466        /// Required. The desired output location information.
3467        pub output_config: std::option::Option<crate::model::OutputConfig>,
3468
3469        /// If this is set, the model will be solved in the checkpoint mode. In this
3470        /// mode, the input model can have a deadline longer than 30 mins without the
3471        /// risk of interruption. The model will be solved in multiple short-running
3472        /// stages. Each stage generates an intermediate checkpoint
3473        /// and stores it in the user's Cloud Storage buckets. The checkpoint
3474        /// mode should be preferred over
3475        /// allow_large_deadline_despite_interruption_risk since it prevents the risk
3476        /// of interruption.
3477        pub enable_checkpoints: bool,
3478
3479        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3480    }
3481
3482    impl AsyncModelConfig {
3483        pub fn new() -> Self {
3484            std::default::Default::default()
3485        }
3486
3487        /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
3488        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
3489            mut self,
3490            v: T,
3491        ) -> Self {
3492            self.display_name = v.into();
3493            self
3494        }
3495
3496        /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
3497        pub fn set_input_config<T>(mut self, v: T) -> Self
3498        where
3499            T: std::convert::Into<crate::model::InputConfig>,
3500        {
3501            self.input_config = std::option::Option::Some(v.into());
3502            self
3503        }
3504
3505        /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
3506        pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
3507        where
3508            T: std::convert::Into<crate::model::InputConfig>,
3509        {
3510            self.input_config = v.map(|x| x.into());
3511            self
3512        }
3513
3514        /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
3515        pub fn set_output_config<T>(mut self, v: T) -> Self
3516        where
3517            T: std::convert::Into<crate::model::OutputConfig>,
3518        {
3519            self.output_config = std::option::Option::Some(v.into());
3520            self
3521        }
3522
3523        /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
3524        pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
3525        where
3526            T: std::convert::Into<crate::model::OutputConfig>,
3527        {
3528            self.output_config = v.map(|x| x.into());
3529            self
3530        }
3531
3532        /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
3533        pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3534            self.enable_checkpoints = v.into();
3535            self
3536        }
3537    }
3538
3539    impl wkt::message::Message for AsyncModelConfig {
3540        fn typename() -> &'static str {
3541            "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
3542        }
3543    }
3544
3545    #[doc(hidden)]
3546    impl<'de> serde::de::Deserialize<'de> for AsyncModelConfig {
3547        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3548        where
3549            D: serde::Deserializer<'de>,
3550        {
3551            #[allow(non_camel_case_types)]
3552            #[doc(hidden)]
3553            #[derive(PartialEq, Eq, Hash)]
3554            enum __FieldTag {
3555                __display_name,
3556                __input_config,
3557                __output_config,
3558                __enable_checkpoints,
3559                Unknown(std::string::String),
3560            }
3561            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3562                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3563                where
3564                    D: serde::Deserializer<'de>,
3565                {
3566                    struct Visitor;
3567                    impl<'de> serde::de::Visitor<'de> for Visitor {
3568                        type Value = __FieldTag;
3569                        fn expecting(
3570                            &self,
3571                            formatter: &mut std::fmt::Formatter,
3572                        ) -> std::fmt::Result {
3573                            formatter.write_str("a field name for AsyncModelConfig")
3574                        }
3575                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3576                        where
3577                            E: serde::de::Error,
3578                        {
3579                            use std::result::Result::Ok;
3580                            use std::string::ToString;
3581                            match value {
3582                                "displayName" => Ok(__FieldTag::__display_name),
3583                                "display_name" => Ok(__FieldTag::__display_name),
3584                                "inputConfig" => Ok(__FieldTag::__input_config),
3585                                "input_config" => Ok(__FieldTag::__input_config),
3586                                "outputConfig" => Ok(__FieldTag::__output_config),
3587                                "output_config" => Ok(__FieldTag::__output_config),
3588                                "enableCheckpoints" => Ok(__FieldTag::__enable_checkpoints),
3589                                "enable_checkpoints" => Ok(__FieldTag::__enable_checkpoints),
3590                                _ => Ok(__FieldTag::Unknown(value.to_string())),
3591                            }
3592                        }
3593                    }
3594                    deserializer.deserialize_identifier(Visitor)
3595                }
3596            }
3597            struct Visitor;
3598            impl<'de> serde::de::Visitor<'de> for Visitor {
3599                type Value = AsyncModelConfig;
3600                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3601                    formatter.write_str("struct AsyncModelConfig")
3602                }
3603                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3604                where
3605                    A: serde::de::MapAccess<'de>,
3606                {
3607                    #[allow(unused_imports)]
3608                    use serde::de::Error;
3609                    use std::option::Option::Some;
3610                    let mut fields = std::collections::HashSet::new();
3611                    let mut result = Self::Value::new();
3612                    while let Some(tag) = map.next_key::<__FieldTag>()? {
3613                        #[allow(clippy::match_single_binding)]
3614                        match tag {
3615                            __FieldTag::__display_name => {
3616                                if !fields.insert(__FieldTag::__display_name) {
3617                                    return std::result::Result::Err(A::Error::duplicate_field(
3618                                        "multiple values for display_name",
3619                                    ));
3620                                }
3621                                result.display_name = map
3622                                    .next_value::<std::option::Option<std::string::String>>()?
3623                                    .unwrap_or_default();
3624                            }
3625                            __FieldTag::__input_config => {
3626                                if !fields.insert(__FieldTag::__input_config) {
3627                                    return std::result::Result::Err(A::Error::duplicate_field(
3628                                        "multiple values for input_config",
3629                                    ));
3630                                }
3631                                result.input_config = map
3632                                    .next_value::<std::option::Option<crate::model::InputConfig>>(
3633                                    )?;
3634                            }
3635                            __FieldTag::__output_config => {
3636                                if !fields.insert(__FieldTag::__output_config) {
3637                                    return std::result::Result::Err(A::Error::duplicate_field(
3638                                        "multiple values for output_config",
3639                                    ));
3640                                }
3641                                result.output_config = map
3642                                    .next_value::<std::option::Option<crate::model::OutputConfig>>(
3643                                    )?;
3644                            }
3645                            __FieldTag::__enable_checkpoints => {
3646                                if !fields.insert(__FieldTag::__enable_checkpoints) {
3647                                    return std::result::Result::Err(A::Error::duplicate_field(
3648                                        "multiple values for enable_checkpoints",
3649                                    ));
3650                                }
3651                                result.enable_checkpoints = map
3652                                    .next_value::<std::option::Option<bool>>()?
3653                                    .unwrap_or_default();
3654                            }
3655                            __FieldTag::Unknown(key) => {
3656                                let value = map.next_value::<serde_json::Value>()?;
3657                                result._unknown_fields.insert(key, value);
3658                            }
3659                        }
3660                    }
3661                    std::result::Result::Ok(result)
3662                }
3663            }
3664            deserializer.deserialize_any(Visitor)
3665        }
3666    }
3667
3668    #[doc(hidden)]
3669    impl serde::ser::Serialize for AsyncModelConfig {
3670        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3671        where
3672            S: serde::ser::Serializer,
3673        {
3674            use serde::ser::SerializeMap;
3675            #[allow(unused_imports)]
3676            use std::option::Option::Some;
3677            let mut state = serializer.serialize_map(std::option::Option::None)?;
3678            if !self.display_name.is_empty() {
3679                state.serialize_entry("displayName", &self.display_name)?;
3680            }
3681            if self.input_config.is_some() {
3682                state.serialize_entry("inputConfig", &self.input_config)?;
3683            }
3684            if self.output_config.is_some() {
3685                state.serialize_entry("outputConfig", &self.output_config)?;
3686            }
3687            if !wkt::internal::is_default(&self.enable_checkpoints) {
3688                state.serialize_entry("enableCheckpoints", &self.enable_checkpoints)?;
3689            }
3690            if !self._unknown_fields.is_empty() {
3691                for (key, value) in self._unknown_fields.iter() {
3692                    state.serialize_entry(key, &value)?;
3693                }
3694            }
3695            state.end()
3696        }
3697    }
3698
3699    impl std::fmt::Debug for AsyncModelConfig {
3700        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3701            let mut debug_struct = f.debug_struct("AsyncModelConfig");
3702            debug_struct.field("display_name", &self.display_name);
3703            debug_struct.field("input_config", &self.input_config);
3704            debug_struct.field("output_config", &self.output_config);
3705            debug_struct.field("enable_checkpoints", &self.enable_checkpoints);
3706            if !self._unknown_fields.is_empty() {
3707                debug_struct.field("_unknown_fields", &self._unknown_fields);
3708            }
3709            debug_struct.finish()
3710        }
3711    }
3712}
3713
3714/// Response to a `BatchOptimizeToursRequest`. This is returned in
3715/// the LRO Operation after the operation is complete.
3716#[derive(Clone, Default, PartialEq)]
3717#[non_exhaustive]
3718pub struct BatchOptimizeToursResponse {
3719    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3720}
3721
3722impl BatchOptimizeToursResponse {
3723    pub fn new() -> Self {
3724        std::default::Default::default()
3725    }
3726}
3727
3728impl wkt::message::Message for BatchOptimizeToursResponse {
3729    fn typename() -> &'static str {
3730        "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
3731    }
3732}
3733
3734#[doc(hidden)]
3735impl<'de> serde::de::Deserialize<'de> for BatchOptimizeToursResponse {
3736    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3737    where
3738        D: serde::Deserializer<'de>,
3739    {
3740        #[allow(non_camel_case_types)]
3741        #[doc(hidden)]
3742        #[derive(PartialEq, Eq, Hash)]
3743        enum __FieldTag {
3744            Unknown(std::string::String),
3745        }
3746        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3747            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3748            where
3749                D: serde::Deserializer<'de>,
3750            {
3751                struct Visitor;
3752                impl<'de> serde::de::Visitor<'de> for Visitor {
3753                    type Value = __FieldTag;
3754                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3755                        formatter.write_str("a field name for BatchOptimizeToursResponse")
3756                    }
3757                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3758                    where
3759                        E: serde::de::Error,
3760                    {
3761                        use std::result::Result::Ok;
3762                        use std::string::ToString;
3763                        Ok(__FieldTag::Unknown(value.to_string()))
3764                    }
3765                }
3766                deserializer.deserialize_identifier(Visitor)
3767            }
3768        }
3769        struct Visitor;
3770        impl<'de> serde::de::Visitor<'de> for Visitor {
3771            type Value = BatchOptimizeToursResponse;
3772            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3773                formatter.write_str("struct BatchOptimizeToursResponse")
3774            }
3775            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3776            where
3777                A: serde::de::MapAccess<'de>,
3778            {
3779                #[allow(unused_imports)]
3780                use serde::de::Error;
3781                use std::option::Option::Some;
3782                let mut result = Self::Value::new();
3783                while let Some(tag) = map.next_key::<__FieldTag>()? {
3784                    #[allow(clippy::match_single_binding)]
3785                    match tag {
3786                        __FieldTag::Unknown(key) => {
3787                            let value = map.next_value::<serde_json::Value>()?;
3788                            result._unknown_fields.insert(key, value);
3789                        }
3790                    }
3791                }
3792                std::result::Result::Ok(result)
3793            }
3794        }
3795        deserializer.deserialize_any(Visitor)
3796    }
3797}
3798
3799#[doc(hidden)]
3800impl serde::ser::Serialize for BatchOptimizeToursResponse {
3801    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3802    where
3803        S: serde::ser::Serializer,
3804    {
3805        use serde::ser::SerializeMap;
3806        #[allow(unused_imports)]
3807        use std::option::Option::Some;
3808        let mut state = serializer.serialize_map(std::option::Option::None)?;
3809        if !self._unknown_fields.is_empty() {
3810            for (key, value) in self._unknown_fields.iter() {
3811                state.serialize_entry(key, &value)?;
3812            }
3813        }
3814        state.end()
3815    }
3816}
3817
3818impl std::fmt::Debug for BatchOptimizeToursResponse {
3819    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3820        let mut debug_struct = f.debug_struct("BatchOptimizeToursResponse");
3821        if !self._unknown_fields.is_empty() {
3822            debug_struct.field("_unknown_fields", &self._unknown_fields);
3823        }
3824        debug_struct.finish()
3825    }
3826}
3827
3828/// A shipment model contains a set of shipments which must be performed by a
3829/// set of vehicles, while minimizing the overall cost, which is the sum of:
3830///
3831/// * the cost of routing the vehicles (sum of cost per total time, cost per
3832///   travel time, and fixed cost over all vehicles).
3833/// * the unperformed shipment penalties.
3834/// * the cost of the global duration of the shipments
3835#[derive(Clone, Default, PartialEq)]
3836#[non_exhaustive]
3837pub struct ShipmentModel {
3838    /// Set of shipments which must be performed in the model.
3839    pub shipments: std::vec::Vec<crate::model::Shipment>,
3840
3841    /// Set of vehicles which can be used to perform visits.
3842    pub vehicles: std::vec::Vec<crate::model::Vehicle>,
3843
3844    /// Constrains the maximum number of active vehicles. A vehicle is active if
3845    /// its route performs at least one shipment. This can be used to limit the
3846    /// number of routes in the case where there are fewer drivers than
3847    /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
3848    /// will then select the best subset of vehicles to use.
3849    /// Must be strictly positive.
3850    pub max_active_vehicles: std::option::Option<i32>,
3851
3852    /// Global start and end time of the model: no times outside of this range
3853    /// can be considered valid.
3854    ///
3855    /// The model's time span must be less than a year, i.e. the `global_end_time`
3856    /// and the `global_start_time` must be within 31536000 seconds of each other.
3857    ///
3858    /// When using `cost_per_*hour` fields, you might want to set this window to a
3859    /// smaller interval to increase performance (eg. if you model a single day,
3860    /// you should set the global time limits to that day).
3861    /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
3862    /// as default.
3863    pub global_start_time: std::option::Option<wkt::Timestamp>,
3864
3865    /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
3866    /// is used as default.
3867    pub global_end_time: std::option::Option<wkt::Timestamp>,
3868
3869    /// The "global duration" of the overall plan is the difference between the
3870    /// earliest effective start time and the latest effective end time of
3871    /// all vehicles. Users can assign a cost per hour to that quantity to try
3872    /// and optimize for earliest job completion, for example. This cost must be in
3873    /// the same unit as
3874    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
3875    ///
3876    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
3877    pub global_duration_cost_per_hour: f64,
3878
3879    /// Specifies duration and distance matrices used in the model. If this field
3880    /// is empty, Google Maps or geodesic distances will be used instead, depending
3881    /// on the value of the `use_geodesic_distances` field. If it is not empty,
3882    /// `use_geodesic_distances` cannot be true and neither
3883    /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
3884    /// can be empty.
3885    ///
3886    /// Usage examples:
3887    ///
3888    /// * There are two locations: locA and locB.
3889    /// * 1 vehicle starting its route at locA and ending it at locA.
3890    /// * 1 pickup visit request at locB.
3891    ///
3892    /// ```norust
3893    /// model {
3894    ///   vehicles { start_tags: "locA"  end_tags: "locA" }
3895    ///   shipments { pickups { tags: "locB" } }
3896    ///   duration_distance_matrix_src_tags: "locA"
3897    ///   duration_distance_matrix_src_tags: "locB"
3898    ///   duration_distance_matrix_dst_tags: "locA"
3899    ///   duration_distance_matrix_dst_tags: "locB"
3900    ///   duration_distance_matrices {
3901    ///     rows {  # from: locA
3902    ///       durations { seconds: 0 }   meters: 0    # to: locA
3903    ///       durations { seconds: 100 } meters: 1000 # to: locB
3904    ///     }
3905    ///     rows {  # from: locB
3906    ///       durations { seconds: 102 } meters: 990 # to: locA
3907    ///       durations { seconds: 0 }   meters: 0   # to: locB
3908    ///     }
3909    ///   }
3910    /// }
3911    /// ```
3912    ///
3913    /// * There are three locations: locA, locB and locC.
3914    /// * 1 vehicle starting its route at locA and ending it at locB, using
3915    ///   matrix "fast".
3916    /// * 1 vehicle starting its route at locB and ending it at locB, using
3917    ///   matrix "slow".
3918    /// * 1 vehicle starting its route at locB and ending it at locB, using
3919    ///   matrix "fast".
3920    /// * 1 pickup visit request at locC.
3921    ///
3922    /// ```norust
3923    /// model {
3924    ///   vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
3925    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
3926    ///   vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
3927    ///   shipments { pickups { tags: "locC" } }
3928    ///   duration_distance_matrix_src_tags: "locA"
3929    ///   duration_distance_matrix_src_tags: "locB"
3930    ///   duration_distance_matrix_src_tags: "locC"
3931    ///   duration_distance_matrix_dst_tags: "locB"
3932    ///   duration_distance_matrix_dst_tags: "locC"
3933    ///   duration_distance_matrices {
3934    ///     vehicle_start_tag: "fast"
3935    ///     rows {  # from: locA
3936    ///       durations { seconds: 1000 } meters: 2000 # to: locB
3937    ///       durations { seconds: 600 }  meters: 1000 # to: locC
3938    ///     }
3939    ///     rows {  # from: locB
3940    ///       durations { seconds: 0 }   meters: 0    # to: locB
3941    ///       durations { seconds: 700 } meters: 1200 # to: locC
3942    ///     }
3943    ///     rows {  # from: locC
3944    ///       durations { seconds: 702 } meters: 1190 # to: locB
3945    ///       durations { seconds: 0 }   meters: 0    # to: locC
3946    ///     }
3947    ///   }
3948    ///   duration_distance_matrices {
3949    ///     vehicle_start_tag: "slow"
3950    ///     rows {  # from: locA
3951    ///       durations { seconds: 1800 } meters: 2001 # to: locB
3952    ///       durations { seconds: 900 }  meters: 1002 # to: locC
3953    ///     }
3954    ///     rows {  # from: locB
3955    ///       durations { seconds: 0 }    meters: 0    # to: locB
3956    ///       durations { seconds: 1000 } meters: 1202 # to: locC
3957    ///     }
3958    ///     rows {  # from: locC
3959    ///       durations { seconds: 1001 } meters: 1195 # to: locB
3960    ///       durations { seconds: 0 }    meters: 0    # to: locC
3961    ///     }
3962    ///   }
3963    /// }
3964    /// ```
3965    pub duration_distance_matrices:
3966        std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
3967
3968    /// Tags defining the sources of the duration and distance matrices;
3969    /// `duration_distance_matrices(i).rows(j)` defines durations and distances
3970    /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
3971    /// in matrix i.
3972    ///
3973    /// Tags correspond to
3974    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
3975    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
3976    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
3977    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
3978    /// the same; similarly a `VisitRequest`'s source and destination tags may be
3979    /// the same. All tags must be different and cannot be empty strings. If this
3980    /// field is not empty, then `duration_distance_matrices` must not be empty.
3981    ///
3982    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
3983    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
3984    pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
3985
3986    /// Tags defining the destinations of the duration and distance matrices;
3987    /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
3988    /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
3989    /// (resp. the distance) of the travel from visits with tag
3990    /// `duration_distance_matrix_src_tags(j)` to visits with tag
3991    /// `duration_distance_matrix_dst_tags(k)` in matrix i.
3992    ///
3993    /// Tags correspond to
3994    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
3995    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
3996    /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
3997    /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
3998    /// the same; similarly a `VisitRequest`'s source and destination tags may be
3999    /// the same. All tags must be different and cannot be empty strings. If this
4000    /// field is not empty, then `duration_distance_matrices` must not be empty.
4001    ///
4002    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
4003    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
4004    pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
4005
4006    /// Transition attributes added to the model.
4007    pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
4008
4009    /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
4010    pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
4011
4012    /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
4013    pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
4014
4015    /// Set of precedence rules which must be enforced in the model.
4016    pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
4017
4018    /// Deprecated: No longer used.
4019    /// Set of break rules used in the model.
4020    /// Each vehicle specifies the `BreakRule` that applies to it via the
4021    /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
4022    /// field (which must be a singleton).
4023    ///
4024    /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
4025    #[deprecated]
4026    pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
4027
4028    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4029}
4030
4031impl ShipmentModel {
4032    pub fn new() -> Self {
4033        std::default::Default::default()
4034    }
4035
4036    /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
4037    pub fn set_shipments<T, V>(mut self, v: T) -> Self
4038    where
4039        T: std::iter::IntoIterator<Item = V>,
4040        V: std::convert::Into<crate::model::Shipment>,
4041    {
4042        use std::iter::Iterator;
4043        self.shipments = v.into_iter().map(|i| i.into()).collect();
4044        self
4045    }
4046
4047    /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
4048    pub fn set_vehicles<T, V>(mut self, v: T) -> Self
4049    where
4050        T: std::iter::IntoIterator<Item = V>,
4051        V: std::convert::Into<crate::model::Vehicle>,
4052    {
4053        use std::iter::Iterator;
4054        self.vehicles = v.into_iter().map(|i| i.into()).collect();
4055        self
4056    }
4057
4058    /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
4059    pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
4060    where
4061        T: std::convert::Into<i32>,
4062    {
4063        self.max_active_vehicles = std::option::Option::Some(v.into());
4064        self
4065    }
4066
4067    /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
4068    pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
4069    where
4070        T: std::convert::Into<i32>,
4071    {
4072        self.max_active_vehicles = v.map(|x| x.into());
4073        self
4074    }
4075
4076    /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
4077    pub fn set_global_start_time<T>(mut self, v: T) -> Self
4078    where
4079        T: std::convert::Into<wkt::Timestamp>,
4080    {
4081        self.global_start_time = std::option::Option::Some(v.into());
4082        self
4083    }
4084
4085    /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
4086    pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
4087    where
4088        T: std::convert::Into<wkt::Timestamp>,
4089    {
4090        self.global_start_time = v.map(|x| x.into());
4091        self
4092    }
4093
4094    /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
4095    pub fn set_global_end_time<T>(mut self, v: T) -> Self
4096    where
4097        T: std::convert::Into<wkt::Timestamp>,
4098    {
4099        self.global_end_time = std::option::Option::Some(v.into());
4100        self
4101    }
4102
4103    /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
4104    pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
4105    where
4106        T: std::convert::Into<wkt::Timestamp>,
4107    {
4108        self.global_end_time = v.map(|x| x.into());
4109        self
4110    }
4111
4112    /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
4113    pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4114        self.global_duration_cost_per_hour = v.into();
4115        self
4116    }
4117
4118    /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
4119    pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
4120    where
4121        T: std::iter::IntoIterator<Item = V>,
4122        V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
4123    {
4124        use std::iter::Iterator;
4125        self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
4126        self
4127    }
4128
4129    /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
4130    pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
4131    where
4132        T: std::iter::IntoIterator<Item = V>,
4133        V: std::convert::Into<std::string::String>,
4134    {
4135        use std::iter::Iterator;
4136        self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
4137        self
4138    }
4139
4140    /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
4141    pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
4142    where
4143        T: std::iter::IntoIterator<Item = V>,
4144        V: std::convert::Into<std::string::String>,
4145    {
4146        use std::iter::Iterator;
4147        self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
4148        self
4149    }
4150
4151    /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
4152    pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
4153    where
4154        T: std::iter::IntoIterator<Item = V>,
4155        V: std::convert::Into<crate::model::TransitionAttributes>,
4156    {
4157        use std::iter::Iterator;
4158        self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
4159        self
4160    }
4161
4162    /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
4163    pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
4164    where
4165        T: std::iter::IntoIterator<Item = V>,
4166        V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
4167    {
4168        use std::iter::Iterator;
4169        self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
4170        self
4171    }
4172
4173    /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
4174    pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
4175    where
4176        T: std::iter::IntoIterator<Item = V>,
4177        V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
4178    {
4179        use std::iter::Iterator;
4180        self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
4181        self
4182    }
4183
4184    /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
4185    pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
4186    where
4187        T: std::iter::IntoIterator<Item = V>,
4188        V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
4189    {
4190        use std::iter::Iterator;
4191        self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
4192        self
4193    }
4194
4195    /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
4196    #[deprecated]
4197    pub fn set_break_rules<T, V>(mut self, v: T) -> Self
4198    where
4199        T: std::iter::IntoIterator<Item = V>,
4200        V: std::convert::Into<crate::model::shipment_model::BreakRule>,
4201    {
4202        use std::iter::Iterator;
4203        self.break_rules = v.into_iter().map(|i| i.into()).collect();
4204        self
4205    }
4206}
4207
4208impl wkt::message::Message for ShipmentModel {
4209    fn typename() -> &'static str {
4210        "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
4211    }
4212}
4213
4214#[doc(hidden)]
4215impl<'de> serde::de::Deserialize<'de> for ShipmentModel {
4216    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4217    where
4218        D: serde::Deserializer<'de>,
4219    {
4220        #[allow(non_camel_case_types)]
4221        #[doc(hidden)]
4222        #[derive(PartialEq, Eq, Hash)]
4223        enum __FieldTag {
4224            __shipments,
4225            __vehicles,
4226            __max_active_vehicles,
4227            __global_start_time,
4228            __global_end_time,
4229            __global_duration_cost_per_hour,
4230            __duration_distance_matrices,
4231            __duration_distance_matrix_src_tags,
4232            __duration_distance_matrix_dst_tags,
4233            __transition_attributes,
4234            __shipment_type_incompatibilities,
4235            __shipment_type_requirements,
4236            __precedence_rules,
4237            __break_rules,
4238            Unknown(std::string::String),
4239        }
4240        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4241            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4242            where
4243                D: serde::Deserializer<'de>,
4244            {
4245                struct Visitor;
4246                impl<'de> serde::de::Visitor<'de> for Visitor {
4247                    type Value = __FieldTag;
4248                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4249                        formatter.write_str("a field name for ShipmentModel")
4250                    }
4251                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4252                    where
4253                        E: serde::de::Error,
4254                    {
4255                        use std::result::Result::Ok;
4256                        use std::string::ToString;
4257                        match value {
4258                            "shipments" => Ok(__FieldTag::__shipments),
4259                            "vehicles" => Ok(__FieldTag::__vehicles),
4260                            "maxActiveVehicles" => Ok(__FieldTag::__max_active_vehicles),
4261                            "max_active_vehicles" => Ok(__FieldTag::__max_active_vehicles),
4262                            "globalStartTime" => Ok(__FieldTag::__global_start_time),
4263                            "global_start_time" => Ok(__FieldTag::__global_start_time),
4264                            "globalEndTime" => Ok(__FieldTag::__global_end_time),
4265                            "global_end_time" => Ok(__FieldTag::__global_end_time),
4266                            "globalDurationCostPerHour" => {
4267                                Ok(__FieldTag::__global_duration_cost_per_hour)
4268                            }
4269                            "global_duration_cost_per_hour" => {
4270                                Ok(__FieldTag::__global_duration_cost_per_hour)
4271                            }
4272                            "durationDistanceMatrices" => {
4273                                Ok(__FieldTag::__duration_distance_matrices)
4274                            }
4275                            "duration_distance_matrices" => {
4276                                Ok(__FieldTag::__duration_distance_matrices)
4277                            }
4278                            "durationDistanceMatrixSrcTags" => {
4279                                Ok(__FieldTag::__duration_distance_matrix_src_tags)
4280                            }
4281                            "duration_distance_matrix_src_tags" => {
4282                                Ok(__FieldTag::__duration_distance_matrix_src_tags)
4283                            }
4284                            "durationDistanceMatrixDstTags" => {
4285                                Ok(__FieldTag::__duration_distance_matrix_dst_tags)
4286                            }
4287                            "duration_distance_matrix_dst_tags" => {
4288                                Ok(__FieldTag::__duration_distance_matrix_dst_tags)
4289                            }
4290                            "transitionAttributes" => Ok(__FieldTag::__transition_attributes),
4291                            "transition_attributes" => Ok(__FieldTag::__transition_attributes),
4292                            "shipmentTypeIncompatibilities" => {
4293                                Ok(__FieldTag::__shipment_type_incompatibilities)
4294                            }
4295                            "shipment_type_incompatibilities" => {
4296                                Ok(__FieldTag::__shipment_type_incompatibilities)
4297                            }
4298                            "shipmentTypeRequirements" => {
4299                                Ok(__FieldTag::__shipment_type_requirements)
4300                            }
4301                            "shipment_type_requirements" => {
4302                                Ok(__FieldTag::__shipment_type_requirements)
4303                            }
4304                            "precedenceRules" => Ok(__FieldTag::__precedence_rules),
4305                            "precedence_rules" => Ok(__FieldTag::__precedence_rules),
4306                            "breakRules" => Ok(__FieldTag::__break_rules),
4307                            "break_rules" => Ok(__FieldTag::__break_rules),
4308                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4309                        }
4310                    }
4311                }
4312                deserializer.deserialize_identifier(Visitor)
4313            }
4314        }
4315        struct Visitor;
4316        impl<'de> serde::de::Visitor<'de> for Visitor {
4317            type Value = ShipmentModel;
4318            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4319                formatter.write_str("struct ShipmentModel")
4320            }
4321            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4322            where
4323                A: serde::de::MapAccess<'de>,
4324            {
4325                #[allow(unused_imports)]
4326                use serde::de::Error;
4327                use std::option::Option::Some;
4328                let mut fields = std::collections::HashSet::new();
4329                let mut result = Self::Value::new();
4330                while let Some(tag) = map.next_key::<__FieldTag>()? {
4331                    #[allow(clippy::match_single_binding)]
4332                    match tag {
4333                        __FieldTag::__shipments => {
4334                            if !fields.insert(__FieldTag::__shipments) {
4335                                return std::result::Result::Err(A::Error::duplicate_field(
4336                                    "multiple values for shipments",
4337                                ));
4338                            }
4339                            result.shipments = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Shipment>>>()?.unwrap_or_default();
4340                        }
4341                        __FieldTag::__vehicles => {
4342                            if !fields.insert(__FieldTag::__vehicles) {
4343                                return std::result::Result::Err(A::Error::duplicate_field(
4344                                    "multiple values for vehicles",
4345                                ));
4346                            }
4347                            result.vehicles = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Vehicle>>>()?.unwrap_or_default();
4348                        }
4349                        __FieldTag::__max_active_vehicles => {
4350                            if !fields.insert(__FieldTag::__max_active_vehicles) {
4351                                return std::result::Result::Err(A::Error::duplicate_field(
4352                                    "multiple values for max_active_vehicles",
4353                                ));
4354                            }
4355                            struct __With(std::option::Option<i32>);
4356                            impl<'de> serde::de::Deserialize<'de> for __With {
4357                                fn deserialize<D>(
4358                                    deserializer: D,
4359                                ) -> std::result::Result<Self, D::Error>
4360                                where
4361                                    D: serde::de::Deserializer<'de>,
4362                                {
4363                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
4364                                }
4365                            }
4366                            result.max_active_vehicles = map.next_value::<__With>()?.0;
4367                        }
4368                        __FieldTag::__global_start_time => {
4369                            if !fields.insert(__FieldTag::__global_start_time) {
4370                                return std::result::Result::Err(A::Error::duplicate_field(
4371                                    "multiple values for global_start_time",
4372                                ));
4373                            }
4374                            result.global_start_time =
4375                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4376                        }
4377                        __FieldTag::__global_end_time => {
4378                            if !fields.insert(__FieldTag::__global_end_time) {
4379                                return std::result::Result::Err(A::Error::duplicate_field(
4380                                    "multiple values for global_end_time",
4381                                ));
4382                            }
4383                            result.global_end_time =
4384                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4385                        }
4386                        __FieldTag::__global_duration_cost_per_hour => {
4387                            if !fields.insert(__FieldTag::__global_duration_cost_per_hour) {
4388                                return std::result::Result::Err(A::Error::duplicate_field(
4389                                    "multiple values for global_duration_cost_per_hour",
4390                                ));
4391                            }
4392                            struct __With(std::option::Option<f64>);
4393                            impl<'de> serde::de::Deserialize<'de> for __With {
4394                                fn deserialize<D>(
4395                                    deserializer: D,
4396                                ) -> std::result::Result<Self, D::Error>
4397                                where
4398                                    D: serde::de::Deserializer<'de>,
4399                                {
4400                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
4401                                }
4402                            }
4403                            result.global_duration_cost_per_hour =
4404                                map.next_value::<__With>()?.0.unwrap_or_default();
4405                        }
4406                        __FieldTag::__duration_distance_matrices => {
4407                            if !fields.insert(__FieldTag::__duration_distance_matrices) {
4408                                return std::result::Result::Err(A::Error::duplicate_field(
4409                                    "multiple values for duration_distance_matrices",
4410                                ));
4411                            }
4412                            result.duration_distance_matrices = map
4413                                .next_value::<std::option::Option<
4414                                    std::vec::Vec<
4415                                        crate::model::shipment_model::DurationDistanceMatrix,
4416                                    >,
4417                                >>()?
4418                                .unwrap_or_default();
4419                        }
4420                        __FieldTag::__duration_distance_matrix_src_tags => {
4421                            if !fields.insert(__FieldTag::__duration_distance_matrix_src_tags) {
4422                                return std::result::Result::Err(A::Error::duplicate_field(
4423                                    "multiple values for duration_distance_matrix_src_tags",
4424                                ));
4425                            }
4426                            result.duration_distance_matrix_src_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
4427                        }
4428                        __FieldTag::__duration_distance_matrix_dst_tags => {
4429                            if !fields.insert(__FieldTag::__duration_distance_matrix_dst_tags) {
4430                                return std::result::Result::Err(A::Error::duplicate_field(
4431                                    "multiple values for duration_distance_matrix_dst_tags",
4432                                ));
4433                            }
4434                            result.duration_distance_matrix_dst_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
4435                        }
4436                        __FieldTag::__transition_attributes => {
4437                            if !fields.insert(__FieldTag::__transition_attributes) {
4438                                return std::result::Result::Err(A::Error::duplicate_field(
4439                                    "multiple values for transition_attributes",
4440                                ));
4441                            }
4442                            result.transition_attributes = map
4443                                .next_value::<std::option::Option<
4444                                    std::vec::Vec<crate::model::TransitionAttributes>,
4445                                >>()?
4446                                .unwrap_or_default();
4447                        }
4448                        __FieldTag::__shipment_type_incompatibilities => {
4449                            if !fields.insert(__FieldTag::__shipment_type_incompatibilities) {
4450                                return std::result::Result::Err(A::Error::duplicate_field(
4451                                    "multiple values for shipment_type_incompatibilities",
4452                                ));
4453                            }
4454                            result.shipment_type_incompatibilities = map
4455                                .next_value::<std::option::Option<
4456                                    std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
4457                                >>()?
4458                                .unwrap_or_default();
4459                        }
4460                        __FieldTag::__shipment_type_requirements => {
4461                            if !fields.insert(__FieldTag::__shipment_type_requirements) {
4462                                return std::result::Result::Err(A::Error::duplicate_field(
4463                                    "multiple values for shipment_type_requirements",
4464                                ));
4465                            }
4466                            result.shipment_type_requirements = map
4467                                .next_value::<std::option::Option<
4468                                    std::vec::Vec<crate::model::ShipmentTypeRequirement>,
4469                                >>()?
4470                                .unwrap_or_default();
4471                        }
4472                        __FieldTag::__precedence_rules => {
4473                            if !fields.insert(__FieldTag::__precedence_rules) {
4474                                return std::result::Result::Err(A::Error::duplicate_field(
4475                                    "multiple values for precedence_rules",
4476                                ));
4477                            }
4478                            result.precedence_rules = map
4479                                .next_value::<std::option::Option<
4480                                    std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
4481                                >>()?
4482                                .unwrap_or_default();
4483                        }
4484                        __FieldTag::__break_rules => {
4485                            if !fields.insert(__FieldTag::__break_rules) {
4486                                return std::result::Result::Err(A::Error::duplicate_field(
4487                                    "multiple values for break_rules",
4488                                ));
4489                            }
4490                            result.break_rules = map
4491                                .next_value::<std::option::Option<
4492                                    std::vec::Vec<crate::model::shipment_model::BreakRule>,
4493                                >>()?
4494                                .unwrap_or_default();
4495                        }
4496                        __FieldTag::Unknown(key) => {
4497                            let value = map.next_value::<serde_json::Value>()?;
4498                            result._unknown_fields.insert(key, value);
4499                        }
4500                    }
4501                }
4502                std::result::Result::Ok(result)
4503            }
4504        }
4505        deserializer.deserialize_any(Visitor)
4506    }
4507}
4508
4509#[doc(hidden)]
4510impl serde::ser::Serialize for ShipmentModel {
4511    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4512    where
4513        S: serde::ser::Serializer,
4514    {
4515        use serde::ser::SerializeMap;
4516        #[allow(unused_imports)]
4517        use std::option::Option::Some;
4518        let mut state = serializer.serialize_map(std::option::Option::None)?;
4519        if !self.shipments.is_empty() {
4520            state.serialize_entry("shipments", &self.shipments)?;
4521        }
4522        if !self.vehicles.is_empty() {
4523            state.serialize_entry("vehicles", &self.vehicles)?;
4524        }
4525        if self.max_active_vehicles.is_some() {
4526            struct __With<'a>(&'a std::option::Option<i32>);
4527            impl<'a> serde::ser::Serialize for __With<'a> {
4528                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4529                where
4530                    S: serde::ser::Serializer,
4531                {
4532                    serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
4533                        self.0, serializer,
4534                    )
4535                }
4536            }
4537            state.serialize_entry("maxActiveVehicles", &__With(&self.max_active_vehicles))?;
4538        }
4539        if self.global_start_time.is_some() {
4540            state.serialize_entry("globalStartTime", &self.global_start_time)?;
4541        }
4542        if self.global_end_time.is_some() {
4543            state.serialize_entry("globalEndTime", &self.global_end_time)?;
4544        }
4545        if !wkt::internal::is_default(&self.global_duration_cost_per_hour) {
4546            struct __With<'a>(&'a f64);
4547            impl<'a> serde::ser::Serialize for __With<'a> {
4548                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4549                where
4550                    S: serde::ser::Serializer,
4551                {
4552                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
4553                }
4554            }
4555            state.serialize_entry(
4556                "globalDurationCostPerHour",
4557                &__With(&self.global_duration_cost_per_hour),
4558            )?;
4559        }
4560        if !self.duration_distance_matrices.is_empty() {
4561            state.serialize_entry("durationDistanceMatrices", &self.duration_distance_matrices)?;
4562        }
4563        if !self.duration_distance_matrix_src_tags.is_empty() {
4564            state.serialize_entry(
4565                "durationDistanceMatrixSrcTags",
4566                &self.duration_distance_matrix_src_tags,
4567            )?;
4568        }
4569        if !self.duration_distance_matrix_dst_tags.is_empty() {
4570            state.serialize_entry(
4571                "durationDistanceMatrixDstTags",
4572                &self.duration_distance_matrix_dst_tags,
4573            )?;
4574        }
4575        if !self.transition_attributes.is_empty() {
4576            state.serialize_entry("transitionAttributes", &self.transition_attributes)?;
4577        }
4578        if !self.shipment_type_incompatibilities.is_empty() {
4579            state.serialize_entry(
4580                "shipmentTypeIncompatibilities",
4581                &self.shipment_type_incompatibilities,
4582            )?;
4583        }
4584        if !self.shipment_type_requirements.is_empty() {
4585            state.serialize_entry("shipmentTypeRequirements", &self.shipment_type_requirements)?;
4586        }
4587        if !self.precedence_rules.is_empty() {
4588            state.serialize_entry("precedenceRules", &self.precedence_rules)?;
4589        }
4590        if !self.break_rules.is_empty() {
4591            state.serialize_entry("breakRules", &self.break_rules)?;
4592        }
4593        if !self._unknown_fields.is_empty() {
4594            for (key, value) in self._unknown_fields.iter() {
4595                state.serialize_entry(key, &value)?;
4596            }
4597        }
4598        state.end()
4599    }
4600}
4601
4602impl std::fmt::Debug for ShipmentModel {
4603    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4604        let mut debug_struct = f.debug_struct("ShipmentModel");
4605        debug_struct.field("shipments", &self.shipments);
4606        debug_struct.field("vehicles", &self.vehicles);
4607        debug_struct.field("max_active_vehicles", &self.max_active_vehicles);
4608        debug_struct.field("global_start_time", &self.global_start_time);
4609        debug_struct.field("global_end_time", &self.global_end_time);
4610        debug_struct.field(
4611            "global_duration_cost_per_hour",
4612            &self.global_duration_cost_per_hour,
4613        );
4614        debug_struct.field(
4615            "duration_distance_matrices",
4616            &self.duration_distance_matrices,
4617        );
4618        debug_struct.field(
4619            "duration_distance_matrix_src_tags",
4620            &self.duration_distance_matrix_src_tags,
4621        );
4622        debug_struct.field(
4623            "duration_distance_matrix_dst_tags",
4624            &self.duration_distance_matrix_dst_tags,
4625        );
4626        debug_struct.field("transition_attributes", &self.transition_attributes);
4627        debug_struct.field(
4628            "shipment_type_incompatibilities",
4629            &self.shipment_type_incompatibilities,
4630        );
4631        debug_struct.field(
4632            "shipment_type_requirements",
4633            &self.shipment_type_requirements,
4634        );
4635        debug_struct.field("precedence_rules", &self.precedence_rules);
4636        debug_struct.field("break_rules", &self.break_rules);
4637        if !self._unknown_fields.is_empty() {
4638            debug_struct.field("_unknown_fields", &self._unknown_fields);
4639        }
4640        debug_struct.finish()
4641    }
4642}
4643
4644/// Defines additional types related to [ShipmentModel].
4645pub mod shipment_model {
4646    #[allow(unused_imports)]
4647    use super::*;
4648
4649    /// Specifies a duration and distance matrix from visit and vehicle start
4650    /// locations to visit and vehicle end locations.
4651    #[derive(Clone, Default, PartialEq)]
4652    #[non_exhaustive]
4653    pub struct DurationDistanceMatrix {
4654        /// Specifies the rows of the duration and distance matrix. It must have as
4655        /// many elements as
4656        /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
4657        ///
4658        /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
4659        pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
4660
4661        /// Tag defining to which vehicles this duration and distance matrix applies.
4662        /// If empty, this applies to all vehicles, and there can only be a single
4663        /// matrix.
4664        ///
4665        /// Each vehicle start must match exactly one matrix, i.e. exactly one of
4666        /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
4667        /// (and of that matrix only).
4668        ///
4669        /// All matrices must have a different `vehicle_start_tag`.
4670        pub vehicle_start_tag: std::string::String,
4671
4672        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4673    }
4674
4675    impl DurationDistanceMatrix {
4676        pub fn new() -> Self {
4677            std::default::Default::default()
4678        }
4679
4680        /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
4681        pub fn set_rows<T, V>(mut self, v: T) -> Self
4682        where
4683            T: std::iter::IntoIterator<Item = V>,
4684            V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
4685        {
4686            use std::iter::Iterator;
4687            self.rows = v.into_iter().map(|i| i.into()).collect();
4688            self
4689        }
4690
4691        /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
4692        pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
4693            mut self,
4694            v: T,
4695        ) -> Self {
4696            self.vehicle_start_tag = v.into();
4697            self
4698        }
4699    }
4700
4701    impl wkt::message::Message for DurationDistanceMatrix {
4702        fn typename() -> &'static str {
4703            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
4704        }
4705    }
4706
4707    #[doc(hidden)]
4708    impl<'de> serde::de::Deserialize<'de> for DurationDistanceMatrix {
4709        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4710        where
4711            D: serde::Deserializer<'de>,
4712        {
4713            #[allow(non_camel_case_types)]
4714            #[doc(hidden)]
4715            #[derive(PartialEq, Eq, Hash)]
4716            enum __FieldTag {
4717                __rows,
4718                __vehicle_start_tag,
4719                Unknown(std::string::String),
4720            }
4721            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4722                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4723                where
4724                    D: serde::Deserializer<'de>,
4725                {
4726                    struct Visitor;
4727                    impl<'de> serde::de::Visitor<'de> for Visitor {
4728                        type Value = __FieldTag;
4729                        fn expecting(
4730                            &self,
4731                            formatter: &mut std::fmt::Formatter,
4732                        ) -> std::fmt::Result {
4733                            formatter.write_str("a field name for DurationDistanceMatrix")
4734                        }
4735                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4736                        where
4737                            E: serde::de::Error,
4738                        {
4739                            use std::result::Result::Ok;
4740                            use std::string::ToString;
4741                            match value {
4742                                "rows" => Ok(__FieldTag::__rows),
4743                                "vehicleStartTag" => Ok(__FieldTag::__vehicle_start_tag),
4744                                "vehicle_start_tag" => Ok(__FieldTag::__vehicle_start_tag),
4745                                _ => Ok(__FieldTag::Unknown(value.to_string())),
4746                            }
4747                        }
4748                    }
4749                    deserializer.deserialize_identifier(Visitor)
4750                }
4751            }
4752            struct Visitor;
4753            impl<'de> serde::de::Visitor<'de> for Visitor {
4754                type Value = DurationDistanceMatrix;
4755                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4756                    formatter.write_str("struct DurationDistanceMatrix")
4757                }
4758                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4759                where
4760                    A: serde::de::MapAccess<'de>,
4761                {
4762                    #[allow(unused_imports)]
4763                    use serde::de::Error;
4764                    use std::option::Option::Some;
4765                    let mut fields = std::collections::HashSet::new();
4766                    let mut result = Self::Value::new();
4767                    while let Some(tag) = map.next_key::<__FieldTag>()? {
4768                        #[allow(clippy::match_single_binding)]
4769                        match tag {
4770                            __FieldTag::__rows => {
4771                                if !fields.insert(__FieldTag::__rows) {
4772                                    return std::result::Result::Err(A::Error::duplicate_field(
4773                                        "multiple values for rows",
4774                                    ));
4775                                }
4776                                result.rows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>>>()?.unwrap_or_default();
4777                            }
4778                            __FieldTag::__vehicle_start_tag => {
4779                                if !fields.insert(__FieldTag::__vehicle_start_tag) {
4780                                    return std::result::Result::Err(A::Error::duplicate_field(
4781                                        "multiple values for vehicle_start_tag",
4782                                    ));
4783                                }
4784                                result.vehicle_start_tag = map
4785                                    .next_value::<std::option::Option<std::string::String>>()?
4786                                    .unwrap_or_default();
4787                            }
4788                            __FieldTag::Unknown(key) => {
4789                                let value = map.next_value::<serde_json::Value>()?;
4790                                result._unknown_fields.insert(key, value);
4791                            }
4792                        }
4793                    }
4794                    std::result::Result::Ok(result)
4795                }
4796            }
4797            deserializer.deserialize_any(Visitor)
4798        }
4799    }
4800
4801    #[doc(hidden)]
4802    impl serde::ser::Serialize for DurationDistanceMatrix {
4803        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4804        where
4805            S: serde::ser::Serializer,
4806        {
4807            use serde::ser::SerializeMap;
4808            #[allow(unused_imports)]
4809            use std::option::Option::Some;
4810            let mut state = serializer.serialize_map(std::option::Option::None)?;
4811            if !self.rows.is_empty() {
4812                state.serialize_entry("rows", &self.rows)?;
4813            }
4814            if !self.vehicle_start_tag.is_empty() {
4815                state.serialize_entry("vehicleStartTag", &self.vehicle_start_tag)?;
4816            }
4817            if !self._unknown_fields.is_empty() {
4818                for (key, value) in self._unknown_fields.iter() {
4819                    state.serialize_entry(key, &value)?;
4820                }
4821            }
4822            state.end()
4823        }
4824    }
4825
4826    impl std::fmt::Debug for DurationDistanceMatrix {
4827        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4828            let mut debug_struct = f.debug_struct("DurationDistanceMatrix");
4829            debug_struct.field("rows", &self.rows);
4830            debug_struct.field("vehicle_start_tag", &self.vehicle_start_tag);
4831            if !self._unknown_fields.is_empty() {
4832                debug_struct.field("_unknown_fields", &self._unknown_fields);
4833            }
4834            debug_struct.finish()
4835        }
4836    }
4837
4838    /// Defines additional types related to [DurationDistanceMatrix].
4839    pub mod duration_distance_matrix {
4840        #[allow(unused_imports)]
4841        use super::*;
4842
4843        /// Specifies a row of the duration and distance matrix.
4844        #[derive(Clone, Default, PartialEq)]
4845        #[non_exhaustive]
4846        pub struct Row {
4847            /// Duration values for a given row. It must have as many elements as
4848            /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
4849            ///
4850            /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
4851            pub durations: std::vec::Vec<wkt::Duration>,
4852
4853            /// Distance values for a given row. If no costs or constraints refer to
4854            /// distances in the model, this can be left empty; otherwise it must have
4855            /// as many elements as `durations`.
4856            pub meters: std::vec::Vec<f64>,
4857
4858            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4859        }
4860
4861        impl Row {
4862            pub fn new() -> Self {
4863                std::default::Default::default()
4864            }
4865
4866            /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
4867            pub fn set_durations<T, V>(mut self, v: T) -> Self
4868            where
4869                T: std::iter::IntoIterator<Item = V>,
4870                V: std::convert::Into<wkt::Duration>,
4871            {
4872                use std::iter::Iterator;
4873                self.durations = v.into_iter().map(|i| i.into()).collect();
4874                self
4875            }
4876
4877            /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
4878            pub fn set_meters<T, V>(mut self, v: T) -> Self
4879            where
4880                T: std::iter::IntoIterator<Item = V>,
4881                V: std::convert::Into<f64>,
4882            {
4883                use std::iter::Iterator;
4884                self.meters = v.into_iter().map(|i| i.into()).collect();
4885                self
4886            }
4887        }
4888
4889        impl wkt::message::Message for Row {
4890            fn typename() -> &'static str {
4891                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
4892            }
4893        }
4894
4895        #[doc(hidden)]
4896        impl<'de> serde::de::Deserialize<'de> for Row {
4897            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4898            where
4899                D: serde::Deserializer<'de>,
4900            {
4901                #[allow(non_camel_case_types)]
4902                #[doc(hidden)]
4903                #[derive(PartialEq, Eq, Hash)]
4904                enum __FieldTag {
4905                    __durations,
4906                    __meters,
4907                    Unknown(std::string::String),
4908                }
4909                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4910                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4911                    where
4912                        D: serde::Deserializer<'de>,
4913                    {
4914                        struct Visitor;
4915                        impl<'de> serde::de::Visitor<'de> for Visitor {
4916                            type Value = __FieldTag;
4917                            fn expecting(
4918                                &self,
4919                                formatter: &mut std::fmt::Formatter,
4920                            ) -> std::fmt::Result {
4921                                formatter.write_str("a field name for Row")
4922                            }
4923                            fn visit_str<E>(
4924                                self,
4925                                value: &str,
4926                            ) -> std::result::Result<Self::Value, E>
4927                            where
4928                                E: serde::de::Error,
4929                            {
4930                                use std::result::Result::Ok;
4931                                use std::string::ToString;
4932                                match value {
4933                                    "durations" => Ok(__FieldTag::__durations),
4934                                    "meters" => Ok(__FieldTag::__meters),
4935                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
4936                                }
4937                            }
4938                        }
4939                        deserializer.deserialize_identifier(Visitor)
4940                    }
4941                }
4942                struct Visitor;
4943                impl<'de> serde::de::Visitor<'de> for Visitor {
4944                    type Value = Row;
4945                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4946                        formatter.write_str("struct Row")
4947                    }
4948                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4949                    where
4950                        A: serde::de::MapAccess<'de>,
4951                    {
4952                        #[allow(unused_imports)]
4953                        use serde::de::Error;
4954                        use std::option::Option::Some;
4955                        let mut fields = std::collections::HashSet::new();
4956                        let mut result = Self::Value::new();
4957                        while let Some(tag) = map.next_key::<__FieldTag>()? {
4958                            #[allow(clippy::match_single_binding)]
4959                            match tag {
4960                                __FieldTag::__durations => {
4961                                    if !fields.insert(__FieldTag::__durations) {
4962                                        return std::result::Result::Err(
4963                                            A::Error::duplicate_field(
4964                                                "multiple values for durations",
4965                                            ),
4966                                        );
4967                                    }
4968                                    result.durations = map.next_value::<std::option::Option<std::vec::Vec<wkt::Duration>>>()?.unwrap_or_default();
4969                                }
4970                                __FieldTag::__meters => {
4971                                    if !fields.insert(__FieldTag::__meters) {
4972                                        return std::result::Result::Err(
4973                                            A::Error::duplicate_field("multiple values for meters"),
4974                                        );
4975                                    }
4976                                    struct __With(std::option::Option<std::vec::Vec<f64>>);
4977                                    impl<'de> serde::de::Deserialize<'de> for __With {
4978                                        fn deserialize<D>(
4979                                            deserializer: D,
4980                                        ) -> std::result::Result<Self, D::Error>
4981                                        where
4982                                            D: serde::de::Deserializer<'de>,
4983                                        {
4984                                            serde_with::As::<
4985                                                std::option::Option<
4986                                                    std::vec::Vec<wkt::internal::F64>,
4987                                                >,
4988                                            >::deserialize(
4989                                                deserializer
4990                                            )
4991                                            .map(__With)
4992                                        }
4993                                    }
4994                                    result.meters =
4995                                        map.next_value::<__With>()?.0.unwrap_or_default();
4996                                }
4997                                __FieldTag::Unknown(key) => {
4998                                    let value = map.next_value::<serde_json::Value>()?;
4999                                    result._unknown_fields.insert(key, value);
5000                                }
5001                            }
5002                        }
5003                        std::result::Result::Ok(result)
5004                    }
5005                }
5006                deserializer.deserialize_any(Visitor)
5007            }
5008        }
5009
5010        #[doc(hidden)]
5011        impl serde::ser::Serialize for Row {
5012            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5013            where
5014                S: serde::ser::Serializer,
5015            {
5016                use serde::ser::SerializeMap;
5017                #[allow(unused_imports)]
5018                use std::option::Option::Some;
5019                let mut state = serializer.serialize_map(std::option::Option::None)?;
5020                if !self.durations.is_empty() {
5021                    state.serialize_entry("durations", &self.durations)?;
5022                }
5023                if !self.meters.is_empty() {
5024                    struct __With<'a>(&'a std::vec::Vec<f64>);
5025                    impl<'a> serde::ser::Serialize for __With<'a> {
5026                        fn serialize<S>(
5027                            &self,
5028                            serializer: S,
5029                        ) -> std::result::Result<S::Ok, S::Error>
5030                        where
5031                            S: serde::ser::Serializer,
5032                        {
5033                            serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
5034                                self.0, serializer,
5035                            )
5036                        }
5037                    }
5038                    state.serialize_entry("meters", &__With(&self.meters))?;
5039                }
5040                if !self._unknown_fields.is_empty() {
5041                    for (key, value) in self._unknown_fields.iter() {
5042                        state.serialize_entry(key, &value)?;
5043                    }
5044                }
5045                state.end()
5046            }
5047        }
5048
5049        impl std::fmt::Debug for Row {
5050            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5051                let mut debug_struct = f.debug_struct("Row");
5052                debug_struct.field("durations", &self.durations);
5053                debug_struct.field("meters", &self.meters);
5054                if !self._unknown_fields.is_empty() {
5055                    debug_struct.field("_unknown_fields", &self._unknown_fields);
5056                }
5057                debug_struct.finish()
5058            }
5059        }
5060    }
5061
5062    /// A precedence rule between two events (each event is the pickup or the
5063    /// delivery of a shipment): the "second" event has to start at least
5064    /// `offset_duration` after "first" has started.
5065    ///
5066    /// Several precedences can refer to the same (or related) events, e.g.,
5067    /// "pickup of B happens after delivery of A" and "pickup of C happens after
5068    /// pickup of B".
5069    ///
5070    /// Furthermore, precedences only apply when both shipments are performed and
5071    /// are otherwise ignored.
5072    #[derive(Clone, Default, PartialEq)]
5073    #[non_exhaustive]
5074    pub struct PrecedenceRule {
5075        /// Shipment index of the "first" event. This field must be specified.
5076        pub first_index: std::option::Option<i32>,
5077
5078        /// Indicates if the "first" event is a delivery.
5079        pub first_is_delivery: bool,
5080
5081        /// Shipment index of the "second" event. This field must be specified.
5082        pub second_index: std::option::Option<i32>,
5083
5084        /// Indicates if the "second" event is a delivery.
5085        pub second_is_delivery: bool,
5086
5087        /// The offset between the "first" and "second" event. It can be negative.
5088        pub offset_duration: std::option::Option<wkt::Duration>,
5089
5090        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5091    }
5092
5093    impl PrecedenceRule {
5094        pub fn new() -> Self {
5095            std::default::Default::default()
5096        }
5097
5098        /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
5099        pub fn set_first_index<T>(mut self, v: T) -> Self
5100        where
5101            T: std::convert::Into<i32>,
5102        {
5103            self.first_index = std::option::Option::Some(v.into());
5104            self
5105        }
5106
5107        /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
5108        pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
5109        where
5110            T: std::convert::Into<i32>,
5111        {
5112            self.first_index = v.map(|x| x.into());
5113            self
5114        }
5115
5116        /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
5117        pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5118            self.first_is_delivery = v.into();
5119            self
5120        }
5121
5122        /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
5123        pub fn set_second_index<T>(mut self, v: T) -> Self
5124        where
5125            T: std::convert::Into<i32>,
5126        {
5127            self.second_index = std::option::Option::Some(v.into());
5128            self
5129        }
5130
5131        /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
5132        pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
5133        where
5134            T: std::convert::Into<i32>,
5135        {
5136            self.second_index = v.map(|x| x.into());
5137            self
5138        }
5139
5140        /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
5141        pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5142            self.second_is_delivery = v.into();
5143            self
5144        }
5145
5146        /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
5147        pub fn set_offset_duration<T>(mut self, v: T) -> Self
5148        where
5149            T: std::convert::Into<wkt::Duration>,
5150        {
5151            self.offset_duration = std::option::Option::Some(v.into());
5152            self
5153        }
5154
5155        /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
5156        pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
5157        where
5158            T: std::convert::Into<wkt::Duration>,
5159        {
5160            self.offset_duration = v.map(|x| x.into());
5161            self
5162        }
5163    }
5164
5165    impl wkt::message::Message for PrecedenceRule {
5166        fn typename() -> &'static str {
5167            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
5168        }
5169    }
5170
5171    #[doc(hidden)]
5172    impl<'de> serde::de::Deserialize<'de> for PrecedenceRule {
5173        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5174        where
5175            D: serde::Deserializer<'de>,
5176        {
5177            #[allow(non_camel_case_types)]
5178            #[doc(hidden)]
5179            #[derive(PartialEq, Eq, Hash)]
5180            enum __FieldTag {
5181                __first_index,
5182                __first_is_delivery,
5183                __second_index,
5184                __second_is_delivery,
5185                __offset_duration,
5186                Unknown(std::string::String),
5187            }
5188            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5189                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5190                where
5191                    D: serde::Deserializer<'de>,
5192                {
5193                    struct Visitor;
5194                    impl<'de> serde::de::Visitor<'de> for Visitor {
5195                        type Value = __FieldTag;
5196                        fn expecting(
5197                            &self,
5198                            formatter: &mut std::fmt::Formatter,
5199                        ) -> std::fmt::Result {
5200                            formatter.write_str("a field name for PrecedenceRule")
5201                        }
5202                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5203                        where
5204                            E: serde::de::Error,
5205                        {
5206                            use std::result::Result::Ok;
5207                            use std::string::ToString;
5208                            match value {
5209                                "firstIndex" => Ok(__FieldTag::__first_index),
5210                                "first_index" => Ok(__FieldTag::__first_index),
5211                                "firstIsDelivery" => Ok(__FieldTag::__first_is_delivery),
5212                                "first_is_delivery" => Ok(__FieldTag::__first_is_delivery),
5213                                "secondIndex" => Ok(__FieldTag::__second_index),
5214                                "second_index" => Ok(__FieldTag::__second_index),
5215                                "secondIsDelivery" => Ok(__FieldTag::__second_is_delivery),
5216                                "second_is_delivery" => Ok(__FieldTag::__second_is_delivery),
5217                                "offsetDuration" => Ok(__FieldTag::__offset_duration),
5218                                "offset_duration" => Ok(__FieldTag::__offset_duration),
5219                                _ => Ok(__FieldTag::Unknown(value.to_string())),
5220                            }
5221                        }
5222                    }
5223                    deserializer.deserialize_identifier(Visitor)
5224                }
5225            }
5226            struct Visitor;
5227            impl<'de> serde::de::Visitor<'de> for Visitor {
5228                type Value = PrecedenceRule;
5229                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5230                    formatter.write_str("struct PrecedenceRule")
5231                }
5232                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5233                where
5234                    A: serde::de::MapAccess<'de>,
5235                {
5236                    #[allow(unused_imports)]
5237                    use serde::de::Error;
5238                    use std::option::Option::Some;
5239                    let mut fields = std::collections::HashSet::new();
5240                    let mut result = Self::Value::new();
5241                    while let Some(tag) = map.next_key::<__FieldTag>()? {
5242                        #[allow(clippy::match_single_binding)]
5243                        match tag {
5244                            __FieldTag::__first_index => {
5245                                if !fields.insert(__FieldTag::__first_index) {
5246                                    return std::result::Result::Err(A::Error::duplicate_field(
5247                                        "multiple values for first_index",
5248                                    ));
5249                                }
5250                                struct __With(std::option::Option<i32>);
5251                                impl<'de> serde::de::Deserialize<'de> for __With {
5252                                    fn deserialize<D>(
5253                                        deserializer: D,
5254                                    ) -> std::result::Result<Self, D::Error>
5255                                    where
5256                                        D: serde::de::Deserializer<'de>,
5257                                    {
5258                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
5259                                    }
5260                                }
5261                                result.first_index = map.next_value::<__With>()?.0;
5262                            }
5263                            __FieldTag::__first_is_delivery => {
5264                                if !fields.insert(__FieldTag::__first_is_delivery) {
5265                                    return std::result::Result::Err(A::Error::duplicate_field(
5266                                        "multiple values for first_is_delivery",
5267                                    ));
5268                                }
5269                                result.first_is_delivery = map
5270                                    .next_value::<std::option::Option<bool>>()?
5271                                    .unwrap_or_default();
5272                            }
5273                            __FieldTag::__second_index => {
5274                                if !fields.insert(__FieldTag::__second_index) {
5275                                    return std::result::Result::Err(A::Error::duplicate_field(
5276                                        "multiple values for second_index",
5277                                    ));
5278                                }
5279                                struct __With(std::option::Option<i32>);
5280                                impl<'de> serde::de::Deserialize<'de> for __With {
5281                                    fn deserialize<D>(
5282                                        deserializer: D,
5283                                    ) -> std::result::Result<Self, D::Error>
5284                                    where
5285                                        D: serde::de::Deserializer<'de>,
5286                                    {
5287                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
5288                                    }
5289                                }
5290                                result.second_index = map.next_value::<__With>()?.0;
5291                            }
5292                            __FieldTag::__second_is_delivery => {
5293                                if !fields.insert(__FieldTag::__second_is_delivery) {
5294                                    return std::result::Result::Err(A::Error::duplicate_field(
5295                                        "multiple values for second_is_delivery",
5296                                    ));
5297                                }
5298                                result.second_is_delivery = map
5299                                    .next_value::<std::option::Option<bool>>()?
5300                                    .unwrap_or_default();
5301                            }
5302                            __FieldTag::__offset_duration => {
5303                                if !fields.insert(__FieldTag::__offset_duration) {
5304                                    return std::result::Result::Err(A::Error::duplicate_field(
5305                                        "multiple values for offset_duration",
5306                                    ));
5307                                }
5308                                result.offset_duration =
5309                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
5310                            }
5311                            __FieldTag::Unknown(key) => {
5312                                let value = map.next_value::<serde_json::Value>()?;
5313                                result._unknown_fields.insert(key, value);
5314                            }
5315                        }
5316                    }
5317                    std::result::Result::Ok(result)
5318                }
5319            }
5320            deserializer.deserialize_any(Visitor)
5321        }
5322    }
5323
5324    #[doc(hidden)]
5325    impl serde::ser::Serialize for PrecedenceRule {
5326        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5327        where
5328            S: serde::ser::Serializer,
5329        {
5330            use serde::ser::SerializeMap;
5331            #[allow(unused_imports)]
5332            use std::option::Option::Some;
5333            let mut state = serializer.serialize_map(std::option::Option::None)?;
5334            if self.first_index.is_some() {
5335                struct __With<'a>(&'a std::option::Option<i32>);
5336                impl<'a> serde::ser::Serialize for __With<'a> {
5337                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5338                    where
5339                        S: serde::ser::Serializer,
5340                    {
5341                        serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
5342                            self.0, serializer,
5343                        )
5344                    }
5345                }
5346                state.serialize_entry("firstIndex", &__With(&self.first_index))?;
5347            }
5348            if !wkt::internal::is_default(&self.first_is_delivery) {
5349                state.serialize_entry("firstIsDelivery", &self.first_is_delivery)?;
5350            }
5351            if self.second_index.is_some() {
5352                struct __With<'a>(&'a std::option::Option<i32>);
5353                impl<'a> serde::ser::Serialize for __With<'a> {
5354                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5355                    where
5356                        S: serde::ser::Serializer,
5357                    {
5358                        serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
5359                            self.0, serializer,
5360                        )
5361                    }
5362                }
5363                state.serialize_entry("secondIndex", &__With(&self.second_index))?;
5364            }
5365            if !wkt::internal::is_default(&self.second_is_delivery) {
5366                state.serialize_entry("secondIsDelivery", &self.second_is_delivery)?;
5367            }
5368            if self.offset_duration.is_some() {
5369                state.serialize_entry("offsetDuration", &self.offset_duration)?;
5370            }
5371            if !self._unknown_fields.is_empty() {
5372                for (key, value) in self._unknown_fields.iter() {
5373                    state.serialize_entry(key, &value)?;
5374                }
5375            }
5376            state.end()
5377        }
5378    }
5379
5380    impl std::fmt::Debug for PrecedenceRule {
5381        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5382            let mut debug_struct = f.debug_struct("PrecedenceRule");
5383            debug_struct.field("first_index", &self.first_index);
5384            debug_struct.field("first_is_delivery", &self.first_is_delivery);
5385            debug_struct.field("second_index", &self.second_index);
5386            debug_struct.field("second_is_delivery", &self.second_is_delivery);
5387            debug_struct.field("offset_duration", &self.offset_duration);
5388            if !self._unknown_fields.is_empty() {
5389                debug_struct.field("_unknown_fields", &self._unknown_fields);
5390            }
5391            debug_struct.finish()
5392        }
5393    }
5394
5395    /// Deprecated: Use top level
5396    /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
5397    /// Rules to generate time breaks for a vehicle (e.g. lunch
5398    /// breaks). A break is a contiguous period of time during which the vehicle
5399    /// remains idle at its current position and cannot perform any visit. A break
5400    /// may occur:
5401    ///
5402    /// * during the travel between two visits (which includes the time right
5403    ///   before or right after a visit, but not in the middle of a visit), in
5404    ///   which case it extends the corresponding transit time between the visits
5405    /// * before the vehicle start (the vehicle may not start in the middle of
5406    ///   a break), in which case it does not affect the vehicle start time.
5407    /// * after the vehicle end (ditto, with the vehicle end time).
5408    ///
5409    /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
5410    #[derive(Clone, Default, PartialEq)]
5411    #[non_exhaustive]
5412    #[deprecated]
5413    pub struct BreakRule {
5414        /// Sequence of breaks. See the `BreakRequest` message.
5415        pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
5416
5417        /// Several `FrequencyConstraint` may apply. They must all be satisfied by
5418        /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
5419        pub frequency_constraints:
5420            std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
5421
5422        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5423    }
5424
5425    impl BreakRule {
5426        pub fn new() -> Self {
5427            std::default::Default::default()
5428        }
5429
5430        /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
5431        pub fn set_break_requests<T, V>(mut self, v: T) -> Self
5432        where
5433            T: std::iter::IntoIterator<Item = V>,
5434            V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
5435        {
5436            use std::iter::Iterator;
5437            self.break_requests = v.into_iter().map(|i| i.into()).collect();
5438            self
5439        }
5440
5441        /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
5442        pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
5443        where
5444            T: std::iter::IntoIterator<Item = V>,
5445            V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
5446        {
5447            use std::iter::Iterator;
5448            self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
5449            self
5450        }
5451    }
5452
5453    impl wkt::message::Message for BreakRule {
5454        fn typename() -> &'static str {
5455            "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
5456        }
5457    }
5458
5459    #[doc(hidden)]
5460    impl<'de> serde::de::Deserialize<'de> for BreakRule {
5461        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5462        where
5463            D: serde::Deserializer<'de>,
5464        {
5465            #[allow(non_camel_case_types)]
5466            #[doc(hidden)]
5467            #[derive(PartialEq, Eq, Hash)]
5468            enum __FieldTag {
5469                __break_requests,
5470                __frequency_constraints,
5471                Unknown(std::string::String),
5472            }
5473            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5474                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5475                where
5476                    D: serde::Deserializer<'de>,
5477                {
5478                    struct Visitor;
5479                    impl<'de> serde::de::Visitor<'de> for Visitor {
5480                        type Value = __FieldTag;
5481                        fn expecting(
5482                            &self,
5483                            formatter: &mut std::fmt::Formatter,
5484                        ) -> std::fmt::Result {
5485                            formatter.write_str("a field name for BreakRule")
5486                        }
5487                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5488                        where
5489                            E: serde::de::Error,
5490                        {
5491                            use std::result::Result::Ok;
5492                            use std::string::ToString;
5493                            match value {
5494                                "breakRequests" => Ok(__FieldTag::__break_requests),
5495                                "break_requests" => Ok(__FieldTag::__break_requests),
5496                                "frequencyConstraints" => Ok(__FieldTag::__frequency_constraints),
5497                                "frequency_constraints" => Ok(__FieldTag::__frequency_constraints),
5498                                _ => Ok(__FieldTag::Unknown(value.to_string())),
5499                            }
5500                        }
5501                    }
5502                    deserializer.deserialize_identifier(Visitor)
5503                }
5504            }
5505            struct Visitor;
5506            impl<'de> serde::de::Visitor<'de> for Visitor {
5507                type Value = BreakRule;
5508                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5509                    formatter.write_str("struct BreakRule")
5510                }
5511                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5512                where
5513                    A: serde::de::MapAccess<'de>,
5514                {
5515                    #[allow(unused_imports)]
5516                    use serde::de::Error;
5517                    use std::option::Option::Some;
5518                    let mut fields = std::collections::HashSet::new();
5519                    let mut result = Self::Value::new();
5520                    while let Some(tag) = map.next_key::<__FieldTag>()? {
5521                        #[allow(clippy::match_single_binding)]
5522                        match tag {
5523                            __FieldTag::__break_requests => {
5524                                if !fields.insert(__FieldTag::__break_requests) {
5525                                    return std::result::Result::Err(A::Error::duplicate_field(
5526                                        "multiple values for break_requests",
5527                                    ));
5528                                }
5529                                result.break_requests = map
5530                                    .next_value::<std::option::Option<
5531                                        std::vec::Vec<
5532                                            crate::model::shipment_model::break_rule::BreakRequest,
5533                                        >,
5534                                    >>()?
5535                                    .unwrap_or_default();
5536                            }
5537                            __FieldTag::__frequency_constraints => {
5538                                if !fields.insert(__FieldTag::__frequency_constraints) {
5539                                    return std::result::Result::Err(A::Error::duplicate_field(
5540                                        "multiple values for frequency_constraints",
5541                                    ));
5542                                }
5543                                result.frequency_constraints = map.next_value::<std::option::Option<std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>>>()?.unwrap_or_default();
5544                            }
5545                            __FieldTag::Unknown(key) => {
5546                                let value = map.next_value::<serde_json::Value>()?;
5547                                result._unknown_fields.insert(key, value);
5548                            }
5549                        }
5550                    }
5551                    std::result::Result::Ok(result)
5552                }
5553            }
5554            deserializer.deserialize_any(Visitor)
5555        }
5556    }
5557
5558    #[doc(hidden)]
5559    impl serde::ser::Serialize for BreakRule {
5560        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5561        where
5562            S: serde::ser::Serializer,
5563        {
5564            use serde::ser::SerializeMap;
5565            #[allow(unused_imports)]
5566            use std::option::Option::Some;
5567            let mut state = serializer.serialize_map(std::option::Option::None)?;
5568            if !self.break_requests.is_empty() {
5569                state.serialize_entry("breakRequests", &self.break_requests)?;
5570            }
5571            if !self.frequency_constraints.is_empty() {
5572                state.serialize_entry("frequencyConstraints", &self.frequency_constraints)?;
5573            }
5574            if !self._unknown_fields.is_empty() {
5575                for (key, value) in self._unknown_fields.iter() {
5576                    state.serialize_entry(key, &value)?;
5577                }
5578            }
5579            state.end()
5580        }
5581    }
5582
5583    impl std::fmt::Debug for BreakRule {
5584        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5585            let mut debug_struct = f.debug_struct("BreakRule");
5586            debug_struct.field("break_requests", &self.break_requests);
5587            debug_struct.field("frequency_constraints", &self.frequency_constraints);
5588            if !self._unknown_fields.is_empty() {
5589                debug_struct.field("_unknown_fields", &self._unknown_fields);
5590            }
5591            debug_struct.finish()
5592        }
5593    }
5594
5595    /// Defines additional types related to [BreakRule].
5596    pub mod break_rule {
5597        #[allow(unused_imports)]
5598        use super::*;
5599
5600        /// The sequence of breaks (i.e. their number and order) that apply to each
5601        /// vehicle must be known beforehand. The repeated `BreakRequest`s define
5602        /// that sequence, in the order in which they must occur. Their time windows
5603        /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
5604        /// be compatible with the order (this is checked).
5605        #[derive(Clone, Default, PartialEq)]
5606        #[non_exhaustive]
5607        pub struct BreakRequest {
5608            /// Required. Lower bound (inclusive) on the start of the break.
5609            pub earliest_start_time: std::option::Option<wkt::Timestamp>,
5610
5611            /// Required. Upper bound (inclusive) on the start of the break.
5612            pub latest_start_time: std::option::Option<wkt::Timestamp>,
5613
5614            /// Required. Minimum duration of the break. Must be positive.
5615            pub min_duration: std::option::Option<wkt::Duration>,
5616
5617            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5618        }
5619
5620        impl BreakRequest {
5621            pub fn new() -> Self {
5622                std::default::Default::default()
5623            }
5624
5625            /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
5626            pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
5627            where
5628                T: std::convert::Into<wkt::Timestamp>,
5629            {
5630                self.earliest_start_time = std::option::Option::Some(v.into());
5631                self
5632            }
5633
5634            /// Sets or clears the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
5635            pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5636            where
5637                T: std::convert::Into<wkt::Timestamp>,
5638            {
5639                self.earliest_start_time = v.map(|x| x.into());
5640                self
5641            }
5642
5643            /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
5644            pub fn set_latest_start_time<T>(mut self, v: T) -> Self
5645            where
5646                T: std::convert::Into<wkt::Timestamp>,
5647            {
5648                self.latest_start_time = std::option::Option::Some(v.into());
5649                self
5650            }
5651
5652            /// Sets or clears the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
5653            pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5654            where
5655                T: std::convert::Into<wkt::Timestamp>,
5656            {
5657                self.latest_start_time = v.map(|x| x.into());
5658                self
5659            }
5660
5661            /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
5662            pub fn set_min_duration<T>(mut self, v: T) -> Self
5663            where
5664                T: std::convert::Into<wkt::Duration>,
5665            {
5666                self.min_duration = std::option::Option::Some(v.into());
5667                self
5668            }
5669
5670            /// Sets or clears the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
5671            pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
5672            where
5673                T: std::convert::Into<wkt::Duration>,
5674            {
5675                self.min_duration = v.map(|x| x.into());
5676                self
5677            }
5678        }
5679
5680        impl wkt::message::Message for BreakRequest {
5681            fn typename() -> &'static str {
5682                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
5683            }
5684        }
5685
5686        #[doc(hidden)]
5687        impl<'de> serde::de::Deserialize<'de> for BreakRequest {
5688            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5689            where
5690                D: serde::Deserializer<'de>,
5691            {
5692                #[allow(non_camel_case_types)]
5693                #[doc(hidden)]
5694                #[derive(PartialEq, Eq, Hash)]
5695                enum __FieldTag {
5696                    __earliest_start_time,
5697                    __latest_start_time,
5698                    __min_duration,
5699                    Unknown(std::string::String),
5700                }
5701                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5702                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5703                    where
5704                        D: serde::Deserializer<'de>,
5705                    {
5706                        struct Visitor;
5707                        impl<'de> serde::de::Visitor<'de> for Visitor {
5708                            type Value = __FieldTag;
5709                            fn expecting(
5710                                &self,
5711                                formatter: &mut std::fmt::Formatter,
5712                            ) -> std::fmt::Result {
5713                                formatter.write_str("a field name for BreakRequest")
5714                            }
5715                            fn visit_str<E>(
5716                                self,
5717                                value: &str,
5718                            ) -> std::result::Result<Self::Value, E>
5719                            where
5720                                E: serde::de::Error,
5721                            {
5722                                use std::result::Result::Ok;
5723                                use std::string::ToString;
5724                                match value {
5725                                    "earliestStartTime" => Ok(__FieldTag::__earliest_start_time),
5726                                    "earliest_start_time" => Ok(__FieldTag::__earliest_start_time),
5727                                    "latestStartTime" => Ok(__FieldTag::__latest_start_time),
5728                                    "latest_start_time" => Ok(__FieldTag::__latest_start_time),
5729                                    "minDuration" => Ok(__FieldTag::__min_duration),
5730                                    "min_duration" => Ok(__FieldTag::__min_duration),
5731                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
5732                                }
5733                            }
5734                        }
5735                        deserializer.deserialize_identifier(Visitor)
5736                    }
5737                }
5738                struct Visitor;
5739                impl<'de> serde::de::Visitor<'de> for Visitor {
5740                    type Value = BreakRequest;
5741                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5742                        formatter.write_str("struct BreakRequest")
5743                    }
5744                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5745                    where
5746                        A: serde::de::MapAccess<'de>,
5747                    {
5748                        #[allow(unused_imports)]
5749                        use serde::de::Error;
5750                        use std::option::Option::Some;
5751                        let mut fields = std::collections::HashSet::new();
5752                        let mut result = Self::Value::new();
5753                        while let Some(tag) = map.next_key::<__FieldTag>()? {
5754                            #[allow(clippy::match_single_binding)]
5755                            match tag {
5756                                __FieldTag::__earliest_start_time => {
5757                                    if !fields.insert(__FieldTag::__earliest_start_time) {
5758                                        return std::result::Result::Err(
5759                                            A::Error::duplicate_field(
5760                                                "multiple values for earliest_start_time",
5761                                            ),
5762                                        );
5763                                    }
5764                                    result.earliest_start_time =
5765                                        map.next_value::<std::option::Option<wkt::Timestamp>>()?;
5766                                }
5767                                __FieldTag::__latest_start_time => {
5768                                    if !fields.insert(__FieldTag::__latest_start_time) {
5769                                        return std::result::Result::Err(
5770                                            A::Error::duplicate_field(
5771                                                "multiple values for latest_start_time",
5772                                            ),
5773                                        );
5774                                    }
5775                                    result.latest_start_time =
5776                                        map.next_value::<std::option::Option<wkt::Timestamp>>()?;
5777                                }
5778                                __FieldTag::__min_duration => {
5779                                    if !fields.insert(__FieldTag::__min_duration) {
5780                                        return std::result::Result::Err(
5781                                            A::Error::duplicate_field(
5782                                                "multiple values for min_duration",
5783                                            ),
5784                                        );
5785                                    }
5786                                    result.min_duration =
5787                                        map.next_value::<std::option::Option<wkt::Duration>>()?;
5788                                }
5789                                __FieldTag::Unknown(key) => {
5790                                    let value = map.next_value::<serde_json::Value>()?;
5791                                    result._unknown_fields.insert(key, value);
5792                                }
5793                            }
5794                        }
5795                        std::result::Result::Ok(result)
5796                    }
5797                }
5798                deserializer.deserialize_any(Visitor)
5799            }
5800        }
5801
5802        #[doc(hidden)]
5803        impl serde::ser::Serialize for BreakRequest {
5804            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5805            where
5806                S: serde::ser::Serializer,
5807            {
5808                use serde::ser::SerializeMap;
5809                #[allow(unused_imports)]
5810                use std::option::Option::Some;
5811                let mut state = serializer.serialize_map(std::option::Option::None)?;
5812                if self.earliest_start_time.is_some() {
5813                    state.serialize_entry("earliestStartTime", &self.earliest_start_time)?;
5814                }
5815                if self.latest_start_time.is_some() {
5816                    state.serialize_entry("latestStartTime", &self.latest_start_time)?;
5817                }
5818                if self.min_duration.is_some() {
5819                    state.serialize_entry("minDuration", &self.min_duration)?;
5820                }
5821                if !self._unknown_fields.is_empty() {
5822                    for (key, value) in self._unknown_fields.iter() {
5823                        state.serialize_entry(key, &value)?;
5824                    }
5825                }
5826                state.end()
5827            }
5828        }
5829
5830        impl std::fmt::Debug for BreakRequest {
5831            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5832                let mut debug_struct = f.debug_struct("BreakRequest");
5833                debug_struct.field("earliest_start_time", &self.earliest_start_time);
5834                debug_struct.field("latest_start_time", &self.latest_start_time);
5835                debug_struct.field("min_duration", &self.min_duration);
5836                if !self._unknown_fields.is_empty() {
5837                    debug_struct.field("_unknown_fields", &self._unknown_fields);
5838                }
5839                debug_struct.finish()
5840            }
5841        }
5842
5843        /// One may further constrain the frequency and duration of the breaks
5844        /// specified above, by enforcing a minimum break frequency, such as
5845        /// "There must be a break of at least 1 hour every 12 hours". Assuming that
5846        /// this can be interpreted as "Within any sliding time window of 12h, there
5847        /// must be at least one break of at least one hour", that example would
5848        /// translate to the following `FrequencyConstraint`:
5849        ///
5850        /// ```norust
5851        /// {
5852        ///    min_break_duration { seconds: 3600 }         # 1 hour.
5853        ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
5854        /// }
5855        /// ```
5856        ///
5857        /// The timing and duration of the breaks in the solution will respect all
5858        /// such constraints, in addition to the time windows and minimum durations
5859        /// already specified in the `BreakRequest`.
5860        ///
5861        /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
5862        /// For example, the following schedule honors the "1h every 12h" example:
5863        ///
5864        /// ```norust
5865        ///   04:00 vehicle start
5866        ///    .. performing travel and visits ..
5867        ///   09:00 1 hour break
5868        ///   10:00 end of the break
5869        ///    .. performing travel and visits ..
5870        ///   12:00 20-min lunch break
5871        ///   12:20 end of the break
5872        ///    .. performing travel and visits ..
5873        ///   21:00 1 hour break
5874        ///   22:00 end of the break
5875        ///    .. performing travel and visits ..
5876        ///   23:59 vehicle end
5877        /// ```
5878        #[derive(Clone, Default, PartialEq)]
5879        #[non_exhaustive]
5880        pub struct FrequencyConstraint {
5881            /// Required. Minimum break duration for this constraint. Nonnegative.
5882            /// See description of `FrequencyConstraint`.
5883            pub min_break_duration: std::option::Option<wkt::Duration>,
5884
5885            /// Required. Maximum allowed span of any interval of time in the route
5886            /// that does not include at least partially a break of `duration >=
5887            /// min_break_duration`. Must be positive.
5888            pub max_inter_break_duration: std::option::Option<wkt::Duration>,
5889
5890            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5891        }
5892
5893        impl FrequencyConstraint {
5894            pub fn new() -> Self {
5895                std::default::Default::default()
5896            }
5897
5898            /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
5899            pub fn set_min_break_duration<T>(mut self, v: T) -> Self
5900            where
5901                T: std::convert::Into<wkt::Duration>,
5902            {
5903                self.min_break_duration = std::option::Option::Some(v.into());
5904                self
5905            }
5906
5907            /// Sets or clears the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
5908            pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
5909            where
5910                T: std::convert::Into<wkt::Duration>,
5911            {
5912                self.min_break_duration = v.map(|x| x.into());
5913                self
5914            }
5915
5916            /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
5917            pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
5918            where
5919                T: std::convert::Into<wkt::Duration>,
5920            {
5921                self.max_inter_break_duration = std::option::Option::Some(v.into());
5922                self
5923            }
5924
5925            /// Sets or clears the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
5926            pub fn set_or_clear_max_inter_break_duration<T>(
5927                mut self,
5928                v: std::option::Option<T>,
5929            ) -> Self
5930            where
5931                T: std::convert::Into<wkt::Duration>,
5932            {
5933                self.max_inter_break_duration = v.map(|x| x.into());
5934                self
5935            }
5936        }
5937
5938        impl wkt::message::Message for FrequencyConstraint {
5939            fn typename() -> &'static str {
5940                "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
5941            }
5942        }
5943
5944        #[doc(hidden)]
5945        impl<'de> serde::de::Deserialize<'de> for FrequencyConstraint {
5946            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5947            where
5948                D: serde::Deserializer<'de>,
5949            {
5950                #[allow(non_camel_case_types)]
5951                #[doc(hidden)]
5952                #[derive(PartialEq, Eq, Hash)]
5953                enum __FieldTag {
5954                    __min_break_duration,
5955                    __max_inter_break_duration,
5956                    Unknown(std::string::String),
5957                }
5958                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5959                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5960                    where
5961                        D: serde::Deserializer<'de>,
5962                    {
5963                        struct Visitor;
5964                        impl<'de> serde::de::Visitor<'de> for Visitor {
5965                            type Value = __FieldTag;
5966                            fn expecting(
5967                                &self,
5968                                formatter: &mut std::fmt::Formatter,
5969                            ) -> std::fmt::Result {
5970                                formatter.write_str("a field name for FrequencyConstraint")
5971                            }
5972                            fn visit_str<E>(
5973                                self,
5974                                value: &str,
5975                            ) -> std::result::Result<Self::Value, E>
5976                            where
5977                                E: serde::de::Error,
5978                            {
5979                                use std::result::Result::Ok;
5980                                use std::string::ToString;
5981                                match value {
5982                                    "minBreakDuration" => Ok(__FieldTag::__min_break_duration),
5983                                    "min_break_duration" => Ok(__FieldTag::__min_break_duration),
5984                                    "maxInterBreakDuration" => {
5985                                        Ok(__FieldTag::__max_inter_break_duration)
5986                                    }
5987                                    "max_inter_break_duration" => {
5988                                        Ok(__FieldTag::__max_inter_break_duration)
5989                                    }
5990                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
5991                                }
5992                            }
5993                        }
5994                        deserializer.deserialize_identifier(Visitor)
5995                    }
5996                }
5997                struct Visitor;
5998                impl<'de> serde::de::Visitor<'de> for Visitor {
5999                    type Value = FrequencyConstraint;
6000                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6001                        formatter.write_str("struct FrequencyConstraint")
6002                    }
6003                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6004                    where
6005                        A: serde::de::MapAccess<'de>,
6006                    {
6007                        #[allow(unused_imports)]
6008                        use serde::de::Error;
6009                        use std::option::Option::Some;
6010                        let mut fields = std::collections::HashSet::new();
6011                        let mut result = Self::Value::new();
6012                        while let Some(tag) = map.next_key::<__FieldTag>()? {
6013                            #[allow(clippy::match_single_binding)]
6014                            match tag {
6015                                __FieldTag::__min_break_duration => {
6016                                    if !fields.insert(__FieldTag::__min_break_duration) {
6017                                        return std::result::Result::Err(
6018                                            A::Error::duplicate_field(
6019                                                "multiple values for min_break_duration",
6020                                            ),
6021                                        );
6022                                    }
6023                                    result.min_break_duration =
6024                                        map.next_value::<std::option::Option<wkt::Duration>>()?;
6025                                }
6026                                __FieldTag::__max_inter_break_duration => {
6027                                    if !fields.insert(__FieldTag::__max_inter_break_duration) {
6028                                        return std::result::Result::Err(
6029                                            A::Error::duplicate_field(
6030                                                "multiple values for max_inter_break_duration",
6031                                            ),
6032                                        );
6033                                    }
6034                                    result.max_inter_break_duration =
6035                                        map.next_value::<std::option::Option<wkt::Duration>>()?;
6036                                }
6037                                __FieldTag::Unknown(key) => {
6038                                    let value = map.next_value::<serde_json::Value>()?;
6039                                    result._unknown_fields.insert(key, value);
6040                                }
6041                            }
6042                        }
6043                        std::result::Result::Ok(result)
6044                    }
6045                }
6046                deserializer.deserialize_any(Visitor)
6047            }
6048        }
6049
6050        #[doc(hidden)]
6051        impl serde::ser::Serialize for FrequencyConstraint {
6052            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6053            where
6054                S: serde::ser::Serializer,
6055            {
6056                use serde::ser::SerializeMap;
6057                #[allow(unused_imports)]
6058                use std::option::Option::Some;
6059                let mut state = serializer.serialize_map(std::option::Option::None)?;
6060                if self.min_break_duration.is_some() {
6061                    state.serialize_entry("minBreakDuration", &self.min_break_duration)?;
6062                }
6063                if self.max_inter_break_duration.is_some() {
6064                    state
6065                        .serialize_entry("maxInterBreakDuration", &self.max_inter_break_duration)?;
6066                }
6067                if !self._unknown_fields.is_empty() {
6068                    for (key, value) in self._unknown_fields.iter() {
6069                        state.serialize_entry(key, &value)?;
6070                    }
6071                }
6072                state.end()
6073            }
6074        }
6075
6076        impl std::fmt::Debug for FrequencyConstraint {
6077            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6078                let mut debug_struct = f.debug_struct("FrequencyConstraint");
6079                debug_struct.field("min_break_duration", &self.min_break_duration);
6080                debug_struct.field("max_inter_break_duration", &self.max_inter_break_duration);
6081                if !self._unknown_fields.is_empty() {
6082                    debug_struct.field("_unknown_fields", &self._unknown_fields);
6083                }
6084                debug_struct.finish()
6085            }
6086        }
6087    }
6088}
6089
6090/// The shipment of a single item, from one of its pickups to one of its
6091/// deliveries. For the shipment to be considered as performed, a unique vehicle
6092/// must visit one of its pickup locations (and decrease its spare capacities
6093/// accordingly), then visit one of its delivery locations later on (and
6094/// therefore re-increase its spare capacities accordingly).
6095#[derive(Clone, Default, PartialEq)]
6096#[non_exhaustive]
6097pub struct Shipment {
6098    /// Set of pickup alternatives associated to the shipment. If not specified,
6099    /// the vehicle only needs to visit a location corresponding to the deliveries.
6100    pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
6101
6102    /// Set of delivery alternatives associated to the shipment. If not specified,
6103    /// the vehicle only needs to visit a location corresponding to the pickups.
6104    pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
6105
6106    /// Load demands of the shipment (for example weight, volume, number of
6107    /// pallets etc). The keys in the map should be identifiers describing the type
6108    /// of the corresponding load, ideally also including the units.
6109    /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
6110    /// If a given key does not appear in the map, the corresponding load is
6111    /// considered as null.
6112    pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
6113
6114    /// If the shipment is not completed, this penalty is added to the overall
6115    /// cost of the routes. A shipment is considered completed if one of its pickup
6116    /// and delivery alternatives is visited. The cost may be expressed in the
6117    /// same unit used for all other cost-related fields in the model and must be
6118    /// positive.
6119    ///
6120    /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
6121    /// i.e. the shipment must be completed.
6122    pub penalty_cost: std::option::Option<f64>,
6123
6124    /// The set of vehicles that may perform this shipment. If empty, all vehicles
6125    /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
6126    /// `vehicles` list.
6127    pub allowed_vehicle_indices: std::vec::Vec<i32>,
6128
6129    /// Specifies the cost that is incurred when this shipment is delivered by each
6130    /// vehicle. If specified, it must have EITHER:
6131    ///
6132    /// * the same number of elements as `costs_per_vehicle_indices`.
6133    ///   `costs_per_vehicle[i]` corresponds to vehicle
6134    ///   `costs_per_vehicle_indices[i]` of the model.
6135    /// * the same number of elements as there are vehicles in the model. The
6136    ///   i-th element corresponds to vehicle #i of the model.
6137    ///
6138    /// These costs must be in the same unit as `penalty_cost` and must not be
6139    /// negative. Leave this field empty, if there are no such costs.
6140    pub costs_per_vehicle: std::vec::Vec<f64>,
6141
6142    /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
6143    /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
6144    /// index may not be specified more than once. If a vehicle is excluded from
6145    /// `costs_per_vehicle_indices`, its cost is zero.
6146    pub costs_per_vehicle_indices: std::vec::Vec<i32>,
6147
6148    /// Specifies the maximum relative detour time compared to the shortest path
6149    /// from pickup to delivery. If specified, it must be nonnegative, and the
6150    /// shipment must contain at least a pickup and a delivery.
6151    ///
6152    /// For example, let t be the shortest time taken to go from the selected
6153    /// pickup alternative directly to the selected delivery alternative. Then
6154    /// setting `pickup_to_delivery_relative_detour_limit` enforces:
6155    ///
6156    /// ```norust
6157    /// start_time(delivery) - start_time(pickup) <=
6158    /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
6159    /// ```
6160    ///
6161    /// If both relative and absolute limits are specified on the same shipment,
6162    /// the more constraining limit is used for each possible pickup/delivery pair.
6163    /// As of 2017/10, detours are only supported when travel durations do not
6164    /// depend on vehicles.
6165    pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
6166
6167    /// Specifies the maximum absolute detour time compared to the shortest path
6168    /// from pickup to delivery. If specified, it must be nonnegative, and the
6169    /// shipment must contain at least a pickup and a delivery.
6170    ///
6171    /// For example, let t be the shortest time taken to go from the selected
6172    /// pickup alternative directly to the selected delivery alternative. Then
6173    /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
6174    ///
6175    /// ```norust
6176    /// start_time(delivery) - start_time(pickup) <=
6177    /// t + pickup_to_delivery_absolute_detour_limit
6178    /// ```
6179    ///
6180    /// If both relative and absolute limits are specified on the same shipment,
6181    /// the more constraining limit is used for each possible pickup/delivery pair.
6182    /// As of 2017/10, detours are only supported when travel durations do not
6183    /// depend on vehicles.
6184    pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
6185
6186    /// Specifies the maximum duration from start of pickup to start of delivery of
6187    /// a shipment. If specified, it must be nonnegative, and the shipment must
6188    /// contain at least a pickup and a delivery. This does not depend on which
6189    /// alternatives are selected for pickup and delivery, nor on vehicle speed.
6190    /// This can be specified alongside maximum detour constraints: the solution
6191    /// will respect both specifications.
6192    pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
6193
6194    /// Non-empty string specifying a "type" for this shipment.
6195    /// This feature can be used to define incompatibilities or requirements
6196    /// between `shipment_types` (see `shipment_type_incompatibilities` and
6197    /// `shipment_type_requirements` in `ShipmentModel`).
6198    ///
6199    /// Differs from `visit_types` which is specified for a single visit: All
6200    /// pickup/deliveries belonging to the same shipment share the same
6201    /// `shipment_type`.
6202    pub shipment_type: std::string::String,
6203
6204    /// Specifies a label for this shipment. This label is reported in the response
6205    /// in the `shipment_label` of the corresponding
6206    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
6207    ///
6208    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
6209    pub label: std::string::String,
6210
6211    /// If true, skip this shipment, but don't apply a `penalty_cost`.
6212    ///
6213    /// Ignoring a shipment results in a validation error when there are any
6214    /// `shipment_type_requirements` in the model.
6215    ///
6216    /// Ignoring a shipment that is performed in `injected_first_solution_routes`
6217    /// or `injected_solution_constraint` is permitted; the solver removes the
6218    /// related pickup/delivery visits from the performing route.
6219    /// `precedence_rules` that reference ignored shipments will also be ignored.
6220    pub ignore: bool,
6221
6222    /// Deprecated: Use
6223    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
6224    /// instead.
6225    ///
6226    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
6227    #[deprecated]
6228    pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
6229
6230    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6231}
6232
6233impl Shipment {
6234    pub fn new() -> Self {
6235        std::default::Default::default()
6236    }
6237
6238    /// Sets the value of [pickups][crate::model::Shipment::pickups].
6239    pub fn set_pickups<T, V>(mut self, v: T) -> Self
6240    where
6241        T: std::iter::IntoIterator<Item = V>,
6242        V: std::convert::Into<crate::model::shipment::VisitRequest>,
6243    {
6244        use std::iter::Iterator;
6245        self.pickups = v.into_iter().map(|i| i.into()).collect();
6246        self
6247    }
6248
6249    /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
6250    pub fn set_deliveries<T, V>(mut self, v: T) -> Self
6251    where
6252        T: std::iter::IntoIterator<Item = V>,
6253        V: std::convert::Into<crate::model::shipment::VisitRequest>,
6254    {
6255        use std::iter::Iterator;
6256        self.deliveries = v.into_iter().map(|i| i.into()).collect();
6257        self
6258    }
6259
6260    /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
6261    pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
6262    where
6263        T: std::iter::IntoIterator<Item = (K, V)>,
6264        K: std::convert::Into<std::string::String>,
6265        V: std::convert::Into<crate::model::shipment::Load>,
6266    {
6267        use std::iter::Iterator;
6268        self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6269        self
6270    }
6271
6272    /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
6273    pub fn set_penalty_cost<T>(mut self, v: T) -> Self
6274    where
6275        T: std::convert::Into<f64>,
6276    {
6277        self.penalty_cost = std::option::Option::Some(v.into());
6278        self
6279    }
6280
6281    /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
6282    pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
6283    where
6284        T: std::convert::Into<f64>,
6285    {
6286        self.penalty_cost = v.map(|x| x.into());
6287        self
6288    }
6289
6290    /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
6291    pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
6292    where
6293        T: std::iter::IntoIterator<Item = V>,
6294        V: std::convert::Into<i32>,
6295    {
6296        use std::iter::Iterator;
6297        self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
6298        self
6299    }
6300
6301    /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
6302    pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
6303    where
6304        T: std::iter::IntoIterator<Item = V>,
6305        V: std::convert::Into<f64>,
6306    {
6307        use std::iter::Iterator;
6308        self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
6309        self
6310    }
6311
6312    /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
6313    pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
6314    where
6315        T: std::iter::IntoIterator<Item = V>,
6316        V: std::convert::Into<i32>,
6317    {
6318        use std::iter::Iterator;
6319        self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
6320        self
6321    }
6322
6323    /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
6324    pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
6325    where
6326        T: std::convert::Into<f64>,
6327    {
6328        self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
6329        self
6330    }
6331
6332    /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
6333    pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
6334        mut self,
6335        v: std::option::Option<T>,
6336    ) -> Self
6337    where
6338        T: std::convert::Into<f64>,
6339    {
6340        self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
6341        self
6342    }
6343
6344    /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
6345    pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
6346    where
6347        T: std::convert::Into<wkt::Duration>,
6348    {
6349        self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
6350        self
6351    }
6352
6353    /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
6354    pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
6355        mut self,
6356        v: std::option::Option<T>,
6357    ) -> Self
6358    where
6359        T: std::convert::Into<wkt::Duration>,
6360    {
6361        self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
6362        self
6363    }
6364
6365    /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
6366    pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
6367    where
6368        T: std::convert::Into<wkt::Duration>,
6369    {
6370        self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
6371        self
6372    }
6373
6374    /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
6375    pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
6376        mut self,
6377        v: std::option::Option<T>,
6378    ) -> Self
6379    where
6380        T: std::convert::Into<wkt::Duration>,
6381    {
6382        self.pickup_to_delivery_time_limit = v.map(|x| x.into());
6383        self
6384    }
6385
6386    /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
6387    pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6388        self.shipment_type = v.into();
6389        self
6390    }
6391
6392    /// Sets the value of [label][crate::model::Shipment::label].
6393    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6394        self.label = v.into();
6395        self
6396    }
6397
6398    /// Sets the value of [ignore][crate::model::Shipment::ignore].
6399    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6400        self.ignore = v.into();
6401        self
6402    }
6403
6404    /// Sets the value of [demands][crate::model::Shipment::demands].
6405    #[deprecated]
6406    pub fn set_demands<T, V>(mut self, v: T) -> Self
6407    where
6408        T: std::iter::IntoIterator<Item = V>,
6409        V: std::convert::Into<crate::model::CapacityQuantity>,
6410    {
6411        use std::iter::Iterator;
6412        self.demands = v.into_iter().map(|i| i.into()).collect();
6413        self
6414    }
6415}
6416
6417impl wkt::message::Message for Shipment {
6418    fn typename() -> &'static str {
6419        "type.googleapis.com/google.cloud.optimization.v1.Shipment"
6420    }
6421}
6422
6423#[doc(hidden)]
6424impl<'de> serde::de::Deserialize<'de> for Shipment {
6425    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6426    where
6427        D: serde::Deserializer<'de>,
6428    {
6429        #[allow(non_camel_case_types)]
6430        #[doc(hidden)]
6431        #[derive(PartialEq, Eq, Hash)]
6432        enum __FieldTag {
6433            __pickups,
6434            __deliveries,
6435            __load_demands,
6436            __penalty_cost,
6437            __allowed_vehicle_indices,
6438            __costs_per_vehicle,
6439            __costs_per_vehicle_indices,
6440            __pickup_to_delivery_relative_detour_limit,
6441            __pickup_to_delivery_absolute_detour_limit,
6442            __pickup_to_delivery_time_limit,
6443            __shipment_type,
6444            __label,
6445            __ignore,
6446            __demands,
6447            Unknown(std::string::String),
6448        }
6449        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6450            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6451            where
6452                D: serde::Deserializer<'de>,
6453            {
6454                struct Visitor;
6455                impl<'de> serde::de::Visitor<'de> for Visitor {
6456                    type Value = __FieldTag;
6457                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6458                        formatter.write_str("a field name for Shipment")
6459                    }
6460                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6461                    where
6462                        E: serde::de::Error,
6463                    {
6464                        use std::result::Result::Ok;
6465                        use std::string::ToString;
6466                        match value {
6467                            "pickups" => Ok(__FieldTag::__pickups),
6468                            "deliveries" => Ok(__FieldTag::__deliveries),
6469                            "loadDemands" => Ok(__FieldTag::__load_demands),
6470                            "load_demands" => Ok(__FieldTag::__load_demands),
6471                            "penaltyCost" => Ok(__FieldTag::__penalty_cost),
6472                            "penalty_cost" => Ok(__FieldTag::__penalty_cost),
6473                            "allowedVehicleIndices" => Ok(__FieldTag::__allowed_vehicle_indices),
6474                            "allowed_vehicle_indices" => Ok(__FieldTag::__allowed_vehicle_indices),
6475                            "costsPerVehicle" => Ok(__FieldTag::__costs_per_vehicle),
6476                            "costs_per_vehicle" => Ok(__FieldTag::__costs_per_vehicle),
6477                            "costsPerVehicleIndices" => Ok(__FieldTag::__costs_per_vehicle_indices),
6478                            "costs_per_vehicle_indices" => {
6479                                Ok(__FieldTag::__costs_per_vehicle_indices)
6480                            }
6481                            "pickupToDeliveryRelativeDetourLimit" => {
6482                                Ok(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6483                            }
6484                            "pickup_to_delivery_relative_detour_limit" => {
6485                                Ok(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6486                            }
6487                            "pickupToDeliveryAbsoluteDetourLimit" => {
6488                                Ok(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6489                            }
6490                            "pickup_to_delivery_absolute_detour_limit" => {
6491                                Ok(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6492                            }
6493                            "pickupToDeliveryTimeLimit" => {
6494                                Ok(__FieldTag::__pickup_to_delivery_time_limit)
6495                            }
6496                            "pickup_to_delivery_time_limit" => {
6497                                Ok(__FieldTag::__pickup_to_delivery_time_limit)
6498                            }
6499                            "shipmentType" => Ok(__FieldTag::__shipment_type),
6500                            "shipment_type" => Ok(__FieldTag::__shipment_type),
6501                            "label" => Ok(__FieldTag::__label),
6502                            "ignore" => Ok(__FieldTag::__ignore),
6503                            "demands" => Ok(__FieldTag::__demands),
6504                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6505                        }
6506                    }
6507                }
6508                deserializer.deserialize_identifier(Visitor)
6509            }
6510        }
6511        struct Visitor;
6512        impl<'de> serde::de::Visitor<'de> for Visitor {
6513            type Value = Shipment;
6514            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6515                formatter.write_str("struct Shipment")
6516            }
6517            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6518            where
6519                A: serde::de::MapAccess<'de>,
6520            {
6521                #[allow(unused_imports)]
6522                use serde::de::Error;
6523                use std::option::Option::Some;
6524                let mut fields = std::collections::HashSet::new();
6525                let mut result = Self::Value::new();
6526                while let Some(tag) = map.next_key::<__FieldTag>()? {
6527                    #[allow(clippy::match_single_binding)]
6528                    match tag {
6529                        __FieldTag::__pickups => {
6530                            if !fields.insert(__FieldTag::__pickups) {
6531                                return std::result::Result::Err(A::Error::duplicate_field(
6532                                    "multiple values for pickups",
6533                                ));
6534                            }
6535                            result.pickups = map
6536                                .next_value::<std::option::Option<
6537                                    std::vec::Vec<crate::model::shipment::VisitRequest>,
6538                                >>()?
6539                                .unwrap_or_default();
6540                        }
6541                        __FieldTag::__deliveries => {
6542                            if !fields.insert(__FieldTag::__deliveries) {
6543                                return std::result::Result::Err(A::Error::duplicate_field(
6544                                    "multiple values for deliveries",
6545                                ));
6546                            }
6547                            result.deliveries = map
6548                                .next_value::<std::option::Option<
6549                                    std::vec::Vec<crate::model::shipment::VisitRequest>,
6550                                >>()?
6551                                .unwrap_or_default();
6552                        }
6553                        __FieldTag::__load_demands => {
6554                            if !fields.insert(__FieldTag::__load_demands) {
6555                                return std::result::Result::Err(A::Error::duplicate_field(
6556                                    "multiple values for load_demands",
6557                                ));
6558                            }
6559                            result.load_demands = map
6560                                .next_value::<std::option::Option<
6561                                    std::collections::HashMap<
6562                                        std::string::String,
6563                                        crate::model::shipment::Load,
6564                                    >,
6565                                >>()?
6566                                .unwrap_or_default();
6567                        }
6568                        __FieldTag::__penalty_cost => {
6569                            if !fields.insert(__FieldTag::__penalty_cost) {
6570                                return std::result::Result::Err(A::Error::duplicate_field(
6571                                    "multiple values for penalty_cost",
6572                                ));
6573                            }
6574                            struct __With(std::option::Option<f64>);
6575                            impl<'de> serde::de::Deserialize<'de> for __With {
6576                                fn deserialize<D>(
6577                                    deserializer: D,
6578                                ) -> std::result::Result<Self, D::Error>
6579                                where
6580                                    D: serde::de::Deserializer<'de>,
6581                                {
6582                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
6583                                }
6584                            }
6585                            result.penalty_cost = map.next_value::<__With>()?.0;
6586                        }
6587                        __FieldTag::__allowed_vehicle_indices => {
6588                            if !fields.insert(__FieldTag::__allowed_vehicle_indices) {
6589                                return std::result::Result::Err(A::Error::duplicate_field(
6590                                    "multiple values for allowed_vehicle_indices",
6591                                ));
6592                            }
6593                            struct __With(std::option::Option<std::vec::Vec<i32>>);
6594                            impl<'de> serde::de::Deserialize<'de> for __With {
6595                                fn deserialize<D>(
6596                                    deserializer: D,
6597                                ) -> std::result::Result<Self, D::Error>
6598                                where
6599                                    D: serde::de::Deserializer<'de>,
6600                                {
6601                                    serde_with::As::<
6602                                        std::option::Option<std::vec::Vec<wkt::internal::I32>>,
6603                                    >::deserialize(deserializer)
6604                                    .map(__With)
6605                                }
6606                            }
6607                            result.allowed_vehicle_indices =
6608                                map.next_value::<__With>()?.0.unwrap_or_default();
6609                        }
6610                        __FieldTag::__costs_per_vehicle => {
6611                            if !fields.insert(__FieldTag::__costs_per_vehicle) {
6612                                return std::result::Result::Err(A::Error::duplicate_field(
6613                                    "multiple values for costs_per_vehicle",
6614                                ));
6615                            }
6616                            struct __With(std::option::Option<std::vec::Vec<f64>>);
6617                            impl<'de> serde::de::Deserialize<'de> for __With {
6618                                fn deserialize<D>(
6619                                    deserializer: D,
6620                                ) -> std::result::Result<Self, D::Error>
6621                                where
6622                                    D: serde::de::Deserializer<'de>,
6623                                {
6624                                    serde_with::As::<
6625                                        std::option::Option<std::vec::Vec<wkt::internal::F64>>,
6626                                    >::deserialize(deserializer)
6627                                    .map(__With)
6628                                }
6629                            }
6630                            result.costs_per_vehicle =
6631                                map.next_value::<__With>()?.0.unwrap_or_default();
6632                        }
6633                        __FieldTag::__costs_per_vehicle_indices => {
6634                            if !fields.insert(__FieldTag::__costs_per_vehicle_indices) {
6635                                return std::result::Result::Err(A::Error::duplicate_field(
6636                                    "multiple values for costs_per_vehicle_indices",
6637                                ));
6638                            }
6639                            struct __With(std::option::Option<std::vec::Vec<i32>>);
6640                            impl<'de> serde::de::Deserialize<'de> for __With {
6641                                fn deserialize<D>(
6642                                    deserializer: D,
6643                                ) -> std::result::Result<Self, D::Error>
6644                                where
6645                                    D: serde::de::Deserializer<'de>,
6646                                {
6647                                    serde_with::As::<
6648                                        std::option::Option<std::vec::Vec<wkt::internal::I32>>,
6649                                    >::deserialize(deserializer)
6650                                    .map(__With)
6651                                }
6652                            }
6653                            result.costs_per_vehicle_indices =
6654                                map.next_value::<__With>()?.0.unwrap_or_default();
6655                        }
6656                        __FieldTag::__pickup_to_delivery_relative_detour_limit => {
6657                            if !fields
6658                                .insert(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6659                            {
6660                                return std::result::Result::Err(A::Error::duplicate_field(
6661                                    "multiple values for pickup_to_delivery_relative_detour_limit",
6662                                ));
6663                            }
6664                            struct __With(std::option::Option<f64>);
6665                            impl<'de> serde::de::Deserialize<'de> for __With {
6666                                fn deserialize<D>(
6667                                    deserializer: D,
6668                                ) -> std::result::Result<Self, D::Error>
6669                                where
6670                                    D: serde::de::Deserializer<'de>,
6671                                {
6672                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
6673                                }
6674                            }
6675                            result.pickup_to_delivery_relative_detour_limit =
6676                                map.next_value::<__With>()?.0;
6677                        }
6678                        __FieldTag::__pickup_to_delivery_absolute_detour_limit => {
6679                            if !fields
6680                                .insert(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6681                            {
6682                                return std::result::Result::Err(A::Error::duplicate_field(
6683                                    "multiple values for pickup_to_delivery_absolute_detour_limit",
6684                                ));
6685                            }
6686                            result.pickup_to_delivery_absolute_detour_limit =
6687                                map.next_value::<std::option::Option<wkt::Duration>>()?;
6688                        }
6689                        __FieldTag::__pickup_to_delivery_time_limit => {
6690                            if !fields.insert(__FieldTag::__pickup_to_delivery_time_limit) {
6691                                return std::result::Result::Err(A::Error::duplicate_field(
6692                                    "multiple values for pickup_to_delivery_time_limit",
6693                                ));
6694                            }
6695                            result.pickup_to_delivery_time_limit =
6696                                map.next_value::<std::option::Option<wkt::Duration>>()?;
6697                        }
6698                        __FieldTag::__shipment_type => {
6699                            if !fields.insert(__FieldTag::__shipment_type) {
6700                                return std::result::Result::Err(A::Error::duplicate_field(
6701                                    "multiple values for shipment_type",
6702                                ));
6703                            }
6704                            result.shipment_type = map
6705                                .next_value::<std::option::Option<std::string::String>>()?
6706                                .unwrap_or_default();
6707                        }
6708                        __FieldTag::__label => {
6709                            if !fields.insert(__FieldTag::__label) {
6710                                return std::result::Result::Err(A::Error::duplicate_field(
6711                                    "multiple values for label",
6712                                ));
6713                            }
6714                            result.label = map
6715                                .next_value::<std::option::Option<std::string::String>>()?
6716                                .unwrap_or_default();
6717                        }
6718                        __FieldTag::__ignore => {
6719                            if !fields.insert(__FieldTag::__ignore) {
6720                                return std::result::Result::Err(A::Error::duplicate_field(
6721                                    "multiple values for ignore",
6722                                ));
6723                            }
6724                            result.ignore = map
6725                                .next_value::<std::option::Option<bool>>()?
6726                                .unwrap_or_default();
6727                        }
6728                        __FieldTag::__demands => {
6729                            if !fields.insert(__FieldTag::__demands) {
6730                                return std::result::Result::Err(A::Error::duplicate_field(
6731                                    "multiple values for demands",
6732                                ));
6733                            }
6734                            result.demands =
6735                                map.next_value::<std::option::Option<
6736                                    std::vec::Vec<crate::model::CapacityQuantity>,
6737                                >>()?
6738                                .unwrap_or_default();
6739                        }
6740                        __FieldTag::Unknown(key) => {
6741                            let value = map.next_value::<serde_json::Value>()?;
6742                            result._unknown_fields.insert(key, value);
6743                        }
6744                    }
6745                }
6746                std::result::Result::Ok(result)
6747            }
6748        }
6749        deserializer.deserialize_any(Visitor)
6750    }
6751}
6752
6753#[doc(hidden)]
6754impl serde::ser::Serialize for Shipment {
6755    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6756    where
6757        S: serde::ser::Serializer,
6758    {
6759        use serde::ser::SerializeMap;
6760        #[allow(unused_imports)]
6761        use std::option::Option::Some;
6762        let mut state = serializer.serialize_map(std::option::Option::None)?;
6763        if !self.pickups.is_empty() {
6764            state.serialize_entry("pickups", &self.pickups)?;
6765        }
6766        if !self.deliveries.is_empty() {
6767            state.serialize_entry("deliveries", &self.deliveries)?;
6768        }
6769        if !self.load_demands.is_empty() {
6770            state.serialize_entry("loadDemands", &self.load_demands)?;
6771        }
6772        if self.penalty_cost.is_some() {
6773            struct __With<'a>(&'a std::option::Option<f64>);
6774            impl<'a> serde::ser::Serialize for __With<'a> {
6775                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6776                where
6777                    S: serde::ser::Serializer,
6778                {
6779                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
6780                        self.0, serializer,
6781                    )
6782                }
6783            }
6784            state.serialize_entry("penaltyCost", &__With(&self.penalty_cost))?;
6785        }
6786        if !self.allowed_vehicle_indices.is_empty() {
6787            struct __With<'a>(&'a std::vec::Vec<i32>);
6788            impl<'a> serde::ser::Serialize for __With<'a> {
6789                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6790                where
6791                    S: serde::ser::Serializer,
6792                {
6793                    serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
6794                        self.0, serializer,
6795                    )
6796                }
6797            }
6798            state.serialize_entry(
6799                "allowedVehicleIndices",
6800                &__With(&self.allowed_vehicle_indices),
6801            )?;
6802        }
6803        if !self.costs_per_vehicle.is_empty() {
6804            struct __With<'a>(&'a std::vec::Vec<f64>);
6805            impl<'a> serde::ser::Serialize for __With<'a> {
6806                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6807                where
6808                    S: serde::ser::Serializer,
6809                {
6810                    serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
6811                        self.0, serializer,
6812                    )
6813                }
6814            }
6815            state.serialize_entry("costsPerVehicle", &__With(&self.costs_per_vehicle))?;
6816        }
6817        if !self.costs_per_vehicle_indices.is_empty() {
6818            struct __With<'a>(&'a std::vec::Vec<i32>);
6819            impl<'a> serde::ser::Serialize for __With<'a> {
6820                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6821                where
6822                    S: serde::ser::Serializer,
6823                {
6824                    serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
6825                        self.0, serializer,
6826                    )
6827                }
6828            }
6829            state.serialize_entry(
6830                "costsPerVehicleIndices",
6831                &__With(&self.costs_per_vehicle_indices),
6832            )?;
6833        }
6834        if self.pickup_to_delivery_relative_detour_limit.is_some() {
6835            struct __With<'a>(&'a std::option::Option<f64>);
6836            impl<'a> serde::ser::Serialize for __With<'a> {
6837                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6838                where
6839                    S: serde::ser::Serializer,
6840                {
6841                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
6842                        self.0, serializer,
6843                    )
6844                }
6845            }
6846            state.serialize_entry(
6847                "pickupToDeliveryRelativeDetourLimit",
6848                &__With(&self.pickup_to_delivery_relative_detour_limit),
6849            )?;
6850        }
6851        if self.pickup_to_delivery_absolute_detour_limit.is_some() {
6852            state.serialize_entry(
6853                "pickupToDeliveryAbsoluteDetourLimit",
6854                &self.pickup_to_delivery_absolute_detour_limit,
6855            )?;
6856        }
6857        if self.pickup_to_delivery_time_limit.is_some() {
6858            state.serialize_entry(
6859                "pickupToDeliveryTimeLimit",
6860                &self.pickup_to_delivery_time_limit,
6861            )?;
6862        }
6863        if !self.shipment_type.is_empty() {
6864            state.serialize_entry("shipmentType", &self.shipment_type)?;
6865        }
6866        if !self.label.is_empty() {
6867            state.serialize_entry("label", &self.label)?;
6868        }
6869        if !wkt::internal::is_default(&self.ignore) {
6870            state.serialize_entry("ignore", &self.ignore)?;
6871        }
6872        if !self.demands.is_empty() {
6873            state.serialize_entry("demands", &self.demands)?;
6874        }
6875        if !self._unknown_fields.is_empty() {
6876            for (key, value) in self._unknown_fields.iter() {
6877                state.serialize_entry(key, &value)?;
6878            }
6879        }
6880        state.end()
6881    }
6882}
6883
6884impl std::fmt::Debug for Shipment {
6885    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6886        let mut debug_struct = f.debug_struct("Shipment");
6887        debug_struct.field("pickups", &self.pickups);
6888        debug_struct.field("deliveries", &self.deliveries);
6889        debug_struct.field("load_demands", &self.load_demands);
6890        debug_struct.field("penalty_cost", &self.penalty_cost);
6891        debug_struct.field("allowed_vehicle_indices", &self.allowed_vehicle_indices);
6892        debug_struct.field("costs_per_vehicle", &self.costs_per_vehicle);
6893        debug_struct.field("costs_per_vehicle_indices", &self.costs_per_vehicle_indices);
6894        debug_struct.field(
6895            "pickup_to_delivery_relative_detour_limit",
6896            &self.pickup_to_delivery_relative_detour_limit,
6897        );
6898        debug_struct.field(
6899            "pickup_to_delivery_absolute_detour_limit",
6900            &self.pickup_to_delivery_absolute_detour_limit,
6901        );
6902        debug_struct.field(
6903            "pickup_to_delivery_time_limit",
6904            &self.pickup_to_delivery_time_limit,
6905        );
6906        debug_struct.field("shipment_type", &self.shipment_type);
6907        debug_struct.field("label", &self.label);
6908        debug_struct.field("ignore", &self.ignore);
6909        debug_struct.field("demands", &self.demands);
6910        if !self._unknown_fields.is_empty() {
6911            debug_struct.field("_unknown_fields", &self._unknown_fields);
6912        }
6913        debug_struct.finish()
6914    }
6915}
6916
6917/// Defines additional types related to [Shipment].
6918pub mod shipment {
6919    #[allow(unused_imports)]
6920    use super::*;
6921
6922    /// Request for a visit which can be done by a vehicle: it has a geo-location
6923    /// (or two, see below), opening and closing times represented by time windows,
6924    /// and a service duration time (time spent by the vehicle once it has arrived
6925    /// to pickup or drop off goods).
6926    #[derive(Clone, Default, PartialEq)]
6927    #[non_exhaustive]
6928    pub struct VisitRequest {
6929        /// The geo-location where the vehicle arrives when performing this
6930        /// `VisitRequest`. If the shipment model has duration distance matrices,
6931        /// `arrival_location` must not be specified.
6932        pub arrival_location: std::option::Option<gtype::model::LatLng>,
6933
6934        /// The waypoint where the vehicle arrives when performing this
6935        /// `VisitRequest`. If the shipment model has duration distance matrices,
6936        /// `arrival_waypoint` must not be specified.
6937        pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
6938
6939        /// The geo-location where the vehicle departs after completing this
6940        /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
6941        /// If the shipment model has duration distance matrices,
6942        /// `departure_location` must not be specified.
6943        pub departure_location: std::option::Option<gtype::model::LatLng>,
6944
6945        /// The waypoint where the vehicle departs after completing this
6946        /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
6947        /// If the shipment model has duration distance matrices,
6948        /// `departure_waypoint` must not be specified.
6949        pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
6950
6951        /// Specifies tags attached to the visit request.
6952        /// Empty or duplicate strings are not allowed.
6953        pub tags: std::vec::Vec<std::string::String>,
6954
6955        /// Time windows which constrain the arrival time at a visit.
6956        /// Note that a vehicle may depart outside of the arrival time window, i.e.
6957        /// arrival time + duration do not need to be inside a time window. This can
6958        /// result in waiting time if the vehicle arrives before
6959        /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
6960        ///
6961        /// The absence of `TimeWindow` means that the vehicle can perform this visit
6962        /// at any time.
6963        ///
6964        /// Time windows must be disjoint, i.e. no time window must overlap with or
6965        /// be adjacent to another, and they must be in increasing order.
6966        ///
6967        /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
6968        /// be set if there is a single time window.
6969        ///
6970        /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
6971        pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
6972
6973        /// Duration of the visit, i.e. time spent by the vehicle between arrival
6974        /// and departure (to be added to the possible waiting time; see
6975        /// `time_windows`).
6976        pub duration: std::option::Option<wkt::Duration>,
6977
6978        /// Cost to service this visit request on a vehicle route. This can be used
6979        /// to pay different costs for each alternative pickup or delivery of a
6980        /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
6981        /// and must not be negative.
6982        pub cost: f64,
6983
6984        /// Load demands of this visit request. This is just like
6985        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
6986        /// field, except that it only applies to this
6987        /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
6988        /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
6989        /// The demands listed here are added to the demands listed in
6990        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
6991        ///
6992        /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
6993        /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
6994        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
6995        pub load_demands:
6996            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
6997
6998        /// Specifies the types of the visit. This may be used to allocate additional
6999        /// time required for a vehicle to complete this visit (see
7000        /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
7001        ///
7002        /// A type can only appear once.
7003        ///
7004        /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
7005        pub visit_types: std::vec::Vec<std::string::String>,
7006
7007        /// Specifies a label for this `VisitRequest`. This label is reported in the
7008        /// response as `visit_label` in the corresponding
7009        /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
7010        ///
7011        /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
7012        pub label: std::string::String,
7013
7014        /// Deprecated: Use
7015        /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
7016        /// instead.
7017        ///
7018        /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
7019        #[deprecated]
7020        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
7021
7022        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7023    }
7024
7025    impl VisitRequest {
7026        pub fn new() -> Self {
7027            std::default::Default::default()
7028        }
7029
7030        /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
7031        pub fn set_arrival_location<T>(mut self, v: T) -> Self
7032        where
7033            T: std::convert::Into<gtype::model::LatLng>,
7034        {
7035            self.arrival_location = std::option::Option::Some(v.into());
7036            self
7037        }
7038
7039        /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
7040        pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
7041        where
7042            T: std::convert::Into<gtype::model::LatLng>,
7043        {
7044            self.arrival_location = v.map(|x| x.into());
7045            self
7046        }
7047
7048        /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
7049        pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
7050        where
7051            T: std::convert::Into<crate::model::Waypoint>,
7052        {
7053            self.arrival_waypoint = std::option::Option::Some(v.into());
7054            self
7055        }
7056
7057        /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
7058        pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
7059        where
7060            T: std::convert::Into<crate::model::Waypoint>,
7061        {
7062            self.arrival_waypoint = v.map(|x| x.into());
7063            self
7064        }
7065
7066        /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
7067        pub fn set_departure_location<T>(mut self, v: T) -> Self
7068        where
7069            T: std::convert::Into<gtype::model::LatLng>,
7070        {
7071            self.departure_location = std::option::Option::Some(v.into());
7072            self
7073        }
7074
7075        /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
7076        pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
7077        where
7078            T: std::convert::Into<gtype::model::LatLng>,
7079        {
7080            self.departure_location = v.map(|x| x.into());
7081            self
7082        }
7083
7084        /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
7085        pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
7086        where
7087            T: std::convert::Into<crate::model::Waypoint>,
7088        {
7089            self.departure_waypoint = std::option::Option::Some(v.into());
7090            self
7091        }
7092
7093        /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
7094        pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
7095        where
7096            T: std::convert::Into<crate::model::Waypoint>,
7097        {
7098            self.departure_waypoint = v.map(|x| x.into());
7099            self
7100        }
7101
7102        /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
7103        pub fn set_tags<T, V>(mut self, v: T) -> Self
7104        where
7105            T: std::iter::IntoIterator<Item = V>,
7106            V: std::convert::Into<std::string::String>,
7107        {
7108            use std::iter::Iterator;
7109            self.tags = v.into_iter().map(|i| i.into()).collect();
7110            self
7111        }
7112
7113        /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
7114        pub fn set_time_windows<T, V>(mut self, v: T) -> Self
7115        where
7116            T: std::iter::IntoIterator<Item = V>,
7117            V: std::convert::Into<crate::model::TimeWindow>,
7118        {
7119            use std::iter::Iterator;
7120            self.time_windows = v.into_iter().map(|i| i.into()).collect();
7121            self
7122        }
7123
7124        /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
7125        pub fn set_duration<T>(mut self, v: T) -> Self
7126        where
7127            T: std::convert::Into<wkt::Duration>,
7128        {
7129            self.duration = std::option::Option::Some(v.into());
7130            self
7131        }
7132
7133        /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
7134        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
7135        where
7136            T: std::convert::Into<wkt::Duration>,
7137        {
7138            self.duration = v.map(|x| x.into());
7139            self
7140        }
7141
7142        /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
7143        pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7144            self.cost = v.into();
7145            self
7146        }
7147
7148        /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
7149        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
7150        where
7151            T: std::iter::IntoIterator<Item = (K, V)>,
7152            K: std::convert::Into<std::string::String>,
7153            V: std::convert::Into<crate::model::shipment::Load>,
7154        {
7155            use std::iter::Iterator;
7156            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7157            self
7158        }
7159
7160        /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
7161        pub fn set_visit_types<T, V>(mut self, v: T) -> Self
7162        where
7163            T: std::iter::IntoIterator<Item = V>,
7164            V: std::convert::Into<std::string::String>,
7165        {
7166            use std::iter::Iterator;
7167            self.visit_types = v.into_iter().map(|i| i.into()).collect();
7168            self
7169        }
7170
7171        /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
7172        pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7173            self.label = v.into();
7174            self
7175        }
7176
7177        /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
7178        #[deprecated]
7179        pub fn set_demands<T, V>(mut self, v: T) -> Self
7180        where
7181            T: std::iter::IntoIterator<Item = V>,
7182            V: std::convert::Into<crate::model::CapacityQuantity>,
7183        {
7184            use std::iter::Iterator;
7185            self.demands = v.into_iter().map(|i| i.into()).collect();
7186            self
7187        }
7188    }
7189
7190    impl wkt::message::Message for VisitRequest {
7191        fn typename() -> &'static str {
7192            "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
7193        }
7194    }
7195
7196    #[doc(hidden)]
7197    impl<'de> serde::de::Deserialize<'de> for VisitRequest {
7198        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7199        where
7200            D: serde::Deserializer<'de>,
7201        {
7202            #[allow(non_camel_case_types)]
7203            #[doc(hidden)]
7204            #[derive(PartialEq, Eq, Hash)]
7205            enum __FieldTag {
7206                __arrival_location,
7207                __arrival_waypoint,
7208                __departure_location,
7209                __departure_waypoint,
7210                __tags,
7211                __time_windows,
7212                __duration,
7213                __cost,
7214                __load_demands,
7215                __visit_types,
7216                __label,
7217                __demands,
7218                Unknown(std::string::String),
7219            }
7220            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7221                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7222                where
7223                    D: serde::Deserializer<'de>,
7224                {
7225                    struct Visitor;
7226                    impl<'de> serde::de::Visitor<'de> for Visitor {
7227                        type Value = __FieldTag;
7228                        fn expecting(
7229                            &self,
7230                            formatter: &mut std::fmt::Formatter,
7231                        ) -> std::fmt::Result {
7232                            formatter.write_str("a field name for VisitRequest")
7233                        }
7234                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7235                        where
7236                            E: serde::de::Error,
7237                        {
7238                            use std::result::Result::Ok;
7239                            use std::string::ToString;
7240                            match value {
7241                                "arrivalLocation" => Ok(__FieldTag::__arrival_location),
7242                                "arrival_location" => Ok(__FieldTag::__arrival_location),
7243                                "arrivalWaypoint" => Ok(__FieldTag::__arrival_waypoint),
7244                                "arrival_waypoint" => Ok(__FieldTag::__arrival_waypoint),
7245                                "departureLocation" => Ok(__FieldTag::__departure_location),
7246                                "departure_location" => Ok(__FieldTag::__departure_location),
7247                                "departureWaypoint" => Ok(__FieldTag::__departure_waypoint),
7248                                "departure_waypoint" => Ok(__FieldTag::__departure_waypoint),
7249                                "tags" => Ok(__FieldTag::__tags),
7250                                "timeWindows" => Ok(__FieldTag::__time_windows),
7251                                "time_windows" => Ok(__FieldTag::__time_windows),
7252                                "duration" => Ok(__FieldTag::__duration),
7253                                "cost" => Ok(__FieldTag::__cost),
7254                                "loadDemands" => Ok(__FieldTag::__load_demands),
7255                                "load_demands" => Ok(__FieldTag::__load_demands),
7256                                "visitTypes" => Ok(__FieldTag::__visit_types),
7257                                "visit_types" => Ok(__FieldTag::__visit_types),
7258                                "label" => Ok(__FieldTag::__label),
7259                                "demands" => Ok(__FieldTag::__demands),
7260                                _ => Ok(__FieldTag::Unknown(value.to_string())),
7261                            }
7262                        }
7263                    }
7264                    deserializer.deserialize_identifier(Visitor)
7265                }
7266            }
7267            struct Visitor;
7268            impl<'de> serde::de::Visitor<'de> for Visitor {
7269                type Value = VisitRequest;
7270                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7271                    formatter.write_str("struct VisitRequest")
7272                }
7273                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7274                where
7275                    A: serde::de::MapAccess<'de>,
7276                {
7277                    #[allow(unused_imports)]
7278                    use serde::de::Error;
7279                    use std::option::Option::Some;
7280                    let mut fields = std::collections::HashSet::new();
7281                    let mut result = Self::Value::new();
7282                    while let Some(tag) = map.next_key::<__FieldTag>()? {
7283                        #[allow(clippy::match_single_binding)]
7284                        match tag {
7285                            __FieldTag::__arrival_location => {
7286                                if !fields.insert(__FieldTag::__arrival_location) {
7287                                    return std::result::Result::Err(A::Error::duplicate_field(
7288                                        "multiple values for arrival_location",
7289                                    ));
7290                                }
7291                                result.arrival_location =
7292                                    map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
7293                            }
7294                            __FieldTag::__arrival_waypoint => {
7295                                if !fields.insert(__FieldTag::__arrival_waypoint) {
7296                                    return std::result::Result::Err(A::Error::duplicate_field(
7297                                        "multiple values for arrival_waypoint",
7298                                    ));
7299                                }
7300                                result.arrival_waypoint = map
7301                                    .next_value::<std::option::Option<crate::model::Waypoint>>()?;
7302                            }
7303                            __FieldTag::__departure_location => {
7304                                if !fields.insert(__FieldTag::__departure_location) {
7305                                    return std::result::Result::Err(A::Error::duplicate_field(
7306                                        "multiple values for departure_location",
7307                                    ));
7308                                }
7309                                result.departure_location =
7310                                    map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
7311                            }
7312                            __FieldTag::__departure_waypoint => {
7313                                if !fields.insert(__FieldTag::__departure_waypoint) {
7314                                    return std::result::Result::Err(A::Error::duplicate_field(
7315                                        "multiple values for departure_waypoint",
7316                                    ));
7317                                }
7318                                result.departure_waypoint = map
7319                                    .next_value::<std::option::Option<crate::model::Waypoint>>()?;
7320                            }
7321                            __FieldTag::__tags => {
7322                                if !fields.insert(__FieldTag::__tags) {
7323                                    return std::result::Result::Err(A::Error::duplicate_field(
7324                                        "multiple values for tags",
7325                                    ));
7326                                }
7327                                result.tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7328                            }
7329                            __FieldTag::__time_windows => {
7330                                if !fields.insert(__FieldTag::__time_windows) {
7331                                    return std::result::Result::Err(A::Error::duplicate_field(
7332                                        "multiple values for time_windows",
7333                                    ));
7334                                }
7335                                result.time_windows =
7336                                    map.next_value::<std::option::Option<
7337                                        std::vec::Vec<crate::model::TimeWindow>,
7338                                    >>()?
7339                                    .unwrap_or_default();
7340                            }
7341                            __FieldTag::__duration => {
7342                                if !fields.insert(__FieldTag::__duration) {
7343                                    return std::result::Result::Err(A::Error::duplicate_field(
7344                                        "multiple values for duration",
7345                                    ));
7346                                }
7347                                result.duration =
7348                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
7349                            }
7350                            __FieldTag::__cost => {
7351                                if !fields.insert(__FieldTag::__cost) {
7352                                    return std::result::Result::Err(A::Error::duplicate_field(
7353                                        "multiple values for cost",
7354                                    ));
7355                                }
7356                                struct __With(std::option::Option<f64>);
7357                                impl<'de> serde::de::Deserialize<'de> for __With {
7358                                    fn deserialize<D>(
7359                                        deserializer: D,
7360                                    ) -> std::result::Result<Self, D::Error>
7361                                    where
7362                                        D: serde::de::Deserializer<'de>,
7363                                    {
7364                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
7365                                    }
7366                                }
7367                                result.cost = map.next_value::<__With>()?.0.unwrap_or_default();
7368                            }
7369                            __FieldTag::__load_demands => {
7370                                if !fields.insert(__FieldTag::__load_demands) {
7371                                    return std::result::Result::Err(A::Error::duplicate_field(
7372                                        "multiple values for load_demands",
7373                                    ));
7374                                }
7375                                result.load_demands = map
7376                                    .next_value::<std::option::Option<
7377                                        std::collections::HashMap<
7378                                            std::string::String,
7379                                            crate::model::shipment::Load,
7380                                        >,
7381                                    >>()?
7382                                    .unwrap_or_default();
7383                            }
7384                            __FieldTag::__visit_types => {
7385                                if !fields.insert(__FieldTag::__visit_types) {
7386                                    return std::result::Result::Err(A::Error::duplicate_field(
7387                                        "multiple values for visit_types",
7388                                    ));
7389                                }
7390                                result.visit_types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7391                            }
7392                            __FieldTag::__label => {
7393                                if !fields.insert(__FieldTag::__label) {
7394                                    return std::result::Result::Err(A::Error::duplicate_field(
7395                                        "multiple values for label",
7396                                    ));
7397                                }
7398                                result.label = map
7399                                    .next_value::<std::option::Option<std::string::String>>()?
7400                                    .unwrap_or_default();
7401                            }
7402                            __FieldTag::__demands => {
7403                                if !fields.insert(__FieldTag::__demands) {
7404                                    return std::result::Result::Err(A::Error::duplicate_field(
7405                                        "multiple values for demands",
7406                                    ));
7407                                }
7408                                result.demands = map
7409                                    .next_value::<std::option::Option<
7410                                        std::vec::Vec<crate::model::CapacityQuantity>,
7411                                    >>()?
7412                                    .unwrap_or_default();
7413                            }
7414                            __FieldTag::Unknown(key) => {
7415                                let value = map.next_value::<serde_json::Value>()?;
7416                                result._unknown_fields.insert(key, value);
7417                            }
7418                        }
7419                    }
7420                    std::result::Result::Ok(result)
7421                }
7422            }
7423            deserializer.deserialize_any(Visitor)
7424        }
7425    }
7426
7427    #[doc(hidden)]
7428    impl serde::ser::Serialize for VisitRequest {
7429        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7430        where
7431            S: serde::ser::Serializer,
7432        {
7433            use serde::ser::SerializeMap;
7434            #[allow(unused_imports)]
7435            use std::option::Option::Some;
7436            let mut state = serializer.serialize_map(std::option::Option::None)?;
7437            if self.arrival_location.is_some() {
7438                state.serialize_entry("arrivalLocation", &self.arrival_location)?;
7439            }
7440            if self.arrival_waypoint.is_some() {
7441                state.serialize_entry("arrivalWaypoint", &self.arrival_waypoint)?;
7442            }
7443            if self.departure_location.is_some() {
7444                state.serialize_entry("departureLocation", &self.departure_location)?;
7445            }
7446            if self.departure_waypoint.is_some() {
7447                state.serialize_entry("departureWaypoint", &self.departure_waypoint)?;
7448            }
7449            if !self.tags.is_empty() {
7450                state.serialize_entry("tags", &self.tags)?;
7451            }
7452            if !self.time_windows.is_empty() {
7453                state.serialize_entry("timeWindows", &self.time_windows)?;
7454            }
7455            if self.duration.is_some() {
7456                state.serialize_entry("duration", &self.duration)?;
7457            }
7458            if !wkt::internal::is_default(&self.cost) {
7459                struct __With<'a>(&'a f64);
7460                impl<'a> serde::ser::Serialize for __With<'a> {
7461                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7462                    where
7463                        S: serde::ser::Serializer,
7464                    {
7465                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
7466                    }
7467                }
7468                state.serialize_entry("cost", &__With(&self.cost))?;
7469            }
7470            if !self.load_demands.is_empty() {
7471                state.serialize_entry("loadDemands", &self.load_demands)?;
7472            }
7473            if !self.visit_types.is_empty() {
7474                state.serialize_entry("visitTypes", &self.visit_types)?;
7475            }
7476            if !self.label.is_empty() {
7477                state.serialize_entry("label", &self.label)?;
7478            }
7479            if !self.demands.is_empty() {
7480                state.serialize_entry("demands", &self.demands)?;
7481            }
7482            if !self._unknown_fields.is_empty() {
7483                for (key, value) in self._unknown_fields.iter() {
7484                    state.serialize_entry(key, &value)?;
7485                }
7486            }
7487            state.end()
7488        }
7489    }
7490
7491    impl std::fmt::Debug for VisitRequest {
7492        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7493            let mut debug_struct = f.debug_struct("VisitRequest");
7494            debug_struct.field("arrival_location", &self.arrival_location);
7495            debug_struct.field("arrival_waypoint", &self.arrival_waypoint);
7496            debug_struct.field("departure_location", &self.departure_location);
7497            debug_struct.field("departure_waypoint", &self.departure_waypoint);
7498            debug_struct.field("tags", &self.tags);
7499            debug_struct.field("time_windows", &self.time_windows);
7500            debug_struct.field("duration", &self.duration);
7501            debug_struct.field("cost", &self.cost);
7502            debug_struct.field("load_demands", &self.load_demands);
7503            debug_struct.field("visit_types", &self.visit_types);
7504            debug_struct.field("label", &self.label);
7505            debug_struct.field("demands", &self.demands);
7506            if !self._unknown_fields.is_empty() {
7507                debug_struct.field("_unknown_fields", &self._unknown_fields);
7508            }
7509            debug_struct.finish()
7510        }
7511    }
7512
7513    /// When performing a visit, a predefined amount may be added to the vehicle
7514    /// load if it's a pickup, or subtracted if it's a delivery. This message
7515    /// defines such amount. See
7516    /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
7517    ///
7518    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
7519    #[derive(Clone, Default, PartialEq)]
7520    #[non_exhaustive]
7521    pub struct Load {
7522        /// The amount by which the load of the vehicle performing the corresponding
7523        /// visit will vary. Since it is an integer, users are advised to choose an
7524        /// appropriate unit to avoid loss of precision. Must be ≥ 0.
7525        pub amount: i64,
7526
7527        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7528    }
7529
7530    impl Load {
7531        pub fn new() -> Self {
7532            std::default::Default::default()
7533        }
7534
7535        /// Sets the value of [amount][crate::model::shipment::Load::amount].
7536        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7537            self.amount = v.into();
7538            self
7539        }
7540    }
7541
7542    impl wkt::message::Message for Load {
7543        fn typename() -> &'static str {
7544            "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
7545        }
7546    }
7547
7548    #[doc(hidden)]
7549    impl<'de> serde::de::Deserialize<'de> for Load {
7550        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7551        where
7552            D: serde::Deserializer<'de>,
7553        {
7554            #[allow(non_camel_case_types)]
7555            #[doc(hidden)]
7556            #[derive(PartialEq, Eq, Hash)]
7557            enum __FieldTag {
7558                __amount,
7559                Unknown(std::string::String),
7560            }
7561            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7562                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7563                where
7564                    D: serde::Deserializer<'de>,
7565                {
7566                    struct Visitor;
7567                    impl<'de> serde::de::Visitor<'de> for Visitor {
7568                        type Value = __FieldTag;
7569                        fn expecting(
7570                            &self,
7571                            formatter: &mut std::fmt::Formatter,
7572                        ) -> std::fmt::Result {
7573                            formatter.write_str("a field name for Load")
7574                        }
7575                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7576                        where
7577                            E: serde::de::Error,
7578                        {
7579                            use std::result::Result::Ok;
7580                            use std::string::ToString;
7581                            match value {
7582                                "amount" => Ok(__FieldTag::__amount),
7583                                _ => Ok(__FieldTag::Unknown(value.to_string())),
7584                            }
7585                        }
7586                    }
7587                    deserializer.deserialize_identifier(Visitor)
7588                }
7589            }
7590            struct Visitor;
7591            impl<'de> serde::de::Visitor<'de> for Visitor {
7592                type Value = Load;
7593                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7594                    formatter.write_str("struct Load")
7595                }
7596                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7597                where
7598                    A: serde::de::MapAccess<'de>,
7599                {
7600                    #[allow(unused_imports)]
7601                    use serde::de::Error;
7602                    use std::option::Option::Some;
7603                    let mut fields = std::collections::HashSet::new();
7604                    let mut result = Self::Value::new();
7605                    while let Some(tag) = map.next_key::<__FieldTag>()? {
7606                        #[allow(clippy::match_single_binding)]
7607                        match tag {
7608                            __FieldTag::__amount => {
7609                                if !fields.insert(__FieldTag::__amount) {
7610                                    return std::result::Result::Err(A::Error::duplicate_field(
7611                                        "multiple values for amount",
7612                                    ));
7613                                }
7614                                struct __With(std::option::Option<i64>);
7615                                impl<'de> serde::de::Deserialize<'de> for __With {
7616                                    fn deserialize<D>(
7617                                        deserializer: D,
7618                                    ) -> std::result::Result<Self, D::Error>
7619                                    where
7620                                        D: serde::de::Deserializer<'de>,
7621                                    {
7622                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
7623                                    }
7624                                }
7625                                result.amount = map.next_value::<__With>()?.0.unwrap_or_default();
7626                            }
7627                            __FieldTag::Unknown(key) => {
7628                                let value = map.next_value::<serde_json::Value>()?;
7629                                result._unknown_fields.insert(key, value);
7630                            }
7631                        }
7632                    }
7633                    std::result::Result::Ok(result)
7634                }
7635            }
7636            deserializer.deserialize_any(Visitor)
7637        }
7638    }
7639
7640    #[doc(hidden)]
7641    impl serde::ser::Serialize for Load {
7642        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7643        where
7644            S: serde::ser::Serializer,
7645        {
7646            use serde::ser::SerializeMap;
7647            #[allow(unused_imports)]
7648            use std::option::Option::Some;
7649            let mut state = serializer.serialize_map(std::option::Option::None)?;
7650            if !wkt::internal::is_default(&self.amount) {
7651                struct __With<'a>(&'a i64);
7652                impl<'a> serde::ser::Serialize for __With<'a> {
7653                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7654                    where
7655                        S: serde::ser::Serializer,
7656                    {
7657                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
7658                    }
7659                }
7660                state.serialize_entry("amount", &__With(&self.amount))?;
7661            }
7662            if !self._unknown_fields.is_empty() {
7663                for (key, value) in self._unknown_fields.iter() {
7664                    state.serialize_entry(key, &value)?;
7665                }
7666            }
7667            state.end()
7668        }
7669    }
7670
7671    impl std::fmt::Debug for Load {
7672        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7673            let mut debug_struct = f.debug_struct("Load");
7674            debug_struct.field("amount", &self.amount);
7675            if !self._unknown_fields.is_empty() {
7676                debug_struct.field("_unknown_fields", &self._unknown_fields);
7677            }
7678            debug_struct.finish()
7679        }
7680    }
7681}
7682
7683/// Specifies incompatibilties between shipments depending on their
7684/// shipment_type. The appearance of incompatible shipments on the same route is
7685/// restricted based on the incompatibility mode.
7686#[derive(Clone, Default, PartialEq)]
7687#[non_exhaustive]
7688pub struct ShipmentTypeIncompatibility {
7689    /// List of incompatible types. Two shipments having different `shipment_types`
7690    /// among those listed are "incompatible".
7691    pub types: std::vec::Vec<std::string::String>,
7692
7693    /// Mode applied to the incompatibility.
7694    pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
7695
7696    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7697}
7698
7699impl ShipmentTypeIncompatibility {
7700    pub fn new() -> Self {
7701        std::default::Default::default()
7702    }
7703
7704    /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
7705    pub fn set_types<T, V>(mut self, v: T) -> Self
7706    where
7707        T: std::iter::IntoIterator<Item = V>,
7708        V: std::convert::Into<std::string::String>,
7709    {
7710        use std::iter::Iterator;
7711        self.types = v.into_iter().map(|i| i.into()).collect();
7712        self
7713    }
7714
7715    /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
7716    pub fn set_incompatibility_mode<
7717        T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
7718    >(
7719        mut self,
7720        v: T,
7721    ) -> Self {
7722        self.incompatibility_mode = v.into();
7723        self
7724    }
7725}
7726
7727impl wkt::message::Message for ShipmentTypeIncompatibility {
7728    fn typename() -> &'static str {
7729        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
7730    }
7731}
7732
7733#[doc(hidden)]
7734impl<'de> serde::de::Deserialize<'de> for ShipmentTypeIncompatibility {
7735    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7736    where
7737        D: serde::Deserializer<'de>,
7738    {
7739        #[allow(non_camel_case_types)]
7740        #[doc(hidden)]
7741        #[derive(PartialEq, Eq, Hash)]
7742        enum __FieldTag {
7743            __types,
7744            __incompatibility_mode,
7745            Unknown(std::string::String),
7746        }
7747        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7748            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7749            where
7750                D: serde::Deserializer<'de>,
7751            {
7752                struct Visitor;
7753                impl<'de> serde::de::Visitor<'de> for Visitor {
7754                    type Value = __FieldTag;
7755                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7756                        formatter.write_str("a field name for ShipmentTypeIncompatibility")
7757                    }
7758                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7759                    where
7760                        E: serde::de::Error,
7761                    {
7762                        use std::result::Result::Ok;
7763                        use std::string::ToString;
7764                        match value {
7765                            "types" => Ok(__FieldTag::__types),
7766                            "incompatibilityMode" => Ok(__FieldTag::__incompatibility_mode),
7767                            "incompatibility_mode" => Ok(__FieldTag::__incompatibility_mode),
7768                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7769                        }
7770                    }
7771                }
7772                deserializer.deserialize_identifier(Visitor)
7773            }
7774        }
7775        struct Visitor;
7776        impl<'de> serde::de::Visitor<'de> for Visitor {
7777            type Value = ShipmentTypeIncompatibility;
7778            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7779                formatter.write_str("struct ShipmentTypeIncompatibility")
7780            }
7781            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7782            where
7783                A: serde::de::MapAccess<'de>,
7784            {
7785                #[allow(unused_imports)]
7786                use serde::de::Error;
7787                use std::option::Option::Some;
7788                let mut fields = std::collections::HashSet::new();
7789                let mut result = Self::Value::new();
7790                while let Some(tag) = map.next_key::<__FieldTag>()? {
7791                    #[allow(clippy::match_single_binding)]
7792                    match tag {
7793                        __FieldTag::__types => {
7794                            if !fields.insert(__FieldTag::__types) {
7795                                return std::result::Result::Err(A::Error::duplicate_field(
7796                                    "multiple values for types",
7797                                ));
7798                            }
7799                            result.types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7800                        }
7801                        __FieldTag::__incompatibility_mode => {
7802                            if !fields.insert(__FieldTag::__incompatibility_mode) {
7803                                return std::result::Result::Err(A::Error::duplicate_field(
7804                                    "multiple values for incompatibility_mode",
7805                                ));
7806                            }
7807                            result.incompatibility_mode = map.next_value::<std::option::Option<crate::model::shipment_type_incompatibility::IncompatibilityMode>>()?.unwrap_or_default();
7808                        }
7809                        __FieldTag::Unknown(key) => {
7810                            let value = map.next_value::<serde_json::Value>()?;
7811                            result._unknown_fields.insert(key, value);
7812                        }
7813                    }
7814                }
7815                std::result::Result::Ok(result)
7816            }
7817        }
7818        deserializer.deserialize_any(Visitor)
7819    }
7820}
7821
7822#[doc(hidden)]
7823impl serde::ser::Serialize for ShipmentTypeIncompatibility {
7824    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7825    where
7826        S: serde::ser::Serializer,
7827    {
7828        use serde::ser::SerializeMap;
7829        #[allow(unused_imports)]
7830        use std::option::Option::Some;
7831        let mut state = serializer.serialize_map(std::option::Option::None)?;
7832        if !self.types.is_empty() {
7833            state.serialize_entry("types", &self.types)?;
7834        }
7835        if !wkt::internal::is_default(&self.incompatibility_mode) {
7836            state.serialize_entry("incompatibilityMode", &self.incompatibility_mode)?;
7837        }
7838        if !self._unknown_fields.is_empty() {
7839            for (key, value) in self._unknown_fields.iter() {
7840                state.serialize_entry(key, &value)?;
7841            }
7842        }
7843        state.end()
7844    }
7845}
7846
7847impl std::fmt::Debug for ShipmentTypeIncompatibility {
7848    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7849        let mut debug_struct = f.debug_struct("ShipmentTypeIncompatibility");
7850        debug_struct.field("types", &self.types);
7851        debug_struct.field("incompatibility_mode", &self.incompatibility_mode);
7852        if !self._unknown_fields.is_empty() {
7853            debug_struct.field("_unknown_fields", &self._unknown_fields);
7854        }
7855        debug_struct.finish()
7856    }
7857}
7858
7859/// Defines additional types related to [ShipmentTypeIncompatibility].
7860pub mod shipment_type_incompatibility {
7861    #[allow(unused_imports)]
7862    use super::*;
7863
7864    /// Modes defining how the appearance of incompatible shipments are restricted
7865    /// on the same route.
7866    ///
7867    /// # Working with unknown values
7868    ///
7869    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7870    /// additional enum variants at any time. Adding new variants is not considered
7871    /// a breaking change. Applications should write their code in anticipation of:
7872    ///
7873    /// - New values appearing in future releases of the client library, **and**
7874    /// - New values received dynamically, without application changes.
7875    ///
7876    /// Please consult the [Working with enums] section in the user guide for some
7877    /// guidelines.
7878    ///
7879    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
7880    #[derive(Clone, Debug, PartialEq)]
7881    #[non_exhaustive]
7882    pub enum IncompatibilityMode {
7883        /// Unspecified incompatibility mode. This value should never be used.
7884        Unspecified,
7885        /// In this mode, two shipments with incompatible types can never share the
7886        /// same vehicle.
7887        NotPerformedBySameVehicle,
7888        /// For two shipments with incompatible types with the
7889        /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
7890        ///
7891        /// * If both are pickups only (no deliveries) or deliveries only (no
7892        ///   pickups), they cannot share the same vehicle at all.
7893        /// * If one of the shipments has a delivery and the other a pickup, the two
7894        ///   shipments can share the same vehicle iff the former shipment is
7895        ///   delivered before the latter is picked up.
7896        NotInSameVehicleSimultaneously,
7897        /// If set, the enum was initialized with an unknown value.
7898        ///
7899        /// Applications can examine the value using [IncompatibilityMode::value] or
7900        /// [IncompatibilityMode::name].
7901        UnknownValue(incompatibility_mode::UnknownValue),
7902    }
7903
7904    #[doc(hidden)]
7905    pub mod incompatibility_mode {
7906        #[allow(unused_imports)]
7907        use super::*;
7908        #[derive(Clone, Debug, PartialEq)]
7909        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7910    }
7911
7912    impl IncompatibilityMode {
7913        /// Gets the enum value.
7914        ///
7915        /// Returns `None` if the enum contains an unknown value deserialized from
7916        /// the string representation of enums.
7917        pub fn value(&self) -> std::option::Option<i32> {
7918            match self {
7919                Self::Unspecified => std::option::Option::Some(0),
7920                Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
7921                Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
7922                Self::UnknownValue(u) => u.0.value(),
7923            }
7924        }
7925
7926        /// Gets the enum value as a string.
7927        ///
7928        /// Returns `None` if the enum contains an unknown value deserialized from
7929        /// the integer representation of enums.
7930        pub fn name(&self) -> std::option::Option<&str> {
7931            match self {
7932                Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
7933                Self::NotPerformedBySameVehicle => {
7934                    std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
7935                }
7936                Self::NotInSameVehicleSimultaneously => {
7937                    std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
7938                }
7939                Self::UnknownValue(u) => u.0.name(),
7940            }
7941        }
7942    }
7943
7944    impl std::default::Default for IncompatibilityMode {
7945        fn default() -> Self {
7946            use std::convert::From;
7947            Self::from(0)
7948        }
7949    }
7950
7951    impl std::fmt::Display for IncompatibilityMode {
7952        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7953            wkt::internal::display_enum(f, self.name(), self.value())
7954        }
7955    }
7956
7957    impl std::convert::From<i32> for IncompatibilityMode {
7958        fn from(value: i32) -> Self {
7959            match value {
7960                0 => Self::Unspecified,
7961                1 => Self::NotPerformedBySameVehicle,
7962                2 => Self::NotInSameVehicleSimultaneously,
7963                _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
7964                    wkt::internal::UnknownEnumValue::Integer(value),
7965                )),
7966            }
7967        }
7968    }
7969
7970    impl std::convert::From<&str> for IncompatibilityMode {
7971        fn from(value: &str) -> Self {
7972            use std::string::ToString;
7973            match value {
7974                "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
7975                "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
7976                "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
7977                _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
7978                    wkt::internal::UnknownEnumValue::String(value.to_string()),
7979                )),
7980            }
7981        }
7982    }
7983
7984    impl serde::ser::Serialize for IncompatibilityMode {
7985        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7986        where
7987            S: serde::Serializer,
7988        {
7989            match self {
7990                Self::Unspecified => serializer.serialize_i32(0),
7991                Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
7992                Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
7993                Self::UnknownValue(u) => u.0.serialize(serializer),
7994            }
7995        }
7996    }
7997
7998    impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
7999        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8000        where
8001            D: serde::Deserializer<'de>,
8002        {
8003            deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
8004                ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
8005            ))
8006        }
8007    }
8008}
8009
8010/// Specifies requirements between shipments based on their shipment_type.
8011/// The specifics of the requirement are defined by the requirement mode.
8012#[derive(Clone, Default, PartialEq)]
8013#[non_exhaustive]
8014pub struct ShipmentTypeRequirement {
8015    /// List of alternative shipment types required by the
8016    /// `dependent_shipment_types`.
8017    pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
8018
8019    /// All shipments with a type in the `dependent_shipment_types` field require
8020    /// at least one shipment of type `required_shipment_type_alternatives` to be
8021    /// visited on the same route.
8022    ///
8023    /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
8024    /// are not allowed.
8025    pub dependent_shipment_types: std::vec::Vec<std::string::String>,
8026
8027    /// Mode applied to the requirement.
8028    pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
8029
8030    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8031}
8032
8033impl ShipmentTypeRequirement {
8034    pub fn new() -> Self {
8035        std::default::Default::default()
8036    }
8037
8038    /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
8039    pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
8040    where
8041        T: std::iter::IntoIterator<Item = V>,
8042        V: std::convert::Into<std::string::String>,
8043    {
8044        use std::iter::Iterator;
8045        self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
8046        self
8047    }
8048
8049    /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
8050    pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
8051    where
8052        T: std::iter::IntoIterator<Item = V>,
8053        V: std::convert::Into<std::string::String>,
8054    {
8055        use std::iter::Iterator;
8056        self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
8057        self
8058    }
8059
8060    /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
8061    pub fn set_requirement_mode<
8062        T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
8063    >(
8064        mut self,
8065        v: T,
8066    ) -> Self {
8067        self.requirement_mode = v.into();
8068        self
8069    }
8070}
8071
8072impl wkt::message::Message for ShipmentTypeRequirement {
8073    fn typename() -> &'static str {
8074        "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
8075    }
8076}
8077
8078#[doc(hidden)]
8079impl<'de> serde::de::Deserialize<'de> for ShipmentTypeRequirement {
8080    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8081    where
8082        D: serde::Deserializer<'de>,
8083    {
8084        #[allow(non_camel_case_types)]
8085        #[doc(hidden)]
8086        #[derive(PartialEq, Eq, Hash)]
8087        enum __FieldTag {
8088            __required_shipment_type_alternatives,
8089            __dependent_shipment_types,
8090            __requirement_mode,
8091            Unknown(std::string::String),
8092        }
8093        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8094            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8095            where
8096                D: serde::Deserializer<'de>,
8097            {
8098                struct Visitor;
8099                impl<'de> serde::de::Visitor<'de> for Visitor {
8100                    type Value = __FieldTag;
8101                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8102                        formatter.write_str("a field name for ShipmentTypeRequirement")
8103                    }
8104                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8105                    where
8106                        E: serde::de::Error,
8107                    {
8108                        use std::result::Result::Ok;
8109                        use std::string::ToString;
8110                        match value {
8111                            "requiredShipmentTypeAlternatives" => {
8112                                Ok(__FieldTag::__required_shipment_type_alternatives)
8113                            }
8114                            "required_shipment_type_alternatives" => {
8115                                Ok(__FieldTag::__required_shipment_type_alternatives)
8116                            }
8117                            "dependentShipmentTypes" => Ok(__FieldTag::__dependent_shipment_types),
8118                            "dependent_shipment_types" => {
8119                                Ok(__FieldTag::__dependent_shipment_types)
8120                            }
8121                            "requirementMode" => Ok(__FieldTag::__requirement_mode),
8122                            "requirement_mode" => Ok(__FieldTag::__requirement_mode),
8123                            _ => Ok(__FieldTag::Unknown(value.to_string())),
8124                        }
8125                    }
8126                }
8127                deserializer.deserialize_identifier(Visitor)
8128            }
8129        }
8130        struct Visitor;
8131        impl<'de> serde::de::Visitor<'de> for Visitor {
8132            type Value = ShipmentTypeRequirement;
8133            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8134                formatter.write_str("struct ShipmentTypeRequirement")
8135            }
8136            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8137            where
8138                A: serde::de::MapAccess<'de>,
8139            {
8140                #[allow(unused_imports)]
8141                use serde::de::Error;
8142                use std::option::Option::Some;
8143                let mut fields = std::collections::HashSet::new();
8144                let mut result = Self::Value::new();
8145                while let Some(tag) = map.next_key::<__FieldTag>()? {
8146                    #[allow(clippy::match_single_binding)]
8147                    match tag {
8148                        __FieldTag::__required_shipment_type_alternatives => {
8149                            if !fields.insert(__FieldTag::__required_shipment_type_alternatives) {
8150                                return std::result::Result::Err(A::Error::duplicate_field(
8151                                    "multiple values for required_shipment_type_alternatives",
8152                                ));
8153                            }
8154                            result.required_shipment_type_alternatives = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
8155                        }
8156                        __FieldTag::__dependent_shipment_types => {
8157                            if !fields.insert(__FieldTag::__dependent_shipment_types) {
8158                                return std::result::Result::Err(A::Error::duplicate_field(
8159                                    "multiple values for dependent_shipment_types",
8160                                ));
8161                            }
8162                            result.dependent_shipment_types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
8163                        }
8164                        __FieldTag::__requirement_mode => {
8165                            if !fields.insert(__FieldTag::__requirement_mode) {
8166                                return std::result::Result::Err(A::Error::duplicate_field(
8167                                    "multiple values for requirement_mode",
8168                                ));
8169                            }
8170                            result.requirement_mode = map
8171                                .next_value::<std::option::Option<
8172                                    crate::model::shipment_type_requirement::RequirementMode,
8173                                >>()?
8174                                .unwrap_or_default();
8175                        }
8176                        __FieldTag::Unknown(key) => {
8177                            let value = map.next_value::<serde_json::Value>()?;
8178                            result._unknown_fields.insert(key, value);
8179                        }
8180                    }
8181                }
8182                std::result::Result::Ok(result)
8183            }
8184        }
8185        deserializer.deserialize_any(Visitor)
8186    }
8187}
8188
8189#[doc(hidden)]
8190impl serde::ser::Serialize for ShipmentTypeRequirement {
8191    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8192    where
8193        S: serde::ser::Serializer,
8194    {
8195        use serde::ser::SerializeMap;
8196        #[allow(unused_imports)]
8197        use std::option::Option::Some;
8198        let mut state = serializer.serialize_map(std::option::Option::None)?;
8199        if !self.required_shipment_type_alternatives.is_empty() {
8200            state.serialize_entry(
8201                "requiredShipmentTypeAlternatives",
8202                &self.required_shipment_type_alternatives,
8203            )?;
8204        }
8205        if !self.dependent_shipment_types.is_empty() {
8206            state.serialize_entry("dependentShipmentTypes", &self.dependent_shipment_types)?;
8207        }
8208        if !wkt::internal::is_default(&self.requirement_mode) {
8209            state.serialize_entry("requirementMode", &self.requirement_mode)?;
8210        }
8211        if !self._unknown_fields.is_empty() {
8212            for (key, value) in self._unknown_fields.iter() {
8213                state.serialize_entry(key, &value)?;
8214            }
8215        }
8216        state.end()
8217    }
8218}
8219
8220impl std::fmt::Debug for ShipmentTypeRequirement {
8221    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8222        let mut debug_struct = f.debug_struct("ShipmentTypeRequirement");
8223        debug_struct.field(
8224            "required_shipment_type_alternatives",
8225            &self.required_shipment_type_alternatives,
8226        );
8227        debug_struct.field("dependent_shipment_types", &self.dependent_shipment_types);
8228        debug_struct.field("requirement_mode", &self.requirement_mode);
8229        if !self._unknown_fields.is_empty() {
8230            debug_struct.field("_unknown_fields", &self._unknown_fields);
8231        }
8232        debug_struct.finish()
8233    }
8234}
8235
8236/// Defines additional types related to [ShipmentTypeRequirement].
8237pub mod shipment_type_requirement {
8238    #[allow(unused_imports)]
8239    use super::*;
8240
8241    /// Modes defining the appearance of dependent shipments on a route.
8242    ///
8243    /// # Working with unknown values
8244    ///
8245    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8246    /// additional enum variants at any time. Adding new variants is not considered
8247    /// a breaking change. Applications should write their code in anticipation of:
8248    ///
8249    /// - New values appearing in future releases of the client library, **and**
8250    /// - New values received dynamically, without application changes.
8251    ///
8252    /// Please consult the [Working with enums] section in the user guide for some
8253    /// guidelines.
8254    ///
8255    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
8256    #[derive(Clone, Debug, PartialEq)]
8257    #[non_exhaustive]
8258    pub enum RequirementMode {
8259        /// Unspecified requirement mode. This value should never be used.
8260        Unspecified,
8261        /// In this mode, all "dependent" shipments must share the same vehicle as at
8262        /// least one of their "required" shipments.
8263        PerformedBySameVehicle,
8264        /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
8265        /// shipments need to have at least one "required" shipment on their vehicle
8266        /// at the time of their pickup.
8267        ///
8268        /// A "dependent" shipment pickup must therefore have either:
8269        ///
8270        /// * A delivery-only "required" shipment delivered on the route after, or
8271        /// * A "required" shipment picked up on the route before it, and if the
8272        ///   "required" shipment has a delivery, this delivery must be performed
8273        ///   after the "dependent" shipment's pickup.
8274        InSameVehicleAtPickupTime,
8275        /// Same as before, except the "dependent" shipments need to have a
8276        /// "required" shipment on their vehicle at the time of their *delivery*.
8277        InSameVehicleAtDeliveryTime,
8278        /// If set, the enum was initialized with an unknown value.
8279        ///
8280        /// Applications can examine the value using [RequirementMode::value] or
8281        /// [RequirementMode::name].
8282        UnknownValue(requirement_mode::UnknownValue),
8283    }
8284
8285    #[doc(hidden)]
8286    pub mod requirement_mode {
8287        #[allow(unused_imports)]
8288        use super::*;
8289        #[derive(Clone, Debug, PartialEq)]
8290        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8291    }
8292
8293    impl RequirementMode {
8294        /// Gets the enum value.
8295        ///
8296        /// Returns `None` if the enum contains an unknown value deserialized from
8297        /// the string representation of enums.
8298        pub fn value(&self) -> std::option::Option<i32> {
8299            match self {
8300                Self::Unspecified => std::option::Option::Some(0),
8301                Self::PerformedBySameVehicle => std::option::Option::Some(1),
8302                Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
8303                Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
8304                Self::UnknownValue(u) => u.0.value(),
8305            }
8306        }
8307
8308        /// Gets the enum value as a string.
8309        ///
8310        /// Returns `None` if the enum contains an unknown value deserialized from
8311        /// the integer representation of enums.
8312        pub fn name(&self) -> std::option::Option<&str> {
8313            match self {
8314                Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
8315                Self::PerformedBySameVehicle => {
8316                    std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
8317                }
8318                Self::InSameVehicleAtPickupTime => {
8319                    std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
8320                }
8321                Self::InSameVehicleAtDeliveryTime => {
8322                    std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
8323                }
8324                Self::UnknownValue(u) => u.0.name(),
8325            }
8326        }
8327    }
8328
8329    impl std::default::Default for RequirementMode {
8330        fn default() -> Self {
8331            use std::convert::From;
8332            Self::from(0)
8333        }
8334    }
8335
8336    impl std::fmt::Display for RequirementMode {
8337        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8338            wkt::internal::display_enum(f, self.name(), self.value())
8339        }
8340    }
8341
8342    impl std::convert::From<i32> for RequirementMode {
8343        fn from(value: i32) -> Self {
8344            match value {
8345                0 => Self::Unspecified,
8346                1 => Self::PerformedBySameVehicle,
8347                2 => Self::InSameVehicleAtPickupTime,
8348                3 => Self::InSameVehicleAtDeliveryTime,
8349                _ => Self::UnknownValue(requirement_mode::UnknownValue(
8350                    wkt::internal::UnknownEnumValue::Integer(value),
8351                )),
8352            }
8353        }
8354    }
8355
8356    impl std::convert::From<&str> for RequirementMode {
8357        fn from(value: &str) -> Self {
8358            use std::string::ToString;
8359            match value {
8360                "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
8361                "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
8362                "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
8363                "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
8364                _ => Self::UnknownValue(requirement_mode::UnknownValue(
8365                    wkt::internal::UnknownEnumValue::String(value.to_string()),
8366                )),
8367            }
8368        }
8369    }
8370
8371    impl serde::ser::Serialize for RequirementMode {
8372        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8373        where
8374            S: serde::Serializer,
8375        {
8376            match self {
8377                Self::Unspecified => serializer.serialize_i32(0),
8378                Self::PerformedBySameVehicle => serializer.serialize_i32(1),
8379                Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
8380                Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
8381                Self::UnknownValue(u) => u.0.serialize(serializer),
8382            }
8383        }
8384    }
8385
8386    impl<'de> serde::de::Deserialize<'de> for RequirementMode {
8387        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8388        where
8389            D: serde::Deserializer<'de>,
8390        {
8391            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
8392                ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
8393            ))
8394        }
8395    }
8396}
8397
8398/// Encapsulates a set of optional conditions to satisfy when calculating
8399/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
8400/// Platform API; see:
8401/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
8402#[derive(Clone, Default, PartialEq)]
8403#[non_exhaustive]
8404pub struct RouteModifiers {
8405    /// Specifies whether to avoid toll roads where reasonable. Preference will be
8406    /// given to routes not containing toll roads. Applies only to motorized travel
8407    /// modes.
8408    pub avoid_tolls: bool,
8409
8410    /// Specifies whether to avoid highways where reasonable. Preference will be
8411    /// given to routes not containing highways. Applies only to motorized travel
8412    /// modes.
8413    pub avoid_highways: bool,
8414
8415    /// Specifies whether to avoid ferries where reasonable. Preference will be
8416    /// given to routes not containing travel by ferries. Applies only to motorized
8417    /// travel modes.
8418    pub avoid_ferries: bool,
8419
8420    /// Optional. Specifies whether to avoid navigating indoors where reasonable.
8421    /// Preference will be given to routes not containing indoor navigation.
8422    /// Applies only to the `WALKING` travel mode.
8423    pub avoid_indoor: bool,
8424
8425    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8426}
8427
8428impl RouteModifiers {
8429    pub fn new() -> Self {
8430        std::default::Default::default()
8431    }
8432
8433    /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
8434    pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8435        self.avoid_tolls = v.into();
8436        self
8437    }
8438
8439    /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
8440    pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8441        self.avoid_highways = v.into();
8442        self
8443    }
8444
8445    /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
8446    pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8447        self.avoid_ferries = v.into();
8448        self
8449    }
8450
8451    /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
8452    pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8453        self.avoid_indoor = v.into();
8454        self
8455    }
8456}
8457
8458impl wkt::message::Message for RouteModifiers {
8459    fn typename() -> &'static str {
8460        "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
8461    }
8462}
8463
8464#[doc(hidden)]
8465impl<'de> serde::de::Deserialize<'de> for RouteModifiers {
8466    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8467    where
8468        D: serde::Deserializer<'de>,
8469    {
8470        #[allow(non_camel_case_types)]
8471        #[doc(hidden)]
8472        #[derive(PartialEq, Eq, Hash)]
8473        enum __FieldTag {
8474            __avoid_tolls,
8475            __avoid_highways,
8476            __avoid_ferries,
8477            __avoid_indoor,
8478            Unknown(std::string::String),
8479        }
8480        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8481            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8482            where
8483                D: serde::Deserializer<'de>,
8484            {
8485                struct Visitor;
8486                impl<'de> serde::de::Visitor<'de> for Visitor {
8487                    type Value = __FieldTag;
8488                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8489                        formatter.write_str("a field name for RouteModifiers")
8490                    }
8491                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8492                    where
8493                        E: serde::de::Error,
8494                    {
8495                        use std::result::Result::Ok;
8496                        use std::string::ToString;
8497                        match value {
8498                            "avoidTolls" => Ok(__FieldTag::__avoid_tolls),
8499                            "avoid_tolls" => Ok(__FieldTag::__avoid_tolls),
8500                            "avoidHighways" => Ok(__FieldTag::__avoid_highways),
8501                            "avoid_highways" => Ok(__FieldTag::__avoid_highways),
8502                            "avoidFerries" => Ok(__FieldTag::__avoid_ferries),
8503                            "avoid_ferries" => Ok(__FieldTag::__avoid_ferries),
8504                            "avoidIndoor" => Ok(__FieldTag::__avoid_indoor),
8505                            "avoid_indoor" => Ok(__FieldTag::__avoid_indoor),
8506                            _ => Ok(__FieldTag::Unknown(value.to_string())),
8507                        }
8508                    }
8509                }
8510                deserializer.deserialize_identifier(Visitor)
8511            }
8512        }
8513        struct Visitor;
8514        impl<'de> serde::de::Visitor<'de> for Visitor {
8515            type Value = RouteModifiers;
8516            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8517                formatter.write_str("struct RouteModifiers")
8518            }
8519            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8520            where
8521                A: serde::de::MapAccess<'de>,
8522            {
8523                #[allow(unused_imports)]
8524                use serde::de::Error;
8525                use std::option::Option::Some;
8526                let mut fields = std::collections::HashSet::new();
8527                let mut result = Self::Value::new();
8528                while let Some(tag) = map.next_key::<__FieldTag>()? {
8529                    #[allow(clippy::match_single_binding)]
8530                    match tag {
8531                        __FieldTag::__avoid_tolls => {
8532                            if !fields.insert(__FieldTag::__avoid_tolls) {
8533                                return std::result::Result::Err(A::Error::duplicate_field(
8534                                    "multiple values for avoid_tolls",
8535                                ));
8536                            }
8537                            result.avoid_tolls = map
8538                                .next_value::<std::option::Option<bool>>()?
8539                                .unwrap_or_default();
8540                        }
8541                        __FieldTag::__avoid_highways => {
8542                            if !fields.insert(__FieldTag::__avoid_highways) {
8543                                return std::result::Result::Err(A::Error::duplicate_field(
8544                                    "multiple values for avoid_highways",
8545                                ));
8546                            }
8547                            result.avoid_highways = map
8548                                .next_value::<std::option::Option<bool>>()?
8549                                .unwrap_or_default();
8550                        }
8551                        __FieldTag::__avoid_ferries => {
8552                            if !fields.insert(__FieldTag::__avoid_ferries) {
8553                                return std::result::Result::Err(A::Error::duplicate_field(
8554                                    "multiple values for avoid_ferries",
8555                                ));
8556                            }
8557                            result.avoid_ferries = map
8558                                .next_value::<std::option::Option<bool>>()?
8559                                .unwrap_or_default();
8560                        }
8561                        __FieldTag::__avoid_indoor => {
8562                            if !fields.insert(__FieldTag::__avoid_indoor) {
8563                                return std::result::Result::Err(A::Error::duplicate_field(
8564                                    "multiple values for avoid_indoor",
8565                                ));
8566                            }
8567                            result.avoid_indoor = map
8568                                .next_value::<std::option::Option<bool>>()?
8569                                .unwrap_or_default();
8570                        }
8571                        __FieldTag::Unknown(key) => {
8572                            let value = map.next_value::<serde_json::Value>()?;
8573                            result._unknown_fields.insert(key, value);
8574                        }
8575                    }
8576                }
8577                std::result::Result::Ok(result)
8578            }
8579        }
8580        deserializer.deserialize_any(Visitor)
8581    }
8582}
8583
8584#[doc(hidden)]
8585impl serde::ser::Serialize for RouteModifiers {
8586    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8587    where
8588        S: serde::ser::Serializer,
8589    {
8590        use serde::ser::SerializeMap;
8591        #[allow(unused_imports)]
8592        use std::option::Option::Some;
8593        let mut state = serializer.serialize_map(std::option::Option::None)?;
8594        if !wkt::internal::is_default(&self.avoid_tolls) {
8595            state.serialize_entry("avoidTolls", &self.avoid_tolls)?;
8596        }
8597        if !wkt::internal::is_default(&self.avoid_highways) {
8598            state.serialize_entry("avoidHighways", &self.avoid_highways)?;
8599        }
8600        if !wkt::internal::is_default(&self.avoid_ferries) {
8601            state.serialize_entry("avoidFerries", &self.avoid_ferries)?;
8602        }
8603        if !wkt::internal::is_default(&self.avoid_indoor) {
8604            state.serialize_entry("avoidIndoor", &self.avoid_indoor)?;
8605        }
8606        if !self._unknown_fields.is_empty() {
8607            for (key, value) in self._unknown_fields.iter() {
8608                state.serialize_entry(key, &value)?;
8609            }
8610        }
8611        state.end()
8612    }
8613}
8614
8615impl std::fmt::Debug for RouteModifiers {
8616    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8617        let mut debug_struct = f.debug_struct("RouteModifiers");
8618        debug_struct.field("avoid_tolls", &self.avoid_tolls);
8619        debug_struct.field("avoid_highways", &self.avoid_highways);
8620        debug_struct.field("avoid_ferries", &self.avoid_ferries);
8621        debug_struct.field("avoid_indoor", &self.avoid_indoor);
8622        if !self._unknown_fields.is_empty() {
8623            debug_struct.field("_unknown_fields", &self._unknown_fields);
8624        }
8625        debug_struct.finish()
8626    }
8627}
8628
8629/// Models a vehicle in a shipment problem. Solving a shipment problem will
8630/// build a route starting from `start_location` and ending at `end_location`
8631/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
8632#[derive(Clone, Default, PartialEq)]
8633#[non_exhaustive]
8634pub struct Vehicle {
8635    /// The travel mode which affects the roads usable by the vehicle and its
8636    /// speed. See also `travel_duration_multiple`.
8637    pub travel_mode: crate::model::vehicle::TravelMode,
8638
8639    /// Optional. A set of conditions to satisfy that affect the way routes are
8640    /// calculated for the given vehicle.
8641    pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
8642
8643    /// Geographic location where the vehicle starts before picking up any
8644    /// shipments. If not specified, the vehicle starts at its first pickup.
8645    /// If the shipment model has duration and distance matrices, `start_location`
8646    /// must not be specified.
8647    pub start_location: std::option::Option<gtype::model::LatLng>,
8648
8649    /// Waypoint representing a geographic location where the vehicle starts before
8650    /// picking up any shipments. If neither `start_waypoint` nor `start_location`
8651    /// is specified, the vehicle starts at its first pickup.
8652    /// If the shipment model has duration and distance matrices, `start_waypoint`
8653    /// must not be specified.
8654    pub start_waypoint: std::option::Option<crate::model::Waypoint>,
8655
8656    /// Geographic location where the vehicle ends after it has completed its last
8657    /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
8658    /// immediately when it completes its last `VisitRequest`.
8659    /// If the shipment model has duration and distance matrices, `end_location`
8660    /// must not be specified.
8661    pub end_location: std::option::Option<gtype::model::LatLng>,
8662
8663    /// Waypoint representing a geographic location where the vehicle ends after
8664    /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
8665    /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
8666    /// when it completes its last `VisitRequest`.
8667    /// If the shipment model has duration and distance matrices, `end_waypoint`
8668    /// must not be specified.
8669    pub end_waypoint: std::option::Option<crate::model::Waypoint>,
8670
8671    /// Specifies tags attached to the start of the vehicle's route.
8672    ///
8673    /// Empty or duplicate strings are not allowed.
8674    pub start_tags: std::vec::Vec<std::string::String>,
8675
8676    /// Specifies tags attached to the end of the vehicle's route.
8677    ///
8678    /// Empty or duplicate strings are not allowed.
8679    pub end_tags: std::vec::Vec<std::string::String>,
8680
8681    /// Time windows during which the vehicle may depart its start location.
8682    /// They must be within the global time limits (see
8683    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
8684    /// fields). If unspecified, there is no limitation besides those global time
8685    /// limits.
8686    ///
8687    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
8688    /// time window can overlap with or be adjacent to another, and they must be in
8689    /// chronological order.
8690    ///
8691    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
8692    /// there is a single time window.
8693    ///
8694    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
8695    pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
8696
8697    /// Time windows during which the vehicle may arrive at its end location.
8698    /// They must be within the global time limits (see
8699    /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
8700    /// fields). If unspecified, there is no limitation besides those global time
8701    /// limits.
8702    ///
8703    /// Time windows belonging to the same repeated field must be disjoint, i.e. no
8704    /// time window can overlap with or be adjacent to another, and they must be in
8705    /// chronological order.
8706    ///
8707    /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
8708    /// there is a single time window.
8709    ///
8710    /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
8711    pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
8712
8713    /// Specifies a multiplicative factor that can be used to increase or decrease
8714    /// travel times of this vehicle. For example, setting this to 2.0 means
8715    /// that this vehicle is slower and has travel times that are twice what they
8716    /// are for standard vehicles. This multiple does not affect visit durations.
8717    /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
8718    /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
8719    /// is standard, and this multiple is considered 1.0.
8720    ///
8721    /// WARNING: Travel times will be rounded to the nearest second after this
8722    /// multiple is applied but before performing any numerical operations, thus,
8723    /// a small multiple may result in a loss of precision.
8724    ///
8725    /// See also `extra_visit_duration_for_visit_type` below.
8726    pub travel_duration_multiple: std::option::Option<f64>,
8727
8728    /// Unloading policy enforced on the vehicle.
8729    pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
8730
8731    /// Capacities of the vehicle (weight, volume, # of pallets for example).
8732    /// The keys in the map are the identifiers of the type of load, consistent
8733    /// with the keys of the
8734    /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
8735    /// field. If a given key is absent from this map, the corresponding capacity
8736    /// is considered to be limitless.
8737    ///
8738    /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
8739    pub load_limits:
8740        std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
8741
8742    /// Vehicle costs: all costs add up and must be in the same unit as
8743    /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
8744    ///
8745    /// Cost per hour of the vehicle route. This cost is applied to the total time
8746    /// taken by the route, and includes travel time, waiting time, and visit time.
8747    /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
8748    /// in additional latency.
8749    ///
8750    /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
8751    pub cost_per_hour: f64,
8752
8753    /// Cost per traveled hour of the vehicle route. This cost is applied only to
8754    /// travel time taken by the route (i.e., that reported in
8755    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
8756    /// and excludes waiting time and visit time.
8757    ///
8758    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8759    pub cost_per_traveled_hour: f64,
8760
8761    /// Cost per kilometer of the vehicle route. This cost is applied to the
8762    /// distance reported in the
8763    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8764    /// and does not apply to any distance implicitly traveled from the
8765    /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
8766    ///
8767    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8768    pub cost_per_kilometer: f64,
8769
8770    /// Fixed cost applied if this vehicle is used to handle a shipment.
8771    pub fixed_cost: f64,
8772
8773    /// This field only applies to vehicles when their route does not serve any
8774    /// shipments. It indicates if the vehicle should be considered as used or not
8775    /// in this case.
8776    ///
8777    /// If true, the vehicle goes from its start to its end location even if it
8778    /// doesn't serve any shipments, and time and distance costs resulting from its
8779    /// start --> end travel are taken into account.
8780    ///
8781    /// Otherwise, it doesn't travel from its start to its end location, and no
8782    /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
8783    /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
8784    /// information except for the vehicle index and label.
8785    pub used_if_route_is_empty: bool,
8786
8787    /// Limit applied to the total duration of the vehicle's route. In a given
8788    /// `OptimizeToursResponse`, the route duration of a vehicle is the
8789    /// difference between its `vehicle_end_time` and `vehicle_start_time`.
8790    pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
8791
8792    /// Limit applied to the travel duration of the vehicle's route. In a given
8793    /// `OptimizeToursResponse`, the route travel duration is the sum of all its
8794    /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
8795    ///
8796    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
8797    pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
8798
8799    /// Limit applied to the total distance of the vehicle's route. In a given
8800    /// `OptimizeToursResponse`, the route distance is the sum of all its
8801    /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
8802    ///
8803    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
8804    pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
8805
8806    /// Specifies a map from visit_types strings to durations. The duration is time
8807    /// in addition to
8808    /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
8809    /// to be taken at visits with the specified `visit_types`. This extra visit
8810    /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
8811    /// `visit_types`) cannot be empty strings.
8812    ///
8813    /// If a visit request has multiple types, a duration will be added for each
8814    /// type in the map.
8815    ///
8816    /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
8817    pub extra_visit_duration_for_visit_type:
8818        std::collections::HashMap<std::string::String, wkt::Duration>,
8819
8820    /// Describes the break schedule to be enforced on this vehicle.
8821    /// If empty, no breaks will be scheduled for this vehicle.
8822    pub break_rule: std::option::Option<crate::model::BreakRule>,
8823
8824    /// Specifies a label for this vehicle. This label is reported in the response
8825    /// as the `vehicle_label` of the corresponding
8826    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
8827    ///
8828    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
8829    pub label: std::string::String,
8830
8831    /// If true, `used_if_route_is_empty` must be false, and this vehicle will
8832    /// remain unused.
8833    ///
8834    /// If a shipment is performed by an ignored vehicle in
8835    /// `injected_first_solution_routes`, it is skipped in the first solution but
8836    /// is free to be performed in the response.
8837    ///
8838    /// If a shipment is performed by an ignored vehicle in
8839    /// `injected_solution_constraint` and any related pickup/delivery is
8840    /// constrained to remain on the vehicle (i.e., not relaxed to level
8841    /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
8842    /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
8843    /// the allowed vehicles are ignored, it is skipped in the response.
8844    pub ignore: bool,
8845
8846    /// Deprecated: No longer used.
8847    /// Indices in the `break_rule` field in the source
8848    /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
8849    /// correspond to break rules enforced on the vehicle.
8850    ///
8851    /// As of 2018/03, at most one rule index per vehicle can be specified.
8852    ///
8853    /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
8854    #[deprecated]
8855    pub break_rule_indices: std::vec::Vec<i32>,
8856
8857    /// Deprecated: Use
8858    /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
8859    /// instead.
8860    ///
8861    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
8862    #[deprecated]
8863    pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
8864
8865    /// Deprecated: Use
8866    /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
8867    /// instead.
8868    ///
8869    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
8870    #[deprecated]
8871    pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
8872
8873    /// Deprecated: Use
8874    /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
8875    /// instead.
8876    ///
8877    /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
8878    #[deprecated]
8879    pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
8880
8881    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8882}
8883
8884impl Vehicle {
8885    pub fn new() -> Self {
8886        std::default::Default::default()
8887    }
8888
8889    /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
8890    pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
8891        mut self,
8892        v: T,
8893    ) -> Self {
8894        self.travel_mode = v.into();
8895        self
8896    }
8897
8898    /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
8899    pub fn set_route_modifiers<T>(mut self, v: T) -> Self
8900    where
8901        T: std::convert::Into<crate::model::RouteModifiers>,
8902    {
8903        self.route_modifiers = std::option::Option::Some(v.into());
8904        self
8905    }
8906
8907    /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
8908    pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
8909    where
8910        T: std::convert::Into<crate::model::RouteModifiers>,
8911    {
8912        self.route_modifiers = v.map(|x| x.into());
8913        self
8914    }
8915
8916    /// Sets the value of [start_location][crate::model::Vehicle::start_location].
8917    pub fn set_start_location<T>(mut self, v: T) -> Self
8918    where
8919        T: std::convert::Into<gtype::model::LatLng>,
8920    {
8921        self.start_location = std::option::Option::Some(v.into());
8922        self
8923    }
8924
8925    /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
8926    pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
8927    where
8928        T: std::convert::Into<gtype::model::LatLng>,
8929    {
8930        self.start_location = v.map(|x| x.into());
8931        self
8932    }
8933
8934    /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
8935    pub fn set_start_waypoint<T>(mut self, v: T) -> Self
8936    where
8937        T: std::convert::Into<crate::model::Waypoint>,
8938    {
8939        self.start_waypoint = std::option::Option::Some(v.into());
8940        self
8941    }
8942
8943    /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
8944    pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
8945    where
8946        T: std::convert::Into<crate::model::Waypoint>,
8947    {
8948        self.start_waypoint = v.map(|x| x.into());
8949        self
8950    }
8951
8952    /// Sets the value of [end_location][crate::model::Vehicle::end_location].
8953    pub fn set_end_location<T>(mut self, v: T) -> Self
8954    where
8955        T: std::convert::Into<gtype::model::LatLng>,
8956    {
8957        self.end_location = std::option::Option::Some(v.into());
8958        self
8959    }
8960
8961    /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
8962    pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
8963    where
8964        T: std::convert::Into<gtype::model::LatLng>,
8965    {
8966        self.end_location = v.map(|x| x.into());
8967        self
8968    }
8969
8970    /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
8971    pub fn set_end_waypoint<T>(mut self, v: T) -> Self
8972    where
8973        T: std::convert::Into<crate::model::Waypoint>,
8974    {
8975        self.end_waypoint = std::option::Option::Some(v.into());
8976        self
8977    }
8978
8979    /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
8980    pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
8981    where
8982        T: std::convert::Into<crate::model::Waypoint>,
8983    {
8984        self.end_waypoint = v.map(|x| x.into());
8985        self
8986    }
8987
8988    /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
8989    pub fn set_start_tags<T, V>(mut self, v: T) -> Self
8990    where
8991        T: std::iter::IntoIterator<Item = V>,
8992        V: std::convert::Into<std::string::String>,
8993    {
8994        use std::iter::Iterator;
8995        self.start_tags = v.into_iter().map(|i| i.into()).collect();
8996        self
8997    }
8998
8999    /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
9000    pub fn set_end_tags<T, V>(mut self, v: T) -> Self
9001    where
9002        T: std::iter::IntoIterator<Item = V>,
9003        V: std::convert::Into<std::string::String>,
9004    {
9005        use std::iter::Iterator;
9006        self.end_tags = v.into_iter().map(|i| i.into()).collect();
9007        self
9008    }
9009
9010    /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
9011    pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
9012    where
9013        T: std::iter::IntoIterator<Item = V>,
9014        V: std::convert::Into<crate::model::TimeWindow>,
9015    {
9016        use std::iter::Iterator;
9017        self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
9018        self
9019    }
9020
9021    /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
9022    pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
9023    where
9024        T: std::iter::IntoIterator<Item = V>,
9025        V: std::convert::Into<crate::model::TimeWindow>,
9026    {
9027        use std::iter::Iterator;
9028        self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
9029        self
9030    }
9031
9032    /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
9033    pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
9034    where
9035        T: std::convert::Into<f64>,
9036    {
9037        self.travel_duration_multiple = std::option::Option::Some(v.into());
9038        self
9039    }
9040
9041    /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
9042    pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
9043    where
9044        T: std::convert::Into<f64>,
9045    {
9046        self.travel_duration_multiple = v.map(|x| x.into());
9047        self
9048    }
9049
9050    /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
9051    pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
9052        mut self,
9053        v: T,
9054    ) -> Self {
9055        self.unloading_policy = v.into();
9056        self
9057    }
9058
9059    /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
9060    pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
9061    where
9062        T: std::iter::IntoIterator<Item = (K, V)>,
9063        K: std::convert::Into<std::string::String>,
9064        V: std::convert::Into<crate::model::vehicle::LoadLimit>,
9065    {
9066        use std::iter::Iterator;
9067        self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
9068        self
9069    }
9070
9071    /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
9072    pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9073        self.cost_per_hour = v.into();
9074        self
9075    }
9076
9077    /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
9078    pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9079        self.cost_per_traveled_hour = v.into();
9080        self
9081    }
9082
9083    /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
9084    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9085        self.cost_per_kilometer = v.into();
9086        self
9087    }
9088
9089    /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
9090    pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9091        self.fixed_cost = v.into();
9092        self
9093    }
9094
9095    /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
9096    pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9097        self.used_if_route_is_empty = v.into();
9098        self
9099    }
9100
9101    /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
9102    pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
9103    where
9104        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
9105    {
9106        self.route_duration_limit = std::option::Option::Some(v.into());
9107        self
9108    }
9109
9110    /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
9111    pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
9112    where
9113        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
9114    {
9115        self.route_duration_limit = v.map(|x| x.into());
9116        self
9117    }
9118
9119    /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
9120    pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
9121    where
9122        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
9123    {
9124        self.travel_duration_limit = std::option::Option::Some(v.into());
9125        self
9126    }
9127
9128    /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
9129    pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
9130    where
9131        T: std::convert::Into<crate::model::vehicle::DurationLimit>,
9132    {
9133        self.travel_duration_limit = v.map(|x| x.into());
9134        self
9135    }
9136
9137    /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
9138    pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
9139    where
9140        T: std::convert::Into<crate::model::DistanceLimit>,
9141    {
9142        self.route_distance_limit = std::option::Option::Some(v.into());
9143        self
9144    }
9145
9146    /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
9147    pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
9148    where
9149        T: std::convert::Into<crate::model::DistanceLimit>,
9150    {
9151        self.route_distance_limit = v.map(|x| x.into());
9152        self
9153    }
9154
9155    /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
9156    pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
9157    where
9158        T: std::iter::IntoIterator<Item = (K, V)>,
9159        K: std::convert::Into<std::string::String>,
9160        V: std::convert::Into<wkt::Duration>,
9161    {
9162        use std::iter::Iterator;
9163        self.extra_visit_duration_for_visit_type =
9164            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
9165        self
9166    }
9167
9168    /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
9169    pub fn set_break_rule<T>(mut self, v: T) -> Self
9170    where
9171        T: std::convert::Into<crate::model::BreakRule>,
9172    {
9173        self.break_rule = std::option::Option::Some(v.into());
9174        self
9175    }
9176
9177    /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
9178    pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
9179    where
9180        T: std::convert::Into<crate::model::BreakRule>,
9181    {
9182        self.break_rule = v.map(|x| x.into());
9183        self
9184    }
9185
9186    /// Sets the value of [label][crate::model::Vehicle::label].
9187    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9188        self.label = v.into();
9189        self
9190    }
9191
9192    /// Sets the value of [ignore][crate::model::Vehicle::ignore].
9193    pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9194        self.ignore = v.into();
9195        self
9196    }
9197
9198    /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
9199    #[deprecated]
9200    pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
9201    where
9202        T: std::iter::IntoIterator<Item = V>,
9203        V: std::convert::Into<i32>,
9204    {
9205        use std::iter::Iterator;
9206        self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
9207        self
9208    }
9209
9210    /// Sets the value of [capacities][crate::model::Vehicle::capacities].
9211    #[deprecated]
9212    pub fn set_capacities<T, V>(mut self, v: T) -> Self
9213    where
9214        T: std::iter::IntoIterator<Item = V>,
9215        V: std::convert::Into<crate::model::CapacityQuantity>,
9216    {
9217        use std::iter::Iterator;
9218        self.capacities = v.into_iter().map(|i| i.into()).collect();
9219        self
9220    }
9221
9222    /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
9223    #[deprecated]
9224    pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
9225    where
9226        T: std::iter::IntoIterator<Item = V>,
9227        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
9228    {
9229        use std::iter::Iterator;
9230        self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
9231        self
9232    }
9233
9234    /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
9235    #[deprecated]
9236    pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
9237    where
9238        T: std::iter::IntoIterator<Item = V>,
9239        V: std::convert::Into<crate::model::CapacityQuantityInterval>,
9240    {
9241        use std::iter::Iterator;
9242        self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
9243        self
9244    }
9245}
9246
9247impl wkt::message::Message for Vehicle {
9248    fn typename() -> &'static str {
9249        "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
9250    }
9251}
9252
9253#[doc(hidden)]
9254impl<'de> serde::de::Deserialize<'de> for Vehicle {
9255    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9256    where
9257        D: serde::Deserializer<'de>,
9258    {
9259        #[allow(non_camel_case_types)]
9260        #[doc(hidden)]
9261        #[derive(PartialEq, Eq, Hash)]
9262        enum __FieldTag {
9263            __travel_mode,
9264            __route_modifiers,
9265            __start_location,
9266            __start_waypoint,
9267            __end_location,
9268            __end_waypoint,
9269            __start_tags,
9270            __end_tags,
9271            __start_time_windows,
9272            __end_time_windows,
9273            __travel_duration_multiple,
9274            __unloading_policy,
9275            __load_limits,
9276            __cost_per_hour,
9277            __cost_per_traveled_hour,
9278            __cost_per_kilometer,
9279            __fixed_cost,
9280            __used_if_route_is_empty,
9281            __route_duration_limit,
9282            __travel_duration_limit,
9283            __route_distance_limit,
9284            __extra_visit_duration_for_visit_type,
9285            __break_rule,
9286            __label,
9287            __ignore,
9288            __break_rule_indices,
9289            __capacities,
9290            __start_load_intervals,
9291            __end_load_intervals,
9292            Unknown(std::string::String),
9293        }
9294        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9295            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9296            where
9297                D: serde::Deserializer<'de>,
9298            {
9299                struct Visitor;
9300                impl<'de> serde::de::Visitor<'de> for Visitor {
9301                    type Value = __FieldTag;
9302                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9303                        formatter.write_str("a field name for Vehicle")
9304                    }
9305                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
9306                    where
9307                        E: serde::de::Error,
9308                    {
9309                        use std::result::Result::Ok;
9310                        use std::string::ToString;
9311                        match value {
9312                            "travelMode" => Ok(__FieldTag::__travel_mode),
9313                            "travel_mode" => Ok(__FieldTag::__travel_mode),
9314                            "routeModifiers" => Ok(__FieldTag::__route_modifiers),
9315                            "route_modifiers" => Ok(__FieldTag::__route_modifiers),
9316                            "startLocation" => Ok(__FieldTag::__start_location),
9317                            "start_location" => Ok(__FieldTag::__start_location),
9318                            "startWaypoint" => Ok(__FieldTag::__start_waypoint),
9319                            "start_waypoint" => Ok(__FieldTag::__start_waypoint),
9320                            "endLocation" => Ok(__FieldTag::__end_location),
9321                            "end_location" => Ok(__FieldTag::__end_location),
9322                            "endWaypoint" => Ok(__FieldTag::__end_waypoint),
9323                            "end_waypoint" => Ok(__FieldTag::__end_waypoint),
9324                            "startTags" => Ok(__FieldTag::__start_tags),
9325                            "start_tags" => Ok(__FieldTag::__start_tags),
9326                            "endTags" => Ok(__FieldTag::__end_tags),
9327                            "end_tags" => Ok(__FieldTag::__end_tags),
9328                            "startTimeWindows" => Ok(__FieldTag::__start_time_windows),
9329                            "start_time_windows" => Ok(__FieldTag::__start_time_windows),
9330                            "endTimeWindows" => Ok(__FieldTag::__end_time_windows),
9331                            "end_time_windows" => Ok(__FieldTag::__end_time_windows),
9332                            "travelDurationMultiple" => Ok(__FieldTag::__travel_duration_multiple),
9333                            "travel_duration_multiple" => {
9334                                Ok(__FieldTag::__travel_duration_multiple)
9335                            }
9336                            "unloadingPolicy" => Ok(__FieldTag::__unloading_policy),
9337                            "unloading_policy" => Ok(__FieldTag::__unloading_policy),
9338                            "loadLimits" => Ok(__FieldTag::__load_limits),
9339                            "load_limits" => Ok(__FieldTag::__load_limits),
9340                            "costPerHour" => Ok(__FieldTag::__cost_per_hour),
9341                            "cost_per_hour" => Ok(__FieldTag::__cost_per_hour),
9342                            "costPerTraveledHour" => Ok(__FieldTag::__cost_per_traveled_hour),
9343                            "cost_per_traveled_hour" => Ok(__FieldTag::__cost_per_traveled_hour),
9344                            "costPerKilometer" => Ok(__FieldTag::__cost_per_kilometer),
9345                            "cost_per_kilometer" => Ok(__FieldTag::__cost_per_kilometer),
9346                            "fixedCost" => Ok(__FieldTag::__fixed_cost),
9347                            "fixed_cost" => Ok(__FieldTag::__fixed_cost),
9348                            "usedIfRouteIsEmpty" => Ok(__FieldTag::__used_if_route_is_empty),
9349                            "used_if_route_is_empty" => Ok(__FieldTag::__used_if_route_is_empty),
9350                            "routeDurationLimit" => Ok(__FieldTag::__route_duration_limit),
9351                            "route_duration_limit" => Ok(__FieldTag::__route_duration_limit),
9352                            "travelDurationLimit" => Ok(__FieldTag::__travel_duration_limit),
9353                            "travel_duration_limit" => Ok(__FieldTag::__travel_duration_limit),
9354                            "routeDistanceLimit" => Ok(__FieldTag::__route_distance_limit),
9355                            "route_distance_limit" => Ok(__FieldTag::__route_distance_limit),
9356                            "extraVisitDurationForVisitType" => {
9357                                Ok(__FieldTag::__extra_visit_duration_for_visit_type)
9358                            }
9359                            "extra_visit_duration_for_visit_type" => {
9360                                Ok(__FieldTag::__extra_visit_duration_for_visit_type)
9361                            }
9362                            "breakRule" => Ok(__FieldTag::__break_rule),
9363                            "break_rule" => Ok(__FieldTag::__break_rule),
9364                            "label" => Ok(__FieldTag::__label),
9365                            "ignore" => Ok(__FieldTag::__ignore),
9366                            "breakRuleIndices" => Ok(__FieldTag::__break_rule_indices),
9367                            "break_rule_indices" => Ok(__FieldTag::__break_rule_indices),
9368                            "capacities" => Ok(__FieldTag::__capacities),
9369                            "startLoadIntervals" => Ok(__FieldTag::__start_load_intervals),
9370                            "start_load_intervals" => Ok(__FieldTag::__start_load_intervals),
9371                            "endLoadIntervals" => Ok(__FieldTag::__end_load_intervals),
9372                            "end_load_intervals" => Ok(__FieldTag::__end_load_intervals),
9373                            _ => Ok(__FieldTag::Unknown(value.to_string())),
9374                        }
9375                    }
9376                }
9377                deserializer.deserialize_identifier(Visitor)
9378            }
9379        }
9380        struct Visitor;
9381        impl<'de> serde::de::Visitor<'de> for Visitor {
9382            type Value = Vehicle;
9383            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9384                formatter.write_str("struct Vehicle")
9385            }
9386            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9387            where
9388                A: serde::de::MapAccess<'de>,
9389            {
9390                #[allow(unused_imports)]
9391                use serde::de::Error;
9392                use std::option::Option::Some;
9393                let mut fields = std::collections::HashSet::new();
9394                let mut result = Self::Value::new();
9395                while let Some(tag) = map.next_key::<__FieldTag>()? {
9396                    #[allow(clippy::match_single_binding)]
9397                    match tag {
9398                        __FieldTag::__travel_mode => {
9399                            if !fields.insert(__FieldTag::__travel_mode) {
9400                                return std::result::Result::Err(A::Error::duplicate_field(
9401                                    "multiple values for travel_mode",
9402                                ));
9403                            }
9404                            result.travel_mode = map.next_value::<std::option::Option<crate::model::vehicle::TravelMode>>()?.unwrap_or_default();
9405                        }
9406                        __FieldTag::__route_modifiers => {
9407                            if !fields.insert(__FieldTag::__route_modifiers) {
9408                                return std::result::Result::Err(A::Error::duplicate_field(
9409                                    "multiple values for route_modifiers",
9410                                ));
9411                            }
9412                            result.route_modifiers = map
9413                                .next_value::<std::option::Option<crate::model::RouteModifiers>>(
9414                                )?;
9415                        }
9416                        __FieldTag::__start_location => {
9417                            if !fields.insert(__FieldTag::__start_location) {
9418                                return std::result::Result::Err(A::Error::duplicate_field(
9419                                    "multiple values for start_location",
9420                                ));
9421                            }
9422                            result.start_location =
9423                                map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
9424                        }
9425                        __FieldTag::__start_waypoint => {
9426                            if !fields.insert(__FieldTag::__start_waypoint) {
9427                                return std::result::Result::Err(A::Error::duplicate_field(
9428                                    "multiple values for start_waypoint",
9429                                ));
9430                            }
9431                            result.start_waypoint =
9432                                map.next_value::<std::option::Option<crate::model::Waypoint>>()?;
9433                        }
9434                        __FieldTag::__end_location => {
9435                            if !fields.insert(__FieldTag::__end_location) {
9436                                return std::result::Result::Err(A::Error::duplicate_field(
9437                                    "multiple values for end_location",
9438                                ));
9439                            }
9440                            result.end_location =
9441                                map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
9442                        }
9443                        __FieldTag::__end_waypoint => {
9444                            if !fields.insert(__FieldTag::__end_waypoint) {
9445                                return std::result::Result::Err(A::Error::duplicate_field(
9446                                    "multiple values for end_waypoint",
9447                                ));
9448                            }
9449                            result.end_waypoint =
9450                                map.next_value::<std::option::Option<crate::model::Waypoint>>()?;
9451                        }
9452                        __FieldTag::__start_tags => {
9453                            if !fields.insert(__FieldTag::__start_tags) {
9454                                return std::result::Result::Err(A::Error::duplicate_field(
9455                                    "multiple values for start_tags",
9456                                ));
9457                            }
9458                            result.start_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
9459                        }
9460                        __FieldTag::__end_tags => {
9461                            if !fields.insert(__FieldTag::__end_tags) {
9462                                return std::result::Result::Err(A::Error::duplicate_field(
9463                                    "multiple values for end_tags",
9464                                ));
9465                            }
9466                            result.end_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
9467                        }
9468                        __FieldTag::__start_time_windows => {
9469                            if !fields.insert(__FieldTag::__start_time_windows) {
9470                                return std::result::Result::Err(A::Error::duplicate_field(
9471                                    "multiple values for start_time_windows",
9472                                ));
9473                            }
9474                            result.start_time_windows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::TimeWindow>>>()?.unwrap_or_default();
9475                        }
9476                        __FieldTag::__end_time_windows => {
9477                            if !fields.insert(__FieldTag::__end_time_windows) {
9478                                return std::result::Result::Err(A::Error::duplicate_field(
9479                                    "multiple values for end_time_windows",
9480                                ));
9481                            }
9482                            result.end_time_windows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::TimeWindow>>>()?.unwrap_or_default();
9483                        }
9484                        __FieldTag::__travel_duration_multiple => {
9485                            if !fields.insert(__FieldTag::__travel_duration_multiple) {
9486                                return std::result::Result::Err(A::Error::duplicate_field(
9487                                    "multiple values for travel_duration_multiple",
9488                                ));
9489                            }
9490                            struct __With(std::option::Option<f64>);
9491                            impl<'de> serde::de::Deserialize<'de> for __With {
9492                                fn deserialize<D>(
9493                                    deserializer: D,
9494                                ) -> std::result::Result<Self, D::Error>
9495                                where
9496                                    D: serde::de::Deserializer<'de>,
9497                                {
9498                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9499                                }
9500                            }
9501                            result.travel_duration_multiple = map.next_value::<__With>()?.0;
9502                        }
9503                        __FieldTag::__unloading_policy => {
9504                            if !fields.insert(__FieldTag::__unloading_policy) {
9505                                return std::result::Result::Err(A::Error::duplicate_field(
9506                                    "multiple values for unloading_policy",
9507                                ));
9508                            }
9509                            result.unloading_policy = map.next_value::<std::option::Option<crate::model::vehicle::UnloadingPolicy>>()?.unwrap_or_default();
9510                        }
9511                        __FieldTag::__load_limits => {
9512                            if !fields.insert(__FieldTag::__load_limits) {
9513                                return std::result::Result::Err(A::Error::duplicate_field(
9514                                    "multiple values for load_limits",
9515                                ));
9516                            }
9517                            result.load_limits = map
9518                                .next_value::<std::option::Option<
9519                                    std::collections::HashMap<
9520                                        std::string::String,
9521                                        crate::model::vehicle::LoadLimit,
9522                                    >,
9523                                >>()?
9524                                .unwrap_or_default();
9525                        }
9526                        __FieldTag::__cost_per_hour => {
9527                            if !fields.insert(__FieldTag::__cost_per_hour) {
9528                                return std::result::Result::Err(A::Error::duplicate_field(
9529                                    "multiple values for cost_per_hour",
9530                                ));
9531                            }
9532                            struct __With(std::option::Option<f64>);
9533                            impl<'de> serde::de::Deserialize<'de> for __With {
9534                                fn deserialize<D>(
9535                                    deserializer: D,
9536                                ) -> std::result::Result<Self, D::Error>
9537                                where
9538                                    D: serde::de::Deserializer<'de>,
9539                                {
9540                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9541                                }
9542                            }
9543                            result.cost_per_hour =
9544                                map.next_value::<__With>()?.0.unwrap_or_default();
9545                        }
9546                        __FieldTag::__cost_per_traveled_hour => {
9547                            if !fields.insert(__FieldTag::__cost_per_traveled_hour) {
9548                                return std::result::Result::Err(A::Error::duplicate_field(
9549                                    "multiple values for cost_per_traveled_hour",
9550                                ));
9551                            }
9552                            struct __With(std::option::Option<f64>);
9553                            impl<'de> serde::de::Deserialize<'de> for __With {
9554                                fn deserialize<D>(
9555                                    deserializer: D,
9556                                ) -> std::result::Result<Self, D::Error>
9557                                where
9558                                    D: serde::de::Deserializer<'de>,
9559                                {
9560                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9561                                }
9562                            }
9563                            result.cost_per_traveled_hour =
9564                                map.next_value::<__With>()?.0.unwrap_or_default();
9565                        }
9566                        __FieldTag::__cost_per_kilometer => {
9567                            if !fields.insert(__FieldTag::__cost_per_kilometer) {
9568                                return std::result::Result::Err(A::Error::duplicate_field(
9569                                    "multiple values for cost_per_kilometer",
9570                                ));
9571                            }
9572                            struct __With(std::option::Option<f64>);
9573                            impl<'de> serde::de::Deserialize<'de> for __With {
9574                                fn deserialize<D>(
9575                                    deserializer: D,
9576                                ) -> std::result::Result<Self, D::Error>
9577                                where
9578                                    D: serde::de::Deserializer<'de>,
9579                                {
9580                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9581                                }
9582                            }
9583                            result.cost_per_kilometer =
9584                                map.next_value::<__With>()?.0.unwrap_or_default();
9585                        }
9586                        __FieldTag::__fixed_cost => {
9587                            if !fields.insert(__FieldTag::__fixed_cost) {
9588                                return std::result::Result::Err(A::Error::duplicate_field(
9589                                    "multiple values for fixed_cost",
9590                                ));
9591                            }
9592                            struct __With(std::option::Option<f64>);
9593                            impl<'de> serde::de::Deserialize<'de> for __With {
9594                                fn deserialize<D>(
9595                                    deserializer: D,
9596                                ) -> std::result::Result<Self, D::Error>
9597                                where
9598                                    D: serde::de::Deserializer<'de>,
9599                                {
9600                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9601                                }
9602                            }
9603                            result.fixed_cost = map.next_value::<__With>()?.0.unwrap_or_default();
9604                        }
9605                        __FieldTag::__used_if_route_is_empty => {
9606                            if !fields.insert(__FieldTag::__used_if_route_is_empty) {
9607                                return std::result::Result::Err(A::Error::duplicate_field(
9608                                    "multiple values for used_if_route_is_empty",
9609                                ));
9610                            }
9611                            result.used_if_route_is_empty = map
9612                                .next_value::<std::option::Option<bool>>()?
9613                                .unwrap_or_default();
9614                        }
9615                        __FieldTag::__route_duration_limit => {
9616                            if !fields.insert(__FieldTag::__route_duration_limit) {
9617                                return std::result::Result::Err(A::Error::duplicate_field(
9618                                    "multiple values for route_duration_limit",
9619                                ));
9620                            }
9621                            result.route_duration_limit = map.next_value::<std::option::Option<crate::model::vehicle::DurationLimit>>()?
9622                                ;
9623                        }
9624                        __FieldTag::__travel_duration_limit => {
9625                            if !fields.insert(__FieldTag::__travel_duration_limit) {
9626                                return std::result::Result::Err(A::Error::duplicate_field(
9627                                    "multiple values for travel_duration_limit",
9628                                ));
9629                            }
9630                            result.travel_duration_limit = map.next_value::<std::option::Option<crate::model::vehicle::DurationLimit>>()?
9631                                ;
9632                        }
9633                        __FieldTag::__route_distance_limit => {
9634                            if !fields.insert(__FieldTag::__route_distance_limit) {
9635                                return std::result::Result::Err(A::Error::duplicate_field(
9636                                    "multiple values for route_distance_limit",
9637                                ));
9638                            }
9639                            result.route_distance_limit = map
9640                                .next_value::<std::option::Option<crate::model::DistanceLimit>>()?;
9641                        }
9642                        __FieldTag::__extra_visit_duration_for_visit_type => {
9643                            if !fields.insert(__FieldTag::__extra_visit_duration_for_visit_type) {
9644                                return std::result::Result::Err(A::Error::duplicate_field(
9645                                    "multiple values for extra_visit_duration_for_visit_type",
9646                                ));
9647                            }
9648                            result.extra_visit_duration_for_visit_type = map
9649                                .next_value::<std::option::Option<
9650                                    std::collections::HashMap<std::string::String, wkt::Duration>,
9651                                >>()?
9652                                .unwrap_or_default();
9653                        }
9654                        __FieldTag::__break_rule => {
9655                            if !fields.insert(__FieldTag::__break_rule) {
9656                                return std::result::Result::Err(A::Error::duplicate_field(
9657                                    "multiple values for break_rule",
9658                                ));
9659                            }
9660                            result.break_rule =
9661                                map.next_value::<std::option::Option<crate::model::BreakRule>>()?;
9662                        }
9663                        __FieldTag::__label => {
9664                            if !fields.insert(__FieldTag::__label) {
9665                                return std::result::Result::Err(A::Error::duplicate_field(
9666                                    "multiple values for label",
9667                                ));
9668                            }
9669                            result.label = map
9670                                .next_value::<std::option::Option<std::string::String>>()?
9671                                .unwrap_or_default();
9672                        }
9673                        __FieldTag::__ignore => {
9674                            if !fields.insert(__FieldTag::__ignore) {
9675                                return std::result::Result::Err(A::Error::duplicate_field(
9676                                    "multiple values for ignore",
9677                                ));
9678                            }
9679                            result.ignore = map
9680                                .next_value::<std::option::Option<bool>>()?
9681                                .unwrap_or_default();
9682                        }
9683                        __FieldTag::__break_rule_indices => {
9684                            if !fields.insert(__FieldTag::__break_rule_indices) {
9685                                return std::result::Result::Err(A::Error::duplicate_field(
9686                                    "multiple values for break_rule_indices",
9687                                ));
9688                            }
9689                            struct __With(std::option::Option<std::vec::Vec<i32>>);
9690                            impl<'de> serde::de::Deserialize<'de> for __With {
9691                                fn deserialize<D>(
9692                                    deserializer: D,
9693                                ) -> std::result::Result<Self, D::Error>
9694                                where
9695                                    D: serde::de::Deserializer<'de>,
9696                                {
9697                                    serde_with::As::<
9698                                        std::option::Option<std::vec::Vec<wkt::internal::I32>>,
9699                                    >::deserialize(deserializer)
9700                                    .map(__With)
9701                                }
9702                            }
9703                            result.break_rule_indices =
9704                                map.next_value::<__With>()?.0.unwrap_or_default();
9705                        }
9706                        __FieldTag::__capacities => {
9707                            if !fields.insert(__FieldTag::__capacities) {
9708                                return std::result::Result::Err(A::Error::duplicate_field(
9709                                    "multiple values for capacities",
9710                                ));
9711                            }
9712                            result.capacities =
9713                                map.next_value::<std::option::Option<
9714                                    std::vec::Vec<crate::model::CapacityQuantity>,
9715                                >>()?
9716                                .unwrap_or_default();
9717                        }
9718                        __FieldTag::__start_load_intervals => {
9719                            if !fields.insert(__FieldTag::__start_load_intervals) {
9720                                return std::result::Result::Err(A::Error::duplicate_field(
9721                                    "multiple values for start_load_intervals",
9722                                ));
9723                            }
9724                            result.start_load_intervals = map
9725                                .next_value::<std::option::Option<
9726                                    std::vec::Vec<crate::model::CapacityQuantityInterval>,
9727                                >>()?
9728                                .unwrap_or_default();
9729                        }
9730                        __FieldTag::__end_load_intervals => {
9731                            if !fields.insert(__FieldTag::__end_load_intervals) {
9732                                return std::result::Result::Err(A::Error::duplicate_field(
9733                                    "multiple values for end_load_intervals",
9734                                ));
9735                            }
9736                            result.end_load_intervals = map
9737                                .next_value::<std::option::Option<
9738                                    std::vec::Vec<crate::model::CapacityQuantityInterval>,
9739                                >>()?
9740                                .unwrap_or_default();
9741                        }
9742                        __FieldTag::Unknown(key) => {
9743                            let value = map.next_value::<serde_json::Value>()?;
9744                            result._unknown_fields.insert(key, value);
9745                        }
9746                    }
9747                }
9748                std::result::Result::Ok(result)
9749            }
9750        }
9751        deserializer.deserialize_any(Visitor)
9752    }
9753}
9754
9755#[doc(hidden)]
9756impl serde::ser::Serialize for Vehicle {
9757    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9758    where
9759        S: serde::ser::Serializer,
9760    {
9761        use serde::ser::SerializeMap;
9762        #[allow(unused_imports)]
9763        use std::option::Option::Some;
9764        let mut state = serializer.serialize_map(std::option::Option::None)?;
9765        if !wkt::internal::is_default(&self.travel_mode) {
9766            state.serialize_entry("travelMode", &self.travel_mode)?;
9767        }
9768        if self.route_modifiers.is_some() {
9769            state.serialize_entry("routeModifiers", &self.route_modifiers)?;
9770        }
9771        if self.start_location.is_some() {
9772            state.serialize_entry("startLocation", &self.start_location)?;
9773        }
9774        if self.start_waypoint.is_some() {
9775            state.serialize_entry("startWaypoint", &self.start_waypoint)?;
9776        }
9777        if self.end_location.is_some() {
9778            state.serialize_entry("endLocation", &self.end_location)?;
9779        }
9780        if self.end_waypoint.is_some() {
9781            state.serialize_entry("endWaypoint", &self.end_waypoint)?;
9782        }
9783        if !self.start_tags.is_empty() {
9784            state.serialize_entry("startTags", &self.start_tags)?;
9785        }
9786        if !self.end_tags.is_empty() {
9787            state.serialize_entry("endTags", &self.end_tags)?;
9788        }
9789        if !self.start_time_windows.is_empty() {
9790            state.serialize_entry("startTimeWindows", &self.start_time_windows)?;
9791        }
9792        if !self.end_time_windows.is_empty() {
9793            state.serialize_entry("endTimeWindows", &self.end_time_windows)?;
9794        }
9795        if self.travel_duration_multiple.is_some() {
9796            struct __With<'a>(&'a std::option::Option<f64>);
9797            impl<'a> serde::ser::Serialize for __With<'a> {
9798                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9799                where
9800                    S: serde::ser::Serializer,
9801                {
9802                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
9803                        self.0, serializer,
9804                    )
9805                }
9806            }
9807            state.serialize_entry(
9808                "travelDurationMultiple",
9809                &__With(&self.travel_duration_multiple),
9810            )?;
9811        }
9812        if !wkt::internal::is_default(&self.unloading_policy) {
9813            state.serialize_entry("unloadingPolicy", &self.unloading_policy)?;
9814        }
9815        if !self.load_limits.is_empty() {
9816            state.serialize_entry("loadLimits", &self.load_limits)?;
9817        }
9818        if !wkt::internal::is_default(&self.cost_per_hour) {
9819            struct __With<'a>(&'a f64);
9820            impl<'a> serde::ser::Serialize for __With<'a> {
9821                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9822                where
9823                    S: serde::ser::Serializer,
9824                {
9825                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9826                }
9827            }
9828            state.serialize_entry("costPerHour", &__With(&self.cost_per_hour))?;
9829        }
9830        if !wkt::internal::is_default(&self.cost_per_traveled_hour) {
9831            struct __With<'a>(&'a f64);
9832            impl<'a> serde::ser::Serialize for __With<'a> {
9833                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9834                where
9835                    S: serde::ser::Serializer,
9836                {
9837                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9838                }
9839            }
9840            state.serialize_entry("costPerTraveledHour", &__With(&self.cost_per_traveled_hour))?;
9841        }
9842        if !wkt::internal::is_default(&self.cost_per_kilometer) {
9843            struct __With<'a>(&'a f64);
9844            impl<'a> serde::ser::Serialize for __With<'a> {
9845                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9846                where
9847                    S: serde::ser::Serializer,
9848                {
9849                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9850                }
9851            }
9852            state.serialize_entry("costPerKilometer", &__With(&self.cost_per_kilometer))?;
9853        }
9854        if !wkt::internal::is_default(&self.fixed_cost) {
9855            struct __With<'a>(&'a f64);
9856            impl<'a> serde::ser::Serialize for __With<'a> {
9857                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9858                where
9859                    S: serde::ser::Serializer,
9860                {
9861                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9862                }
9863            }
9864            state.serialize_entry("fixedCost", &__With(&self.fixed_cost))?;
9865        }
9866        if !wkt::internal::is_default(&self.used_if_route_is_empty) {
9867            state.serialize_entry("usedIfRouteIsEmpty", &self.used_if_route_is_empty)?;
9868        }
9869        if self.route_duration_limit.is_some() {
9870            state.serialize_entry("routeDurationLimit", &self.route_duration_limit)?;
9871        }
9872        if self.travel_duration_limit.is_some() {
9873            state.serialize_entry("travelDurationLimit", &self.travel_duration_limit)?;
9874        }
9875        if self.route_distance_limit.is_some() {
9876            state.serialize_entry("routeDistanceLimit", &self.route_distance_limit)?;
9877        }
9878        if !self.extra_visit_duration_for_visit_type.is_empty() {
9879            state.serialize_entry(
9880                "extraVisitDurationForVisitType",
9881                &self.extra_visit_duration_for_visit_type,
9882            )?;
9883        }
9884        if self.break_rule.is_some() {
9885            state.serialize_entry("breakRule", &self.break_rule)?;
9886        }
9887        if !self.label.is_empty() {
9888            state.serialize_entry("label", &self.label)?;
9889        }
9890        if !wkt::internal::is_default(&self.ignore) {
9891            state.serialize_entry("ignore", &self.ignore)?;
9892        }
9893        if !self.break_rule_indices.is_empty() {
9894            struct __With<'a>(&'a std::vec::Vec<i32>);
9895            impl<'a> serde::ser::Serialize for __With<'a> {
9896                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9897                where
9898                    S: serde::ser::Serializer,
9899                {
9900                    serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
9901                        self.0, serializer,
9902                    )
9903                }
9904            }
9905            state.serialize_entry("breakRuleIndices", &__With(&self.break_rule_indices))?;
9906        }
9907        if !self.capacities.is_empty() {
9908            state.serialize_entry("capacities", &self.capacities)?;
9909        }
9910        if !self.start_load_intervals.is_empty() {
9911            state.serialize_entry("startLoadIntervals", &self.start_load_intervals)?;
9912        }
9913        if !self.end_load_intervals.is_empty() {
9914            state.serialize_entry("endLoadIntervals", &self.end_load_intervals)?;
9915        }
9916        if !self._unknown_fields.is_empty() {
9917            for (key, value) in self._unknown_fields.iter() {
9918                state.serialize_entry(key, &value)?;
9919            }
9920        }
9921        state.end()
9922    }
9923}
9924
9925impl std::fmt::Debug for Vehicle {
9926    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9927        let mut debug_struct = f.debug_struct("Vehicle");
9928        debug_struct.field("travel_mode", &self.travel_mode);
9929        debug_struct.field("route_modifiers", &self.route_modifiers);
9930        debug_struct.field("start_location", &self.start_location);
9931        debug_struct.field("start_waypoint", &self.start_waypoint);
9932        debug_struct.field("end_location", &self.end_location);
9933        debug_struct.field("end_waypoint", &self.end_waypoint);
9934        debug_struct.field("start_tags", &self.start_tags);
9935        debug_struct.field("end_tags", &self.end_tags);
9936        debug_struct.field("start_time_windows", &self.start_time_windows);
9937        debug_struct.field("end_time_windows", &self.end_time_windows);
9938        debug_struct.field("travel_duration_multiple", &self.travel_duration_multiple);
9939        debug_struct.field("unloading_policy", &self.unloading_policy);
9940        debug_struct.field("load_limits", &self.load_limits);
9941        debug_struct.field("cost_per_hour", &self.cost_per_hour);
9942        debug_struct.field("cost_per_traveled_hour", &self.cost_per_traveled_hour);
9943        debug_struct.field("cost_per_kilometer", &self.cost_per_kilometer);
9944        debug_struct.field("fixed_cost", &self.fixed_cost);
9945        debug_struct.field("used_if_route_is_empty", &self.used_if_route_is_empty);
9946        debug_struct.field("route_duration_limit", &self.route_duration_limit);
9947        debug_struct.field("travel_duration_limit", &self.travel_duration_limit);
9948        debug_struct.field("route_distance_limit", &self.route_distance_limit);
9949        debug_struct.field(
9950            "extra_visit_duration_for_visit_type",
9951            &self.extra_visit_duration_for_visit_type,
9952        );
9953        debug_struct.field("break_rule", &self.break_rule);
9954        debug_struct.field("label", &self.label);
9955        debug_struct.field("ignore", &self.ignore);
9956        debug_struct.field("break_rule_indices", &self.break_rule_indices);
9957        debug_struct.field("capacities", &self.capacities);
9958        debug_struct.field("start_load_intervals", &self.start_load_intervals);
9959        debug_struct.field("end_load_intervals", &self.end_load_intervals);
9960        if !self._unknown_fields.is_empty() {
9961            debug_struct.field("_unknown_fields", &self._unknown_fields);
9962        }
9963        debug_struct.finish()
9964    }
9965}
9966
9967/// Defines additional types related to [Vehicle].
9968pub mod vehicle {
9969    #[allow(unused_imports)]
9970    use super::*;
9971
9972    /// Defines a load limit applying to a vehicle, e.g. "this truck may only
9973    /// carry up to 3500 kg". See
9974    /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
9975    ///
9976    /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
9977    #[derive(Clone, Default, PartialEq)]
9978    #[non_exhaustive]
9979    pub struct LoadLimit {
9980        /// The maximum acceptable amount of load.
9981        pub max_load: std::option::Option<i64>,
9982
9983        /// A soft limit of the load. See
9984        /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
9985        ///
9986        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
9987        pub soft_max_load: i64,
9988
9989        /// If the load ever exceeds
9990        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
9991        /// along this vehicle's route, the following cost penalty applies (only once
9992        /// per vehicle): (load -
9993        /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
9994        ///
9995        /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
9996        ///   add up and must be in the same unit as
9997        ///   [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
9998        ///
9999        /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
10000        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
10001        /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
10002        pub cost_per_unit_above_soft_max: f64,
10003
10004        /// The acceptable load interval of the vehicle at the start of the route.
10005        pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
10006
10007        /// The acceptable load interval of the vehicle at the end of the route.
10008        pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
10009
10010        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10011    }
10012
10013    impl LoadLimit {
10014        pub fn new() -> Self {
10015            std::default::Default::default()
10016        }
10017
10018        /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
10019        pub fn set_max_load<T>(mut self, v: T) -> Self
10020        where
10021            T: std::convert::Into<i64>,
10022        {
10023            self.max_load = std::option::Option::Some(v.into());
10024            self
10025        }
10026
10027        /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
10028        pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
10029        where
10030            T: std::convert::Into<i64>,
10031        {
10032            self.max_load = v.map(|x| x.into());
10033            self
10034        }
10035
10036        /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
10037        pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
10038            self.soft_max_load = v.into();
10039            self
10040        }
10041
10042        /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
10043        pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
10044            mut self,
10045            v: T,
10046        ) -> Self {
10047            self.cost_per_unit_above_soft_max = v.into();
10048            self
10049        }
10050
10051        /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
10052        pub fn set_start_load_interval<T>(mut self, v: T) -> Self
10053        where
10054            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
10055        {
10056            self.start_load_interval = std::option::Option::Some(v.into());
10057            self
10058        }
10059
10060        /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
10061        pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
10062        where
10063            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
10064        {
10065            self.start_load_interval = v.map(|x| x.into());
10066            self
10067        }
10068
10069        /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
10070        pub fn set_end_load_interval<T>(mut self, v: T) -> Self
10071        where
10072            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
10073        {
10074            self.end_load_interval = std::option::Option::Some(v.into());
10075            self
10076        }
10077
10078        /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
10079        pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
10080        where
10081            T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
10082        {
10083            self.end_load_interval = v.map(|x| x.into());
10084            self
10085        }
10086    }
10087
10088    impl wkt::message::Message for LoadLimit {
10089        fn typename() -> &'static str {
10090            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
10091        }
10092    }
10093
10094    #[doc(hidden)]
10095    impl<'de> serde::de::Deserialize<'de> for LoadLimit {
10096        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10097        where
10098            D: serde::Deserializer<'de>,
10099        {
10100            #[allow(non_camel_case_types)]
10101            #[doc(hidden)]
10102            #[derive(PartialEq, Eq, Hash)]
10103            enum __FieldTag {
10104                __max_load,
10105                __soft_max_load,
10106                __cost_per_unit_above_soft_max,
10107                __start_load_interval,
10108                __end_load_interval,
10109                Unknown(std::string::String),
10110            }
10111            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10112                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10113                where
10114                    D: serde::Deserializer<'de>,
10115                {
10116                    struct Visitor;
10117                    impl<'de> serde::de::Visitor<'de> for Visitor {
10118                        type Value = __FieldTag;
10119                        fn expecting(
10120                            &self,
10121                            formatter: &mut std::fmt::Formatter,
10122                        ) -> std::fmt::Result {
10123                            formatter.write_str("a field name for LoadLimit")
10124                        }
10125                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10126                        where
10127                            E: serde::de::Error,
10128                        {
10129                            use std::result::Result::Ok;
10130                            use std::string::ToString;
10131                            match value {
10132                                "maxLoad" => Ok(__FieldTag::__max_load),
10133                                "max_load" => Ok(__FieldTag::__max_load),
10134                                "softMaxLoad" => Ok(__FieldTag::__soft_max_load),
10135                                "soft_max_load" => Ok(__FieldTag::__soft_max_load),
10136                                "costPerUnitAboveSoftMax" => {
10137                                    Ok(__FieldTag::__cost_per_unit_above_soft_max)
10138                                }
10139                                "cost_per_unit_above_soft_max" => {
10140                                    Ok(__FieldTag::__cost_per_unit_above_soft_max)
10141                                }
10142                                "startLoadInterval" => Ok(__FieldTag::__start_load_interval),
10143                                "start_load_interval" => Ok(__FieldTag::__start_load_interval),
10144                                "endLoadInterval" => Ok(__FieldTag::__end_load_interval),
10145                                "end_load_interval" => Ok(__FieldTag::__end_load_interval),
10146                                _ => Ok(__FieldTag::Unknown(value.to_string())),
10147                            }
10148                        }
10149                    }
10150                    deserializer.deserialize_identifier(Visitor)
10151                }
10152            }
10153            struct Visitor;
10154            impl<'de> serde::de::Visitor<'de> for Visitor {
10155                type Value = LoadLimit;
10156                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10157                    formatter.write_str("struct LoadLimit")
10158                }
10159                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10160                where
10161                    A: serde::de::MapAccess<'de>,
10162                {
10163                    #[allow(unused_imports)]
10164                    use serde::de::Error;
10165                    use std::option::Option::Some;
10166                    let mut fields = std::collections::HashSet::new();
10167                    let mut result = Self::Value::new();
10168                    while let Some(tag) = map.next_key::<__FieldTag>()? {
10169                        #[allow(clippy::match_single_binding)]
10170                        match tag {
10171                            __FieldTag::__max_load => {
10172                                if !fields.insert(__FieldTag::__max_load) {
10173                                    return std::result::Result::Err(A::Error::duplicate_field(
10174                                        "multiple values for max_load",
10175                                    ));
10176                                }
10177                                struct __With(std::option::Option<i64>);
10178                                impl<'de> serde::de::Deserialize<'de> for __With {
10179                                    fn deserialize<D>(
10180                                        deserializer: D,
10181                                    ) -> std::result::Result<Self, D::Error>
10182                                    where
10183                                        D: serde::de::Deserializer<'de>,
10184                                    {
10185                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
10186                                    }
10187                                }
10188                                result.max_load = map.next_value::<__With>()?.0;
10189                            }
10190                            __FieldTag::__soft_max_load => {
10191                                if !fields.insert(__FieldTag::__soft_max_load) {
10192                                    return std::result::Result::Err(A::Error::duplicate_field(
10193                                        "multiple values for soft_max_load",
10194                                    ));
10195                                }
10196                                struct __With(std::option::Option<i64>);
10197                                impl<'de> serde::de::Deserialize<'de> for __With {
10198                                    fn deserialize<D>(
10199                                        deserializer: D,
10200                                    ) -> std::result::Result<Self, D::Error>
10201                                    where
10202                                        D: serde::de::Deserializer<'de>,
10203                                    {
10204                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
10205                                    }
10206                                }
10207                                result.soft_max_load =
10208                                    map.next_value::<__With>()?.0.unwrap_or_default();
10209                            }
10210                            __FieldTag::__cost_per_unit_above_soft_max => {
10211                                if !fields.insert(__FieldTag::__cost_per_unit_above_soft_max) {
10212                                    return std::result::Result::Err(A::Error::duplicate_field(
10213                                        "multiple values for cost_per_unit_above_soft_max",
10214                                    ));
10215                                }
10216                                struct __With(std::option::Option<f64>);
10217                                impl<'de> serde::de::Deserialize<'de> for __With {
10218                                    fn deserialize<D>(
10219                                        deserializer: D,
10220                                    ) -> std::result::Result<Self, D::Error>
10221                                    where
10222                                        D: serde::de::Deserializer<'de>,
10223                                    {
10224                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
10225                                    }
10226                                }
10227                                result.cost_per_unit_above_soft_max =
10228                                    map.next_value::<__With>()?.0.unwrap_or_default();
10229                            }
10230                            __FieldTag::__start_load_interval => {
10231                                if !fields.insert(__FieldTag::__start_load_interval) {
10232                                    return std::result::Result::Err(A::Error::duplicate_field(
10233                                        "multiple values for start_load_interval",
10234                                    ));
10235                                }
10236                                result.start_load_interval = map
10237                                    .next_value::<std::option::Option<
10238                                        crate::model::vehicle::load_limit::Interval,
10239                                    >>()?;
10240                            }
10241                            __FieldTag::__end_load_interval => {
10242                                if !fields.insert(__FieldTag::__end_load_interval) {
10243                                    return std::result::Result::Err(A::Error::duplicate_field(
10244                                        "multiple values for end_load_interval",
10245                                    ));
10246                                }
10247                                result.end_load_interval = map
10248                                    .next_value::<std::option::Option<
10249                                        crate::model::vehicle::load_limit::Interval,
10250                                    >>()?;
10251                            }
10252                            __FieldTag::Unknown(key) => {
10253                                let value = map.next_value::<serde_json::Value>()?;
10254                                result._unknown_fields.insert(key, value);
10255                            }
10256                        }
10257                    }
10258                    std::result::Result::Ok(result)
10259                }
10260            }
10261            deserializer.deserialize_any(Visitor)
10262        }
10263    }
10264
10265    #[doc(hidden)]
10266    impl serde::ser::Serialize for LoadLimit {
10267        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10268        where
10269            S: serde::ser::Serializer,
10270        {
10271            use serde::ser::SerializeMap;
10272            #[allow(unused_imports)]
10273            use std::option::Option::Some;
10274            let mut state = serializer.serialize_map(std::option::Option::None)?;
10275            if self.max_load.is_some() {
10276                struct __With<'a>(&'a std::option::Option<i64>);
10277                impl<'a> serde::ser::Serialize for __With<'a> {
10278                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10279                    where
10280                        S: serde::ser::Serializer,
10281                    {
10282                        serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
10283                            self.0, serializer,
10284                        )
10285                    }
10286                }
10287                state.serialize_entry("maxLoad", &__With(&self.max_load))?;
10288            }
10289            if !wkt::internal::is_default(&self.soft_max_load) {
10290                struct __With<'a>(&'a i64);
10291                impl<'a> serde::ser::Serialize for __With<'a> {
10292                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10293                    where
10294                        S: serde::ser::Serializer,
10295                    {
10296                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
10297                    }
10298                }
10299                state.serialize_entry("softMaxLoad", &__With(&self.soft_max_load))?;
10300            }
10301            if !wkt::internal::is_default(&self.cost_per_unit_above_soft_max) {
10302                struct __With<'a>(&'a f64);
10303                impl<'a> serde::ser::Serialize for __With<'a> {
10304                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10305                    where
10306                        S: serde::ser::Serializer,
10307                    {
10308                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
10309                    }
10310                }
10311                state.serialize_entry(
10312                    "costPerUnitAboveSoftMax",
10313                    &__With(&self.cost_per_unit_above_soft_max),
10314                )?;
10315            }
10316            if self.start_load_interval.is_some() {
10317                state.serialize_entry("startLoadInterval", &self.start_load_interval)?;
10318            }
10319            if self.end_load_interval.is_some() {
10320                state.serialize_entry("endLoadInterval", &self.end_load_interval)?;
10321            }
10322            if !self._unknown_fields.is_empty() {
10323                for (key, value) in self._unknown_fields.iter() {
10324                    state.serialize_entry(key, &value)?;
10325                }
10326            }
10327            state.end()
10328        }
10329    }
10330
10331    impl std::fmt::Debug for LoadLimit {
10332        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10333            let mut debug_struct = f.debug_struct("LoadLimit");
10334            debug_struct.field("max_load", &self.max_load);
10335            debug_struct.field("soft_max_load", &self.soft_max_load);
10336            debug_struct.field(
10337                "cost_per_unit_above_soft_max",
10338                &self.cost_per_unit_above_soft_max,
10339            );
10340            debug_struct.field("start_load_interval", &self.start_load_interval);
10341            debug_struct.field("end_load_interval", &self.end_load_interval);
10342            if !self._unknown_fields.is_empty() {
10343                debug_struct.field("_unknown_fields", &self._unknown_fields);
10344            }
10345            debug_struct.finish()
10346        }
10347    }
10348
10349    /// Defines additional types related to [LoadLimit].
10350    pub mod load_limit {
10351        #[allow(unused_imports)]
10352        use super::*;
10353
10354        /// Interval of acceptable load amounts.
10355        #[derive(Clone, Default, PartialEq)]
10356        #[non_exhaustive]
10357        pub struct Interval {
10358            /// A minimum acceptable load. Must be ≥ 0.
10359            /// If they're both specified,
10360            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
10361            /// be ≤
10362            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
10363            ///
10364            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
10365            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
10366            pub min: i64,
10367
10368            /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
10369            /// load is unrestricted by this message.
10370            /// If they're both specified,
10371            /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
10372            /// be ≤
10373            /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
10374            ///
10375            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
10376            /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
10377            pub max: std::option::Option<i64>,
10378
10379            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10380        }
10381
10382        impl Interval {
10383            pub fn new() -> Self {
10384                std::default::Default::default()
10385            }
10386
10387            /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
10388            pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
10389                self.min = v.into();
10390                self
10391            }
10392
10393            /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
10394            pub fn set_max<T>(mut self, v: T) -> Self
10395            where
10396                T: std::convert::Into<i64>,
10397            {
10398                self.max = std::option::Option::Some(v.into());
10399                self
10400            }
10401
10402            /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
10403            pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
10404            where
10405                T: std::convert::Into<i64>,
10406            {
10407                self.max = v.map(|x| x.into());
10408                self
10409            }
10410        }
10411
10412        impl wkt::message::Message for Interval {
10413            fn typename() -> &'static str {
10414                "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
10415            }
10416        }
10417
10418        #[doc(hidden)]
10419        impl<'de> serde::de::Deserialize<'de> for Interval {
10420            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10421            where
10422                D: serde::Deserializer<'de>,
10423            {
10424                #[allow(non_camel_case_types)]
10425                #[doc(hidden)]
10426                #[derive(PartialEq, Eq, Hash)]
10427                enum __FieldTag {
10428                    __min,
10429                    __max,
10430                    Unknown(std::string::String),
10431                }
10432                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10433                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10434                    where
10435                        D: serde::Deserializer<'de>,
10436                    {
10437                        struct Visitor;
10438                        impl<'de> serde::de::Visitor<'de> for Visitor {
10439                            type Value = __FieldTag;
10440                            fn expecting(
10441                                &self,
10442                                formatter: &mut std::fmt::Formatter,
10443                            ) -> std::fmt::Result {
10444                                formatter.write_str("a field name for Interval")
10445                            }
10446                            fn visit_str<E>(
10447                                self,
10448                                value: &str,
10449                            ) -> std::result::Result<Self::Value, E>
10450                            where
10451                                E: serde::de::Error,
10452                            {
10453                                use std::result::Result::Ok;
10454                                use std::string::ToString;
10455                                match value {
10456                                    "min" => Ok(__FieldTag::__min),
10457                                    "max" => Ok(__FieldTag::__max),
10458                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
10459                                }
10460                            }
10461                        }
10462                        deserializer.deserialize_identifier(Visitor)
10463                    }
10464                }
10465                struct Visitor;
10466                impl<'de> serde::de::Visitor<'de> for Visitor {
10467                    type Value = Interval;
10468                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10469                        formatter.write_str("struct Interval")
10470                    }
10471                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10472                    where
10473                        A: serde::de::MapAccess<'de>,
10474                    {
10475                        #[allow(unused_imports)]
10476                        use serde::de::Error;
10477                        use std::option::Option::Some;
10478                        let mut fields = std::collections::HashSet::new();
10479                        let mut result = Self::Value::new();
10480                        while let Some(tag) = map.next_key::<__FieldTag>()? {
10481                            #[allow(clippy::match_single_binding)]
10482                            match tag {
10483                                __FieldTag::__min => {
10484                                    if !fields.insert(__FieldTag::__min) {
10485                                        return std::result::Result::Err(
10486                                            A::Error::duplicate_field("multiple values for min"),
10487                                        );
10488                                    }
10489                                    struct __With(std::option::Option<i64>);
10490                                    impl<'de> serde::de::Deserialize<'de> for __With {
10491                                        fn deserialize<D>(
10492                                            deserializer: D,
10493                                        ) -> std::result::Result<Self, D::Error>
10494                                        where
10495                                            D: serde::de::Deserializer<'de>,
10496                                        {
10497                                            serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
10498                                        }
10499                                    }
10500                                    result.min = map.next_value::<__With>()?.0.unwrap_or_default();
10501                                }
10502                                __FieldTag::__max => {
10503                                    if !fields.insert(__FieldTag::__max) {
10504                                        return std::result::Result::Err(
10505                                            A::Error::duplicate_field("multiple values for max"),
10506                                        );
10507                                    }
10508                                    struct __With(std::option::Option<i64>);
10509                                    impl<'de> serde::de::Deserialize<'de> for __With {
10510                                        fn deserialize<D>(
10511                                            deserializer: D,
10512                                        ) -> std::result::Result<Self, D::Error>
10513                                        where
10514                                            D: serde::de::Deserializer<'de>,
10515                                        {
10516                                            serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
10517                                        }
10518                                    }
10519                                    result.max = map.next_value::<__With>()?.0;
10520                                }
10521                                __FieldTag::Unknown(key) => {
10522                                    let value = map.next_value::<serde_json::Value>()?;
10523                                    result._unknown_fields.insert(key, value);
10524                                }
10525                            }
10526                        }
10527                        std::result::Result::Ok(result)
10528                    }
10529                }
10530                deserializer.deserialize_any(Visitor)
10531            }
10532        }
10533
10534        #[doc(hidden)]
10535        impl serde::ser::Serialize for Interval {
10536            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10537            where
10538                S: serde::ser::Serializer,
10539            {
10540                use serde::ser::SerializeMap;
10541                #[allow(unused_imports)]
10542                use std::option::Option::Some;
10543                let mut state = serializer.serialize_map(std::option::Option::None)?;
10544                if !wkt::internal::is_default(&self.min) {
10545                    struct __With<'a>(&'a i64);
10546                    impl<'a> serde::ser::Serialize for __With<'a> {
10547                        fn serialize<S>(
10548                            &self,
10549                            serializer: S,
10550                        ) -> std::result::Result<S::Ok, S::Error>
10551                        where
10552                            S: serde::ser::Serializer,
10553                        {
10554                            serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
10555                        }
10556                    }
10557                    state.serialize_entry("min", &__With(&self.min))?;
10558                }
10559                if self.max.is_some() {
10560                    struct __With<'a>(&'a std::option::Option<i64>);
10561                    impl<'a> serde::ser::Serialize for __With<'a> {
10562                        fn serialize<S>(
10563                            &self,
10564                            serializer: S,
10565                        ) -> std::result::Result<S::Ok, S::Error>
10566                        where
10567                            S: serde::ser::Serializer,
10568                        {
10569                            serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
10570                                self.0, serializer,
10571                            )
10572                        }
10573                    }
10574                    state.serialize_entry("max", &__With(&self.max))?;
10575                }
10576                if !self._unknown_fields.is_empty() {
10577                    for (key, value) in self._unknown_fields.iter() {
10578                        state.serialize_entry(key, &value)?;
10579                    }
10580                }
10581                state.end()
10582            }
10583        }
10584
10585        impl std::fmt::Debug for Interval {
10586            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10587                let mut debug_struct = f.debug_struct("Interval");
10588                debug_struct.field("min", &self.min);
10589                debug_struct.field("max", &self.max);
10590                if !self._unknown_fields.is_empty() {
10591                    debug_struct.field("_unknown_fields", &self._unknown_fields);
10592                }
10593                debug_struct.finish()
10594            }
10595        }
10596    }
10597
10598    /// A limit defining a maximum duration of the route of a vehicle. It can be
10599    /// either hard or soft.
10600    ///
10601    /// When a soft limit field is defined, both the soft max threshold and its
10602    /// associated cost must be defined together.
10603    #[derive(Clone, Default, PartialEq)]
10604    #[non_exhaustive]
10605    pub struct DurationLimit {
10606        /// A hard limit constraining the duration to be at most max_duration.
10607        pub max_duration: std::option::Option<wkt::Duration>,
10608
10609        /// A soft limit not enforcing a maximum duration limit, but when violated
10610        /// makes the route incur a cost. This cost adds up to other costs defined in
10611        /// the model, with the same unit.
10612        ///
10613        /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
10614        /// also defined, `soft_max_duration` must be less than max_duration.
10615        pub soft_max_duration: std::option::Option<wkt::Duration>,
10616
10617        /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
10618        /// The additional cost is 0 if the duration is under the threshold,
10619        /// otherwise the cost depends on the duration as follows:
10620        ///
10621        /// ```norust
10622        ///   cost_per_hour_after_soft_max * (duration - soft_max_duration)
10623        /// ```
10624        ///
10625        /// The cost must be nonnegative.
10626        pub cost_per_hour_after_soft_max: std::option::Option<f64>,
10627
10628        /// A soft limit not enforcing a maximum duration limit, but when violated
10629        /// makes the route incur a cost, quadratic in the duration. This cost adds
10630        /// up to other costs defined in the model, with the same unit.
10631        ///
10632        /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
10633        /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
10634        /// less than `max_duration`, and the difference must be no larger than one
10635        /// day:
10636        ///
10637        /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
10638        pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
10639
10640        /// Cost per square hour incurred if the
10641        /// `quadratic_soft_max_duration` threshold is violated.
10642        ///
10643        /// The additional cost is 0 if the duration is under the threshold,
10644        /// otherwise the cost depends on the duration as follows:
10645        ///
10646        /// ```norust
10647        ///   cost_per_square_hour_after_quadratic_soft_max *
10648        ///   (duration - quadratic_soft_max_duration)^2
10649        /// ```
10650        ///
10651        /// The cost must be nonnegative.
10652        pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
10653
10654        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10655    }
10656
10657    impl DurationLimit {
10658        pub fn new() -> Self {
10659            std::default::Default::default()
10660        }
10661
10662        /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
10663        pub fn set_max_duration<T>(mut self, v: T) -> Self
10664        where
10665            T: std::convert::Into<wkt::Duration>,
10666        {
10667            self.max_duration = std::option::Option::Some(v.into());
10668            self
10669        }
10670
10671        /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
10672        pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
10673        where
10674            T: std::convert::Into<wkt::Duration>,
10675        {
10676            self.max_duration = v.map(|x| x.into());
10677            self
10678        }
10679
10680        /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
10681        pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
10682        where
10683            T: std::convert::Into<wkt::Duration>,
10684        {
10685            self.soft_max_duration = std::option::Option::Some(v.into());
10686            self
10687        }
10688
10689        /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
10690        pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
10691        where
10692            T: std::convert::Into<wkt::Duration>,
10693        {
10694            self.soft_max_duration = v.map(|x| x.into());
10695            self
10696        }
10697
10698        /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
10699        pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
10700        where
10701            T: std::convert::Into<f64>,
10702        {
10703            self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
10704            self
10705        }
10706
10707        /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
10708        pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
10709            mut self,
10710            v: std::option::Option<T>,
10711        ) -> Self
10712        where
10713            T: std::convert::Into<f64>,
10714        {
10715            self.cost_per_hour_after_soft_max = v.map(|x| x.into());
10716            self
10717        }
10718
10719        /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
10720        pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
10721        where
10722            T: std::convert::Into<wkt::Duration>,
10723        {
10724            self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
10725            self
10726        }
10727
10728        /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
10729        pub fn set_or_clear_quadratic_soft_max_duration<T>(
10730            mut self,
10731            v: std::option::Option<T>,
10732        ) -> Self
10733        where
10734            T: std::convert::Into<wkt::Duration>,
10735        {
10736            self.quadratic_soft_max_duration = v.map(|x| x.into());
10737            self
10738        }
10739
10740        /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
10741        pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
10742        where
10743            T: std::convert::Into<f64>,
10744        {
10745            self.cost_per_square_hour_after_quadratic_soft_max =
10746                std::option::Option::Some(v.into());
10747            self
10748        }
10749
10750        /// 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].
10751        pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
10752            mut self,
10753            v: std::option::Option<T>,
10754        ) -> Self
10755        where
10756            T: std::convert::Into<f64>,
10757        {
10758            self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
10759            self
10760        }
10761    }
10762
10763    impl wkt::message::Message for DurationLimit {
10764        fn typename() -> &'static str {
10765            "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
10766        }
10767    }
10768
10769    #[doc(hidden)]
10770    impl<'de> serde::de::Deserialize<'de> for DurationLimit {
10771        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10772        where
10773            D: serde::Deserializer<'de>,
10774        {
10775            #[allow(non_camel_case_types)]
10776            #[doc(hidden)]
10777            #[derive(PartialEq, Eq, Hash)]
10778            enum __FieldTag {
10779                __max_duration,
10780                __soft_max_duration,
10781                __cost_per_hour_after_soft_max,
10782                __quadratic_soft_max_duration,
10783                __cost_per_square_hour_after_quadratic_soft_max,
10784                Unknown(std::string::String),
10785            }
10786            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10787                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10788                where
10789                    D: serde::Deserializer<'de>,
10790                {
10791                    struct Visitor;
10792                    impl<'de> serde::de::Visitor<'de> for Visitor {
10793                        type Value = __FieldTag;
10794                        fn expecting(
10795                            &self,
10796                            formatter: &mut std::fmt::Formatter,
10797                        ) -> std::fmt::Result {
10798                            formatter.write_str("a field name for DurationLimit")
10799                        }
10800                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10801                        where
10802                            E: serde::de::Error,
10803                        {
10804                            use std::result::Result::Ok;
10805                            use std::string::ToString;
10806                            match value {
10807                                "maxDuration" => Ok(__FieldTag::__max_duration),
10808                                "max_duration" => Ok(__FieldTag::__max_duration),
10809                                "softMaxDuration" => Ok(__FieldTag::__soft_max_duration),
10810                                "soft_max_duration" => Ok(__FieldTag::__soft_max_duration),
10811                                "costPerHourAfterSoftMax" => {
10812                                    Ok(__FieldTag::__cost_per_hour_after_soft_max)
10813                                }
10814                                "cost_per_hour_after_soft_max" => {
10815                                    Ok(__FieldTag::__cost_per_hour_after_soft_max)
10816                                }
10817                                "quadraticSoftMaxDuration" => {
10818                                    Ok(__FieldTag::__quadratic_soft_max_duration)
10819                                }
10820                                "quadratic_soft_max_duration" => {
10821                                    Ok(__FieldTag::__quadratic_soft_max_duration)
10822                                }
10823                                "costPerSquareHourAfterQuadraticSoftMax" => {
10824                                    Ok(__FieldTag::__cost_per_square_hour_after_quadratic_soft_max)
10825                                }
10826                                "cost_per_square_hour_after_quadratic_soft_max" => {
10827                                    Ok(__FieldTag::__cost_per_square_hour_after_quadratic_soft_max)
10828                                }
10829                                _ => Ok(__FieldTag::Unknown(value.to_string())),
10830                            }
10831                        }
10832                    }
10833                    deserializer.deserialize_identifier(Visitor)
10834                }
10835            }
10836            struct Visitor;
10837            impl<'de> serde::de::Visitor<'de> for Visitor {
10838                type Value = DurationLimit;
10839                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10840                    formatter.write_str("struct DurationLimit")
10841                }
10842                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10843                where
10844                    A: serde::de::MapAccess<'de>,
10845                {
10846                    #[allow(unused_imports)]
10847                    use serde::de::Error;
10848                    use std::option::Option::Some;
10849                    let mut fields = std::collections::HashSet::new();
10850                    let mut result = Self::Value::new();
10851                    while let Some(tag) = map.next_key::<__FieldTag>()? {
10852                        #[allow(clippy::match_single_binding)]
10853                        match tag {
10854                            __FieldTag::__max_duration => {
10855                                if !fields.insert(__FieldTag::__max_duration) {
10856                                    return std::result::Result::Err(A::Error::duplicate_field(
10857                                        "multiple values for max_duration",
10858                                    ));
10859                                }
10860                                result.max_duration =
10861                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
10862                            }
10863                            __FieldTag::__soft_max_duration => {
10864                                if !fields.insert(__FieldTag::__soft_max_duration) {
10865                                    return std::result::Result::Err(A::Error::duplicate_field(
10866                                        "multiple values for soft_max_duration",
10867                                    ));
10868                                }
10869                                result.soft_max_duration =
10870                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
10871                            }
10872                            __FieldTag::__cost_per_hour_after_soft_max => {
10873                                if !fields.insert(__FieldTag::__cost_per_hour_after_soft_max) {
10874                                    return std::result::Result::Err(A::Error::duplicate_field(
10875                                        "multiple values for cost_per_hour_after_soft_max",
10876                                    ));
10877                                }
10878                                struct __With(std::option::Option<f64>);
10879                                impl<'de> serde::de::Deserialize<'de> for __With {
10880                                    fn deserialize<D>(
10881                                        deserializer: D,
10882                                    ) -> std::result::Result<Self, D::Error>
10883                                    where
10884                                        D: serde::de::Deserializer<'de>,
10885                                    {
10886                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
10887                                    }
10888                                }
10889                                result.cost_per_hour_after_soft_max = map.next_value::<__With>()?.0;
10890                            }
10891                            __FieldTag::__quadratic_soft_max_duration => {
10892                                if !fields.insert(__FieldTag::__quadratic_soft_max_duration) {
10893                                    return std::result::Result::Err(A::Error::duplicate_field(
10894                                        "multiple values for quadratic_soft_max_duration",
10895                                    ));
10896                                }
10897                                result.quadratic_soft_max_duration =
10898                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
10899                            }
10900                            __FieldTag::__cost_per_square_hour_after_quadratic_soft_max => {
10901                                if !fields.insert(
10902                                    __FieldTag::__cost_per_square_hour_after_quadratic_soft_max,
10903                                ) {
10904                                    return std::result::Result::Err(A::Error::duplicate_field(
10905                                        "multiple values for cost_per_square_hour_after_quadratic_soft_max",
10906                                    ));
10907                                }
10908                                struct __With(std::option::Option<f64>);
10909                                impl<'de> serde::de::Deserialize<'de> for __With {
10910                                    fn deserialize<D>(
10911                                        deserializer: D,
10912                                    ) -> std::result::Result<Self, D::Error>
10913                                    where
10914                                        D: serde::de::Deserializer<'de>,
10915                                    {
10916                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
10917                                    }
10918                                }
10919                                result.cost_per_square_hour_after_quadratic_soft_max =
10920                                    map.next_value::<__With>()?.0;
10921                            }
10922                            __FieldTag::Unknown(key) => {
10923                                let value = map.next_value::<serde_json::Value>()?;
10924                                result._unknown_fields.insert(key, value);
10925                            }
10926                        }
10927                    }
10928                    std::result::Result::Ok(result)
10929                }
10930            }
10931            deserializer.deserialize_any(Visitor)
10932        }
10933    }
10934
10935    #[doc(hidden)]
10936    impl serde::ser::Serialize for DurationLimit {
10937        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10938        where
10939            S: serde::ser::Serializer,
10940        {
10941            use serde::ser::SerializeMap;
10942            #[allow(unused_imports)]
10943            use std::option::Option::Some;
10944            let mut state = serializer.serialize_map(std::option::Option::None)?;
10945            if self.max_duration.is_some() {
10946                state.serialize_entry("maxDuration", &self.max_duration)?;
10947            }
10948            if self.soft_max_duration.is_some() {
10949                state.serialize_entry("softMaxDuration", &self.soft_max_duration)?;
10950            }
10951            if self.cost_per_hour_after_soft_max.is_some() {
10952                struct __With<'a>(&'a std::option::Option<f64>);
10953                impl<'a> serde::ser::Serialize for __With<'a> {
10954                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10955                    where
10956                        S: serde::ser::Serializer,
10957                    {
10958                        serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
10959                            self.0, serializer,
10960                        )
10961                    }
10962                }
10963                state.serialize_entry(
10964                    "costPerHourAfterSoftMax",
10965                    &__With(&self.cost_per_hour_after_soft_max),
10966                )?;
10967            }
10968            if self.quadratic_soft_max_duration.is_some() {
10969                state.serialize_entry(
10970                    "quadraticSoftMaxDuration",
10971                    &self.quadratic_soft_max_duration,
10972                )?;
10973            }
10974            if self.cost_per_square_hour_after_quadratic_soft_max.is_some() {
10975                struct __With<'a>(&'a std::option::Option<f64>);
10976                impl<'a> serde::ser::Serialize for __With<'a> {
10977                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10978                    where
10979                        S: serde::ser::Serializer,
10980                    {
10981                        serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
10982                            self.0, serializer,
10983                        )
10984                    }
10985                }
10986                state.serialize_entry(
10987                    "costPerSquareHourAfterQuadraticSoftMax",
10988                    &__With(&self.cost_per_square_hour_after_quadratic_soft_max),
10989                )?;
10990            }
10991            if !self._unknown_fields.is_empty() {
10992                for (key, value) in self._unknown_fields.iter() {
10993                    state.serialize_entry(key, &value)?;
10994                }
10995            }
10996            state.end()
10997        }
10998    }
10999
11000    impl std::fmt::Debug for DurationLimit {
11001        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11002            let mut debug_struct = f.debug_struct("DurationLimit");
11003            debug_struct.field("max_duration", &self.max_duration);
11004            debug_struct.field("soft_max_duration", &self.soft_max_duration);
11005            debug_struct.field(
11006                "cost_per_hour_after_soft_max",
11007                &self.cost_per_hour_after_soft_max,
11008            );
11009            debug_struct.field(
11010                "quadratic_soft_max_duration",
11011                &self.quadratic_soft_max_duration,
11012            );
11013            debug_struct.field(
11014                "cost_per_square_hour_after_quadratic_soft_max",
11015                &self.cost_per_square_hour_after_quadratic_soft_max,
11016            );
11017            if !self._unknown_fields.is_empty() {
11018                debug_struct.field("_unknown_fields", &self._unknown_fields);
11019            }
11020            debug_struct.finish()
11021        }
11022    }
11023
11024    /// Travel modes which can be used by vehicles.
11025    ///
11026    /// These should be a subset of the Google Maps Platform Routes Preferred API
11027    /// travel modes, see:
11028    /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
11029    ///
11030    /// # Working with unknown values
11031    ///
11032    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11033    /// additional enum variants at any time. Adding new variants is not considered
11034    /// a breaking change. Applications should write their code in anticipation of:
11035    ///
11036    /// - New values appearing in future releases of the client library, **and**
11037    /// - New values received dynamically, without application changes.
11038    ///
11039    /// Please consult the [Working with enums] section in the user guide for some
11040    /// guidelines.
11041    ///
11042    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
11043    #[derive(Clone, Debug, PartialEq)]
11044    #[non_exhaustive]
11045    pub enum TravelMode {
11046        /// Unspecified travel mode, equivalent to `DRIVING`.
11047        Unspecified,
11048        /// Travel mode corresponding to driving directions (car, ...).
11049        Driving,
11050        /// Travel mode corresponding to walking directions.
11051        Walking,
11052        /// If set, the enum was initialized with an unknown value.
11053        ///
11054        /// Applications can examine the value using [TravelMode::value] or
11055        /// [TravelMode::name].
11056        UnknownValue(travel_mode::UnknownValue),
11057    }
11058
11059    #[doc(hidden)]
11060    pub mod travel_mode {
11061        #[allow(unused_imports)]
11062        use super::*;
11063        #[derive(Clone, Debug, PartialEq)]
11064        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11065    }
11066
11067    impl TravelMode {
11068        /// Gets the enum value.
11069        ///
11070        /// Returns `None` if the enum contains an unknown value deserialized from
11071        /// the string representation of enums.
11072        pub fn value(&self) -> std::option::Option<i32> {
11073            match self {
11074                Self::Unspecified => std::option::Option::Some(0),
11075                Self::Driving => std::option::Option::Some(1),
11076                Self::Walking => std::option::Option::Some(2),
11077                Self::UnknownValue(u) => u.0.value(),
11078            }
11079        }
11080
11081        /// Gets the enum value as a string.
11082        ///
11083        /// Returns `None` if the enum contains an unknown value deserialized from
11084        /// the integer representation of enums.
11085        pub fn name(&self) -> std::option::Option<&str> {
11086            match self {
11087                Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
11088                Self::Driving => std::option::Option::Some("DRIVING"),
11089                Self::Walking => std::option::Option::Some("WALKING"),
11090                Self::UnknownValue(u) => u.0.name(),
11091            }
11092        }
11093    }
11094
11095    impl std::default::Default for TravelMode {
11096        fn default() -> Self {
11097            use std::convert::From;
11098            Self::from(0)
11099        }
11100    }
11101
11102    impl std::fmt::Display for TravelMode {
11103        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11104            wkt::internal::display_enum(f, self.name(), self.value())
11105        }
11106    }
11107
11108    impl std::convert::From<i32> for TravelMode {
11109        fn from(value: i32) -> Self {
11110            match value {
11111                0 => Self::Unspecified,
11112                1 => Self::Driving,
11113                2 => Self::Walking,
11114                _ => Self::UnknownValue(travel_mode::UnknownValue(
11115                    wkt::internal::UnknownEnumValue::Integer(value),
11116                )),
11117            }
11118        }
11119    }
11120
11121    impl std::convert::From<&str> for TravelMode {
11122        fn from(value: &str) -> Self {
11123            use std::string::ToString;
11124            match value {
11125                "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
11126                "DRIVING" => Self::Driving,
11127                "WALKING" => Self::Walking,
11128                _ => Self::UnknownValue(travel_mode::UnknownValue(
11129                    wkt::internal::UnknownEnumValue::String(value.to_string()),
11130                )),
11131            }
11132        }
11133    }
11134
11135    impl serde::ser::Serialize for TravelMode {
11136        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11137        where
11138            S: serde::Serializer,
11139        {
11140            match self {
11141                Self::Unspecified => serializer.serialize_i32(0),
11142                Self::Driving => serializer.serialize_i32(1),
11143                Self::Walking => serializer.serialize_i32(2),
11144                Self::UnknownValue(u) => u.0.serialize(serializer),
11145            }
11146        }
11147    }
11148
11149    impl<'de> serde::de::Deserialize<'de> for TravelMode {
11150        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11151        where
11152            D: serde::Deserializer<'de>,
11153        {
11154            deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
11155                ".google.cloud.optimization.v1.Vehicle.TravelMode",
11156            ))
11157        }
11158    }
11159
11160    /// Policy on how a vehicle can be unloaded. Applies only to shipments having
11161    /// both a pickup and a delivery.
11162    ///
11163    /// Other shipments are free to occur anywhere on the route independent of
11164    /// `unloading_policy`.
11165    ///
11166    /// # Working with unknown values
11167    ///
11168    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11169    /// additional enum variants at any time. Adding new variants is not considered
11170    /// a breaking change. Applications should write their code in anticipation of:
11171    ///
11172    /// - New values appearing in future releases of the client library, **and**
11173    /// - New values received dynamically, without application changes.
11174    ///
11175    /// Please consult the [Working with enums] section in the user guide for some
11176    /// guidelines.
11177    ///
11178    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
11179    #[derive(Clone, Debug, PartialEq)]
11180    #[non_exhaustive]
11181    pub enum UnloadingPolicy {
11182        /// Unspecified unloading policy; deliveries must just occur after their
11183        /// corresponding pickups.
11184        Unspecified,
11185        /// Deliveries must occur in reverse order of pickups
11186        LastInFirstOut,
11187        /// Deliveries must occur in the same order as pickups
11188        FirstInFirstOut,
11189        /// If set, the enum was initialized with an unknown value.
11190        ///
11191        /// Applications can examine the value using [UnloadingPolicy::value] or
11192        /// [UnloadingPolicy::name].
11193        UnknownValue(unloading_policy::UnknownValue),
11194    }
11195
11196    #[doc(hidden)]
11197    pub mod unloading_policy {
11198        #[allow(unused_imports)]
11199        use super::*;
11200        #[derive(Clone, Debug, PartialEq)]
11201        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11202    }
11203
11204    impl UnloadingPolicy {
11205        /// Gets the enum value.
11206        ///
11207        /// Returns `None` if the enum contains an unknown value deserialized from
11208        /// the string representation of enums.
11209        pub fn value(&self) -> std::option::Option<i32> {
11210            match self {
11211                Self::Unspecified => std::option::Option::Some(0),
11212                Self::LastInFirstOut => std::option::Option::Some(1),
11213                Self::FirstInFirstOut => std::option::Option::Some(2),
11214                Self::UnknownValue(u) => u.0.value(),
11215            }
11216        }
11217
11218        /// Gets the enum value as a string.
11219        ///
11220        /// Returns `None` if the enum contains an unknown value deserialized from
11221        /// the integer representation of enums.
11222        pub fn name(&self) -> std::option::Option<&str> {
11223            match self {
11224                Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
11225                Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
11226                Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
11227                Self::UnknownValue(u) => u.0.name(),
11228            }
11229        }
11230    }
11231
11232    impl std::default::Default for UnloadingPolicy {
11233        fn default() -> Self {
11234            use std::convert::From;
11235            Self::from(0)
11236        }
11237    }
11238
11239    impl std::fmt::Display for UnloadingPolicy {
11240        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11241            wkt::internal::display_enum(f, self.name(), self.value())
11242        }
11243    }
11244
11245    impl std::convert::From<i32> for UnloadingPolicy {
11246        fn from(value: i32) -> Self {
11247            match value {
11248                0 => Self::Unspecified,
11249                1 => Self::LastInFirstOut,
11250                2 => Self::FirstInFirstOut,
11251                _ => Self::UnknownValue(unloading_policy::UnknownValue(
11252                    wkt::internal::UnknownEnumValue::Integer(value),
11253                )),
11254            }
11255        }
11256    }
11257
11258    impl std::convert::From<&str> for UnloadingPolicy {
11259        fn from(value: &str) -> Self {
11260            use std::string::ToString;
11261            match value {
11262                "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
11263                "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
11264                "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
11265                _ => Self::UnknownValue(unloading_policy::UnknownValue(
11266                    wkt::internal::UnknownEnumValue::String(value.to_string()),
11267                )),
11268            }
11269        }
11270    }
11271
11272    impl serde::ser::Serialize for UnloadingPolicy {
11273        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11274        where
11275            S: serde::Serializer,
11276        {
11277            match self {
11278                Self::Unspecified => serializer.serialize_i32(0),
11279                Self::LastInFirstOut => serializer.serialize_i32(1),
11280                Self::FirstInFirstOut => serializer.serialize_i32(2),
11281                Self::UnknownValue(u) => u.0.serialize(serializer),
11282            }
11283        }
11284    }
11285
11286    impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
11287        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11288        where
11289            D: serde::Deserializer<'de>,
11290        {
11291            deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
11292                ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
11293            ))
11294        }
11295    }
11296}
11297
11298/// Time windows constrain the time of an event, such as the arrival time at a
11299/// visit, or the start and end time of a vehicle.
11300///
11301/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
11302/// and latest time of the event, such that `start_time <= event_time <=
11303/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
11304/// preference for the event to happen at or after `soft_start_time` by incurring
11305/// a cost proportional to how long before soft_start_time the event occurs. The
11306/// soft time window upper bound, `soft_end_time`, expresses a preference for the
11307/// event to happen at or before `soft_end_time` by incurring a cost proportional
11308/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
11309/// `soft_start_time` and `soft_end_time` should be within the global time limits
11310/// (see
11311/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
11312/// and
11313/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
11314/// and should respect:
11315///
11316/// ```norust
11317///   0 <= `start_time` <= `soft_start_time` <= `end_time` and
11318///   0 <= `start_time` <= `soft_end_time` <= `end_time`.
11319/// ```
11320///
11321/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
11322/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
11323#[derive(Clone, Default, PartialEq)]
11324#[non_exhaustive]
11325pub struct TimeWindow {
11326    /// The hard time window start time. If unspecified it will be set to
11327    /// `ShipmentModel.global_start_time`.
11328    pub start_time: std::option::Option<wkt::Timestamp>,
11329
11330    /// The hard time window end time. If unspecified it will be set to
11331    /// `ShipmentModel.global_end_time`.
11332    pub end_time: std::option::Option<wkt::Timestamp>,
11333
11334    /// The soft start time of the time window.
11335    pub soft_start_time: std::option::Option<wkt::Timestamp>,
11336
11337    /// The soft end time of the time window.
11338    pub soft_end_time: std::option::Option<wkt::Timestamp>,
11339
11340    /// A cost per hour added to other costs in the model if the event occurs
11341    /// before soft_start_time, computed as:
11342    ///
11343    /// ```norust
11344    ///    max(0, soft_start_time - t.seconds)
11345    ///                           * cost_per_hour_before_soft_start_time / 3600,
11346    /// t being the time of the event.
11347    /// ```
11348    ///
11349    /// This cost must be positive, and the field can only be set if
11350    /// soft_start_time has been set.
11351    pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
11352
11353    /// A cost per hour added to other costs in the model if the event occurs after
11354    /// `soft_end_time`, computed as:
11355    ///
11356    /// ```norust
11357    ///    max(0, t.seconds - soft_end_time.seconds)
11358    ///                     * cost_per_hour_after_soft_end_time / 3600,
11359    /// t being the time of the event.
11360    /// ```
11361    ///
11362    /// This cost must be positive, and the field can only be set if
11363    /// `soft_end_time` has been set.
11364    pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
11365
11366    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11367}
11368
11369impl TimeWindow {
11370    pub fn new() -> Self {
11371        std::default::Default::default()
11372    }
11373
11374    /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
11375    pub fn set_start_time<T>(mut self, v: T) -> Self
11376    where
11377        T: std::convert::Into<wkt::Timestamp>,
11378    {
11379        self.start_time = std::option::Option::Some(v.into());
11380        self
11381    }
11382
11383    /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
11384    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
11385    where
11386        T: std::convert::Into<wkt::Timestamp>,
11387    {
11388        self.start_time = v.map(|x| x.into());
11389        self
11390    }
11391
11392    /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
11393    pub fn set_end_time<T>(mut self, v: T) -> Self
11394    where
11395        T: std::convert::Into<wkt::Timestamp>,
11396    {
11397        self.end_time = std::option::Option::Some(v.into());
11398        self
11399    }
11400
11401    /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
11402    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
11403    where
11404        T: std::convert::Into<wkt::Timestamp>,
11405    {
11406        self.end_time = v.map(|x| x.into());
11407        self
11408    }
11409
11410    /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
11411    pub fn set_soft_start_time<T>(mut self, v: T) -> Self
11412    where
11413        T: std::convert::Into<wkt::Timestamp>,
11414    {
11415        self.soft_start_time = std::option::Option::Some(v.into());
11416        self
11417    }
11418
11419    /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
11420    pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
11421    where
11422        T: std::convert::Into<wkt::Timestamp>,
11423    {
11424        self.soft_start_time = v.map(|x| x.into());
11425        self
11426    }
11427
11428    /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
11429    pub fn set_soft_end_time<T>(mut self, v: T) -> Self
11430    where
11431        T: std::convert::Into<wkt::Timestamp>,
11432    {
11433        self.soft_end_time = std::option::Option::Some(v.into());
11434        self
11435    }
11436
11437    /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
11438    pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
11439    where
11440        T: std::convert::Into<wkt::Timestamp>,
11441    {
11442        self.soft_end_time = v.map(|x| x.into());
11443        self
11444    }
11445
11446    /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
11447    pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
11448    where
11449        T: std::convert::Into<f64>,
11450    {
11451        self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
11452        self
11453    }
11454
11455    /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
11456    pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
11457        mut self,
11458        v: std::option::Option<T>,
11459    ) -> Self
11460    where
11461        T: std::convert::Into<f64>,
11462    {
11463        self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
11464        self
11465    }
11466
11467    /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
11468    pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
11469    where
11470        T: std::convert::Into<f64>,
11471    {
11472        self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
11473        self
11474    }
11475
11476    /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
11477    pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
11478        mut self,
11479        v: std::option::Option<T>,
11480    ) -> Self
11481    where
11482        T: std::convert::Into<f64>,
11483    {
11484        self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
11485        self
11486    }
11487}
11488
11489impl wkt::message::Message for TimeWindow {
11490    fn typename() -> &'static str {
11491        "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
11492    }
11493}
11494
11495#[doc(hidden)]
11496impl<'de> serde::de::Deserialize<'de> for TimeWindow {
11497    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11498    where
11499        D: serde::Deserializer<'de>,
11500    {
11501        #[allow(non_camel_case_types)]
11502        #[doc(hidden)]
11503        #[derive(PartialEq, Eq, Hash)]
11504        enum __FieldTag {
11505            __start_time,
11506            __end_time,
11507            __soft_start_time,
11508            __soft_end_time,
11509            __cost_per_hour_before_soft_start_time,
11510            __cost_per_hour_after_soft_end_time,
11511            Unknown(std::string::String),
11512        }
11513        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11514            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11515            where
11516                D: serde::Deserializer<'de>,
11517            {
11518                struct Visitor;
11519                impl<'de> serde::de::Visitor<'de> for Visitor {
11520                    type Value = __FieldTag;
11521                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11522                        formatter.write_str("a field name for TimeWindow")
11523                    }
11524                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11525                    where
11526                        E: serde::de::Error,
11527                    {
11528                        use std::result::Result::Ok;
11529                        use std::string::ToString;
11530                        match value {
11531                            "startTime" => Ok(__FieldTag::__start_time),
11532                            "start_time" => Ok(__FieldTag::__start_time),
11533                            "endTime" => Ok(__FieldTag::__end_time),
11534                            "end_time" => Ok(__FieldTag::__end_time),
11535                            "softStartTime" => Ok(__FieldTag::__soft_start_time),
11536                            "soft_start_time" => Ok(__FieldTag::__soft_start_time),
11537                            "softEndTime" => Ok(__FieldTag::__soft_end_time),
11538                            "soft_end_time" => Ok(__FieldTag::__soft_end_time),
11539                            "costPerHourBeforeSoftStartTime" => {
11540                                Ok(__FieldTag::__cost_per_hour_before_soft_start_time)
11541                            }
11542                            "cost_per_hour_before_soft_start_time" => {
11543                                Ok(__FieldTag::__cost_per_hour_before_soft_start_time)
11544                            }
11545                            "costPerHourAfterSoftEndTime" => {
11546                                Ok(__FieldTag::__cost_per_hour_after_soft_end_time)
11547                            }
11548                            "cost_per_hour_after_soft_end_time" => {
11549                                Ok(__FieldTag::__cost_per_hour_after_soft_end_time)
11550                            }
11551                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11552                        }
11553                    }
11554                }
11555                deserializer.deserialize_identifier(Visitor)
11556            }
11557        }
11558        struct Visitor;
11559        impl<'de> serde::de::Visitor<'de> for Visitor {
11560            type Value = TimeWindow;
11561            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11562                formatter.write_str("struct TimeWindow")
11563            }
11564            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11565            where
11566                A: serde::de::MapAccess<'de>,
11567            {
11568                #[allow(unused_imports)]
11569                use serde::de::Error;
11570                use std::option::Option::Some;
11571                let mut fields = std::collections::HashSet::new();
11572                let mut result = Self::Value::new();
11573                while let Some(tag) = map.next_key::<__FieldTag>()? {
11574                    #[allow(clippy::match_single_binding)]
11575                    match tag {
11576                        __FieldTag::__start_time => {
11577                            if !fields.insert(__FieldTag::__start_time) {
11578                                return std::result::Result::Err(A::Error::duplicate_field(
11579                                    "multiple values for start_time",
11580                                ));
11581                            }
11582                            result.start_time =
11583                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11584                        }
11585                        __FieldTag::__end_time => {
11586                            if !fields.insert(__FieldTag::__end_time) {
11587                                return std::result::Result::Err(A::Error::duplicate_field(
11588                                    "multiple values for end_time",
11589                                ));
11590                            }
11591                            result.end_time =
11592                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11593                        }
11594                        __FieldTag::__soft_start_time => {
11595                            if !fields.insert(__FieldTag::__soft_start_time) {
11596                                return std::result::Result::Err(A::Error::duplicate_field(
11597                                    "multiple values for soft_start_time",
11598                                ));
11599                            }
11600                            result.soft_start_time =
11601                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11602                        }
11603                        __FieldTag::__soft_end_time => {
11604                            if !fields.insert(__FieldTag::__soft_end_time) {
11605                                return std::result::Result::Err(A::Error::duplicate_field(
11606                                    "multiple values for soft_end_time",
11607                                ));
11608                            }
11609                            result.soft_end_time =
11610                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11611                        }
11612                        __FieldTag::__cost_per_hour_before_soft_start_time => {
11613                            if !fields.insert(__FieldTag::__cost_per_hour_before_soft_start_time) {
11614                                return std::result::Result::Err(A::Error::duplicate_field(
11615                                    "multiple values for cost_per_hour_before_soft_start_time",
11616                                ));
11617                            }
11618                            struct __With(std::option::Option<f64>);
11619                            impl<'de> serde::de::Deserialize<'de> for __With {
11620                                fn deserialize<D>(
11621                                    deserializer: D,
11622                                ) -> std::result::Result<Self, D::Error>
11623                                where
11624                                    D: serde::de::Deserializer<'de>,
11625                                {
11626                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11627                                }
11628                            }
11629                            result.cost_per_hour_before_soft_start_time =
11630                                map.next_value::<__With>()?.0;
11631                        }
11632                        __FieldTag::__cost_per_hour_after_soft_end_time => {
11633                            if !fields.insert(__FieldTag::__cost_per_hour_after_soft_end_time) {
11634                                return std::result::Result::Err(A::Error::duplicate_field(
11635                                    "multiple values for cost_per_hour_after_soft_end_time",
11636                                ));
11637                            }
11638                            struct __With(std::option::Option<f64>);
11639                            impl<'de> serde::de::Deserialize<'de> for __With {
11640                                fn deserialize<D>(
11641                                    deserializer: D,
11642                                ) -> std::result::Result<Self, D::Error>
11643                                where
11644                                    D: serde::de::Deserializer<'de>,
11645                                {
11646                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11647                                }
11648                            }
11649                            result.cost_per_hour_after_soft_end_time =
11650                                map.next_value::<__With>()?.0;
11651                        }
11652                        __FieldTag::Unknown(key) => {
11653                            let value = map.next_value::<serde_json::Value>()?;
11654                            result._unknown_fields.insert(key, value);
11655                        }
11656                    }
11657                }
11658                std::result::Result::Ok(result)
11659            }
11660        }
11661        deserializer.deserialize_any(Visitor)
11662    }
11663}
11664
11665#[doc(hidden)]
11666impl serde::ser::Serialize for TimeWindow {
11667    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11668    where
11669        S: serde::ser::Serializer,
11670    {
11671        use serde::ser::SerializeMap;
11672        #[allow(unused_imports)]
11673        use std::option::Option::Some;
11674        let mut state = serializer.serialize_map(std::option::Option::None)?;
11675        if self.start_time.is_some() {
11676            state.serialize_entry("startTime", &self.start_time)?;
11677        }
11678        if self.end_time.is_some() {
11679            state.serialize_entry("endTime", &self.end_time)?;
11680        }
11681        if self.soft_start_time.is_some() {
11682            state.serialize_entry("softStartTime", &self.soft_start_time)?;
11683        }
11684        if self.soft_end_time.is_some() {
11685            state.serialize_entry("softEndTime", &self.soft_end_time)?;
11686        }
11687        if self.cost_per_hour_before_soft_start_time.is_some() {
11688            struct __With<'a>(&'a std::option::Option<f64>);
11689            impl<'a> serde::ser::Serialize for __With<'a> {
11690                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11691                where
11692                    S: serde::ser::Serializer,
11693                {
11694                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
11695                        self.0, serializer,
11696                    )
11697                }
11698            }
11699            state.serialize_entry(
11700                "costPerHourBeforeSoftStartTime",
11701                &__With(&self.cost_per_hour_before_soft_start_time),
11702            )?;
11703        }
11704        if self.cost_per_hour_after_soft_end_time.is_some() {
11705            struct __With<'a>(&'a std::option::Option<f64>);
11706            impl<'a> serde::ser::Serialize for __With<'a> {
11707                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11708                where
11709                    S: serde::ser::Serializer,
11710                {
11711                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
11712                        self.0, serializer,
11713                    )
11714                }
11715            }
11716            state.serialize_entry(
11717                "costPerHourAfterSoftEndTime",
11718                &__With(&self.cost_per_hour_after_soft_end_time),
11719            )?;
11720        }
11721        if !self._unknown_fields.is_empty() {
11722            for (key, value) in self._unknown_fields.iter() {
11723                state.serialize_entry(key, &value)?;
11724            }
11725        }
11726        state.end()
11727    }
11728}
11729
11730impl std::fmt::Debug for TimeWindow {
11731    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11732        let mut debug_struct = f.debug_struct("TimeWindow");
11733        debug_struct.field("start_time", &self.start_time);
11734        debug_struct.field("end_time", &self.end_time);
11735        debug_struct.field("soft_start_time", &self.soft_start_time);
11736        debug_struct.field("soft_end_time", &self.soft_end_time);
11737        debug_struct.field(
11738            "cost_per_hour_before_soft_start_time",
11739            &self.cost_per_hour_before_soft_start_time,
11740        );
11741        debug_struct.field(
11742            "cost_per_hour_after_soft_end_time",
11743            &self.cost_per_hour_after_soft_end_time,
11744        );
11745        if !self._unknown_fields.is_empty() {
11746            debug_struct.field("_unknown_fields", &self._unknown_fields);
11747        }
11748        debug_struct.finish()
11749    }
11750}
11751
11752/// Deprecated: Use
11753/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
11754/// instead.
11755///
11756/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
11757#[derive(Clone, Default, PartialEq)]
11758#[non_exhaustive]
11759#[deprecated]
11760pub struct CapacityQuantity {
11761    pub r#type: std::string::String,
11762
11763    pub value: i64,
11764
11765    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11766}
11767
11768impl CapacityQuantity {
11769    pub fn new() -> Self {
11770        std::default::Default::default()
11771    }
11772
11773    /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
11774    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11775        self.r#type = v.into();
11776        self
11777    }
11778
11779    /// Sets the value of [value][crate::model::CapacityQuantity::value].
11780    pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
11781        self.value = v.into();
11782        self
11783    }
11784}
11785
11786impl wkt::message::Message for CapacityQuantity {
11787    fn typename() -> &'static str {
11788        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
11789    }
11790}
11791
11792#[doc(hidden)]
11793impl<'de> serde::de::Deserialize<'de> for CapacityQuantity {
11794    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11795    where
11796        D: serde::Deserializer<'de>,
11797    {
11798        #[allow(non_camel_case_types)]
11799        #[doc(hidden)]
11800        #[derive(PartialEq, Eq, Hash)]
11801        enum __FieldTag {
11802            __type,
11803            __value,
11804            Unknown(std::string::String),
11805        }
11806        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11807            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11808            where
11809                D: serde::Deserializer<'de>,
11810            {
11811                struct Visitor;
11812                impl<'de> serde::de::Visitor<'de> for Visitor {
11813                    type Value = __FieldTag;
11814                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11815                        formatter.write_str("a field name for CapacityQuantity")
11816                    }
11817                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11818                    where
11819                        E: serde::de::Error,
11820                    {
11821                        use std::result::Result::Ok;
11822                        use std::string::ToString;
11823                        match value {
11824                            "type" => Ok(__FieldTag::__type),
11825                            "value" => Ok(__FieldTag::__value),
11826                            _ => Ok(__FieldTag::Unknown(value.to_string())),
11827                        }
11828                    }
11829                }
11830                deserializer.deserialize_identifier(Visitor)
11831            }
11832        }
11833        struct Visitor;
11834        impl<'de> serde::de::Visitor<'de> for Visitor {
11835            type Value = CapacityQuantity;
11836            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11837                formatter.write_str("struct CapacityQuantity")
11838            }
11839            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11840            where
11841                A: serde::de::MapAccess<'de>,
11842            {
11843                #[allow(unused_imports)]
11844                use serde::de::Error;
11845                use std::option::Option::Some;
11846                let mut fields = std::collections::HashSet::new();
11847                let mut result = Self::Value::new();
11848                while let Some(tag) = map.next_key::<__FieldTag>()? {
11849                    #[allow(clippy::match_single_binding)]
11850                    match tag {
11851                        __FieldTag::__type => {
11852                            if !fields.insert(__FieldTag::__type) {
11853                                return std::result::Result::Err(A::Error::duplicate_field(
11854                                    "multiple values for type",
11855                                ));
11856                            }
11857                            result.r#type = map
11858                                .next_value::<std::option::Option<std::string::String>>()?
11859                                .unwrap_or_default();
11860                        }
11861                        __FieldTag::__value => {
11862                            if !fields.insert(__FieldTag::__value) {
11863                                return std::result::Result::Err(A::Error::duplicate_field(
11864                                    "multiple values for value",
11865                                ));
11866                            }
11867                            struct __With(std::option::Option<i64>);
11868                            impl<'de> serde::de::Deserialize<'de> for __With {
11869                                fn deserialize<D>(
11870                                    deserializer: D,
11871                                ) -> std::result::Result<Self, D::Error>
11872                                where
11873                                    D: serde::de::Deserializer<'de>,
11874                                {
11875                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11876                                }
11877                            }
11878                            result.value = map.next_value::<__With>()?.0.unwrap_or_default();
11879                        }
11880                        __FieldTag::Unknown(key) => {
11881                            let value = map.next_value::<serde_json::Value>()?;
11882                            result._unknown_fields.insert(key, value);
11883                        }
11884                    }
11885                }
11886                std::result::Result::Ok(result)
11887            }
11888        }
11889        deserializer.deserialize_any(Visitor)
11890    }
11891}
11892
11893#[doc(hidden)]
11894impl serde::ser::Serialize for CapacityQuantity {
11895    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11896    where
11897        S: serde::ser::Serializer,
11898    {
11899        use serde::ser::SerializeMap;
11900        #[allow(unused_imports)]
11901        use std::option::Option::Some;
11902        let mut state = serializer.serialize_map(std::option::Option::None)?;
11903        if !self.r#type.is_empty() {
11904            state.serialize_entry("type", &self.r#type)?;
11905        }
11906        if !wkt::internal::is_default(&self.value) {
11907            struct __With<'a>(&'a i64);
11908            impl<'a> serde::ser::Serialize for __With<'a> {
11909                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11910                where
11911                    S: serde::ser::Serializer,
11912                {
11913                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
11914                }
11915            }
11916            state.serialize_entry("value", &__With(&self.value))?;
11917        }
11918        if !self._unknown_fields.is_empty() {
11919            for (key, value) in self._unknown_fields.iter() {
11920                state.serialize_entry(key, &value)?;
11921            }
11922        }
11923        state.end()
11924    }
11925}
11926
11927impl std::fmt::Debug for CapacityQuantity {
11928    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11929        let mut debug_struct = f.debug_struct("CapacityQuantity");
11930        debug_struct.field("r#type", &self.r#type);
11931        debug_struct.field("value", &self.value);
11932        if !self._unknown_fields.is_empty() {
11933            debug_struct.field("_unknown_fields", &self._unknown_fields);
11934        }
11935        debug_struct.finish()
11936    }
11937}
11938
11939/// Deprecated: Use
11940/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
11941/// instead.
11942///
11943/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
11944#[derive(Clone, Default, PartialEq)]
11945#[non_exhaustive]
11946#[deprecated]
11947pub struct CapacityQuantityInterval {
11948    pub r#type: std::string::String,
11949
11950    pub min_value: std::option::Option<i64>,
11951
11952    pub max_value: std::option::Option<i64>,
11953
11954    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11955}
11956
11957impl CapacityQuantityInterval {
11958    pub fn new() -> Self {
11959        std::default::Default::default()
11960    }
11961
11962    /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
11963    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11964        self.r#type = v.into();
11965        self
11966    }
11967
11968    /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
11969    pub fn set_min_value<T>(mut self, v: T) -> Self
11970    where
11971        T: std::convert::Into<i64>,
11972    {
11973        self.min_value = std::option::Option::Some(v.into());
11974        self
11975    }
11976
11977    /// Sets or clears the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
11978    pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
11979    where
11980        T: std::convert::Into<i64>,
11981    {
11982        self.min_value = v.map(|x| x.into());
11983        self
11984    }
11985
11986    /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
11987    pub fn set_max_value<T>(mut self, v: T) -> Self
11988    where
11989        T: std::convert::Into<i64>,
11990    {
11991        self.max_value = std::option::Option::Some(v.into());
11992        self
11993    }
11994
11995    /// Sets or clears the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
11996    pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
11997    where
11998        T: std::convert::Into<i64>,
11999    {
12000        self.max_value = v.map(|x| x.into());
12001        self
12002    }
12003}
12004
12005impl wkt::message::Message for CapacityQuantityInterval {
12006    fn typename() -> &'static str {
12007        "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
12008    }
12009}
12010
12011#[doc(hidden)]
12012impl<'de> serde::de::Deserialize<'de> for CapacityQuantityInterval {
12013    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12014    where
12015        D: serde::Deserializer<'de>,
12016    {
12017        #[allow(non_camel_case_types)]
12018        #[doc(hidden)]
12019        #[derive(PartialEq, Eq, Hash)]
12020        enum __FieldTag {
12021            __type,
12022            __min_value,
12023            __max_value,
12024            Unknown(std::string::String),
12025        }
12026        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12027            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12028            where
12029                D: serde::Deserializer<'de>,
12030            {
12031                struct Visitor;
12032                impl<'de> serde::de::Visitor<'de> for Visitor {
12033                    type Value = __FieldTag;
12034                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12035                        formatter.write_str("a field name for CapacityQuantityInterval")
12036                    }
12037                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12038                    where
12039                        E: serde::de::Error,
12040                    {
12041                        use std::result::Result::Ok;
12042                        use std::string::ToString;
12043                        match value {
12044                            "type" => Ok(__FieldTag::__type),
12045                            "minValue" => Ok(__FieldTag::__min_value),
12046                            "min_value" => Ok(__FieldTag::__min_value),
12047                            "maxValue" => Ok(__FieldTag::__max_value),
12048                            "max_value" => Ok(__FieldTag::__max_value),
12049                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12050                        }
12051                    }
12052                }
12053                deserializer.deserialize_identifier(Visitor)
12054            }
12055        }
12056        struct Visitor;
12057        impl<'de> serde::de::Visitor<'de> for Visitor {
12058            type Value = CapacityQuantityInterval;
12059            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12060                formatter.write_str("struct CapacityQuantityInterval")
12061            }
12062            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12063            where
12064                A: serde::de::MapAccess<'de>,
12065            {
12066                #[allow(unused_imports)]
12067                use serde::de::Error;
12068                use std::option::Option::Some;
12069                let mut fields = std::collections::HashSet::new();
12070                let mut result = Self::Value::new();
12071                while let Some(tag) = map.next_key::<__FieldTag>()? {
12072                    #[allow(clippy::match_single_binding)]
12073                    match tag {
12074                        __FieldTag::__type => {
12075                            if !fields.insert(__FieldTag::__type) {
12076                                return std::result::Result::Err(A::Error::duplicate_field(
12077                                    "multiple values for type",
12078                                ));
12079                            }
12080                            result.r#type = map
12081                                .next_value::<std::option::Option<std::string::String>>()?
12082                                .unwrap_or_default();
12083                        }
12084                        __FieldTag::__min_value => {
12085                            if !fields.insert(__FieldTag::__min_value) {
12086                                return std::result::Result::Err(A::Error::duplicate_field(
12087                                    "multiple values for min_value",
12088                                ));
12089                            }
12090                            struct __With(std::option::Option<i64>);
12091                            impl<'de> serde::de::Deserialize<'de> for __With {
12092                                fn deserialize<D>(
12093                                    deserializer: D,
12094                                ) -> std::result::Result<Self, D::Error>
12095                                where
12096                                    D: serde::de::Deserializer<'de>,
12097                                {
12098                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
12099                                }
12100                            }
12101                            result.min_value = map.next_value::<__With>()?.0;
12102                        }
12103                        __FieldTag::__max_value => {
12104                            if !fields.insert(__FieldTag::__max_value) {
12105                                return std::result::Result::Err(A::Error::duplicate_field(
12106                                    "multiple values for max_value",
12107                                ));
12108                            }
12109                            struct __With(std::option::Option<i64>);
12110                            impl<'de> serde::de::Deserialize<'de> for __With {
12111                                fn deserialize<D>(
12112                                    deserializer: D,
12113                                ) -> std::result::Result<Self, D::Error>
12114                                where
12115                                    D: serde::de::Deserializer<'de>,
12116                                {
12117                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
12118                                }
12119                            }
12120                            result.max_value = map.next_value::<__With>()?.0;
12121                        }
12122                        __FieldTag::Unknown(key) => {
12123                            let value = map.next_value::<serde_json::Value>()?;
12124                            result._unknown_fields.insert(key, value);
12125                        }
12126                    }
12127                }
12128                std::result::Result::Ok(result)
12129            }
12130        }
12131        deserializer.deserialize_any(Visitor)
12132    }
12133}
12134
12135#[doc(hidden)]
12136impl serde::ser::Serialize for CapacityQuantityInterval {
12137    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12138    where
12139        S: serde::ser::Serializer,
12140    {
12141        use serde::ser::SerializeMap;
12142        #[allow(unused_imports)]
12143        use std::option::Option::Some;
12144        let mut state = serializer.serialize_map(std::option::Option::None)?;
12145        if !self.r#type.is_empty() {
12146            state.serialize_entry("type", &self.r#type)?;
12147        }
12148        if self.min_value.is_some() {
12149            struct __With<'a>(&'a std::option::Option<i64>);
12150            impl<'a> serde::ser::Serialize for __With<'a> {
12151                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12152                where
12153                    S: serde::ser::Serializer,
12154                {
12155                    serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
12156                        self.0, serializer,
12157                    )
12158                }
12159            }
12160            state.serialize_entry("minValue", &__With(&self.min_value))?;
12161        }
12162        if self.max_value.is_some() {
12163            struct __With<'a>(&'a std::option::Option<i64>);
12164            impl<'a> serde::ser::Serialize for __With<'a> {
12165                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12166                where
12167                    S: serde::ser::Serializer,
12168                {
12169                    serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
12170                        self.0, serializer,
12171                    )
12172                }
12173            }
12174            state.serialize_entry("maxValue", &__With(&self.max_value))?;
12175        }
12176        if !self._unknown_fields.is_empty() {
12177            for (key, value) in self._unknown_fields.iter() {
12178                state.serialize_entry(key, &value)?;
12179            }
12180        }
12181        state.end()
12182    }
12183}
12184
12185impl std::fmt::Debug for CapacityQuantityInterval {
12186    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12187        let mut debug_struct = f.debug_struct("CapacityQuantityInterval");
12188        debug_struct.field("r#type", &self.r#type);
12189        debug_struct.field("min_value", &self.min_value);
12190        debug_struct.field("max_value", &self.max_value);
12191        if !self._unknown_fields.is_empty() {
12192            debug_struct.field("_unknown_fields", &self._unknown_fields);
12193        }
12194        debug_struct.finish()
12195    }
12196}
12197
12198/// A limit defining a maximum distance which can be traveled. It can be either
12199/// hard or soft.
12200///
12201/// If a soft limit is defined, both `soft_max_meters` and
12202/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
12203#[derive(Clone, Default, PartialEq)]
12204#[non_exhaustive]
12205pub struct DistanceLimit {
12206    /// A hard limit constraining the distance to be at most max_meters. The limit
12207    /// must be nonnegative.
12208    pub max_meters: std::option::Option<i64>,
12209
12210    /// A soft limit not enforcing a maximum distance limit, but when violated
12211    /// results in a cost which adds up to other costs defined in the model,
12212    /// with the same unit.
12213    ///
12214    /// If defined soft_max_meters must be less than max_meters and must be
12215    /// nonnegative.
12216    pub soft_max_meters: std::option::Option<i64>,
12217
12218    /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
12219    /// formula:
12220    ///
12221    /// ```norust
12222    ///   min(distance_meters, soft_max_meters) / 1000.0 *
12223    ///   cost_per_kilometer_below_soft_max.
12224    /// ```
12225    ///
12226    /// This cost is not supported in `route_distance_limit`.
12227    pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
12228
12229    /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
12230    /// The additional cost is 0 if the distance is under the limit, otherwise the
12231    /// formula used to compute the cost is the following:
12232    ///
12233    /// ```norust
12234    ///   (distance_meters - soft_max_meters) / 1000.0 *
12235    ///   cost_per_kilometer_above_soft_max.
12236    /// ```
12237    ///
12238    /// The cost must be nonnegative.
12239    pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
12240
12241    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12242}
12243
12244impl DistanceLimit {
12245    pub fn new() -> Self {
12246        std::default::Default::default()
12247    }
12248
12249    /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
12250    pub fn set_max_meters<T>(mut self, v: T) -> Self
12251    where
12252        T: std::convert::Into<i64>,
12253    {
12254        self.max_meters = std::option::Option::Some(v.into());
12255        self
12256    }
12257
12258    /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
12259    pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
12260    where
12261        T: std::convert::Into<i64>,
12262    {
12263        self.max_meters = v.map(|x| x.into());
12264        self
12265    }
12266
12267    /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
12268    pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
12269    where
12270        T: std::convert::Into<i64>,
12271    {
12272        self.soft_max_meters = std::option::Option::Some(v.into());
12273        self
12274    }
12275
12276    /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
12277    pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
12278    where
12279        T: std::convert::Into<i64>,
12280    {
12281        self.soft_max_meters = v.map(|x| x.into());
12282        self
12283    }
12284
12285    /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
12286    pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
12287    where
12288        T: std::convert::Into<f64>,
12289    {
12290        self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
12291        self
12292    }
12293
12294    /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
12295    pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
12296        mut self,
12297        v: std::option::Option<T>,
12298    ) -> Self
12299    where
12300        T: std::convert::Into<f64>,
12301    {
12302        self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
12303        self
12304    }
12305
12306    /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
12307    pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
12308    where
12309        T: std::convert::Into<f64>,
12310    {
12311        self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
12312        self
12313    }
12314
12315    /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
12316    pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
12317        mut self,
12318        v: std::option::Option<T>,
12319    ) -> Self
12320    where
12321        T: std::convert::Into<f64>,
12322    {
12323        self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
12324        self
12325    }
12326}
12327
12328impl wkt::message::Message for DistanceLimit {
12329    fn typename() -> &'static str {
12330        "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
12331    }
12332}
12333
12334#[doc(hidden)]
12335impl<'de> serde::de::Deserialize<'de> for DistanceLimit {
12336    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12337    where
12338        D: serde::Deserializer<'de>,
12339    {
12340        #[allow(non_camel_case_types)]
12341        #[doc(hidden)]
12342        #[derive(PartialEq, Eq, Hash)]
12343        enum __FieldTag {
12344            __max_meters,
12345            __soft_max_meters,
12346            __cost_per_kilometer_below_soft_max,
12347            __cost_per_kilometer_above_soft_max,
12348            Unknown(std::string::String),
12349        }
12350        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12351            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12352            where
12353                D: serde::Deserializer<'de>,
12354            {
12355                struct Visitor;
12356                impl<'de> serde::de::Visitor<'de> for Visitor {
12357                    type Value = __FieldTag;
12358                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12359                        formatter.write_str("a field name for DistanceLimit")
12360                    }
12361                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12362                    where
12363                        E: serde::de::Error,
12364                    {
12365                        use std::result::Result::Ok;
12366                        use std::string::ToString;
12367                        match value {
12368                            "maxMeters" => Ok(__FieldTag::__max_meters),
12369                            "max_meters" => Ok(__FieldTag::__max_meters),
12370                            "softMaxMeters" => Ok(__FieldTag::__soft_max_meters),
12371                            "soft_max_meters" => Ok(__FieldTag::__soft_max_meters),
12372                            "costPerKilometerBelowSoftMax" => {
12373                                Ok(__FieldTag::__cost_per_kilometer_below_soft_max)
12374                            }
12375                            "cost_per_kilometer_below_soft_max" => {
12376                                Ok(__FieldTag::__cost_per_kilometer_below_soft_max)
12377                            }
12378                            "costPerKilometerAboveSoftMax" => {
12379                                Ok(__FieldTag::__cost_per_kilometer_above_soft_max)
12380                            }
12381                            "cost_per_kilometer_above_soft_max" => {
12382                                Ok(__FieldTag::__cost_per_kilometer_above_soft_max)
12383                            }
12384                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12385                        }
12386                    }
12387                }
12388                deserializer.deserialize_identifier(Visitor)
12389            }
12390        }
12391        struct Visitor;
12392        impl<'de> serde::de::Visitor<'de> for Visitor {
12393            type Value = DistanceLimit;
12394            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12395                formatter.write_str("struct DistanceLimit")
12396            }
12397            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12398            where
12399                A: serde::de::MapAccess<'de>,
12400            {
12401                #[allow(unused_imports)]
12402                use serde::de::Error;
12403                use std::option::Option::Some;
12404                let mut fields = std::collections::HashSet::new();
12405                let mut result = Self::Value::new();
12406                while let Some(tag) = map.next_key::<__FieldTag>()? {
12407                    #[allow(clippy::match_single_binding)]
12408                    match tag {
12409                        __FieldTag::__max_meters => {
12410                            if !fields.insert(__FieldTag::__max_meters) {
12411                                return std::result::Result::Err(A::Error::duplicate_field(
12412                                    "multiple values for max_meters",
12413                                ));
12414                            }
12415                            struct __With(std::option::Option<i64>);
12416                            impl<'de> serde::de::Deserialize<'de> for __With {
12417                                fn deserialize<D>(
12418                                    deserializer: D,
12419                                ) -> std::result::Result<Self, D::Error>
12420                                where
12421                                    D: serde::de::Deserializer<'de>,
12422                                {
12423                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
12424                                }
12425                            }
12426                            result.max_meters = map.next_value::<__With>()?.0;
12427                        }
12428                        __FieldTag::__soft_max_meters => {
12429                            if !fields.insert(__FieldTag::__soft_max_meters) {
12430                                return std::result::Result::Err(A::Error::duplicate_field(
12431                                    "multiple values for soft_max_meters",
12432                                ));
12433                            }
12434                            struct __With(std::option::Option<i64>);
12435                            impl<'de> serde::de::Deserialize<'de> for __With {
12436                                fn deserialize<D>(
12437                                    deserializer: D,
12438                                ) -> std::result::Result<Self, D::Error>
12439                                where
12440                                    D: serde::de::Deserializer<'de>,
12441                                {
12442                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
12443                                }
12444                            }
12445                            result.soft_max_meters = map.next_value::<__With>()?.0;
12446                        }
12447                        __FieldTag::__cost_per_kilometer_below_soft_max => {
12448                            if !fields.insert(__FieldTag::__cost_per_kilometer_below_soft_max) {
12449                                return std::result::Result::Err(A::Error::duplicate_field(
12450                                    "multiple values for cost_per_kilometer_below_soft_max",
12451                                ));
12452                            }
12453                            struct __With(std::option::Option<f64>);
12454                            impl<'de> serde::de::Deserialize<'de> for __With {
12455                                fn deserialize<D>(
12456                                    deserializer: D,
12457                                ) -> std::result::Result<Self, D::Error>
12458                                where
12459                                    D: serde::de::Deserializer<'de>,
12460                                {
12461                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
12462                                }
12463                            }
12464                            result.cost_per_kilometer_below_soft_max =
12465                                map.next_value::<__With>()?.0;
12466                        }
12467                        __FieldTag::__cost_per_kilometer_above_soft_max => {
12468                            if !fields.insert(__FieldTag::__cost_per_kilometer_above_soft_max) {
12469                                return std::result::Result::Err(A::Error::duplicate_field(
12470                                    "multiple values for cost_per_kilometer_above_soft_max",
12471                                ));
12472                            }
12473                            struct __With(std::option::Option<f64>);
12474                            impl<'de> serde::de::Deserialize<'de> for __With {
12475                                fn deserialize<D>(
12476                                    deserializer: D,
12477                                ) -> std::result::Result<Self, D::Error>
12478                                where
12479                                    D: serde::de::Deserializer<'de>,
12480                                {
12481                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
12482                                }
12483                            }
12484                            result.cost_per_kilometer_above_soft_max =
12485                                map.next_value::<__With>()?.0;
12486                        }
12487                        __FieldTag::Unknown(key) => {
12488                            let value = map.next_value::<serde_json::Value>()?;
12489                            result._unknown_fields.insert(key, value);
12490                        }
12491                    }
12492                }
12493                std::result::Result::Ok(result)
12494            }
12495        }
12496        deserializer.deserialize_any(Visitor)
12497    }
12498}
12499
12500#[doc(hidden)]
12501impl serde::ser::Serialize for DistanceLimit {
12502    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12503    where
12504        S: serde::ser::Serializer,
12505    {
12506        use serde::ser::SerializeMap;
12507        #[allow(unused_imports)]
12508        use std::option::Option::Some;
12509        let mut state = serializer.serialize_map(std::option::Option::None)?;
12510        if self.max_meters.is_some() {
12511            struct __With<'a>(&'a std::option::Option<i64>);
12512            impl<'a> serde::ser::Serialize for __With<'a> {
12513                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12514                where
12515                    S: serde::ser::Serializer,
12516                {
12517                    serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
12518                        self.0, serializer,
12519                    )
12520                }
12521            }
12522            state.serialize_entry("maxMeters", &__With(&self.max_meters))?;
12523        }
12524        if self.soft_max_meters.is_some() {
12525            struct __With<'a>(&'a std::option::Option<i64>);
12526            impl<'a> serde::ser::Serialize for __With<'a> {
12527                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12528                where
12529                    S: serde::ser::Serializer,
12530                {
12531                    serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
12532                        self.0, serializer,
12533                    )
12534                }
12535            }
12536            state.serialize_entry("softMaxMeters", &__With(&self.soft_max_meters))?;
12537        }
12538        if self.cost_per_kilometer_below_soft_max.is_some() {
12539            struct __With<'a>(&'a std::option::Option<f64>);
12540            impl<'a> serde::ser::Serialize for __With<'a> {
12541                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12542                where
12543                    S: serde::ser::Serializer,
12544                {
12545                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
12546                        self.0, serializer,
12547                    )
12548                }
12549            }
12550            state.serialize_entry(
12551                "costPerKilometerBelowSoftMax",
12552                &__With(&self.cost_per_kilometer_below_soft_max),
12553            )?;
12554        }
12555        if self.cost_per_kilometer_above_soft_max.is_some() {
12556            struct __With<'a>(&'a std::option::Option<f64>);
12557            impl<'a> serde::ser::Serialize for __With<'a> {
12558                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12559                where
12560                    S: serde::ser::Serializer,
12561                {
12562                    serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
12563                        self.0, serializer,
12564                    )
12565                }
12566            }
12567            state.serialize_entry(
12568                "costPerKilometerAboveSoftMax",
12569                &__With(&self.cost_per_kilometer_above_soft_max),
12570            )?;
12571        }
12572        if !self._unknown_fields.is_empty() {
12573            for (key, value) in self._unknown_fields.iter() {
12574                state.serialize_entry(key, &value)?;
12575            }
12576        }
12577        state.end()
12578    }
12579}
12580
12581impl std::fmt::Debug for DistanceLimit {
12582    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12583        let mut debug_struct = f.debug_struct("DistanceLimit");
12584        debug_struct.field("max_meters", &self.max_meters);
12585        debug_struct.field("soft_max_meters", &self.soft_max_meters);
12586        debug_struct.field(
12587            "cost_per_kilometer_below_soft_max",
12588            &self.cost_per_kilometer_below_soft_max,
12589        );
12590        debug_struct.field(
12591            "cost_per_kilometer_above_soft_max",
12592            &self.cost_per_kilometer_above_soft_max,
12593        );
12594        if !self._unknown_fields.is_empty() {
12595            debug_struct.field("_unknown_fields", &self._unknown_fields);
12596        }
12597        debug_struct.finish()
12598    }
12599}
12600
12601/// Specifies attributes of transitions between two consecutive visits on a
12602/// route. Several `TransitionAttributes` may apply to the same transition: in
12603/// that case, all extra costs add up and the strictest constraint or limit
12604/// applies (following natural "AND" semantics).
12605#[derive(Clone, Default, PartialEq)]
12606#[non_exhaustive]
12607pub struct TransitionAttributes {
12608    /// Tags defining the set of (src->dst) transitions these attributes apply to.
12609    ///
12610    /// A source visit or vehicle start matches iff its
12611    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
12612    /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
12613    /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
12614    /// on which of these two fields is non-empty).
12615    ///
12616    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
12617    /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
12618    pub src_tag: std::string::String,
12619
12620    /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
12621    /// non-empty.
12622    pub excluded_src_tag: std::string::String,
12623
12624    /// A destination visit or vehicle end matches iff its
12625    /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
12626    /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
12627    /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
12628    /// which of these two fields is non-empty).
12629    ///
12630    /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
12631    /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
12632    pub dst_tag: std::string::String,
12633
12634    /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
12635    /// non-empty.
12636    pub excluded_dst_tag: std::string::String,
12637
12638    /// Specifies a cost for performing this transition. This is in the same unit
12639    /// as all other costs in the model and must not be negative. It is applied on
12640    /// top of all other existing costs.
12641    pub cost: f64,
12642
12643    /// Specifies a cost per kilometer applied to the distance traveled while
12644    /// performing this transition. It adds up to any
12645    /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
12646    /// specified on vehicles.
12647    ///
12648    /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
12649    pub cost_per_kilometer: f64,
12650
12651    /// Specifies a limit on the distance traveled while performing this
12652    /// transition.
12653    ///
12654    /// As of 2021/06, only soft limits are supported.
12655    pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
12656
12657    /// Specifies a delay incurred when performing this transition.
12658    ///
12659    /// This delay always occurs *after* finishing the source visit and *before*
12660    /// starting the destination visit.
12661    pub delay: std::option::Option<wkt::Duration>,
12662
12663    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12664}
12665
12666impl TransitionAttributes {
12667    pub fn new() -> Self {
12668        std::default::Default::default()
12669    }
12670
12671    /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
12672    pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12673        self.src_tag = v.into();
12674        self
12675    }
12676
12677    /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
12678    pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
12679        mut self,
12680        v: T,
12681    ) -> Self {
12682        self.excluded_src_tag = v.into();
12683        self
12684    }
12685
12686    /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
12687    pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12688        self.dst_tag = v.into();
12689        self
12690    }
12691
12692    /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
12693    pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
12694        mut self,
12695        v: T,
12696    ) -> Self {
12697        self.excluded_dst_tag = v.into();
12698        self
12699    }
12700
12701    /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
12702    pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
12703        self.cost = v.into();
12704        self
12705    }
12706
12707    /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
12708    pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
12709        self.cost_per_kilometer = v.into();
12710        self
12711    }
12712
12713    /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
12714    pub fn set_distance_limit<T>(mut self, v: T) -> Self
12715    where
12716        T: std::convert::Into<crate::model::DistanceLimit>,
12717    {
12718        self.distance_limit = std::option::Option::Some(v.into());
12719        self
12720    }
12721
12722    /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
12723    pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
12724    where
12725        T: std::convert::Into<crate::model::DistanceLimit>,
12726    {
12727        self.distance_limit = v.map(|x| x.into());
12728        self
12729    }
12730
12731    /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
12732    pub fn set_delay<T>(mut self, v: T) -> Self
12733    where
12734        T: std::convert::Into<wkt::Duration>,
12735    {
12736        self.delay = std::option::Option::Some(v.into());
12737        self
12738    }
12739
12740    /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
12741    pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
12742    where
12743        T: std::convert::Into<wkt::Duration>,
12744    {
12745        self.delay = v.map(|x| x.into());
12746        self
12747    }
12748}
12749
12750impl wkt::message::Message for TransitionAttributes {
12751    fn typename() -> &'static str {
12752        "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
12753    }
12754}
12755
12756#[doc(hidden)]
12757impl<'de> serde::de::Deserialize<'de> for TransitionAttributes {
12758    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12759    where
12760        D: serde::Deserializer<'de>,
12761    {
12762        #[allow(non_camel_case_types)]
12763        #[doc(hidden)]
12764        #[derive(PartialEq, Eq, Hash)]
12765        enum __FieldTag {
12766            __src_tag,
12767            __excluded_src_tag,
12768            __dst_tag,
12769            __excluded_dst_tag,
12770            __cost,
12771            __cost_per_kilometer,
12772            __distance_limit,
12773            __delay,
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 TransitionAttributes")
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                            "srcTag" => Ok(__FieldTag::__src_tag),
12795                            "src_tag" => Ok(__FieldTag::__src_tag),
12796                            "excludedSrcTag" => Ok(__FieldTag::__excluded_src_tag),
12797                            "excluded_src_tag" => Ok(__FieldTag::__excluded_src_tag),
12798                            "dstTag" => Ok(__FieldTag::__dst_tag),
12799                            "dst_tag" => Ok(__FieldTag::__dst_tag),
12800                            "excludedDstTag" => Ok(__FieldTag::__excluded_dst_tag),
12801                            "excluded_dst_tag" => Ok(__FieldTag::__excluded_dst_tag),
12802                            "cost" => Ok(__FieldTag::__cost),
12803                            "costPerKilometer" => Ok(__FieldTag::__cost_per_kilometer),
12804                            "cost_per_kilometer" => Ok(__FieldTag::__cost_per_kilometer),
12805                            "distanceLimit" => Ok(__FieldTag::__distance_limit),
12806                            "distance_limit" => Ok(__FieldTag::__distance_limit),
12807                            "delay" => Ok(__FieldTag::__delay),
12808                            _ => Ok(__FieldTag::Unknown(value.to_string())),
12809                        }
12810                    }
12811                }
12812                deserializer.deserialize_identifier(Visitor)
12813            }
12814        }
12815        struct Visitor;
12816        impl<'de> serde::de::Visitor<'de> for Visitor {
12817            type Value = TransitionAttributes;
12818            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12819                formatter.write_str("struct TransitionAttributes")
12820            }
12821            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12822            where
12823                A: serde::de::MapAccess<'de>,
12824            {
12825                #[allow(unused_imports)]
12826                use serde::de::Error;
12827                use std::option::Option::Some;
12828                let mut fields = std::collections::HashSet::new();
12829                let mut result = Self::Value::new();
12830                while let Some(tag) = map.next_key::<__FieldTag>()? {
12831                    #[allow(clippy::match_single_binding)]
12832                    match tag {
12833                        __FieldTag::__src_tag => {
12834                            if !fields.insert(__FieldTag::__src_tag) {
12835                                return std::result::Result::Err(A::Error::duplicate_field(
12836                                    "multiple values for src_tag",
12837                                ));
12838                            }
12839                            result.src_tag = map
12840                                .next_value::<std::option::Option<std::string::String>>()?
12841                                .unwrap_or_default();
12842                        }
12843                        __FieldTag::__excluded_src_tag => {
12844                            if !fields.insert(__FieldTag::__excluded_src_tag) {
12845                                return std::result::Result::Err(A::Error::duplicate_field(
12846                                    "multiple values for excluded_src_tag",
12847                                ));
12848                            }
12849                            result.excluded_src_tag = map
12850                                .next_value::<std::option::Option<std::string::String>>()?
12851                                .unwrap_or_default();
12852                        }
12853                        __FieldTag::__dst_tag => {
12854                            if !fields.insert(__FieldTag::__dst_tag) {
12855                                return std::result::Result::Err(A::Error::duplicate_field(
12856                                    "multiple values for dst_tag",
12857                                ));
12858                            }
12859                            result.dst_tag = map
12860                                .next_value::<std::option::Option<std::string::String>>()?
12861                                .unwrap_or_default();
12862                        }
12863                        __FieldTag::__excluded_dst_tag => {
12864                            if !fields.insert(__FieldTag::__excluded_dst_tag) {
12865                                return std::result::Result::Err(A::Error::duplicate_field(
12866                                    "multiple values for excluded_dst_tag",
12867                                ));
12868                            }
12869                            result.excluded_dst_tag = map
12870                                .next_value::<std::option::Option<std::string::String>>()?
12871                                .unwrap_or_default();
12872                        }
12873                        __FieldTag::__cost => {
12874                            if !fields.insert(__FieldTag::__cost) {
12875                                return std::result::Result::Err(A::Error::duplicate_field(
12876                                    "multiple values for cost",
12877                                ));
12878                            }
12879                            struct __With(std::option::Option<f64>);
12880                            impl<'de> serde::de::Deserialize<'de> for __With {
12881                                fn deserialize<D>(
12882                                    deserializer: D,
12883                                ) -> std::result::Result<Self, D::Error>
12884                                where
12885                                    D: serde::de::Deserializer<'de>,
12886                                {
12887                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
12888                                }
12889                            }
12890                            result.cost = map.next_value::<__With>()?.0.unwrap_or_default();
12891                        }
12892                        __FieldTag::__cost_per_kilometer => {
12893                            if !fields.insert(__FieldTag::__cost_per_kilometer) {
12894                                return std::result::Result::Err(A::Error::duplicate_field(
12895                                    "multiple values for cost_per_kilometer",
12896                                ));
12897                            }
12898                            struct __With(std::option::Option<f64>);
12899                            impl<'de> serde::de::Deserialize<'de> for __With {
12900                                fn deserialize<D>(
12901                                    deserializer: D,
12902                                ) -> std::result::Result<Self, D::Error>
12903                                where
12904                                    D: serde::de::Deserializer<'de>,
12905                                {
12906                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
12907                                }
12908                            }
12909                            result.cost_per_kilometer =
12910                                map.next_value::<__With>()?.0.unwrap_or_default();
12911                        }
12912                        __FieldTag::__distance_limit => {
12913                            if !fields.insert(__FieldTag::__distance_limit) {
12914                                return std::result::Result::Err(A::Error::duplicate_field(
12915                                    "multiple values for distance_limit",
12916                                ));
12917                            }
12918                            result.distance_limit = map
12919                                .next_value::<std::option::Option<crate::model::DistanceLimit>>()?;
12920                        }
12921                        __FieldTag::__delay => {
12922                            if !fields.insert(__FieldTag::__delay) {
12923                                return std::result::Result::Err(A::Error::duplicate_field(
12924                                    "multiple values for delay",
12925                                ));
12926                            }
12927                            result.delay =
12928                                map.next_value::<std::option::Option<wkt::Duration>>()?;
12929                        }
12930                        __FieldTag::Unknown(key) => {
12931                            let value = map.next_value::<serde_json::Value>()?;
12932                            result._unknown_fields.insert(key, value);
12933                        }
12934                    }
12935                }
12936                std::result::Result::Ok(result)
12937            }
12938        }
12939        deserializer.deserialize_any(Visitor)
12940    }
12941}
12942
12943#[doc(hidden)]
12944impl serde::ser::Serialize for TransitionAttributes {
12945    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12946    where
12947        S: serde::ser::Serializer,
12948    {
12949        use serde::ser::SerializeMap;
12950        #[allow(unused_imports)]
12951        use std::option::Option::Some;
12952        let mut state = serializer.serialize_map(std::option::Option::None)?;
12953        if !self.src_tag.is_empty() {
12954            state.serialize_entry("srcTag", &self.src_tag)?;
12955        }
12956        if !self.excluded_src_tag.is_empty() {
12957            state.serialize_entry("excludedSrcTag", &self.excluded_src_tag)?;
12958        }
12959        if !self.dst_tag.is_empty() {
12960            state.serialize_entry("dstTag", &self.dst_tag)?;
12961        }
12962        if !self.excluded_dst_tag.is_empty() {
12963            state.serialize_entry("excludedDstTag", &self.excluded_dst_tag)?;
12964        }
12965        if !wkt::internal::is_default(&self.cost) {
12966            struct __With<'a>(&'a f64);
12967            impl<'a> serde::ser::Serialize for __With<'a> {
12968                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12969                where
12970                    S: serde::ser::Serializer,
12971                {
12972                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
12973                }
12974            }
12975            state.serialize_entry("cost", &__With(&self.cost))?;
12976        }
12977        if !wkt::internal::is_default(&self.cost_per_kilometer) {
12978            struct __With<'a>(&'a f64);
12979            impl<'a> serde::ser::Serialize for __With<'a> {
12980                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12981                where
12982                    S: serde::ser::Serializer,
12983                {
12984                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
12985                }
12986            }
12987            state.serialize_entry("costPerKilometer", &__With(&self.cost_per_kilometer))?;
12988        }
12989        if self.distance_limit.is_some() {
12990            state.serialize_entry("distanceLimit", &self.distance_limit)?;
12991        }
12992        if self.delay.is_some() {
12993            state.serialize_entry("delay", &self.delay)?;
12994        }
12995        if !self._unknown_fields.is_empty() {
12996            for (key, value) in self._unknown_fields.iter() {
12997                state.serialize_entry(key, &value)?;
12998            }
12999        }
13000        state.end()
13001    }
13002}
13003
13004impl std::fmt::Debug for TransitionAttributes {
13005    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13006        let mut debug_struct = f.debug_struct("TransitionAttributes");
13007        debug_struct.field("src_tag", &self.src_tag);
13008        debug_struct.field("excluded_src_tag", &self.excluded_src_tag);
13009        debug_struct.field("dst_tag", &self.dst_tag);
13010        debug_struct.field("excluded_dst_tag", &self.excluded_dst_tag);
13011        debug_struct.field("cost", &self.cost);
13012        debug_struct.field("cost_per_kilometer", &self.cost_per_kilometer);
13013        debug_struct.field("distance_limit", &self.distance_limit);
13014        debug_struct.field("delay", &self.delay);
13015        if !self._unknown_fields.is_empty() {
13016            debug_struct.field("_unknown_fields", &self._unknown_fields);
13017        }
13018        debug_struct.finish()
13019    }
13020}
13021
13022/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
13023/// VisitRequests, and start and end locations of Vehicles.
13024#[derive(Clone, Default, PartialEq)]
13025#[non_exhaustive]
13026pub struct Waypoint {
13027    /// Indicates that the location of this waypoint is meant to have a preference
13028    /// for the vehicle to stop at a particular side of road. When you set this
13029    /// value, the route will pass through the location so that the vehicle can
13030    /// stop at the side of road that the location is biased towards from the
13031    /// center of the road. This option works only for the 'DRIVING' travel mode,
13032    /// and when the 'location_type' is set to 'location'.
13033    pub side_of_road: bool,
13034
13035    /// Different ways to represent a location.
13036    pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
13037
13038    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13039}
13040
13041impl Waypoint {
13042    pub fn new() -> Self {
13043        std::default::Default::default()
13044    }
13045
13046    /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
13047    pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
13048        self.side_of_road = v.into();
13049        self
13050    }
13051
13052    /// Sets the value of [location_type][crate::model::Waypoint::location_type].
13053    ///
13054    /// Note that all the setters affecting `location_type` are mutually
13055    /// exclusive.
13056    pub fn set_location_type<
13057        T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
13058    >(
13059        mut self,
13060        v: T,
13061    ) -> Self {
13062        self.location_type = v.into();
13063        self
13064    }
13065
13066    /// The value of [location_type][crate::model::Waypoint::location_type]
13067    /// if it holds a `Location`, `None` if the field is not set or
13068    /// holds a different branch.
13069    pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
13070        #[allow(unreachable_patterns)]
13071        self.location_type.as_ref().and_then(|v| match v {
13072            crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
13073            _ => std::option::Option::None,
13074        })
13075    }
13076
13077    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
13078    /// to hold a `Location`.
13079    ///
13080    /// Note that all the setters affecting `location_type` are
13081    /// mutually exclusive.
13082    pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
13083        mut self,
13084        v: T,
13085    ) -> Self {
13086        self.location_type =
13087            std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
13088        self
13089    }
13090
13091    /// The value of [location_type][crate::model::Waypoint::location_type]
13092    /// if it holds a `PlaceId`, `None` if the field is not set or
13093    /// holds a different branch.
13094    pub fn place_id(&self) -> std::option::Option<&std::string::String> {
13095        #[allow(unreachable_patterns)]
13096        self.location_type.as_ref().and_then(|v| match v {
13097            crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
13098            _ => std::option::Option::None,
13099        })
13100    }
13101
13102    /// Sets the value of [location_type][crate::model::Waypoint::location_type]
13103    /// to hold a `PlaceId`.
13104    ///
13105    /// Note that all the setters affecting `location_type` are
13106    /// mutually exclusive.
13107    pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13108        self.location_type =
13109            std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
13110        self
13111    }
13112}
13113
13114impl wkt::message::Message for Waypoint {
13115    fn typename() -> &'static str {
13116        "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
13117    }
13118}
13119
13120#[doc(hidden)]
13121impl<'de> serde::de::Deserialize<'de> for Waypoint {
13122    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13123    where
13124        D: serde::Deserializer<'de>,
13125    {
13126        #[allow(non_camel_case_types)]
13127        #[doc(hidden)]
13128        #[derive(PartialEq, Eq, Hash)]
13129        enum __FieldTag {
13130            __location,
13131            __place_id,
13132            __side_of_road,
13133            Unknown(std::string::String),
13134        }
13135        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13136            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13137            where
13138                D: serde::Deserializer<'de>,
13139            {
13140                struct Visitor;
13141                impl<'de> serde::de::Visitor<'de> for Visitor {
13142                    type Value = __FieldTag;
13143                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13144                        formatter.write_str("a field name for Waypoint")
13145                    }
13146                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13147                    where
13148                        E: serde::de::Error,
13149                    {
13150                        use std::result::Result::Ok;
13151                        use std::string::ToString;
13152                        match value {
13153                            "location" => Ok(__FieldTag::__location),
13154                            "placeId" => Ok(__FieldTag::__place_id),
13155                            "place_id" => Ok(__FieldTag::__place_id),
13156                            "sideOfRoad" => Ok(__FieldTag::__side_of_road),
13157                            "side_of_road" => Ok(__FieldTag::__side_of_road),
13158                            _ => Ok(__FieldTag::Unknown(value.to_string())),
13159                        }
13160                    }
13161                }
13162                deserializer.deserialize_identifier(Visitor)
13163            }
13164        }
13165        struct Visitor;
13166        impl<'de> serde::de::Visitor<'de> for Visitor {
13167            type Value = Waypoint;
13168            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13169                formatter.write_str("struct Waypoint")
13170            }
13171            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13172            where
13173                A: serde::de::MapAccess<'de>,
13174            {
13175                #[allow(unused_imports)]
13176                use serde::de::Error;
13177                use std::option::Option::Some;
13178                let mut fields = std::collections::HashSet::new();
13179                let mut result = Self::Value::new();
13180                while let Some(tag) = map.next_key::<__FieldTag>()? {
13181                    #[allow(clippy::match_single_binding)]
13182                    match tag {
13183                        __FieldTag::__location => {
13184                            if !fields.insert(__FieldTag::__location) {
13185                                return std::result::Result::Err(A::Error::duplicate_field(
13186                                    "multiple values for location",
13187                                ));
13188                            }
13189                            if result.location_type.is_some() {
13190                                return std::result::Result::Err(A::Error::duplicate_field(
13191                                    "multiple values for `location_type`, a oneof with full ID .google.cloud.optimization.v1.Waypoint.location, latest field was location",
13192                                ));
13193                            }
13194                            result.location_type = std::option::Option::Some(
13195                                crate::model::waypoint::LocationType::Location(
13196                                    map.next_value::<std::option::Option<
13197                                        std::boxed::Box<crate::model::Location>,
13198                                    >>()?
13199                                    .unwrap_or_default(),
13200                                ),
13201                            );
13202                        }
13203                        __FieldTag::__place_id => {
13204                            if !fields.insert(__FieldTag::__place_id) {
13205                                return std::result::Result::Err(A::Error::duplicate_field(
13206                                    "multiple values for place_id",
13207                                ));
13208                            }
13209                            if result.location_type.is_some() {
13210                                return std::result::Result::Err(A::Error::duplicate_field(
13211                                    "multiple values for `location_type`, a oneof with full ID .google.cloud.optimization.v1.Waypoint.place_id, latest field was placeId",
13212                                ));
13213                            }
13214                            result.location_type = std::option::Option::Some(
13215                                crate::model::waypoint::LocationType::PlaceId(
13216                                    map.next_value::<std::option::Option<std::string::String>>()?
13217                                        .unwrap_or_default(),
13218                                ),
13219                            );
13220                        }
13221                        __FieldTag::__side_of_road => {
13222                            if !fields.insert(__FieldTag::__side_of_road) {
13223                                return std::result::Result::Err(A::Error::duplicate_field(
13224                                    "multiple values for side_of_road",
13225                                ));
13226                            }
13227                            result.side_of_road = map
13228                                .next_value::<std::option::Option<bool>>()?
13229                                .unwrap_or_default();
13230                        }
13231                        __FieldTag::Unknown(key) => {
13232                            let value = map.next_value::<serde_json::Value>()?;
13233                            result._unknown_fields.insert(key, value);
13234                        }
13235                    }
13236                }
13237                std::result::Result::Ok(result)
13238            }
13239        }
13240        deserializer.deserialize_any(Visitor)
13241    }
13242}
13243
13244#[doc(hidden)]
13245impl serde::ser::Serialize for Waypoint {
13246    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13247    where
13248        S: serde::ser::Serializer,
13249    {
13250        use serde::ser::SerializeMap;
13251        #[allow(unused_imports)]
13252        use std::option::Option::Some;
13253        let mut state = serializer.serialize_map(std::option::Option::None)?;
13254        if let Some(value) = self.location() {
13255            state.serialize_entry("location", value)?;
13256        }
13257        if let Some(value) = self.place_id() {
13258            state.serialize_entry("placeId", value)?;
13259        }
13260        if !wkt::internal::is_default(&self.side_of_road) {
13261            state.serialize_entry("sideOfRoad", &self.side_of_road)?;
13262        }
13263        if !self._unknown_fields.is_empty() {
13264            for (key, value) in self._unknown_fields.iter() {
13265                state.serialize_entry(key, &value)?;
13266            }
13267        }
13268        state.end()
13269    }
13270}
13271
13272impl std::fmt::Debug for Waypoint {
13273    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13274        let mut debug_struct = f.debug_struct("Waypoint");
13275        debug_struct.field("side_of_road", &self.side_of_road);
13276        debug_struct.field("location_type", &self.location_type);
13277        if !self._unknown_fields.is_empty() {
13278            debug_struct.field("_unknown_fields", &self._unknown_fields);
13279        }
13280        debug_struct.finish()
13281    }
13282}
13283
13284/// Defines additional types related to [Waypoint].
13285pub mod waypoint {
13286    #[allow(unused_imports)]
13287    use super::*;
13288
13289    /// Different ways to represent a location.
13290    #[derive(Clone, Debug, PartialEq)]
13291    #[non_exhaustive]
13292    pub enum LocationType {
13293        /// A point specified using geographic coordinates, including an optional
13294        /// heading.
13295        Location(std::boxed::Box<crate::model::Location>),
13296        /// The POI Place ID associated with the waypoint.
13297        PlaceId(std::string::String),
13298    }
13299}
13300
13301/// Encapsulates a location (a geographic point, and an optional heading).
13302#[derive(Clone, Default, PartialEq)]
13303#[non_exhaustive]
13304pub struct Location {
13305    /// The waypoint's geographic coordinates.
13306    pub lat_lng: std::option::Option<gtype::model::LatLng>,
13307
13308    /// The compass heading associated with the direction of the flow of traffic.
13309    /// This value is used to specify the side of the road to use for pickup and
13310    /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
13311    /// of due North, 90 specifies a heading of due East, etc.
13312    pub heading: std::option::Option<i32>,
13313
13314    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13315}
13316
13317impl Location {
13318    pub fn new() -> Self {
13319        std::default::Default::default()
13320    }
13321
13322    /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
13323    pub fn set_lat_lng<T>(mut self, v: T) -> Self
13324    where
13325        T: std::convert::Into<gtype::model::LatLng>,
13326    {
13327        self.lat_lng = std::option::Option::Some(v.into());
13328        self
13329    }
13330
13331    /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
13332    pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
13333    where
13334        T: std::convert::Into<gtype::model::LatLng>,
13335    {
13336        self.lat_lng = v.map(|x| x.into());
13337        self
13338    }
13339
13340    /// Sets the value of [heading][crate::model::Location::heading].
13341    pub fn set_heading<T>(mut self, v: T) -> Self
13342    where
13343        T: std::convert::Into<i32>,
13344    {
13345        self.heading = std::option::Option::Some(v.into());
13346        self
13347    }
13348
13349    /// Sets or clears the value of [heading][crate::model::Location::heading].
13350    pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
13351    where
13352        T: std::convert::Into<i32>,
13353    {
13354        self.heading = v.map(|x| x.into());
13355        self
13356    }
13357}
13358
13359impl wkt::message::Message for Location {
13360    fn typename() -> &'static str {
13361        "type.googleapis.com/google.cloud.optimization.v1.Location"
13362    }
13363}
13364
13365#[doc(hidden)]
13366impl<'de> serde::de::Deserialize<'de> for Location {
13367    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13368    where
13369        D: serde::Deserializer<'de>,
13370    {
13371        #[allow(non_camel_case_types)]
13372        #[doc(hidden)]
13373        #[derive(PartialEq, Eq, Hash)]
13374        enum __FieldTag {
13375            __lat_lng,
13376            __heading,
13377            Unknown(std::string::String),
13378        }
13379        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13380            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13381            where
13382                D: serde::Deserializer<'de>,
13383            {
13384                struct Visitor;
13385                impl<'de> serde::de::Visitor<'de> for Visitor {
13386                    type Value = __FieldTag;
13387                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13388                        formatter.write_str("a field name for Location")
13389                    }
13390                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13391                    where
13392                        E: serde::de::Error,
13393                    {
13394                        use std::result::Result::Ok;
13395                        use std::string::ToString;
13396                        match value {
13397                            "latLng" => Ok(__FieldTag::__lat_lng),
13398                            "lat_lng" => Ok(__FieldTag::__lat_lng),
13399                            "heading" => Ok(__FieldTag::__heading),
13400                            _ => Ok(__FieldTag::Unknown(value.to_string())),
13401                        }
13402                    }
13403                }
13404                deserializer.deserialize_identifier(Visitor)
13405            }
13406        }
13407        struct Visitor;
13408        impl<'de> serde::de::Visitor<'de> for Visitor {
13409            type Value = Location;
13410            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13411                formatter.write_str("struct Location")
13412            }
13413            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13414            where
13415                A: serde::de::MapAccess<'de>,
13416            {
13417                #[allow(unused_imports)]
13418                use serde::de::Error;
13419                use std::option::Option::Some;
13420                let mut fields = std::collections::HashSet::new();
13421                let mut result = Self::Value::new();
13422                while let Some(tag) = map.next_key::<__FieldTag>()? {
13423                    #[allow(clippy::match_single_binding)]
13424                    match tag {
13425                        __FieldTag::__lat_lng => {
13426                            if !fields.insert(__FieldTag::__lat_lng) {
13427                                return std::result::Result::Err(A::Error::duplicate_field(
13428                                    "multiple values for lat_lng",
13429                                ));
13430                            }
13431                            result.lat_lng =
13432                                map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
13433                        }
13434                        __FieldTag::__heading => {
13435                            if !fields.insert(__FieldTag::__heading) {
13436                                return std::result::Result::Err(A::Error::duplicate_field(
13437                                    "multiple values for heading",
13438                                ));
13439                            }
13440                            struct __With(std::option::Option<i32>);
13441                            impl<'de> serde::de::Deserialize<'de> for __With {
13442                                fn deserialize<D>(
13443                                    deserializer: D,
13444                                ) -> std::result::Result<Self, D::Error>
13445                                where
13446                                    D: serde::de::Deserializer<'de>,
13447                                {
13448                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
13449                                }
13450                            }
13451                            result.heading = map.next_value::<__With>()?.0;
13452                        }
13453                        __FieldTag::Unknown(key) => {
13454                            let value = map.next_value::<serde_json::Value>()?;
13455                            result._unknown_fields.insert(key, value);
13456                        }
13457                    }
13458                }
13459                std::result::Result::Ok(result)
13460            }
13461        }
13462        deserializer.deserialize_any(Visitor)
13463    }
13464}
13465
13466#[doc(hidden)]
13467impl serde::ser::Serialize for Location {
13468    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13469    where
13470        S: serde::ser::Serializer,
13471    {
13472        use serde::ser::SerializeMap;
13473        #[allow(unused_imports)]
13474        use std::option::Option::Some;
13475        let mut state = serializer.serialize_map(std::option::Option::None)?;
13476        if self.lat_lng.is_some() {
13477            state.serialize_entry("latLng", &self.lat_lng)?;
13478        }
13479        if self.heading.is_some() {
13480            struct __With<'a>(&'a std::option::Option<i32>);
13481            impl<'a> serde::ser::Serialize for __With<'a> {
13482                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13483                where
13484                    S: serde::ser::Serializer,
13485                {
13486                    serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
13487                        self.0, serializer,
13488                    )
13489                }
13490            }
13491            state.serialize_entry("heading", &__With(&self.heading))?;
13492        }
13493        if !self._unknown_fields.is_empty() {
13494            for (key, value) in self._unknown_fields.iter() {
13495                state.serialize_entry(key, &value)?;
13496            }
13497        }
13498        state.end()
13499    }
13500}
13501
13502impl std::fmt::Debug for Location {
13503    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13504        let mut debug_struct = f.debug_struct("Location");
13505        debug_struct.field("lat_lng", &self.lat_lng);
13506        debug_struct.field("heading", &self.heading);
13507        if !self._unknown_fields.is_empty() {
13508            debug_struct.field("_unknown_fields", &self._unknown_fields);
13509        }
13510        debug_struct.finish()
13511    }
13512}
13513
13514/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
13515/// is a contiguous period of time during which the vehicle remains idle at its
13516/// current position and cannot perform any visit. A break may occur:
13517///
13518/// * during the travel between two visits (which includes the time right
13519///   before or right after a visit, but not in the middle of a visit), in
13520///   which case it extends the corresponding transit time between the visits,
13521/// * or before the vehicle start (the vehicle may not start in the middle of
13522///   a break), in which case it does not affect the vehicle start time.
13523/// * or after the vehicle end (ditto, with the vehicle end time).
13524#[derive(Clone, Default, PartialEq)]
13525#[non_exhaustive]
13526pub struct BreakRule {
13527    /// Sequence of breaks. See the `BreakRequest` message.
13528    pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
13529
13530    /// Several `FrequencyConstraint` may apply. They must all be satisfied by
13531    /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
13532    pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
13533
13534    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13535}
13536
13537impl BreakRule {
13538    pub fn new() -> Self {
13539        std::default::Default::default()
13540    }
13541
13542    /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
13543    pub fn set_break_requests<T, V>(mut self, v: T) -> Self
13544    where
13545        T: std::iter::IntoIterator<Item = V>,
13546        V: std::convert::Into<crate::model::break_rule::BreakRequest>,
13547    {
13548        use std::iter::Iterator;
13549        self.break_requests = v.into_iter().map(|i| i.into()).collect();
13550        self
13551    }
13552
13553    /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
13554    pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
13555    where
13556        T: std::iter::IntoIterator<Item = V>,
13557        V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
13558    {
13559        use std::iter::Iterator;
13560        self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
13561        self
13562    }
13563}
13564
13565impl wkt::message::Message for BreakRule {
13566    fn typename() -> &'static str {
13567        "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
13568    }
13569}
13570
13571#[doc(hidden)]
13572impl<'de> serde::de::Deserialize<'de> for BreakRule {
13573    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13574    where
13575        D: serde::Deserializer<'de>,
13576    {
13577        #[allow(non_camel_case_types)]
13578        #[doc(hidden)]
13579        #[derive(PartialEq, Eq, Hash)]
13580        enum __FieldTag {
13581            __break_requests,
13582            __frequency_constraints,
13583            Unknown(std::string::String),
13584        }
13585        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13586            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13587            where
13588                D: serde::Deserializer<'de>,
13589            {
13590                struct Visitor;
13591                impl<'de> serde::de::Visitor<'de> for Visitor {
13592                    type Value = __FieldTag;
13593                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13594                        formatter.write_str("a field name for BreakRule")
13595                    }
13596                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13597                    where
13598                        E: serde::de::Error,
13599                    {
13600                        use std::result::Result::Ok;
13601                        use std::string::ToString;
13602                        match value {
13603                            "breakRequests" => Ok(__FieldTag::__break_requests),
13604                            "break_requests" => Ok(__FieldTag::__break_requests),
13605                            "frequencyConstraints" => Ok(__FieldTag::__frequency_constraints),
13606                            "frequency_constraints" => Ok(__FieldTag::__frequency_constraints),
13607                            _ => Ok(__FieldTag::Unknown(value.to_string())),
13608                        }
13609                    }
13610                }
13611                deserializer.deserialize_identifier(Visitor)
13612            }
13613        }
13614        struct Visitor;
13615        impl<'de> serde::de::Visitor<'de> for Visitor {
13616            type Value = BreakRule;
13617            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13618                formatter.write_str("struct BreakRule")
13619            }
13620            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13621            where
13622                A: serde::de::MapAccess<'de>,
13623            {
13624                #[allow(unused_imports)]
13625                use serde::de::Error;
13626                use std::option::Option::Some;
13627                let mut fields = std::collections::HashSet::new();
13628                let mut result = Self::Value::new();
13629                while let Some(tag) = map.next_key::<__FieldTag>()? {
13630                    #[allow(clippy::match_single_binding)]
13631                    match tag {
13632                        __FieldTag::__break_requests => {
13633                            if !fields.insert(__FieldTag::__break_requests) {
13634                                return std::result::Result::Err(A::Error::duplicate_field(
13635                                    "multiple values for break_requests",
13636                                ));
13637                            }
13638                            result.break_requests = map
13639                                .next_value::<std::option::Option<
13640                                    std::vec::Vec<crate::model::break_rule::BreakRequest>,
13641                                >>()?
13642                                .unwrap_or_default();
13643                        }
13644                        __FieldTag::__frequency_constraints => {
13645                            if !fields.insert(__FieldTag::__frequency_constraints) {
13646                                return std::result::Result::Err(A::Error::duplicate_field(
13647                                    "multiple values for frequency_constraints",
13648                                ));
13649                            }
13650                            result.frequency_constraints = map
13651                                .next_value::<std::option::Option<
13652                                    std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
13653                                >>()?
13654                                .unwrap_or_default();
13655                        }
13656                        __FieldTag::Unknown(key) => {
13657                            let value = map.next_value::<serde_json::Value>()?;
13658                            result._unknown_fields.insert(key, value);
13659                        }
13660                    }
13661                }
13662                std::result::Result::Ok(result)
13663            }
13664        }
13665        deserializer.deserialize_any(Visitor)
13666    }
13667}
13668
13669#[doc(hidden)]
13670impl serde::ser::Serialize for BreakRule {
13671    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13672    where
13673        S: serde::ser::Serializer,
13674    {
13675        use serde::ser::SerializeMap;
13676        #[allow(unused_imports)]
13677        use std::option::Option::Some;
13678        let mut state = serializer.serialize_map(std::option::Option::None)?;
13679        if !self.break_requests.is_empty() {
13680            state.serialize_entry("breakRequests", &self.break_requests)?;
13681        }
13682        if !self.frequency_constraints.is_empty() {
13683            state.serialize_entry("frequencyConstraints", &self.frequency_constraints)?;
13684        }
13685        if !self._unknown_fields.is_empty() {
13686            for (key, value) in self._unknown_fields.iter() {
13687                state.serialize_entry(key, &value)?;
13688            }
13689        }
13690        state.end()
13691    }
13692}
13693
13694impl std::fmt::Debug for BreakRule {
13695    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13696        let mut debug_struct = f.debug_struct("BreakRule");
13697        debug_struct.field("break_requests", &self.break_requests);
13698        debug_struct.field("frequency_constraints", &self.frequency_constraints);
13699        if !self._unknown_fields.is_empty() {
13700            debug_struct.field("_unknown_fields", &self._unknown_fields);
13701        }
13702        debug_struct.finish()
13703    }
13704}
13705
13706/// Defines additional types related to [BreakRule].
13707pub mod break_rule {
13708    #[allow(unused_imports)]
13709    use super::*;
13710
13711    /// The sequence of breaks (i.e. their number and order) that apply to each
13712    /// vehicle must be known beforehand. The repeated `BreakRequest`s define
13713    /// that sequence, in the order in which they must occur. Their time windows
13714    /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
13715    /// be compatible with the order (this is checked).
13716    #[derive(Clone, Default, PartialEq)]
13717    #[non_exhaustive]
13718    pub struct BreakRequest {
13719        /// Required. Lower bound (inclusive) on the start of the break.
13720        pub earliest_start_time: std::option::Option<wkt::Timestamp>,
13721
13722        /// Required. Upper bound (inclusive) on the start of the break.
13723        pub latest_start_time: std::option::Option<wkt::Timestamp>,
13724
13725        /// Required. Minimum duration of the break. Must be positive.
13726        pub min_duration: std::option::Option<wkt::Duration>,
13727
13728        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13729    }
13730
13731    impl BreakRequest {
13732        pub fn new() -> Self {
13733            std::default::Default::default()
13734        }
13735
13736        /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
13737        pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
13738        where
13739            T: std::convert::Into<wkt::Timestamp>,
13740        {
13741            self.earliest_start_time = std::option::Option::Some(v.into());
13742            self
13743        }
13744
13745        /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
13746        pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
13747        where
13748            T: std::convert::Into<wkt::Timestamp>,
13749        {
13750            self.earliest_start_time = v.map(|x| x.into());
13751            self
13752        }
13753
13754        /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
13755        pub fn set_latest_start_time<T>(mut self, v: T) -> Self
13756        where
13757            T: std::convert::Into<wkt::Timestamp>,
13758        {
13759            self.latest_start_time = std::option::Option::Some(v.into());
13760            self
13761        }
13762
13763        /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
13764        pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
13765        where
13766            T: std::convert::Into<wkt::Timestamp>,
13767        {
13768            self.latest_start_time = v.map(|x| x.into());
13769            self
13770        }
13771
13772        /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
13773        pub fn set_min_duration<T>(mut self, v: T) -> Self
13774        where
13775            T: std::convert::Into<wkt::Duration>,
13776        {
13777            self.min_duration = std::option::Option::Some(v.into());
13778            self
13779        }
13780
13781        /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
13782        pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
13783        where
13784            T: std::convert::Into<wkt::Duration>,
13785        {
13786            self.min_duration = v.map(|x| x.into());
13787            self
13788        }
13789    }
13790
13791    impl wkt::message::Message for BreakRequest {
13792        fn typename() -> &'static str {
13793            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
13794        }
13795    }
13796
13797    #[doc(hidden)]
13798    impl<'de> serde::de::Deserialize<'de> for BreakRequest {
13799        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13800        where
13801            D: serde::Deserializer<'de>,
13802        {
13803            #[allow(non_camel_case_types)]
13804            #[doc(hidden)]
13805            #[derive(PartialEq, Eq, Hash)]
13806            enum __FieldTag {
13807                __earliest_start_time,
13808                __latest_start_time,
13809                __min_duration,
13810                Unknown(std::string::String),
13811            }
13812            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13813                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13814                where
13815                    D: serde::Deserializer<'de>,
13816                {
13817                    struct Visitor;
13818                    impl<'de> serde::de::Visitor<'de> for Visitor {
13819                        type Value = __FieldTag;
13820                        fn expecting(
13821                            &self,
13822                            formatter: &mut std::fmt::Formatter,
13823                        ) -> std::fmt::Result {
13824                            formatter.write_str("a field name for BreakRequest")
13825                        }
13826                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13827                        where
13828                            E: serde::de::Error,
13829                        {
13830                            use std::result::Result::Ok;
13831                            use std::string::ToString;
13832                            match value {
13833                                "earliestStartTime" => Ok(__FieldTag::__earliest_start_time),
13834                                "earliest_start_time" => Ok(__FieldTag::__earliest_start_time),
13835                                "latestStartTime" => Ok(__FieldTag::__latest_start_time),
13836                                "latest_start_time" => Ok(__FieldTag::__latest_start_time),
13837                                "minDuration" => Ok(__FieldTag::__min_duration),
13838                                "min_duration" => Ok(__FieldTag::__min_duration),
13839                                _ => Ok(__FieldTag::Unknown(value.to_string())),
13840                            }
13841                        }
13842                    }
13843                    deserializer.deserialize_identifier(Visitor)
13844                }
13845            }
13846            struct Visitor;
13847            impl<'de> serde::de::Visitor<'de> for Visitor {
13848                type Value = BreakRequest;
13849                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13850                    formatter.write_str("struct BreakRequest")
13851                }
13852                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13853                where
13854                    A: serde::de::MapAccess<'de>,
13855                {
13856                    #[allow(unused_imports)]
13857                    use serde::de::Error;
13858                    use std::option::Option::Some;
13859                    let mut fields = std::collections::HashSet::new();
13860                    let mut result = Self::Value::new();
13861                    while let Some(tag) = map.next_key::<__FieldTag>()? {
13862                        #[allow(clippy::match_single_binding)]
13863                        match tag {
13864                            __FieldTag::__earliest_start_time => {
13865                                if !fields.insert(__FieldTag::__earliest_start_time) {
13866                                    return std::result::Result::Err(A::Error::duplicate_field(
13867                                        "multiple values for earliest_start_time",
13868                                    ));
13869                                }
13870                                result.earliest_start_time =
13871                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
13872                            }
13873                            __FieldTag::__latest_start_time => {
13874                                if !fields.insert(__FieldTag::__latest_start_time) {
13875                                    return std::result::Result::Err(A::Error::duplicate_field(
13876                                        "multiple values for latest_start_time",
13877                                    ));
13878                                }
13879                                result.latest_start_time =
13880                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
13881                            }
13882                            __FieldTag::__min_duration => {
13883                                if !fields.insert(__FieldTag::__min_duration) {
13884                                    return std::result::Result::Err(A::Error::duplicate_field(
13885                                        "multiple values for min_duration",
13886                                    ));
13887                                }
13888                                result.min_duration =
13889                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
13890                            }
13891                            __FieldTag::Unknown(key) => {
13892                                let value = map.next_value::<serde_json::Value>()?;
13893                                result._unknown_fields.insert(key, value);
13894                            }
13895                        }
13896                    }
13897                    std::result::Result::Ok(result)
13898                }
13899            }
13900            deserializer.deserialize_any(Visitor)
13901        }
13902    }
13903
13904    #[doc(hidden)]
13905    impl serde::ser::Serialize for BreakRequest {
13906        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13907        where
13908            S: serde::ser::Serializer,
13909        {
13910            use serde::ser::SerializeMap;
13911            #[allow(unused_imports)]
13912            use std::option::Option::Some;
13913            let mut state = serializer.serialize_map(std::option::Option::None)?;
13914            if self.earliest_start_time.is_some() {
13915                state.serialize_entry("earliestStartTime", &self.earliest_start_time)?;
13916            }
13917            if self.latest_start_time.is_some() {
13918                state.serialize_entry("latestStartTime", &self.latest_start_time)?;
13919            }
13920            if self.min_duration.is_some() {
13921                state.serialize_entry("minDuration", &self.min_duration)?;
13922            }
13923            if !self._unknown_fields.is_empty() {
13924                for (key, value) in self._unknown_fields.iter() {
13925                    state.serialize_entry(key, &value)?;
13926                }
13927            }
13928            state.end()
13929        }
13930    }
13931
13932    impl std::fmt::Debug for BreakRequest {
13933        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13934            let mut debug_struct = f.debug_struct("BreakRequest");
13935            debug_struct.field("earliest_start_time", &self.earliest_start_time);
13936            debug_struct.field("latest_start_time", &self.latest_start_time);
13937            debug_struct.field("min_duration", &self.min_duration);
13938            if !self._unknown_fields.is_empty() {
13939                debug_struct.field("_unknown_fields", &self._unknown_fields);
13940            }
13941            debug_struct.finish()
13942        }
13943    }
13944
13945    /// One may further constrain the frequency and duration of the breaks
13946    /// specified above, by enforcing a minimum break frequency, such as
13947    /// "There must be a break of at least 1 hour every 12 hours". Assuming that
13948    /// this can be interpreted as "Within any sliding time window of 12h, there
13949    /// must be at least one break of at least one hour", that example would
13950    /// translate to the following `FrequencyConstraint`:
13951    ///
13952    /// ```norust
13953    /// {
13954    ///    min_break_duration { seconds: 3600 }         # 1 hour.
13955    ///    max_inter_break_duration { seconds: 39600 }  # 11 hours (12 - 1 = 11).
13956    /// }
13957    /// ```
13958    ///
13959    /// The timing and duration of the breaks in the solution will respect all
13960    /// such constraints, in addition to the time windows and minimum durations
13961    /// already specified in the `BreakRequest`.
13962    ///
13963    /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
13964    /// For example, the following schedule honors the "1h every 12h" example:
13965    ///
13966    /// ```norust
13967    ///   04:00 vehicle start
13968    ///    .. performing travel and visits ..
13969    ///   09:00 1 hour break
13970    ///   10:00 end of the break
13971    ///    .. performing travel and visits ..
13972    ///   12:00 20-min lunch break
13973    ///   12:20 end of the break
13974    ///    .. performing travel and visits ..
13975    ///   21:00 1 hour break
13976    ///   22:00 end of the break
13977    ///    .. performing travel and visits ..
13978    ///   23:59 vehicle end
13979    /// ```
13980    #[derive(Clone, Default, PartialEq)]
13981    #[non_exhaustive]
13982    pub struct FrequencyConstraint {
13983        /// Required. Minimum break duration for this constraint. Nonnegative.
13984        /// See description of `FrequencyConstraint`.
13985        pub min_break_duration: std::option::Option<wkt::Duration>,
13986
13987        /// Required. Maximum allowed span of any interval of time in the route that
13988        /// does not include at least partially a break of `duration >=
13989        /// min_break_duration`. Must be positive.
13990        pub max_inter_break_duration: std::option::Option<wkt::Duration>,
13991
13992        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13993    }
13994
13995    impl FrequencyConstraint {
13996        pub fn new() -> Self {
13997            std::default::Default::default()
13998        }
13999
14000        /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
14001        pub fn set_min_break_duration<T>(mut self, v: T) -> Self
14002        where
14003            T: std::convert::Into<wkt::Duration>,
14004        {
14005            self.min_break_duration = std::option::Option::Some(v.into());
14006            self
14007        }
14008
14009        /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
14010        pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
14011        where
14012            T: std::convert::Into<wkt::Duration>,
14013        {
14014            self.min_break_duration = v.map(|x| x.into());
14015            self
14016        }
14017
14018        /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
14019        pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
14020        where
14021            T: std::convert::Into<wkt::Duration>,
14022        {
14023            self.max_inter_break_duration = std::option::Option::Some(v.into());
14024            self
14025        }
14026
14027        /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
14028        pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
14029        where
14030            T: std::convert::Into<wkt::Duration>,
14031        {
14032            self.max_inter_break_duration = v.map(|x| x.into());
14033            self
14034        }
14035    }
14036
14037    impl wkt::message::Message for FrequencyConstraint {
14038        fn typename() -> &'static str {
14039            "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
14040        }
14041    }
14042
14043    #[doc(hidden)]
14044    impl<'de> serde::de::Deserialize<'de> for FrequencyConstraint {
14045        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14046        where
14047            D: serde::Deserializer<'de>,
14048        {
14049            #[allow(non_camel_case_types)]
14050            #[doc(hidden)]
14051            #[derive(PartialEq, Eq, Hash)]
14052            enum __FieldTag {
14053                __min_break_duration,
14054                __max_inter_break_duration,
14055                Unknown(std::string::String),
14056            }
14057            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14058                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14059                where
14060                    D: serde::Deserializer<'de>,
14061                {
14062                    struct Visitor;
14063                    impl<'de> serde::de::Visitor<'de> for Visitor {
14064                        type Value = __FieldTag;
14065                        fn expecting(
14066                            &self,
14067                            formatter: &mut std::fmt::Formatter,
14068                        ) -> std::fmt::Result {
14069                            formatter.write_str("a field name for FrequencyConstraint")
14070                        }
14071                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14072                        where
14073                            E: serde::de::Error,
14074                        {
14075                            use std::result::Result::Ok;
14076                            use std::string::ToString;
14077                            match value {
14078                                "minBreakDuration" => Ok(__FieldTag::__min_break_duration),
14079                                "min_break_duration" => Ok(__FieldTag::__min_break_duration),
14080                                "maxInterBreakDuration" => {
14081                                    Ok(__FieldTag::__max_inter_break_duration)
14082                                }
14083                                "max_inter_break_duration" => {
14084                                    Ok(__FieldTag::__max_inter_break_duration)
14085                                }
14086                                _ => Ok(__FieldTag::Unknown(value.to_string())),
14087                            }
14088                        }
14089                    }
14090                    deserializer.deserialize_identifier(Visitor)
14091                }
14092            }
14093            struct Visitor;
14094            impl<'de> serde::de::Visitor<'de> for Visitor {
14095                type Value = FrequencyConstraint;
14096                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14097                    formatter.write_str("struct FrequencyConstraint")
14098                }
14099                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14100                where
14101                    A: serde::de::MapAccess<'de>,
14102                {
14103                    #[allow(unused_imports)]
14104                    use serde::de::Error;
14105                    use std::option::Option::Some;
14106                    let mut fields = std::collections::HashSet::new();
14107                    let mut result = Self::Value::new();
14108                    while let Some(tag) = map.next_key::<__FieldTag>()? {
14109                        #[allow(clippy::match_single_binding)]
14110                        match tag {
14111                            __FieldTag::__min_break_duration => {
14112                                if !fields.insert(__FieldTag::__min_break_duration) {
14113                                    return std::result::Result::Err(A::Error::duplicate_field(
14114                                        "multiple values for min_break_duration",
14115                                    ));
14116                                }
14117                                result.min_break_duration =
14118                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
14119                            }
14120                            __FieldTag::__max_inter_break_duration => {
14121                                if !fields.insert(__FieldTag::__max_inter_break_duration) {
14122                                    return std::result::Result::Err(A::Error::duplicate_field(
14123                                        "multiple values for max_inter_break_duration",
14124                                    ));
14125                                }
14126                                result.max_inter_break_duration =
14127                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
14128                            }
14129                            __FieldTag::Unknown(key) => {
14130                                let value = map.next_value::<serde_json::Value>()?;
14131                                result._unknown_fields.insert(key, value);
14132                            }
14133                        }
14134                    }
14135                    std::result::Result::Ok(result)
14136                }
14137            }
14138            deserializer.deserialize_any(Visitor)
14139        }
14140    }
14141
14142    #[doc(hidden)]
14143    impl serde::ser::Serialize for FrequencyConstraint {
14144        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14145        where
14146            S: serde::ser::Serializer,
14147        {
14148            use serde::ser::SerializeMap;
14149            #[allow(unused_imports)]
14150            use std::option::Option::Some;
14151            let mut state = serializer.serialize_map(std::option::Option::None)?;
14152            if self.min_break_duration.is_some() {
14153                state.serialize_entry("minBreakDuration", &self.min_break_duration)?;
14154            }
14155            if self.max_inter_break_duration.is_some() {
14156                state.serialize_entry("maxInterBreakDuration", &self.max_inter_break_duration)?;
14157            }
14158            if !self._unknown_fields.is_empty() {
14159                for (key, value) in self._unknown_fields.iter() {
14160                    state.serialize_entry(key, &value)?;
14161                }
14162            }
14163            state.end()
14164        }
14165    }
14166
14167    impl std::fmt::Debug for FrequencyConstraint {
14168        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14169            let mut debug_struct = f.debug_struct("FrequencyConstraint");
14170            debug_struct.field("min_break_duration", &self.min_break_duration);
14171            debug_struct.field("max_inter_break_duration", &self.max_inter_break_duration);
14172            if !self._unknown_fields.is_empty() {
14173                debug_struct.field("_unknown_fields", &self._unknown_fields);
14174            }
14175            debug_struct.finish()
14176        }
14177    }
14178}
14179
14180/// A vehicle's route can be decomposed, along the time axis, like this (we
14181/// assume there are n visits):
14182///
14183/// ```norust
14184///   |            |            |          |       |  T[2], |        |      |
14185///   | Transition |  Visit #0  |          |       |  V[2], |        |      |
14186///   |     #0     |    aka     |   T[1]   |  V[1] |  ...   | V[n-1] | T[n] |
14187///   |  aka T[0]  |    V[0]    |          |       | V[n-2],|        |      |
14188///   |            |            |          |       | T[n-1] |        |      |
14189///   ^            ^            ^          ^       ^        ^        ^      ^
14190/// vehicle    V[0].start   V[0].end     V[1].   V[1].    V[n].    V[n]. vehicle
14191///  start     (arrival)   (departure)   start   end      start    end     end
14192/// ```
14193///
14194/// Note that we make a difference between:
14195///
14196/// * "punctual events", such as the vehicle start and end and each visit's start
14197///   and end (aka arrival and departure). They happen at a given second.
14198/// * "time intervals", such as the visits themselves, and the transition between
14199///   visits. Though time intervals can sometimes have zero duration, i.e. start
14200///   and end at the same second, they often have a positive duration.
14201///
14202/// Invariants:
14203///
14204/// * If there are n visits, there are n+1 transitions.
14205/// * A visit is always surrounded by a transition before it (same index) and a
14206///   transition after it (index + 1).
14207/// * The vehicle start is always followed by transition #0.
14208/// * The vehicle end is always preceded by transition #n.
14209///
14210/// Zooming in, here is what happens during a `Transition` and a `Visit`:
14211///
14212/// ```norust
14213/// ---+-------------------------------------+-----------------------------+-->
14214///    |           TRANSITION[i]             |           VISIT[i]          |
14215///    |                                     |                             |
14216///    |  * TRAVEL: the vehicle moves from   |      PERFORM the visit:     |
14217///    |    VISIT[i-1].departure_location to |                             |
14218///    |    VISIT[i].arrival_location, which |  * Spend some time:         |
14219///    |    takes a given travel duration    |    the "visit duration".    |
14220///    |    and distance                     |                             |
14221///    |                                     |  * Load or unload           |
14222///    |  * BREAKS: the driver may have      |    some quantities from the |
14223///    |    breaks (e.g. lunch break).       |    vehicle: the "demand".   |
14224///    |                                     |                             |
14225///    |  * WAIT: the driver/vehicle does    |                             |
14226///    |    nothing. This can happen for     |                             |
14227///    |    many reasons, for example when   |                             |
14228///    |    the vehicle reaches the next     |                             |
14229///    |    event's destination before the   |                             |
14230///    |    start of its time window         |                             |
14231///    |                                     |                             |
14232///    |  * DELAY: *right before* the next   |                             |
14233///    |    arrival. E.g. the vehicle and/or |                             |
14234///    |    driver spends time unloading.    |                             |
14235///    |                                     |                             |
14236/// ---+-------------------------------------+-----------------------------+-->
14237///    ^                                     ^                             ^
14238/// V[i-1].end                           V[i].start                    V[i].end
14239/// ```
14240///
14241/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
14242/// during a transition.
14243///
14244/// * They don't overlap.
14245/// * The DELAY is unique and *must* be a contiguous period of time right
14246///   before the next visit (or vehicle end). Thus, it suffice to know the
14247///   delay duration to know its start and end time.
14248/// * The BREAKS are contiguous, non-overlapping periods of time. The
14249///   response specifies the start time and duration of each break.
14250/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
14251///   during this transition. Clients can assume that travel happens "as soon as
14252///   possible" and that "wait" fills the remaining time.
14253///
14254/// A (complex) example:
14255///
14256/// ```norust
14257///                                TRANSITION[i]
14258/// --++-----+-----------------------------------------------------------++-->
14259///   ||     |       |           |       |           |         |         ||
14260///   ||  T  |   B   |     T     |       |     B     |         |    D    ||
14261///   ||  r  |   r   |     r     |   W   |     r     |    W    |    e    ||
14262///   ||  a  |   e   |     a     |   a   |     e     |    a    |    l    ||
14263///   ||  v  |   a   |     v     |   i   |     a     |    i    |    a    ||
14264///   ||  e  |   k   |     e     |   t   |     k     |    t    |    y    ||
14265///   ||  l  |       |     l     |       |           |         |         ||
14266///   ||     |       |           |       |           |         |         ||
14267/// --++-----------------------------------------------------------------++-->
14268/// ```
14269#[derive(Clone, Default, PartialEq)]
14270#[non_exhaustive]
14271pub struct ShipmentRoute {
14272    /// Vehicle performing the route, identified by its index in the source
14273    /// `ShipmentModel`.
14274    pub vehicle_index: i32,
14275
14276    /// Label of the vehicle performing this route, equal to
14277    /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
14278    pub vehicle_label: std::string::String,
14279
14280    /// Time at which the vehicle starts its route.
14281    pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
14282
14283    /// Time at which the vehicle finishes its route.
14284    pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
14285
14286    /// Ordered sequence of visits representing a route.
14287    /// visits[i] is the i-th visit in the route.
14288    /// If this field is empty, the vehicle is considered as unused.
14289    pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
14290
14291    /// Ordered list of transitions for the route.
14292    pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
14293
14294    /// When
14295    /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
14296    /// is set to true, this field indicates that inconsistencies in route timings
14297    /// are predicted using traffic-based travel duration estimates. There may be
14298    /// insufficient time to complete traffic-adjusted travel, delays, and breaks
14299    /// between visits, before the first visit, or after the last visit, while
14300    /// still satisfying the visit and vehicle time windows. For example,
14301    ///
14302    /// ```norust
14303    ///   start_time(previous_visit) + duration(previous_visit) +
14304    ///   travel_duration(previous_visit, next_visit) > start_time(next_visit)
14305    /// ```
14306    ///
14307    /// Arrival at next_visit will likely happen later than its current
14308    /// time window due the increased estimate of travel time
14309    /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
14310    /// may be forced to overlap with a visit due to an increase in travel time
14311    /// estimates and visit or break time window restrictions.
14312    ///
14313    /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
14314    pub has_traffic_infeasibilities: bool,
14315
14316    /// The encoded polyline representation of the route.
14317    /// This field is only populated if
14318    /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
14319    /// is set to true.
14320    ///
14321    /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
14322    pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
14323
14324    /// Breaks scheduled for the vehicle performing this route.
14325    /// The `breaks` sequence represents time intervals, each starting at the
14326    /// corresponding `start_time` and lasting `duration` seconds.
14327    pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
14328
14329    /// Duration, distance and load metrics for this route. The fields of
14330    /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
14331    /// summed over all
14332    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
14333    /// or
14334    /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
14335    /// depending on the context.
14336    ///
14337    /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
14338    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
14339    /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
14340    pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
14341
14342    /// Cost of the route, broken down by cost-related request fields.
14343    /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
14344    /// "model.shipments.pickups.cost", and the values are the total cost
14345    /// generated by the corresponding cost field, aggregated over the whole route.
14346    /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
14347    /// pickup costs over the route. All costs defined in the model are reported in
14348    /// detail here with the exception of costs related to TransitionAttributes
14349    /// that are only reported in an aggregated way as of 2022/01.
14350    pub route_costs: std::collections::HashMap<std::string::String, f64>,
14351
14352    /// Total cost of the route. The sum of all costs in the cost map.
14353    pub route_total_cost: f64,
14354
14355    /// Deprecated: Use
14356    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
14357    /// instead. Vehicle loads upon arrival at its end location, for each type
14358    /// specified in
14359    /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
14360    /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
14361    /// loads for quantity types unconstrained by intervals and that don't have any
14362    /// non-zero demand on the route.
14363    ///
14364    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
14365    /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
14366    #[deprecated]
14367    pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
14368
14369    /// Deprecated: Use
14370    /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
14371    /// instead. Ordered list of travel steps for the route.
14372    ///
14373    /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
14374    #[deprecated]
14375    pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
14376
14377    /// Deprecated: No longer used.
14378    /// This field will only be populated at the
14379    /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
14380    /// level.
14381    ///
14382    /// This field is the extra detour time due to the shipments visited on the
14383    /// route.
14384    ///
14385    /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
14386    /// from the vehicle's start_location to its `end_location`.
14387    ///
14388    /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
14389    #[deprecated]
14390    pub vehicle_detour: std::option::Option<wkt::Duration>,
14391
14392    /// Deprecated: Delay occurring before the vehicle end. See
14393    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
14394    ///
14395    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
14396    #[deprecated]
14397    pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
14398
14399    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14400}
14401
14402impl ShipmentRoute {
14403    pub fn new() -> Self {
14404        std::default::Default::default()
14405    }
14406
14407    /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
14408    pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
14409        self.vehicle_index = v.into();
14410        self
14411    }
14412
14413    /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
14414    pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14415        self.vehicle_label = v.into();
14416        self
14417    }
14418
14419    /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
14420    pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
14421    where
14422        T: std::convert::Into<wkt::Timestamp>,
14423    {
14424        self.vehicle_start_time = std::option::Option::Some(v.into());
14425        self
14426    }
14427
14428    /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
14429    pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
14430    where
14431        T: std::convert::Into<wkt::Timestamp>,
14432    {
14433        self.vehicle_start_time = v.map(|x| x.into());
14434        self
14435    }
14436
14437    /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
14438    pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
14439    where
14440        T: std::convert::Into<wkt::Timestamp>,
14441    {
14442        self.vehicle_end_time = std::option::Option::Some(v.into());
14443        self
14444    }
14445
14446    /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
14447    pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
14448    where
14449        T: std::convert::Into<wkt::Timestamp>,
14450    {
14451        self.vehicle_end_time = v.map(|x| x.into());
14452        self
14453    }
14454
14455    /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
14456    pub fn set_visits<T, V>(mut self, v: T) -> Self
14457    where
14458        T: std::iter::IntoIterator<Item = V>,
14459        V: std::convert::Into<crate::model::shipment_route::Visit>,
14460    {
14461        use std::iter::Iterator;
14462        self.visits = v.into_iter().map(|i| i.into()).collect();
14463        self
14464    }
14465
14466    /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
14467    pub fn set_transitions<T, V>(mut self, v: T) -> Self
14468    where
14469        T: std::iter::IntoIterator<Item = V>,
14470        V: std::convert::Into<crate::model::shipment_route::Transition>,
14471    {
14472        use std::iter::Iterator;
14473        self.transitions = v.into_iter().map(|i| i.into()).collect();
14474        self
14475    }
14476
14477    /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
14478    pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
14479        self.has_traffic_infeasibilities = v.into();
14480        self
14481    }
14482
14483    /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
14484    pub fn set_route_polyline<T>(mut self, v: T) -> Self
14485    where
14486        T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
14487    {
14488        self.route_polyline = std::option::Option::Some(v.into());
14489        self
14490    }
14491
14492    /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
14493    pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
14494    where
14495        T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
14496    {
14497        self.route_polyline = v.map(|x| x.into());
14498        self
14499    }
14500
14501    /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
14502    pub fn set_breaks<T, V>(mut self, v: T) -> Self
14503    where
14504        T: std::iter::IntoIterator<Item = V>,
14505        V: std::convert::Into<crate::model::shipment_route::Break>,
14506    {
14507        use std::iter::Iterator;
14508        self.breaks = v.into_iter().map(|i| i.into()).collect();
14509        self
14510    }
14511
14512    /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
14513    pub fn set_metrics<T>(mut self, v: T) -> Self
14514    where
14515        T: std::convert::Into<crate::model::AggregatedMetrics>,
14516    {
14517        self.metrics = std::option::Option::Some(v.into());
14518        self
14519    }
14520
14521    /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
14522    pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
14523    where
14524        T: std::convert::Into<crate::model::AggregatedMetrics>,
14525    {
14526        self.metrics = v.map(|x| x.into());
14527        self
14528    }
14529
14530    /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
14531    pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
14532    where
14533        T: std::iter::IntoIterator<Item = (K, V)>,
14534        K: std::convert::Into<std::string::String>,
14535        V: std::convert::Into<f64>,
14536    {
14537        use std::iter::Iterator;
14538        self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
14539        self
14540    }
14541
14542    /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
14543    pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
14544        self.route_total_cost = v.into();
14545        self
14546    }
14547
14548    /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
14549    #[deprecated]
14550    pub fn set_end_loads<T, V>(mut self, v: T) -> Self
14551    where
14552        T: std::iter::IntoIterator<Item = V>,
14553        V: std::convert::Into<crate::model::CapacityQuantity>,
14554    {
14555        use std::iter::Iterator;
14556        self.end_loads = v.into_iter().map(|i| i.into()).collect();
14557        self
14558    }
14559
14560    /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
14561    #[deprecated]
14562    pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
14563    where
14564        T: std::iter::IntoIterator<Item = V>,
14565        V: std::convert::Into<crate::model::shipment_route::TravelStep>,
14566    {
14567        use std::iter::Iterator;
14568        self.travel_steps = v.into_iter().map(|i| i.into()).collect();
14569        self
14570    }
14571
14572    /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
14573    #[deprecated]
14574    pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
14575    where
14576        T: std::convert::Into<wkt::Duration>,
14577    {
14578        self.vehicle_detour = std::option::Option::Some(v.into());
14579        self
14580    }
14581
14582    /// Sets or clears the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
14583    #[deprecated]
14584    pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
14585    where
14586        T: std::convert::Into<wkt::Duration>,
14587    {
14588        self.vehicle_detour = v.map(|x| x.into());
14589        self
14590    }
14591
14592    /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
14593    #[deprecated]
14594    pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
14595    where
14596        T: std::convert::Into<crate::model::shipment_route::Delay>,
14597    {
14598        self.delay_before_vehicle_end = std::option::Option::Some(v.into());
14599        self
14600    }
14601
14602    /// Sets or clears the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
14603    #[deprecated]
14604    pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
14605    where
14606        T: std::convert::Into<crate::model::shipment_route::Delay>,
14607    {
14608        self.delay_before_vehicle_end = v.map(|x| x.into());
14609        self
14610    }
14611}
14612
14613impl wkt::message::Message for ShipmentRoute {
14614    fn typename() -> &'static str {
14615        "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
14616    }
14617}
14618
14619#[doc(hidden)]
14620impl<'de> serde::de::Deserialize<'de> for ShipmentRoute {
14621    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14622    where
14623        D: serde::Deserializer<'de>,
14624    {
14625        #[allow(non_camel_case_types)]
14626        #[doc(hidden)]
14627        #[derive(PartialEq, Eq, Hash)]
14628        enum __FieldTag {
14629            __vehicle_index,
14630            __vehicle_label,
14631            __vehicle_start_time,
14632            __vehicle_end_time,
14633            __visits,
14634            __transitions,
14635            __has_traffic_infeasibilities,
14636            __route_polyline,
14637            __breaks,
14638            __metrics,
14639            __route_costs,
14640            __route_total_cost,
14641            __end_loads,
14642            __travel_steps,
14643            __vehicle_detour,
14644            __delay_before_vehicle_end,
14645            Unknown(std::string::String),
14646        }
14647        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14648            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14649            where
14650                D: serde::Deserializer<'de>,
14651            {
14652                struct Visitor;
14653                impl<'de> serde::de::Visitor<'de> for Visitor {
14654                    type Value = __FieldTag;
14655                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14656                        formatter.write_str("a field name for ShipmentRoute")
14657                    }
14658                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14659                    where
14660                        E: serde::de::Error,
14661                    {
14662                        use std::result::Result::Ok;
14663                        use std::string::ToString;
14664                        match value {
14665                            "vehicleIndex" => Ok(__FieldTag::__vehicle_index),
14666                            "vehicle_index" => Ok(__FieldTag::__vehicle_index),
14667                            "vehicleLabel" => Ok(__FieldTag::__vehicle_label),
14668                            "vehicle_label" => Ok(__FieldTag::__vehicle_label),
14669                            "vehicleStartTime" => Ok(__FieldTag::__vehicle_start_time),
14670                            "vehicle_start_time" => Ok(__FieldTag::__vehicle_start_time),
14671                            "vehicleEndTime" => Ok(__FieldTag::__vehicle_end_time),
14672                            "vehicle_end_time" => Ok(__FieldTag::__vehicle_end_time),
14673                            "visits" => Ok(__FieldTag::__visits),
14674                            "transitions" => Ok(__FieldTag::__transitions),
14675                            "hasTrafficInfeasibilities" => {
14676                                Ok(__FieldTag::__has_traffic_infeasibilities)
14677                            }
14678                            "has_traffic_infeasibilities" => {
14679                                Ok(__FieldTag::__has_traffic_infeasibilities)
14680                            }
14681                            "routePolyline" => Ok(__FieldTag::__route_polyline),
14682                            "route_polyline" => Ok(__FieldTag::__route_polyline),
14683                            "breaks" => Ok(__FieldTag::__breaks),
14684                            "metrics" => Ok(__FieldTag::__metrics),
14685                            "routeCosts" => Ok(__FieldTag::__route_costs),
14686                            "route_costs" => Ok(__FieldTag::__route_costs),
14687                            "routeTotalCost" => Ok(__FieldTag::__route_total_cost),
14688                            "route_total_cost" => Ok(__FieldTag::__route_total_cost),
14689                            "endLoads" => Ok(__FieldTag::__end_loads),
14690                            "end_loads" => Ok(__FieldTag::__end_loads),
14691                            "travelSteps" => Ok(__FieldTag::__travel_steps),
14692                            "travel_steps" => Ok(__FieldTag::__travel_steps),
14693                            "vehicleDetour" => Ok(__FieldTag::__vehicle_detour),
14694                            "vehicle_detour" => Ok(__FieldTag::__vehicle_detour),
14695                            "delayBeforeVehicleEnd" => Ok(__FieldTag::__delay_before_vehicle_end),
14696                            "delay_before_vehicle_end" => {
14697                                Ok(__FieldTag::__delay_before_vehicle_end)
14698                            }
14699                            _ => Ok(__FieldTag::Unknown(value.to_string())),
14700                        }
14701                    }
14702                }
14703                deserializer.deserialize_identifier(Visitor)
14704            }
14705        }
14706        struct Visitor;
14707        impl<'de> serde::de::Visitor<'de> for Visitor {
14708            type Value = ShipmentRoute;
14709            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14710                formatter.write_str("struct ShipmentRoute")
14711            }
14712            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14713            where
14714                A: serde::de::MapAccess<'de>,
14715            {
14716                #[allow(unused_imports)]
14717                use serde::de::Error;
14718                use std::option::Option::Some;
14719                let mut fields = std::collections::HashSet::new();
14720                let mut result = Self::Value::new();
14721                while let Some(tag) = map.next_key::<__FieldTag>()? {
14722                    #[allow(clippy::match_single_binding)]
14723                    match tag {
14724                        __FieldTag::__vehicle_index => {
14725                            if !fields.insert(__FieldTag::__vehicle_index) {
14726                                return std::result::Result::Err(A::Error::duplicate_field(
14727                                    "multiple values for vehicle_index",
14728                                ));
14729                            }
14730                            struct __With(std::option::Option<i32>);
14731                            impl<'de> serde::de::Deserialize<'de> for __With {
14732                                fn deserialize<D>(
14733                                    deserializer: D,
14734                                ) -> std::result::Result<Self, D::Error>
14735                                where
14736                                    D: serde::de::Deserializer<'de>,
14737                                {
14738                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
14739                                }
14740                            }
14741                            result.vehicle_index =
14742                                map.next_value::<__With>()?.0.unwrap_or_default();
14743                        }
14744                        __FieldTag::__vehicle_label => {
14745                            if !fields.insert(__FieldTag::__vehicle_label) {
14746                                return std::result::Result::Err(A::Error::duplicate_field(
14747                                    "multiple values for vehicle_label",
14748                                ));
14749                            }
14750                            result.vehicle_label = map
14751                                .next_value::<std::option::Option<std::string::String>>()?
14752                                .unwrap_or_default();
14753                        }
14754                        __FieldTag::__vehicle_start_time => {
14755                            if !fields.insert(__FieldTag::__vehicle_start_time) {
14756                                return std::result::Result::Err(A::Error::duplicate_field(
14757                                    "multiple values for vehicle_start_time",
14758                                ));
14759                            }
14760                            result.vehicle_start_time =
14761                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14762                        }
14763                        __FieldTag::__vehicle_end_time => {
14764                            if !fields.insert(__FieldTag::__vehicle_end_time) {
14765                                return std::result::Result::Err(A::Error::duplicate_field(
14766                                    "multiple values for vehicle_end_time",
14767                                ));
14768                            }
14769                            result.vehicle_end_time =
14770                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14771                        }
14772                        __FieldTag::__visits => {
14773                            if !fields.insert(__FieldTag::__visits) {
14774                                return std::result::Result::Err(A::Error::duplicate_field(
14775                                    "multiple values for visits",
14776                                ));
14777                            }
14778                            result.visits = map
14779                                .next_value::<std::option::Option<
14780                                    std::vec::Vec<crate::model::shipment_route::Visit>,
14781                                >>()?
14782                                .unwrap_or_default();
14783                        }
14784                        __FieldTag::__transitions => {
14785                            if !fields.insert(__FieldTag::__transitions) {
14786                                return std::result::Result::Err(A::Error::duplicate_field(
14787                                    "multiple values for transitions",
14788                                ));
14789                            }
14790                            result.transitions = map
14791                                .next_value::<std::option::Option<
14792                                    std::vec::Vec<crate::model::shipment_route::Transition>,
14793                                >>()?
14794                                .unwrap_or_default();
14795                        }
14796                        __FieldTag::__has_traffic_infeasibilities => {
14797                            if !fields.insert(__FieldTag::__has_traffic_infeasibilities) {
14798                                return std::result::Result::Err(A::Error::duplicate_field(
14799                                    "multiple values for has_traffic_infeasibilities",
14800                                ));
14801                            }
14802                            result.has_traffic_infeasibilities = map
14803                                .next_value::<std::option::Option<bool>>()?
14804                                .unwrap_or_default();
14805                        }
14806                        __FieldTag::__route_polyline => {
14807                            if !fields.insert(__FieldTag::__route_polyline) {
14808                                return std::result::Result::Err(A::Error::duplicate_field(
14809                                    "multiple values for route_polyline",
14810                                ));
14811                            }
14812                            result.route_polyline = map.next_value::<std::option::Option<
14813                                crate::model::shipment_route::EncodedPolyline,
14814                            >>()?;
14815                        }
14816                        __FieldTag::__breaks => {
14817                            if !fields.insert(__FieldTag::__breaks) {
14818                                return std::result::Result::Err(A::Error::duplicate_field(
14819                                    "multiple values for breaks",
14820                                ));
14821                            }
14822                            result.breaks = map
14823                                .next_value::<std::option::Option<
14824                                    std::vec::Vec<crate::model::shipment_route::Break>,
14825                                >>()?
14826                                .unwrap_or_default();
14827                        }
14828                        __FieldTag::__metrics => {
14829                            if !fields.insert(__FieldTag::__metrics) {
14830                                return std::result::Result::Err(A::Error::duplicate_field(
14831                                    "multiple values for metrics",
14832                                ));
14833                            }
14834                            result.metrics = map
14835                                .next_value::<std::option::Option<crate::model::AggregatedMetrics>>(
14836                                )?;
14837                        }
14838                        __FieldTag::__route_costs => {
14839                            if !fields.insert(__FieldTag::__route_costs) {
14840                                return std::result::Result::Err(A::Error::duplicate_field(
14841                                    "multiple values for route_costs",
14842                                ));
14843                            }
14844                            struct __With(
14845                                std::option::Option<
14846                                    std::collections::HashMap<std::string::String, f64>,
14847                                >,
14848                            );
14849                            impl<'de> serde::de::Deserialize<'de> for __With {
14850                                fn deserialize<D>(
14851                                    deserializer: D,
14852                                ) -> std::result::Result<Self, D::Error>
14853                                where
14854                                    D: serde::de::Deserializer<'de>,
14855                                {
14856                                    serde_with::As::<
14857                                        std::option::Option<
14858                                            std::collections::HashMap<
14859                                                serde_with::Same,
14860                                                wkt::internal::F64,
14861                                            >,
14862                                        >,
14863                                    >::deserialize(deserializer)
14864                                    .map(__With)
14865                                }
14866                            }
14867                            result.route_costs = map.next_value::<__With>()?.0.unwrap_or_default();
14868                        }
14869                        __FieldTag::__route_total_cost => {
14870                            if !fields.insert(__FieldTag::__route_total_cost) {
14871                                return std::result::Result::Err(A::Error::duplicate_field(
14872                                    "multiple values for route_total_cost",
14873                                ));
14874                            }
14875                            struct __With(std::option::Option<f64>);
14876                            impl<'de> serde::de::Deserialize<'de> for __With {
14877                                fn deserialize<D>(
14878                                    deserializer: D,
14879                                ) -> std::result::Result<Self, D::Error>
14880                                where
14881                                    D: serde::de::Deserializer<'de>,
14882                                {
14883                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
14884                                }
14885                            }
14886                            result.route_total_cost =
14887                                map.next_value::<__With>()?.0.unwrap_or_default();
14888                        }
14889                        __FieldTag::__end_loads => {
14890                            if !fields.insert(__FieldTag::__end_loads) {
14891                                return std::result::Result::Err(A::Error::duplicate_field(
14892                                    "multiple values for end_loads",
14893                                ));
14894                            }
14895                            result.end_loads =
14896                                map.next_value::<std::option::Option<
14897                                    std::vec::Vec<crate::model::CapacityQuantity>,
14898                                >>()?
14899                                .unwrap_or_default();
14900                        }
14901                        __FieldTag::__travel_steps => {
14902                            if !fields.insert(__FieldTag::__travel_steps) {
14903                                return std::result::Result::Err(A::Error::duplicate_field(
14904                                    "multiple values for travel_steps",
14905                                ));
14906                            }
14907                            result.travel_steps = map
14908                                .next_value::<std::option::Option<
14909                                    std::vec::Vec<crate::model::shipment_route::TravelStep>,
14910                                >>()?
14911                                .unwrap_or_default();
14912                        }
14913                        __FieldTag::__vehicle_detour => {
14914                            if !fields.insert(__FieldTag::__vehicle_detour) {
14915                                return std::result::Result::Err(A::Error::duplicate_field(
14916                                    "multiple values for vehicle_detour",
14917                                ));
14918                            }
14919                            result.vehicle_detour =
14920                                map.next_value::<std::option::Option<wkt::Duration>>()?;
14921                        }
14922                        __FieldTag::__delay_before_vehicle_end => {
14923                            if !fields.insert(__FieldTag::__delay_before_vehicle_end) {
14924                                return std::result::Result::Err(A::Error::duplicate_field(
14925                                    "multiple values for delay_before_vehicle_end",
14926                                ));
14927                            }
14928                            result.delay_before_vehicle_end = map.next_value::<std::option::Option<crate::model::shipment_route::Delay>>()?
14929                                ;
14930                        }
14931                        __FieldTag::Unknown(key) => {
14932                            let value = map.next_value::<serde_json::Value>()?;
14933                            result._unknown_fields.insert(key, value);
14934                        }
14935                    }
14936                }
14937                std::result::Result::Ok(result)
14938            }
14939        }
14940        deserializer.deserialize_any(Visitor)
14941    }
14942}
14943
14944#[doc(hidden)]
14945impl serde::ser::Serialize for ShipmentRoute {
14946    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14947    where
14948        S: serde::ser::Serializer,
14949    {
14950        use serde::ser::SerializeMap;
14951        #[allow(unused_imports)]
14952        use std::option::Option::Some;
14953        let mut state = serializer.serialize_map(std::option::Option::None)?;
14954        if !wkt::internal::is_default(&self.vehicle_index) {
14955            struct __With<'a>(&'a i32);
14956            impl<'a> serde::ser::Serialize for __With<'a> {
14957                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14958                where
14959                    S: serde::ser::Serializer,
14960                {
14961                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
14962                }
14963            }
14964            state.serialize_entry("vehicleIndex", &__With(&self.vehicle_index))?;
14965        }
14966        if !self.vehicle_label.is_empty() {
14967            state.serialize_entry("vehicleLabel", &self.vehicle_label)?;
14968        }
14969        if self.vehicle_start_time.is_some() {
14970            state.serialize_entry("vehicleStartTime", &self.vehicle_start_time)?;
14971        }
14972        if self.vehicle_end_time.is_some() {
14973            state.serialize_entry("vehicleEndTime", &self.vehicle_end_time)?;
14974        }
14975        if !self.visits.is_empty() {
14976            state.serialize_entry("visits", &self.visits)?;
14977        }
14978        if !self.transitions.is_empty() {
14979            state.serialize_entry("transitions", &self.transitions)?;
14980        }
14981        if !wkt::internal::is_default(&self.has_traffic_infeasibilities) {
14982            state.serialize_entry(
14983                "hasTrafficInfeasibilities",
14984                &self.has_traffic_infeasibilities,
14985            )?;
14986        }
14987        if self.route_polyline.is_some() {
14988            state.serialize_entry("routePolyline", &self.route_polyline)?;
14989        }
14990        if !self.breaks.is_empty() {
14991            state.serialize_entry("breaks", &self.breaks)?;
14992        }
14993        if self.metrics.is_some() {
14994            state.serialize_entry("metrics", &self.metrics)?;
14995        }
14996        if !self.route_costs.is_empty() {
14997            struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
14998            impl<'a> serde::ser::Serialize for __With<'a> {
14999                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15000                where
15001                    S: serde::ser::Serializer,
15002                {
15003                    serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::F64> >::serialize(self.0, serializer)
15004                }
15005            }
15006            state.serialize_entry("routeCosts", &__With(&self.route_costs))?;
15007        }
15008        if !wkt::internal::is_default(&self.route_total_cost) {
15009            struct __With<'a>(&'a f64);
15010            impl<'a> serde::ser::Serialize for __With<'a> {
15011                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15012                where
15013                    S: serde::ser::Serializer,
15014                {
15015                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
15016                }
15017            }
15018            state.serialize_entry("routeTotalCost", &__With(&self.route_total_cost))?;
15019        }
15020        if !self.end_loads.is_empty() {
15021            state.serialize_entry("endLoads", &self.end_loads)?;
15022        }
15023        if !self.travel_steps.is_empty() {
15024            state.serialize_entry("travelSteps", &self.travel_steps)?;
15025        }
15026        if self.vehicle_detour.is_some() {
15027            state.serialize_entry("vehicleDetour", &self.vehicle_detour)?;
15028        }
15029        if self.delay_before_vehicle_end.is_some() {
15030            state.serialize_entry("delayBeforeVehicleEnd", &self.delay_before_vehicle_end)?;
15031        }
15032        if !self._unknown_fields.is_empty() {
15033            for (key, value) in self._unknown_fields.iter() {
15034                state.serialize_entry(key, &value)?;
15035            }
15036        }
15037        state.end()
15038    }
15039}
15040
15041impl std::fmt::Debug for ShipmentRoute {
15042    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15043        let mut debug_struct = f.debug_struct("ShipmentRoute");
15044        debug_struct.field("vehicle_index", &self.vehicle_index);
15045        debug_struct.field("vehicle_label", &self.vehicle_label);
15046        debug_struct.field("vehicle_start_time", &self.vehicle_start_time);
15047        debug_struct.field("vehicle_end_time", &self.vehicle_end_time);
15048        debug_struct.field("visits", &self.visits);
15049        debug_struct.field("transitions", &self.transitions);
15050        debug_struct.field(
15051            "has_traffic_infeasibilities",
15052            &self.has_traffic_infeasibilities,
15053        );
15054        debug_struct.field("route_polyline", &self.route_polyline);
15055        debug_struct.field("breaks", &self.breaks);
15056        debug_struct.field("metrics", &self.metrics);
15057        debug_struct.field("route_costs", &self.route_costs);
15058        debug_struct.field("route_total_cost", &self.route_total_cost);
15059        debug_struct.field("end_loads", &self.end_loads);
15060        debug_struct.field("travel_steps", &self.travel_steps);
15061        debug_struct.field("vehicle_detour", &self.vehicle_detour);
15062        debug_struct.field("delay_before_vehicle_end", &self.delay_before_vehicle_end);
15063        if !self._unknown_fields.is_empty() {
15064            debug_struct.field("_unknown_fields", &self._unknown_fields);
15065        }
15066        debug_struct.finish()
15067    }
15068}
15069
15070/// Defines additional types related to [ShipmentRoute].
15071pub mod shipment_route {
15072    #[allow(unused_imports)]
15073    use super::*;
15074
15075    /// Deprecated: Use
15076    /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
15077    /// instead. Time interval spent on the route resulting from a
15078    /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
15079    ///
15080    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
15081    /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
15082    #[derive(Clone, Default, PartialEq)]
15083    #[non_exhaustive]
15084    #[deprecated]
15085    pub struct Delay {
15086        /// Start of the delay.
15087        pub start_time: std::option::Option<wkt::Timestamp>,
15088
15089        /// Duration of the delay.
15090        pub duration: std::option::Option<wkt::Duration>,
15091
15092        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15093    }
15094
15095    impl Delay {
15096        pub fn new() -> Self {
15097            std::default::Default::default()
15098        }
15099
15100        /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
15101        pub fn set_start_time<T>(mut self, v: T) -> Self
15102        where
15103            T: std::convert::Into<wkt::Timestamp>,
15104        {
15105            self.start_time = std::option::Option::Some(v.into());
15106            self
15107        }
15108
15109        /// Sets or clears the value of [start_time][crate::model::shipment_route::Delay::start_time].
15110        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
15111        where
15112            T: std::convert::Into<wkt::Timestamp>,
15113        {
15114            self.start_time = v.map(|x| x.into());
15115            self
15116        }
15117
15118        /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
15119        pub fn set_duration<T>(mut self, v: T) -> Self
15120        where
15121            T: std::convert::Into<wkt::Duration>,
15122        {
15123            self.duration = std::option::Option::Some(v.into());
15124            self
15125        }
15126
15127        /// Sets or clears the value of [duration][crate::model::shipment_route::Delay::duration].
15128        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
15129        where
15130            T: std::convert::Into<wkt::Duration>,
15131        {
15132            self.duration = v.map(|x| x.into());
15133            self
15134        }
15135    }
15136
15137    impl wkt::message::Message for Delay {
15138        fn typename() -> &'static str {
15139            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
15140        }
15141    }
15142
15143    #[doc(hidden)]
15144    impl<'de> serde::de::Deserialize<'de> for Delay {
15145        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15146        where
15147            D: serde::Deserializer<'de>,
15148        {
15149            #[allow(non_camel_case_types)]
15150            #[doc(hidden)]
15151            #[derive(PartialEq, Eq, Hash)]
15152            enum __FieldTag {
15153                __start_time,
15154                __duration,
15155                Unknown(std::string::String),
15156            }
15157            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15158                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15159                where
15160                    D: serde::Deserializer<'de>,
15161                {
15162                    struct Visitor;
15163                    impl<'de> serde::de::Visitor<'de> for Visitor {
15164                        type Value = __FieldTag;
15165                        fn expecting(
15166                            &self,
15167                            formatter: &mut std::fmt::Formatter,
15168                        ) -> std::fmt::Result {
15169                            formatter.write_str("a field name for Delay")
15170                        }
15171                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15172                        where
15173                            E: serde::de::Error,
15174                        {
15175                            use std::result::Result::Ok;
15176                            use std::string::ToString;
15177                            match value {
15178                                "startTime" => Ok(__FieldTag::__start_time),
15179                                "start_time" => Ok(__FieldTag::__start_time),
15180                                "duration" => Ok(__FieldTag::__duration),
15181                                _ => Ok(__FieldTag::Unknown(value.to_string())),
15182                            }
15183                        }
15184                    }
15185                    deserializer.deserialize_identifier(Visitor)
15186                }
15187            }
15188            struct Visitor;
15189            impl<'de> serde::de::Visitor<'de> for Visitor {
15190                type Value = Delay;
15191                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15192                    formatter.write_str("struct Delay")
15193                }
15194                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15195                where
15196                    A: serde::de::MapAccess<'de>,
15197                {
15198                    #[allow(unused_imports)]
15199                    use serde::de::Error;
15200                    use std::option::Option::Some;
15201                    let mut fields = std::collections::HashSet::new();
15202                    let mut result = Self::Value::new();
15203                    while let Some(tag) = map.next_key::<__FieldTag>()? {
15204                        #[allow(clippy::match_single_binding)]
15205                        match tag {
15206                            __FieldTag::__start_time => {
15207                                if !fields.insert(__FieldTag::__start_time) {
15208                                    return std::result::Result::Err(A::Error::duplicate_field(
15209                                        "multiple values for start_time",
15210                                    ));
15211                                }
15212                                result.start_time =
15213                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
15214                            }
15215                            __FieldTag::__duration => {
15216                                if !fields.insert(__FieldTag::__duration) {
15217                                    return std::result::Result::Err(A::Error::duplicate_field(
15218                                        "multiple values for duration",
15219                                    ));
15220                                }
15221                                result.duration =
15222                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
15223                            }
15224                            __FieldTag::Unknown(key) => {
15225                                let value = map.next_value::<serde_json::Value>()?;
15226                                result._unknown_fields.insert(key, value);
15227                            }
15228                        }
15229                    }
15230                    std::result::Result::Ok(result)
15231                }
15232            }
15233            deserializer.deserialize_any(Visitor)
15234        }
15235    }
15236
15237    #[doc(hidden)]
15238    impl serde::ser::Serialize for Delay {
15239        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15240        where
15241            S: serde::ser::Serializer,
15242        {
15243            use serde::ser::SerializeMap;
15244            #[allow(unused_imports)]
15245            use std::option::Option::Some;
15246            let mut state = serializer.serialize_map(std::option::Option::None)?;
15247            if self.start_time.is_some() {
15248                state.serialize_entry("startTime", &self.start_time)?;
15249            }
15250            if self.duration.is_some() {
15251                state.serialize_entry("duration", &self.duration)?;
15252            }
15253            if !self._unknown_fields.is_empty() {
15254                for (key, value) in self._unknown_fields.iter() {
15255                    state.serialize_entry(key, &value)?;
15256                }
15257            }
15258            state.end()
15259        }
15260    }
15261
15262    impl std::fmt::Debug for Delay {
15263        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15264            let mut debug_struct = f.debug_struct("Delay");
15265            debug_struct.field("start_time", &self.start_time);
15266            debug_struct.field("duration", &self.duration);
15267            if !self._unknown_fields.is_empty() {
15268                debug_struct.field("_unknown_fields", &self._unknown_fields);
15269            }
15270            debug_struct.finish()
15271        }
15272    }
15273
15274    /// A visit performed during a route. This visit corresponds to a pickup or a
15275    /// delivery of a `Shipment`.
15276    #[derive(Clone, Default, PartialEq)]
15277    #[non_exhaustive]
15278    pub struct Visit {
15279        /// Index of the `shipments` field in the source
15280        /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
15281        ///
15282        /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
15283        pub shipment_index: i32,
15284
15285        /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
15286        /// corresponds to a delivery.
15287        pub is_pickup: bool,
15288
15289        /// Index of `VisitRequest` in either the pickup or delivery field of the
15290        /// `Shipment` (see `is_pickup`).
15291        pub visit_request_index: i32,
15292
15293        /// Time at which the visit starts. Note that the vehicle may arrive earlier
15294        /// than this at the visit location. Times are consistent with the
15295        /// `ShipmentModel`.
15296        pub start_time: std::option::Option<wkt::Timestamp>,
15297
15298        /// Total visit load demand as the sum of the shipment and the visit request
15299        /// `load_demands`. The values are negative if the visit is a delivery.
15300        /// Demands are reported for the same types as the
15301        /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
15302        /// (see this field).
15303        ///
15304        /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
15305        pub load_demands:
15306            std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
15307
15308        /// Extra detour time due to the shipments visited on the route before the
15309        /// visit and to the potential waiting time induced by time windows.
15310        /// If the visit is a delivery, the detour is computed from the corresponding
15311        /// pickup visit and is equal to:
15312        ///
15313        /// ```norust
15314        /// start_time(delivery) - start_time(pickup)
15315        /// - (duration(pickup) + travel duration from the pickup location
15316        /// to the delivery location).
15317        /// ```
15318        ///
15319        /// Otherwise, it is computed from the vehicle `start_location` and is equal
15320        /// to:
15321        ///
15322        /// ```norust
15323        /// start_time - vehicle_start_time - travel duration from
15324        /// the vehicle's `start_location` to the visit.
15325        /// ```
15326        pub detour: std::option::Option<wkt::Duration>,
15327
15328        /// Copy of the corresponding `Shipment.label`, if specified in the
15329        /// `Shipment`.
15330        pub shipment_label: std::string::String,
15331
15332        /// Copy of the corresponding
15333        /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
15334        /// if specified in the `VisitRequest`.
15335        ///
15336        /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
15337        pub visit_label: std::string::String,
15338
15339        /// Deprecated: Use
15340        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
15341        /// instead. Vehicle loads upon arrival at the visit location, for each type
15342        /// specified in
15343        /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
15344        /// `start_load_intervals`, `end_load_intervals` or `demands`.
15345        ///
15346        /// Exception: we omit loads for quantity types unconstrained by intervals
15347        /// and that don't have any non-zero demand on the route.
15348        ///
15349        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
15350        /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
15351        #[deprecated]
15352        pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
15353
15354        /// Deprecated: Use
15355        /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
15356        /// instead. Delay occurring before the visit starts.
15357        ///
15358        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
15359        #[deprecated]
15360        pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
15361
15362        /// Deprecated: Use
15363        /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
15364        /// instead.
15365        ///
15366        /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
15367        #[deprecated]
15368        pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
15369
15370        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15371    }
15372
15373    impl Visit {
15374        pub fn new() -> Self {
15375            std::default::Default::default()
15376        }
15377
15378        /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
15379        pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
15380            self.shipment_index = v.into();
15381            self
15382        }
15383
15384        /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
15385        pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
15386            self.is_pickup = v.into();
15387            self
15388        }
15389
15390        /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
15391        pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
15392            self.visit_request_index = v.into();
15393            self
15394        }
15395
15396        /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
15397        pub fn set_start_time<T>(mut self, v: T) -> Self
15398        where
15399            T: std::convert::Into<wkt::Timestamp>,
15400        {
15401            self.start_time = std::option::Option::Some(v.into());
15402            self
15403        }
15404
15405        /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
15406        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
15407        where
15408            T: std::convert::Into<wkt::Timestamp>,
15409        {
15410            self.start_time = v.map(|x| x.into());
15411            self
15412        }
15413
15414        /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
15415        pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
15416        where
15417            T: std::iter::IntoIterator<Item = (K, V)>,
15418            K: std::convert::Into<std::string::String>,
15419            V: std::convert::Into<crate::model::shipment::Load>,
15420        {
15421            use std::iter::Iterator;
15422            self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
15423            self
15424        }
15425
15426        /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
15427        pub fn set_detour<T>(mut self, v: T) -> Self
15428        where
15429            T: std::convert::Into<wkt::Duration>,
15430        {
15431            self.detour = std::option::Option::Some(v.into());
15432            self
15433        }
15434
15435        /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
15436        pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
15437        where
15438            T: std::convert::Into<wkt::Duration>,
15439        {
15440            self.detour = v.map(|x| x.into());
15441            self
15442        }
15443
15444        /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
15445        pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
15446            mut self,
15447            v: T,
15448        ) -> Self {
15449            self.shipment_label = v.into();
15450            self
15451        }
15452
15453        /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
15454        pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15455            self.visit_label = v.into();
15456            self
15457        }
15458
15459        /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
15460        #[deprecated]
15461        pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
15462        where
15463            T: std::iter::IntoIterator<Item = V>,
15464            V: std::convert::Into<crate::model::CapacityQuantity>,
15465        {
15466            use std::iter::Iterator;
15467            self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
15468            self
15469        }
15470
15471        /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
15472        #[deprecated]
15473        pub fn set_delay_before_start<T>(mut self, v: T) -> Self
15474        where
15475            T: std::convert::Into<crate::model::shipment_route::Delay>,
15476        {
15477            self.delay_before_start = std::option::Option::Some(v.into());
15478            self
15479        }
15480
15481        /// Sets or clears the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
15482        #[deprecated]
15483        pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
15484        where
15485            T: std::convert::Into<crate::model::shipment_route::Delay>,
15486        {
15487            self.delay_before_start = v.map(|x| x.into());
15488            self
15489        }
15490
15491        /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
15492        #[deprecated]
15493        pub fn set_demands<T, V>(mut self, v: T) -> Self
15494        where
15495            T: std::iter::IntoIterator<Item = V>,
15496            V: std::convert::Into<crate::model::CapacityQuantity>,
15497        {
15498            use std::iter::Iterator;
15499            self.demands = v.into_iter().map(|i| i.into()).collect();
15500            self
15501        }
15502    }
15503
15504    impl wkt::message::Message for Visit {
15505        fn typename() -> &'static str {
15506            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
15507        }
15508    }
15509
15510    #[doc(hidden)]
15511    impl<'de> serde::de::Deserialize<'de> for Visit {
15512        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15513        where
15514            D: serde::Deserializer<'de>,
15515        {
15516            #[allow(non_camel_case_types)]
15517            #[doc(hidden)]
15518            #[derive(PartialEq, Eq, Hash)]
15519            enum __FieldTag {
15520                __shipment_index,
15521                __is_pickup,
15522                __visit_request_index,
15523                __start_time,
15524                __load_demands,
15525                __detour,
15526                __shipment_label,
15527                __visit_label,
15528                __arrival_loads,
15529                __delay_before_start,
15530                __demands,
15531                Unknown(std::string::String),
15532            }
15533            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15534                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15535                where
15536                    D: serde::Deserializer<'de>,
15537                {
15538                    struct Visitor;
15539                    impl<'de> serde::de::Visitor<'de> for Visitor {
15540                        type Value = __FieldTag;
15541                        fn expecting(
15542                            &self,
15543                            formatter: &mut std::fmt::Formatter,
15544                        ) -> std::fmt::Result {
15545                            formatter.write_str("a field name for Visit")
15546                        }
15547                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15548                        where
15549                            E: serde::de::Error,
15550                        {
15551                            use std::result::Result::Ok;
15552                            use std::string::ToString;
15553                            match value {
15554                                "shipmentIndex" => Ok(__FieldTag::__shipment_index),
15555                                "shipment_index" => Ok(__FieldTag::__shipment_index),
15556                                "isPickup" => Ok(__FieldTag::__is_pickup),
15557                                "is_pickup" => Ok(__FieldTag::__is_pickup),
15558                                "visitRequestIndex" => Ok(__FieldTag::__visit_request_index),
15559                                "visit_request_index" => Ok(__FieldTag::__visit_request_index),
15560                                "startTime" => Ok(__FieldTag::__start_time),
15561                                "start_time" => Ok(__FieldTag::__start_time),
15562                                "loadDemands" => Ok(__FieldTag::__load_demands),
15563                                "load_demands" => Ok(__FieldTag::__load_demands),
15564                                "detour" => Ok(__FieldTag::__detour),
15565                                "shipmentLabel" => Ok(__FieldTag::__shipment_label),
15566                                "shipment_label" => Ok(__FieldTag::__shipment_label),
15567                                "visitLabel" => Ok(__FieldTag::__visit_label),
15568                                "visit_label" => Ok(__FieldTag::__visit_label),
15569                                "arrivalLoads" => Ok(__FieldTag::__arrival_loads),
15570                                "arrival_loads" => Ok(__FieldTag::__arrival_loads),
15571                                "delayBeforeStart" => Ok(__FieldTag::__delay_before_start),
15572                                "delay_before_start" => Ok(__FieldTag::__delay_before_start),
15573                                "demands" => Ok(__FieldTag::__demands),
15574                                _ => Ok(__FieldTag::Unknown(value.to_string())),
15575                            }
15576                        }
15577                    }
15578                    deserializer.deserialize_identifier(Visitor)
15579                }
15580            }
15581            struct Visitor;
15582            impl<'de> serde::de::Visitor<'de> for Visitor {
15583                type Value = Visit;
15584                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15585                    formatter.write_str("struct Visit")
15586                }
15587                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15588                where
15589                    A: serde::de::MapAccess<'de>,
15590                {
15591                    #[allow(unused_imports)]
15592                    use serde::de::Error;
15593                    use std::option::Option::Some;
15594                    let mut fields = std::collections::HashSet::new();
15595                    let mut result = Self::Value::new();
15596                    while let Some(tag) = map.next_key::<__FieldTag>()? {
15597                        #[allow(clippy::match_single_binding)]
15598                        match tag {
15599                            __FieldTag::__shipment_index => {
15600                                if !fields.insert(__FieldTag::__shipment_index) {
15601                                    return std::result::Result::Err(A::Error::duplicate_field(
15602                                        "multiple values for shipment_index",
15603                                    ));
15604                                }
15605                                struct __With(std::option::Option<i32>);
15606                                impl<'de> serde::de::Deserialize<'de> for __With {
15607                                    fn deserialize<D>(
15608                                        deserializer: D,
15609                                    ) -> std::result::Result<Self, D::Error>
15610                                    where
15611                                        D: serde::de::Deserializer<'de>,
15612                                    {
15613                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
15614                                    }
15615                                }
15616                                result.shipment_index =
15617                                    map.next_value::<__With>()?.0.unwrap_or_default();
15618                            }
15619                            __FieldTag::__is_pickup => {
15620                                if !fields.insert(__FieldTag::__is_pickup) {
15621                                    return std::result::Result::Err(A::Error::duplicate_field(
15622                                        "multiple values for is_pickup",
15623                                    ));
15624                                }
15625                                result.is_pickup = map
15626                                    .next_value::<std::option::Option<bool>>()?
15627                                    .unwrap_or_default();
15628                            }
15629                            __FieldTag::__visit_request_index => {
15630                                if !fields.insert(__FieldTag::__visit_request_index) {
15631                                    return std::result::Result::Err(A::Error::duplicate_field(
15632                                        "multiple values for visit_request_index",
15633                                    ));
15634                                }
15635                                struct __With(std::option::Option<i32>);
15636                                impl<'de> serde::de::Deserialize<'de> for __With {
15637                                    fn deserialize<D>(
15638                                        deserializer: D,
15639                                    ) -> std::result::Result<Self, D::Error>
15640                                    where
15641                                        D: serde::de::Deserializer<'de>,
15642                                    {
15643                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
15644                                    }
15645                                }
15646                                result.visit_request_index =
15647                                    map.next_value::<__With>()?.0.unwrap_or_default();
15648                            }
15649                            __FieldTag::__start_time => {
15650                                if !fields.insert(__FieldTag::__start_time) {
15651                                    return std::result::Result::Err(A::Error::duplicate_field(
15652                                        "multiple values for start_time",
15653                                    ));
15654                                }
15655                                result.start_time =
15656                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
15657                            }
15658                            __FieldTag::__load_demands => {
15659                                if !fields.insert(__FieldTag::__load_demands) {
15660                                    return std::result::Result::Err(A::Error::duplicate_field(
15661                                        "multiple values for load_demands",
15662                                    ));
15663                                }
15664                                result.load_demands = map
15665                                    .next_value::<std::option::Option<
15666                                        std::collections::HashMap<
15667                                            std::string::String,
15668                                            crate::model::shipment::Load,
15669                                        >,
15670                                    >>()?
15671                                    .unwrap_or_default();
15672                            }
15673                            __FieldTag::__detour => {
15674                                if !fields.insert(__FieldTag::__detour) {
15675                                    return std::result::Result::Err(A::Error::duplicate_field(
15676                                        "multiple values for detour",
15677                                    ));
15678                                }
15679                                result.detour =
15680                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
15681                            }
15682                            __FieldTag::__shipment_label => {
15683                                if !fields.insert(__FieldTag::__shipment_label) {
15684                                    return std::result::Result::Err(A::Error::duplicate_field(
15685                                        "multiple values for shipment_label",
15686                                    ));
15687                                }
15688                                result.shipment_label = map
15689                                    .next_value::<std::option::Option<std::string::String>>()?
15690                                    .unwrap_or_default();
15691                            }
15692                            __FieldTag::__visit_label => {
15693                                if !fields.insert(__FieldTag::__visit_label) {
15694                                    return std::result::Result::Err(A::Error::duplicate_field(
15695                                        "multiple values for visit_label",
15696                                    ));
15697                                }
15698                                result.visit_label = map
15699                                    .next_value::<std::option::Option<std::string::String>>()?
15700                                    .unwrap_or_default();
15701                            }
15702                            __FieldTag::__arrival_loads => {
15703                                if !fields.insert(__FieldTag::__arrival_loads) {
15704                                    return std::result::Result::Err(A::Error::duplicate_field(
15705                                        "multiple values for arrival_loads",
15706                                    ));
15707                                }
15708                                result.arrival_loads = map
15709                                    .next_value::<std::option::Option<
15710                                        std::vec::Vec<crate::model::CapacityQuantity>,
15711                                    >>()?
15712                                    .unwrap_or_default();
15713                            }
15714                            __FieldTag::__delay_before_start => {
15715                                if !fields.insert(__FieldTag::__delay_before_start) {
15716                                    return std::result::Result::Err(A::Error::duplicate_field(
15717                                        "multiple values for delay_before_start",
15718                                    ));
15719                                }
15720                                result.delay_before_start = map.next_value::<std::option::Option<crate::model::shipment_route::Delay>>()?
15721                                    ;
15722                            }
15723                            __FieldTag::__demands => {
15724                                if !fields.insert(__FieldTag::__demands) {
15725                                    return std::result::Result::Err(A::Error::duplicate_field(
15726                                        "multiple values for demands",
15727                                    ));
15728                                }
15729                                result.demands = map
15730                                    .next_value::<std::option::Option<
15731                                        std::vec::Vec<crate::model::CapacityQuantity>,
15732                                    >>()?
15733                                    .unwrap_or_default();
15734                            }
15735                            __FieldTag::Unknown(key) => {
15736                                let value = map.next_value::<serde_json::Value>()?;
15737                                result._unknown_fields.insert(key, value);
15738                            }
15739                        }
15740                    }
15741                    std::result::Result::Ok(result)
15742                }
15743            }
15744            deserializer.deserialize_any(Visitor)
15745        }
15746    }
15747
15748    #[doc(hidden)]
15749    impl serde::ser::Serialize for Visit {
15750        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15751        where
15752            S: serde::ser::Serializer,
15753        {
15754            use serde::ser::SerializeMap;
15755            #[allow(unused_imports)]
15756            use std::option::Option::Some;
15757            let mut state = serializer.serialize_map(std::option::Option::None)?;
15758            if !wkt::internal::is_default(&self.shipment_index) {
15759                struct __With<'a>(&'a i32);
15760                impl<'a> serde::ser::Serialize for __With<'a> {
15761                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15762                    where
15763                        S: serde::ser::Serializer,
15764                    {
15765                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
15766                    }
15767                }
15768                state.serialize_entry("shipmentIndex", &__With(&self.shipment_index))?;
15769            }
15770            if !wkt::internal::is_default(&self.is_pickup) {
15771                state.serialize_entry("isPickup", &self.is_pickup)?;
15772            }
15773            if !wkt::internal::is_default(&self.visit_request_index) {
15774                struct __With<'a>(&'a i32);
15775                impl<'a> serde::ser::Serialize for __With<'a> {
15776                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15777                    where
15778                        S: serde::ser::Serializer,
15779                    {
15780                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
15781                    }
15782                }
15783                state.serialize_entry("visitRequestIndex", &__With(&self.visit_request_index))?;
15784            }
15785            if self.start_time.is_some() {
15786                state.serialize_entry("startTime", &self.start_time)?;
15787            }
15788            if !self.load_demands.is_empty() {
15789                state.serialize_entry("loadDemands", &self.load_demands)?;
15790            }
15791            if self.detour.is_some() {
15792                state.serialize_entry("detour", &self.detour)?;
15793            }
15794            if !self.shipment_label.is_empty() {
15795                state.serialize_entry("shipmentLabel", &self.shipment_label)?;
15796            }
15797            if !self.visit_label.is_empty() {
15798                state.serialize_entry("visitLabel", &self.visit_label)?;
15799            }
15800            if !self.arrival_loads.is_empty() {
15801                state.serialize_entry("arrivalLoads", &self.arrival_loads)?;
15802            }
15803            if self.delay_before_start.is_some() {
15804                state.serialize_entry("delayBeforeStart", &self.delay_before_start)?;
15805            }
15806            if !self.demands.is_empty() {
15807                state.serialize_entry("demands", &self.demands)?;
15808            }
15809            if !self._unknown_fields.is_empty() {
15810                for (key, value) in self._unknown_fields.iter() {
15811                    state.serialize_entry(key, &value)?;
15812                }
15813            }
15814            state.end()
15815        }
15816    }
15817
15818    impl std::fmt::Debug for Visit {
15819        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15820            let mut debug_struct = f.debug_struct("Visit");
15821            debug_struct.field("shipment_index", &self.shipment_index);
15822            debug_struct.field("is_pickup", &self.is_pickup);
15823            debug_struct.field("visit_request_index", &self.visit_request_index);
15824            debug_struct.field("start_time", &self.start_time);
15825            debug_struct.field("load_demands", &self.load_demands);
15826            debug_struct.field("detour", &self.detour);
15827            debug_struct.field("shipment_label", &self.shipment_label);
15828            debug_struct.field("visit_label", &self.visit_label);
15829            debug_struct.field("arrival_loads", &self.arrival_loads);
15830            debug_struct.field("delay_before_start", &self.delay_before_start);
15831            debug_struct.field("demands", &self.demands);
15832            if !self._unknown_fields.is_empty() {
15833                debug_struct.field("_unknown_fields", &self._unknown_fields);
15834            }
15835            debug_struct.finish()
15836        }
15837    }
15838
15839    /// Transition between two events on the route. See the description of
15840    /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
15841    ///
15842    /// If the vehicle does not have a `start_location` and/or `end_location`, the
15843    /// corresponding travel metrics are 0.
15844    ///
15845    /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
15846    #[derive(Clone, Default, PartialEq)]
15847    #[non_exhaustive]
15848    pub struct Transition {
15849        /// Travel duration during this transition.
15850        pub travel_duration: std::option::Option<wkt::Duration>,
15851
15852        /// Distance traveled during the transition.
15853        pub travel_distance_meters: f64,
15854
15855        /// When traffic is requested via
15856        /// [OptimizeToursRequest.consider_road_traffic]
15857        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
15858        /// and the traffic info couldn't be retrieved for a `Transition`, this
15859        /// boolean is set to true. This may be temporary (rare hiccup in the
15860        /// realtime traffic servers) or permanent (no data for this location).
15861        pub traffic_info_unavailable: bool,
15862
15863        /// Sum of the delay durations applied to this transition. If any, the delay
15864        /// starts exactly `delay_duration` seconds before the next event (visit or
15865        /// vehicle end). See
15866        /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
15867        ///
15868        /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
15869        pub delay_duration: std::option::Option<wkt::Duration>,
15870
15871        /// Sum of the duration of the breaks occurring during this transition, if
15872        /// any. Details about each break's start time and duration are stored in
15873        /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
15874        ///
15875        /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
15876        pub break_duration: std::option::Option<wkt::Duration>,
15877
15878        /// Time spent waiting during this transition. Wait duration corresponds to
15879        /// idle time and does not include break time. Also note that this wait time
15880        /// may be split into several non-contiguous intervals.
15881        pub wait_duration: std::option::Option<wkt::Duration>,
15882
15883        /// Total duration of the transition, provided for convenience. It is equal
15884        /// to:
15885        ///
15886        /// * next visit `start_time` (or `vehicle_end_time` if this is the last
15887        ///   transition) - this transition's `start_time`;
15888        /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
15889        ///   additionally holds: `total_duration = travel_duration + delay_duration
15890        ///
15891        /// + break_duration + wait_duration`.
15892        pub total_duration: std::option::Option<wkt::Duration>,
15893
15894        /// Start time of this transition.
15895        pub start_time: std::option::Option<wkt::Timestamp>,
15896
15897        /// The encoded polyline representation of the route followed during the
15898        /// transition.
15899        /// This field is only populated if [populate_transition_polylines]
15900        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
15901        /// is set to true.
15902        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
15903
15904        /// Vehicle loads during this transition, for each type that either appears
15905        /// in this vehicle's
15906        /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
15907        /// or that have non-zero
15908        /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
15909        /// on some shipment performed on this route.
15910        ///
15911        /// The loads during the first transition are the starting loads of the
15912        /// vehicle route. Then, after each visit, the visit's `load_demands` are
15913        /// either added or subtracted to get the next transition's loads, depending
15914        /// on whether the visit was a pickup or a delivery.
15915        ///
15916        /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
15917        /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
15918        pub vehicle_loads: std::collections::HashMap<
15919            std::string::String,
15920            crate::model::shipment_route::VehicleLoad,
15921        >,
15922
15923        /// Deprecated: Use
15924        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
15925        /// instead.
15926        ///
15927        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
15928        #[deprecated]
15929        pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
15930
15931        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15932    }
15933
15934    impl Transition {
15935        pub fn new() -> Self {
15936            std::default::Default::default()
15937        }
15938
15939        /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
15940        pub fn set_travel_duration<T>(mut self, v: T) -> Self
15941        where
15942            T: std::convert::Into<wkt::Duration>,
15943        {
15944            self.travel_duration = std::option::Option::Some(v.into());
15945            self
15946        }
15947
15948        /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
15949        pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
15950        where
15951            T: std::convert::Into<wkt::Duration>,
15952        {
15953            self.travel_duration = v.map(|x| x.into());
15954            self
15955        }
15956
15957        /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
15958        pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
15959            self.travel_distance_meters = v.into();
15960            self
15961        }
15962
15963        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
15964        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
15965            self.traffic_info_unavailable = v.into();
15966            self
15967        }
15968
15969        /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
15970        pub fn set_delay_duration<T>(mut self, v: T) -> Self
15971        where
15972            T: std::convert::Into<wkt::Duration>,
15973        {
15974            self.delay_duration = std::option::Option::Some(v.into());
15975            self
15976        }
15977
15978        /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
15979        pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
15980        where
15981            T: std::convert::Into<wkt::Duration>,
15982        {
15983            self.delay_duration = v.map(|x| x.into());
15984            self
15985        }
15986
15987        /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
15988        pub fn set_break_duration<T>(mut self, v: T) -> Self
15989        where
15990            T: std::convert::Into<wkt::Duration>,
15991        {
15992            self.break_duration = std::option::Option::Some(v.into());
15993            self
15994        }
15995
15996        /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
15997        pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
15998        where
15999            T: std::convert::Into<wkt::Duration>,
16000        {
16001            self.break_duration = v.map(|x| x.into());
16002            self
16003        }
16004
16005        /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
16006        pub fn set_wait_duration<T>(mut self, v: T) -> Self
16007        where
16008            T: std::convert::Into<wkt::Duration>,
16009        {
16010            self.wait_duration = std::option::Option::Some(v.into());
16011            self
16012        }
16013
16014        /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
16015        pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
16016        where
16017            T: std::convert::Into<wkt::Duration>,
16018        {
16019            self.wait_duration = v.map(|x| x.into());
16020            self
16021        }
16022
16023        /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
16024        pub fn set_total_duration<T>(mut self, v: T) -> Self
16025        where
16026            T: std::convert::Into<wkt::Duration>,
16027        {
16028            self.total_duration = std::option::Option::Some(v.into());
16029            self
16030        }
16031
16032        /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
16033        pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
16034        where
16035            T: std::convert::Into<wkt::Duration>,
16036        {
16037            self.total_duration = v.map(|x| x.into());
16038            self
16039        }
16040
16041        /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
16042        pub fn set_start_time<T>(mut self, v: T) -> Self
16043        where
16044            T: std::convert::Into<wkt::Timestamp>,
16045        {
16046            self.start_time = std::option::Option::Some(v.into());
16047            self
16048        }
16049
16050        /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
16051        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
16052        where
16053            T: std::convert::Into<wkt::Timestamp>,
16054        {
16055            self.start_time = v.map(|x| x.into());
16056            self
16057        }
16058
16059        /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
16060        pub fn set_route_polyline<T>(mut self, v: T) -> Self
16061        where
16062            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
16063        {
16064            self.route_polyline = std::option::Option::Some(v.into());
16065            self
16066        }
16067
16068        /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
16069        pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
16070        where
16071            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
16072        {
16073            self.route_polyline = v.map(|x| x.into());
16074            self
16075        }
16076
16077        /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
16078        pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
16079        where
16080            T: std::iter::IntoIterator<Item = (K, V)>,
16081            K: std::convert::Into<std::string::String>,
16082            V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
16083        {
16084            use std::iter::Iterator;
16085            self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
16086            self
16087        }
16088
16089        /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
16090        #[deprecated]
16091        pub fn set_loads<T, V>(mut self, v: T) -> Self
16092        where
16093            T: std::iter::IntoIterator<Item = V>,
16094            V: std::convert::Into<crate::model::CapacityQuantity>,
16095        {
16096            use std::iter::Iterator;
16097            self.loads = v.into_iter().map(|i| i.into()).collect();
16098            self
16099        }
16100    }
16101
16102    impl wkt::message::Message for Transition {
16103        fn typename() -> &'static str {
16104            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
16105        }
16106    }
16107
16108    #[doc(hidden)]
16109    impl<'de> serde::de::Deserialize<'de> for Transition {
16110        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16111        where
16112            D: serde::Deserializer<'de>,
16113        {
16114            #[allow(non_camel_case_types)]
16115            #[doc(hidden)]
16116            #[derive(PartialEq, Eq, Hash)]
16117            enum __FieldTag {
16118                __travel_duration,
16119                __travel_distance_meters,
16120                __traffic_info_unavailable,
16121                __delay_duration,
16122                __break_duration,
16123                __wait_duration,
16124                __total_duration,
16125                __start_time,
16126                __route_polyline,
16127                __vehicle_loads,
16128                __loads,
16129                Unknown(std::string::String),
16130            }
16131            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16132                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16133                where
16134                    D: serde::Deserializer<'de>,
16135                {
16136                    struct Visitor;
16137                    impl<'de> serde::de::Visitor<'de> for Visitor {
16138                        type Value = __FieldTag;
16139                        fn expecting(
16140                            &self,
16141                            formatter: &mut std::fmt::Formatter,
16142                        ) -> std::fmt::Result {
16143                            formatter.write_str("a field name for Transition")
16144                        }
16145                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16146                        where
16147                            E: serde::de::Error,
16148                        {
16149                            use std::result::Result::Ok;
16150                            use std::string::ToString;
16151                            match value {
16152                                "travelDuration" => Ok(__FieldTag::__travel_duration),
16153                                "travel_duration" => Ok(__FieldTag::__travel_duration),
16154                                "travelDistanceMeters" => Ok(__FieldTag::__travel_distance_meters),
16155                                "travel_distance_meters" => {
16156                                    Ok(__FieldTag::__travel_distance_meters)
16157                                }
16158                                "trafficInfoUnavailable" => {
16159                                    Ok(__FieldTag::__traffic_info_unavailable)
16160                                }
16161                                "traffic_info_unavailable" => {
16162                                    Ok(__FieldTag::__traffic_info_unavailable)
16163                                }
16164                                "delayDuration" => Ok(__FieldTag::__delay_duration),
16165                                "delay_duration" => Ok(__FieldTag::__delay_duration),
16166                                "breakDuration" => Ok(__FieldTag::__break_duration),
16167                                "break_duration" => Ok(__FieldTag::__break_duration),
16168                                "waitDuration" => Ok(__FieldTag::__wait_duration),
16169                                "wait_duration" => Ok(__FieldTag::__wait_duration),
16170                                "totalDuration" => Ok(__FieldTag::__total_duration),
16171                                "total_duration" => Ok(__FieldTag::__total_duration),
16172                                "startTime" => Ok(__FieldTag::__start_time),
16173                                "start_time" => Ok(__FieldTag::__start_time),
16174                                "routePolyline" => Ok(__FieldTag::__route_polyline),
16175                                "route_polyline" => Ok(__FieldTag::__route_polyline),
16176                                "vehicleLoads" => Ok(__FieldTag::__vehicle_loads),
16177                                "vehicle_loads" => Ok(__FieldTag::__vehicle_loads),
16178                                "loads" => Ok(__FieldTag::__loads),
16179                                _ => Ok(__FieldTag::Unknown(value.to_string())),
16180                            }
16181                        }
16182                    }
16183                    deserializer.deserialize_identifier(Visitor)
16184                }
16185            }
16186            struct Visitor;
16187            impl<'de> serde::de::Visitor<'de> for Visitor {
16188                type Value = Transition;
16189                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16190                    formatter.write_str("struct Transition")
16191                }
16192                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16193                where
16194                    A: serde::de::MapAccess<'de>,
16195                {
16196                    #[allow(unused_imports)]
16197                    use serde::de::Error;
16198                    use std::option::Option::Some;
16199                    let mut fields = std::collections::HashSet::new();
16200                    let mut result = Self::Value::new();
16201                    while let Some(tag) = map.next_key::<__FieldTag>()? {
16202                        #[allow(clippy::match_single_binding)]
16203                        match tag {
16204                            __FieldTag::__travel_duration => {
16205                                if !fields.insert(__FieldTag::__travel_duration) {
16206                                    return std::result::Result::Err(A::Error::duplicate_field(
16207                                        "multiple values for travel_duration",
16208                                    ));
16209                                }
16210                                result.travel_duration =
16211                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
16212                            }
16213                            __FieldTag::__travel_distance_meters => {
16214                                if !fields.insert(__FieldTag::__travel_distance_meters) {
16215                                    return std::result::Result::Err(A::Error::duplicate_field(
16216                                        "multiple values for travel_distance_meters",
16217                                    ));
16218                                }
16219                                struct __With(std::option::Option<f64>);
16220                                impl<'de> serde::de::Deserialize<'de> for __With {
16221                                    fn deserialize<D>(
16222                                        deserializer: D,
16223                                    ) -> std::result::Result<Self, D::Error>
16224                                    where
16225                                        D: serde::de::Deserializer<'de>,
16226                                    {
16227                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
16228                                    }
16229                                }
16230                                result.travel_distance_meters =
16231                                    map.next_value::<__With>()?.0.unwrap_or_default();
16232                            }
16233                            __FieldTag::__traffic_info_unavailable => {
16234                                if !fields.insert(__FieldTag::__traffic_info_unavailable) {
16235                                    return std::result::Result::Err(A::Error::duplicate_field(
16236                                        "multiple values for traffic_info_unavailable",
16237                                    ));
16238                                }
16239                                result.traffic_info_unavailable = map
16240                                    .next_value::<std::option::Option<bool>>()?
16241                                    .unwrap_or_default();
16242                            }
16243                            __FieldTag::__delay_duration => {
16244                                if !fields.insert(__FieldTag::__delay_duration) {
16245                                    return std::result::Result::Err(A::Error::duplicate_field(
16246                                        "multiple values for delay_duration",
16247                                    ));
16248                                }
16249                                result.delay_duration =
16250                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
16251                            }
16252                            __FieldTag::__break_duration => {
16253                                if !fields.insert(__FieldTag::__break_duration) {
16254                                    return std::result::Result::Err(A::Error::duplicate_field(
16255                                        "multiple values for break_duration",
16256                                    ));
16257                                }
16258                                result.break_duration =
16259                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
16260                            }
16261                            __FieldTag::__wait_duration => {
16262                                if !fields.insert(__FieldTag::__wait_duration) {
16263                                    return std::result::Result::Err(A::Error::duplicate_field(
16264                                        "multiple values for wait_duration",
16265                                    ));
16266                                }
16267                                result.wait_duration =
16268                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
16269                            }
16270                            __FieldTag::__total_duration => {
16271                                if !fields.insert(__FieldTag::__total_duration) {
16272                                    return std::result::Result::Err(A::Error::duplicate_field(
16273                                        "multiple values for total_duration",
16274                                    ));
16275                                }
16276                                result.total_duration =
16277                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
16278                            }
16279                            __FieldTag::__start_time => {
16280                                if !fields.insert(__FieldTag::__start_time) {
16281                                    return std::result::Result::Err(A::Error::duplicate_field(
16282                                        "multiple values for start_time",
16283                                    ));
16284                                }
16285                                result.start_time =
16286                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
16287                            }
16288                            __FieldTag::__route_polyline => {
16289                                if !fields.insert(__FieldTag::__route_polyline) {
16290                                    return std::result::Result::Err(A::Error::duplicate_field(
16291                                        "multiple values for route_polyline",
16292                                    ));
16293                                }
16294                                result.route_polyline = map.next_value::<std::option::Option<
16295                                    crate::model::shipment_route::EncodedPolyline,
16296                                >>()?;
16297                            }
16298                            __FieldTag::__vehicle_loads => {
16299                                if !fields.insert(__FieldTag::__vehicle_loads) {
16300                                    return std::result::Result::Err(A::Error::duplicate_field(
16301                                        "multiple values for vehicle_loads",
16302                                    ));
16303                                }
16304                                result.vehicle_loads = map
16305                                    .next_value::<std::option::Option<
16306                                        std::collections::HashMap<
16307                                            std::string::String,
16308                                            crate::model::shipment_route::VehicleLoad,
16309                                        >,
16310                                    >>()?
16311                                    .unwrap_or_default();
16312                            }
16313                            __FieldTag::__loads => {
16314                                if !fields.insert(__FieldTag::__loads) {
16315                                    return std::result::Result::Err(A::Error::duplicate_field(
16316                                        "multiple values for loads",
16317                                    ));
16318                                }
16319                                result.loads = map
16320                                    .next_value::<std::option::Option<
16321                                        std::vec::Vec<crate::model::CapacityQuantity>,
16322                                    >>()?
16323                                    .unwrap_or_default();
16324                            }
16325                            __FieldTag::Unknown(key) => {
16326                                let value = map.next_value::<serde_json::Value>()?;
16327                                result._unknown_fields.insert(key, value);
16328                            }
16329                        }
16330                    }
16331                    std::result::Result::Ok(result)
16332                }
16333            }
16334            deserializer.deserialize_any(Visitor)
16335        }
16336    }
16337
16338    #[doc(hidden)]
16339    impl serde::ser::Serialize for Transition {
16340        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16341        where
16342            S: serde::ser::Serializer,
16343        {
16344            use serde::ser::SerializeMap;
16345            #[allow(unused_imports)]
16346            use std::option::Option::Some;
16347            let mut state = serializer.serialize_map(std::option::Option::None)?;
16348            if self.travel_duration.is_some() {
16349                state.serialize_entry("travelDuration", &self.travel_duration)?;
16350            }
16351            if !wkt::internal::is_default(&self.travel_distance_meters) {
16352                struct __With<'a>(&'a f64);
16353                impl<'a> serde::ser::Serialize for __With<'a> {
16354                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16355                    where
16356                        S: serde::ser::Serializer,
16357                    {
16358                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
16359                    }
16360                }
16361                state.serialize_entry(
16362                    "travelDistanceMeters",
16363                    &__With(&self.travel_distance_meters),
16364                )?;
16365            }
16366            if !wkt::internal::is_default(&self.traffic_info_unavailable) {
16367                state.serialize_entry("trafficInfoUnavailable", &self.traffic_info_unavailable)?;
16368            }
16369            if self.delay_duration.is_some() {
16370                state.serialize_entry("delayDuration", &self.delay_duration)?;
16371            }
16372            if self.break_duration.is_some() {
16373                state.serialize_entry("breakDuration", &self.break_duration)?;
16374            }
16375            if self.wait_duration.is_some() {
16376                state.serialize_entry("waitDuration", &self.wait_duration)?;
16377            }
16378            if self.total_duration.is_some() {
16379                state.serialize_entry("totalDuration", &self.total_duration)?;
16380            }
16381            if self.start_time.is_some() {
16382                state.serialize_entry("startTime", &self.start_time)?;
16383            }
16384            if self.route_polyline.is_some() {
16385                state.serialize_entry("routePolyline", &self.route_polyline)?;
16386            }
16387            if !self.vehicle_loads.is_empty() {
16388                state.serialize_entry("vehicleLoads", &self.vehicle_loads)?;
16389            }
16390            if !self.loads.is_empty() {
16391                state.serialize_entry("loads", &self.loads)?;
16392            }
16393            if !self._unknown_fields.is_empty() {
16394                for (key, value) in self._unknown_fields.iter() {
16395                    state.serialize_entry(key, &value)?;
16396                }
16397            }
16398            state.end()
16399        }
16400    }
16401
16402    impl std::fmt::Debug for Transition {
16403        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16404            let mut debug_struct = f.debug_struct("Transition");
16405            debug_struct.field("travel_duration", &self.travel_duration);
16406            debug_struct.field("travel_distance_meters", &self.travel_distance_meters);
16407            debug_struct.field("traffic_info_unavailable", &self.traffic_info_unavailable);
16408            debug_struct.field("delay_duration", &self.delay_duration);
16409            debug_struct.field("break_duration", &self.break_duration);
16410            debug_struct.field("wait_duration", &self.wait_duration);
16411            debug_struct.field("total_duration", &self.total_duration);
16412            debug_struct.field("start_time", &self.start_time);
16413            debug_struct.field("route_polyline", &self.route_polyline);
16414            debug_struct.field("vehicle_loads", &self.vehicle_loads);
16415            debug_struct.field("loads", &self.loads);
16416            if !self._unknown_fields.is_empty() {
16417                debug_struct.field("_unknown_fields", &self._unknown_fields);
16418            }
16419            debug_struct.finish()
16420        }
16421    }
16422
16423    /// Reports the actual load of the vehicle at some point along the route,
16424    /// for a given type (see
16425    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
16426    ///
16427    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
16428    #[derive(Clone, Default, PartialEq)]
16429    #[non_exhaustive]
16430    pub struct VehicleLoad {
16431        /// The amount of load on the vehicle, for the given type. The unit of load
16432        /// is usually indicated by the type. See
16433        /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
16434        ///
16435        /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
16436        pub amount: i64,
16437
16438        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16439    }
16440
16441    impl VehicleLoad {
16442        pub fn new() -> Self {
16443            std::default::Default::default()
16444        }
16445
16446        /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
16447        pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
16448            self.amount = v.into();
16449            self
16450        }
16451    }
16452
16453    impl wkt::message::Message for VehicleLoad {
16454        fn typename() -> &'static str {
16455            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
16456        }
16457    }
16458
16459    #[doc(hidden)]
16460    impl<'de> serde::de::Deserialize<'de> for VehicleLoad {
16461        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16462        where
16463            D: serde::Deserializer<'de>,
16464        {
16465            #[allow(non_camel_case_types)]
16466            #[doc(hidden)]
16467            #[derive(PartialEq, Eq, Hash)]
16468            enum __FieldTag {
16469                __amount,
16470                Unknown(std::string::String),
16471            }
16472            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16473                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16474                where
16475                    D: serde::Deserializer<'de>,
16476                {
16477                    struct Visitor;
16478                    impl<'de> serde::de::Visitor<'de> for Visitor {
16479                        type Value = __FieldTag;
16480                        fn expecting(
16481                            &self,
16482                            formatter: &mut std::fmt::Formatter,
16483                        ) -> std::fmt::Result {
16484                            formatter.write_str("a field name for VehicleLoad")
16485                        }
16486                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16487                        where
16488                            E: serde::de::Error,
16489                        {
16490                            use std::result::Result::Ok;
16491                            use std::string::ToString;
16492                            match value {
16493                                "amount" => Ok(__FieldTag::__amount),
16494                                _ => Ok(__FieldTag::Unknown(value.to_string())),
16495                            }
16496                        }
16497                    }
16498                    deserializer.deserialize_identifier(Visitor)
16499                }
16500            }
16501            struct Visitor;
16502            impl<'de> serde::de::Visitor<'de> for Visitor {
16503                type Value = VehicleLoad;
16504                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16505                    formatter.write_str("struct VehicleLoad")
16506                }
16507                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16508                where
16509                    A: serde::de::MapAccess<'de>,
16510                {
16511                    #[allow(unused_imports)]
16512                    use serde::de::Error;
16513                    use std::option::Option::Some;
16514                    let mut fields = std::collections::HashSet::new();
16515                    let mut result = Self::Value::new();
16516                    while let Some(tag) = map.next_key::<__FieldTag>()? {
16517                        #[allow(clippy::match_single_binding)]
16518                        match tag {
16519                            __FieldTag::__amount => {
16520                                if !fields.insert(__FieldTag::__amount) {
16521                                    return std::result::Result::Err(A::Error::duplicate_field(
16522                                        "multiple values for amount",
16523                                    ));
16524                                }
16525                                struct __With(std::option::Option<i64>);
16526                                impl<'de> serde::de::Deserialize<'de> for __With {
16527                                    fn deserialize<D>(
16528                                        deserializer: D,
16529                                    ) -> std::result::Result<Self, D::Error>
16530                                    where
16531                                        D: serde::de::Deserializer<'de>,
16532                                    {
16533                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
16534                                    }
16535                                }
16536                                result.amount = map.next_value::<__With>()?.0.unwrap_or_default();
16537                            }
16538                            __FieldTag::Unknown(key) => {
16539                                let value = map.next_value::<serde_json::Value>()?;
16540                                result._unknown_fields.insert(key, value);
16541                            }
16542                        }
16543                    }
16544                    std::result::Result::Ok(result)
16545                }
16546            }
16547            deserializer.deserialize_any(Visitor)
16548        }
16549    }
16550
16551    #[doc(hidden)]
16552    impl serde::ser::Serialize for VehicleLoad {
16553        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16554        where
16555            S: serde::ser::Serializer,
16556        {
16557            use serde::ser::SerializeMap;
16558            #[allow(unused_imports)]
16559            use std::option::Option::Some;
16560            let mut state = serializer.serialize_map(std::option::Option::None)?;
16561            if !wkt::internal::is_default(&self.amount) {
16562                struct __With<'a>(&'a i64);
16563                impl<'a> serde::ser::Serialize for __With<'a> {
16564                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16565                    where
16566                        S: serde::ser::Serializer,
16567                    {
16568                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
16569                    }
16570                }
16571                state.serialize_entry("amount", &__With(&self.amount))?;
16572            }
16573            if !self._unknown_fields.is_empty() {
16574                for (key, value) in self._unknown_fields.iter() {
16575                    state.serialize_entry(key, &value)?;
16576                }
16577            }
16578            state.end()
16579        }
16580    }
16581
16582    impl std::fmt::Debug for VehicleLoad {
16583        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16584            let mut debug_struct = f.debug_struct("VehicleLoad");
16585            debug_struct.field("amount", &self.amount);
16586            if !self._unknown_fields.is_empty() {
16587                debug_struct.field("_unknown_fields", &self._unknown_fields);
16588            }
16589            debug_struct.finish()
16590        }
16591    }
16592
16593    /// The encoded representation of a polyline. More information on polyline
16594    /// encoding can be found here:
16595    /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
16596    /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
16597    #[derive(Clone, Default, PartialEq)]
16598    #[non_exhaustive]
16599    pub struct EncodedPolyline {
16600        /// String representing encoded points of the polyline.
16601        pub points: std::string::String,
16602
16603        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16604    }
16605
16606    impl EncodedPolyline {
16607        pub fn new() -> Self {
16608            std::default::Default::default()
16609        }
16610
16611        /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
16612        pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16613            self.points = v.into();
16614            self
16615        }
16616    }
16617
16618    impl wkt::message::Message for EncodedPolyline {
16619        fn typename() -> &'static str {
16620            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
16621        }
16622    }
16623
16624    #[doc(hidden)]
16625    impl<'de> serde::de::Deserialize<'de> for EncodedPolyline {
16626        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16627        where
16628            D: serde::Deserializer<'de>,
16629        {
16630            #[allow(non_camel_case_types)]
16631            #[doc(hidden)]
16632            #[derive(PartialEq, Eq, Hash)]
16633            enum __FieldTag {
16634                __points,
16635                Unknown(std::string::String),
16636            }
16637            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16638                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16639                where
16640                    D: serde::Deserializer<'de>,
16641                {
16642                    struct Visitor;
16643                    impl<'de> serde::de::Visitor<'de> for Visitor {
16644                        type Value = __FieldTag;
16645                        fn expecting(
16646                            &self,
16647                            formatter: &mut std::fmt::Formatter,
16648                        ) -> std::fmt::Result {
16649                            formatter.write_str("a field name for EncodedPolyline")
16650                        }
16651                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16652                        where
16653                            E: serde::de::Error,
16654                        {
16655                            use std::result::Result::Ok;
16656                            use std::string::ToString;
16657                            match value {
16658                                "points" => Ok(__FieldTag::__points),
16659                                _ => Ok(__FieldTag::Unknown(value.to_string())),
16660                            }
16661                        }
16662                    }
16663                    deserializer.deserialize_identifier(Visitor)
16664                }
16665            }
16666            struct Visitor;
16667            impl<'de> serde::de::Visitor<'de> for Visitor {
16668                type Value = EncodedPolyline;
16669                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16670                    formatter.write_str("struct EncodedPolyline")
16671                }
16672                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16673                where
16674                    A: serde::de::MapAccess<'de>,
16675                {
16676                    #[allow(unused_imports)]
16677                    use serde::de::Error;
16678                    use std::option::Option::Some;
16679                    let mut fields = std::collections::HashSet::new();
16680                    let mut result = Self::Value::new();
16681                    while let Some(tag) = map.next_key::<__FieldTag>()? {
16682                        #[allow(clippy::match_single_binding)]
16683                        match tag {
16684                            __FieldTag::__points => {
16685                                if !fields.insert(__FieldTag::__points) {
16686                                    return std::result::Result::Err(A::Error::duplicate_field(
16687                                        "multiple values for points",
16688                                    ));
16689                                }
16690                                result.points = map
16691                                    .next_value::<std::option::Option<std::string::String>>()?
16692                                    .unwrap_or_default();
16693                            }
16694                            __FieldTag::Unknown(key) => {
16695                                let value = map.next_value::<serde_json::Value>()?;
16696                                result._unknown_fields.insert(key, value);
16697                            }
16698                        }
16699                    }
16700                    std::result::Result::Ok(result)
16701                }
16702            }
16703            deserializer.deserialize_any(Visitor)
16704        }
16705    }
16706
16707    #[doc(hidden)]
16708    impl serde::ser::Serialize for EncodedPolyline {
16709        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16710        where
16711            S: serde::ser::Serializer,
16712        {
16713            use serde::ser::SerializeMap;
16714            #[allow(unused_imports)]
16715            use std::option::Option::Some;
16716            let mut state = serializer.serialize_map(std::option::Option::None)?;
16717            if !self.points.is_empty() {
16718                state.serialize_entry("points", &self.points)?;
16719            }
16720            if !self._unknown_fields.is_empty() {
16721                for (key, value) in self._unknown_fields.iter() {
16722                    state.serialize_entry(key, &value)?;
16723                }
16724            }
16725            state.end()
16726        }
16727    }
16728
16729    impl std::fmt::Debug for EncodedPolyline {
16730        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16731            let mut debug_struct = f.debug_struct("EncodedPolyline");
16732            debug_struct.field("points", &self.points);
16733            if !self._unknown_fields.is_empty() {
16734                debug_struct.field("_unknown_fields", &self._unknown_fields);
16735            }
16736            debug_struct.finish()
16737        }
16738    }
16739
16740    /// Data representing the execution of a break.
16741    #[derive(Clone, Default, PartialEq)]
16742    #[non_exhaustive]
16743    pub struct Break {
16744        /// Start time of a break.
16745        pub start_time: std::option::Option<wkt::Timestamp>,
16746
16747        /// Duration of a break.
16748        pub duration: std::option::Option<wkt::Duration>,
16749
16750        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16751    }
16752
16753    impl Break {
16754        pub fn new() -> Self {
16755            std::default::Default::default()
16756        }
16757
16758        /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
16759        pub fn set_start_time<T>(mut self, v: T) -> Self
16760        where
16761            T: std::convert::Into<wkt::Timestamp>,
16762        {
16763            self.start_time = std::option::Option::Some(v.into());
16764            self
16765        }
16766
16767        /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
16768        pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
16769        where
16770            T: std::convert::Into<wkt::Timestamp>,
16771        {
16772            self.start_time = v.map(|x| x.into());
16773            self
16774        }
16775
16776        /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
16777        pub fn set_duration<T>(mut self, v: T) -> Self
16778        where
16779            T: std::convert::Into<wkt::Duration>,
16780        {
16781            self.duration = std::option::Option::Some(v.into());
16782            self
16783        }
16784
16785        /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
16786        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
16787        where
16788            T: std::convert::Into<wkt::Duration>,
16789        {
16790            self.duration = v.map(|x| x.into());
16791            self
16792        }
16793    }
16794
16795    impl wkt::message::Message for Break {
16796        fn typename() -> &'static str {
16797            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
16798        }
16799    }
16800
16801    #[doc(hidden)]
16802    impl<'de> serde::de::Deserialize<'de> for Break {
16803        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16804        where
16805            D: serde::Deserializer<'de>,
16806        {
16807            #[allow(non_camel_case_types)]
16808            #[doc(hidden)]
16809            #[derive(PartialEq, Eq, Hash)]
16810            enum __FieldTag {
16811                __start_time,
16812                __duration,
16813                Unknown(std::string::String),
16814            }
16815            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16816                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16817                where
16818                    D: serde::Deserializer<'de>,
16819                {
16820                    struct Visitor;
16821                    impl<'de> serde::de::Visitor<'de> for Visitor {
16822                        type Value = __FieldTag;
16823                        fn expecting(
16824                            &self,
16825                            formatter: &mut std::fmt::Formatter,
16826                        ) -> std::fmt::Result {
16827                            formatter.write_str("a field name for Break")
16828                        }
16829                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16830                        where
16831                            E: serde::de::Error,
16832                        {
16833                            use std::result::Result::Ok;
16834                            use std::string::ToString;
16835                            match value {
16836                                "startTime" => Ok(__FieldTag::__start_time),
16837                                "start_time" => Ok(__FieldTag::__start_time),
16838                                "duration" => Ok(__FieldTag::__duration),
16839                                _ => Ok(__FieldTag::Unknown(value.to_string())),
16840                            }
16841                        }
16842                    }
16843                    deserializer.deserialize_identifier(Visitor)
16844                }
16845            }
16846            struct Visitor;
16847            impl<'de> serde::de::Visitor<'de> for Visitor {
16848                type Value = Break;
16849                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16850                    formatter.write_str("struct Break")
16851                }
16852                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16853                where
16854                    A: serde::de::MapAccess<'de>,
16855                {
16856                    #[allow(unused_imports)]
16857                    use serde::de::Error;
16858                    use std::option::Option::Some;
16859                    let mut fields = std::collections::HashSet::new();
16860                    let mut result = Self::Value::new();
16861                    while let Some(tag) = map.next_key::<__FieldTag>()? {
16862                        #[allow(clippy::match_single_binding)]
16863                        match tag {
16864                            __FieldTag::__start_time => {
16865                                if !fields.insert(__FieldTag::__start_time) {
16866                                    return std::result::Result::Err(A::Error::duplicate_field(
16867                                        "multiple values for start_time",
16868                                    ));
16869                                }
16870                                result.start_time =
16871                                    map.next_value::<std::option::Option<wkt::Timestamp>>()?;
16872                            }
16873                            __FieldTag::__duration => {
16874                                if !fields.insert(__FieldTag::__duration) {
16875                                    return std::result::Result::Err(A::Error::duplicate_field(
16876                                        "multiple values for duration",
16877                                    ));
16878                                }
16879                                result.duration =
16880                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
16881                            }
16882                            __FieldTag::Unknown(key) => {
16883                                let value = map.next_value::<serde_json::Value>()?;
16884                                result._unknown_fields.insert(key, value);
16885                            }
16886                        }
16887                    }
16888                    std::result::Result::Ok(result)
16889                }
16890            }
16891            deserializer.deserialize_any(Visitor)
16892        }
16893    }
16894
16895    #[doc(hidden)]
16896    impl serde::ser::Serialize for Break {
16897        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16898        where
16899            S: serde::ser::Serializer,
16900        {
16901            use serde::ser::SerializeMap;
16902            #[allow(unused_imports)]
16903            use std::option::Option::Some;
16904            let mut state = serializer.serialize_map(std::option::Option::None)?;
16905            if self.start_time.is_some() {
16906                state.serialize_entry("startTime", &self.start_time)?;
16907            }
16908            if self.duration.is_some() {
16909                state.serialize_entry("duration", &self.duration)?;
16910            }
16911            if !self._unknown_fields.is_empty() {
16912                for (key, value) in self._unknown_fields.iter() {
16913                    state.serialize_entry(key, &value)?;
16914                }
16915            }
16916            state.end()
16917        }
16918    }
16919
16920    impl std::fmt::Debug for Break {
16921        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16922            let mut debug_struct = f.debug_struct("Break");
16923            debug_struct.field("start_time", &self.start_time);
16924            debug_struct.field("duration", &self.duration);
16925            if !self._unknown_fields.is_empty() {
16926                debug_struct.field("_unknown_fields", &self._unknown_fields);
16927            }
16928            debug_struct.finish()
16929        }
16930    }
16931
16932    /// Deprecated: Use
16933    /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
16934    /// instead. Travel between each visit along the route: from the vehicle's
16935    /// `start_location` to the first visit's `arrival_location`, then from the
16936    /// first visit's `departure_location` to the second visit's
16937    /// `arrival_location`, and so on until the vehicle's `end_location`. This
16938    /// accounts only for the actual travel between visits, not counting the
16939    /// waiting time, the time spent performing a visit, nor the distance covered
16940    /// during a visit.
16941    ///
16942    /// Invariant: `travel_steps_size() == visits_size() + 1`.
16943    ///
16944    /// If the vehicle does not have a start_ and/or end_location, the
16945    /// corresponding travel metrics are 0 and/or empty.
16946    ///
16947    /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
16948    #[derive(Clone, Default, PartialEq)]
16949    #[non_exhaustive]
16950    #[deprecated]
16951    pub struct TravelStep {
16952        /// Duration of the travel step.
16953        pub duration: std::option::Option<wkt::Duration>,
16954
16955        /// Distance traveled during the step.
16956        pub distance_meters: f64,
16957
16958        /// When traffic is requested via
16959        /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
16960        /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
16961        /// is set to true. This may be temporary (rare hiccup in the realtime
16962        /// traffic servers) or permanent (no data for this location).
16963        ///
16964        /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
16965        pub traffic_info_unavailable: bool,
16966
16967        /// The encoded polyline representation of the route followed during the
16968        /// step.
16969        ///
16970        /// This field is only populated if
16971        /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
16972        /// is set to true.
16973        ///
16974        /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
16975        pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
16976
16977        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16978    }
16979
16980    impl TravelStep {
16981        pub fn new() -> Self {
16982            std::default::Default::default()
16983        }
16984
16985        /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
16986        pub fn set_duration<T>(mut self, v: T) -> Self
16987        where
16988            T: std::convert::Into<wkt::Duration>,
16989        {
16990            self.duration = std::option::Option::Some(v.into());
16991            self
16992        }
16993
16994        /// Sets or clears the value of [duration][crate::model::shipment_route::TravelStep::duration].
16995        pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
16996        where
16997            T: std::convert::Into<wkt::Duration>,
16998        {
16999            self.duration = v.map(|x| x.into());
17000            self
17001        }
17002
17003        /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
17004        pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
17005            self.distance_meters = v.into();
17006            self
17007        }
17008
17009        /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
17010        pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
17011            self.traffic_info_unavailable = v.into();
17012            self
17013        }
17014
17015        /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
17016        pub fn set_route_polyline<T>(mut self, v: T) -> Self
17017        where
17018            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
17019        {
17020            self.route_polyline = std::option::Option::Some(v.into());
17021            self
17022        }
17023
17024        /// Sets or clears the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
17025        pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
17026        where
17027            T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
17028        {
17029            self.route_polyline = v.map(|x| x.into());
17030            self
17031        }
17032    }
17033
17034    impl wkt::message::Message for TravelStep {
17035        fn typename() -> &'static str {
17036            "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
17037        }
17038    }
17039
17040    #[doc(hidden)]
17041    impl<'de> serde::de::Deserialize<'de> for TravelStep {
17042        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17043        where
17044            D: serde::Deserializer<'de>,
17045        {
17046            #[allow(non_camel_case_types)]
17047            #[doc(hidden)]
17048            #[derive(PartialEq, Eq, Hash)]
17049            enum __FieldTag {
17050                __duration,
17051                __distance_meters,
17052                __traffic_info_unavailable,
17053                __route_polyline,
17054                Unknown(std::string::String),
17055            }
17056            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17057                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17058                where
17059                    D: serde::Deserializer<'de>,
17060                {
17061                    struct Visitor;
17062                    impl<'de> serde::de::Visitor<'de> for Visitor {
17063                        type Value = __FieldTag;
17064                        fn expecting(
17065                            &self,
17066                            formatter: &mut std::fmt::Formatter,
17067                        ) -> std::fmt::Result {
17068                            formatter.write_str("a field name for TravelStep")
17069                        }
17070                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17071                        where
17072                            E: serde::de::Error,
17073                        {
17074                            use std::result::Result::Ok;
17075                            use std::string::ToString;
17076                            match value {
17077                                "duration" => Ok(__FieldTag::__duration),
17078                                "distanceMeters" => Ok(__FieldTag::__distance_meters),
17079                                "distance_meters" => Ok(__FieldTag::__distance_meters),
17080                                "trafficInfoUnavailable" => {
17081                                    Ok(__FieldTag::__traffic_info_unavailable)
17082                                }
17083                                "traffic_info_unavailable" => {
17084                                    Ok(__FieldTag::__traffic_info_unavailable)
17085                                }
17086                                "routePolyline" => Ok(__FieldTag::__route_polyline),
17087                                "route_polyline" => Ok(__FieldTag::__route_polyline),
17088                                _ => Ok(__FieldTag::Unknown(value.to_string())),
17089                            }
17090                        }
17091                    }
17092                    deserializer.deserialize_identifier(Visitor)
17093                }
17094            }
17095            struct Visitor;
17096            impl<'de> serde::de::Visitor<'de> for Visitor {
17097                type Value = TravelStep;
17098                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17099                    formatter.write_str("struct TravelStep")
17100                }
17101                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17102                where
17103                    A: serde::de::MapAccess<'de>,
17104                {
17105                    #[allow(unused_imports)]
17106                    use serde::de::Error;
17107                    use std::option::Option::Some;
17108                    let mut fields = std::collections::HashSet::new();
17109                    let mut result = Self::Value::new();
17110                    while let Some(tag) = map.next_key::<__FieldTag>()? {
17111                        #[allow(clippy::match_single_binding)]
17112                        match tag {
17113                            __FieldTag::__duration => {
17114                                if !fields.insert(__FieldTag::__duration) {
17115                                    return std::result::Result::Err(A::Error::duplicate_field(
17116                                        "multiple values for duration",
17117                                    ));
17118                                }
17119                                result.duration =
17120                                    map.next_value::<std::option::Option<wkt::Duration>>()?;
17121                            }
17122                            __FieldTag::__distance_meters => {
17123                                if !fields.insert(__FieldTag::__distance_meters) {
17124                                    return std::result::Result::Err(A::Error::duplicate_field(
17125                                        "multiple values for distance_meters",
17126                                    ));
17127                                }
17128                                struct __With(std::option::Option<f64>);
17129                                impl<'de> serde::de::Deserialize<'de> for __With {
17130                                    fn deserialize<D>(
17131                                        deserializer: D,
17132                                    ) -> std::result::Result<Self, D::Error>
17133                                    where
17134                                        D: serde::de::Deserializer<'de>,
17135                                    {
17136                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
17137                                    }
17138                                }
17139                                result.distance_meters =
17140                                    map.next_value::<__With>()?.0.unwrap_or_default();
17141                            }
17142                            __FieldTag::__traffic_info_unavailable => {
17143                                if !fields.insert(__FieldTag::__traffic_info_unavailable) {
17144                                    return std::result::Result::Err(A::Error::duplicate_field(
17145                                        "multiple values for traffic_info_unavailable",
17146                                    ));
17147                                }
17148                                result.traffic_info_unavailable = map
17149                                    .next_value::<std::option::Option<bool>>()?
17150                                    .unwrap_or_default();
17151                            }
17152                            __FieldTag::__route_polyline => {
17153                                if !fields.insert(__FieldTag::__route_polyline) {
17154                                    return std::result::Result::Err(A::Error::duplicate_field(
17155                                        "multiple values for route_polyline",
17156                                    ));
17157                                }
17158                                result.route_polyline = map.next_value::<std::option::Option<
17159                                    crate::model::shipment_route::EncodedPolyline,
17160                                >>()?;
17161                            }
17162                            __FieldTag::Unknown(key) => {
17163                                let value = map.next_value::<serde_json::Value>()?;
17164                                result._unknown_fields.insert(key, value);
17165                            }
17166                        }
17167                    }
17168                    std::result::Result::Ok(result)
17169                }
17170            }
17171            deserializer.deserialize_any(Visitor)
17172        }
17173    }
17174
17175    #[doc(hidden)]
17176    impl serde::ser::Serialize for TravelStep {
17177        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17178        where
17179            S: serde::ser::Serializer,
17180        {
17181            use serde::ser::SerializeMap;
17182            #[allow(unused_imports)]
17183            use std::option::Option::Some;
17184            let mut state = serializer.serialize_map(std::option::Option::None)?;
17185            if self.duration.is_some() {
17186                state.serialize_entry("duration", &self.duration)?;
17187            }
17188            if !wkt::internal::is_default(&self.distance_meters) {
17189                struct __With<'a>(&'a f64);
17190                impl<'a> serde::ser::Serialize for __With<'a> {
17191                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17192                    where
17193                        S: serde::ser::Serializer,
17194                    {
17195                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
17196                    }
17197                }
17198                state.serialize_entry("distanceMeters", &__With(&self.distance_meters))?;
17199            }
17200            if !wkt::internal::is_default(&self.traffic_info_unavailable) {
17201                state.serialize_entry("trafficInfoUnavailable", &self.traffic_info_unavailable)?;
17202            }
17203            if self.route_polyline.is_some() {
17204                state.serialize_entry("routePolyline", &self.route_polyline)?;
17205            }
17206            if !self._unknown_fields.is_empty() {
17207                for (key, value) in self._unknown_fields.iter() {
17208                    state.serialize_entry(key, &value)?;
17209                }
17210            }
17211            state.end()
17212        }
17213    }
17214
17215    impl std::fmt::Debug for TravelStep {
17216        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17217            let mut debug_struct = f.debug_struct("TravelStep");
17218            debug_struct.field("duration", &self.duration);
17219            debug_struct.field("distance_meters", &self.distance_meters);
17220            debug_struct.field("traffic_info_unavailable", &self.traffic_info_unavailable);
17221            debug_struct.field("route_polyline", &self.route_polyline);
17222            if !self._unknown_fields.is_empty() {
17223                debug_struct.field("_unknown_fields", &self._unknown_fields);
17224            }
17225            debug_struct.finish()
17226        }
17227    }
17228}
17229
17230/// Specifies details of unperformed shipments in a solution. For trivial cases
17231/// and/or if we are able to identify the cause for skipping, we report the
17232/// reason here.
17233#[derive(Clone, Default, PartialEq)]
17234#[non_exhaustive]
17235pub struct SkippedShipment {
17236    /// The index corresponds to the index of the shipment in the source
17237    /// `ShipmentModel`.
17238    pub index: i32,
17239
17240    /// Copy of the corresponding
17241    /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
17242    /// in the `Shipment`.
17243    ///
17244    /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
17245    pub label: std::string::String,
17246
17247    /// A list of reasons that explain why the shipment was skipped. See comment
17248    /// above `Reason`.
17249    pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
17250
17251    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17252}
17253
17254impl SkippedShipment {
17255    pub fn new() -> Self {
17256        std::default::Default::default()
17257    }
17258
17259    /// Sets the value of [index][crate::model::SkippedShipment::index].
17260    pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
17261        self.index = v.into();
17262        self
17263    }
17264
17265    /// Sets the value of [label][crate::model::SkippedShipment::label].
17266    pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
17267        self.label = v.into();
17268        self
17269    }
17270
17271    /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
17272    pub fn set_reasons<T, V>(mut self, v: T) -> Self
17273    where
17274        T: std::iter::IntoIterator<Item = V>,
17275        V: std::convert::Into<crate::model::skipped_shipment::Reason>,
17276    {
17277        use std::iter::Iterator;
17278        self.reasons = v.into_iter().map(|i| i.into()).collect();
17279        self
17280    }
17281}
17282
17283impl wkt::message::Message for SkippedShipment {
17284    fn typename() -> &'static str {
17285        "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
17286    }
17287}
17288
17289#[doc(hidden)]
17290impl<'de> serde::de::Deserialize<'de> for SkippedShipment {
17291    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17292    where
17293        D: serde::Deserializer<'de>,
17294    {
17295        #[allow(non_camel_case_types)]
17296        #[doc(hidden)]
17297        #[derive(PartialEq, Eq, Hash)]
17298        enum __FieldTag {
17299            __index,
17300            __label,
17301            __reasons,
17302            Unknown(std::string::String),
17303        }
17304        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17305            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17306            where
17307                D: serde::Deserializer<'de>,
17308            {
17309                struct Visitor;
17310                impl<'de> serde::de::Visitor<'de> for Visitor {
17311                    type Value = __FieldTag;
17312                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17313                        formatter.write_str("a field name for SkippedShipment")
17314                    }
17315                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17316                    where
17317                        E: serde::de::Error,
17318                    {
17319                        use std::result::Result::Ok;
17320                        use std::string::ToString;
17321                        match value {
17322                            "index" => Ok(__FieldTag::__index),
17323                            "label" => Ok(__FieldTag::__label),
17324                            "reasons" => Ok(__FieldTag::__reasons),
17325                            _ => Ok(__FieldTag::Unknown(value.to_string())),
17326                        }
17327                    }
17328                }
17329                deserializer.deserialize_identifier(Visitor)
17330            }
17331        }
17332        struct Visitor;
17333        impl<'de> serde::de::Visitor<'de> for Visitor {
17334            type Value = SkippedShipment;
17335            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17336                formatter.write_str("struct SkippedShipment")
17337            }
17338            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17339            where
17340                A: serde::de::MapAccess<'de>,
17341            {
17342                #[allow(unused_imports)]
17343                use serde::de::Error;
17344                use std::option::Option::Some;
17345                let mut fields = std::collections::HashSet::new();
17346                let mut result = Self::Value::new();
17347                while let Some(tag) = map.next_key::<__FieldTag>()? {
17348                    #[allow(clippy::match_single_binding)]
17349                    match tag {
17350                        __FieldTag::__index => {
17351                            if !fields.insert(__FieldTag::__index) {
17352                                return std::result::Result::Err(A::Error::duplicate_field(
17353                                    "multiple values for index",
17354                                ));
17355                            }
17356                            struct __With(std::option::Option<i32>);
17357                            impl<'de> serde::de::Deserialize<'de> for __With {
17358                                fn deserialize<D>(
17359                                    deserializer: D,
17360                                ) -> std::result::Result<Self, D::Error>
17361                                where
17362                                    D: serde::de::Deserializer<'de>,
17363                                {
17364                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
17365                                }
17366                            }
17367                            result.index = map.next_value::<__With>()?.0.unwrap_or_default();
17368                        }
17369                        __FieldTag::__label => {
17370                            if !fields.insert(__FieldTag::__label) {
17371                                return std::result::Result::Err(A::Error::duplicate_field(
17372                                    "multiple values for label",
17373                                ));
17374                            }
17375                            result.label = map
17376                                .next_value::<std::option::Option<std::string::String>>()?
17377                                .unwrap_or_default();
17378                        }
17379                        __FieldTag::__reasons => {
17380                            if !fields.insert(__FieldTag::__reasons) {
17381                                return std::result::Result::Err(A::Error::duplicate_field(
17382                                    "multiple values for reasons",
17383                                ));
17384                            }
17385                            result.reasons = map
17386                                .next_value::<std::option::Option<
17387                                    std::vec::Vec<crate::model::skipped_shipment::Reason>,
17388                                >>()?
17389                                .unwrap_or_default();
17390                        }
17391                        __FieldTag::Unknown(key) => {
17392                            let value = map.next_value::<serde_json::Value>()?;
17393                            result._unknown_fields.insert(key, value);
17394                        }
17395                    }
17396                }
17397                std::result::Result::Ok(result)
17398            }
17399        }
17400        deserializer.deserialize_any(Visitor)
17401    }
17402}
17403
17404#[doc(hidden)]
17405impl serde::ser::Serialize for SkippedShipment {
17406    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17407    where
17408        S: serde::ser::Serializer,
17409    {
17410        use serde::ser::SerializeMap;
17411        #[allow(unused_imports)]
17412        use std::option::Option::Some;
17413        let mut state = serializer.serialize_map(std::option::Option::None)?;
17414        if !wkt::internal::is_default(&self.index) {
17415            struct __With<'a>(&'a i32);
17416            impl<'a> serde::ser::Serialize for __With<'a> {
17417                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17418                where
17419                    S: serde::ser::Serializer,
17420                {
17421                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
17422                }
17423            }
17424            state.serialize_entry("index", &__With(&self.index))?;
17425        }
17426        if !self.label.is_empty() {
17427            state.serialize_entry("label", &self.label)?;
17428        }
17429        if !self.reasons.is_empty() {
17430            state.serialize_entry("reasons", &self.reasons)?;
17431        }
17432        if !self._unknown_fields.is_empty() {
17433            for (key, value) in self._unknown_fields.iter() {
17434                state.serialize_entry(key, &value)?;
17435            }
17436        }
17437        state.end()
17438    }
17439}
17440
17441impl std::fmt::Debug for SkippedShipment {
17442    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17443        let mut debug_struct = f.debug_struct("SkippedShipment");
17444        debug_struct.field("index", &self.index);
17445        debug_struct.field("label", &self.label);
17446        debug_struct.field("reasons", &self.reasons);
17447        if !self._unknown_fields.is_empty() {
17448            debug_struct.field("_unknown_fields", &self._unknown_fields);
17449        }
17450        debug_struct.finish()
17451    }
17452}
17453
17454/// Defines additional types related to [SkippedShipment].
17455pub mod skipped_shipment {
17456    #[allow(unused_imports)]
17457    use super::*;
17458
17459    /// If we can explain why the shipment was skipped, reasons will be listed
17460    /// here. If the reason is not the same for all vehicles, `reason` will have
17461    /// more than 1 element. A skipped shipment cannot have duplicate reasons,
17462    /// i.e. where all fields are the same except for `example_vehicle_index`.
17463    /// Example:
17464    ///
17465    /// ```norust
17466    /// reasons {
17467    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
17468    ///   example_vehicle_index: 1
17469    ///   example_exceeded_capacity_type: "Apples"
17470    /// }
17471    /// reasons {
17472    ///   code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
17473    ///   example_vehicle_index: 3
17474    ///   example_exceeded_capacity_type: "Pears"
17475    /// }
17476    /// reasons {
17477    ///   code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
17478    ///   example_vehicle_index: 1
17479    /// }
17480    /// ```
17481    ///
17482    /// The skipped shipment is incompatible with all vehicles. The reasons may
17483    /// be different for all vehicles but at least one vehicle's "Apples"
17484    /// capacity would be exceeded (including vehicle 1), at least one vehicle's
17485    /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
17486    /// vehicle's distance limit would be exceeded (including vehicle 1).
17487    #[derive(Clone, Default, PartialEq)]
17488    #[non_exhaustive]
17489    pub struct Reason {
17490        /// Refer to the comments of Code.
17491        pub code: crate::model::skipped_shipment::reason::Code,
17492
17493        /// If the reason is related to a shipment-vehicle incompatibility, this
17494        /// field provides the index of one relevant vehicle.
17495        pub example_vehicle_index: std::option::Option<i32>,
17496
17497        /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
17498        /// capacity type that is exceeded.
17499        pub example_exceeded_capacity_type: std::string::String,
17500
17501        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17502    }
17503
17504    impl Reason {
17505        pub fn new() -> Self {
17506            std::default::Default::default()
17507        }
17508
17509        /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
17510        pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
17511            mut self,
17512            v: T,
17513        ) -> Self {
17514            self.code = v.into();
17515            self
17516        }
17517
17518        /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
17519        pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
17520        where
17521            T: std::convert::Into<i32>,
17522        {
17523            self.example_vehicle_index = std::option::Option::Some(v.into());
17524            self
17525        }
17526
17527        /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
17528        pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
17529        where
17530            T: std::convert::Into<i32>,
17531        {
17532            self.example_vehicle_index = v.map(|x| x.into());
17533            self
17534        }
17535
17536        /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
17537        pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
17538            mut self,
17539            v: T,
17540        ) -> Self {
17541            self.example_exceeded_capacity_type = v.into();
17542            self
17543        }
17544    }
17545
17546    impl wkt::message::Message for Reason {
17547        fn typename() -> &'static str {
17548            "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
17549        }
17550    }
17551
17552    #[doc(hidden)]
17553    impl<'de> serde::de::Deserialize<'de> for Reason {
17554        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17555        where
17556            D: serde::Deserializer<'de>,
17557        {
17558            #[allow(non_camel_case_types)]
17559            #[doc(hidden)]
17560            #[derive(PartialEq, Eq, Hash)]
17561            enum __FieldTag {
17562                __code,
17563                __example_vehicle_index,
17564                __example_exceeded_capacity_type,
17565                Unknown(std::string::String),
17566            }
17567            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17568                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17569                where
17570                    D: serde::Deserializer<'de>,
17571                {
17572                    struct Visitor;
17573                    impl<'de> serde::de::Visitor<'de> for Visitor {
17574                        type Value = __FieldTag;
17575                        fn expecting(
17576                            &self,
17577                            formatter: &mut std::fmt::Formatter,
17578                        ) -> std::fmt::Result {
17579                            formatter.write_str("a field name for Reason")
17580                        }
17581                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17582                        where
17583                            E: serde::de::Error,
17584                        {
17585                            use std::result::Result::Ok;
17586                            use std::string::ToString;
17587                            match value {
17588                                "code" => Ok(__FieldTag::__code),
17589                                "exampleVehicleIndex" => Ok(__FieldTag::__example_vehicle_index),
17590                                "example_vehicle_index" => Ok(__FieldTag::__example_vehicle_index),
17591                                "exampleExceededCapacityType" => {
17592                                    Ok(__FieldTag::__example_exceeded_capacity_type)
17593                                }
17594                                "example_exceeded_capacity_type" => {
17595                                    Ok(__FieldTag::__example_exceeded_capacity_type)
17596                                }
17597                                _ => Ok(__FieldTag::Unknown(value.to_string())),
17598                            }
17599                        }
17600                    }
17601                    deserializer.deserialize_identifier(Visitor)
17602                }
17603            }
17604            struct Visitor;
17605            impl<'de> serde::de::Visitor<'de> for Visitor {
17606                type Value = Reason;
17607                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17608                    formatter.write_str("struct Reason")
17609                }
17610                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17611                where
17612                    A: serde::de::MapAccess<'de>,
17613                {
17614                    #[allow(unused_imports)]
17615                    use serde::de::Error;
17616                    use std::option::Option::Some;
17617                    let mut fields = std::collections::HashSet::new();
17618                    let mut result = Self::Value::new();
17619                    while let Some(tag) = map.next_key::<__FieldTag>()? {
17620                        #[allow(clippy::match_single_binding)]
17621                        match tag {
17622                            __FieldTag::__code => {
17623                                if !fields.insert(__FieldTag::__code) {
17624                                    return std::result::Result::Err(A::Error::duplicate_field(
17625                                        "multiple values for code",
17626                                    ));
17627                                }
17628                                result.code = map
17629                                    .next_value::<std::option::Option<
17630                                        crate::model::skipped_shipment::reason::Code,
17631                                    >>()?
17632                                    .unwrap_or_default();
17633                            }
17634                            __FieldTag::__example_vehicle_index => {
17635                                if !fields.insert(__FieldTag::__example_vehicle_index) {
17636                                    return std::result::Result::Err(A::Error::duplicate_field(
17637                                        "multiple values for example_vehicle_index",
17638                                    ));
17639                                }
17640                                struct __With(std::option::Option<i32>);
17641                                impl<'de> serde::de::Deserialize<'de> for __With {
17642                                    fn deserialize<D>(
17643                                        deserializer: D,
17644                                    ) -> std::result::Result<Self, D::Error>
17645                                    where
17646                                        D: serde::de::Deserializer<'de>,
17647                                    {
17648                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
17649                                    }
17650                                }
17651                                result.example_vehicle_index = map.next_value::<__With>()?.0;
17652                            }
17653                            __FieldTag::__example_exceeded_capacity_type => {
17654                                if !fields.insert(__FieldTag::__example_exceeded_capacity_type) {
17655                                    return std::result::Result::Err(A::Error::duplicate_field(
17656                                        "multiple values for example_exceeded_capacity_type",
17657                                    ));
17658                                }
17659                                result.example_exceeded_capacity_type = map
17660                                    .next_value::<std::option::Option<std::string::String>>()?
17661                                    .unwrap_or_default();
17662                            }
17663                            __FieldTag::Unknown(key) => {
17664                                let value = map.next_value::<serde_json::Value>()?;
17665                                result._unknown_fields.insert(key, value);
17666                            }
17667                        }
17668                    }
17669                    std::result::Result::Ok(result)
17670                }
17671            }
17672            deserializer.deserialize_any(Visitor)
17673        }
17674    }
17675
17676    #[doc(hidden)]
17677    impl serde::ser::Serialize for Reason {
17678        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17679        where
17680            S: serde::ser::Serializer,
17681        {
17682            use serde::ser::SerializeMap;
17683            #[allow(unused_imports)]
17684            use std::option::Option::Some;
17685            let mut state = serializer.serialize_map(std::option::Option::None)?;
17686            if !wkt::internal::is_default(&self.code) {
17687                state.serialize_entry("code", &self.code)?;
17688            }
17689            if self.example_vehicle_index.is_some() {
17690                struct __With<'a>(&'a std::option::Option<i32>);
17691                impl<'a> serde::ser::Serialize for __With<'a> {
17692                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17693                    where
17694                        S: serde::ser::Serializer,
17695                    {
17696                        serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
17697                            self.0, serializer,
17698                        )
17699                    }
17700                }
17701                state
17702                    .serialize_entry("exampleVehicleIndex", &__With(&self.example_vehicle_index))?;
17703            }
17704            if !self.example_exceeded_capacity_type.is_empty() {
17705                state.serialize_entry(
17706                    "exampleExceededCapacityType",
17707                    &self.example_exceeded_capacity_type,
17708                )?;
17709            }
17710            if !self._unknown_fields.is_empty() {
17711                for (key, value) in self._unknown_fields.iter() {
17712                    state.serialize_entry(key, &value)?;
17713                }
17714            }
17715            state.end()
17716        }
17717    }
17718
17719    impl std::fmt::Debug for Reason {
17720        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17721            let mut debug_struct = f.debug_struct("Reason");
17722            debug_struct.field("code", &self.code);
17723            debug_struct.field("example_vehicle_index", &self.example_vehicle_index);
17724            debug_struct.field(
17725                "example_exceeded_capacity_type",
17726                &self.example_exceeded_capacity_type,
17727            );
17728            if !self._unknown_fields.is_empty() {
17729                debug_struct.field("_unknown_fields", &self._unknown_fields);
17730            }
17731            debug_struct.finish()
17732        }
17733    }
17734
17735    /// Defines additional types related to [Reason].
17736    pub mod reason {
17737        #[allow(unused_imports)]
17738        use super::*;
17739
17740        /// Code identifying the reason type. The order here is meaningless. In
17741        /// particular, it gives no indication of whether a given reason will
17742        /// appear before another in the solution, if both apply.
17743        ///
17744        /// # Working with unknown values
17745        ///
17746        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
17747        /// additional enum variants at any time. Adding new variants is not considered
17748        /// a breaking change. Applications should write their code in anticipation of:
17749        ///
17750        /// - New values appearing in future releases of the client library, **and**
17751        /// - New values received dynamically, without application changes.
17752        ///
17753        /// Please consult the [Working with enums] section in the user guide for some
17754        /// guidelines.
17755        ///
17756        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
17757        #[derive(Clone, Debug, PartialEq)]
17758        #[non_exhaustive]
17759        pub enum Code {
17760            /// This should never be used. If we are unable to understand why a
17761            /// shipment was skipped, we simply return an empty set of reasons.
17762            Unspecified,
17763            /// There is no vehicle in the model making all shipments infeasible.
17764            NoVehicle,
17765            /// The demand of the shipment exceeds a vehicle's capacity for some
17766            /// capacity types, one of which is `example_exceeded_capacity_type`.
17767            DemandExceedsVehicleCapacity,
17768            /// The minimum distance necessary to perform this shipment, i.e. from
17769            /// the vehicle's `start_location` to the shipment's pickup and/or delivery
17770            /// locations and to the vehicle's end location exceeds the vehicle's
17771            /// `route_distance_limit`.
17772            ///
17773            /// Note that for this computation we use the geodesic distances.
17774            CannotBePerformedWithinVehicleDistanceLimit,
17775            /// The minimum time necessary to perform this shipment, including travel
17776            /// time, wait time and service time exceeds the vehicle's
17777            /// `route_duration_limit`.
17778            ///
17779            /// Note: travel time is computed in the best-case scenario, namely as
17780            /// geodesic distance x 36 m/s (roughly 130 km/hour).
17781            CannotBePerformedWithinVehicleDurationLimit,
17782            /// Same as above but we only compare minimum travel time and the
17783            /// vehicle's `travel_duration_limit`.
17784            CannotBePerformedWithinVehicleTravelDurationLimit,
17785            /// The vehicle cannot perform this shipment in the best-case scenario
17786            /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
17787            /// computation) if it starts at its earliest start time: the total time
17788            /// would make the vehicle end after its latest end time.
17789            CannotBePerformedWithinVehicleTimeWindows,
17790            /// The `allowed_vehicle_indices` field of the shipment is not empty and
17791            /// this vehicle does not belong to it.
17792            VehicleNotAllowed,
17793            /// If set, the enum was initialized with an unknown value.
17794            ///
17795            /// Applications can examine the value using [Code::value] or
17796            /// [Code::name].
17797            UnknownValue(code::UnknownValue),
17798        }
17799
17800        #[doc(hidden)]
17801        pub mod code {
17802            #[allow(unused_imports)]
17803            use super::*;
17804            #[derive(Clone, Debug, PartialEq)]
17805            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
17806        }
17807
17808        impl Code {
17809            /// Gets the enum value.
17810            ///
17811            /// Returns `None` if the enum contains an unknown value deserialized from
17812            /// the string representation of enums.
17813            pub fn value(&self) -> std::option::Option<i32> {
17814                match self {
17815                    Self::Unspecified => std::option::Option::Some(0),
17816                    Self::NoVehicle => std::option::Option::Some(1),
17817                    Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
17818                    Self::CannotBePerformedWithinVehicleDistanceLimit => {
17819                        std::option::Option::Some(3)
17820                    }
17821                    Self::CannotBePerformedWithinVehicleDurationLimit => {
17822                        std::option::Option::Some(4)
17823                    }
17824                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17825                        std::option::Option::Some(5)
17826                    }
17827                    Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
17828                    Self::VehicleNotAllowed => std::option::Option::Some(7),
17829                    Self::UnknownValue(u) => u.0.value(),
17830                }
17831            }
17832
17833            /// Gets the enum value as a string.
17834            ///
17835            /// Returns `None` if the enum contains an unknown value deserialized from
17836            /// the integer representation of enums.
17837            pub fn name(&self) -> std::option::Option<&str> {
17838                match self {
17839                    Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
17840                    Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
17841                    Self::DemandExceedsVehicleCapacity => {
17842                        std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
17843                    }
17844                    Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
17845                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
17846                    ),
17847                    Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
17848                        "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
17849                    ),
17850                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17851                        std::option::Option::Some(
17852                            "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
17853                        )
17854                    }
17855                    Self::CannotBePerformedWithinVehicleTimeWindows => {
17856                        std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
17857                    }
17858                    Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
17859                    Self::UnknownValue(u) => u.0.name(),
17860                }
17861            }
17862        }
17863
17864        impl std::default::Default for Code {
17865            fn default() -> Self {
17866                use std::convert::From;
17867                Self::from(0)
17868            }
17869        }
17870
17871        impl std::fmt::Display for Code {
17872            fn fmt(
17873                &self,
17874                f: &mut std::fmt::Formatter<'_>,
17875            ) -> std::result::Result<(), std::fmt::Error> {
17876                wkt::internal::display_enum(f, self.name(), self.value())
17877            }
17878        }
17879
17880        impl std::convert::From<i32> for Code {
17881            fn from(value: i32) -> Self {
17882                match value {
17883                    0 => Self::Unspecified,
17884                    1 => Self::NoVehicle,
17885                    2 => Self::DemandExceedsVehicleCapacity,
17886                    3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
17887                    4 => Self::CannotBePerformedWithinVehicleDurationLimit,
17888                    5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
17889                    6 => Self::CannotBePerformedWithinVehicleTimeWindows,
17890                    7 => Self::VehicleNotAllowed,
17891                    _ => Self::UnknownValue(code::UnknownValue(
17892                        wkt::internal::UnknownEnumValue::Integer(value),
17893                    )),
17894                }
17895            }
17896        }
17897
17898        impl std::convert::From<&str> for Code {
17899            fn from(value: &str) -> Self {
17900                use std::string::ToString;
17901                match value {
17902                    "CODE_UNSPECIFIED" => Self::Unspecified,
17903                    "NO_VEHICLE" => Self::NoVehicle,
17904                    "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
17905                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
17906                        Self::CannotBePerformedWithinVehicleDistanceLimit
17907                    }
17908                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
17909                        Self::CannotBePerformedWithinVehicleDurationLimit
17910                    }
17911                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
17912                        Self::CannotBePerformedWithinVehicleTravelDurationLimit
17913                    }
17914                    "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
17915                        Self::CannotBePerformedWithinVehicleTimeWindows
17916                    }
17917                    "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
17918                    _ => Self::UnknownValue(code::UnknownValue(
17919                        wkt::internal::UnknownEnumValue::String(value.to_string()),
17920                    )),
17921                }
17922            }
17923        }
17924
17925        impl serde::ser::Serialize for Code {
17926            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17927            where
17928                S: serde::Serializer,
17929            {
17930                match self {
17931                    Self::Unspecified => serializer.serialize_i32(0),
17932                    Self::NoVehicle => serializer.serialize_i32(1),
17933                    Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
17934                    Self::CannotBePerformedWithinVehicleDistanceLimit => {
17935                        serializer.serialize_i32(3)
17936                    }
17937                    Self::CannotBePerformedWithinVehicleDurationLimit => {
17938                        serializer.serialize_i32(4)
17939                    }
17940                    Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17941                        serializer.serialize_i32(5)
17942                    }
17943                    Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
17944                    Self::VehicleNotAllowed => serializer.serialize_i32(7),
17945                    Self::UnknownValue(u) => u.0.serialize(serializer),
17946                }
17947            }
17948        }
17949
17950        impl<'de> serde::de::Deserialize<'de> for Code {
17951            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17952            where
17953                D: serde::Deserializer<'de>,
17954            {
17955                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
17956                    ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
17957                ))
17958            }
17959        }
17960    }
17961}
17962
17963/// Aggregated metrics for
17964/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
17965/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
17966/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
17967/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
17968/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
17969///
17970/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
17971/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
17972/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
17973/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
17974#[derive(Clone, Default, PartialEq)]
17975#[non_exhaustive]
17976pub struct AggregatedMetrics {
17977    /// Number of shipments performed. Note that a pickup and delivery pair only
17978    /// counts once.
17979    pub performed_shipment_count: i32,
17980
17981    /// Total travel duration for a route or a solution.
17982    pub travel_duration: std::option::Option<wkt::Duration>,
17983
17984    /// Total wait duration for a route or a solution.
17985    pub wait_duration: std::option::Option<wkt::Duration>,
17986
17987    /// Total delay duration for a route or a solution.
17988    pub delay_duration: std::option::Option<wkt::Duration>,
17989
17990    /// Total break duration for a route or a solution.
17991    pub break_duration: std::option::Option<wkt::Duration>,
17992
17993    /// Total visit duration for a route or a solution.
17994    pub visit_duration: std::option::Option<wkt::Duration>,
17995
17996    /// The total duration should be equal to the sum of all durations above.
17997    /// For routes, it also corresponds to:
17998    /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
17999    /// `-`
18000    /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
18001    ///
18002    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
18003    /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
18004    pub total_duration: std::option::Option<wkt::Duration>,
18005
18006    /// Total travel distance for a route or a solution.
18007    pub travel_distance_meters: f64,
18008
18009    /// Maximum load achieved over the entire route (resp. solution), for each of
18010    /// the quantities on this route (resp. solution), computed as the maximum over
18011    /// all
18012    /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
18013    /// (resp.
18014    /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
18015    ///
18016    /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
18017    /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
18018    pub max_loads:
18019        std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
18020
18021    /// Deprecated: Use
18022    /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
18023    /// and
18024    /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
18025    /// instead.
18026    ///
18027    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
18028    /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
18029    #[deprecated]
18030    pub costs: std::collections::HashMap<std::string::String, f64>,
18031
18032    /// Deprecated: Use
18033    /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
18034    /// and
18035    /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
18036    /// instead.
18037    ///
18038    /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
18039    /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
18040    #[deprecated]
18041    pub total_cost: f64,
18042
18043    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18044}
18045
18046impl AggregatedMetrics {
18047    pub fn new() -> Self {
18048        std::default::Default::default()
18049    }
18050
18051    /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
18052    pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
18053        self.performed_shipment_count = v.into();
18054        self
18055    }
18056
18057    /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
18058    pub fn set_travel_duration<T>(mut self, v: T) -> Self
18059    where
18060        T: std::convert::Into<wkt::Duration>,
18061    {
18062        self.travel_duration = std::option::Option::Some(v.into());
18063        self
18064    }
18065
18066    /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
18067    pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
18068    where
18069        T: std::convert::Into<wkt::Duration>,
18070    {
18071        self.travel_duration = v.map(|x| x.into());
18072        self
18073    }
18074
18075    /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
18076    pub fn set_wait_duration<T>(mut self, v: T) -> Self
18077    where
18078        T: std::convert::Into<wkt::Duration>,
18079    {
18080        self.wait_duration = std::option::Option::Some(v.into());
18081        self
18082    }
18083
18084    /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
18085    pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
18086    where
18087        T: std::convert::Into<wkt::Duration>,
18088    {
18089        self.wait_duration = v.map(|x| x.into());
18090        self
18091    }
18092
18093    /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
18094    pub fn set_delay_duration<T>(mut self, v: T) -> Self
18095    where
18096        T: std::convert::Into<wkt::Duration>,
18097    {
18098        self.delay_duration = std::option::Option::Some(v.into());
18099        self
18100    }
18101
18102    /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
18103    pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
18104    where
18105        T: std::convert::Into<wkt::Duration>,
18106    {
18107        self.delay_duration = v.map(|x| x.into());
18108        self
18109    }
18110
18111    /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
18112    pub fn set_break_duration<T>(mut self, v: T) -> Self
18113    where
18114        T: std::convert::Into<wkt::Duration>,
18115    {
18116        self.break_duration = std::option::Option::Some(v.into());
18117        self
18118    }
18119
18120    /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
18121    pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
18122    where
18123        T: std::convert::Into<wkt::Duration>,
18124    {
18125        self.break_duration = v.map(|x| x.into());
18126        self
18127    }
18128
18129    /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
18130    pub fn set_visit_duration<T>(mut self, v: T) -> Self
18131    where
18132        T: std::convert::Into<wkt::Duration>,
18133    {
18134        self.visit_duration = std::option::Option::Some(v.into());
18135        self
18136    }
18137
18138    /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
18139    pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
18140    where
18141        T: std::convert::Into<wkt::Duration>,
18142    {
18143        self.visit_duration = v.map(|x| x.into());
18144        self
18145    }
18146
18147    /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
18148    pub fn set_total_duration<T>(mut self, v: T) -> Self
18149    where
18150        T: std::convert::Into<wkt::Duration>,
18151    {
18152        self.total_duration = std::option::Option::Some(v.into());
18153        self
18154    }
18155
18156    /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
18157    pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
18158    where
18159        T: std::convert::Into<wkt::Duration>,
18160    {
18161        self.total_duration = v.map(|x| x.into());
18162        self
18163    }
18164
18165    /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
18166    pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
18167        self.travel_distance_meters = v.into();
18168        self
18169    }
18170
18171    /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
18172    pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
18173    where
18174        T: std::iter::IntoIterator<Item = (K, V)>,
18175        K: std::convert::Into<std::string::String>,
18176        V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
18177    {
18178        use std::iter::Iterator;
18179        self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
18180        self
18181    }
18182
18183    /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
18184    #[deprecated]
18185    pub fn set_costs<T, K, V>(mut self, v: T) -> Self
18186    where
18187        T: std::iter::IntoIterator<Item = (K, V)>,
18188        K: std::convert::Into<std::string::String>,
18189        V: std::convert::Into<f64>,
18190    {
18191        use std::iter::Iterator;
18192        self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
18193        self
18194    }
18195
18196    /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
18197    #[deprecated]
18198    pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
18199        self.total_cost = v.into();
18200        self
18201    }
18202}
18203
18204impl wkt::message::Message for AggregatedMetrics {
18205    fn typename() -> &'static str {
18206        "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
18207    }
18208}
18209
18210#[doc(hidden)]
18211impl<'de> serde::de::Deserialize<'de> for AggregatedMetrics {
18212    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18213    where
18214        D: serde::Deserializer<'de>,
18215    {
18216        #[allow(non_camel_case_types)]
18217        #[doc(hidden)]
18218        #[derive(PartialEq, Eq, Hash)]
18219        enum __FieldTag {
18220            __performed_shipment_count,
18221            __travel_duration,
18222            __wait_duration,
18223            __delay_duration,
18224            __break_duration,
18225            __visit_duration,
18226            __total_duration,
18227            __travel_distance_meters,
18228            __max_loads,
18229            __costs,
18230            __total_cost,
18231            Unknown(std::string::String),
18232        }
18233        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18234            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18235            where
18236                D: serde::Deserializer<'de>,
18237            {
18238                struct Visitor;
18239                impl<'de> serde::de::Visitor<'de> for Visitor {
18240                    type Value = __FieldTag;
18241                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18242                        formatter.write_str("a field name for AggregatedMetrics")
18243                    }
18244                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18245                    where
18246                        E: serde::de::Error,
18247                    {
18248                        use std::result::Result::Ok;
18249                        use std::string::ToString;
18250                        match value {
18251                            "performedShipmentCount" => Ok(__FieldTag::__performed_shipment_count),
18252                            "performed_shipment_count" => {
18253                                Ok(__FieldTag::__performed_shipment_count)
18254                            }
18255                            "travelDuration" => Ok(__FieldTag::__travel_duration),
18256                            "travel_duration" => Ok(__FieldTag::__travel_duration),
18257                            "waitDuration" => Ok(__FieldTag::__wait_duration),
18258                            "wait_duration" => Ok(__FieldTag::__wait_duration),
18259                            "delayDuration" => Ok(__FieldTag::__delay_duration),
18260                            "delay_duration" => Ok(__FieldTag::__delay_duration),
18261                            "breakDuration" => Ok(__FieldTag::__break_duration),
18262                            "break_duration" => Ok(__FieldTag::__break_duration),
18263                            "visitDuration" => Ok(__FieldTag::__visit_duration),
18264                            "visit_duration" => Ok(__FieldTag::__visit_duration),
18265                            "totalDuration" => Ok(__FieldTag::__total_duration),
18266                            "total_duration" => Ok(__FieldTag::__total_duration),
18267                            "travelDistanceMeters" => Ok(__FieldTag::__travel_distance_meters),
18268                            "travel_distance_meters" => Ok(__FieldTag::__travel_distance_meters),
18269                            "maxLoads" => Ok(__FieldTag::__max_loads),
18270                            "max_loads" => Ok(__FieldTag::__max_loads),
18271                            "costs" => Ok(__FieldTag::__costs),
18272                            "totalCost" => Ok(__FieldTag::__total_cost),
18273                            "total_cost" => Ok(__FieldTag::__total_cost),
18274                            _ => Ok(__FieldTag::Unknown(value.to_string())),
18275                        }
18276                    }
18277                }
18278                deserializer.deserialize_identifier(Visitor)
18279            }
18280        }
18281        struct Visitor;
18282        impl<'de> serde::de::Visitor<'de> for Visitor {
18283            type Value = AggregatedMetrics;
18284            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18285                formatter.write_str("struct AggregatedMetrics")
18286            }
18287            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18288            where
18289                A: serde::de::MapAccess<'de>,
18290            {
18291                #[allow(unused_imports)]
18292                use serde::de::Error;
18293                use std::option::Option::Some;
18294                let mut fields = std::collections::HashSet::new();
18295                let mut result = Self::Value::new();
18296                while let Some(tag) = map.next_key::<__FieldTag>()? {
18297                    #[allow(clippy::match_single_binding)]
18298                    match tag {
18299                        __FieldTag::__performed_shipment_count => {
18300                            if !fields.insert(__FieldTag::__performed_shipment_count) {
18301                                return std::result::Result::Err(A::Error::duplicate_field(
18302                                    "multiple values for performed_shipment_count",
18303                                ));
18304                            }
18305                            struct __With(std::option::Option<i32>);
18306                            impl<'de> serde::de::Deserialize<'de> for __With {
18307                                fn deserialize<D>(
18308                                    deserializer: D,
18309                                ) -> std::result::Result<Self, D::Error>
18310                                where
18311                                    D: serde::de::Deserializer<'de>,
18312                                {
18313                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
18314                                }
18315                            }
18316                            result.performed_shipment_count =
18317                                map.next_value::<__With>()?.0.unwrap_or_default();
18318                        }
18319                        __FieldTag::__travel_duration => {
18320                            if !fields.insert(__FieldTag::__travel_duration) {
18321                                return std::result::Result::Err(A::Error::duplicate_field(
18322                                    "multiple values for travel_duration",
18323                                ));
18324                            }
18325                            result.travel_duration =
18326                                map.next_value::<std::option::Option<wkt::Duration>>()?;
18327                        }
18328                        __FieldTag::__wait_duration => {
18329                            if !fields.insert(__FieldTag::__wait_duration) {
18330                                return std::result::Result::Err(A::Error::duplicate_field(
18331                                    "multiple values for wait_duration",
18332                                ));
18333                            }
18334                            result.wait_duration =
18335                                map.next_value::<std::option::Option<wkt::Duration>>()?;
18336                        }
18337                        __FieldTag::__delay_duration => {
18338                            if !fields.insert(__FieldTag::__delay_duration) {
18339                                return std::result::Result::Err(A::Error::duplicate_field(
18340                                    "multiple values for delay_duration",
18341                                ));
18342                            }
18343                            result.delay_duration =
18344                                map.next_value::<std::option::Option<wkt::Duration>>()?;
18345                        }
18346                        __FieldTag::__break_duration => {
18347                            if !fields.insert(__FieldTag::__break_duration) {
18348                                return std::result::Result::Err(A::Error::duplicate_field(
18349                                    "multiple values for break_duration",
18350                                ));
18351                            }
18352                            result.break_duration =
18353                                map.next_value::<std::option::Option<wkt::Duration>>()?;
18354                        }
18355                        __FieldTag::__visit_duration => {
18356                            if !fields.insert(__FieldTag::__visit_duration) {
18357                                return std::result::Result::Err(A::Error::duplicate_field(
18358                                    "multiple values for visit_duration",
18359                                ));
18360                            }
18361                            result.visit_duration =
18362                                map.next_value::<std::option::Option<wkt::Duration>>()?;
18363                        }
18364                        __FieldTag::__total_duration => {
18365                            if !fields.insert(__FieldTag::__total_duration) {
18366                                return std::result::Result::Err(A::Error::duplicate_field(
18367                                    "multiple values for total_duration",
18368                                ));
18369                            }
18370                            result.total_duration =
18371                                map.next_value::<std::option::Option<wkt::Duration>>()?;
18372                        }
18373                        __FieldTag::__travel_distance_meters => {
18374                            if !fields.insert(__FieldTag::__travel_distance_meters) {
18375                                return std::result::Result::Err(A::Error::duplicate_field(
18376                                    "multiple values for travel_distance_meters",
18377                                ));
18378                            }
18379                            struct __With(std::option::Option<f64>);
18380                            impl<'de> serde::de::Deserialize<'de> for __With {
18381                                fn deserialize<D>(
18382                                    deserializer: D,
18383                                ) -> std::result::Result<Self, D::Error>
18384                                where
18385                                    D: serde::de::Deserializer<'de>,
18386                                {
18387                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
18388                                }
18389                            }
18390                            result.travel_distance_meters =
18391                                map.next_value::<__With>()?.0.unwrap_or_default();
18392                        }
18393                        __FieldTag::__max_loads => {
18394                            if !fields.insert(__FieldTag::__max_loads) {
18395                                return std::result::Result::Err(A::Error::duplicate_field(
18396                                    "multiple values for max_loads",
18397                                ));
18398                            }
18399                            result.max_loads = map
18400                                .next_value::<std::option::Option<
18401                                    std::collections::HashMap<
18402                                        std::string::String,
18403                                        crate::model::shipment_route::VehicleLoad,
18404                                    >,
18405                                >>()?
18406                                .unwrap_or_default();
18407                        }
18408                        __FieldTag::__costs => {
18409                            if !fields.insert(__FieldTag::__costs) {
18410                                return std::result::Result::Err(A::Error::duplicate_field(
18411                                    "multiple values for costs",
18412                                ));
18413                            }
18414                            struct __With(
18415                                std::option::Option<
18416                                    std::collections::HashMap<std::string::String, f64>,
18417                                >,
18418                            );
18419                            impl<'de> serde::de::Deserialize<'de> for __With {
18420                                fn deserialize<D>(
18421                                    deserializer: D,
18422                                ) -> std::result::Result<Self, D::Error>
18423                                where
18424                                    D: serde::de::Deserializer<'de>,
18425                                {
18426                                    serde_with::As::<
18427                                        std::option::Option<
18428                                            std::collections::HashMap<
18429                                                serde_with::Same,
18430                                                wkt::internal::F64,
18431                                            >,
18432                                        >,
18433                                    >::deserialize(deserializer)
18434                                    .map(__With)
18435                                }
18436                            }
18437                            result.costs = map.next_value::<__With>()?.0.unwrap_or_default();
18438                        }
18439                        __FieldTag::__total_cost => {
18440                            if !fields.insert(__FieldTag::__total_cost) {
18441                                return std::result::Result::Err(A::Error::duplicate_field(
18442                                    "multiple values for total_cost",
18443                                ));
18444                            }
18445                            struct __With(std::option::Option<f64>);
18446                            impl<'de> serde::de::Deserialize<'de> for __With {
18447                                fn deserialize<D>(
18448                                    deserializer: D,
18449                                ) -> std::result::Result<Self, D::Error>
18450                                where
18451                                    D: serde::de::Deserializer<'de>,
18452                                {
18453                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
18454                                }
18455                            }
18456                            result.total_cost = map.next_value::<__With>()?.0.unwrap_or_default();
18457                        }
18458                        __FieldTag::Unknown(key) => {
18459                            let value = map.next_value::<serde_json::Value>()?;
18460                            result._unknown_fields.insert(key, value);
18461                        }
18462                    }
18463                }
18464                std::result::Result::Ok(result)
18465            }
18466        }
18467        deserializer.deserialize_any(Visitor)
18468    }
18469}
18470
18471#[doc(hidden)]
18472impl serde::ser::Serialize for AggregatedMetrics {
18473    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18474    where
18475        S: serde::ser::Serializer,
18476    {
18477        use serde::ser::SerializeMap;
18478        #[allow(unused_imports)]
18479        use std::option::Option::Some;
18480        let mut state = serializer.serialize_map(std::option::Option::None)?;
18481        if !wkt::internal::is_default(&self.performed_shipment_count) {
18482            struct __With<'a>(&'a i32);
18483            impl<'a> serde::ser::Serialize for __With<'a> {
18484                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18485                where
18486                    S: serde::ser::Serializer,
18487                {
18488                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
18489                }
18490            }
18491            state.serialize_entry(
18492                "performedShipmentCount",
18493                &__With(&self.performed_shipment_count),
18494            )?;
18495        }
18496        if self.travel_duration.is_some() {
18497            state.serialize_entry("travelDuration", &self.travel_duration)?;
18498        }
18499        if self.wait_duration.is_some() {
18500            state.serialize_entry("waitDuration", &self.wait_duration)?;
18501        }
18502        if self.delay_duration.is_some() {
18503            state.serialize_entry("delayDuration", &self.delay_duration)?;
18504        }
18505        if self.break_duration.is_some() {
18506            state.serialize_entry("breakDuration", &self.break_duration)?;
18507        }
18508        if self.visit_duration.is_some() {
18509            state.serialize_entry("visitDuration", &self.visit_duration)?;
18510        }
18511        if self.total_duration.is_some() {
18512            state.serialize_entry("totalDuration", &self.total_duration)?;
18513        }
18514        if !wkt::internal::is_default(&self.travel_distance_meters) {
18515            struct __With<'a>(&'a f64);
18516            impl<'a> serde::ser::Serialize for __With<'a> {
18517                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18518                where
18519                    S: serde::ser::Serializer,
18520                {
18521                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
18522                }
18523            }
18524            state.serialize_entry(
18525                "travelDistanceMeters",
18526                &__With(&self.travel_distance_meters),
18527            )?;
18528        }
18529        if !self.max_loads.is_empty() {
18530            state.serialize_entry("maxLoads", &self.max_loads)?;
18531        }
18532        if !self.costs.is_empty() {
18533            struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
18534            impl<'a> serde::ser::Serialize for __With<'a> {
18535                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18536                where
18537                    S: serde::ser::Serializer,
18538                {
18539                    serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::F64> >::serialize(self.0, serializer)
18540                }
18541            }
18542            state.serialize_entry("costs", &__With(&self.costs))?;
18543        }
18544        if !wkt::internal::is_default(&self.total_cost) {
18545            struct __With<'a>(&'a f64);
18546            impl<'a> serde::ser::Serialize for __With<'a> {
18547                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18548                where
18549                    S: serde::ser::Serializer,
18550                {
18551                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
18552                }
18553            }
18554            state.serialize_entry("totalCost", &__With(&self.total_cost))?;
18555        }
18556        if !self._unknown_fields.is_empty() {
18557            for (key, value) in self._unknown_fields.iter() {
18558                state.serialize_entry(key, &value)?;
18559            }
18560        }
18561        state.end()
18562    }
18563}
18564
18565impl std::fmt::Debug for AggregatedMetrics {
18566    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18567        let mut debug_struct = f.debug_struct("AggregatedMetrics");
18568        debug_struct.field("performed_shipment_count", &self.performed_shipment_count);
18569        debug_struct.field("travel_duration", &self.travel_duration);
18570        debug_struct.field("wait_duration", &self.wait_duration);
18571        debug_struct.field("delay_duration", &self.delay_duration);
18572        debug_struct.field("break_duration", &self.break_duration);
18573        debug_struct.field("visit_duration", &self.visit_duration);
18574        debug_struct.field("total_duration", &self.total_duration);
18575        debug_struct.field("travel_distance_meters", &self.travel_distance_meters);
18576        debug_struct.field("max_loads", &self.max_loads);
18577        debug_struct.field("costs", &self.costs);
18578        debug_struct.field("total_cost", &self.total_cost);
18579        if !self._unknown_fields.is_empty() {
18580            debug_struct.field("_unknown_fields", &self._unknown_fields);
18581        }
18582        debug_struct.finish()
18583    }
18584}
18585
18586/// Solution injected in the request including information about which visits
18587/// must be constrained and how they must be constrained.
18588#[derive(Clone, Default, PartialEq)]
18589#[non_exhaustive]
18590pub struct InjectedSolutionConstraint {
18591    /// Routes of the solution to inject. Some routes may be omitted from the
18592    /// original solution. The routes and skipped shipments must satisfy the basic
18593    /// validity assumptions listed for `injected_first_solution_routes`.
18594    pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
18595
18596    /// Skipped shipments of the solution to inject. Some may be omitted from the
18597    /// original solution. See the `routes` field.
18598    pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
18599
18600    /// For zero or more groups of vehicles, specifies when and how much to relax
18601    /// constraints. If this field is empty, all non-empty vehicle routes are
18602    /// fully constrained.
18603    pub constraint_relaxations:
18604        std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
18605
18606    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18607}
18608
18609impl InjectedSolutionConstraint {
18610    pub fn new() -> Self {
18611        std::default::Default::default()
18612    }
18613
18614    /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
18615    pub fn set_routes<T, V>(mut self, v: T) -> Self
18616    where
18617        T: std::iter::IntoIterator<Item = V>,
18618        V: std::convert::Into<crate::model::ShipmentRoute>,
18619    {
18620        use std::iter::Iterator;
18621        self.routes = v.into_iter().map(|i| i.into()).collect();
18622        self
18623    }
18624
18625    /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
18626    pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
18627    where
18628        T: std::iter::IntoIterator<Item = V>,
18629        V: std::convert::Into<crate::model::SkippedShipment>,
18630    {
18631        use std::iter::Iterator;
18632        self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
18633        self
18634    }
18635
18636    /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
18637    pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
18638    where
18639        T: std::iter::IntoIterator<Item = V>,
18640        V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
18641    {
18642        use std::iter::Iterator;
18643        self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
18644        self
18645    }
18646}
18647
18648impl wkt::message::Message for InjectedSolutionConstraint {
18649    fn typename() -> &'static str {
18650        "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
18651    }
18652}
18653
18654#[doc(hidden)]
18655impl<'de> serde::de::Deserialize<'de> for InjectedSolutionConstraint {
18656    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18657    where
18658        D: serde::Deserializer<'de>,
18659    {
18660        #[allow(non_camel_case_types)]
18661        #[doc(hidden)]
18662        #[derive(PartialEq, Eq, Hash)]
18663        enum __FieldTag {
18664            __routes,
18665            __skipped_shipments,
18666            __constraint_relaxations,
18667            Unknown(std::string::String),
18668        }
18669        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18670            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18671            where
18672                D: serde::Deserializer<'de>,
18673            {
18674                struct Visitor;
18675                impl<'de> serde::de::Visitor<'de> for Visitor {
18676                    type Value = __FieldTag;
18677                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18678                        formatter.write_str("a field name for InjectedSolutionConstraint")
18679                    }
18680                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18681                    where
18682                        E: serde::de::Error,
18683                    {
18684                        use std::result::Result::Ok;
18685                        use std::string::ToString;
18686                        match value {
18687                            "routes" => Ok(__FieldTag::__routes),
18688                            "skippedShipments" => Ok(__FieldTag::__skipped_shipments),
18689                            "skipped_shipments" => Ok(__FieldTag::__skipped_shipments),
18690                            "constraintRelaxations" => Ok(__FieldTag::__constraint_relaxations),
18691                            "constraint_relaxations" => Ok(__FieldTag::__constraint_relaxations),
18692                            _ => Ok(__FieldTag::Unknown(value.to_string())),
18693                        }
18694                    }
18695                }
18696                deserializer.deserialize_identifier(Visitor)
18697            }
18698        }
18699        struct Visitor;
18700        impl<'de> serde::de::Visitor<'de> for Visitor {
18701            type Value = InjectedSolutionConstraint;
18702            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18703                formatter.write_str("struct InjectedSolutionConstraint")
18704            }
18705            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18706            where
18707                A: serde::de::MapAccess<'de>,
18708            {
18709                #[allow(unused_imports)]
18710                use serde::de::Error;
18711                use std::option::Option::Some;
18712                let mut fields = std::collections::HashSet::new();
18713                let mut result = Self::Value::new();
18714                while let Some(tag) = map.next_key::<__FieldTag>()? {
18715                    #[allow(clippy::match_single_binding)]
18716                    match tag {
18717                        __FieldTag::__routes => {
18718                            if !fields.insert(__FieldTag::__routes) {
18719                                return std::result::Result::Err(A::Error::duplicate_field(
18720                                    "multiple values for routes",
18721                                ));
18722                            }
18723                            result.routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
18724                        }
18725                        __FieldTag::__skipped_shipments => {
18726                            if !fields.insert(__FieldTag::__skipped_shipments) {
18727                                return std::result::Result::Err(A::Error::duplicate_field(
18728                                    "multiple values for skipped_shipments",
18729                                ));
18730                            }
18731                            result.skipped_shipments =
18732                                map.next_value::<std::option::Option<
18733                                    std::vec::Vec<crate::model::SkippedShipment>,
18734                                >>()?
18735                                .unwrap_or_default();
18736                        }
18737                        __FieldTag::__constraint_relaxations => {
18738                            if !fields.insert(__FieldTag::__constraint_relaxations) {
18739                                return std::result::Result::Err(A::Error::duplicate_field(
18740                                    "multiple values for constraint_relaxations",
18741                                ));
18742                            }
18743                            result.constraint_relaxations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>>>()?.unwrap_or_default();
18744                        }
18745                        __FieldTag::Unknown(key) => {
18746                            let value = map.next_value::<serde_json::Value>()?;
18747                            result._unknown_fields.insert(key, value);
18748                        }
18749                    }
18750                }
18751                std::result::Result::Ok(result)
18752            }
18753        }
18754        deserializer.deserialize_any(Visitor)
18755    }
18756}
18757
18758#[doc(hidden)]
18759impl serde::ser::Serialize for InjectedSolutionConstraint {
18760    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18761    where
18762        S: serde::ser::Serializer,
18763    {
18764        use serde::ser::SerializeMap;
18765        #[allow(unused_imports)]
18766        use std::option::Option::Some;
18767        let mut state = serializer.serialize_map(std::option::Option::None)?;
18768        if !self.routes.is_empty() {
18769            state.serialize_entry("routes", &self.routes)?;
18770        }
18771        if !self.skipped_shipments.is_empty() {
18772            state.serialize_entry("skippedShipments", &self.skipped_shipments)?;
18773        }
18774        if !self.constraint_relaxations.is_empty() {
18775            state.serialize_entry("constraintRelaxations", &self.constraint_relaxations)?;
18776        }
18777        if !self._unknown_fields.is_empty() {
18778            for (key, value) in self._unknown_fields.iter() {
18779                state.serialize_entry(key, &value)?;
18780            }
18781        }
18782        state.end()
18783    }
18784}
18785
18786impl std::fmt::Debug for InjectedSolutionConstraint {
18787    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18788        let mut debug_struct = f.debug_struct("InjectedSolutionConstraint");
18789        debug_struct.field("routes", &self.routes);
18790        debug_struct.field("skipped_shipments", &self.skipped_shipments);
18791        debug_struct.field("constraint_relaxations", &self.constraint_relaxations);
18792        if !self._unknown_fields.is_empty() {
18793            debug_struct.field("_unknown_fields", &self._unknown_fields);
18794        }
18795        debug_struct.finish()
18796    }
18797}
18798
18799/// Defines additional types related to [InjectedSolutionConstraint].
18800pub mod injected_solution_constraint {
18801    #[allow(unused_imports)]
18802    use super::*;
18803
18804    /// For a group of vehicles, specifies at what threshold(s) constraints on
18805    /// visits will be relaxed and to which level. Shipments listed in
18806    /// the `skipped_shipment` field are constrained to be skipped; i.e., they
18807    /// cannot be performed.
18808    #[derive(Clone, Default, PartialEq)]
18809    #[non_exhaustive]
18810    pub struct ConstraintRelaxation {
18811        /// All the visit constraint relaxations that will apply to visits on
18812        /// routes with vehicles in `vehicle_indices`.
18813        pub relaxations: std::vec::Vec<
18814            crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
18815        >,
18816
18817        /// Specifies the vehicle indices to which the visit constraint
18818        /// `relaxations` apply. If empty, this is considered the default and the
18819        /// `relaxations` apply to all vehicles that are not specified in other
18820        /// `constraint_relaxations`. There can be at most one default, i.e., at
18821        /// most one constraint relaxation field is allowed empty
18822        /// `vehicle_indices`. A vehicle index can only be listed once, even within
18823        /// several `constraint_relaxations`.
18824        ///
18825        /// A vehicle index is mapped the same as
18826        /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
18827        /// if `interpret_injected_solutions_using_labels` is true (see `fields`
18828        /// comment).
18829        ///
18830        /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
18831        pub vehicle_indices: std::vec::Vec<i32>,
18832
18833        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18834    }
18835
18836    impl ConstraintRelaxation {
18837        pub fn new() -> Self {
18838            std::default::Default::default()
18839        }
18840
18841        /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
18842        pub fn set_relaxations<T, V>(mut self, v: T) -> Self
18843        where
18844            T: std::iter::IntoIterator<Item = V>,
18845            V: std::convert::Into<
18846                    crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
18847                >,
18848        {
18849            use std::iter::Iterator;
18850            self.relaxations = v.into_iter().map(|i| i.into()).collect();
18851            self
18852        }
18853
18854        /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
18855        pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
18856        where
18857            T: std::iter::IntoIterator<Item = V>,
18858            V: std::convert::Into<i32>,
18859        {
18860            use std::iter::Iterator;
18861            self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
18862            self
18863        }
18864    }
18865
18866    impl wkt::message::Message for ConstraintRelaxation {
18867        fn typename() -> &'static str {
18868            "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
18869        }
18870    }
18871
18872    #[doc(hidden)]
18873    impl<'de> serde::de::Deserialize<'de> for ConstraintRelaxation {
18874        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18875        where
18876            D: serde::Deserializer<'de>,
18877        {
18878            #[allow(non_camel_case_types)]
18879            #[doc(hidden)]
18880            #[derive(PartialEq, Eq, Hash)]
18881            enum __FieldTag {
18882                __relaxations,
18883                __vehicle_indices,
18884                Unknown(std::string::String),
18885            }
18886            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18887                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18888                where
18889                    D: serde::Deserializer<'de>,
18890                {
18891                    struct Visitor;
18892                    impl<'de> serde::de::Visitor<'de> for Visitor {
18893                        type Value = __FieldTag;
18894                        fn expecting(
18895                            &self,
18896                            formatter: &mut std::fmt::Formatter,
18897                        ) -> std::fmt::Result {
18898                            formatter.write_str("a field name for ConstraintRelaxation")
18899                        }
18900                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18901                        where
18902                            E: serde::de::Error,
18903                        {
18904                            use std::result::Result::Ok;
18905                            use std::string::ToString;
18906                            match value {
18907                                "relaxations" => Ok(__FieldTag::__relaxations),
18908                                "vehicleIndices" => Ok(__FieldTag::__vehicle_indices),
18909                                "vehicle_indices" => Ok(__FieldTag::__vehicle_indices),
18910                                _ => Ok(__FieldTag::Unknown(value.to_string())),
18911                            }
18912                        }
18913                    }
18914                    deserializer.deserialize_identifier(Visitor)
18915                }
18916            }
18917            struct Visitor;
18918            impl<'de> serde::de::Visitor<'de> for Visitor {
18919                type Value = ConstraintRelaxation;
18920                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18921                    formatter.write_str("struct ConstraintRelaxation")
18922                }
18923                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18924                where
18925                    A: serde::de::MapAccess<'de>,
18926                {
18927                    #[allow(unused_imports)]
18928                    use serde::de::Error;
18929                    use std::option::Option::Some;
18930                    let mut fields = std::collections::HashSet::new();
18931                    let mut result = Self::Value::new();
18932                    while let Some(tag) = map.next_key::<__FieldTag>()? {
18933                        #[allow(clippy::match_single_binding)]
18934                        match tag {
18935                            __FieldTag::__relaxations => {
18936                                if !fields.insert(__FieldTag::__relaxations) {
18937                                    return std::result::Result::Err(A::Error::duplicate_field(
18938                                        "multiple values for relaxations",
18939                                    ));
18940                                }
18941                                result.relaxations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::injected_solution_constraint::constraint_relaxation::Relaxation>>>()?.unwrap_or_default();
18942                            }
18943                            __FieldTag::__vehicle_indices => {
18944                                if !fields.insert(__FieldTag::__vehicle_indices) {
18945                                    return std::result::Result::Err(A::Error::duplicate_field(
18946                                        "multiple values for vehicle_indices",
18947                                    ));
18948                                }
18949                                struct __With(std::option::Option<std::vec::Vec<i32>>);
18950                                impl<'de> serde::de::Deserialize<'de> for __With {
18951                                    fn deserialize<D>(
18952                                        deserializer: D,
18953                                    ) -> std::result::Result<Self, D::Error>
18954                                    where
18955                                        D: serde::de::Deserializer<'de>,
18956                                    {
18957                                        serde_with::As::<
18958                                            std::option::Option<std::vec::Vec<wkt::internal::I32>>,
18959                                        >::deserialize(
18960                                            deserializer
18961                                        )
18962                                        .map(__With)
18963                                    }
18964                                }
18965                                result.vehicle_indices =
18966                                    map.next_value::<__With>()?.0.unwrap_or_default();
18967                            }
18968                            __FieldTag::Unknown(key) => {
18969                                let value = map.next_value::<serde_json::Value>()?;
18970                                result._unknown_fields.insert(key, value);
18971                            }
18972                        }
18973                    }
18974                    std::result::Result::Ok(result)
18975                }
18976            }
18977            deserializer.deserialize_any(Visitor)
18978        }
18979    }
18980
18981    #[doc(hidden)]
18982    impl serde::ser::Serialize for ConstraintRelaxation {
18983        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18984        where
18985            S: serde::ser::Serializer,
18986        {
18987            use serde::ser::SerializeMap;
18988            #[allow(unused_imports)]
18989            use std::option::Option::Some;
18990            let mut state = serializer.serialize_map(std::option::Option::None)?;
18991            if !self.relaxations.is_empty() {
18992                state.serialize_entry("relaxations", &self.relaxations)?;
18993            }
18994            if !self.vehicle_indices.is_empty() {
18995                struct __With<'a>(&'a std::vec::Vec<i32>);
18996                impl<'a> serde::ser::Serialize for __With<'a> {
18997                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18998                    where
18999                        S: serde::ser::Serializer,
19000                    {
19001                        serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
19002                            self.0, serializer,
19003                        )
19004                    }
19005                }
19006                state.serialize_entry("vehicleIndices", &__With(&self.vehicle_indices))?;
19007            }
19008            if !self._unknown_fields.is_empty() {
19009                for (key, value) in self._unknown_fields.iter() {
19010                    state.serialize_entry(key, &value)?;
19011                }
19012            }
19013            state.end()
19014        }
19015    }
19016
19017    impl std::fmt::Debug for ConstraintRelaxation {
19018        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19019            let mut debug_struct = f.debug_struct("ConstraintRelaxation");
19020            debug_struct.field("relaxations", &self.relaxations);
19021            debug_struct.field("vehicle_indices", &self.vehicle_indices);
19022            if !self._unknown_fields.is_empty() {
19023                debug_struct.field("_unknown_fields", &self._unknown_fields);
19024            }
19025            debug_struct.finish()
19026        }
19027    }
19028
19029    /// Defines additional types related to [ConstraintRelaxation].
19030    pub mod constraint_relaxation {
19031        #[allow(unused_imports)]
19032        use super::*;
19033
19034        /// If `relaxations` is empty, the start time and sequence of all visits
19035        /// on `routes` are fully constrained and no new visits may be inserted or
19036        /// added to those routes. Also, a vehicle's start and end time in
19037        /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
19038        /// visits and has `used_if_route_is_empty` set to false in the model).
19039        ///
19040        /// `relaxations(i).level` specifies the constraint relaxation level applied
19041        /// to a visit #j that satisfies:
19042        ///
19043        /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
19044        /// * `j + 1 >= relaxations(i).threshold_visit_count`
19045        ///
19046        /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
19047        /// satisfies:
19048        ///
19049        /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
19050        /// * `relaxations(i).threshold_visit_count == 0`
19051        ///   and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
19052        /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
19053        /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
19054        ///
19055        /// To apply a relaxation level if a visit meets the `threshold_visit_count`
19056        /// OR the `threshold_time` add two `relaxations` with the same `level`:
19057        /// one with only `threshold_visit_count` set and the other with only
19058        /// `threshold_time` set. If a visit satisfies the conditions of multiple
19059        /// `relaxations`, the most relaxed level applies. As a result, from the
19060        /// vehicle start through the route visits in order to the vehicle end, the
19061        /// relaxation level becomes more relaxed: i.e., the relaxation level is
19062        /// non-decreasing as the route progresses.
19063        ///
19064        /// The timing and sequence of route visits that do not satisfy the
19065        /// threshold conditions of any `relaxations` are fully constrained
19066        /// and no visits may be inserted into these sequences. Also, if a
19067        /// vehicle start or end does not satisfy the conditions of any
19068        /// relaxation the time is fixed, unless the vehicle is empty.
19069        #[derive(Clone, Default, PartialEq)]
19070        #[non_exhaustive]
19071        pub struct Relaxation {
19072
19073            /// The constraint relaxation level that applies when the conditions
19074            /// at or after `threshold_time` AND at least `threshold_visit_count` are
19075            /// satisfied.
19076            pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
19077
19078            /// The time at or after which the relaxation `level` may be applied.
19079            pub threshold_time: std::option::Option<wkt::Timestamp>,
19080
19081            /// The number of visits at or after which the relaxation `level` may be
19082            /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
19083            /// applied directly at the vehicle start.
19084            ///
19085            /// If it is `route.visits_size() + 1`, the `level` may only be applied to
19086            /// the vehicle end. If it is more than `route.visits_size() + 1`,
19087            /// `level` is not applied at all for that route.
19088            pub threshold_visit_count: i32,
19089
19090            _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19091        }
19092
19093        impl Relaxation {
19094            pub fn new() -> Self {
19095                std::default::Default::default()
19096            }
19097
19098            /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
19099            pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
19100                self.level = v.into();
19101                self
19102            }
19103
19104            /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
19105            pub fn set_threshold_time<T>(mut self, v: T) -> Self
19106            where
19107                T: std::convert::Into<wkt::Timestamp>,
19108            {
19109                self.threshold_time = std::option::Option::Some(v.into());
19110                self
19111            }
19112
19113            /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
19114            pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
19115            where
19116                T: std::convert::Into<wkt::Timestamp>,
19117            {
19118                self.threshold_time = v.map(|x| x.into());
19119                self
19120            }
19121
19122            /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
19123            pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
19124                self.threshold_visit_count = v.into();
19125                self
19126            }
19127        }
19128
19129        impl wkt::message::Message for Relaxation {
19130            fn typename() -> &'static str {
19131                "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
19132            }
19133        }
19134
19135        #[doc(hidden)]
19136        impl<'de> serde::de::Deserialize<'de> for Relaxation {
19137            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19138            where
19139                D: serde::Deserializer<'de>,
19140            {
19141                #[allow(non_camel_case_types)]
19142                #[doc(hidden)]
19143                #[derive(PartialEq, Eq, Hash)]
19144                enum __FieldTag {
19145                    __level,
19146                    __threshold_time,
19147                    __threshold_visit_count,
19148                    Unknown(std::string::String),
19149                }
19150                impl<'de> serde::de::Deserialize<'de> for __FieldTag {
19151                    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19152                    where
19153                        D: serde::Deserializer<'de>,
19154                    {
19155                        struct Visitor;
19156                        impl<'de> serde::de::Visitor<'de> for Visitor {
19157                            type Value = __FieldTag;
19158                            fn expecting(
19159                                &self,
19160                                formatter: &mut std::fmt::Formatter,
19161                            ) -> std::fmt::Result {
19162                                formatter.write_str("a field name for Relaxation")
19163                            }
19164                            fn visit_str<E>(
19165                                self,
19166                                value: &str,
19167                            ) -> std::result::Result<Self::Value, E>
19168                            where
19169                                E: serde::de::Error,
19170                            {
19171                                use std::result::Result::Ok;
19172                                use std::string::ToString;
19173                                match value {
19174                                    "level" => Ok(__FieldTag::__level),
19175                                    "thresholdTime" => Ok(__FieldTag::__threshold_time),
19176                                    "threshold_time" => Ok(__FieldTag::__threshold_time),
19177                                    "thresholdVisitCount" => {
19178                                        Ok(__FieldTag::__threshold_visit_count)
19179                                    }
19180                                    "threshold_visit_count" => {
19181                                        Ok(__FieldTag::__threshold_visit_count)
19182                                    }
19183                                    _ => Ok(__FieldTag::Unknown(value.to_string())),
19184                                }
19185                            }
19186                        }
19187                        deserializer.deserialize_identifier(Visitor)
19188                    }
19189                }
19190                struct Visitor;
19191                impl<'de> serde::de::Visitor<'de> for Visitor {
19192                    type Value = Relaxation;
19193                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19194                        formatter.write_str("struct Relaxation")
19195                    }
19196                    fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19197                    where
19198                        A: serde::de::MapAccess<'de>,
19199                    {
19200                        #[allow(unused_imports)]
19201                        use serde::de::Error;
19202                        use std::option::Option::Some;
19203                        let mut fields = std::collections::HashSet::new();
19204                        let mut result = Self::Value::new();
19205                        while let Some(tag) = map.next_key::<__FieldTag>()? {
19206                            #[allow(clippy::match_single_binding)]
19207                            match tag {
19208                                __FieldTag::__level => {
19209                                    if !fields.insert(__FieldTag::__level) {
19210                                        return std::result::Result::Err(
19211                                            A::Error::duplicate_field("multiple values for level"),
19212                                        );
19213                                    }
19214                                    result.level = map.next_value::<std::option::Option<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>()?.unwrap_or_default();
19215                                }
19216                                __FieldTag::__threshold_time => {
19217                                    if !fields.insert(__FieldTag::__threshold_time) {
19218                                        return std::result::Result::Err(
19219                                            A::Error::duplicate_field(
19220                                                "multiple values for threshold_time",
19221                                            ),
19222                                        );
19223                                    }
19224                                    result.threshold_time =
19225                                        map.next_value::<std::option::Option<wkt::Timestamp>>()?;
19226                                }
19227                                __FieldTag::__threshold_visit_count => {
19228                                    if !fields.insert(__FieldTag::__threshold_visit_count) {
19229                                        return std::result::Result::Err(
19230                                            A::Error::duplicate_field(
19231                                                "multiple values for threshold_visit_count",
19232                                            ),
19233                                        );
19234                                    }
19235                                    struct __With(std::option::Option<i32>);
19236                                    impl<'de> serde::de::Deserialize<'de> for __With {
19237                                        fn deserialize<D>(
19238                                            deserializer: D,
19239                                        ) -> std::result::Result<Self, D::Error>
19240                                        where
19241                                            D: serde::de::Deserializer<'de>,
19242                                        {
19243                                            serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
19244                                        }
19245                                    }
19246                                    result.threshold_visit_count =
19247                                        map.next_value::<__With>()?.0.unwrap_or_default();
19248                                }
19249                                __FieldTag::Unknown(key) => {
19250                                    let value = map.next_value::<serde_json::Value>()?;
19251                                    result._unknown_fields.insert(key, value);
19252                                }
19253                            }
19254                        }
19255                        std::result::Result::Ok(result)
19256                    }
19257                }
19258                deserializer.deserialize_any(Visitor)
19259            }
19260        }
19261
19262        #[doc(hidden)]
19263        impl serde::ser::Serialize for Relaxation {
19264            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19265            where
19266                S: serde::ser::Serializer,
19267            {
19268                use serde::ser::SerializeMap;
19269                #[allow(unused_imports)]
19270                use std::option::Option::Some;
19271                let mut state = serializer.serialize_map(std::option::Option::None)?;
19272                if !wkt::internal::is_default(&self.level) {
19273                    state.serialize_entry("level", &self.level)?;
19274                }
19275                if self.threshold_time.is_some() {
19276                    state.serialize_entry("thresholdTime", &self.threshold_time)?;
19277                }
19278                if !wkt::internal::is_default(&self.threshold_visit_count) {
19279                    struct __With<'a>(&'a i32);
19280                    impl<'a> serde::ser::Serialize for __With<'a> {
19281                        fn serialize<S>(
19282                            &self,
19283                            serializer: S,
19284                        ) -> std::result::Result<S::Ok, S::Error>
19285                        where
19286                            S: serde::ser::Serializer,
19287                        {
19288                            serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
19289                        }
19290                    }
19291                    state.serialize_entry(
19292                        "thresholdVisitCount",
19293                        &__With(&self.threshold_visit_count),
19294                    )?;
19295                }
19296                if !self._unknown_fields.is_empty() {
19297                    for (key, value) in self._unknown_fields.iter() {
19298                        state.serialize_entry(key, &value)?;
19299                    }
19300                }
19301                state.end()
19302            }
19303        }
19304
19305        impl std::fmt::Debug for Relaxation {
19306            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19307                let mut debug_struct = f.debug_struct("Relaxation");
19308                debug_struct.field("level", &self.level);
19309                debug_struct.field("threshold_time", &self.threshold_time);
19310                debug_struct.field("threshold_visit_count", &self.threshold_visit_count);
19311                if !self._unknown_fields.is_empty() {
19312                    debug_struct.field("_unknown_fields", &self._unknown_fields);
19313                }
19314                debug_struct.finish()
19315            }
19316        }
19317
19318        /// Defines additional types related to [Relaxation].
19319        pub mod relaxation {
19320            #[allow(unused_imports)]
19321            use super::*;
19322
19323            /// Expresses the different constraint relaxation levels, which are
19324            /// applied for a visit and those that follow when it satisfies the
19325            /// threshold conditions.
19326            ///
19327            /// The enumeration below is in order of increasing relaxation.
19328            ///
19329            /// # Working with unknown values
19330            ///
19331            /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
19332            /// additional enum variants at any time. Adding new variants is not considered
19333            /// a breaking change. Applications should write their code in anticipation of:
19334            ///
19335            /// - New values appearing in future releases of the client library, **and**
19336            /// - New values received dynamically, without application changes.
19337            ///
19338            /// Please consult the [Working with enums] section in the user guide for some
19339            /// guidelines.
19340            ///
19341            /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
19342            #[derive(Clone, Debug, PartialEq)]
19343            #[non_exhaustive]
19344            pub enum Level {
19345                /// Implicit default relaxation level: no constraints are relaxed,
19346                /// i.e., all visits are fully constrained.
19347                ///
19348                /// This value must not be explicitly used in `level`.
19349                Unspecified,
19350                /// Visit start times and vehicle start/end times will be relaxed, but
19351                /// each visit remains bound to the same vehicle and the visit sequence
19352                /// must be observed: no visit can be inserted between them or before
19353                /// them.
19354                RelaxVisitTimesAfterThreshold,
19355                /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
19356                /// is also relaxed: visits can only be performed by this vehicle, but
19357                /// can potentially become unperformed.
19358                RelaxVisitTimesAndSequenceAfterThreshold,
19359                /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
19360                /// vehicle is also relaxed: visits are completely free at or after the
19361                /// threshold time and can potentially become unperformed.
19362                RelaxAllAfterThreshold,
19363                /// If set, the enum was initialized with an unknown value.
19364                ///
19365                /// Applications can examine the value using [Level::value] or
19366                /// [Level::name].
19367                UnknownValue(level::UnknownValue),
19368            }
19369
19370            #[doc(hidden)]
19371            pub mod level {
19372                #[allow(unused_imports)]
19373                use super::*;
19374                #[derive(Clone, Debug, PartialEq)]
19375                pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
19376            }
19377
19378            impl Level {
19379                /// Gets the enum value.
19380                ///
19381                /// Returns `None` if the enum contains an unknown value deserialized from
19382                /// the string representation of enums.
19383                pub fn value(&self) -> std::option::Option<i32> {
19384                    match self {
19385                        Self::Unspecified => std::option::Option::Some(0),
19386                        Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
19387                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
19388                            std::option::Option::Some(2)
19389                        }
19390                        Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
19391                        Self::UnknownValue(u) => u.0.value(),
19392                    }
19393                }
19394
19395                /// Gets the enum value as a string.
19396                ///
19397                /// Returns `None` if the enum contains an unknown value deserialized from
19398                /// the integer representation of enums.
19399                pub fn name(&self) -> std::option::Option<&str> {
19400                    match self {
19401                        Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
19402                        Self::RelaxVisitTimesAfterThreshold => {
19403                            std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
19404                        }
19405                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
19406                            std::option::Option::Some(
19407                                "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
19408                            )
19409                        }
19410                        Self::RelaxAllAfterThreshold => {
19411                            std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
19412                        }
19413                        Self::UnknownValue(u) => u.0.name(),
19414                    }
19415                }
19416            }
19417
19418            impl std::default::Default for Level {
19419                fn default() -> Self {
19420                    use std::convert::From;
19421                    Self::from(0)
19422                }
19423            }
19424
19425            impl std::fmt::Display for Level {
19426                fn fmt(
19427                    &self,
19428                    f: &mut std::fmt::Formatter<'_>,
19429                ) -> std::result::Result<(), std::fmt::Error> {
19430                    wkt::internal::display_enum(f, self.name(), self.value())
19431                }
19432            }
19433
19434            impl std::convert::From<i32> for Level {
19435                fn from(value: i32) -> Self {
19436                    match value {
19437                        0 => Self::Unspecified,
19438                        1 => Self::RelaxVisitTimesAfterThreshold,
19439                        2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
19440                        3 => Self::RelaxAllAfterThreshold,
19441                        _ => Self::UnknownValue(level::UnknownValue(
19442                            wkt::internal::UnknownEnumValue::Integer(value),
19443                        )),
19444                    }
19445                }
19446            }
19447
19448            impl std::convert::From<&str> for Level {
19449                fn from(value: &str) -> Self {
19450                    use std::string::ToString;
19451                    match value {
19452                        "LEVEL_UNSPECIFIED" => Self::Unspecified,
19453                        "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
19454                        "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
19455                            Self::RelaxVisitTimesAndSequenceAfterThreshold
19456                        }
19457                        "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
19458                        _ => Self::UnknownValue(level::UnknownValue(
19459                            wkt::internal::UnknownEnumValue::String(value.to_string()),
19460                        )),
19461                    }
19462                }
19463            }
19464
19465            impl serde::ser::Serialize for Level {
19466                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19467                where
19468                    S: serde::Serializer,
19469                {
19470                    match self {
19471                        Self::Unspecified => serializer.serialize_i32(0),
19472                        Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
19473                        Self::RelaxVisitTimesAndSequenceAfterThreshold => {
19474                            serializer.serialize_i32(2)
19475                        }
19476                        Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
19477                        Self::UnknownValue(u) => u.0.serialize(serializer),
19478                    }
19479                }
19480            }
19481
19482            impl<'de> serde::de::Deserialize<'de> for Level {
19483                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19484                where
19485                    D: serde::Deserializer<'de>,
19486                {
19487                    deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
19488                        ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
19489                }
19490            }
19491        }
19492    }
19493}
19494
19495/// Describes an error encountered when validating an `OptimizeToursRequest`.
19496#[derive(Clone, Default, PartialEq)]
19497#[non_exhaustive]
19498pub struct OptimizeToursValidationError {
19499    /// A validation error is defined by the pair (`code`, `display_name`) which
19500    /// are always present.
19501    ///
19502    /// Other fields (below) provide more context about the error.
19503    ///
19504    /// *MULTIPLE ERRORS*:
19505    /// When there are multiple errors, the validation process tries to output
19506    /// several of them. Much like a compiler, this is an imperfect process. Some
19507    /// validation errors will be "fatal", meaning that they stop the entire
19508    /// validation process. This is the case for `display_name="UNSPECIFIED"`
19509    /// errors, among others. Some may cause the validation process to skip other
19510    /// errors.
19511    ///
19512    /// *STABILITY*:
19513    /// `code` and `display_name` should be very stable. But new codes and
19514    /// display names may appear over time, which may cause a given (invalid)
19515    /// request to yield a different (`code`, `display_name`) pair because the new
19516    /// error hid the old one (see "MULTIPLE ERRORS").
19517    ///
19518    /// *REFERENCE*: A list of all (code, name) pairs:
19519    ///
19520    /// * UNSPECIFIED = 0;
19521    ///
19522    /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
19523    ///   the deadline.
19524    ///
19525    /// * REQUEST_OPTIONS_ERROR = 12;
19526    ///
19527    ///   * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
19528    ///   * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
19529    ///   * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
19530    ///   * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
19531    ///   * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
19532    ///   * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
19533    ///     = 1207;
19534    ///   * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
19535    ///   * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
19536    ///   * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
19537    ///   * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
19538    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
19539    ///   * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
19540    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
19541    ///   * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
19542    /// * INJECTED_SOLUTION_ERROR = 20;
19543    ///
19544    ///   * INJECTED_SOLUTION_MISSING_LABEL = 2000;
19545    ///   * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
19546    ///   * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
19547    ///   * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
19548    ///   * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
19549    ///   * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
19550    ///   * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
19551    ///   * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
19552    ///   * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
19553    /// * SHIPMENT_MODEL_ERROR = 22;
19554    ///
19555    ///   * SHIPMENT_MODEL_TOO_LARGE = 2200;
19556    ///   * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
19557    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
19558    ///   * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
19559    ///   * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
19560    ///   * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
19561    ///   * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
19562    ///   * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
19563    /// * INDEX_ERROR = 24;
19564    ///
19565    /// * TAG_ERROR = 26;
19566    ///
19567    /// * TIME_WINDOW_ERROR = 28;
19568    ///
19569    ///   * TIME_WINDOW_INVALID_START_TIME = 2800;
19570    ///   * TIME_WINDOW_INVALID_END_TIME = 2801;
19571    ///   * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
19572    ///   * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
19573    ///   * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
19574    ///   * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
19575    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
19576    ///   * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
19577    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
19578    ///     = 2808;
19579    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
19580    ///   * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
19581    ///     = 2810;
19582    ///   * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
19583    ///   * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
19584    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
19585    ///   * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
19586    ///   * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
19587    ///   * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
19588    ///   * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
19589    ///     = 2817;
19590    ///   * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
19591    ///   * TRANSITION_ATTRIBUTES_ERROR = 30;
19592    ///   * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
19593    ///   * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
19594    ///   * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
19595    ///   * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
19596    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
19597    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
19598    ///   * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
19599    ///   * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
19600    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
19601    ///   * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
19602    /// * AMOUNT_ERROR = 31;
19603    ///
19604    ///   * AMOUNT_NEGATIVE_VALUE = 3100;
19605    /// * LOAD_LIMIT_ERROR = 33;
19606    ///
19607    ///   * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
19608    ///   * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
19609    ///   * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
19610    ///   * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
19611    ///   * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
19612    ///   * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
19613    ///   * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
19614    /// * INTERVAL_ERROR = 34;
19615    ///
19616    ///   * INTERVAL_MIN_EXCEEDS_MAX = 3401;
19617    ///   * INTERVAL_NEGATIVE_MIN = 3402;
19618    ///   * INTERVAL_NEGATIVE_MAX = 3403;
19619    ///   * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
19620    ///   * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
19621    /// * DISTANCE_LIMIT_ERROR = 36;
19622    ///
19623    ///   * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
19624    ///   * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
19625    ///   * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
19626    ///   * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
19627    ///   * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
19628    ///   * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
19629    /// * DURATION_LIMIT_ERROR = 38;
19630    ///
19631    ///   * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
19632    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
19633    ///   * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
19634    ///   * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
19635    ///   * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
19636    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
19637    ///   * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
19638    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
19639    ///     = 3807;
19640    ///   * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
19641    ///     = 3808;
19642    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
19643    ///   * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
19644    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
19645    ///   * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
19646    ///     = 3812;
19647    ///   * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
19648    ///   * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
19649    ///   * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
19650    ///     = 3815;
19651    /// * SHIPMENT_ERROR = 40;
19652    ///
19653    ///   * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
19654    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
19655    ///   * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
19656    ///     = 4001;
19657    ///   * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
19658    ///   * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
19659    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
19660    ///   * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
19661    ///   * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
19662    ///   * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
19663    ///   * SHIPMENT_INVALID_PENALTY_COST = 4006;
19664    ///   * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
19665    ///   * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
19666    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
19667    ///   * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
19668    ///   * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
19669    ///   * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
19670    ///   * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
19671    /// * VEHICLE_ERROR = 42;
19672    ///
19673    ///   * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
19674    ///   * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
19675    ///   * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
19676    ///   * VEHICLE_EMPTY_START_TAG = 4203;
19677    ///   * VEHICLE_DUPLICATE_START_TAG = 4204;
19678    ///   * VEHICLE_EMPTY_END_TAG = 4205;
19679    ///   * VEHICLE_DUPLICATE_END_TAG = 4206;
19680    ///   * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
19681    ///   * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
19682    ///   * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
19683    ///   * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
19684    ///   * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
19685    ///   * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
19686    ///   * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
19687    ///   * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
19688    ///   * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
19689    ///   * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
19690    ///   * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
19691    ///   * VEHICLE_INVALID_COST_PER_HOUR = 4218;
19692    ///   * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
19693    ///   * VEHICLE_INVALID_FIXED_COST = 4220;
19694    ///   * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
19695    ///   * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
19696    ///     = 4223;
19697    ///   * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
19698    ///   * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
19699    /// * VISIT_REQUEST_ERROR = 44;
19700    ///
19701    ///   * VISIT_REQUEST_EMPTY_TAG = 4400;
19702    ///   * VISIT_REQUEST_DUPLICATE_TAG = 4401;
19703    ///   * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
19704    ///   * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
19705    /// * PRECEDENCE_ERROR = 46;
19706    ///
19707    ///   * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
19708    ///   * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
19709    ///   * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
19710    ///   * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
19711    ///   * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
19712    ///   * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
19713    ///   * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
19714    /// * BREAK_ERROR = 48;
19715    ///
19716    ///   * BREAK_RULE_EMPTY = 4800;
19717    ///   * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
19718    ///   * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
19719    ///   * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
19720    ///   * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
19721    ///   * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
19722    ///   * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
19723    ///   * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
19724    ///   * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
19725    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
19726    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
19727    ///   * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
19728    ///   * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
19729    ///     = 4812;
19730    ///   * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
19731    ///   * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
19732    ///   * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
19733    /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
19734    ///
19735    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
19736    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
19737    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
19738    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
19739    ///   * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
19740    /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
19741    ///
19742    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
19743    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
19744    ///   * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
19745    ///   * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
19746    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
19747    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
19748    ///   * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
19749    ///   * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
19750    ///   * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
19751    ///   * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
19752    ///   * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
19753    /// * VEHICLE_OPERATOR_ERROR = 54;
19754    ///
19755    ///   * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
19756    ///   * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
19757    ///   * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
19758    ///   * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
19759    ///   * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
19760    /// * DURATION_SECONDS_MATRIX_ERROR = 56;
19761    ///
19762    ///   * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
19763    ///   * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
19764    pub code: i32,
19765
19766    /// The error display name.
19767    pub display_name: std::string::String,
19768
19769    /// An error context may involve 0, 1 (most of the time) or more fields. For
19770    /// example, referring to vehicle #4 and shipment #2's first pickup can be
19771    /// done as follows:
19772    ///
19773    /// ```norust
19774    /// fields { name: "vehicles" index: 4}
19775    /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
19776    /// ```
19777    ///
19778    /// Note, however, that the cardinality of `fields` should not change for a
19779    /// given error code.
19780    pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
19781
19782    /// Human-readable string describing the error. There is a 1:1 mapping
19783    /// between `code` and `error_message` (when code != "UNSPECIFIED").
19784    ///
19785    /// *STABILITY*: Not stable: the error message associated to a given `code` may
19786    /// change (hopefully to clarify it) over time. Please rely on the
19787    /// `display_name` and `code` instead.
19788    pub error_message: std::string::String,
19789
19790    /// May contain the value(s) of the field(s). This is not always available. You
19791    /// should absolutely not rely on it and use it only for manual model
19792    /// debugging.
19793    pub offending_values: std::string::String,
19794
19795    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19796}
19797
19798impl OptimizeToursValidationError {
19799    pub fn new() -> Self {
19800        std::default::Default::default()
19801    }
19802
19803    /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
19804    pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
19805        self.code = v.into();
19806        self
19807    }
19808
19809    /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
19810    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19811        self.display_name = v.into();
19812        self
19813    }
19814
19815    /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
19816    pub fn set_fields<T, V>(mut self, v: T) -> Self
19817    where
19818        T: std::iter::IntoIterator<Item = V>,
19819        V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
19820    {
19821        use std::iter::Iterator;
19822        self.fields = v.into_iter().map(|i| i.into()).collect();
19823        self
19824    }
19825
19826    /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
19827    pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19828        self.error_message = v.into();
19829        self
19830    }
19831
19832    /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
19833    pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
19834        mut self,
19835        v: T,
19836    ) -> Self {
19837        self.offending_values = v.into();
19838        self
19839    }
19840}
19841
19842impl wkt::message::Message for OptimizeToursValidationError {
19843    fn typename() -> &'static str {
19844        "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
19845    }
19846}
19847
19848#[doc(hidden)]
19849impl<'de> serde::de::Deserialize<'de> for OptimizeToursValidationError {
19850    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19851    where
19852        D: serde::Deserializer<'de>,
19853    {
19854        #[allow(non_camel_case_types)]
19855        #[doc(hidden)]
19856        #[derive(PartialEq, Eq, Hash)]
19857        enum __FieldTag {
19858            __code,
19859            __display_name,
19860            __fields,
19861            __error_message,
19862            __offending_values,
19863            Unknown(std::string::String),
19864        }
19865        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
19866            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19867            where
19868                D: serde::Deserializer<'de>,
19869            {
19870                struct Visitor;
19871                impl<'de> serde::de::Visitor<'de> for Visitor {
19872                    type Value = __FieldTag;
19873                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19874                        formatter.write_str("a field name for OptimizeToursValidationError")
19875                    }
19876                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19877                    where
19878                        E: serde::de::Error,
19879                    {
19880                        use std::result::Result::Ok;
19881                        use std::string::ToString;
19882                        match value {
19883                            "code" => Ok(__FieldTag::__code),
19884                            "displayName" => Ok(__FieldTag::__display_name),
19885                            "display_name" => Ok(__FieldTag::__display_name),
19886                            "fields" => Ok(__FieldTag::__fields),
19887                            "errorMessage" => Ok(__FieldTag::__error_message),
19888                            "error_message" => Ok(__FieldTag::__error_message),
19889                            "offendingValues" => Ok(__FieldTag::__offending_values),
19890                            "offending_values" => Ok(__FieldTag::__offending_values),
19891                            _ => Ok(__FieldTag::Unknown(value.to_string())),
19892                        }
19893                    }
19894                }
19895                deserializer.deserialize_identifier(Visitor)
19896            }
19897        }
19898        struct Visitor;
19899        impl<'de> serde::de::Visitor<'de> for Visitor {
19900            type Value = OptimizeToursValidationError;
19901            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19902                formatter.write_str("struct OptimizeToursValidationError")
19903            }
19904            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19905            where
19906                A: serde::de::MapAccess<'de>,
19907            {
19908                #[allow(unused_imports)]
19909                use serde::de::Error;
19910                use std::option::Option::Some;
19911                let mut fields = std::collections::HashSet::new();
19912                let mut result = Self::Value::new();
19913                while let Some(tag) = map.next_key::<__FieldTag>()? {
19914                    #[allow(clippy::match_single_binding)]
19915                    match tag {
19916                        __FieldTag::__code => {
19917                            if !fields.insert(__FieldTag::__code) {
19918                                return std::result::Result::Err(A::Error::duplicate_field(
19919                                    "multiple values for code",
19920                                ));
19921                            }
19922                            struct __With(std::option::Option<i32>);
19923                            impl<'de> serde::de::Deserialize<'de> for __With {
19924                                fn deserialize<D>(
19925                                    deserializer: D,
19926                                ) -> std::result::Result<Self, D::Error>
19927                                where
19928                                    D: serde::de::Deserializer<'de>,
19929                                {
19930                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
19931                                }
19932                            }
19933                            result.code = map.next_value::<__With>()?.0.unwrap_or_default();
19934                        }
19935                        __FieldTag::__display_name => {
19936                            if !fields.insert(__FieldTag::__display_name) {
19937                                return std::result::Result::Err(A::Error::duplicate_field(
19938                                    "multiple values for display_name",
19939                                ));
19940                            }
19941                            result.display_name = map
19942                                .next_value::<std::option::Option<std::string::String>>()?
19943                                .unwrap_or_default();
19944                        }
19945                        __FieldTag::__fields => {
19946                            if !fields.insert(__FieldTag::__fields) {
19947                                return std::result::Result::Err(A::Error::duplicate_field(
19948                                    "multiple values for fields",
19949                                ));
19950                            }
19951                            result.fields = map.next_value::<std::option::Option<std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>>>()?.unwrap_or_default();
19952                        }
19953                        __FieldTag::__error_message => {
19954                            if !fields.insert(__FieldTag::__error_message) {
19955                                return std::result::Result::Err(A::Error::duplicate_field(
19956                                    "multiple values for error_message",
19957                                ));
19958                            }
19959                            result.error_message = map
19960                                .next_value::<std::option::Option<std::string::String>>()?
19961                                .unwrap_or_default();
19962                        }
19963                        __FieldTag::__offending_values => {
19964                            if !fields.insert(__FieldTag::__offending_values) {
19965                                return std::result::Result::Err(A::Error::duplicate_field(
19966                                    "multiple values for offending_values",
19967                                ));
19968                            }
19969                            result.offending_values = map
19970                                .next_value::<std::option::Option<std::string::String>>()?
19971                                .unwrap_or_default();
19972                        }
19973                        __FieldTag::Unknown(key) => {
19974                            let value = map.next_value::<serde_json::Value>()?;
19975                            result._unknown_fields.insert(key, value);
19976                        }
19977                    }
19978                }
19979                std::result::Result::Ok(result)
19980            }
19981        }
19982        deserializer.deserialize_any(Visitor)
19983    }
19984}
19985
19986#[doc(hidden)]
19987impl serde::ser::Serialize for OptimizeToursValidationError {
19988    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19989    where
19990        S: serde::ser::Serializer,
19991    {
19992        use serde::ser::SerializeMap;
19993        #[allow(unused_imports)]
19994        use std::option::Option::Some;
19995        let mut state = serializer.serialize_map(std::option::Option::None)?;
19996        if !wkt::internal::is_default(&self.code) {
19997            struct __With<'a>(&'a i32);
19998            impl<'a> serde::ser::Serialize for __With<'a> {
19999                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20000                where
20001                    S: serde::ser::Serializer,
20002                {
20003                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
20004                }
20005            }
20006            state.serialize_entry("code", &__With(&self.code))?;
20007        }
20008        if !self.display_name.is_empty() {
20009            state.serialize_entry("displayName", &self.display_name)?;
20010        }
20011        if !self.fields.is_empty() {
20012            state.serialize_entry("fields", &self.fields)?;
20013        }
20014        if !self.error_message.is_empty() {
20015            state.serialize_entry("errorMessage", &self.error_message)?;
20016        }
20017        if !self.offending_values.is_empty() {
20018            state.serialize_entry("offendingValues", &self.offending_values)?;
20019        }
20020        if !self._unknown_fields.is_empty() {
20021            for (key, value) in self._unknown_fields.iter() {
20022                state.serialize_entry(key, &value)?;
20023            }
20024        }
20025        state.end()
20026    }
20027}
20028
20029impl std::fmt::Debug for OptimizeToursValidationError {
20030    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20031        let mut debug_struct = f.debug_struct("OptimizeToursValidationError");
20032        debug_struct.field("code", &self.code);
20033        debug_struct.field("display_name", &self.display_name);
20034        debug_struct.field("fields", &self.fields);
20035        debug_struct.field("error_message", &self.error_message);
20036        debug_struct.field("offending_values", &self.offending_values);
20037        if !self._unknown_fields.is_empty() {
20038            debug_struct.field("_unknown_fields", &self._unknown_fields);
20039        }
20040        debug_struct.finish()
20041    }
20042}
20043
20044/// Defines additional types related to [OptimizeToursValidationError].
20045pub mod optimize_tours_validation_error {
20046    #[allow(unused_imports)]
20047    use super::*;
20048
20049    /// Specifies a context for the validation error. A `FieldReference` always
20050    /// refers to a given field in this file and follows the same hierarchical
20051    /// structure. For example, we may specify element #2 of `start_time_windows`
20052    /// of vehicle #5 using:
20053    ///
20054    /// ```norust
20055    /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
20056    /// ```
20057    ///
20058    /// We however omit top-level entities such as `OptimizeToursRequest` or
20059    /// `ShipmentModel` to avoid crowding the message.
20060    #[derive(Clone, Default, PartialEq)]
20061    #[non_exhaustive]
20062    pub struct FieldReference {
20063        /// Name of the field, e.g., "vehicles".
20064        pub name: std::string::String,
20065
20066        /// Recursively nested sub-field, if needed.
20067        pub sub_field: std::option::Option<
20068            std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
20069        >,
20070
20071        pub index_or_key: std::option::Option<
20072            crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
20073        >,
20074
20075        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
20076    }
20077
20078    impl FieldReference {
20079        pub fn new() -> Self {
20080            std::default::Default::default()
20081        }
20082
20083        /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
20084        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
20085            self.name = v.into();
20086            self
20087        }
20088
20089        /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
20090        pub fn set_sub_field<T>(mut self, v: T) -> Self
20091        where
20092            T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
20093        {
20094            self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
20095            self
20096        }
20097
20098        /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
20099        pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
20100        where
20101            T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
20102        {
20103            self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
20104            self
20105        }
20106
20107        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
20108        ///
20109        /// Note that all the setters affecting `index_or_key` are mutually
20110        /// exclusive.
20111        pub fn set_index_or_key<
20112            T: std::convert::Into<
20113                    std::option::Option<
20114                        crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
20115                    >,
20116                >,
20117        >(
20118            mut self,
20119            v: T,
20120        ) -> Self {
20121            self.index_or_key = v.into();
20122            self
20123        }
20124
20125        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
20126        /// if it holds a `Index`, `None` if the field is not set or
20127        /// holds a different branch.
20128        pub fn index(&self) -> std::option::Option<&i32> {
20129            #[allow(unreachable_patterns)]
20130            self.index_or_key.as_ref().and_then(|v| match v {
20131                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
20132                _ => std::option::Option::None,
20133            })
20134        }
20135
20136        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
20137        /// to hold a `Index`.
20138        ///
20139        /// Note that all the setters affecting `index_or_key` are
20140        /// mutually exclusive.
20141        pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
20142            self.index_or_key = std::option::Option::Some(
20143                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
20144                    v.into(),
20145                ),
20146            );
20147            self
20148        }
20149
20150        /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
20151        /// if it holds a `Key`, `None` if the field is not set or
20152        /// holds a different branch.
20153        pub fn key(&self) -> std::option::Option<&std::string::String> {
20154            #[allow(unreachable_patterns)]
20155            self.index_or_key.as_ref().and_then(|v| match v {
20156                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
20157                    v,
20158                ) => std::option::Option::Some(v),
20159                _ => std::option::Option::None,
20160            })
20161        }
20162
20163        /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
20164        /// to hold a `Key`.
20165        ///
20166        /// Note that all the setters affecting `index_or_key` are
20167        /// mutually exclusive.
20168        pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
20169            self.index_or_key = std::option::Option::Some(
20170                crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
20171                    v.into(),
20172                ),
20173            );
20174            self
20175        }
20176    }
20177
20178    impl wkt::message::Message for FieldReference {
20179        fn typename() -> &'static str {
20180            "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
20181        }
20182    }
20183
20184    #[doc(hidden)]
20185    impl<'de> serde::de::Deserialize<'de> for FieldReference {
20186        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20187        where
20188            D: serde::Deserializer<'de>,
20189        {
20190            #[allow(non_camel_case_types)]
20191            #[doc(hidden)]
20192            #[derive(PartialEq, Eq, Hash)]
20193            enum __FieldTag {
20194                __name,
20195                __index,
20196                __key,
20197                __sub_field,
20198                Unknown(std::string::String),
20199            }
20200            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
20201                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20202                where
20203                    D: serde::Deserializer<'de>,
20204                {
20205                    struct Visitor;
20206                    impl<'de> serde::de::Visitor<'de> for Visitor {
20207                        type Value = __FieldTag;
20208                        fn expecting(
20209                            &self,
20210                            formatter: &mut std::fmt::Formatter,
20211                        ) -> std::fmt::Result {
20212                            formatter.write_str("a field name for FieldReference")
20213                        }
20214                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
20215                        where
20216                            E: serde::de::Error,
20217                        {
20218                            use std::result::Result::Ok;
20219                            use std::string::ToString;
20220                            match value {
20221                                "name" => Ok(__FieldTag::__name),
20222                                "index" => Ok(__FieldTag::__index),
20223                                "key" => Ok(__FieldTag::__key),
20224                                "subField" => Ok(__FieldTag::__sub_field),
20225                                "sub_field" => Ok(__FieldTag::__sub_field),
20226                                _ => Ok(__FieldTag::Unknown(value.to_string())),
20227                            }
20228                        }
20229                    }
20230                    deserializer.deserialize_identifier(Visitor)
20231                }
20232            }
20233            struct Visitor;
20234            impl<'de> serde::de::Visitor<'de> for Visitor {
20235                type Value = FieldReference;
20236                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
20237                    formatter.write_str("struct FieldReference")
20238                }
20239                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
20240                where
20241                    A: serde::de::MapAccess<'de>,
20242                {
20243                    #[allow(unused_imports)]
20244                    use serde::de::Error;
20245                    use std::option::Option::Some;
20246                    let mut fields = std::collections::HashSet::new();
20247                    let mut result = Self::Value::new();
20248                    while let Some(tag) = map.next_key::<__FieldTag>()? {
20249                        #[allow(clippy::match_single_binding)]
20250                        match tag {
20251                            __FieldTag::__name => {
20252                                if !fields.insert(__FieldTag::__name) {
20253                                    return std::result::Result::Err(A::Error::duplicate_field(
20254                                        "multiple values for name",
20255                                    ));
20256                                }
20257                                result.name = map
20258                                    .next_value::<std::option::Option<std::string::String>>()?
20259                                    .unwrap_or_default();
20260                            }
20261                            __FieldTag::__index => {
20262                                if !fields.insert(__FieldTag::__index) {
20263                                    return std::result::Result::Err(A::Error::duplicate_field(
20264                                        "multiple values for index",
20265                                    ));
20266                                }
20267                                struct __With(std::option::Option<i32>);
20268                                impl<'de> serde::de::Deserialize<'de> for __With {
20269                                    fn deserialize<D>(
20270                                        deserializer: D,
20271                                    ) -> std::result::Result<Self, D::Error>
20272                                    where
20273                                        D: serde::de::Deserializer<'de>,
20274                                    {
20275                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
20276                                    }
20277                                }
20278                                if result.index_or_key.is_some() {
20279                                    return std::result::Result::Err(A::Error::duplicate_field(
20280                                        "multiple values for `index_or_key`, a oneof with full ID .google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference.index, latest field was index",
20281                                    ));
20282                                }
20283                                result.index_or_key = std::option::Option::Some(
20284                                    crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
20285                                        map.next_value::<__With>()?.0.unwrap_or_default()
20286                                    ),
20287                                );
20288                            }
20289                            __FieldTag::__key => {
20290                                if !fields.insert(__FieldTag::__key) {
20291                                    return std::result::Result::Err(A::Error::duplicate_field(
20292                                        "multiple values for key",
20293                                    ));
20294                                }
20295                                if result.index_or_key.is_some() {
20296                                    return std::result::Result::Err(A::Error::duplicate_field(
20297                                        "multiple values for `index_or_key`, a oneof with full ID .google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference.key, latest field was key",
20298                                    ));
20299                                }
20300                                result.index_or_key = std::option::Option::Some(
20301                                    crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
20302                                        map.next_value::<std::option::Option<std::string::String>>()?.unwrap_or_default()
20303                                    ),
20304                                );
20305                            }
20306                            __FieldTag::__sub_field => {
20307                                if !fields.insert(__FieldTag::__sub_field) {
20308                                    return std::result::Result::Err(A::Error::duplicate_field(
20309                                        "multiple values for sub_field",
20310                                    ));
20311                                }
20312                                result.sub_field = map.next_value::<std::option::Option<std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>>>()?
20313                                    ;
20314                            }
20315                            __FieldTag::Unknown(key) => {
20316                                let value = map.next_value::<serde_json::Value>()?;
20317                                result._unknown_fields.insert(key, value);
20318                            }
20319                        }
20320                    }
20321                    std::result::Result::Ok(result)
20322                }
20323            }
20324            deserializer.deserialize_any(Visitor)
20325        }
20326    }
20327
20328    #[doc(hidden)]
20329    impl serde::ser::Serialize for FieldReference {
20330        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20331        where
20332            S: serde::ser::Serializer,
20333        {
20334            use serde::ser::SerializeMap;
20335            #[allow(unused_imports)]
20336            use std::option::Option::Some;
20337            let mut state = serializer.serialize_map(std::option::Option::None)?;
20338            if !self.name.is_empty() {
20339                state.serialize_entry("name", &self.name)?;
20340            }
20341            if let Some(value) = self.index() {
20342                struct __With<'a>(&'a i32);
20343                impl<'a> serde::ser::Serialize for __With<'a> {
20344                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20345                    where
20346                        S: serde::ser::Serializer,
20347                    {
20348                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
20349                    }
20350                }
20351                state.serialize_entry("index", &__With(value))?;
20352            }
20353            if let Some(value) = self.key() {
20354                state.serialize_entry("key", value)?;
20355            }
20356            if self.sub_field.is_some() {
20357                state.serialize_entry("subField", &self.sub_field)?;
20358            }
20359            if !self._unknown_fields.is_empty() {
20360                for (key, value) in self._unknown_fields.iter() {
20361                    state.serialize_entry(key, &value)?;
20362                }
20363            }
20364            state.end()
20365        }
20366    }
20367
20368    impl std::fmt::Debug for FieldReference {
20369        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20370            let mut debug_struct = f.debug_struct("FieldReference");
20371            debug_struct.field("name", &self.name);
20372            debug_struct.field("sub_field", &self.sub_field);
20373            debug_struct.field("index_or_key", &self.index_or_key);
20374            if !self._unknown_fields.is_empty() {
20375                debug_struct.field("_unknown_fields", &self._unknown_fields);
20376            }
20377            debug_struct.finish()
20378        }
20379    }
20380
20381    /// Defines additional types related to [FieldReference].
20382    pub mod field_reference {
20383        #[allow(unused_imports)]
20384        use super::*;
20385
20386        #[derive(Clone, Debug, PartialEq)]
20387        #[non_exhaustive]
20388        pub enum IndexOrKey {
20389            /// Index of the field if repeated.
20390            Index(i32),
20391            /// Key if the field is a map.
20392            Key(std::string::String),
20393        }
20394    }
20395}
20396
20397/// Data formats for input and output files.
20398///
20399/// # Working with unknown values
20400///
20401/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
20402/// additional enum variants at any time. Adding new variants is not considered
20403/// a breaking change. Applications should write their code in anticipation of:
20404///
20405/// - New values appearing in future releases of the client library, **and**
20406/// - New values received dynamically, without application changes.
20407///
20408/// Please consult the [Working with enums] section in the user guide for some
20409/// guidelines.
20410///
20411/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
20412#[derive(Clone, Debug, PartialEq)]
20413#[non_exhaustive]
20414pub enum DataFormat {
20415    /// Default value.
20416    Unspecified,
20417    /// Input data in json format.
20418    Json,
20419    /// Input data in string format.
20420    String,
20421    /// If set, the enum was initialized with an unknown value.
20422    ///
20423    /// Applications can examine the value using [DataFormat::value] or
20424    /// [DataFormat::name].
20425    UnknownValue(data_format::UnknownValue),
20426}
20427
20428#[doc(hidden)]
20429pub mod data_format {
20430    #[allow(unused_imports)]
20431    use super::*;
20432    #[derive(Clone, Debug, PartialEq)]
20433    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
20434}
20435
20436impl DataFormat {
20437    /// Gets the enum value.
20438    ///
20439    /// Returns `None` if the enum contains an unknown value deserialized from
20440    /// the string representation of enums.
20441    pub fn value(&self) -> std::option::Option<i32> {
20442        match self {
20443            Self::Unspecified => std::option::Option::Some(0),
20444            Self::Json => std::option::Option::Some(1),
20445            Self::String => std::option::Option::Some(2),
20446            Self::UnknownValue(u) => u.0.value(),
20447        }
20448    }
20449
20450    /// Gets the enum value as a string.
20451    ///
20452    /// Returns `None` if the enum contains an unknown value deserialized from
20453    /// the integer representation of enums.
20454    pub fn name(&self) -> std::option::Option<&str> {
20455        match self {
20456            Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
20457            Self::Json => std::option::Option::Some("JSON"),
20458            Self::String => std::option::Option::Some("STRING"),
20459            Self::UnknownValue(u) => u.0.name(),
20460        }
20461    }
20462}
20463
20464impl std::default::Default for DataFormat {
20465    fn default() -> Self {
20466        use std::convert::From;
20467        Self::from(0)
20468    }
20469}
20470
20471impl std::fmt::Display for DataFormat {
20472    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
20473        wkt::internal::display_enum(f, self.name(), self.value())
20474    }
20475}
20476
20477impl std::convert::From<i32> for DataFormat {
20478    fn from(value: i32) -> Self {
20479        match value {
20480            0 => Self::Unspecified,
20481            1 => Self::Json,
20482            2 => Self::String,
20483            _ => Self::UnknownValue(data_format::UnknownValue(
20484                wkt::internal::UnknownEnumValue::Integer(value),
20485            )),
20486        }
20487    }
20488}
20489
20490impl std::convert::From<&str> for DataFormat {
20491    fn from(value: &str) -> Self {
20492        use std::string::ToString;
20493        match value {
20494            "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
20495            "JSON" => Self::Json,
20496            "STRING" => Self::String,
20497            _ => Self::UnknownValue(data_format::UnknownValue(
20498                wkt::internal::UnknownEnumValue::String(value.to_string()),
20499            )),
20500        }
20501    }
20502}
20503
20504impl serde::ser::Serialize for DataFormat {
20505    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
20506    where
20507        S: serde::Serializer,
20508    {
20509        match self {
20510            Self::Unspecified => serializer.serialize_i32(0),
20511            Self::Json => serializer.serialize_i32(1),
20512            Self::String => serializer.serialize_i32(2),
20513            Self::UnknownValue(u) => u.0.serialize(serializer),
20514        }
20515    }
20516}
20517
20518impl<'de> serde::de::Deserialize<'de> for DataFormat {
20519    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
20520    where
20521        D: serde::Deserializer<'de>,
20522    {
20523        deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
20524            ".google.cloud.optimization.v1.DataFormat",
20525        ))
20526    }
20527}