1#![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#[derive(Clone, Debug, Default, PartialEq)]
38#[non_exhaustive]
39pub struct InputConfig {
40 pub data_format: crate::model::DataFormat,
42
43 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 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 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 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 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
239pub mod input_config {
241 #[allow(unused_imports)]
242 use super::*;
243
244 #[derive(Clone, Debug, PartialEq)]
247 #[non_exhaustive]
248 pub enum Source {
249 GcsSource(std::boxed::Box<crate::model::GcsSource>),
252 }
253}
254
255#[derive(Clone, Debug, Default, PartialEq)]
257#[non_exhaustive]
258pub struct OutputConfig {
259 pub data_format: crate::model::DataFormat,
261
262 pub destination: std::option::Option<crate::model::output_config::Destination>,
265
266 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
267}
268
269impl OutputConfig {
270 pub fn new() -> Self {
271 std::default::Default::default()
272 }
273
274 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
276 mut self,
277 v: T,
278 ) -> Self {
279 self.data_format = v.into();
280 self
281 }
282
283 pub fn set_destination<
288 T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
289 >(
290 mut self,
291 v: T,
292 ) -> Self {
293 self.destination = v.into();
294 self
295 }
296
297 pub fn gcs_destination(
301 &self,
302 ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
303 #[allow(unreachable_patterns)]
304 self.destination.as_ref().and_then(|v| match v {
305 crate::model::output_config::Destination::GcsDestination(v) => {
306 std::option::Option::Some(v)
307 }
308 _ => std::option::Option::None,
309 })
310 }
311
312 pub fn set_gcs_destination<
318 T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
319 >(
320 mut self,
321 v: T,
322 ) -> Self {
323 self.destination = std::option::Option::Some(
324 crate::model::output_config::Destination::GcsDestination(v.into()),
325 );
326 self
327 }
328}
329
330impl wkt::message::Message for OutputConfig {
331 fn typename() -> &'static str {
332 "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
333 }
334}
335
336#[doc(hidden)]
337impl<'de> serde::de::Deserialize<'de> for OutputConfig {
338 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
339 where
340 D: serde::Deserializer<'de>,
341 {
342 #[allow(non_camel_case_types)]
343 #[doc(hidden)]
344 #[derive(PartialEq, Eq, Hash)]
345 enum __FieldTag {
346 __gcs_destination,
347 __data_format,
348 Unknown(std::string::String),
349 }
350 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
351 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
352 where
353 D: serde::Deserializer<'de>,
354 {
355 struct Visitor;
356 impl<'de> serde::de::Visitor<'de> for Visitor {
357 type Value = __FieldTag;
358 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
359 formatter.write_str("a field name for OutputConfig")
360 }
361 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
362 where
363 E: serde::de::Error,
364 {
365 use std::result::Result::Ok;
366 use std::string::ToString;
367 match value {
368 "gcsDestination" => Ok(__FieldTag::__gcs_destination),
369 "gcs_destination" => Ok(__FieldTag::__gcs_destination),
370 "dataFormat" => Ok(__FieldTag::__data_format),
371 "data_format" => Ok(__FieldTag::__data_format),
372 _ => Ok(__FieldTag::Unknown(value.to_string())),
373 }
374 }
375 }
376 deserializer.deserialize_identifier(Visitor)
377 }
378 }
379 struct Visitor;
380 impl<'de> serde::de::Visitor<'de> for Visitor {
381 type Value = OutputConfig;
382 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
383 formatter.write_str("struct OutputConfig")
384 }
385 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
386 where
387 A: serde::de::MapAccess<'de>,
388 {
389 #[allow(unused_imports)]
390 use serde::de::Error;
391 use std::option::Option::Some;
392 let mut fields = std::collections::HashSet::new();
393 let mut result = Self::Value::new();
394 while let Some(tag) = map.next_key::<__FieldTag>()? {
395 #[allow(clippy::match_single_binding)]
396 match tag {
397 __FieldTag::__gcs_destination => {
398 if !fields.insert(__FieldTag::__gcs_destination) {
399 return std::result::Result::Err(A::Error::duplicate_field(
400 "multiple values for gcs_destination",
401 ));
402 }
403 if result.destination.is_some() {
404 return std::result::Result::Err(A::Error::duplicate_field(
405 "multiple values for `destination`, a oneof with full ID .google.cloud.optimization.v1.OutputConfig.gcs_destination, latest field was gcsDestination",
406 ));
407 }
408 result.destination = std::option::Option::Some(
409 crate::model::output_config::Destination::GcsDestination(
410 map.next_value::<std::option::Option<
411 std::boxed::Box<crate::model::GcsDestination>,
412 >>()?
413 .unwrap_or_default(),
414 ),
415 );
416 }
417 __FieldTag::__data_format => {
418 if !fields.insert(__FieldTag::__data_format) {
419 return std::result::Result::Err(A::Error::duplicate_field(
420 "multiple values for data_format",
421 ));
422 }
423 result.data_format = map
424 .next_value::<std::option::Option<crate::model::DataFormat>>()?
425 .unwrap_or_default();
426 }
427 __FieldTag::Unknown(key) => {
428 let value = map.next_value::<serde_json::Value>()?;
429 result._unknown_fields.insert(key, value);
430 }
431 }
432 }
433 std::result::Result::Ok(result)
434 }
435 }
436 deserializer.deserialize_any(Visitor)
437 }
438}
439
440#[doc(hidden)]
441impl serde::ser::Serialize for OutputConfig {
442 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
443 where
444 S: serde::ser::Serializer,
445 {
446 use serde::ser::SerializeMap;
447 #[allow(unused_imports)]
448 use std::option::Option::Some;
449 let mut state = serializer.serialize_map(std::option::Option::None)?;
450 if let Some(value) = self.gcs_destination() {
451 state.serialize_entry("gcsDestination", value)?;
452 }
453 if !wkt::internal::is_default(&self.data_format) {
454 state.serialize_entry("dataFormat", &self.data_format)?;
455 }
456 if !self._unknown_fields.is_empty() {
457 for (key, value) in self._unknown_fields.iter() {
458 state.serialize_entry(key, &value)?;
459 }
460 }
461 state.end()
462 }
463}
464
465pub mod output_config {
467 #[allow(unused_imports)]
468 use super::*;
469
470 #[derive(Clone, Debug, PartialEq)]
473 #[non_exhaustive]
474 pub enum Destination {
475 GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
477 }
478}
479
480#[derive(Clone, Debug, Default, PartialEq)]
482#[non_exhaustive]
483pub struct GcsSource {
484 pub uri: std::string::String,
486
487 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
488}
489
490impl GcsSource {
491 pub fn new() -> Self {
492 std::default::Default::default()
493 }
494
495 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
497 self.uri = v.into();
498 self
499 }
500}
501
502impl wkt::message::Message for GcsSource {
503 fn typename() -> &'static str {
504 "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
505 }
506}
507
508#[doc(hidden)]
509impl<'de> serde::de::Deserialize<'de> for GcsSource {
510 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
511 where
512 D: serde::Deserializer<'de>,
513 {
514 #[allow(non_camel_case_types)]
515 #[doc(hidden)]
516 #[derive(PartialEq, Eq, Hash)]
517 enum __FieldTag {
518 __uri,
519 Unknown(std::string::String),
520 }
521 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
522 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
523 where
524 D: serde::Deserializer<'de>,
525 {
526 struct Visitor;
527 impl<'de> serde::de::Visitor<'de> for Visitor {
528 type Value = __FieldTag;
529 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
530 formatter.write_str("a field name for GcsSource")
531 }
532 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
533 where
534 E: serde::de::Error,
535 {
536 use std::result::Result::Ok;
537 use std::string::ToString;
538 match value {
539 "uri" => Ok(__FieldTag::__uri),
540 _ => Ok(__FieldTag::Unknown(value.to_string())),
541 }
542 }
543 }
544 deserializer.deserialize_identifier(Visitor)
545 }
546 }
547 struct Visitor;
548 impl<'de> serde::de::Visitor<'de> for Visitor {
549 type Value = GcsSource;
550 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
551 formatter.write_str("struct GcsSource")
552 }
553 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
554 where
555 A: serde::de::MapAccess<'de>,
556 {
557 #[allow(unused_imports)]
558 use serde::de::Error;
559 use std::option::Option::Some;
560 let mut fields = std::collections::HashSet::new();
561 let mut result = Self::Value::new();
562 while let Some(tag) = map.next_key::<__FieldTag>()? {
563 #[allow(clippy::match_single_binding)]
564 match tag {
565 __FieldTag::__uri => {
566 if !fields.insert(__FieldTag::__uri) {
567 return std::result::Result::Err(A::Error::duplicate_field(
568 "multiple values for uri",
569 ));
570 }
571 result.uri = map
572 .next_value::<std::option::Option<std::string::String>>()?
573 .unwrap_or_default();
574 }
575 __FieldTag::Unknown(key) => {
576 let value = map.next_value::<serde_json::Value>()?;
577 result._unknown_fields.insert(key, value);
578 }
579 }
580 }
581 std::result::Result::Ok(result)
582 }
583 }
584 deserializer.deserialize_any(Visitor)
585 }
586}
587
588#[doc(hidden)]
589impl serde::ser::Serialize for GcsSource {
590 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
591 where
592 S: serde::ser::Serializer,
593 {
594 use serde::ser::SerializeMap;
595 #[allow(unused_imports)]
596 use std::option::Option::Some;
597 let mut state = serializer.serialize_map(std::option::Option::None)?;
598 if !self.uri.is_empty() {
599 state.serialize_entry("uri", &self.uri)?;
600 }
601 if !self._unknown_fields.is_empty() {
602 for (key, value) in self._unknown_fields.iter() {
603 state.serialize_entry(key, &value)?;
604 }
605 }
606 state.end()
607 }
608}
609
610#[derive(Clone, Debug, Default, PartialEq)]
612#[non_exhaustive]
613pub struct GcsDestination {
614 pub uri: std::string::String,
616
617 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
618}
619
620impl GcsDestination {
621 pub fn new() -> Self {
622 std::default::Default::default()
623 }
624
625 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
627 self.uri = v.into();
628 self
629 }
630}
631
632impl wkt::message::Message for GcsDestination {
633 fn typename() -> &'static str {
634 "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
635 }
636}
637
638#[doc(hidden)]
639impl<'de> serde::de::Deserialize<'de> for GcsDestination {
640 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
641 where
642 D: serde::Deserializer<'de>,
643 {
644 #[allow(non_camel_case_types)]
645 #[doc(hidden)]
646 #[derive(PartialEq, Eq, Hash)]
647 enum __FieldTag {
648 __uri,
649 Unknown(std::string::String),
650 }
651 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
652 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
653 where
654 D: serde::Deserializer<'de>,
655 {
656 struct Visitor;
657 impl<'de> serde::de::Visitor<'de> for Visitor {
658 type Value = __FieldTag;
659 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
660 formatter.write_str("a field name for GcsDestination")
661 }
662 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
663 where
664 E: serde::de::Error,
665 {
666 use std::result::Result::Ok;
667 use std::string::ToString;
668 match value {
669 "uri" => Ok(__FieldTag::__uri),
670 _ => Ok(__FieldTag::Unknown(value.to_string())),
671 }
672 }
673 }
674 deserializer.deserialize_identifier(Visitor)
675 }
676 }
677 struct Visitor;
678 impl<'de> serde::de::Visitor<'de> for Visitor {
679 type Value = GcsDestination;
680 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
681 formatter.write_str("struct GcsDestination")
682 }
683 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
684 where
685 A: serde::de::MapAccess<'de>,
686 {
687 #[allow(unused_imports)]
688 use serde::de::Error;
689 use std::option::Option::Some;
690 let mut fields = std::collections::HashSet::new();
691 let mut result = Self::Value::new();
692 while let Some(tag) = map.next_key::<__FieldTag>()? {
693 #[allow(clippy::match_single_binding)]
694 match tag {
695 __FieldTag::__uri => {
696 if !fields.insert(__FieldTag::__uri) {
697 return std::result::Result::Err(A::Error::duplicate_field(
698 "multiple values for uri",
699 ));
700 }
701 result.uri = map
702 .next_value::<std::option::Option<std::string::String>>()?
703 .unwrap_or_default();
704 }
705 __FieldTag::Unknown(key) => {
706 let value = map.next_value::<serde_json::Value>()?;
707 result._unknown_fields.insert(key, value);
708 }
709 }
710 }
711 std::result::Result::Ok(result)
712 }
713 }
714 deserializer.deserialize_any(Visitor)
715 }
716}
717
718#[doc(hidden)]
719impl serde::ser::Serialize for GcsDestination {
720 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
721 where
722 S: serde::ser::Serializer,
723 {
724 use serde::ser::SerializeMap;
725 #[allow(unused_imports)]
726 use std::option::Option::Some;
727 let mut state = serializer.serialize_map(std::option::Option::None)?;
728 if !self.uri.is_empty() {
729 state.serialize_entry("uri", &self.uri)?;
730 }
731 if !self._unknown_fields.is_empty() {
732 for (key, value) in self._unknown_fields.iter() {
733 state.serialize_entry(key, &value)?;
734 }
735 }
736 state.end()
737 }
738}
739
740#[derive(Clone, Debug, Default, PartialEq)]
742#[non_exhaustive]
743pub struct AsyncModelMetadata {
744 pub state: crate::model::async_model_metadata::State,
746
747 pub state_message: std::string::String,
750
751 pub create_time: std::option::Option<wkt::Timestamp>,
753
754 pub update_time: std::option::Option<wkt::Timestamp>,
756
757 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
758}
759
760impl AsyncModelMetadata {
761 pub fn new() -> Self {
762 std::default::Default::default()
763 }
764
765 pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
767 mut self,
768 v: T,
769 ) -> Self {
770 self.state = v.into();
771 self
772 }
773
774 pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
776 self.state_message = v.into();
777 self
778 }
779
780 pub fn set_create_time<T>(mut self, v: T) -> Self
782 where
783 T: std::convert::Into<wkt::Timestamp>,
784 {
785 self.create_time = std::option::Option::Some(v.into());
786 self
787 }
788
789 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
791 where
792 T: std::convert::Into<wkt::Timestamp>,
793 {
794 self.create_time = v.map(|x| x.into());
795 self
796 }
797
798 pub fn set_update_time<T>(mut self, v: T) -> Self
800 where
801 T: std::convert::Into<wkt::Timestamp>,
802 {
803 self.update_time = std::option::Option::Some(v.into());
804 self
805 }
806
807 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
809 where
810 T: std::convert::Into<wkt::Timestamp>,
811 {
812 self.update_time = v.map(|x| x.into());
813 self
814 }
815}
816
817impl wkt::message::Message for AsyncModelMetadata {
818 fn typename() -> &'static str {
819 "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
820 }
821}
822
823#[doc(hidden)]
824impl<'de> serde::de::Deserialize<'de> for AsyncModelMetadata {
825 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
826 where
827 D: serde::Deserializer<'de>,
828 {
829 #[allow(non_camel_case_types)]
830 #[doc(hidden)]
831 #[derive(PartialEq, Eq, Hash)]
832 enum __FieldTag {
833 __state,
834 __state_message,
835 __create_time,
836 __update_time,
837 Unknown(std::string::String),
838 }
839 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
840 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
841 where
842 D: serde::Deserializer<'de>,
843 {
844 struct Visitor;
845 impl<'de> serde::de::Visitor<'de> for Visitor {
846 type Value = __FieldTag;
847 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
848 formatter.write_str("a field name for AsyncModelMetadata")
849 }
850 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
851 where
852 E: serde::de::Error,
853 {
854 use std::result::Result::Ok;
855 use std::string::ToString;
856 match value {
857 "state" => Ok(__FieldTag::__state),
858 "stateMessage" => Ok(__FieldTag::__state_message),
859 "state_message" => Ok(__FieldTag::__state_message),
860 "createTime" => Ok(__FieldTag::__create_time),
861 "create_time" => Ok(__FieldTag::__create_time),
862 "updateTime" => Ok(__FieldTag::__update_time),
863 "update_time" => Ok(__FieldTag::__update_time),
864 _ => Ok(__FieldTag::Unknown(value.to_string())),
865 }
866 }
867 }
868 deserializer.deserialize_identifier(Visitor)
869 }
870 }
871 struct Visitor;
872 impl<'de> serde::de::Visitor<'de> for Visitor {
873 type Value = AsyncModelMetadata;
874 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
875 formatter.write_str("struct AsyncModelMetadata")
876 }
877 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
878 where
879 A: serde::de::MapAccess<'de>,
880 {
881 #[allow(unused_imports)]
882 use serde::de::Error;
883 use std::option::Option::Some;
884 let mut fields = std::collections::HashSet::new();
885 let mut result = Self::Value::new();
886 while let Some(tag) = map.next_key::<__FieldTag>()? {
887 #[allow(clippy::match_single_binding)]
888 match tag {
889 __FieldTag::__state => {
890 if !fields.insert(__FieldTag::__state) {
891 return std::result::Result::Err(A::Error::duplicate_field(
892 "multiple values for state",
893 ));
894 }
895 result.state = map.next_value::<std::option::Option<crate::model::async_model_metadata::State>>()?.unwrap_or_default();
896 }
897 __FieldTag::__state_message => {
898 if !fields.insert(__FieldTag::__state_message) {
899 return std::result::Result::Err(A::Error::duplicate_field(
900 "multiple values for state_message",
901 ));
902 }
903 result.state_message = map
904 .next_value::<std::option::Option<std::string::String>>()?
905 .unwrap_or_default();
906 }
907 __FieldTag::__create_time => {
908 if !fields.insert(__FieldTag::__create_time) {
909 return std::result::Result::Err(A::Error::duplicate_field(
910 "multiple values for create_time",
911 ));
912 }
913 result.create_time =
914 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
915 }
916 __FieldTag::__update_time => {
917 if !fields.insert(__FieldTag::__update_time) {
918 return std::result::Result::Err(A::Error::duplicate_field(
919 "multiple values for update_time",
920 ));
921 }
922 result.update_time =
923 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
924 }
925 __FieldTag::Unknown(key) => {
926 let value = map.next_value::<serde_json::Value>()?;
927 result._unknown_fields.insert(key, value);
928 }
929 }
930 }
931 std::result::Result::Ok(result)
932 }
933 }
934 deserializer.deserialize_any(Visitor)
935 }
936}
937
938#[doc(hidden)]
939impl serde::ser::Serialize for AsyncModelMetadata {
940 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
941 where
942 S: serde::ser::Serializer,
943 {
944 use serde::ser::SerializeMap;
945 #[allow(unused_imports)]
946 use std::option::Option::Some;
947 let mut state = serializer.serialize_map(std::option::Option::None)?;
948 if !wkt::internal::is_default(&self.state) {
949 state.serialize_entry("state", &self.state)?;
950 }
951 if !self.state_message.is_empty() {
952 state.serialize_entry("stateMessage", &self.state_message)?;
953 }
954 if self.create_time.is_some() {
955 state.serialize_entry("createTime", &self.create_time)?;
956 }
957 if self.update_time.is_some() {
958 state.serialize_entry("updateTime", &self.update_time)?;
959 }
960 if !self._unknown_fields.is_empty() {
961 for (key, value) in self._unknown_fields.iter() {
962 state.serialize_entry(key, &value)?;
963 }
964 }
965 state.end()
966 }
967}
968
969pub mod async_model_metadata {
971 #[allow(unused_imports)]
972 use super::*;
973
974 #[derive(Clone, Debug, PartialEq)]
990 #[non_exhaustive]
991 pub enum State {
992 Unspecified,
994 Running,
996 Succeeded,
998 Cancelled,
1000 Failed,
1002 UnknownValue(state::UnknownValue),
1007 }
1008
1009 #[doc(hidden)]
1010 pub mod state {
1011 #[allow(unused_imports)]
1012 use super::*;
1013 #[derive(Clone, Debug, PartialEq)]
1014 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1015 }
1016
1017 impl State {
1018 pub fn value(&self) -> std::option::Option<i32> {
1023 match self {
1024 Self::Unspecified => std::option::Option::Some(0),
1025 Self::Running => std::option::Option::Some(1),
1026 Self::Succeeded => std::option::Option::Some(2),
1027 Self::Cancelled => std::option::Option::Some(3),
1028 Self::Failed => std::option::Option::Some(4),
1029 Self::UnknownValue(u) => u.0.value(),
1030 }
1031 }
1032
1033 pub fn name(&self) -> std::option::Option<&str> {
1038 match self {
1039 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1040 Self::Running => std::option::Option::Some("RUNNING"),
1041 Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
1042 Self::Cancelled => std::option::Option::Some("CANCELLED"),
1043 Self::Failed => std::option::Option::Some("FAILED"),
1044 Self::UnknownValue(u) => u.0.name(),
1045 }
1046 }
1047 }
1048
1049 impl std::default::Default for State {
1050 fn default() -> Self {
1051 use std::convert::From;
1052 Self::from(0)
1053 }
1054 }
1055
1056 impl std::fmt::Display for State {
1057 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1058 wkt::internal::display_enum(f, self.name(), self.value())
1059 }
1060 }
1061
1062 impl std::convert::From<i32> for State {
1063 fn from(value: i32) -> Self {
1064 match value {
1065 0 => Self::Unspecified,
1066 1 => Self::Running,
1067 2 => Self::Succeeded,
1068 3 => Self::Cancelled,
1069 4 => Self::Failed,
1070 _ => Self::UnknownValue(state::UnknownValue(
1071 wkt::internal::UnknownEnumValue::Integer(value),
1072 )),
1073 }
1074 }
1075 }
1076
1077 impl std::convert::From<&str> for State {
1078 fn from(value: &str) -> Self {
1079 use std::string::ToString;
1080 match value {
1081 "STATE_UNSPECIFIED" => Self::Unspecified,
1082 "RUNNING" => Self::Running,
1083 "SUCCEEDED" => Self::Succeeded,
1084 "CANCELLED" => Self::Cancelled,
1085 "FAILED" => Self::Failed,
1086 _ => Self::UnknownValue(state::UnknownValue(
1087 wkt::internal::UnknownEnumValue::String(value.to_string()),
1088 )),
1089 }
1090 }
1091 }
1092
1093 impl serde::ser::Serialize for State {
1094 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1095 where
1096 S: serde::Serializer,
1097 {
1098 match self {
1099 Self::Unspecified => serializer.serialize_i32(0),
1100 Self::Running => serializer.serialize_i32(1),
1101 Self::Succeeded => serializer.serialize_i32(2),
1102 Self::Cancelled => serializer.serialize_i32(3),
1103 Self::Failed => serializer.serialize_i32(4),
1104 Self::UnknownValue(u) => u.0.serialize(serializer),
1105 }
1106 }
1107 }
1108
1109 impl<'de> serde::de::Deserialize<'de> for State {
1110 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1111 where
1112 D: serde::Deserializer<'de>,
1113 {
1114 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1115 ".google.cloud.optimization.v1.AsyncModelMetadata.State",
1116 ))
1117 }
1118 }
1119}
1120
1121#[derive(Clone, Debug, Default, PartialEq)]
1124#[non_exhaustive]
1125pub struct OptimizeToursRequest {
1126 pub parent: std::string::String,
1132
1133 pub timeout: std::option::Option<wkt::Duration>,
1140
1141 pub model: std::option::Option<crate::model::ShipmentModel>,
1143
1144 pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
1146
1147 pub search_mode: crate::model::optimize_tours_request::SearchMode,
1149
1150 pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
1182
1183 pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
1192
1193 pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
1210
1211 pub interpret_injected_solutions_using_labels: bool,
1286
1287 pub consider_road_traffic: bool,
1301
1302 pub populate_polylines: bool,
1304
1305 pub populate_transition_polylines: bool,
1312
1313 pub allow_large_deadline_despite_interruption_risk: bool,
1319
1320 pub use_geodesic_distances: bool,
1324
1325 pub geodesic_meters_per_second: std::option::Option<f64>,
1329
1330 pub max_validation_errors: std::option::Option<i32>,
1340
1341 pub label: std::string::String,
1346
1347 #[deprecated]
1357 pub populate_travel_step_polylines: bool,
1358
1359 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1360}
1361
1362impl OptimizeToursRequest {
1363 pub fn new() -> Self {
1364 std::default::Default::default()
1365 }
1366
1367 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1369 self.parent = v.into();
1370 self
1371 }
1372
1373 pub fn set_timeout<T>(mut self, v: T) -> Self
1375 where
1376 T: std::convert::Into<wkt::Duration>,
1377 {
1378 self.timeout = std::option::Option::Some(v.into());
1379 self
1380 }
1381
1382 pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
1384 where
1385 T: std::convert::Into<wkt::Duration>,
1386 {
1387 self.timeout = v.map(|x| x.into());
1388 self
1389 }
1390
1391 pub fn set_model<T>(mut self, v: T) -> Self
1393 where
1394 T: std::convert::Into<crate::model::ShipmentModel>,
1395 {
1396 self.model = std::option::Option::Some(v.into());
1397 self
1398 }
1399
1400 pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
1402 where
1403 T: std::convert::Into<crate::model::ShipmentModel>,
1404 {
1405 self.model = v.map(|x| x.into());
1406 self
1407 }
1408
1409 pub fn set_solving_mode<
1411 T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
1412 >(
1413 mut self,
1414 v: T,
1415 ) -> Self {
1416 self.solving_mode = v.into();
1417 self
1418 }
1419
1420 pub fn set_search_mode<
1422 T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
1423 >(
1424 mut self,
1425 v: T,
1426 ) -> Self {
1427 self.search_mode = v.into();
1428 self
1429 }
1430
1431 pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
1433 where
1434 T: std::iter::IntoIterator<Item = V>,
1435 V: std::convert::Into<crate::model::ShipmentRoute>,
1436 {
1437 use std::iter::Iterator;
1438 self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
1439 self
1440 }
1441
1442 pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
1444 where
1445 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1446 {
1447 self.injected_solution_constraint = std::option::Option::Some(v.into());
1448 self
1449 }
1450
1451 pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
1453 where
1454 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1455 {
1456 self.injected_solution_constraint = v.map(|x| x.into());
1457 self
1458 }
1459
1460 pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
1462 where
1463 T: std::iter::IntoIterator<Item = V>,
1464 V: std::convert::Into<crate::model::ShipmentRoute>,
1465 {
1466 use std::iter::Iterator;
1467 self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
1468 self
1469 }
1470
1471 pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
1473 mut self,
1474 v: T,
1475 ) -> Self {
1476 self.interpret_injected_solutions_using_labels = v.into();
1477 self
1478 }
1479
1480 pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1482 self.consider_road_traffic = v.into();
1483 self
1484 }
1485
1486 pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1488 self.populate_polylines = v.into();
1489 self
1490 }
1491
1492 pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1494 self.populate_transition_polylines = v.into();
1495 self
1496 }
1497
1498 pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1500 mut self,
1501 v: T,
1502 ) -> Self {
1503 self.allow_large_deadline_despite_interruption_risk = v.into();
1504 self
1505 }
1506
1507 pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1509 self.use_geodesic_distances = v.into();
1510 self
1511 }
1512
1513 pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1515 where
1516 T: std::convert::Into<f64>,
1517 {
1518 self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1519 self
1520 }
1521
1522 pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1524 where
1525 T: std::convert::Into<f64>,
1526 {
1527 self.geodesic_meters_per_second = v.map(|x| x.into());
1528 self
1529 }
1530
1531 pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1533 where
1534 T: std::convert::Into<i32>,
1535 {
1536 self.max_validation_errors = std::option::Option::Some(v.into());
1537 self
1538 }
1539
1540 pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1542 where
1543 T: std::convert::Into<i32>,
1544 {
1545 self.max_validation_errors = v.map(|x| x.into());
1546 self
1547 }
1548
1549 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1551 self.label = v.into();
1552 self
1553 }
1554
1555 #[deprecated]
1557 pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1558 self.populate_travel_step_polylines = v.into();
1559 self
1560 }
1561}
1562
1563impl wkt::message::Message for OptimizeToursRequest {
1564 fn typename() -> &'static str {
1565 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
1566 }
1567}
1568
1569#[doc(hidden)]
1570impl<'de> serde::de::Deserialize<'de> for OptimizeToursRequest {
1571 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1572 where
1573 D: serde::Deserializer<'de>,
1574 {
1575 #[allow(non_camel_case_types)]
1576 #[doc(hidden)]
1577 #[derive(PartialEq, Eq, Hash)]
1578 enum __FieldTag {
1579 __parent,
1580 __timeout,
1581 __model,
1582 __solving_mode,
1583 __search_mode,
1584 __injected_first_solution_routes,
1585 __injected_solution_constraint,
1586 __refresh_details_routes,
1587 __interpret_injected_solutions_using_labels,
1588 __consider_road_traffic,
1589 __populate_polylines,
1590 __populate_transition_polylines,
1591 __allow_large_deadline_despite_interruption_risk,
1592 __use_geodesic_distances,
1593 __geodesic_meters_per_second,
1594 __max_validation_errors,
1595 __label,
1596 __populate_travel_step_polylines,
1597 Unknown(std::string::String),
1598 }
1599 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1600 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1601 where
1602 D: serde::Deserializer<'de>,
1603 {
1604 struct Visitor;
1605 impl<'de> serde::de::Visitor<'de> for Visitor {
1606 type Value = __FieldTag;
1607 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1608 formatter.write_str("a field name for OptimizeToursRequest")
1609 }
1610 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1611 where
1612 E: serde::de::Error,
1613 {
1614 use std::result::Result::Ok;
1615 use std::string::ToString;
1616 match value {
1617 "parent" => Ok(__FieldTag::__parent),
1618 "timeout" => Ok(__FieldTag::__timeout),
1619 "model" => Ok(__FieldTag::__model),
1620 "solvingMode" => Ok(__FieldTag::__solving_mode),
1621 "solving_mode" => Ok(__FieldTag::__solving_mode),
1622 "searchMode" => Ok(__FieldTag::__search_mode),
1623 "search_mode" => Ok(__FieldTag::__search_mode),
1624 "injectedFirstSolutionRoutes" => {
1625 Ok(__FieldTag::__injected_first_solution_routes)
1626 }
1627 "injected_first_solution_routes" => {
1628 Ok(__FieldTag::__injected_first_solution_routes)
1629 }
1630 "injectedSolutionConstraint" => {
1631 Ok(__FieldTag::__injected_solution_constraint)
1632 }
1633 "injected_solution_constraint" => {
1634 Ok(__FieldTag::__injected_solution_constraint)
1635 }
1636 "refreshDetailsRoutes" => Ok(__FieldTag::__refresh_details_routes),
1637 "refresh_details_routes" => Ok(__FieldTag::__refresh_details_routes),
1638 "interpretInjectedSolutionsUsingLabels" => {
1639 Ok(__FieldTag::__interpret_injected_solutions_using_labels)
1640 }
1641 "interpret_injected_solutions_using_labels" => {
1642 Ok(__FieldTag::__interpret_injected_solutions_using_labels)
1643 }
1644 "considerRoadTraffic" => Ok(__FieldTag::__consider_road_traffic),
1645 "consider_road_traffic" => Ok(__FieldTag::__consider_road_traffic),
1646 "populatePolylines" => Ok(__FieldTag::__populate_polylines),
1647 "populate_polylines" => Ok(__FieldTag::__populate_polylines),
1648 "populateTransitionPolylines" => {
1649 Ok(__FieldTag::__populate_transition_polylines)
1650 }
1651 "populate_transition_polylines" => {
1652 Ok(__FieldTag::__populate_transition_polylines)
1653 }
1654 "allowLargeDeadlineDespiteInterruptionRisk" => {
1655 Ok(__FieldTag::__allow_large_deadline_despite_interruption_risk)
1656 }
1657 "allow_large_deadline_despite_interruption_risk" => {
1658 Ok(__FieldTag::__allow_large_deadline_despite_interruption_risk)
1659 }
1660 "useGeodesicDistances" => Ok(__FieldTag::__use_geodesic_distances),
1661 "use_geodesic_distances" => Ok(__FieldTag::__use_geodesic_distances),
1662 "geodesicMetersPerSecond" => {
1663 Ok(__FieldTag::__geodesic_meters_per_second)
1664 }
1665 "geodesic_meters_per_second" => {
1666 Ok(__FieldTag::__geodesic_meters_per_second)
1667 }
1668 "maxValidationErrors" => Ok(__FieldTag::__max_validation_errors),
1669 "max_validation_errors" => Ok(__FieldTag::__max_validation_errors),
1670 "label" => Ok(__FieldTag::__label),
1671 "populateTravelStepPolylines" => {
1672 Ok(__FieldTag::__populate_travel_step_polylines)
1673 }
1674 "populate_travel_step_polylines" => {
1675 Ok(__FieldTag::__populate_travel_step_polylines)
1676 }
1677 _ => Ok(__FieldTag::Unknown(value.to_string())),
1678 }
1679 }
1680 }
1681 deserializer.deserialize_identifier(Visitor)
1682 }
1683 }
1684 struct Visitor;
1685 impl<'de> serde::de::Visitor<'de> for Visitor {
1686 type Value = OptimizeToursRequest;
1687 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1688 formatter.write_str("struct OptimizeToursRequest")
1689 }
1690 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1691 where
1692 A: serde::de::MapAccess<'de>,
1693 {
1694 #[allow(unused_imports)]
1695 use serde::de::Error;
1696 use std::option::Option::Some;
1697 let mut fields = std::collections::HashSet::new();
1698 let mut result = Self::Value::new();
1699 while let Some(tag) = map.next_key::<__FieldTag>()? {
1700 #[allow(clippy::match_single_binding)]
1701 match tag {
1702 __FieldTag::__parent => {
1703 if !fields.insert(__FieldTag::__parent) {
1704 return std::result::Result::Err(A::Error::duplicate_field(
1705 "multiple values for parent",
1706 ));
1707 }
1708 result.parent = map
1709 .next_value::<std::option::Option<std::string::String>>()?
1710 .unwrap_or_default();
1711 }
1712 __FieldTag::__timeout => {
1713 if !fields.insert(__FieldTag::__timeout) {
1714 return std::result::Result::Err(A::Error::duplicate_field(
1715 "multiple values for timeout",
1716 ));
1717 }
1718 result.timeout =
1719 map.next_value::<std::option::Option<wkt::Duration>>()?;
1720 }
1721 __FieldTag::__model => {
1722 if !fields.insert(__FieldTag::__model) {
1723 return std::result::Result::Err(A::Error::duplicate_field(
1724 "multiple values for model",
1725 ));
1726 }
1727 result.model = map
1728 .next_value::<std::option::Option<crate::model::ShipmentModel>>()?;
1729 }
1730 __FieldTag::__solving_mode => {
1731 if !fields.insert(__FieldTag::__solving_mode) {
1732 return std::result::Result::Err(A::Error::duplicate_field(
1733 "multiple values for solving_mode",
1734 ));
1735 }
1736 result.solving_mode = map
1737 .next_value::<std::option::Option<
1738 crate::model::optimize_tours_request::SolvingMode,
1739 >>()?
1740 .unwrap_or_default();
1741 }
1742 __FieldTag::__search_mode => {
1743 if !fields.insert(__FieldTag::__search_mode) {
1744 return std::result::Result::Err(A::Error::duplicate_field(
1745 "multiple values for search_mode",
1746 ));
1747 }
1748 result.search_mode = map
1749 .next_value::<std::option::Option<
1750 crate::model::optimize_tours_request::SearchMode,
1751 >>()?
1752 .unwrap_or_default();
1753 }
1754 __FieldTag::__injected_first_solution_routes => {
1755 if !fields.insert(__FieldTag::__injected_first_solution_routes) {
1756 return std::result::Result::Err(A::Error::duplicate_field(
1757 "multiple values for injected_first_solution_routes",
1758 ));
1759 }
1760 result.injected_first_solution_routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
1761 }
1762 __FieldTag::__injected_solution_constraint => {
1763 if !fields.insert(__FieldTag::__injected_solution_constraint) {
1764 return std::result::Result::Err(A::Error::duplicate_field(
1765 "multiple values for injected_solution_constraint",
1766 ));
1767 }
1768 result.injected_solution_constraint = map.next_value::<std::option::Option<crate::model::InjectedSolutionConstraint>>()?
1769 ;
1770 }
1771 __FieldTag::__refresh_details_routes => {
1772 if !fields.insert(__FieldTag::__refresh_details_routes) {
1773 return std::result::Result::Err(A::Error::duplicate_field(
1774 "multiple values for refresh_details_routes",
1775 ));
1776 }
1777 result.refresh_details_routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
1778 }
1779 __FieldTag::__interpret_injected_solutions_using_labels => {
1780 if !fields
1781 .insert(__FieldTag::__interpret_injected_solutions_using_labels)
1782 {
1783 return std::result::Result::Err(A::Error::duplicate_field(
1784 "multiple values for interpret_injected_solutions_using_labels",
1785 ));
1786 }
1787 result.interpret_injected_solutions_using_labels = map
1788 .next_value::<std::option::Option<bool>>()?
1789 .unwrap_or_default();
1790 }
1791 __FieldTag::__consider_road_traffic => {
1792 if !fields.insert(__FieldTag::__consider_road_traffic) {
1793 return std::result::Result::Err(A::Error::duplicate_field(
1794 "multiple values for consider_road_traffic",
1795 ));
1796 }
1797 result.consider_road_traffic = map
1798 .next_value::<std::option::Option<bool>>()?
1799 .unwrap_or_default();
1800 }
1801 __FieldTag::__populate_polylines => {
1802 if !fields.insert(__FieldTag::__populate_polylines) {
1803 return std::result::Result::Err(A::Error::duplicate_field(
1804 "multiple values for populate_polylines",
1805 ));
1806 }
1807 result.populate_polylines = map
1808 .next_value::<std::option::Option<bool>>()?
1809 .unwrap_or_default();
1810 }
1811 __FieldTag::__populate_transition_polylines => {
1812 if !fields.insert(__FieldTag::__populate_transition_polylines) {
1813 return std::result::Result::Err(A::Error::duplicate_field(
1814 "multiple values for populate_transition_polylines",
1815 ));
1816 }
1817 result.populate_transition_polylines = map
1818 .next_value::<std::option::Option<bool>>()?
1819 .unwrap_or_default();
1820 }
1821 __FieldTag::__allow_large_deadline_despite_interruption_risk => {
1822 if !fields.insert(
1823 __FieldTag::__allow_large_deadline_despite_interruption_risk,
1824 ) {
1825 return std::result::Result::Err(A::Error::duplicate_field(
1826 "multiple values for allow_large_deadline_despite_interruption_risk",
1827 ));
1828 }
1829 result.allow_large_deadline_despite_interruption_risk = map
1830 .next_value::<std::option::Option<bool>>()?
1831 .unwrap_or_default();
1832 }
1833 __FieldTag::__use_geodesic_distances => {
1834 if !fields.insert(__FieldTag::__use_geodesic_distances) {
1835 return std::result::Result::Err(A::Error::duplicate_field(
1836 "multiple values for use_geodesic_distances",
1837 ));
1838 }
1839 result.use_geodesic_distances = map
1840 .next_value::<std::option::Option<bool>>()?
1841 .unwrap_or_default();
1842 }
1843 __FieldTag::__geodesic_meters_per_second => {
1844 if !fields.insert(__FieldTag::__geodesic_meters_per_second) {
1845 return std::result::Result::Err(A::Error::duplicate_field(
1846 "multiple values for geodesic_meters_per_second",
1847 ));
1848 }
1849 struct __With(std::option::Option<f64>);
1850 impl<'de> serde::de::Deserialize<'de> for __With {
1851 fn deserialize<D>(
1852 deserializer: D,
1853 ) -> std::result::Result<Self, D::Error>
1854 where
1855 D: serde::de::Deserializer<'de>,
1856 {
1857 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1858 }
1859 }
1860 result.geodesic_meters_per_second = map.next_value::<__With>()?.0;
1861 }
1862 __FieldTag::__max_validation_errors => {
1863 if !fields.insert(__FieldTag::__max_validation_errors) {
1864 return std::result::Result::Err(A::Error::duplicate_field(
1865 "multiple values for max_validation_errors",
1866 ));
1867 }
1868 struct __With(std::option::Option<i32>);
1869 impl<'de> serde::de::Deserialize<'de> for __With {
1870 fn deserialize<D>(
1871 deserializer: D,
1872 ) -> std::result::Result<Self, D::Error>
1873 where
1874 D: serde::de::Deserializer<'de>,
1875 {
1876 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1877 }
1878 }
1879 result.max_validation_errors = map.next_value::<__With>()?.0;
1880 }
1881 __FieldTag::__label => {
1882 if !fields.insert(__FieldTag::__label) {
1883 return std::result::Result::Err(A::Error::duplicate_field(
1884 "multiple values for label",
1885 ));
1886 }
1887 result.label = map
1888 .next_value::<std::option::Option<std::string::String>>()?
1889 .unwrap_or_default();
1890 }
1891 __FieldTag::__populate_travel_step_polylines => {
1892 if !fields.insert(__FieldTag::__populate_travel_step_polylines) {
1893 return std::result::Result::Err(A::Error::duplicate_field(
1894 "multiple values for populate_travel_step_polylines",
1895 ));
1896 }
1897 result.populate_travel_step_polylines = map
1898 .next_value::<std::option::Option<bool>>()?
1899 .unwrap_or_default();
1900 }
1901 __FieldTag::Unknown(key) => {
1902 let value = map.next_value::<serde_json::Value>()?;
1903 result._unknown_fields.insert(key, value);
1904 }
1905 }
1906 }
1907 std::result::Result::Ok(result)
1908 }
1909 }
1910 deserializer.deserialize_any(Visitor)
1911 }
1912}
1913
1914#[doc(hidden)]
1915impl serde::ser::Serialize for OptimizeToursRequest {
1916 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1917 where
1918 S: serde::ser::Serializer,
1919 {
1920 use serde::ser::SerializeMap;
1921 #[allow(unused_imports)]
1922 use std::option::Option::Some;
1923 let mut state = serializer.serialize_map(std::option::Option::None)?;
1924 if !self.parent.is_empty() {
1925 state.serialize_entry("parent", &self.parent)?;
1926 }
1927 if self.timeout.is_some() {
1928 state.serialize_entry("timeout", &self.timeout)?;
1929 }
1930 if self.model.is_some() {
1931 state.serialize_entry("model", &self.model)?;
1932 }
1933 if !wkt::internal::is_default(&self.solving_mode) {
1934 state.serialize_entry("solvingMode", &self.solving_mode)?;
1935 }
1936 if !wkt::internal::is_default(&self.search_mode) {
1937 state.serialize_entry("searchMode", &self.search_mode)?;
1938 }
1939 if !self.injected_first_solution_routes.is_empty() {
1940 state.serialize_entry(
1941 "injectedFirstSolutionRoutes",
1942 &self.injected_first_solution_routes,
1943 )?;
1944 }
1945 if self.injected_solution_constraint.is_some() {
1946 state.serialize_entry(
1947 "injectedSolutionConstraint",
1948 &self.injected_solution_constraint,
1949 )?;
1950 }
1951 if !self.refresh_details_routes.is_empty() {
1952 state.serialize_entry("refreshDetailsRoutes", &self.refresh_details_routes)?;
1953 }
1954 if !wkt::internal::is_default(&self.interpret_injected_solutions_using_labels) {
1955 state.serialize_entry(
1956 "interpretInjectedSolutionsUsingLabels",
1957 &self.interpret_injected_solutions_using_labels,
1958 )?;
1959 }
1960 if !wkt::internal::is_default(&self.consider_road_traffic) {
1961 state.serialize_entry("considerRoadTraffic", &self.consider_road_traffic)?;
1962 }
1963 if !wkt::internal::is_default(&self.populate_polylines) {
1964 state.serialize_entry("populatePolylines", &self.populate_polylines)?;
1965 }
1966 if !wkt::internal::is_default(&self.populate_transition_polylines) {
1967 state.serialize_entry(
1968 "populateTransitionPolylines",
1969 &self.populate_transition_polylines,
1970 )?;
1971 }
1972 if !wkt::internal::is_default(&self.allow_large_deadline_despite_interruption_risk) {
1973 state.serialize_entry(
1974 "allowLargeDeadlineDespiteInterruptionRisk",
1975 &self.allow_large_deadline_despite_interruption_risk,
1976 )?;
1977 }
1978 if !wkt::internal::is_default(&self.use_geodesic_distances) {
1979 state.serialize_entry("useGeodesicDistances", &self.use_geodesic_distances)?;
1980 }
1981 if self.geodesic_meters_per_second.is_some() {
1982 struct __With<'a>(&'a std::option::Option<f64>);
1983 impl<'a> serde::ser::Serialize for __With<'a> {
1984 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1985 where
1986 S: serde::ser::Serializer,
1987 {
1988 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
1989 self.0, serializer,
1990 )
1991 }
1992 }
1993 state.serialize_entry(
1994 "geodesicMetersPerSecond",
1995 &__With(&self.geodesic_meters_per_second),
1996 )?;
1997 }
1998 if self.max_validation_errors.is_some() {
1999 struct __With<'a>(&'a std::option::Option<i32>);
2000 impl<'a> serde::ser::Serialize for __With<'a> {
2001 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2002 where
2003 S: serde::ser::Serializer,
2004 {
2005 serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
2006 self.0, serializer,
2007 )
2008 }
2009 }
2010 state.serialize_entry("maxValidationErrors", &__With(&self.max_validation_errors))?;
2011 }
2012 if !self.label.is_empty() {
2013 state.serialize_entry("label", &self.label)?;
2014 }
2015 if !wkt::internal::is_default(&self.populate_travel_step_polylines) {
2016 state.serialize_entry(
2017 "populateTravelStepPolylines",
2018 &self.populate_travel_step_polylines,
2019 )?;
2020 }
2021 if !self._unknown_fields.is_empty() {
2022 for (key, value) in self._unknown_fields.iter() {
2023 state.serialize_entry(key, &value)?;
2024 }
2025 }
2026 state.end()
2027 }
2028}
2029
2030pub mod optimize_tours_request {
2032 #[allow(unused_imports)]
2033 use super::*;
2034
2035 #[derive(Clone, Debug, PartialEq)]
2057 #[non_exhaustive]
2058 pub enum SolvingMode {
2059 DefaultSolve,
2061 ValidateOnly,
2067 DetectSomeInfeasibleShipments,
2086 UnknownValue(solving_mode::UnknownValue),
2091 }
2092
2093 #[doc(hidden)]
2094 pub mod solving_mode {
2095 #[allow(unused_imports)]
2096 use super::*;
2097 #[derive(Clone, Debug, PartialEq)]
2098 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2099 }
2100
2101 impl SolvingMode {
2102 pub fn value(&self) -> std::option::Option<i32> {
2107 match self {
2108 Self::DefaultSolve => std::option::Option::Some(0),
2109 Self::ValidateOnly => std::option::Option::Some(1),
2110 Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
2111 Self::UnknownValue(u) => u.0.value(),
2112 }
2113 }
2114
2115 pub fn name(&self) -> std::option::Option<&str> {
2120 match self {
2121 Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
2122 Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
2123 Self::DetectSomeInfeasibleShipments => {
2124 std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
2125 }
2126 Self::UnknownValue(u) => u.0.name(),
2127 }
2128 }
2129 }
2130
2131 impl std::default::Default for SolvingMode {
2132 fn default() -> Self {
2133 use std::convert::From;
2134 Self::from(0)
2135 }
2136 }
2137
2138 impl std::fmt::Display for SolvingMode {
2139 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2140 wkt::internal::display_enum(f, self.name(), self.value())
2141 }
2142 }
2143
2144 impl std::convert::From<i32> for SolvingMode {
2145 fn from(value: i32) -> Self {
2146 match value {
2147 0 => Self::DefaultSolve,
2148 1 => Self::ValidateOnly,
2149 2 => Self::DetectSomeInfeasibleShipments,
2150 _ => Self::UnknownValue(solving_mode::UnknownValue(
2151 wkt::internal::UnknownEnumValue::Integer(value),
2152 )),
2153 }
2154 }
2155 }
2156
2157 impl std::convert::From<&str> for SolvingMode {
2158 fn from(value: &str) -> Self {
2159 use std::string::ToString;
2160 match value {
2161 "DEFAULT_SOLVE" => Self::DefaultSolve,
2162 "VALIDATE_ONLY" => Self::ValidateOnly,
2163 "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
2164 _ => Self::UnknownValue(solving_mode::UnknownValue(
2165 wkt::internal::UnknownEnumValue::String(value.to_string()),
2166 )),
2167 }
2168 }
2169 }
2170
2171 impl serde::ser::Serialize for SolvingMode {
2172 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2173 where
2174 S: serde::Serializer,
2175 {
2176 match self {
2177 Self::DefaultSolve => serializer.serialize_i32(0),
2178 Self::ValidateOnly => serializer.serialize_i32(1),
2179 Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
2180 Self::UnknownValue(u) => u.0.serialize(serializer),
2181 }
2182 }
2183 }
2184
2185 impl<'de> serde::de::Deserialize<'de> for SolvingMode {
2186 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2187 where
2188 D: serde::Deserializer<'de>,
2189 {
2190 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
2191 ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
2192 ))
2193 }
2194 }
2195
2196 #[derive(Clone, Debug, PartialEq)]
2213 #[non_exhaustive]
2214 pub enum SearchMode {
2215 Unspecified,
2217 ReturnFast,
2219 ConsumeAllAvailableTime,
2221 UnknownValue(search_mode::UnknownValue),
2226 }
2227
2228 #[doc(hidden)]
2229 pub mod search_mode {
2230 #[allow(unused_imports)]
2231 use super::*;
2232 #[derive(Clone, Debug, PartialEq)]
2233 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2234 }
2235
2236 impl SearchMode {
2237 pub fn value(&self) -> std::option::Option<i32> {
2242 match self {
2243 Self::Unspecified => std::option::Option::Some(0),
2244 Self::ReturnFast => std::option::Option::Some(1),
2245 Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
2246 Self::UnknownValue(u) => u.0.value(),
2247 }
2248 }
2249
2250 pub fn name(&self) -> std::option::Option<&str> {
2255 match self {
2256 Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
2257 Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
2258 Self::ConsumeAllAvailableTime => {
2259 std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
2260 }
2261 Self::UnknownValue(u) => u.0.name(),
2262 }
2263 }
2264 }
2265
2266 impl std::default::Default for SearchMode {
2267 fn default() -> Self {
2268 use std::convert::From;
2269 Self::from(0)
2270 }
2271 }
2272
2273 impl std::fmt::Display for SearchMode {
2274 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2275 wkt::internal::display_enum(f, self.name(), self.value())
2276 }
2277 }
2278
2279 impl std::convert::From<i32> for SearchMode {
2280 fn from(value: i32) -> Self {
2281 match value {
2282 0 => Self::Unspecified,
2283 1 => Self::ReturnFast,
2284 2 => Self::ConsumeAllAvailableTime,
2285 _ => Self::UnknownValue(search_mode::UnknownValue(
2286 wkt::internal::UnknownEnumValue::Integer(value),
2287 )),
2288 }
2289 }
2290 }
2291
2292 impl std::convert::From<&str> for SearchMode {
2293 fn from(value: &str) -> Self {
2294 use std::string::ToString;
2295 match value {
2296 "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
2297 "RETURN_FAST" => Self::ReturnFast,
2298 "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
2299 _ => Self::UnknownValue(search_mode::UnknownValue(
2300 wkt::internal::UnknownEnumValue::String(value.to_string()),
2301 )),
2302 }
2303 }
2304 }
2305
2306 impl serde::ser::Serialize for SearchMode {
2307 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2308 where
2309 S: serde::Serializer,
2310 {
2311 match self {
2312 Self::Unspecified => serializer.serialize_i32(0),
2313 Self::ReturnFast => serializer.serialize_i32(1),
2314 Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
2315 Self::UnknownValue(u) => u.0.serialize(serializer),
2316 }
2317 }
2318 }
2319
2320 impl<'de> serde::de::Deserialize<'de> for SearchMode {
2321 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2322 where
2323 D: serde::Deserializer<'de>,
2324 {
2325 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
2326 ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
2327 ))
2328 }
2329 }
2330}
2331
2332#[derive(Clone, Debug, Default, PartialEq)]
2336#[non_exhaustive]
2337pub struct OptimizeToursResponse {
2338 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
2341
2342 pub request_label: std::string::String,
2348
2349 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
2351
2352 pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
2359
2360 pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
2362
2363 #[deprecated]
2371 pub total_cost: f64,
2372
2373 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2374}
2375
2376impl OptimizeToursResponse {
2377 pub fn new() -> Self {
2378 std::default::Default::default()
2379 }
2380
2381 pub fn set_routes<T, V>(mut self, v: T) -> Self
2383 where
2384 T: std::iter::IntoIterator<Item = V>,
2385 V: std::convert::Into<crate::model::ShipmentRoute>,
2386 {
2387 use std::iter::Iterator;
2388 self.routes = v.into_iter().map(|i| i.into()).collect();
2389 self
2390 }
2391
2392 pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2394 self.request_label = v.into();
2395 self
2396 }
2397
2398 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
2400 where
2401 T: std::iter::IntoIterator<Item = V>,
2402 V: std::convert::Into<crate::model::SkippedShipment>,
2403 {
2404 use std::iter::Iterator;
2405 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
2406 self
2407 }
2408
2409 pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
2411 where
2412 T: std::iter::IntoIterator<Item = V>,
2413 V: std::convert::Into<crate::model::OptimizeToursValidationError>,
2414 {
2415 use std::iter::Iterator;
2416 self.validation_errors = v.into_iter().map(|i| i.into()).collect();
2417 self
2418 }
2419
2420 pub fn set_metrics<T>(mut self, v: T) -> Self
2422 where
2423 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
2424 {
2425 self.metrics = std::option::Option::Some(v.into());
2426 self
2427 }
2428
2429 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
2431 where
2432 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
2433 {
2434 self.metrics = v.map(|x| x.into());
2435 self
2436 }
2437
2438 #[deprecated]
2440 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2441 self.total_cost = v.into();
2442 self
2443 }
2444}
2445
2446impl wkt::message::Message for OptimizeToursResponse {
2447 fn typename() -> &'static str {
2448 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
2449 }
2450}
2451
2452#[doc(hidden)]
2453impl<'de> serde::de::Deserialize<'de> for OptimizeToursResponse {
2454 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2455 where
2456 D: serde::Deserializer<'de>,
2457 {
2458 #[allow(non_camel_case_types)]
2459 #[doc(hidden)]
2460 #[derive(PartialEq, Eq, Hash)]
2461 enum __FieldTag {
2462 __routes,
2463 __request_label,
2464 __skipped_shipments,
2465 __validation_errors,
2466 __metrics,
2467 __total_cost,
2468 Unknown(std::string::String),
2469 }
2470 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2471 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2472 where
2473 D: serde::Deserializer<'de>,
2474 {
2475 struct Visitor;
2476 impl<'de> serde::de::Visitor<'de> for Visitor {
2477 type Value = __FieldTag;
2478 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2479 formatter.write_str("a field name for OptimizeToursResponse")
2480 }
2481 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2482 where
2483 E: serde::de::Error,
2484 {
2485 use std::result::Result::Ok;
2486 use std::string::ToString;
2487 match value {
2488 "routes" => Ok(__FieldTag::__routes),
2489 "requestLabel" => Ok(__FieldTag::__request_label),
2490 "request_label" => Ok(__FieldTag::__request_label),
2491 "skippedShipments" => Ok(__FieldTag::__skipped_shipments),
2492 "skipped_shipments" => Ok(__FieldTag::__skipped_shipments),
2493 "validationErrors" => Ok(__FieldTag::__validation_errors),
2494 "validation_errors" => Ok(__FieldTag::__validation_errors),
2495 "metrics" => Ok(__FieldTag::__metrics),
2496 "totalCost" => Ok(__FieldTag::__total_cost),
2497 "total_cost" => Ok(__FieldTag::__total_cost),
2498 _ => Ok(__FieldTag::Unknown(value.to_string())),
2499 }
2500 }
2501 }
2502 deserializer.deserialize_identifier(Visitor)
2503 }
2504 }
2505 struct Visitor;
2506 impl<'de> serde::de::Visitor<'de> for Visitor {
2507 type Value = OptimizeToursResponse;
2508 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2509 formatter.write_str("struct OptimizeToursResponse")
2510 }
2511 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2512 where
2513 A: serde::de::MapAccess<'de>,
2514 {
2515 #[allow(unused_imports)]
2516 use serde::de::Error;
2517 use std::option::Option::Some;
2518 let mut fields = std::collections::HashSet::new();
2519 let mut result = Self::Value::new();
2520 while let Some(tag) = map.next_key::<__FieldTag>()? {
2521 #[allow(clippy::match_single_binding)]
2522 match tag {
2523 __FieldTag::__routes => {
2524 if !fields.insert(__FieldTag::__routes) {
2525 return std::result::Result::Err(A::Error::duplicate_field(
2526 "multiple values for routes",
2527 ));
2528 }
2529 result.routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
2530 }
2531 __FieldTag::__request_label => {
2532 if !fields.insert(__FieldTag::__request_label) {
2533 return std::result::Result::Err(A::Error::duplicate_field(
2534 "multiple values for request_label",
2535 ));
2536 }
2537 result.request_label = map
2538 .next_value::<std::option::Option<std::string::String>>()?
2539 .unwrap_or_default();
2540 }
2541 __FieldTag::__skipped_shipments => {
2542 if !fields.insert(__FieldTag::__skipped_shipments) {
2543 return std::result::Result::Err(A::Error::duplicate_field(
2544 "multiple values for skipped_shipments",
2545 ));
2546 }
2547 result.skipped_shipments =
2548 map.next_value::<std::option::Option<
2549 std::vec::Vec<crate::model::SkippedShipment>,
2550 >>()?
2551 .unwrap_or_default();
2552 }
2553 __FieldTag::__validation_errors => {
2554 if !fields.insert(__FieldTag::__validation_errors) {
2555 return std::result::Result::Err(A::Error::duplicate_field(
2556 "multiple values for validation_errors",
2557 ));
2558 }
2559 result.validation_errors = map
2560 .next_value::<std::option::Option<
2561 std::vec::Vec<crate::model::OptimizeToursValidationError>,
2562 >>()?
2563 .unwrap_or_default();
2564 }
2565 __FieldTag::__metrics => {
2566 if !fields.insert(__FieldTag::__metrics) {
2567 return std::result::Result::Err(A::Error::duplicate_field(
2568 "multiple values for metrics",
2569 ));
2570 }
2571 result.metrics = map.next_value::<std::option::Option<
2572 crate::model::optimize_tours_response::Metrics,
2573 >>()?;
2574 }
2575 __FieldTag::__total_cost => {
2576 if !fields.insert(__FieldTag::__total_cost) {
2577 return std::result::Result::Err(A::Error::duplicate_field(
2578 "multiple values for total_cost",
2579 ));
2580 }
2581 struct __With(std::option::Option<f64>);
2582 impl<'de> serde::de::Deserialize<'de> for __With {
2583 fn deserialize<D>(
2584 deserializer: D,
2585 ) -> std::result::Result<Self, D::Error>
2586 where
2587 D: serde::de::Deserializer<'de>,
2588 {
2589 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
2590 }
2591 }
2592 result.total_cost = map.next_value::<__With>()?.0.unwrap_or_default();
2593 }
2594 __FieldTag::Unknown(key) => {
2595 let value = map.next_value::<serde_json::Value>()?;
2596 result._unknown_fields.insert(key, value);
2597 }
2598 }
2599 }
2600 std::result::Result::Ok(result)
2601 }
2602 }
2603 deserializer.deserialize_any(Visitor)
2604 }
2605}
2606
2607#[doc(hidden)]
2608impl serde::ser::Serialize for OptimizeToursResponse {
2609 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2610 where
2611 S: serde::ser::Serializer,
2612 {
2613 use serde::ser::SerializeMap;
2614 #[allow(unused_imports)]
2615 use std::option::Option::Some;
2616 let mut state = serializer.serialize_map(std::option::Option::None)?;
2617 if !self.routes.is_empty() {
2618 state.serialize_entry("routes", &self.routes)?;
2619 }
2620 if !self.request_label.is_empty() {
2621 state.serialize_entry("requestLabel", &self.request_label)?;
2622 }
2623 if !self.skipped_shipments.is_empty() {
2624 state.serialize_entry("skippedShipments", &self.skipped_shipments)?;
2625 }
2626 if !self.validation_errors.is_empty() {
2627 state.serialize_entry("validationErrors", &self.validation_errors)?;
2628 }
2629 if self.metrics.is_some() {
2630 state.serialize_entry("metrics", &self.metrics)?;
2631 }
2632 if !wkt::internal::is_default(&self.total_cost) {
2633 struct __With<'a>(&'a f64);
2634 impl<'a> serde::ser::Serialize for __With<'a> {
2635 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2636 where
2637 S: serde::ser::Serializer,
2638 {
2639 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2640 }
2641 }
2642 state.serialize_entry("totalCost", &__With(&self.total_cost))?;
2643 }
2644 if !self._unknown_fields.is_empty() {
2645 for (key, value) in self._unknown_fields.iter() {
2646 state.serialize_entry(key, &value)?;
2647 }
2648 }
2649 state.end()
2650 }
2651}
2652
2653pub mod optimize_tours_response {
2655 #[allow(unused_imports)]
2656 use super::*;
2657
2658 #[derive(Clone, Debug, Default, PartialEq)]
2660 #[non_exhaustive]
2661 pub struct Metrics {
2662 pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
2669
2670 pub skipped_mandatory_shipment_count: i32,
2672
2673 pub used_vehicle_count: i32,
2679
2680 pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
2686
2687 pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
2693
2694 pub costs: std::collections::HashMap<std::string::String, f64>,
2704
2705 pub total_cost: f64,
2707
2708 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2709 }
2710
2711 impl Metrics {
2712 pub fn new() -> Self {
2713 std::default::Default::default()
2714 }
2715
2716 pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
2718 where
2719 T: std::convert::Into<crate::model::AggregatedMetrics>,
2720 {
2721 self.aggregated_route_metrics = std::option::Option::Some(v.into());
2722 self
2723 }
2724
2725 pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
2727 where
2728 T: std::convert::Into<crate::model::AggregatedMetrics>,
2729 {
2730 self.aggregated_route_metrics = v.map(|x| x.into());
2731 self
2732 }
2733
2734 pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
2736 mut self,
2737 v: T,
2738 ) -> Self {
2739 self.skipped_mandatory_shipment_count = v.into();
2740 self
2741 }
2742
2743 pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2745 self.used_vehicle_count = v.into();
2746 self
2747 }
2748
2749 pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
2751 where
2752 T: std::convert::Into<wkt::Timestamp>,
2753 {
2754 self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
2755 self
2756 }
2757
2758 pub fn set_or_clear_earliest_vehicle_start_time<T>(
2760 mut self,
2761 v: std::option::Option<T>,
2762 ) -> Self
2763 where
2764 T: std::convert::Into<wkt::Timestamp>,
2765 {
2766 self.earliest_vehicle_start_time = v.map(|x| x.into());
2767 self
2768 }
2769
2770 pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
2772 where
2773 T: std::convert::Into<wkt::Timestamp>,
2774 {
2775 self.latest_vehicle_end_time = std::option::Option::Some(v.into());
2776 self
2777 }
2778
2779 pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2781 where
2782 T: std::convert::Into<wkt::Timestamp>,
2783 {
2784 self.latest_vehicle_end_time = v.map(|x| x.into());
2785 self
2786 }
2787
2788 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
2790 where
2791 T: std::iter::IntoIterator<Item = (K, V)>,
2792 K: std::convert::Into<std::string::String>,
2793 V: std::convert::Into<f64>,
2794 {
2795 use std::iter::Iterator;
2796 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2797 self
2798 }
2799
2800 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2802 self.total_cost = v.into();
2803 self
2804 }
2805 }
2806
2807 impl wkt::message::Message for Metrics {
2808 fn typename() -> &'static str {
2809 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
2810 }
2811 }
2812
2813 #[doc(hidden)]
2814 impl<'de> serde::de::Deserialize<'de> for Metrics {
2815 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2816 where
2817 D: serde::Deserializer<'de>,
2818 {
2819 #[allow(non_camel_case_types)]
2820 #[doc(hidden)]
2821 #[derive(PartialEq, Eq, Hash)]
2822 enum __FieldTag {
2823 __aggregated_route_metrics,
2824 __skipped_mandatory_shipment_count,
2825 __used_vehicle_count,
2826 __earliest_vehicle_start_time,
2827 __latest_vehicle_end_time,
2828 __costs,
2829 __total_cost,
2830 Unknown(std::string::String),
2831 }
2832 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2833 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2834 where
2835 D: serde::Deserializer<'de>,
2836 {
2837 struct Visitor;
2838 impl<'de> serde::de::Visitor<'de> for Visitor {
2839 type Value = __FieldTag;
2840 fn expecting(
2841 &self,
2842 formatter: &mut std::fmt::Formatter,
2843 ) -> std::fmt::Result {
2844 formatter.write_str("a field name for Metrics")
2845 }
2846 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2847 where
2848 E: serde::de::Error,
2849 {
2850 use std::result::Result::Ok;
2851 use std::string::ToString;
2852 match value {
2853 "aggregatedRouteMetrics" => {
2854 Ok(__FieldTag::__aggregated_route_metrics)
2855 }
2856 "aggregated_route_metrics" => {
2857 Ok(__FieldTag::__aggregated_route_metrics)
2858 }
2859 "skippedMandatoryShipmentCount" => {
2860 Ok(__FieldTag::__skipped_mandatory_shipment_count)
2861 }
2862 "skipped_mandatory_shipment_count" => {
2863 Ok(__FieldTag::__skipped_mandatory_shipment_count)
2864 }
2865 "usedVehicleCount" => Ok(__FieldTag::__used_vehicle_count),
2866 "used_vehicle_count" => Ok(__FieldTag::__used_vehicle_count),
2867 "earliestVehicleStartTime" => {
2868 Ok(__FieldTag::__earliest_vehicle_start_time)
2869 }
2870 "earliest_vehicle_start_time" => {
2871 Ok(__FieldTag::__earliest_vehicle_start_time)
2872 }
2873 "latestVehicleEndTime" => Ok(__FieldTag::__latest_vehicle_end_time),
2874 "latest_vehicle_end_time" => {
2875 Ok(__FieldTag::__latest_vehicle_end_time)
2876 }
2877 "costs" => Ok(__FieldTag::__costs),
2878 "totalCost" => Ok(__FieldTag::__total_cost),
2879 "total_cost" => Ok(__FieldTag::__total_cost),
2880 _ => Ok(__FieldTag::Unknown(value.to_string())),
2881 }
2882 }
2883 }
2884 deserializer.deserialize_identifier(Visitor)
2885 }
2886 }
2887 struct Visitor;
2888 impl<'de> serde::de::Visitor<'de> for Visitor {
2889 type Value = Metrics;
2890 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2891 formatter.write_str("struct Metrics")
2892 }
2893 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2894 where
2895 A: serde::de::MapAccess<'de>,
2896 {
2897 #[allow(unused_imports)]
2898 use serde::de::Error;
2899 use std::option::Option::Some;
2900 let mut fields = std::collections::HashSet::new();
2901 let mut result = Self::Value::new();
2902 while let Some(tag) = map.next_key::<__FieldTag>()? {
2903 #[allow(clippy::match_single_binding)]
2904 match tag {
2905 __FieldTag::__aggregated_route_metrics => {
2906 if !fields.insert(__FieldTag::__aggregated_route_metrics) {
2907 return std::result::Result::Err(A::Error::duplicate_field(
2908 "multiple values for aggregated_route_metrics",
2909 ));
2910 }
2911 result.aggregated_route_metrics = map.next_value::<std::option::Option<crate::model::AggregatedMetrics>>()?
2912 ;
2913 }
2914 __FieldTag::__skipped_mandatory_shipment_count => {
2915 if !fields.insert(__FieldTag::__skipped_mandatory_shipment_count) {
2916 return std::result::Result::Err(A::Error::duplicate_field(
2917 "multiple values for skipped_mandatory_shipment_count",
2918 ));
2919 }
2920 struct __With(std::option::Option<i32>);
2921 impl<'de> serde::de::Deserialize<'de> for __With {
2922 fn deserialize<D>(
2923 deserializer: D,
2924 ) -> std::result::Result<Self, D::Error>
2925 where
2926 D: serde::de::Deserializer<'de>,
2927 {
2928 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2929 }
2930 }
2931 result.skipped_mandatory_shipment_count =
2932 map.next_value::<__With>()?.0.unwrap_or_default();
2933 }
2934 __FieldTag::__used_vehicle_count => {
2935 if !fields.insert(__FieldTag::__used_vehicle_count) {
2936 return std::result::Result::Err(A::Error::duplicate_field(
2937 "multiple values for used_vehicle_count",
2938 ));
2939 }
2940 struct __With(std::option::Option<i32>);
2941 impl<'de> serde::de::Deserialize<'de> for __With {
2942 fn deserialize<D>(
2943 deserializer: D,
2944 ) -> std::result::Result<Self, D::Error>
2945 where
2946 D: serde::de::Deserializer<'de>,
2947 {
2948 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2949 }
2950 }
2951 result.used_vehicle_count =
2952 map.next_value::<__With>()?.0.unwrap_or_default();
2953 }
2954 __FieldTag::__earliest_vehicle_start_time => {
2955 if !fields.insert(__FieldTag::__earliest_vehicle_start_time) {
2956 return std::result::Result::Err(A::Error::duplicate_field(
2957 "multiple values for earliest_vehicle_start_time",
2958 ));
2959 }
2960 result.earliest_vehicle_start_time =
2961 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2962 }
2963 __FieldTag::__latest_vehicle_end_time => {
2964 if !fields.insert(__FieldTag::__latest_vehicle_end_time) {
2965 return std::result::Result::Err(A::Error::duplicate_field(
2966 "multiple values for latest_vehicle_end_time",
2967 ));
2968 }
2969 result.latest_vehicle_end_time =
2970 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2971 }
2972 __FieldTag::__costs => {
2973 if !fields.insert(__FieldTag::__costs) {
2974 return std::result::Result::Err(A::Error::duplicate_field(
2975 "multiple values for costs",
2976 ));
2977 }
2978 struct __With(
2979 std::option::Option<
2980 std::collections::HashMap<std::string::String, f64>,
2981 >,
2982 );
2983 impl<'de> serde::de::Deserialize<'de> for __With {
2984 fn deserialize<D>(
2985 deserializer: D,
2986 ) -> std::result::Result<Self, D::Error>
2987 where
2988 D: serde::de::Deserializer<'de>,
2989 {
2990 serde_with::As::<
2991 std::option::Option<
2992 std::collections::HashMap<
2993 serde_with::Same,
2994 wkt::internal::F64,
2995 >,
2996 >,
2997 >::deserialize(
2998 deserializer
2999 )
3000 .map(__With)
3001 }
3002 }
3003 result.costs = map.next_value::<__With>()?.0.unwrap_or_default();
3004 }
3005 __FieldTag::__total_cost => {
3006 if !fields.insert(__FieldTag::__total_cost) {
3007 return std::result::Result::Err(A::Error::duplicate_field(
3008 "multiple values for total_cost",
3009 ));
3010 }
3011 struct __With(std::option::Option<f64>);
3012 impl<'de> serde::de::Deserialize<'de> for __With {
3013 fn deserialize<D>(
3014 deserializer: D,
3015 ) -> std::result::Result<Self, D::Error>
3016 where
3017 D: serde::de::Deserializer<'de>,
3018 {
3019 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
3020 }
3021 }
3022 result.total_cost =
3023 map.next_value::<__With>()?.0.unwrap_or_default();
3024 }
3025 __FieldTag::Unknown(key) => {
3026 let value = map.next_value::<serde_json::Value>()?;
3027 result._unknown_fields.insert(key, value);
3028 }
3029 }
3030 }
3031 std::result::Result::Ok(result)
3032 }
3033 }
3034 deserializer.deserialize_any(Visitor)
3035 }
3036 }
3037
3038 #[doc(hidden)]
3039 impl serde::ser::Serialize for Metrics {
3040 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3041 where
3042 S: serde::ser::Serializer,
3043 {
3044 use serde::ser::SerializeMap;
3045 #[allow(unused_imports)]
3046 use std::option::Option::Some;
3047 let mut state = serializer.serialize_map(std::option::Option::None)?;
3048 if self.aggregated_route_metrics.is_some() {
3049 state.serialize_entry("aggregatedRouteMetrics", &self.aggregated_route_metrics)?;
3050 }
3051 if !wkt::internal::is_default(&self.skipped_mandatory_shipment_count) {
3052 struct __With<'a>(&'a i32);
3053 impl<'a> serde::ser::Serialize for __With<'a> {
3054 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3055 where
3056 S: serde::ser::Serializer,
3057 {
3058 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3059 }
3060 }
3061 state.serialize_entry(
3062 "skippedMandatoryShipmentCount",
3063 &__With(&self.skipped_mandatory_shipment_count),
3064 )?;
3065 }
3066 if !wkt::internal::is_default(&self.used_vehicle_count) {
3067 struct __With<'a>(&'a i32);
3068 impl<'a> serde::ser::Serialize for __With<'a> {
3069 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3070 where
3071 S: serde::ser::Serializer,
3072 {
3073 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3074 }
3075 }
3076 state.serialize_entry("usedVehicleCount", &__With(&self.used_vehicle_count))?;
3077 }
3078 if self.earliest_vehicle_start_time.is_some() {
3079 state.serialize_entry(
3080 "earliestVehicleStartTime",
3081 &self.earliest_vehicle_start_time,
3082 )?;
3083 }
3084 if self.latest_vehicle_end_time.is_some() {
3085 state.serialize_entry("latestVehicleEndTime", &self.latest_vehicle_end_time)?;
3086 }
3087 if !self.costs.is_empty() {
3088 struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
3089 impl<'a> serde::ser::Serialize for __With<'a> {
3090 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3091 where
3092 S: serde::ser::Serializer,
3093 {
3094 serde_with::As::<
3095 std::collections::HashMap<serde_with::Same, wkt::internal::F64>,
3096 >::serialize(self.0, serializer)
3097 }
3098 }
3099 state.serialize_entry("costs", &__With(&self.costs))?;
3100 }
3101 if !wkt::internal::is_default(&self.total_cost) {
3102 struct __With<'a>(&'a f64);
3103 impl<'a> serde::ser::Serialize for __With<'a> {
3104 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3105 where
3106 S: serde::ser::Serializer,
3107 {
3108 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
3109 }
3110 }
3111 state.serialize_entry("totalCost", &__With(&self.total_cost))?;
3112 }
3113 if !self._unknown_fields.is_empty() {
3114 for (key, value) in self._unknown_fields.iter() {
3115 state.serialize_entry(key, &value)?;
3116 }
3117 }
3118 state.end()
3119 }
3120 }
3121}
3122
3123#[derive(Clone, Debug, Default, PartialEq)]
3129#[non_exhaustive]
3130pub struct BatchOptimizeToursRequest {
3131 pub parent: std::string::String,
3137
3138 pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
3141
3142 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3143}
3144
3145impl BatchOptimizeToursRequest {
3146 pub fn new() -> Self {
3147 std::default::Default::default()
3148 }
3149
3150 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3152 self.parent = v.into();
3153 self
3154 }
3155
3156 pub fn set_model_configs<T, V>(mut self, v: T) -> Self
3158 where
3159 T: std::iter::IntoIterator<Item = V>,
3160 V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
3161 {
3162 use std::iter::Iterator;
3163 self.model_configs = v.into_iter().map(|i| i.into()).collect();
3164 self
3165 }
3166}
3167
3168impl wkt::message::Message for BatchOptimizeToursRequest {
3169 fn typename() -> &'static str {
3170 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
3171 }
3172}
3173
3174#[doc(hidden)]
3175impl<'de> serde::de::Deserialize<'de> for BatchOptimizeToursRequest {
3176 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3177 where
3178 D: serde::Deserializer<'de>,
3179 {
3180 #[allow(non_camel_case_types)]
3181 #[doc(hidden)]
3182 #[derive(PartialEq, Eq, Hash)]
3183 enum __FieldTag {
3184 __parent,
3185 __model_configs,
3186 Unknown(std::string::String),
3187 }
3188 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3189 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3190 where
3191 D: serde::Deserializer<'de>,
3192 {
3193 struct Visitor;
3194 impl<'de> serde::de::Visitor<'de> for Visitor {
3195 type Value = __FieldTag;
3196 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3197 formatter.write_str("a field name for BatchOptimizeToursRequest")
3198 }
3199 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3200 where
3201 E: serde::de::Error,
3202 {
3203 use std::result::Result::Ok;
3204 use std::string::ToString;
3205 match value {
3206 "parent" => Ok(__FieldTag::__parent),
3207 "modelConfigs" => Ok(__FieldTag::__model_configs),
3208 "model_configs" => Ok(__FieldTag::__model_configs),
3209 _ => Ok(__FieldTag::Unknown(value.to_string())),
3210 }
3211 }
3212 }
3213 deserializer.deserialize_identifier(Visitor)
3214 }
3215 }
3216 struct Visitor;
3217 impl<'de> serde::de::Visitor<'de> for Visitor {
3218 type Value = BatchOptimizeToursRequest;
3219 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3220 formatter.write_str("struct BatchOptimizeToursRequest")
3221 }
3222 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3223 where
3224 A: serde::de::MapAccess<'de>,
3225 {
3226 #[allow(unused_imports)]
3227 use serde::de::Error;
3228 use std::option::Option::Some;
3229 let mut fields = std::collections::HashSet::new();
3230 let mut result = Self::Value::new();
3231 while let Some(tag) = map.next_key::<__FieldTag>()? {
3232 #[allow(clippy::match_single_binding)]
3233 match tag {
3234 __FieldTag::__parent => {
3235 if !fields.insert(__FieldTag::__parent) {
3236 return std::result::Result::Err(A::Error::duplicate_field(
3237 "multiple values for parent",
3238 ));
3239 }
3240 result.parent = map
3241 .next_value::<std::option::Option<std::string::String>>()?
3242 .unwrap_or_default();
3243 }
3244 __FieldTag::__model_configs => {
3245 if !fields.insert(__FieldTag::__model_configs) {
3246 return std::result::Result::Err(A::Error::duplicate_field(
3247 "multiple values for model_configs",
3248 ));
3249 }
3250 result.model_configs = map.next_value::<std::option::Option<std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>>>()?.unwrap_or_default();
3251 }
3252 __FieldTag::Unknown(key) => {
3253 let value = map.next_value::<serde_json::Value>()?;
3254 result._unknown_fields.insert(key, value);
3255 }
3256 }
3257 }
3258 std::result::Result::Ok(result)
3259 }
3260 }
3261 deserializer.deserialize_any(Visitor)
3262 }
3263}
3264
3265#[doc(hidden)]
3266impl serde::ser::Serialize for BatchOptimizeToursRequest {
3267 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3268 where
3269 S: serde::ser::Serializer,
3270 {
3271 use serde::ser::SerializeMap;
3272 #[allow(unused_imports)]
3273 use std::option::Option::Some;
3274 let mut state = serializer.serialize_map(std::option::Option::None)?;
3275 if !self.parent.is_empty() {
3276 state.serialize_entry("parent", &self.parent)?;
3277 }
3278 if !self.model_configs.is_empty() {
3279 state.serialize_entry("modelConfigs", &self.model_configs)?;
3280 }
3281 if !self._unknown_fields.is_empty() {
3282 for (key, value) in self._unknown_fields.iter() {
3283 state.serialize_entry(key, &value)?;
3284 }
3285 }
3286 state.end()
3287 }
3288}
3289
3290pub mod batch_optimize_tours_request {
3292 #[allow(unused_imports)]
3293 use super::*;
3294
3295 #[derive(Clone, Debug, Default, PartialEq)]
3297 #[non_exhaustive]
3298 pub struct AsyncModelConfig {
3299 pub display_name: std::string::String,
3302
3303 pub input_config: std::option::Option<crate::model::InputConfig>,
3305
3306 pub output_config: std::option::Option<crate::model::OutputConfig>,
3308
3309 pub enable_checkpoints: bool,
3318
3319 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3320 }
3321
3322 impl AsyncModelConfig {
3323 pub fn new() -> Self {
3324 std::default::Default::default()
3325 }
3326
3327 pub fn set_display_name<T: std::convert::Into<std::string::String>>(
3329 mut self,
3330 v: T,
3331 ) -> Self {
3332 self.display_name = v.into();
3333 self
3334 }
3335
3336 pub fn set_input_config<T>(mut self, v: T) -> Self
3338 where
3339 T: std::convert::Into<crate::model::InputConfig>,
3340 {
3341 self.input_config = std::option::Option::Some(v.into());
3342 self
3343 }
3344
3345 pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
3347 where
3348 T: std::convert::Into<crate::model::InputConfig>,
3349 {
3350 self.input_config = v.map(|x| x.into());
3351 self
3352 }
3353
3354 pub fn set_output_config<T>(mut self, v: T) -> Self
3356 where
3357 T: std::convert::Into<crate::model::OutputConfig>,
3358 {
3359 self.output_config = std::option::Option::Some(v.into());
3360 self
3361 }
3362
3363 pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
3365 where
3366 T: std::convert::Into<crate::model::OutputConfig>,
3367 {
3368 self.output_config = v.map(|x| x.into());
3369 self
3370 }
3371
3372 pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3374 self.enable_checkpoints = v.into();
3375 self
3376 }
3377 }
3378
3379 impl wkt::message::Message for AsyncModelConfig {
3380 fn typename() -> &'static str {
3381 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
3382 }
3383 }
3384
3385 #[doc(hidden)]
3386 impl<'de> serde::de::Deserialize<'de> for AsyncModelConfig {
3387 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3388 where
3389 D: serde::Deserializer<'de>,
3390 {
3391 #[allow(non_camel_case_types)]
3392 #[doc(hidden)]
3393 #[derive(PartialEq, Eq, Hash)]
3394 enum __FieldTag {
3395 __display_name,
3396 __input_config,
3397 __output_config,
3398 __enable_checkpoints,
3399 Unknown(std::string::String),
3400 }
3401 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3402 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3403 where
3404 D: serde::Deserializer<'de>,
3405 {
3406 struct Visitor;
3407 impl<'de> serde::de::Visitor<'de> for Visitor {
3408 type Value = __FieldTag;
3409 fn expecting(
3410 &self,
3411 formatter: &mut std::fmt::Formatter,
3412 ) -> std::fmt::Result {
3413 formatter.write_str("a field name for AsyncModelConfig")
3414 }
3415 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3416 where
3417 E: serde::de::Error,
3418 {
3419 use std::result::Result::Ok;
3420 use std::string::ToString;
3421 match value {
3422 "displayName" => Ok(__FieldTag::__display_name),
3423 "display_name" => Ok(__FieldTag::__display_name),
3424 "inputConfig" => Ok(__FieldTag::__input_config),
3425 "input_config" => Ok(__FieldTag::__input_config),
3426 "outputConfig" => Ok(__FieldTag::__output_config),
3427 "output_config" => Ok(__FieldTag::__output_config),
3428 "enableCheckpoints" => Ok(__FieldTag::__enable_checkpoints),
3429 "enable_checkpoints" => Ok(__FieldTag::__enable_checkpoints),
3430 _ => Ok(__FieldTag::Unknown(value.to_string())),
3431 }
3432 }
3433 }
3434 deserializer.deserialize_identifier(Visitor)
3435 }
3436 }
3437 struct Visitor;
3438 impl<'de> serde::de::Visitor<'de> for Visitor {
3439 type Value = AsyncModelConfig;
3440 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3441 formatter.write_str("struct AsyncModelConfig")
3442 }
3443 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3444 where
3445 A: serde::de::MapAccess<'de>,
3446 {
3447 #[allow(unused_imports)]
3448 use serde::de::Error;
3449 use std::option::Option::Some;
3450 let mut fields = std::collections::HashSet::new();
3451 let mut result = Self::Value::new();
3452 while let Some(tag) = map.next_key::<__FieldTag>()? {
3453 #[allow(clippy::match_single_binding)]
3454 match tag {
3455 __FieldTag::__display_name => {
3456 if !fields.insert(__FieldTag::__display_name) {
3457 return std::result::Result::Err(A::Error::duplicate_field(
3458 "multiple values for display_name",
3459 ));
3460 }
3461 result.display_name = map
3462 .next_value::<std::option::Option<std::string::String>>()?
3463 .unwrap_or_default();
3464 }
3465 __FieldTag::__input_config => {
3466 if !fields.insert(__FieldTag::__input_config) {
3467 return std::result::Result::Err(A::Error::duplicate_field(
3468 "multiple values for input_config",
3469 ));
3470 }
3471 result.input_config = map
3472 .next_value::<std::option::Option<crate::model::InputConfig>>(
3473 )?;
3474 }
3475 __FieldTag::__output_config => {
3476 if !fields.insert(__FieldTag::__output_config) {
3477 return std::result::Result::Err(A::Error::duplicate_field(
3478 "multiple values for output_config",
3479 ));
3480 }
3481 result.output_config = map
3482 .next_value::<std::option::Option<crate::model::OutputConfig>>(
3483 )?;
3484 }
3485 __FieldTag::__enable_checkpoints => {
3486 if !fields.insert(__FieldTag::__enable_checkpoints) {
3487 return std::result::Result::Err(A::Error::duplicate_field(
3488 "multiple values for enable_checkpoints",
3489 ));
3490 }
3491 result.enable_checkpoints = map
3492 .next_value::<std::option::Option<bool>>()?
3493 .unwrap_or_default();
3494 }
3495 __FieldTag::Unknown(key) => {
3496 let value = map.next_value::<serde_json::Value>()?;
3497 result._unknown_fields.insert(key, value);
3498 }
3499 }
3500 }
3501 std::result::Result::Ok(result)
3502 }
3503 }
3504 deserializer.deserialize_any(Visitor)
3505 }
3506 }
3507
3508 #[doc(hidden)]
3509 impl serde::ser::Serialize for AsyncModelConfig {
3510 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3511 where
3512 S: serde::ser::Serializer,
3513 {
3514 use serde::ser::SerializeMap;
3515 #[allow(unused_imports)]
3516 use std::option::Option::Some;
3517 let mut state = serializer.serialize_map(std::option::Option::None)?;
3518 if !self.display_name.is_empty() {
3519 state.serialize_entry("displayName", &self.display_name)?;
3520 }
3521 if self.input_config.is_some() {
3522 state.serialize_entry("inputConfig", &self.input_config)?;
3523 }
3524 if self.output_config.is_some() {
3525 state.serialize_entry("outputConfig", &self.output_config)?;
3526 }
3527 if !wkt::internal::is_default(&self.enable_checkpoints) {
3528 state.serialize_entry("enableCheckpoints", &self.enable_checkpoints)?;
3529 }
3530 if !self._unknown_fields.is_empty() {
3531 for (key, value) in self._unknown_fields.iter() {
3532 state.serialize_entry(key, &value)?;
3533 }
3534 }
3535 state.end()
3536 }
3537 }
3538}
3539
3540#[derive(Clone, Debug, Default, PartialEq)]
3543#[non_exhaustive]
3544pub struct BatchOptimizeToursResponse {
3545 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3546}
3547
3548impl BatchOptimizeToursResponse {
3549 pub fn new() -> Self {
3550 std::default::Default::default()
3551 }
3552}
3553
3554impl wkt::message::Message for BatchOptimizeToursResponse {
3555 fn typename() -> &'static str {
3556 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
3557 }
3558}
3559
3560#[doc(hidden)]
3561impl<'de> serde::de::Deserialize<'de> for BatchOptimizeToursResponse {
3562 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3563 where
3564 D: serde::Deserializer<'de>,
3565 {
3566 #[allow(non_camel_case_types)]
3567 #[doc(hidden)]
3568 #[derive(PartialEq, Eq, Hash)]
3569 enum __FieldTag {
3570 Unknown(std::string::String),
3571 }
3572 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3573 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3574 where
3575 D: serde::Deserializer<'de>,
3576 {
3577 struct Visitor;
3578 impl<'de> serde::de::Visitor<'de> for Visitor {
3579 type Value = __FieldTag;
3580 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3581 formatter.write_str("a field name for BatchOptimizeToursResponse")
3582 }
3583 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3584 where
3585 E: serde::de::Error,
3586 {
3587 use std::result::Result::Ok;
3588 use std::string::ToString;
3589 Ok(__FieldTag::Unknown(value.to_string()))
3590 }
3591 }
3592 deserializer.deserialize_identifier(Visitor)
3593 }
3594 }
3595 struct Visitor;
3596 impl<'de> serde::de::Visitor<'de> for Visitor {
3597 type Value = BatchOptimizeToursResponse;
3598 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3599 formatter.write_str("struct BatchOptimizeToursResponse")
3600 }
3601 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3602 where
3603 A: serde::de::MapAccess<'de>,
3604 {
3605 #[allow(unused_imports)]
3606 use serde::de::Error;
3607 use std::option::Option::Some;
3608 let mut result = Self::Value::new();
3609 while let Some(tag) = map.next_key::<__FieldTag>()? {
3610 #[allow(clippy::match_single_binding)]
3611 match tag {
3612 __FieldTag::Unknown(key) => {
3613 let value = map.next_value::<serde_json::Value>()?;
3614 result._unknown_fields.insert(key, value);
3615 }
3616 }
3617 }
3618 std::result::Result::Ok(result)
3619 }
3620 }
3621 deserializer.deserialize_any(Visitor)
3622 }
3623}
3624
3625#[doc(hidden)]
3626impl serde::ser::Serialize for BatchOptimizeToursResponse {
3627 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3628 where
3629 S: serde::ser::Serializer,
3630 {
3631 use serde::ser::SerializeMap;
3632 #[allow(unused_imports)]
3633 use std::option::Option::Some;
3634 let mut state = serializer.serialize_map(std::option::Option::None)?;
3635 if !self._unknown_fields.is_empty() {
3636 for (key, value) in self._unknown_fields.iter() {
3637 state.serialize_entry(key, &value)?;
3638 }
3639 }
3640 state.end()
3641 }
3642}
3643
3644#[derive(Clone, Debug, Default, PartialEq)]
3652#[non_exhaustive]
3653pub struct ShipmentModel {
3654 pub shipments: std::vec::Vec<crate::model::Shipment>,
3656
3657 pub vehicles: std::vec::Vec<crate::model::Vehicle>,
3659
3660 pub max_active_vehicles: std::option::Option<i32>,
3667
3668 pub global_start_time: std::option::Option<wkt::Timestamp>,
3680
3681 pub global_end_time: std::option::Option<wkt::Timestamp>,
3684
3685 pub global_duration_cost_per_hour: f64,
3694
3695 pub duration_distance_matrices:
3782 std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
3783
3784 pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
3801
3802 pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
3821
3822 pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
3824
3825 pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
3827
3828 pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
3830
3831 pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
3833
3834 #[deprecated]
3842 pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
3843
3844 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3845}
3846
3847impl ShipmentModel {
3848 pub fn new() -> Self {
3849 std::default::Default::default()
3850 }
3851
3852 pub fn set_shipments<T, V>(mut self, v: T) -> Self
3854 where
3855 T: std::iter::IntoIterator<Item = V>,
3856 V: std::convert::Into<crate::model::Shipment>,
3857 {
3858 use std::iter::Iterator;
3859 self.shipments = v.into_iter().map(|i| i.into()).collect();
3860 self
3861 }
3862
3863 pub fn set_vehicles<T, V>(mut self, v: T) -> Self
3865 where
3866 T: std::iter::IntoIterator<Item = V>,
3867 V: std::convert::Into<crate::model::Vehicle>,
3868 {
3869 use std::iter::Iterator;
3870 self.vehicles = v.into_iter().map(|i| i.into()).collect();
3871 self
3872 }
3873
3874 pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
3876 where
3877 T: std::convert::Into<i32>,
3878 {
3879 self.max_active_vehicles = std::option::Option::Some(v.into());
3880 self
3881 }
3882
3883 pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
3885 where
3886 T: std::convert::Into<i32>,
3887 {
3888 self.max_active_vehicles = v.map(|x| x.into());
3889 self
3890 }
3891
3892 pub fn set_global_start_time<T>(mut self, v: T) -> Self
3894 where
3895 T: std::convert::Into<wkt::Timestamp>,
3896 {
3897 self.global_start_time = std::option::Option::Some(v.into());
3898 self
3899 }
3900
3901 pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3903 where
3904 T: std::convert::Into<wkt::Timestamp>,
3905 {
3906 self.global_start_time = v.map(|x| x.into());
3907 self
3908 }
3909
3910 pub fn set_global_end_time<T>(mut self, v: T) -> Self
3912 where
3913 T: std::convert::Into<wkt::Timestamp>,
3914 {
3915 self.global_end_time = std::option::Option::Some(v.into());
3916 self
3917 }
3918
3919 pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
3921 where
3922 T: std::convert::Into<wkt::Timestamp>,
3923 {
3924 self.global_end_time = v.map(|x| x.into());
3925 self
3926 }
3927
3928 pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3930 self.global_duration_cost_per_hour = v.into();
3931 self
3932 }
3933
3934 pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
3936 where
3937 T: std::iter::IntoIterator<Item = V>,
3938 V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
3939 {
3940 use std::iter::Iterator;
3941 self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
3942 self
3943 }
3944
3945 pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
3947 where
3948 T: std::iter::IntoIterator<Item = V>,
3949 V: std::convert::Into<std::string::String>,
3950 {
3951 use std::iter::Iterator;
3952 self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
3953 self
3954 }
3955
3956 pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
3958 where
3959 T: std::iter::IntoIterator<Item = V>,
3960 V: std::convert::Into<std::string::String>,
3961 {
3962 use std::iter::Iterator;
3963 self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
3964 self
3965 }
3966
3967 pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
3969 where
3970 T: std::iter::IntoIterator<Item = V>,
3971 V: std::convert::Into<crate::model::TransitionAttributes>,
3972 {
3973 use std::iter::Iterator;
3974 self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
3975 self
3976 }
3977
3978 pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
3980 where
3981 T: std::iter::IntoIterator<Item = V>,
3982 V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
3983 {
3984 use std::iter::Iterator;
3985 self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
3986 self
3987 }
3988
3989 pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
3991 where
3992 T: std::iter::IntoIterator<Item = V>,
3993 V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
3994 {
3995 use std::iter::Iterator;
3996 self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
3997 self
3998 }
3999
4000 pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
4002 where
4003 T: std::iter::IntoIterator<Item = V>,
4004 V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
4005 {
4006 use std::iter::Iterator;
4007 self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
4008 self
4009 }
4010
4011 #[deprecated]
4013 pub fn set_break_rules<T, V>(mut self, v: T) -> Self
4014 where
4015 T: std::iter::IntoIterator<Item = V>,
4016 V: std::convert::Into<crate::model::shipment_model::BreakRule>,
4017 {
4018 use std::iter::Iterator;
4019 self.break_rules = v.into_iter().map(|i| i.into()).collect();
4020 self
4021 }
4022}
4023
4024impl wkt::message::Message for ShipmentModel {
4025 fn typename() -> &'static str {
4026 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
4027 }
4028}
4029
4030#[doc(hidden)]
4031impl<'de> serde::de::Deserialize<'de> for ShipmentModel {
4032 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4033 where
4034 D: serde::Deserializer<'de>,
4035 {
4036 #[allow(non_camel_case_types)]
4037 #[doc(hidden)]
4038 #[derive(PartialEq, Eq, Hash)]
4039 enum __FieldTag {
4040 __shipments,
4041 __vehicles,
4042 __max_active_vehicles,
4043 __global_start_time,
4044 __global_end_time,
4045 __global_duration_cost_per_hour,
4046 __duration_distance_matrices,
4047 __duration_distance_matrix_src_tags,
4048 __duration_distance_matrix_dst_tags,
4049 __transition_attributes,
4050 __shipment_type_incompatibilities,
4051 __shipment_type_requirements,
4052 __precedence_rules,
4053 __break_rules,
4054 Unknown(std::string::String),
4055 }
4056 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4057 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4058 where
4059 D: serde::Deserializer<'de>,
4060 {
4061 struct Visitor;
4062 impl<'de> serde::de::Visitor<'de> for Visitor {
4063 type Value = __FieldTag;
4064 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4065 formatter.write_str("a field name for ShipmentModel")
4066 }
4067 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4068 where
4069 E: serde::de::Error,
4070 {
4071 use std::result::Result::Ok;
4072 use std::string::ToString;
4073 match value {
4074 "shipments" => Ok(__FieldTag::__shipments),
4075 "vehicles" => Ok(__FieldTag::__vehicles),
4076 "maxActiveVehicles" => Ok(__FieldTag::__max_active_vehicles),
4077 "max_active_vehicles" => Ok(__FieldTag::__max_active_vehicles),
4078 "globalStartTime" => Ok(__FieldTag::__global_start_time),
4079 "global_start_time" => Ok(__FieldTag::__global_start_time),
4080 "globalEndTime" => Ok(__FieldTag::__global_end_time),
4081 "global_end_time" => Ok(__FieldTag::__global_end_time),
4082 "globalDurationCostPerHour" => {
4083 Ok(__FieldTag::__global_duration_cost_per_hour)
4084 }
4085 "global_duration_cost_per_hour" => {
4086 Ok(__FieldTag::__global_duration_cost_per_hour)
4087 }
4088 "durationDistanceMatrices" => {
4089 Ok(__FieldTag::__duration_distance_matrices)
4090 }
4091 "duration_distance_matrices" => {
4092 Ok(__FieldTag::__duration_distance_matrices)
4093 }
4094 "durationDistanceMatrixSrcTags" => {
4095 Ok(__FieldTag::__duration_distance_matrix_src_tags)
4096 }
4097 "duration_distance_matrix_src_tags" => {
4098 Ok(__FieldTag::__duration_distance_matrix_src_tags)
4099 }
4100 "durationDistanceMatrixDstTags" => {
4101 Ok(__FieldTag::__duration_distance_matrix_dst_tags)
4102 }
4103 "duration_distance_matrix_dst_tags" => {
4104 Ok(__FieldTag::__duration_distance_matrix_dst_tags)
4105 }
4106 "transitionAttributes" => Ok(__FieldTag::__transition_attributes),
4107 "transition_attributes" => Ok(__FieldTag::__transition_attributes),
4108 "shipmentTypeIncompatibilities" => {
4109 Ok(__FieldTag::__shipment_type_incompatibilities)
4110 }
4111 "shipment_type_incompatibilities" => {
4112 Ok(__FieldTag::__shipment_type_incompatibilities)
4113 }
4114 "shipmentTypeRequirements" => {
4115 Ok(__FieldTag::__shipment_type_requirements)
4116 }
4117 "shipment_type_requirements" => {
4118 Ok(__FieldTag::__shipment_type_requirements)
4119 }
4120 "precedenceRules" => Ok(__FieldTag::__precedence_rules),
4121 "precedence_rules" => Ok(__FieldTag::__precedence_rules),
4122 "breakRules" => Ok(__FieldTag::__break_rules),
4123 "break_rules" => Ok(__FieldTag::__break_rules),
4124 _ => Ok(__FieldTag::Unknown(value.to_string())),
4125 }
4126 }
4127 }
4128 deserializer.deserialize_identifier(Visitor)
4129 }
4130 }
4131 struct Visitor;
4132 impl<'de> serde::de::Visitor<'de> for Visitor {
4133 type Value = ShipmentModel;
4134 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4135 formatter.write_str("struct ShipmentModel")
4136 }
4137 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4138 where
4139 A: serde::de::MapAccess<'de>,
4140 {
4141 #[allow(unused_imports)]
4142 use serde::de::Error;
4143 use std::option::Option::Some;
4144 let mut fields = std::collections::HashSet::new();
4145 let mut result = Self::Value::new();
4146 while let Some(tag) = map.next_key::<__FieldTag>()? {
4147 #[allow(clippy::match_single_binding)]
4148 match tag {
4149 __FieldTag::__shipments => {
4150 if !fields.insert(__FieldTag::__shipments) {
4151 return std::result::Result::Err(A::Error::duplicate_field(
4152 "multiple values for shipments",
4153 ));
4154 }
4155 result.shipments = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Shipment>>>()?.unwrap_or_default();
4156 }
4157 __FieldTag::__vehicles => {
4158 if !fields.insert(__FieldTag::__vehicles) {
4159 return std::result::Result::Err(A::Error::duplicate_field(
4160 "multiple values for vehicles",
4161 ));
4162 }
4163 result.vehicles = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Vehicle>>>()?.unwrap_or_default();
4164 }
4165 __FieldTag::__max_active_vehicles => {
4166 if !fields.insert(__FieldTag::__max_active_vehicles) {
4167 return std::result::Result::Err(A::Error::duplicate_field(
4168 "multiple values for max_active_vehicles",
4169 ));
4170 }
4171 struct __With(std::option::Option<i32>);
4172 impl<'de> serde::de::Deserialize<'de> for __With {
4173 fn deserialize<D>(
4174 deserializer: D,
4175 ) -> std::result::Result<Self, D::Error>
4176 where
4177 D: serde::de::Deserializer<'de>,
4178 {
4179 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
4180 }
4181 }
4182 result.max_active_vehicles = map.next_value::<__With>()?.0;
4183 }
4184 __FieldTag::__global_start_time => {
4185 if !fields.insert(__FieldTag::__global_start_time) {
4186 return std::result::Result::Err(A::Error::duplicate_field(
4187 "multiple values for global_start_time",
4188 ));
4189 }
4190 result.global_start_time =
4191 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4192 }
4193 __FieldTag::__global_end_time => {
4194 if !fields.insert(__FieldTag::__global_end_time) {
4195 return std::result::Result::Err(A::Error::duplicate_field(
4196 "multiple values for global_end_time",
4197 ));
4198 }
4199 result.global_end_time =
4200 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4201 }
4202 __FieldTag::__global_duration_cost_per_hour => {
4203 if !fields.insert(__FieldTag::__global_duration_cost_per_hour) {
4204 return std::result::Result::Err(A::Error::duplicate_field(
4205 "multiple values for global_duration_cost_per_hour",
4206 ));
4207 }
4208 struct __With(std::option::Option<f64>);
4209 impl<'de> serde::de::Deserialize<'de> for __With {
4210 fn deserialize<D>(
4211 deserializer: D,
4212 ) -> std::result::Result<Self, D::Error>
4213 where
4214 D: serde::de::Deserializer<'de>,
4215 {
4216 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
4217 }
4218 }
4219 result.global_duration_cost_per_hour =
4220 map.next_value::<__With>()?.0.unwrap_or_default();
4221 }
4222 __FieldTag::__duration_distance_matrices => {
4223 if !fields.insert(__FieldTag::__duration_distance_matrices) {
4224 return std::result::Result::Err(A::Error::duplicate_field(
4225 "multiple values for duration_distance_matrices",
4226 ));
4227 }
4228 result.duration_distance_matrices = map
4229 .next_value::<std::option::Option<
4230 std::vec::Vec<
4231 crate::model::shipment_model::DurationDistanceMatrix,
4232 >,
4233 >>()?
4234 .unwrap_or_default();
4235 }
4236 __FieldTag::__duration_distance_matrix_src_tags => {
4237 if !fields.insert(__FieldTag::__duration_distance_matrix_src_tags) {
4238 return std::result::Result::Err(A::Error::duplicate_field(
4239 "multiple values for duration_distance_matrix_src_tags",
4240 ));
4241 }
4242 result.duration_distance_matrix_src_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
4243 }
4244 __FieldTag::__duration_distance_matrix_dst_tags => {
4245 if !fields.insert(__FieldTag::__duration_distance_matrix_dst_tags) {
4246 return std::result::Result::Err(A::Error::duplicate_field(
4247 "multiple values for duration_distance_matrix_dst_tags",
4248 ));
4249 }
4250 result.duration_distance_matrix_dst_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
4251 }
4252 __FieldTag::__transition_attributes => {
4253 if !fields.insert(__FieldTag::__transition_attributes) {
4254 return std::result::Result::Err(A::Error::duplicate_field(
4255 "multiple values for transition_attributes",
4256 ));
4257 }
4258 result.transition_attributes = map
4259 .next_value::<std::option::Option<
4260 std::vec::Vec<crate::model::TransitionAttributes>,
4261 >>()?
4262 .unwrap_or_default();
4263 }
4264 __FieldTag::__shipment_type_incompatibilities => {
4265 if !fields.insert(__FieldTag::__shipment_type_incompatibilities) {
4266 return std::result::Result::Err(A::Error::duplicate_field(
4267 "multiple values for shipment_type_incompatibilities",
4268 ));
4269 }
4270 result.shipment_type_incompatibilities = map
4271 .next_value::<std::option::Option<
4272 std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
4273 >>()?
4274 .unwrap_or_default();
4275 }
4276 __FieldTag::__shipment_type_requirements => {
4277 if !fields.insert(__FieldTag::__shipment_type_requirements) {
4278 return std::result::Result::Err(A::Error::duplicate_field(
4279 "multiple values for shipment_type_requirements",
4280 ));
4281 }
4282 result.shipment_type_requirements = map
4283 .next_value::<std::option::Option<
4284 std::vec::Vec<crate::model::ShipmentTypeRequirement>,
4285 >>()?
4286 .unwrap_or_default();
4287 }
4288 __FieldTag::__precedence_rules => {
4289 if !fields.insert(__FieldTag::__precedence_rules) {
4290 return std::result::Result::Err(A::Error::duplicate_field(
4291 "multiple values for precedence_rules",
4292 ));
4293 }
4294 result.precedence_rules = map
4295 .next_value::<std::option::Option<
4296 std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
4297 >>()?
4298 .unwrap_or_default();
4299 }
4300 __FieldTag::__break_rules => {
4301 if !fields.insert(__FieldTag::__break_rules) {
4302 return std::result::Result::Err(A::Error::duplicate_field(
4303 "multiple values for break_rules",
4304 ));
4305 }
4306 result.break_rules = map
4307 .next_value::<std::option::Option<
4308 std::vec::Vec<crate::model::shipment_model::BreakRule>,
4309 >>()?
4310 .unwrap_or_default();
4311 }
4312 __FieldTag::Unknown(key) => {
4313 let value = map.next_value::<serde_json::Value>()?;
4314 result._unknown_fields.insert(key, value);
4315 }
4316 }
4317 }
4318 std::result::Result::Ok(result)
4319 }
4320 }
4321 deserializer.deserialize_any(Visitor)
4322 }
4323}
4324
4325#[doc(hidden)]
4326impl serde::ser::Serialize for ShipmentModel {
4327 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4328 where
4329 S: serde::ser::Serializer,
4330 {
4331 use serde::ser::SerializeMap;
4332 #[allow(unused_imports)]
4333 use std::option::Option::Some;
4334 let mut state = serializer.serialize_map(std::option::Option::None)?;
4335 if !self.shipments.is_empty() {
4336 state.serialize_entry("shipments", &self.shipments)?;
4337 }
4338 if !self.vehicles.is_empty() {
4339 state.serialize_entry("vehicles", &self.vehicles)?;
4340 }
4341 if self.max_active_vehicles.is_some() {
4342 struct __With<'a>(&'a std::option::Option<i32>);
4343 impl<'a> serde::ser::Serialize for __With<'a> {
4344 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4345 where
4346 S: serde::ser::Serializer,
4347 {
4348 serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
4349 self.0, serializer,
4350 )
4351 }
4352 }
4353 state.serialize_entry("maxActiveVehicles", &__With(&self.max_active_vehicles))?;
4354 }
4355 if self.global_start_time.is_some() {
4356 state.serialize_entry("globalStartTime", &self.global_start_time)?;
4357 }
4358 if self.global_end_time.is_some() {
4359 state.serialize_entry("globalEndTime", &self.global_end_time)?;
4360 }
4361 if !wkt::internal::is_default(&self.global_duration_cost_per_hour) {
4362 struct __With<'a>(&'a f64);
4363 impl<'a> serde::ser::Serialize for __With<'a> {
4364 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4365 where
4366 S: serde::ser::Serializer,
4367 {
4368 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
4369 }
4370 }
4371 state.serialize_entry(
4372 "globalDurationCostPerHour",
4373 &__With(&self.global_duration_cost_per_hour),
4374 )?;
4375 }
4376 if !self.duration_distance_matrices.is_empty() {
4377 state.serialize_entry("durationDistanceMatrices", &self.duration_distance_matrices)?;
4378 }
4379 if !self.duration_distance_matrix_src_tags.is_empty() {
4380 state.serialize_entry(
4381 "durationDistanceMatrixSrcTags",
4382 &self.duration_distance_matrix_src_tags,
4383 )?;
4384 }
4385 if !self.duration_distance_matrix_dst_tags.is_empty() {
4386 state.serialize_entry(
4387 "durationDistanceMatrixDstTags",
4388 &self.duration_distance_matrix_dst_tags,
4389 )?;
4390 }
4391 if !self.transition_attributes.is_empty() {
4392 state.serialize_entry("transitionAttributes", &self.transition_attributes)?;
4393 }
4394 if !self.shipment_type_incompatibilities.is_empty() {
4395 state.serialize_entry(
4396 "shipmentTypeIncompatibilities",
4397 &self.shipment_type_incompatibilities,
4398 )?;
4399 }
4400 if !self.shipment_type_requirements.is_empty() {
4401 state.serialize_entry("shipmentTypeRequirements", &self.shipment_type_requirements)?;
4402 }
4403 if !self.precedence_rules.is_empty() {
4404 state.serialize_entry("precedenceRules", &self.precedence_rules)?;
4405 }
4406 if !self.break_rules.is_empty() {
4407 state.serialize_entry("breakRules", &self.break_rules)?;
4408 }
4409 if !self._unknown_fields.is_empty() {
4410 for (key, value) in self._unknown_fields.iter() {
4411 state.serialize_entry(key, &value)?;
4412 }
4413 }
4414 state.end()
4415 }
4416}
4417
4418pub mod shipment_model {
4420 #[allow(unused_imports)]
4421 use super::*;
4422
4423 #[derive(Clone, Debug, Default, PartialEq)]
4426 #[non_exhaustive]
4427 pub struct DurationDistanceMatrix {
4428 pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
4434
4435 pub vehicle_start_tag: std::string::String,
4445
4446 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4447 }
4448
4449 impl DurationDistanceMatrix {
4450 pub fn new() -> Self {
4451 std::default::Default::default()
4452 }
4453
4454 pub fn set_rows<T, V>(mut self, v: T) -> Self
4456 where
4457 T: std::iter::IntoIterator<Item = V>,
4458 V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
4459 {
4460 use std::iter::Iterator;
4461 self.rows = v.into_iter().map(|i| i.into()).collect();
4462 self
4463 }
4464
4465 pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
4467 mut self,
4468 v: T,
4469 ) -> Self {
4470 self.vehicle_start_tag = v.into();
4471 self
4472 }
4473 }
4474
4475 impl wkt::message::Message for DurationDistanceMatrix {
4476 fn typename() -> &'static str {
4477 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
4478 }
4479 }
4480
4481 #[doc(hidden)]
4482 impl<'de> serde::de::Deserialize<'de> for DurationDistanceMatrix {
4483 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4484 where
4485 D: serde::Deserializer<'de>,
4486 {
4487 #[allow(non_camel_case_types)]
4488 #[doc(hidden)]
4489 #[derive(PartialEq, Eq, Hash)]
4490 enum __FieldTag {
4491 __rows,
4492 __vehicle_start_tag,
4493 Unknown(std::string::String),
4494 }
4495 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4496 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4497 where
4498 D: serde::Deserializer<'de>,
4499 {
4500 struct Visitor;
4501 impl<'de> serde::de::Visitor<'de> for Visitor {
4502 type Value = __FieldTag;
4503 fn expecting(
4504 &self,
4505 formatter: &mut std::fmt::Formatter,
4506 ) -> std::fmt::Result {
4507 formatter.write_str("a field name for DurationDistanceMatrix")
4508 }
4509 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4510 where
4511 E: serde::de::Error,
4512 {
4513 use std::result::Result::Ok;
4514 use std::string::ToString;
4515 match value {
4516 "rows" => Ok(__FieldTag::__rows),
4517 "vehicleStartTag" => Ok(__FieldTag::__vehicle_start_tag),
4518 "vehicle_start_tag" => Ok(__FieldTag::__vehicle_start_tag),
4519 _ => Ok(__FieldTag::Unknown(value.to_string())),
4520 }
4521 }
4522 }
4523 deserializer.deserialize_identifier(Visitor)
4524 }
4525 }
4526 struct Visitor;
4527 impl<'de> serde::de::Visitor<'de> for Visitor {
4528 type Value = DurationDistanceMatrix;
4529 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4530 formatter.write_str("struct DurationDistanceMatrix")
4531 }
4532 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4533 where
4534 A: serde::de::MapAccess<'de>,
4535 {
4536 #[allow(unused_imports)]
4537 use serde::de::Error;
4538 use std::option::Option::Some;
4539 let mut fields = std::collections::HashSet::new();
4540 let mut result = Self::Value::new();
4541 while let Some(tag) = map.next_key::<__FieldTag>()? {
4542 #[allow(clippy::match_single_binding)]
4543 match tag {
4544 __FieldTag::__rows => {
4545 if !fields.insert(__FieldTag::__rows) {
4546 return std::result::Result::Err(A::Error::duplicate_field(
4547 "multiple values for rows",
4548 ));
4549 }
4550 result.rows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>>>()?.unwrap_or_default();
4551 }
4552 __FieldTag::__vehicle_start_tag => {
4553 if !fields.insert(__FieldTag::__vehicle_start_tag) {
4554 return std::result::Result::Err(A::Error::duplicate_field(
4555 "multiple values for vehicle_start_tag",
4556 ));
4557 }
4558 result.vehicle_start_tag = map
4559 .next_value::<std::option::Option<std::string::String>>()?
4560 .unwrap_or_default();
4561 }
4562 __FieldTag::Unknown(key) => {
4563 let value = map.next_value::<serde_json::Value>()?;
4564 result._unknown_fields.insert(key, value);
4565 }
4566 }
4567 }
4568 std::result::Result::Ok(result)
4569 }
4570 }
4571 deserializer.deserialize_any(Visitor)
4572 }
4573 }
4574
4575 #[doc(hidden)]
4576 impl serde::ser::Serialize for DurationDistanceMatrix {
4577 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4578 where
4579 S: serde::ser::Serializer,
4580 {
4581 use serde::ser::SerializeMap;
4582 #[allow(unused_imports)]
4583 use std::option::Option::Some;
4584 let mut state = serializer.serialize_map(std::option::Option::None)?;
4585 if !self.rows.is_empty() {
4586 state.serialize_entry("rows", &self.rows)?;
4587 }
4588 if !self.vehicle_start_tag.is_empty() {
4589 state.serialize_entry("vehicleStartTag", &self.vehicle_start_tag)?;
4590 }
4591 if !self._unknown_fields.is_empty() {
4592 for (key, value) in self._unknown_fields.iter() {
4593 state.serialize_entry(key, &value)?;
4594 }
4595 }
4596 state.end()
4597 }
4598 }
4599
4600 pub mod duration_distance_matrix {
4602 #[allow(unused_imports)]
4603 use super::*;
4604
4605 #[derive(Clone, Debug, Default, PartialEq)]
4607 #[non_exhaustive]
4608 pub struct Row {
4609 pub durations: std::vec::Vec<wkt::Duration>,
4614
4615 pub meters: std::vec::Vec<f64>,
4619
4620 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4621 }
4622
4623 impl Row {
4624 pub fn new() -> Self {
4625 std::default::Default::default()
4626 }
4627
4628 pub fn set_durations<T, V>(mut self, v: T) -> Self
4630 where
4631 T: std::iter::IntoIterator<Item = V>,
4632 V: std::convert::Into<wkt::Duration>,
4633 {
4634 use std::iter::Iterator;
4635 self.durations = v.into_iter().map(|i| i.into()).collect();
4636 self
4637 }
4638
4639 pub fn set_meters<T, V>(mut self, v: T) -> Self
4641 where
4642 T: std::iter::IntoIterator<Item = V>,
4643 V: std::convert::Into<f64>,
4644 {
4645 use std::iter::Iterator;
4646 self.meters = v.into_iter().map(|i| i.into()).collect();
4647 self
4648 }
4649 }
4650
4651 impl wkt::message::Message for Row {
4652 fn typename() -> &'static str {
4653 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
4654 }
4655 }
4656
4657 #[doc(hidden)]
4658 impl<'de> serde::de::Deserialize<'de> for Row {
4659 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4660 where
4661 D: serde::Deserializer<'de>,
4662 {
4663 #[allow(non_camel_case_types)]
4664 #[doc(hidden)]
4665 #[derive(PartialEq, Eq, Hash)]
4666 enum __FieldTag {
4667 __durations,
4668 __meters,
4669 Unknown(std::string::String),
4670 }
4671 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4672 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4673 where
4674 D: serde::Deserializer<'de>,
4675 {
4676 struct Visitor;
4677 impl<'de> serde::de::Visitor<'de> for Visitor {
4678 type Value = __FieldTag;
4679 fn expecting(
4680 &self,
4681 formatter: &mut std::fmt::Formatter,
4682 ) -> std::fmt::Result {
4683 formatter.write_str("a field name for Row")
4684 }
4685 fn visit_str<E>(
4686 self,
4687 value: &str,
4688 ) -> std::result::Result<Self::Value, E>
4689 where
4690 E: serde::de::Error,
4691 {
4692 use std::result::Result::Ok;
4693 use std::string::ToString;
4694 match value {
4695 "durations" => Ok(__FieldTag::__durations),
4696 "meters" => Ok(__FieldTag::__meters),
4697 _ => Ok(__FieldTag::Unknown(value.to_string())),
4698 }
4699 }
4700 }
4701 deserializer.deserialize_identifier(Visitor)
4702 }
4703 }
4704 struct Visitor;
4705 impl<'de> serde::de::Visitor<'de> for Visitor {
4706 type Value = Row;
4707 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4708 formatter.write_str("struct Row")
4709 }
4710 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4711 where
4712 A: serde::de::MapAccess<'de>,
4713 {
4714 #[allow(unused_imports)]
4715 use serde::de::Error;
4716 use std::option::Option::Some;
4717 let mut fields = std::collections::HashSet::new();
4718 let mut result = Self::Value::new();
4719 while let Some(tag) = map.next_key::<__FieldTag>()? {
4720 #[allow(clippy::match_single_binding)]
4721 match tag {
4722 __FieldTag::__durations => {
4723 if !fields.insert(__FieldTag::__durations) {
4724 return std::result::Result::Err(
4725 A::Error::duplicate_field(
4726 "multiple values for durations",
4727 ),
4728 );
4729 }
4730 result.durations = map.next_value::<std::option::Option<std::vec::Vec<wkt::Duration>>>()?.unwrap_or_default();
4731 }
4732 __FieldTag::__meters => {
4733 if !fields.insert(__FieldTag::__meters) {
4734 return std::result::Result::Err(
4735 A::Error::duplicate_field("multiple values for meters"),
4736 );
4737 }
4738 struct __With(std::option::Option<std::vec::Vec<f64>>);
4739 impl<'de> serde::de::Deserialize<'de> for __With {
4740 fn deserialize<D>(
4741 deserializer: D,
4742 ) -> std::result::Result<Self, D::Error>
4743 where
4744 D: serde::de::Deserializer<'de>,
4745 {
4746 serde_with::As::<
4747 std::option::Option<
4748 std::vec::Vec<wkt::internal::F64>,
4749 >,
4750 >::deserialize(
4751 deserializer
4752 )
4753 .map(__With)
4754 }
4755 }
4756 result.meters =
4757 map.next_value::<__With>()?.0.unwrap_or_default();
4758 }
4759 __FieldTag::Unknown(key) => {
4760 let value = map.next_value::<serde_json::Value>()?;
4761 result._unknown_fields.insert(key, value);
4762 }
4763 }
4764 }
4765 std::result::Result::Ok(result)
4766 }
4767 }
4768 deserializer.deserialize_any(Visitor)
4769 }
4770 }
4771
4772 #[doc(hidden)]
4773 impl serde::ser::Serialize for Row {
4774 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4775 where
4776 S: serde::ser::Serializer,
4777 {
4778 use serde::ser::SerializeMap;
4779 #[allow(unused_imports)]
4780 use std::option::Option::Some;
4781 let mut state = serializer.serialize_map(std::option::Option::None)?;
4782 if !self.durations.is_empty() {
4783 state.serialize_entry("durations", &self.durations)?;
4784 }
4785 if !self.meters.is_empty() {
4786 struct __With<'a>(&'a std::vec::Vec<f64>);
4787 impl<'a> serde::ser::Serialize for __With<'a> {
4788 fn serialize<S>(
4789 &self,
4790 serializer: S,
4791 ) -> std::result::Result<S::Ok, S::Error>
4792 where
4793 S: serde::ser::Serializer,
4794 {
4795 serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
4796 self.0, serializer,
4797 )
4798 }
4799 }
4800 state.serialize_entry("meters", &__With(&self.meters))?;
4801 }
4802 if !self._unknown_fields.is_empty() {
4803 for (key, value) in self._unknown_fields.iter() {
4804 state.serialize_entry(key, &value)?;
4805 }
4806 }
4807 state.end()
4808 }
4809 }
4810 }
4811
4812 #[derive(Clone, Debug, Default, PartialEq)]
4823 #[non_exhaustive]
4824 pub struct PrecedenceRule {
4825 pub first_index: std::option::Option<i32>,
4827
4828 pub first_is_delivery: bool,
4830
4831 pub second_index: std::option::Option<i32>,
4833
4834 pub second_is_delivery: bool,
4836
4837 pub offset_duration: std::option::Option<wkt::Duration>,
4839
4840 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4841 }
4842
4843 impl PrecedenceRule {
4844 pub fn new() -> Self {
4845 std::default::Default::default()
4846 }
4847
4848 pub fn set_first_index<T>(mut self, v: T) -> Self
4850 where
4851 T: std::convert::Into<i32>,
4852 {
4853 self.first_index = std::option::Option::Some(v.into());
4854 self
4855 }
4856
4857 pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
4859 where
4860 T: std::convert::Into<i32>,
4861 {
4862 self.first_index = v.map(|x| x.into());
4863 self
4864 }
4865
4866 pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4868 self.first_is_delivery = v.into();
4869 self
4870 }
4871
4872 pub fn set_second_index<T>(mut self, v: T) -> Self
4874 where
4875 T: std::convert::Into<i32>,
4876 {
4877 self.second_index = std::option::Option::Some(v.into());
4878 self
4879 }
4880
4881 pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
4883 where
4884 T: std::convert::Into<i32>,
4885 {
4886 self.second_index = v.map(|x| x.into());
4887 self
4888 }
4889
4890 pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4892 self.second_is_delivery = v.into();
4893 self
4894 }
4895
4896 pub fn set_offset_duration<T>(mut self, v: T) -> Self
4898 where
4899 T: std::convert::Into<wkt::Duration>,
4900 {
4901 self.offset_duration = std::option::Option::Some(v.into());
4902 self
4903 }
4904
4905 pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
4907 where
4908 T: std::convert::Into<wkt::Duration>,
4909 {
4910 self.offset_duration = v.map(|x| x.into());
4911 self
4912 }
4913 }
4914
4915 impl wkt::message::Message for PrecedenceRule {
4916 fn typename() -> &'static str {
4917 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
4918 }
4919 }
4920
4921 #[doc(hidden)]
4922 impl<'de> serde::de::Deserialize<'de> for PrecedenceRule {
4923 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4924 where
4925 D: serde::Deserializer<'de>,
4926 {
4927 #[allow(non_camel_case_types)]
4928 #[doc(hidden)]
4929 #[derive(PartialEq, Eq, Hash)]
4930 enum __FieldTag {
4931 __first_index,
4932 __first_is_delivery,
4933 __second_index,
4934 __second_is_delivery,
4935 __offset_duration,
4936 Unknown(std::string::String),
4937 }
4938 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4939 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4940 where
4941 D: serde::Deserializer<'de>,
4942 {
4943 struct Visitor;
4944 impl<'de> serde::de::Visitor<'de> for Visitor {
4945 type Value = __FieldTag;
4946 fn expecting(
4947 &self,
4948 formatter: &mut std::fmt::Formatter,
4949 ) -> std::fmt::Result {
4950 formatter.write_str("a field name for PrecedenceRule")
4951 }
4952 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4953 where
4954 E: serde::de::Error,
4955 {
4956 use std::result::Result::Ok;
4957 use std::string::ToString;
4958 match value {
4959 "firstIndex" => Ok(__FieldTag::__first_index),
4960 "first_index" => Ok(__FieldTag::__first_index),
4961 "firstIsDelivery" => Ok(__FieldTag::__first_is_delivery),
4962 "first_is_delivery" => Ok(__FieldTag::__first_is_delivery),
4963 "secondIndex" => Ok(__FieldTag::__second_index),
4964 "second_index" => Ok(__FieldTag::__second_index),
4965 "secondIsDelivery" => Ok(__FieldTag::__second_is_delivery),
4966 "second_is_delivery" => Ok(__FieldTag::__second_is_delivery),
4967 "offsetDuration" => Ok(__FieldTag::__offset_duration),
4968 "offset_duration" => Ok(__FieldTag::__offset_duration),
4969 _ => Ok(__FieldTag::Unknown(value.to_string())),
4970 }
4971 }
4972 }
4973 deserializer.deserialize_identifier(Visitor)
4974 }
4975 }
4976 struct Visitor;
4977 impl<'de> serde::de::Visitor<'de> for Visitor {
4978 type Value = PrecedenceRule;
4979 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4980 formatter.write_str("struct PrecedenceRule")
4981 }
4982 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4983 where
4984 A: serde::de::MapAccess<'de>,
4985 {
4986 #[allow(unused_imports)]
4987 use serde::de::Error;
4988 use std::option::Option::Some;
4989 let mut fields = std::collections::HashSet::new();
4990 let mut result = Self::Value::new();
4991 while let Some(tag) = map.next_key::<__FieldTag>()? {
4992 #[allow(clippy::match_single_binding)]
4993 match tag {
4994 __FieldTag::__first_index => {
4995 if !fields.insert(__FieldTag::__first_index) {
4996 return std::result::Result::Err(A::Error::duplicate_field(
4997 "multiple values for first_index",
4998 ));
4999 }
5000 struct __With(std::option::Option<i32>);
5001 impl<'de> serde::de::Deserialize<'de> for __With {
5002 fn deserialize<D>(
5003 deserializer: D,
5004 ) -> std::result::Result<Self, D::Error>
5005 where
5006 D: serde::de::Deserializer<'de>,
5007 {
5008 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
5009 }
5010 }
5011 result.first_index = map.next_value::<__With>()?.0;
5012 }
5013 __FieldTag::__first_is_delivery => {
5014 if !fields.insert(__FieldTag::__first_is_delivery) {
5015 return std::result::Result::Err(A::Error::duplicate_field(
5016 "multiple values for first_is_delivery",
5017 ));
5018 }
5019 result.first_is_delivery = map
5020 .next_value::<std::option::Option<bool>>()?
5021 .unwrap_or_default();
5022 }
5023 __FieldTag::__second_index => {
5024 if !fields.insert(__FieldTag::__second_index) {
5025 return std::result::Result::Err(A::Error::duplicate_field(
5026 "multiple values for second_index",
5027 ));
5028 }
5029 struct __With(std::option::Option<i32>);
5030 impl<'de> serde::de::Deserialize<'de> for __With {
5031 fn deserialize<D>(
5032 deserializer: D,
5033 ) -> std::result::Result<Self, D::Error>
5034 where
5035 D: serde::de::Deserializer<'de>,
5036 {
5037 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
5038 }
5039 }
5040 result.second_index = map.next_value::<__With>()?.0;
5041 }
5042 __FieldTag::__second_is_delivery => {
5043 if !fields.insert(__FieldTag::__second_is_delivery) {
5044 return std::result::Result::Err(A::Error::duplicate_field(
5045 "multiple values for second_is_delivery",
5046 ));
5047 }
5048 result.second_is_delivery = map
5049 .next_value::<std::option::Option<bool>>()?
5050 .unwrap_or_default();
5051 }
5052 __FieldTag::__offset_duration => {
5053 if !fields.insert(__FieldTag::__offset_duration) {
5054 return std::result::Result::Err(A::Error::duplicate_field(
5055 "multiple values for offset_duration",
5056 ));
5057 }
5058 result.offset_duration =
5059 map.next_value::<std::option::Option<wkt::Duration>>()?;
5060 }
5061 __FieldTag::Unknown(key) => {
5062 let value = map.next_value::<serde_json::Value>()?;
5063 result._unknown_fields.insert(key, value);
5064 }
5065 }
5066 }
5067 std::result::Result::Ok(result)
5068 }
5069 }
5070 deserializer.deserialize_any(Visitor)
5071 }
5072 }
5073
5074 #[doc(hidden)]
5075 impl serde::ser::Serialize for PrecedenceRule {
5076 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5077 where
5078 S: serde::ser::Serializer,
5079 {
5080 use serde::ser::SerializeMap;
5081 #[allow(unused_imports)]
5082 use std::option::Option::Some;
5083 let mut state = serializer.serialize_map(std::option::Option::None)?;
5084 if self.first_index.is_some() {
5085 struct __With<'a>(&'a std::option::Option<i32>);
5086 impl<'a> serde::ser::Serialize for __With<'a> {
5087 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5088 where
5089 S: serde::ser::Serializer,
5090 {
5091 serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
5092 self.0, serializer,
5093 )
5094 }
5095 }
5096 state.serialize_entry("firstIndex", &__With(&self.first_index))?;
5097 }
5098 if !wkt::internal::is_default(&self.first_is_delivery) {
5099 state.serialize_entry("firstIsDelivery", &self.first_is_delivery)?;
5100 }
5101 if self.second_index.is_some() {
5102 struct __With<'a>(&'a std::option::Option<i32>);
5103 impl<'a> serde::ser::Serialize for __With<'a> {
5104 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5105 where
5106 S: serde::ser::Serializer,
5107 {
5108 serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
5109 self.0, serializer,
5110 )
5111 }
5112 }
5113 state.serialize_entry("secondIndex", &__With(&self.second_index))?;
5114 }
5115 if !wkt::internal::is_default(&self.second_is_delivery) {
5116 state.serialize_entry("secondIsDelivery", &self.second_is_delivery)?;
5117 }
5118 if self.offset_duration.is_some() {
5119 state.serialize_entry("offsetDuration", &self.offset_duration)?;
5120 }
5121 if !self._unknown_fields.is_empty() {
5122 for (key, value) in self._unknown_fields.iter() {
5123 state.serialize_entry(key, &value)?;
5124 }
5125 }
5126 state.end()
5127 }
5128 }
5129
5130 #[derive(Clone, Debug, Default, PartialEq)]
5146 #[non_exhaustive]
5147 #[deprecated]
5148 pub struct BreakRule {
5149 pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
5151
5152 pub frequency_constraints:
5155 std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
5156
5157 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5158 }
5159
5160 impl BreakRule {
5161 pub fn new() -> Self {
5162 std::default::Default::default()
5163 }
5164
5165 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
5167 where
5168 T: std::iter::IntoIterator<Item = V>,
5169 V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
5170 {
5171 use std::iter::Iterator;
5172 self.break_requests = v.into_iter().map(|i| i.into()).collect();
5173 self
5174 }
5175
5176 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
5178 where
5179 T: std::iter::IntoIterator<Item = V>,
5180 V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
5181 {
5182 use std::iter::Iterator;
5183 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
5184 self
5185 }
5186 }
5187
5188 impl wkt::message::Message for BreakRule {
5189 fn typename() -> &'static str {
5190 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
5191 }
5192 }
5193
5194 #[doc(hidden)]
5195 impl<'de> serde::de::Deserialize<'de> for BreakRule {
5196 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5197 where
5198 D: serde::Deserializer<'de>,
5199 {
5200 #[allow(non_camel_case_types)]
5201 #[doc(hidden)]
5202 #[derive(PartialEq, Eq, Hash)]
5203 enum __FieldTag {
5204 __break_requests,
5205 __frequency_constraints,
5206 Unknown(std::string::String),
5207 }
5208 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5209 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5210 where
5211 D: serde::Deserializer<'de>,
5212 {
5213 struct Visitor;
5214 impl<'de> serde::de::Visitor<'de> for Visitor {
5215 type Value = __FieldTag;
5216 fn expecting(
5217 &self,
5218 formatter: &mut std::fmt::Formatter,
5219 ) -> std::fmt::Result {
5220 formatter.write_str("a field name for BreakRule")
5221 }
5222 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5223 where
5224 E: serde::de::Error,
5225 {
5226 use std::result::Result::Ok;
5227 use std::string::ToString;
5228 match value {
5229 "breakRequests" => Ok(__FieldTag::__break_requests),
5230 "break_requests" => Ok(__FieldTag::__break_requests),
5231 "frequencyConstraints" => Ok(__FieldTag::__frequency_constraints),
5232 "frequency_constraints" => Ok(__FieldTag::__frequency_constraints),
5233 _ => Ok(__FieldTag::Unknown(value.to_string())),
5234 }
5235 }
5236 }
5237 deserializer.deserialize_identifier(Visitor)
5238 }
5239 }
5240 struct Visitor;
5241 impl<'de> serde::de::Visitor<'de> for Visitor {
5242 type Value = BreakRule;
5243 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5244 formatter.write_str("struct BreakRule")
5245 }
5246 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5247 where
5248 A: serde::de::MapAccess<'de>,
5249 {
5250 #[allow(unused_imports)]
5251 use serde::de::Error;
5252 use std::option::Option::Some;
5253 let mut fields = std::collections::HashSet::new();
5254 let mut result = Self::Value::new();
5255 while let Some(tag) = map.next_key::<__FieldTag>()? {
5256 #[allow(clippy::match_single_binding)]
5257 match tag {
5258 __FieldTag::__break_requests => {
5259 if !fields.insert(__FieldTag::__break_requests) {
5260 return std::result::Result::Err(A::Error::duplicate_field(
5261 "multiple values for break_requests",
5262 ));
5263 }
5264 result.break_requests = map
5265 .next_value::<std::option::Option<
5266 std::vec::Vec<
5267 crate::model::shipment_model::break_rule::BreakRequest,
5268 >,
5269 >>()?
5270 .unwrap_or_default();
5271 }
5272 __FieldTag::__frequency_constraints => {
5273 if !fields.insert(__FieldTag::__frequency_constraints) {
5274 return std::result::Result::Err(A::Error::duplicate_field(
5275 "multiple values for frequency_constraints",
5276 ));
5277 }
5278 result.frequency_constraints = map.next_value::<std::option::Option<std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>>>()?.unwrap_or_default();
5279 }
5280 __FieldTag::Unknown(key) => {
5281 let value = map.next_value::<serde_json::Value>()?;
5282 result._unknown_fields.insert(key, value);
5283 }
5284 }
5285 }
5286 std::result::Result::Ok(result)
5287 }
5288 }
5289 deserializer.deserialize_any(Visitor)
5290 }
5291 }
5292
5293 #[doc(hidden)]
5294 impl serde::ser::Serialize for BreakRule {
5295 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5296 where
5297 S: serde::ser::Serializer,
5298 {
5299 use serde::ser::SerializeMap;
5300 #[allow(unused_imports)]
5301 use std::option::Option::Some;
5302 let mut state = serializer.serialize_map(std::option::Option::None)?;
5303 if !self.break_requests.is_empty() {
5304 state.serialize_entry("breakRequests", &self.break_requests)?;
5305 }
5306 if !self.frequency_constraints.is_empty() {
5307 state.serialize_entry("frequencyConstraints", &self.frequency_constraints)?;
5308 }
5309 if !self._unknown_fields.is_empty() {
5310 for (key, value) in self._unknown_fields.iter() {
5311 state.serialize_entry(key, &value)?;
5312 }
5313 }
5314 state.end()
5315 }
5316 }
5317
5318 pub mod break_rule {
5320 #[allow(unused_imports)]
5321 use super::*;
5322
5323 #[derive(Clone, Debug, Default, PartialEq)]
5329 #[non_exhaustive]
5330 pub struct BreakRequest {
5331 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
5333
5334 pub latest_start_time: std::option::Option<wkt::Timestamp>,
5336
5337 pub min_duration: std::option::Option<wkt::Duration>,
5339
5340 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5341 }
5342
5343 impl BreakRequest {
5344 pub fn new() -> Self {
5345 std::default::Default::default()
5346 }
5347
5348 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
5350 where
5351 T: std::convert::Into<wkt::Timestamp>,
5352 {
5353 self.earliest_start_time = std::option::Option::Some(v.into());
5354 self
5355 }
5356
5357 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5359 where
5360 T: std::convert::Into<wkt::Timestamp>,
5361 {
5362 self.earliest_start_time = v.map(|x| x.into());
5363 self
5364 }
5365
5366 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
5368 where
5369 T: std::convert::Into<wkt::Timestamp>,
5370 {
5371 self.latest_start_time = std::option::Option::Some(v.into());
5372 self
5373 }
5374
5375 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
5377 where
5378 T: std::convert::Into<wkt::Timestamp>,
5379 {
5380 self.latest_start_time = v.map(|x| x.into());
5381 self
5382 }
5383
5384 pub fn set_min_duration<T>(mut self, v: T) -> Self
5386 where
5387 T: std::convert::Into<wkt::Duration>,
5388 {
5389 self.min_duration = std::option::Option::Some(v.into());
5390 self
5391 }
5392
5393 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
5395 where
5396 T: std::convert::Into<wkt::Duration>,
5397 {
5398 self.min_duration = v.map(|x| x.into());
5399 self
5400 }
5401 }
5402
5403 impl wkt::message::Message for BreakRequest {
5404 fn typename() -> &'static str {
5405 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
5406 }
5407 }
5408
5409 #[doc(hidden)]
5410 impl<'de> serde::de::Deserialize<'de> for BreakRequest {
5411 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5412 where
5413 D: serde::Deserializer<'de>,
5414 {
5415 #[allow(non_camel_case_types)]
5416 #[doc(hidden)]
5417 #[derive(PartialEq, Eq, Hash)]
5418 enum __FieldTag {
5419 __earliest_start_time,
5420 __latest_start_time,
5421 __min_duration,
5422 Unknown(std::string::String),
5423 }
5424 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5425 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5426 where
5427 D: serde::Deserializer<'de>,
5428 {
5429 struct Visitor;
5430 impl<'de> serde::de::Visitor<'de> for Visitor {
5431 type Value = __FieldTag;
5432 fn expecting(
5433 &self,
5434 formatter: &mut std::fmt::Formatter,
5435 ) -> std::fmt::Result {
5436 formatter.write_str("a field name for BreakRequest")
5437 }
5438 fn visit_str<E>(
5439 self,
5440 value: &str,
5441 ) -> std::result::Result<Self::Value, E>
5442 where
5443 E: serde::de::Error,
5444 {
5445 use std::result::Result::Ok;
5446 use std::string::ToString;
5447 match value {
5448 "earliestStartTime" => Ok(__FieldTag::__earliest_start_time),
5449 "earliest_start_time" => Ok(__FieldTag::__earliest_start_time),
5450 "latestStartTime" => Ok(__FieldTag::__latest_start_time),
5451 "latest_start_time" => Ok(__FieldTag::__latest_start_time),
5452 "minDuration" => Ok(__FieldTag::__min_duration),
5453 "min_duration" => Ok(__FieldTag::__min_duration),
5454 _ => Ok(__FieldTag::Unknown(value.to_string())),
5455 }
5456 }
5457 }
5458 deserializer.deserialize_identifier(Visitor)
5459 }
5460 }
5461 struct Visitor;
5462 impl<'de> serde::de::Visitor<'de> for Visitor {
5463 type Value = BreakRequest;
5464 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5465 formatter.write_str("struct BreakRequest")
5466 }
5467 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5468 where
5469 A: serde::de::MapAccess<'de>,
5470 {
5471 #[allow(unused_imports)]
5472 use serde::de::Error;
5473 use std::option::Option::Some;
5474 let mut fields = std::collections::HashSet::new();
5475 let mut result = Self::Value::new();
5476 while let Some(tag) = map.next_key::<__FieldTag>()? {
5477 #[allow(clippy::match_single_binding)]
5478 match tag {
5479 __FieldTag::__earliest_start_time => {
5480 if !fields.insert(__FieldTag::__earliest_start_time) {
5481 return std::result::Result::Err(
5482 A::Error::duplicate_field(
5483 "multiple values for earliest_start_time",
5484 ),
5485 );
5486 }
5487 result.earliest_start_time =
5488 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
5489 }
5490 __FieldTag::__latest_start_time => {
5491 if !fields.insert(__FieldTag::__latest_start_time) {
5492 return std::result::Result::Err(
5493 A::Error::duplicate_field(
5494 "multiple values for latest_start_time",
5495 ),
5496 );
5497 }
5498 result.latest_start_time =
5499 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
5500 }
5501 __FieldTag::__min_duration => {
5502 if !fields.insert(__FieldTag::__min_duration) {
5503 return std::result::Result::Err(
5504 A::Error::duplicate_field(
5505 "multiple values for min_duration",
5506 ),
5507 );
5508 }
5509 result.min_duration =
5510 map.next_value::<std::option::Option<wkt::Duration>>()?;
5511 }
5512 __FieldTag::Unknown(key) => {
5513 let value = map.next_value::<serde_json::Value>()?;
5514 result._unknown_fields.insert(key, value);
5515 }
5516 }
5517 }
5518 std::result::Result::Ok(result)
5519 }
5520 }
5521 deserializer.deserialize_any(Visitor)
5522 }
5523 }
5524
5525 #[doc(hidden)]
5526 impl serde::ser::Serialize for BreakRequest {
5527 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5528 where
5529 S: serde::ser::Serializer,
5530 {
5531 use serde::ser::SerializeMap;
5532 #[allow(unused_imports)]
5533 use std::option::Option::Some;
5534 let mut state = serializer.serialize_map(std::option::Option::None)?;
5535 if self.earliest_start_time.is_some() {
5536 state.serialize_entry("earliestStartTime", &self.earliest_start_time)?;
5537 }
5538 if self.latest_start_time.is_some() {
5539 state.serialize_entry("latestStartTime", &self.latest_start_time)?;
5540 }
5541 if self.min_duration.is_some() {
5542 state.serialize_entry("minDuration", &self.min_duration)?;
5543 }
5544 if !self._unknown_fields.is_empty() {
5545 for (key, value) in self._unknown_fields.iter() {
5546 state.serialize_entry(key, &value)?;
5547 }
5548 }
5549 state.end()
5550 }
5551 }
5552
5553 #[derive(Clone, Debug, Default, PartialEq)]
5589 #[non_exhaustive]
5590 pub struct FrequencyConstraint {
5591 pub min_break_duration: std::option::Option<wkt::Duration>,
5594
5595 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
5599
5600 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5601 }
5602
5603 impl FrequencyConstraint {
5604 pub fn new() -> Self {
5605 std::default::Default::default()
5606 }
5607
5608 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
5610 where
5611 T: std::convert::Into<wkt::Duration>,
5612 {
5613 self.min_break_duration = std::option::Option::Some(v.into());
5614 self
5615 }
5616
5617 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
5619 where
5620 T: std::convert::Into<wkt::Duration>,
5621 {
5622 self.min_break_duration = v.map(|x| x.into());
5623 self
5624 }
5625
5626 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
5628 where
5629 T: std::convert::Into<wkt::Duration>,
5630 {
5631 self.max_inter_break_duration = std::option::Option::Some(v.into());
5632 self
5633 }
5634
5635 pub fn set_or_clear_max_inter_break_duration<T>(
5637 mut self,
5638 v: std::option::Option<T>,
5639 ) -> Self
5640 where
5641 T: std::convert::Into<wkt::Duration>,
5642 {
5643 self.max_inter_break_duration = v.map(|x| x.into());
5644 self
5645 }
5646 }
5647
5648 impl wkt::message::Message for FrequencyConstraint {
5649 fn typename() -> &'static str {
5650 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
5651 }
5652 }
5653
5654 #[doc(hidden)]
5655 impl<'de> serde::de::Deserialize<'de> for FrequencyConstraint {
5656 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5657 where
5658 D: serde::Deserializer<'de>,
5659 {
5660 #[allow(non_camel_case_types)]
5661 #[doc(hidden)]
5662 #[derive(PartialEq, Eq, Hash)]
5663 enum __FieldTag {
5664 __min_break_duration,
5665 __max_inter_break_duration,
5666 Unknown(std::string::String),
5667 }
5668 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5669 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5670 where
5671 D: serde::Deserializer<'de>,
5672 {
5673 struct Visitor;
5674 impl<'de> serde::de::Visitor<'de> for Visitor {
5675 type Value = __FieldTag;
5676 fn expecting(
5677 &self,
5678 formatter: &mut std::fmt::Formatter,
5679 ) -> std::fmt::Result {
5680 formatter.write_str("a field name for FrequencyConstraint")
5681 }
5682 fn visit_str<E>(
5683 self,
5684 value: &str,
5685 ) -> std::result::Result<Self::Value, E>
5686 where
5687 E: serde::de::Error,
5688 {
5689 use std::result::Result::Ok;
5690 use std::string::ToString;
5691 match value {
5692 "minBreakDuration" => Ok(__FieldTag::__min_break_duration),
5693 "min_break_duration" => Ok(__FieldTag::__min_break_duration),
5694 "maxInterBreakDuration" => {
5695 Ok(__FieldTag::__max_inter_break_duration)
5696 }
5697 "max_inter_break_duration" => {
5698 Ok(__FieldTag::__max_inter_break_duration)
5699 }
5700 _ => Ok(__FieldTag::Unknown(value.to_string())),
5701 }
5702 }
5703 }
5704 deserializer.deserialize_identifier(Visitor)
5705 }
5706 }
5707 struct Visitor;
5708 impl<'de> serde::de::Visitor<'de> for Visitor {
5709 type Value = FrequencyConstraint;
5710 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5711 formatter.write_str("struct FrequencyConstraint")
5712 }
5713 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5714 where
5715 A: serde::de::MapAccess<'de>,
5716 {
5717 #[allow(unused_imports)]
5718 use serde::de::Error;
5719 use std::option::Option::Some;
5720 let mut fields = std::collections::HashSet::new();
5721 let mut result = Self::Value::new();
5722 while let Some(tag) = map.next_key::<__FieldTag>()? {
5723 #[allow(clippy::match_single_binding)]
5724 match tag {
5725 __FieldTag::__min_break_duration => {
5726 if !fields.insert(__FieldTag::__min_break_duration) {
5727 return std::result::Result::Err(
5728 A::Error::duplicate_field(
5729 "multiple values for min_break_duration",
5730 ),
5731 );
5732 }
5733 result.min_break_duration =
5734 map.next_value::<std::option::Option<wkt::Duration>>()?;
5735 }
5736 __FieldTag::__max_inter_break_duration => {
5737 if !fields.insert(__FieldTag::__max_inter_break_duration) {
5738 return std::result::Result::Err(
5739 A::Error::duplicate_field(
5740 "multiple values for max_inter_break_duration",
5741 ),
5742 );
5743 }
5744 result.max_inter_break_duration =
5745 map.next_value::<std::option::Option<wkt::Duration>>()?;
5746 }
5747 __FieldTag::Unknown(key) => {
5748 let value = map.next_value::<serde_json::Value>()?;
5749 result._unknown_fields.insert(key, value);
5750 }
5751 }
5752 }
5753 std::result::Result::Ok(result)
5754 }
5755 }
5756 deserializer.deserialize_any(Visitor)
5757 }
5758 }
5759
5760 #[doc(hidden)]
5761 impl serde::ser::Serialize for FrequencyConstraint {
5762 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5763 where
5764 S: serde::ser::Serializer,
5765 {
5766 use serde::ser::SerializeMap;
5767 #[allow(unused_imports)]
5768 use std::option::Option::Some;
5769 let mut state = serializer.serialize_map(std::option::Option::None)?;
5770 if self.min_break_duration.is_some() {
5771 state.serialize_entry("minBreakDuration", &self.min_break_duration)?;
5772 }
5773 if self.max_inter_break_duration.is_some() {
5774 state
5775 .serialize_entry("maxInterBreakDuration", &self.max_inter_break_duration)?;
5776 }
5777 if !self._unknown_fields.is_empty() {
5778 for (key, value) in self._unknown_fields.iter() {
5779 state.serialize_entry(key, &value)?;
5780 }
5781 }
5782 state.end()
5783 }
5784 }
5785 }
5786}
5787
5788#[derive(Clone, Debug, Default, PartialEq)]
5794#[non_exhaustive]
5795pub struct Shipment {
5796 pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
5799
5800 pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
5803
5804 pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
5811
5812 pub penalty_cost: std::option::Option<f64>,
5821
5822 pub allowed_vehicle_indices: std::vec::Vec<i32>,
5826
5827 pub costs_per_vehicle: std::vec::Vec<f64>,
5839
5840 pub costs_per_vehicle_indices: std::vec::Vec<i32>,
5845
5846 pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
5864
5865 pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
5883
5884 pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
5891
5892 pub shipment_type: std::string::String,
5901
5902 pub label: std::string::String,
5908
5909 pub ignore: bool,
5919
5920 #[deprecated]
5926 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
5927
5928 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5929}
5930
5931impl Shipment {
5932 pub fn new() -> Self {
5933 std::default::Default::default()
5934 }
5935
5936 pub fn set_pickups<T, V>(mut self, v: T) -> Self
5938 where
5939 T: std::iter::IntoIterator<Item = V>,
5940 V: std::convert::Into<crate::model::shipment::VisitRequest>,
5941 {
5942 use std::iter::Iterator;
5943 self.pickups = v.into_iter().map(|i| i.into()).collect();
5944 self
5945 }
5946
5947 pub fn set_deliveries<T, V>(mut self, v: T) -> Self
5949 where
5950 T: std::iter::IntoIterator<Item = V>,
5951 V: std::convert::Into<crate::model::shipment::VisitRequest>,
5952 {
5953 use std::iter::Iterator;
5954 self.deliveries = v.into_iter().map(|i| i.into()).collect();
5955 self
5956 }
5957
5958 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
5960 where
5961 T: std::iter::IntoIterator<Item = (K, V)>,
5962 K: std::convert::Into<std::string::String>,
5963 V: std::convert::Into<crate::model::shipment::Load>,
5964 {
5965 use std::iter::Iterator;
5966 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5967 self
5968 }
5969
5970 pub fn set_penalty_cost<T>(mut self, v: T) -> Self
5972 where
5973 T: std::convert::Into<f64>,
5974 {
5975 self.penalty_cost = std::option::Option::Some(v.into());
5976 self
5977 }
5978
5979 pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
5981 where
5982 T: std::convert::Into<f64>,
5983 {
5984 self.penalty_cost = v.map(|x| x.into());
5985 self
5986 }
5987
5988 pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
5990 where
5991 T: std::iter::IntoIterator<Item = V>,
5992 V: std::convert::Into<i32>,
5993 {
5994 use std::iter::Iterator;
5995 self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
5996 self
5997 }
5998
5999 pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
6001 where
6002 T: std::iter::IntoIterator<Item = V>,
6003 V: std::convert::Into<f64>,
6004 {
6005 use std::iter::Iterator;
6006 self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
6007 self
6008 }
6009
6010 pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
6012 where
6013 T: std::iter::IntoIterator<Item = V>,
6014 V: std::convert::Into<i32>,
6015 {
6016 use std::iter::Iterator;
6017 self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
6018 self
6019 }
6020
6021 pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
6023 where
6024 T: std::convert::Into<f64>,
6025 {
6026 self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
6027 self
6028 }
6029
6030 pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
6032 mut self,
6033 v: std::option::Option<T>,
6034 ) -> Self
6035 where
6036 T: std::convert::Into<f64>,
6037 {
6038 self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
6039 self
6040 }
6041
6042 pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
6044 where
6045 T: std::convert::Into<wkt::Duration>,
6046 {
6047 self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
6048 self
6049 }
6050
6051 pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
6053 mut self,
6054 v: std::option::Option<T>,
6055 ) -> Self
6056 where
6057 T: std::convert::Into<wkt::Duration>,
6058 {
6059 self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
6060 self
6061 }
6062
6063 pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
6065 where
6066 T: std::convert::Into<wkt::Duration>,
6067 {
6068 self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
6069 self
6070 }
6071
6072 pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
6074 mut self,
6075 v: std::option::Option<T>,
6076 ) -> Self
6077 where
6078 T: std::convert::Into<wkt::Duration>,
6079 {
6080 self.pickup_to_delivery_time_limit = v.map(|x| x.into());
6081 self
6082 }
6083
6084 pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6086 self.shipment_type = v.into();
6087 self
6088 }
6089
6090 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6092 self.label = v.into();
6093 self
6094 }
6095
6096 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6098 self.ignore = v.into();
6099 self
6100 }
6101
6102 #[deprecated]
6104 pub fn set_demands<T, V>(mut self, v: T) -> Self
6105 where
6106 T: std::iter::IntoIterator<Item = V>,
6107 V: std::convert::Into<crate::model::CapacityQuantity>,
6108 {
6109 use std::iter::Iterator;
6110 self.demands = v.into_iter().map(|i| i.into()).collect();
6111 self
6112 }
6113}
6114
6115impl wkt::message::Message for Shipment {
6116 fn typename() -> &'static str {
6117 "type.googleapis.com/google.cloud.optimization.v1.Shipment"
6118 }
6119}
6120
6121#[doc(hidden)]
6122impl<'de> serde::de::Deserialize<'de> for Shipment {
6123 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6124 where
6125 D: serde::Deserializer<'de>,
6126 {
6127 #[allow(non_camel_case_types)]
6128 #[doc(hidden)]
6129 #[derive(PartialEq, Eq, Hash)]
6130 enum __FieldTag {
6131 __pickups,
6132 __deliveries,
6133 __load_demands,
6134 __penalty_cost,
6135 __allowed_vehicle_indices,
6136 __costs_per_vehicle,
6137 __costs_per_vehicle_indices,
6138 __pickup_to_delivery_relative_detour_limit,
6139 __pickup_to_delivery_absolute_detour_limit,
6140 __pickup_to_delivery_time_limit,
6141 __shipment_type,
6142 __label,
6143 __ignore,
6144 __demands,
6145 Unknown(std::string::String),
6146 }
6147 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6148 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6149 where
6150 D: serde::Deserializer<'de>,
6151 {
6152 struct Visitor;
6153 impl<'de> serde::de::Visitor<'de> for Visitor {
6154 type Value = __FieldTag;
6155 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6156 formatter.write_str("a field name for Shipment")
6157 }
6158 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6159 where
6160 E: serde::de::Error,
6161 {
6162 use std::result::Result::Ok;
6163 use std::string::ToString;
6164 match value {
6165 "pickups" => Ok(__FieldTag::__pickups),
6166 "deliveries" => Ok(__FieldTag::__deliveries),
6167 "loadDemands" => Ok(__FieldTag::__load_demands),
6168 "load_demands" => Ok(__FieldTag::__load_demands),
6169 "penaltyCost" => Ok(__FieldTag::__penalty_cost),
6170 "penalty_cost" => Ok(__FieldTag::__penalty_cost),
6171 "allowedVehicleIndices" => Ok(__FieldTag::__allowed_vehicle_indices),
6172 "allowed_vehicle_indices" => Ok(__FieldTag::__allowed_vehicle_indices),
6173 "costsPerVehicle" => Ok(__FieldTag::__costs_per_vehicle),
6174 "costs_per_vehicle" => Ok(__FieldTag::__costs_per_vehicle),
6175 "costsPerVehicleIndices" => Ok(__FieldTag::__costs_per_vehicle_indices),
6176 "costs_per_vehicle_indices" => {
6177 Ok(__FieldTag::__costs_per_vehicle_indices)
6178 }
6179 "pickupToDeliveryRelativeDetourLimit" => {
6180 Ok(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6181 }
6182 "pickup_to_delivery_relative_detour_limit" => {
6183 Ok(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6184 }
6185 "pickupToDeliveryAbsoluteDetourLimit" => {
6186 Ok(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6187 }
6188 "pickup_to_delivery_absolute_detour_limit" => {
6189 Ok(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6190 }
6191 "pickupToDeliveryTimeLimit" => {
6192 Ok(__FieldTag::__pickup_to_delivery_time_limit)
6193 }
6194 "pickup_to_delivery_time_limit" => {
6195 Ok(__FieldTag::__pickup_to_delivery_time_limit)
6196 }
6197 "shipmentType" => Ok(__FieldTag::__shipment_type),
6198 "shipment_type" => Ok(__FieldTag::__shipment_type),
6199 "label" => Ok(__FieldTag::__label),
6200 "ignore" => Ok(__FieldTag::__ignore),
6201 "demands" => Ok(__FieldTag::__demands),
6202 _ => Ok(__FieldTag::Unknown(value.to_string())),
6203 }
6204 }
6205 }
6206 deserializer.deserialize_identifier(Visitor)
6207 }
6208 }
6209 struct Visitor;
6210 impl<'de> serde::de::Visitor<'de> for Visitor {
6211 type Value = Shipment;
6212 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6213 formatter.write_str("struct Shipment")
6214 }
6215 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6216 where
6217 A: serde::de::MapAccess<'de>,
6218 {
6219 #[allow(unused_imports)]
6220 use serde::de::Error;
6221 use std::option::Option::Some;
6222 let mut fields = std::collections::HashSet::new();
6223 let mut result = Self::Value::new();
6224 while let Some(tag) = map.next_key::<__FieldTag>()? {
6225 #[allow(clippy::match_single_binding)]
6226 match tag {
6227 __FieldTag::__pickups => {
6228 if !fields.insert(__FieldTag::__pickups) {
6229 return std::result::Result::Err(A::Error::duplicate_field(
6230 "multiple values for pickups",
6231 ));
6232 }
6233 result.pickups = map
6234 .next_value::<std::option::Option<
6235 std::vec::Vec<crate::model::shipment::VisitRequest>,
6236 >>()?
6237 .unwrap_or_default();
6238 }
6239 __FieldTag::__deliveries => {
6240 if !fields.insert(__FieldTag::__deliveries) {
6241 return std::result::Result::Err(A::Error::duplicate_field(
6242 "multiple values for deliveries",
6243 ));
6244 }
6245 result.deliveries = map
6246 .next_value::<std::option::Option<
6247 std::vec::Vec<crate::model::shipment::VisitRequest>,
6248 >>()?
6249 .unwrap_or_default();
6250 }
6251 __FieldTag::__load_demands => {
6252 if !fields.insert(__FieldTag::__load_demands) {
6253 return std::result::Result::Err(A::Error::duplicate_field(
6254 "multiple values for load_demands",
6255 ));
6256 }
6257 result.load_demands = map
6258 .next_value::<std::option::Option<
6259 std::collections::HashMap<
6260 std::string::String,
6261 crate::model::shipment::Load,
6262 >,
6263 >>()?
6264 .unwrap_or_default();
6265 }
6266 __FieldTag::__penalty_cost => {
6267 if !fields.insert(__FieldTag::__penalty_cost) {
6268 return std::result::Result::Err(A::Error::duplicate_field(
6269 "multiple values for penalty_cost",
6270 ));
6271 }
6272 struct __With(std::option::Option<f64>);
6273 impl<'de> serde::de::Deserialize<'de> for __With {
6274 fn deserialize<D>(
6275 deserializer: D,
6276 ) -> std::result::Result<Self, D::Error>
6277 where
6278 D: serde::de::Deserializer<'de>,
6279 {
6280 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
6281 }
6282 }
6283 result.penalty_cost = map.next_value::<__With>()?.0;
6284 }
6285 __FieldTag::__allowed_vehicle_indices => {
6286 if !fields.insert(__FieldTag::__allowed_vehicle_indices) {
6287 return std::result::Result::Err(A::Error::duplicate_field(
6288 "multiple values for allowed_vehicle_indices",
6289 ));
6290 }
6291 struct __With(std::option::Option<std::vec::Vec<i32>>);
6292 impl<'de> serde::de::Deserialize<'de> for __With {
6293 fn deserialize<D>(
6294 deserializer: D,
6295 ) -> std::result::Result<Self, D::Error>
6296 where
6297 D: serde::de::Deserializer<'de>,
6298 {
6299 serde_with::As::<
6300 std::option::Option<std::vec::Vec<wkt::internal::I32>>,
6301 >::deserialize(deserializer)
6302 .map(__With)
6303 }
6304 }
6305 result.allowed_vehicle_indices =
6306 map.next_value::<__With>()?.0.unwrap_or_default();
6307 }
6308 __FieldTag::__costs_per_vehicle => {
6309 if !fields.insert(__FieldTag::__costs_per_vehicle) {
6310 return std::result::Result::Err(A::Error::duplicate_field(
6311 "multiple values for costs_per_vehicle",
6312 ));
6313 }
6314 struct __With(std::option::Option<std::vec::Vec<f64>>);
6315 impl<'de> serde::de::Deserialize<'de> for __With {
6316 fn deserialize<D>(
6317 deserializer: D,
6318 ) -> std::result::Result<Self, D::Error>
6319 where
6320 D: serde::de::Deserializer<'de>,
6321 {
6322 serde_with::As::<
6323 std::option::Option<std::vec::Vec<wkt::internal::F64>>,
6324 >::deserialize(deserializer)
6325 .map(__With)
6326 }
6327 }
6328 result.costs_per_vehicle =
6329 map.next_value::<__With>()?.0.unwrap_or_default();
6330 }
6331 __FieldTag::__costs_per_vehicle_indices => {
6332 if !fields.insert(__FieldTag::__costs_per_vehicle_indices) {
6333 return std::result::Result::Err(A::Error::duplicate_field(
6334 "multiple values for costs_per_vehicle_indices",
6335 ));
6336 }
6337 struct __With(std::option::Option<std::vec::Vec<i32>>);
6338 impl<'de> serde::de::Deserialize<'de> for __With {
6339 fn deserialize<D>(
6340 deserializer: D,
6341 ) -> std::result::Result<Self, D::Error>
6342 where
6343 D: serde::de::Deserializer<'de>,
6344 {
6345 serde_with::As::<
6346 std::option::Option<std::vec::Vec<wkt::internal::I32>>,
6347 >::deserialize(deserializer)
6348 .map(__With)
6349 }
6350 }
6351 result.costs_per_vehicle_indices =
6352 map.next_value::<__With>()?.0.unwrap_or_default();
6353 }
6354 __FieldTag::__pickup_to_delivery_relative_detour_limit => {
6355 if !fields
6356 .insert(__FieldTag::__pickup_to_delivery_relative_detour_limit)
6357 {
6358 return std::result::Result::Err(A::Error::duplicate_field(
6359 "multiple values for pickup_to_delivery_relative_detour_limit",
6360 ));
6361 }
6362 struct __With(std::option::Option<f64>);
6363 impl<'de> serde::de::Deserialize<'de> for __With {
6364 fn deserialize<D>(
6365 deserializer: D,
6366 ) -> std::result::Result<Self, D::Error>
6367 where
6368 D: serde::de::Deserializer<'de>,
6369 {
6370 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
6371 }
6372 }
6373 result.pickup_to_delivery_relative_detour_limit =
6374 map.next_value::<__With>()?.0;
6375 }
6376 __FieldTag::__pickup_to_delivery_absolute_detour_limit => {
6377 if !fields
6378 .insert(__FieldTag::__pickup_to_delivery_absolute_detour_limit)
6379 {
6380 return std::result::Result::Err(A::Error::duplicate_field(
6381 "multiple values for pickup_to_delivery_absolute_detour_limit",
6382 ));
6383 }
6384 result.pickup_to_delivery_absolute_detour_limit =
6385 map.next_value::<std::option::Option<wkt::Duration>>()?;
6386 }
6387 __FieldTag::__pickup_to_delivery_time_limit => {
6388 if !fields.insert(__FieldTag::__pickup_to_delivery_time_limit) {
6389 return std::result::Result::Err(A::Error::duplicate_field(
6390 "multiple values for pickup_to_delivery_time_limit",
6391 ));
6392 }
6393 result.pickup_to_delivery_time_limit =
6394 map.next_value::<std::option::Option<wkt::Duration>>()?;
6395 }
6396 __FieldTag::__shipment_type => {
6397 if !fields.insert(__FieldTag::__shipment_type) {
6398 return std::result::Result::Err(A::Error::duplicate_field(
6399 "multiple values for shipment_type",
6400 ));
6401 }
6402 result.shipment_type = map
6403 .next_value::<std::option::Option<std::string::String>>()?
6404 .unwrap_or_default();
6405 }
6406 __FieldTag::__label => {
6407 if !fields.insert(__FieldTag::__label) {
6408 return std::result::Result::Err(A::Error::duplicate_field(
6409 "multiple values for label",
6410 ));
6411 }
6412 result.label = map
6413 .next_value::<std::option::Option<std::string::String>>()?
6414 .unwrap_or_default();
6415 }
6416 __FieldTag::__ignore => {
6417 if !fields.insert(__FieldTag::__ignore) {
6418 return std::result::Result::Err(A::Error::duplicate_field(
6419 "multiple values for ignore",
6420 ));
6421 }
6422 result.ignore = map
6423 .next_value::<std::option::Option<bool>>()?
6424 .unwrap_or_default();
6425 }
6426 __FieldTag::__demands => {
6427 if !fields.insert(__FieldTag::__demands) {
6428 return std::result::Result::Err(A::Error::duplicate_field(
6429 "multiple values for demands",
6430 ));
6431 }
6432 result.demands =
6433 map.next_value::<std::option::Option<
6434 std::vec::Vec<crate::model::CapacityQuantity>,
6435 >>()?
6436 .unwrap_or_default();
6437 }
6438 __FieldTag::Unknown(key) => {
6439 let value = map.next_value::<serde_json::Value>()?;
6440 result._unknown_fields.insert(key, value);
6441 }
6442 }
6443 }
6444 std::result::Result::Ok(result)
6445 }
6446 }
6447 deserializer.deserialize_any(Visitor)
6448 }
6449}
6450
6451#[doc(hidden)]
6452impl serde::ser::Serialize for Shipment {
6453 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6454 where
6455 S: serde::ser::Serializer,
6456 {
6457 use serde::ser::SerializeMap;
6458 #[allow(unused_imports)]
6459 use std::option::Option::Some;
6460 let mut state = serializer.serialize_map(std::option::Option::None)?;
6461 if !self.pickups.is_empty() {
6462 state.serialize_entry("pickups", &self.pickups)?;
6463 }
6464 if !self.deliveries.is_empty() {
6465 state.serialize_entry("deliveries", &self.deliveries)?;
6466 }
6467 if !self.load_demands.is_empty() {
6468 state.serialize_entry("loadDemands", &self.load_demands)?;
6469 }
6470 if self.penalty_cost.is_some() {
6471 struct __With<'a>(&'a std::option::Option<f64>);
6472 impl<'a> serde::ser::Serialize for __With<'a> {
6473 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6474 where
6475 S: serde::ser::Serializer,
6476 {
6477 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
6478 self.0, serializer,
6479 )
6480 }
6481 }
6482 state.serialize_entry("penaltyCost", &__With(&self.penalty_cost))?;
6483 }
6484 if !self.allowed_vehicle_indices.is_empty() {
6485 struct __With<'a>(&'a std::vec::Vec<i32>);
6486 impl<'a> serde::ser::Serialize for __With<'a> {
6487 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6488 where
6489 S: serde::ser::Serializer,
6490 {
6491 serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
6492 self.0, serializer,
6493 )
6494 }
6495 }
6496 state.serialize_entry(
6497 "allowedVehicleIndices",
6498 &__With(&self.allowed_vehicle_indices),
6499 )?;
6500 }
6501 if !self.costs_per_vehicle.is_empty() {
6502 struct __With<'a>(&'a std::vec::Vec<f64>);
6503 impl<'a> serde::ser::Serialize for __With<'a> {
6504 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6505 where
6506 S: serde::ser::Serializer,
6507 {
6508 serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
6509 self.0, serializer,
6510 )
6511 }
6512 }
6513 state.serialize_entry("costsPerVehicle", &__With(&self.costs_per_vehicle))?;
6514 }
6515 if !self.costs_per_vehicle_indices.is_empty() {
6516 struct __With<'a>(&'a std::vec::Vec<i32>);
6517 impl<'a> serde::ser::Serialize for __With<'a> {
6518 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6519 where
6520 S: serde::ser::Serializer,
6521 {
6522 serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
6523 self.0, serializer,
6524 )
6525 }
6526 }
6527 state.serialize_entry(
6528 "costsPerVehicleIndices",
6529 &__With(&self.costs_per_vehicle_indices),
6530 )?;
6531 }
6532 if self.pickup_to_delivery_relative_detour_limit.is_some() {
6533 struct __With<'a>(&'a std::option::Option<f64>);
6534 impl<'a> serde::ser::Serialize for __With<'a> {
6535 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6536 where
6537 S: serde::ser::Serializer,
6538 {
6539 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
6540 self.0, serializer,
6541 )
6542 }
6543 }
6544 state.serialize_entry(
6545 "pickupToDeliveryRelativeDetourLimit",
6546 &__With(&self.pickup_to_delivery_relative_detour_limit),
6547 )?;
6548 }
6549 if self.pickup_to_delivery_absolute_detour_limit.is_some() {
6550 state.serialize_entry(
6551 "pickupToDeliveryAbsoluteDetourLimit",
6552 &self.pickup_to_delivery_absolute_detour_limit,
6553 )?;
6554 }
6555 if self.pickup_to_delivery_time_limit.is_some() {
6556 state.serialize_entry(
6557 "pickupToDeliveryTimeLimit",
6558 &self.pickup_to_delivery_time_limit,
6559 )?;
6560 }
6561 if !self.shipment_type.is_empty() {
6562 state.serialize_entry("shipmentType", &self.shipment_type)?;
6563 }
6564 if !self.label.is_empty() {
6565 state.serialize_entry("label", &self.label)?;
6566 }
6567 if !wkt::internal::is_default(&self.ignore) {
6568 state.serialize_entry("ignore", &self.ignore)?;
6569 }
6570 if !self.demands.is_empty() {
6571 state.serialize_entry("demands", &self.demands)?;
6572 }
6573 if !self._unknown_fields.is_empty() {
6574 for (key, value) in self._unknown_fields.iter() {
6575 state.serialize_entry(key, &value)?;
6576 }
6577 }
6578 state.end()
6579 }
6580}
6581
6582pub mod shipment {
6584 #[allow(unused_imports)]
6585 use super::*;
6586
6587 #[derive(Clone, Debug, Default, PartialEq)]
6592 #[non_exhaustive]
6593 pub struct VisitRequest {
6594 pub arrival_location: std::option::Option<gtype::model::LatLng>,
6598
6599 pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
6603
6604 pub departure_location: std::option::Option<gtype::model::LatLng>,
6609
6610 pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
6615
6616 pub tags: std::vec::Vec<std::string::String>,
6619
6620 pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
6637
6638 pub duration: std::option::Option<wkt::Duration>,
6642
6643 pub cost: f64,
6648
6649 pub load_demands:
6661 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
6662
6663 pub visit_types: std::vec::Vec<std::string::String>,
6671
6672 pub label: std::string::String,
6678
6679 #[deprecated]
6685 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
6686
6687 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6688 }
6689
6690 impl VisitRequest {
6691 pub fn new() -> Self {
6692 std::default::Default::default()
6693 }
6694
6695 pub fn set_arrival_location<T>(mut self, v: T) -> Self
6697 where
6698 T: std::convert::Into<gtype::model::LatLng>,
6699 {
6700 self.arrival_location = std::option::Option::Some(v.into());
6701 self
6702 }
6703
6704 pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
6706 where
6707 T: std::convert::Into<gtype::model::LatLng>,
6708 {
6709 self.arrival_location = v.map(|x| x.into());
6710 self
6711 }
6712
6713 pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
6715 where
6716 T: std::convert::Into<crate::model::Waypoint>,
6717 {
6718 self.arrival_waypoint = std::option::Option::Some(v.into());
6719 self
6720 }
6721
6722 pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
6724 where
6725 T: std::convert::Into<crate::model::Waypoint>,
6726 {
6727 self.arrival_waypoint = v.map(|x| x.into());
6728 self
6729 }
6730
6731 pub fn set_departure_location<T>(mut self, v: T) -> Self
6733 where
6734 T: std::convert::Into<gtype::model::LatLng>,
6735 {
6736 self.departure_location = std::option::Option::Some(v.into());
6737 self
6738 }
6739
6740 pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
6742 where
6743 T: std::convert::Into<gtype::model::LatLng>,
6744 {
6745 self.departure_location = v.map(|x| x.into());
6746 self
6747 }
6748
6749 pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
6751 where
6752 T: std::convert::Into<crate::model::Waypoint>,
6753 {
6754 self.departure_waypoint = std::option::Option::Some(v.into());
6755 self
6756 }
6757
6758 pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
6760 where
6761 T: std::convert::Into<crate::model::Waypoint>,
6762 {
6763 self.departure_waypoint = v.map(|x| x.into());
6764 self
6765 }
6766
6767 pub fn set_tags<T, V>(mut self, v: T) -> Self
6769 where
6770 T: std::iter::IntoIterator<Item = V>,
6771 V: std::convert::Into<std::string::String>,
6772 {
6773 use std::iter::Iterator;
6774 self.tags = v.into_iter().map(|i| i.into()).collect();
6775 self
6776 }
6777
6778 pub fn set_time_windows<T, V>(mut self, v: T) -> Self
6780 where
6781 T: std::iter::IntoIterator<Item = V>,
6782 V: std::convert::Into<crate::model::TimeWindow>,
6783 {
6784 use std::iter::Iterator;
6785 self.time_windows = v.into_iter().map(|i| i.into()).collect();
6786 self
6787 }
6788
6789 pub fn set_duration<T>(mut self, v: T) -> Self
6791 where
6792 T: std::convert::Into<wkt::Duration>,
6793 {
6794 self.duration = std::option::Option::Some(v.into());
6795 self
6796 }
6797
6798 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
6800 where
6801 T: std::convert::Into<wkt::Duration>,
6802 {
6803 self.duration = v.map(|x| x.into());
6804 self
6805 }
6806
6807 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
6809 self.cost = v.into();
6810 self
6811 }
6812
6813 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
6815 where
6816 T: std::iter::IntoIterator<Item = (K, V)>,
6817 K: std::convert::Into<std::string::String>,
6818 V: std::convert::Into<crate::model::shipment::Load>,
6819 {
6820 use std::iter::Iterator;
6821 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6822 self
6823 }
6824
6825 pub fn set_visit_types<T, V>(mut self, v: T) -> Self
6827 where
6828 T: std::iter::IntoIterator<Item = V>,
6829 V: std::convert::Into<std::string::String>,
6830 {
6831 use std::iter::Iterator;
6832 self.visit_types = v.into_iter().map(|i| i.into()).collect();
6833 self
6834 }
6835
6836 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6838 self.label = v.into();
6839 self
6840 }
6841
6842 #[deprecated]
6844 pub fn set_demands<T, V>(mut self, v: T) -> Self
6845 where
6846 T: std::iter::IntoIterator<Item = V>,
6847 V: std::convert::Into<crate::model::CapacityQuantity>,
6848 {
6849 use std::iter::Iterator;
6850 self.demands = v.into_iter().map(|i| i.into()).collect();
6851 self
6852 }
6853 }
6854
6855 impl wkt::message::Message for VisitRequest {
6856 fn typename() -> &'static str {
6857 "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
6858 }
6859 }
6860
6861 #[doc(hidden)]
6862 impl<'de> serde::de::Deserialize<'de> for VisitRequest {
6863 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6864 where
6865 D: serde::Deserializer<'de>,
6866 {
6867 #[allow(non_camel_case_types)]
6868 #[doc(hidden)]
6869 #[derive(PartialEq, Eq, Hash)]
6870 enum __FieldTag {
6871 __arrival_location,
6872 __arrival_waypoint,
6873 __departure_location,
6874 __departure_waypoint,
6875 __tags,
6876 __time_windows,
6877 __duration,
6878 __cost,
6879 __load_demands,
6880 __visit_types,
6881 __label,
6882 __demands,
6883 Unknown(std::string::String),
6884 }
6885 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6886 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6887 where
6888 D: serde::Deserializer<'de>,
6889 {
6890 struct Visitor;
6891 impl<'de> serde::de::Visitor<'de> for Visitor {
6892 type Value = __FieldTag;
6893 fn expecting(
6894 &self,
6895 formatter: &mut std::fmt::Formatter,
6896 ) -> std::fmt::Result {
6897 formatter.write_str("a field name for VisitRequest")
6898 }
6899 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6900 where
6901 E: serde::de::Error,
6902 {
6903 use std::result::Result::Ok;
6904 use std::string::ToString;
6905 match value {
6906 "arrivalLocation" => Ok(__FieldTag::__arrival_location),
6907 "arrival_location" => Ok(__FieldTag::__arrival_location),
6908 "arrivalWaypoint" => Ok(__FieldTag::__arrival_waypoint),
6909 "arrival_waypoint" => Ok(__FieldTag::__arrival_waypoint),
6910 "departureLocation" => Ok(__FieldTag::__departure_location),
6911 "departure_location" => Ok(__FieldTag::__departure_location),
6912 "departureWaypoint" => Ok(__FieldTag::__departure_waypoint),
6913 "departure_waypoint" => Ok(__FieldTag::__departure_waypoint),
6914 "tags" => Ok(__FieldTag::__tags),
6915 "timeWindows" => Ok(__FieldTag::__time_windows),
6916 "time_windows" => Ok(__FieldTag::__time_windows),
6917 "duration" => Ok(__FieldTag::__duration),
6918 "cost" => Ok(__FieldTag::__cost),
6919 "loadDemands" => Ok(__FieldTag::__load_demands),
6920 "load_demands" => Ok(__FieldTag::__load_demands),
6921 "visitTypes" => Ok(__FieldTag::__visit_types),
6922 "visit_types" => Ok(__FieldTag::__visit_types),
6923 "label" => Ok(__FieldTag::__label),
6924 "demands" => Ok(__FieldTag::__demands),
6925 _ => Ok(__FieldTag::Unknown(value.to_string())),
6926 }
6927 }
6928 }
6929 deserializer.deserialize_identifier(Visitor)
6930 }
6931 }
6932 struct Visitor;
6933 impl<'de> serde::de::Visitor<'de> for Visitor {
6934 type Value = VisitRequest;
6935 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6936 formatter.write_str("struct VisitRequest")
6937 }
6938 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6939 where
6940 A: serde::de::MapAccess<'de>,
6941 {
6942 #[allow(unused_imports)]
6943 use serde::de::Error;
6944 use std::option::Option::Some;
6945 let mut fields = std::collections::HashSet::new();
6946 let mut result = Self::Value::new();
6947 while let Some(tag) = map.next_key::<__FieldTag>()? {
6948 #[allow(clippy::match_single_binding)]
6949 match tag {
6950 __FieldTag::__arrival_location => {
6951 if !fields.insert(__FieldTag::__arrival_location) {
6952 return std::result::Result::Err(A::Error::duplicate_field(
6953 "multiple values for arrival_location",
6954 ));
6955 }
6956 result.arrival_location =
6957 map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
6958 }
6959 __FieldTag::__arrival_waypoint => {
6960 if !fields.insert(__FieldTag::__arrival_waypoint) {
6961 return std::result::Result::Err(A::Error::duplicate_field(
6962 "multiple values for arrival_waypoint",
6963 ));
6964 }
6965 result.arrival_waypoint = map
6966 .next_value::<std::option::Option<crate::model::Waypoint>>()?;
6967 }
6968 __FieldTag::__departure_location => {
6969 if !fields.insert(__FieldTag::__departure_location) {
6970 return std::result::Result::Err(A::Error::duplicate_field(
6971 "multiple values for departure_location",
6972 ));
6973 }
6974 result.departure_location =
6975 map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
6976 }
6977 __FieldTag::__departure_waypoint => {
6978 if !fields.insert(__FieldTag::__departure_waypoint) {
6979 return std::result::Result::Err(A::Error::duplicate_field(
6980 "multiple values for departure_waypoint",
6981 ));
6982 }
6983 result.departure_waypoint = map
6984 .next_value::<std::option::Option<crate::model::Waypoint>>()?;
6985 }
6986 __FieldTag::__tags => {
6987 if !fields.insert(__FieldTag::__tags) {
6988 return std::result::Result::Err(A::Error::duplicate_field(
6989 "multiple values for tags",
6990 ));
6991 }
6992 result.tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
6993 }
6994 __FieldTag::__time_windows => {
6995 if !fields.insert(__FieldTag::__time_windows) {
6996 return std::result::Result::Err(A::Error::duplicate_field(
6997 "multiple values for time_windows",
6998 ));
6999 }
7000 result.time_windows =
7001 map.next_value::<std::option::Option<
7002 std::vec::Vec<crate::model::TimeWindow>,
7003 >>()?
7004 .unwrap_or_default();
7005 }
7006 __FieldTag::__duration => {
7007 if !fields.insert(__FieldTag::__duration) {
7008 return std::result::Result::Err(A::Error::duplicate_field(
7009 "multiple values for duration",
7010 ));
7011 }
7012 result.duration =
7013 map.next_value::<std::option::Option<wkt::Duration>>()?;
7014 }
7015 __FieldTag::__cost => {
7016 if !fields.insert(__FieldTag::__cost) {
7017 return std::result::Result::Err(A::Error::duplicate_field(
7018 "multiple values for cost",
7019 ));
7020 }
7021 struct __With(std::option::Option<f64>);
7022 impl<'de> serde::de::Deserialize<'de> for __With {
7023 fn deserialize<D>(
7024 deserializer: D,
7025 ) -> std::result::Result<Self, D::Error>
7026 where
7027 D: serde::de::Deserializer<'de>,
7028 {
7029 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
7030 }
7031 }
7032 result.cost = map.next_value::<__With>()?.0.unwrap_or_default();
7033 }
7034 __FieldTag::__load_demands => {
7035 if !fields.insert(__FieldTag::__load_demands) {
7036 return std::result::Result::Err(A::Error::duplicate_field(
7037 "multiple values for load_demands",
7038 ));
7039 }
7040 result.load_demands = map
7041 .next_value::<std::option::Option<
7042 std::collections::HashMap<
7043 std::string::String,
7044 crate::model::shipment::Load,
7045 >,
7046 >>()?
7047 .unwrap_or_default();
7048 }
7049 __FieldTag::__visit_types => {
7050 if !fields.insert(__FieldTag::__visit_types) {
7051 return std::result::Result::Err(A::Error::duplicate_field(
7052 "multiple values for visit_types",
7053 ));
7054 }
7055 result.visit_types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7056 }
7057 __FieldTag::__label => {
7058 if !fields.insert(__FieldTag::__label) {
7059 return std::result::Result::Err(A::Error::duplicate_field(
7060 "multiple values for label",
7061 ));
7062 }
7063 result.label = map
7064 .next_value::<std::option::Option<std::string::String>>()?
7065 .unwrap_or_default();
7066 }
7067 __FieldTag::__demands => {
7068 if !fields.insert(__FieldTag::__demands) {
7069 return std::result::Result::Err(A::Error::duplicate_field(
7070 "multiple values for demands",
7071 ));
7072 }
7073 result.demands = map
7074 .next_value::<std::option::Option<
7075 std::vec::Vec<crate::model::CapacityQuantity>,
7076 >>()?
7077 .unwrap_or_default();
7078 }
7079 __FieldTag::Unknown(key) => {
7080 let value = map.next_value::<serde_json::Value>()?;
7081 result._unknown_fields.insert(key, value);
7082 }
7083 }
7084 }
7085 std::result::Result::Ok(result)
7086 }
7087 }
7088 deserializer.deserialize_any(Visitor)
7089 }
7090 }
7091
7092 #[doc(hidden)]
7093 impl serde::ser::Serialize for VisitRequest {
7094 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7095 where
7096 S: serde::ser::Serializer,
7097 {
7098 use serde::ser::SerializeMap;
7099 #[allow(unused_imports)]
7100 use std::option::Option::Some;
7101 let mut state = serializer.serialize_map(std::option::Option::None)?;
7102 if self.arrival_location.is_some() {
7103 state.serialize_entry("arrivalLocation", &self.arrival_location)?;
7104 }
7105 if self.arrival_waypoint.is_some() {
7106 state.serialize_entry("arrivalWaypoint", &self.arrival_waypoint)?;
7107 }
7108 if self.departure_location.is_some() {
7109 state.serialize_entry("departureLocation", &self.departure_location)?;
7110 }
7111 if self.departure_waypoint.is_some() {
7112 state.serialize_entry("departureWaypoint", &self.departure_waypoint)?;
7113 }
7114 if !self.tags.is_empty() {
7115 state.serialize_entry("tags", &self.tags)?;
7116 }
7117 if !self.time_windows.is_empty() {
7118 state.serialize_entry("timeWindows", &self.time_windows)?;
7119 }
7120 if self.duration.is_some() {
7121 state.serialize_entry("duration", &self.duration)?;
7122 }
7123 if !wkt::internal::is_default(&self.cost) {
7124 struct __With<'a>(&'a f64);
7125 impl<'a> serde::ser::Serialize for __With<'a> {
7126 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7127 where
7128 S: serde::ser::Serializer,
7129 {
7130 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
7131 }
7132 }
7133 state.serialize_entry("cost", &__With(&self.cost))?;
7134 }
7135 if !self.load_demands.is_empty() {
7136 state.serialize_entry("loadDemands", &self.load_demands)?;
7137 }
7138 if !self.visit_types.is_empty() {
7139 state.serialize_entry("visitTypes", &self.visit_types)?;
7140 }
7141 if !self.label.is_empty() {
7142 state.serialize_entry("label", &self.label)?;
7143 }
7144 if !self.demands.is_empty() {
7145 state.serialize_entry("demands", &self.demands)?;
7146 }
7147 if !self._unknown_fields.is_empty() {
7148 for (key, value) in self._unknown_fields.iter() {
7149 state.serialize_entry(key, &value)?;
7150 }
7151 }
7152 state.end()
7153 }
7154 }
7155
7156 #[derive(Clone, Debug, Default, PartialEq)]
7163 #[non_exhaustive]
7164 pub struct Load {
7165 pub amount: i64,
7169
7170 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7171 }
7172
7173 impl Load {
7174 pub fn new() -> Self {
7175 std::default::Default::default()
7176 }
7177
7178 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7180 self.amount = v.into();
7181 self
7182 }
7183 }
7184
7185 impl wkt::message::Message for Load {
7186 fn typename() -> &'static str {
7187 "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
7188 }
7189 }
7190
7191 #[doc(hidden)]
7192 impl<'de> serde::de::Deserialize<'de> for Load {
7193 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7194 where
7195 D: serde::Deserializer<'de>,
7196 {
7197 #[allow(non_camel_case_types)]
7198 #[doc(hidden)]
7199 #[derive(PartialEq, Eq, Hash)]
7200 enum __FieldTag {
7201 __amount,
7202 Unknown(std::string::String),
7203 }
7204 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7205 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7206 where
7207 D: serde::Deserializer<'de>,
7208 {
7209 struct Visitor;
7210 impl<'de> serde::de::Visitor<'de> for Visitor {
7211 type Value = __FieldTag;
7212 fn expecting(
7213 &self,
7214 formatter: &mut std::fmt::Formatter,
7215 ) -> std::fmt::Result {
7216 formatter.write_str("a field name for Load")
7217 }
7218 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7219 where
7220 E: serde::de::Error,
7221 {
7222 use std::result::Result::Ok;
7223 use std::string::ToString;
7224 match value {
7225 "amount" => Ok(__FieldTag::__amount),
7226 _ => Ok(__FieldTag::Unknown(value.to_string())),
7227 }
7228 }
7229 }
7230 deserializer.deserialize_identifier(Visitor)
7231 }
7232 }
7233 struct Visitor;
7234 impl<'de> serde::de::Visitor<'de> for Visitor {
7235 type Value = Load;
7236 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7237 formatter.write_str("struct Load")
7238 }
7239 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7240 where
7241 A: serde::de::MapAccess<'de>,
7242 {
7243 #[allow(unused_imports)]
7244 use serde::de::Error;
7245 use std::option::Option::Some;
7246 let mut fields = std::collections::HashSet::new();
7247 let mut result = Self::Value::new();
7248 while let Some(tag) = map.next_key::<__FieldTag>()? {
7249 #[allow(clippy::match_single_binding)]
7250 match tag {
7251 __FieldTag::__amount => {
7252 if !fields.insert(__FieldTag::__amount) {
7253 return std::result::Result::Err(A::Error::duplicate_field(
7254 "multiple values for amount",
7255 ));
7256 }
7257 struct __With(std::option::Option<i64>);
7258 impl<'de> serde::de::Deserialize<'de> for __With {
7259 fn deserialize<D>(
7260 deserializer: D,
7261 ) -> std::result::Result<Self, D::Error>
7262 where
7263 D: serde::de::Deserializer<'de>,
7264 {
7265 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
7266 }
7267 }
7268 result.amount = map.next_value::<__With>()?.0.unwrap_or_default();
7269 }
7270 __FieldTag::Unknown(key) => {
7271 let value = map.next_value::<serde_json::Value>()?;
7272 result._unknown_fields.insert(key, value);
7273 }
7274 }
7275 }
7276 std::result::Result::Ok(result)
7277 }
7278 }
7279 deserializer.deserialize_any(Visitor)
7280 }
7281 }
7282
7283 #[doc(hidden)]
7284 impl serde::ser::Serialize for Load {
7285 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7286 where
7287 S: serde::ser::Serializer,
7288 {
7289 use serde::ser::SerializeMap;
7290 #[allow(unused_imports)]
7291 use std::option::Option::Some;
7292 let mut state = serializer.serialize_map(std::option::Option::None)?;
7293 if !wkt::internal::is_default(&self.amount) {
7294 struct __With<'a>(&'a i64);
7295 impl<'a> serde::ser::Serialize for __With<'a> {
7296 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7297 where
7298 S: serde::ser::Serializer,
7299 {
7300 serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
7301 }
7302 }
7303 state.serialize_entry("amount", &__With(&self.amount))?;
7304 }
7305 if !self._unknown_fields.is_empty() {
7306 for (key, value) in self._unknown_fields.iter() {
7307 state.serialize_entry(key, &value)?;
7308 }
7309 }
7310 state.end()
7311 }
7312 }
7313}
7314
7315#[derive(Clone, Debug, Default, PartialEq)]
7319#[non_exhaustive]
7320pub struct ShipmentTypeIncompatibility {
7321 pub types: std::vec::Vec<std::string::String>,
7324
7325 pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
7327
7328 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7329}
7330
7331impl ShipmentTypeIncompatibility {
7332 pub fn new() -> Self {
7333 std::default::Default::default()
7334 }
7335
7336 pub fn set_types<T, V>(mut self, v: T) -> Self
7338 where
7339 T: std::iter::IntoIterator<Item = V>,
7340 V: std::convert::Into<std::string::String>,
7341 {
7342 use std::iter::Iterator;
7343 self.types = v.into_iter().map(|i| i.into()).collect();
7344 self
7345 }
7346
7347 pub fn set_incompatibility_mode<
7349 T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
7350 >(
7351 mut self,
7352 v: T,
7353 ) -> Self {
7354 self.incompatibility_mode = v.into();
7355 self
7356 }
7357}
7358
7359impl wkt::message::Message for ShipmentTypeIncompatibility {
7360 fn typename() -> &'static str {
7361 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
7362 }
7363}
7364
7365#[doc(hidden)]
7366impl<'de> serde::de::Deserialize<'de> for ShipmentTypeIncompatibility {
7367 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7368 where
7369 D: serde::Deserializer<'de>,
7370 {
7371 #[allow(non_camel_case_types)]
7372 #[doc(hidden)]
7373 #[derive(PartialEq, Eq, Hash)]
7374 enum __FieldTag {
7375 __types,
7376 __incompatibility_mode,
7377 Unknown(std::string::String),
7378 }
7379 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7380 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7381 where
7382 D: serde::Deserializer<'de>,
7383 {
7384 struct Visitor;
7385 impl<'de> serde::de::Visitor<'de> for Visitor {
7386 type Value = __FieldTag;
7387 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7388 formatter.write_str("a field name for ShipmentTypeIncompatibility")
7389 }
7390 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7391 where
7392 E: serde::de::Error,
7393 {
7394 use std::result::Result::Ok;
7395 use std::string::ToString;
7396 match value {
7397 "types" => Ok(__FieldTag::__types),
7398 "incompatibilityMode" => Ok(__FieldTag::__incompatibility_mode),
7399 "incompatibility_mode" => Ok(__FieldTag::__incompatibility_mode),
7400 _ => Ok(__FieldTag::Unknown(value.to_string())),
7401 }
7402 }
7403 }
7404 deserializer.deserialize_identifier(Visitor)
7405 }
7406 }
7407 struct Visitor;
7408 impl<'de> serde::de::Visitor<'de> for Visitor {
7409 type Value = ShipmentTypeIncompatibility;
7410 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7411 formatter.write_str("struct ShipmentTypeIncompatibility")
7412 }
7413 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7414 where
7415 A: serde::de::MapAccess<'de>,
7416 {
7417 #[allow(unused_imports)]
7418 use serde::de::Error;
7419 use std::option::Option::Some;
7420 let mut fields = std::collections::HashSet::new();
7421 let mut result = Self::Value::new();
7422 while let Some(tag) = map.next_key::<__FieldTag>()? {
7423 #[allow(clippy::match_single_binding)]
7424 match tag {
7425 __FieldTag::__types => {
7426 if !fields.insert(__FieldTag::__types) {
7427 return std::result::Result::Err(A::Error::duplicate_field(
7428 "multiple values for types",
7429 ));
7430 }
7431 result.types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7432 }
7433 __FieldTag::__incompatibility_mode => {
7434 if !fields.insert(__FieldTag::__incompatibility_mode) {
7435 return std::result::Result::Err(A::Error::duplicate_field(
7436 "multiple values for incompatibility_mode",
7437 ));
7438 }
7439 result.incompatibility_mode = map.next_value::<std::option::Option<crate::model::shipment_type_incompatibility::IncompatibilityMode>>()?.unwrap_or_default();
7440 }
7441 __FieldTag::Unknown(key) => {
7442 let value = map.next_value::<serde_json::Value>()?;
7443 result._unknown_fields.insert(key, value);
7444 }
7445 }
7446 }
7447 std::result::Result::Ok(result)
7448 }
7449 }
7450 deserializer.deserialize_any(Visitor)
7451 }
7452}
7453
7454#[doc(hidden)]
7455impl serde::ser::Serialize for ShipmentTypeIncompatibility {
7456 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7457 where
7458 S: serde::ser::Serializer,
7459 {
7460 use serde::ser::SerializeMap;
7461 #[allow(unused_imports)]
7462 use std::option::Option::Some;
7463 let mut state = serializer.serialize_map(std::option::Option::None)?;
7464 if !self.types.is_empty() {
7465 state.serialize_entry("types", &self.types)?;
7466 }
7467 if !wkt::internal::is_default(&self.incompatibility_mode) {
7468 state.serialize_entry("incompatibilityMode", &self.incompatibility_mode)?;
7469 }
7470 if !self._unknown_fields.is_empty() {
7471 for (key, value) in self._unknown_fields.iter() {
7472 state.serialize_entry(key, &value)?;
7473 }
7474 }
7475 state.end()
7476 }
7477}
7478
7479pub mod shipment_type_incompatibility {
7481 #[allow(unused_imports)]
7482 use super::*;
7483
7484 #[derive(Clone, Debug, PartialEq)]
7501 #[non_exhaustive]
7502 pub enum IncompatibilityMode {
7503 Unspecified,
7505 NotPerformedBySameVehicle,
7508 NotInSameVehicleSimultaneously,
7517 UnknownValue(incompatibility_mode::UnknownValue),
7522 }
7523
7524 #[doc(hidden)]
7525 pub mod incompatibility_mode {
7526 #[allow(unused_imports)]
7527 use super::*;
7528 #[derive(Clone, Debug, PartialEq)]
7529 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7530 }
7531
7532 impl IncompatibilityMode {
7533 pub fn value(&self) -> std::option::Option<i32> {
7538 match self {
7539 Self::Unspecified => std::option::Option::Some(0),
7540 Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
7541 Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
7542 Self::UnknownValue(u) => u.0.value(),
7543 }
7544 }
7545
7546 pub fn name(&self) -> std::option::Option<&str> {
7551 match self {
7552 Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
7553 Self::NotPerformedBySameVehicle => {
7554 std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
7555 }
7556 Self::NotInSameVehicleSimultaneously => {
7557 std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
7558 }
7559 Self::UnknownValue(u) => u.0.name(),
7560 }
7561 }
7562 }
7563
7564 impl std::default::Default for IncompatibilityMode {
7565 fn default() -> Self {
7566 use std::convert::From;
7567 Self::from(0)
7568 }
7569 }
7570
7571 impl std::fmt::Display for IncompatibilityMode {
7572 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7573 wkt::internal::display_enum(f, self.name(), self.value())
7574 }
7575 }
7576
7577 impl std::convert::From<i32> for IncompatibilityMode {
7578 fn from(value: i32) -> Self {
7579 match value {
7580 0 => Self::Unspecified,
7581 1 => Self::NotPerformedBySameVehicle,
7582 2 => Self::NotInSameVehicleSimultaneously,
7583 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
7584 wkt::internal::UnknownEnumValue::Integer(value),
7585 )),
7586 }
7587 }
7588 }
7589
7590 impl std::convert::From<&str> for IncompatibilityMode {
7591 fn from(value: &str) -> Self {
7592 use std::string::ToString;
7593 match value {
7594 "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
7595 "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
7596 "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
7597 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
7598 wkt::internal::UnknownEnumValue::String(value.to_string()),
7599 )),
7600 }
7601 }
7602 }
7603
7604 impl serde::ser::Serialize for IncompatibilityMode {
7605 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7606 where
7607 S: serde::Serializer,
7608 {
7609 match self {
7610 Self::Unspecified => serializer.serialize_i32(0),
7611 Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
7612 Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
7613 Self::UnknownValue(u) => u.0.serialize(serializer),
7614 }
7615 }
7616 }
7617
7618 impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
7619 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7620 where
7621 D: serde::Deserializer<'de>,
7622 {
7623 deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
7624 ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
7625 ))
7626 }
7627 }
7628}
7629
7630#[derive(Clone, Debug, Default, PartialEq)]
7633#[non_exhaustive]
7634pub struct ShipmentTypeRequirement {
7635 pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
7638
7639 pub dependent_shipment_types: std::vec::Vec<std::string::String>,
7646
7647 pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
7649
7650 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7651}
7652
7653impl ShipmentTypeRequirement {
7654 pub fn new() -> Self {
7655 std::default::Default::default()
7656 }
7657
7658 pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
7660 where
7661 T: std::iter::IntoIterator<Item = V>,
7662 V: std::convert::Into<std::string::String>,
7663 {
7664 use std::iter::Iterator;
7665 self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
7666 self
7667 }
7668
7669 pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
7671 where
7672 T: std::iter::IntoIterator<Item = V>,
7673 V: std::convert::Into<std::string::String>,
7674 {
7675 use std::iter::Iterator;
7676 self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
7677 self
7678 }
7679
7680 pub fn set_requirement_mode<
7682 T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
7683 >(
7684 mut self,
7685 v: T,
7686 ) -> Self {
7687 self.requirement_mode = v.into();
7688 self
7689 }
7690}
7691
7692impl wkt::message::Message for ShipmentTypeRequirement {
7693 fn typename() -> &'static str {
7694 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
7695 }
7696}
7697
7698#[doc(hidden)]
7699impl<'de> serde::de::Deserialize<'de> for ShipmentTypeRequirement {
7700 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7701 where
7702 D: serde::Deserializer<'de>,
7703 {
7704 #[allow(non_camel_case_types)]
7705 #[doc(hidden)]
7706 #[derive(PartialEq, Eq, Hash)]
7707 enum __FieldTag {
7708 __required_shipment_type_alternatives,
7709 __dependent_shipment_types,
7710 __requirement_mode,
7711 Unknown(std::string::String),
7712 }
7713 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7714 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7715 where
7716 D: serde::Deserializer<'de>,
7717 {
7718 struct Visitor;
7719 impl<'de> serde::de::Visitor<'de> for Visitor {
7720 type Value = __FieldTag;
7721 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7722 formatter.write_str("a field name for ShipmentTypeRequirement")
7723 }
7724 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7725 where
7726 E: serde::de::Error,
7727 {
7728 use std::result::Result::Ok;
7729 use std::string::ToString;
7730 match value {
7731 "requiredShipmentTypeAlternatives" => {
7732 Ok(__FieldTag::__required_shipment_type_alternatives)
7733 }
7734 "required_shipment_type_alternatives" => {
7735 Ok(__FieldTag::__required_shipment_type_alternatives)
7736 }
7737 "dependentShipmentTypes" => Ok(__FieldTag::__dependent_shipment_types),
7738 "dependent_shipment_types" => {
7739 Ok(__FieldTag::__dependent_shipment_types)
7740 }
7741 "requirementMode" => Ok(__FieldTag::__requirement_mode),
7742 "requirement_mode" => Ok(__FieldTag::__requirement_mode),
7743 _ => Ok(__FieldTag::Unknown(value.to_string())),
7744 }
7745 }
7746 }
7747 deserializer.deserialize_identifier(Visitor)
7748 }
7749 }
7750 struct Visitor;
7751 impl<'de> serde::de::Visitor<'de> for Visitor {
7752 type Value = ShipmentTypeRequirement;
7753 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7754 formatter.write_str("struct ShipmentTypeRequirement")
7755 }
7756 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7757 where
7758 A: serde::de::MapAccess<'de>,
7759 {
7760 #[allow(unused_imports)]
7761 use serde::de::Error;
7762 use std::option::Option::Some;
7763 let mut fields = std::collections::HashSet::new();
7764 let mut result = Self::Value::new();
7765 while let Some(tag) = map.next_key::<__FieldTag>()? {
7766 #[allow(clippy::match_single_binding)]
7767 match tag {
7768 __FieldTag::__required_shipment_type_alternatives => {
7769 if !fields.insert(__FieldTag::__required_shipment_type_alternatives) {
7770 return std::result::Result::Err(A::Error::duplicate_field(
7771 "multiple values for required_shipment_type_alternatives",
7772 ));
7773 }
7774 result.required_shipment_type_alternatives = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7775 }
7776 __FieldTag::__dependent_shipment_types => {
7777 if !fields.insert(__FieldTag::__dependent_shipment_types) {
7778 return std::result::Result::Err(A::Error::duplicate_field(
7779 "multiple values for dependent_shipment_types",
7780 ));
7781 }
7782 result.dependent_shipment_types = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
7783 }
7784 __FieldTag::__requirement_mode => {
7785 if !fields.insert(__FieldTag::__requirement_mode) {
7786 return std::result::Result::Err(A::Error::duplicate_field(
7787 "multiple values for requirement_mode",
7788 ));
7789 }
7790 result.requirement_mode = map
7791 .next_value::<std::option::Option<
7792 crate::model::shipment_type_requirement::RequirementMode,
7793 >>()?
7794 .unwrap_or_default();
7795 }
7796 __FieldTag::Unknown(key) => {
7797 let value = map.next_value::<serde_json::Value>()?;
7798 result._unknown_fields.insert(key, value);
7799 }
7800 }
7801 }
7802 std::result::Result::Ok(result)
7803 }
7804 }
7805 deserializer.deserialize_any(Visitor)
7806 }
7807}
7808
7809#[doc(hidden)]
7810impl serde::ser::Serialize for ShipmentTypeRequirement {
7811 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7812 where
7813 S: serde::ser::Serializer,
7814 {
7815 use serde::ser::SerializeMap;
7816 #[allow(unused_imports)]
7817 use std::option::Option::Some;
7818 let mut state = serializer.serialize_map(std::option::Option::None)?;
7819 if !self.required_shipment_type_alternatives.is_empty() {
7820 state.serialize_entry(
7821 "requiredShipmentTypeAlternatives",
7822 &self.required_shipment_type_alternatives,
7823 )?;
7824 }
7825 if !self.dependent_shipment_types.is_empty() {
7826 state.serialize_entry("dependentShipmentTypes", &self.dependent_shipment_types)?;
7827 }
7828 if !wkt::internal::is_default(&self.requirement_mode) {
7829 state.serialize_entry("requirementMode", &self.requirement_mode)?;
7830 }
7831 if !self._unknown_fields.is_empty() {
7832 for (key, value) in self._unknown_fields.iter() {
7833 state.serialize_entry(key, &value)?;
7834 }
7835 }
7836 state.end()
7837 }
7838}
7839
7840pub mod shipment_type_requirement {
7842 #[allow(unused_imports)]
7843 use super::*;
7844
7845 #[derive(Clone, Debug, PartialEq)]
7861 #[non_exhaustive]
7862 pub enum RequirementMode {
7863 Unspecified,
7865 PerformedBySameVehicle,
7868 InSameVehicleAtPickupTime,
7879 InSameVehicleAtDeliveryTime,
7882 UnknownValue(requirement_mode::UnknownValue),
7887 }
7888
7889 #[doc(hidden)]
7890 pub mod requirement_mode {
7891 #[allow(unused_imports)]
7892 use super::*;
7893 #[derive(Clone, Debug, PartialEq)]
7894 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7895 }
7896
7897 impl RequirementMode {
7898 pub fn value(&self) -> std::option::Option<i32> {
7903 match self {
7904 Self::Unspecified => std::option::Option::Some(0),
7905 Self::PerformedBySameVehicle => std::option::Option::Some(1),
7906 Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
7907 Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
7908 Self::UnknownValue(u) => u.0.value(),
7909 }
7910 }
7911
7912 pub fn name(&self) -> std::option::Option<&str> {
7917 match self {
7918 Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
7919 Self::PerformedBySameVehicle => {
7920 std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
7921 }
7922 Self::InSameVehicleAtPickupTime => {
7923 std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
7924 }
7925 Self::InSameVehicleAtDeliveryTime => {
7926 std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
7927 }
7928 Self::UnknownValue(u) => u.0.name(),
7929 }
7930 }
7931 }
7932
7933 impl std::default::Default for RequirementMode {
7934 fn default() -> Self {
7935 use std::convert::From;
7936 Self::from(0)
7937 }
7938 }
7939
7940 impl std::fmt::Display for RequirementMode {
7941 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7942 wkt::internal::display_enum(f, self.name(), self.value())
7943 }
7944 }
7945
7946 impl std::convert::From<i32> for RequirementMode {
7947 fn from(value: i32) -> Self {
7948 match value {
7949 0 => Self::Unspecified,
7950 1 => Self::PerformedBySameVehicle,
7951 2 => Self::InSameVehicleAtPickupTime,
7952 3 => Self::InSameVehicleAtDeliveryTime,
7953 _ => Self::UnknownValue(requirement_mode::UnknownValue(
7954 wkt::internal::UnknownEnumValue::Integer(value),
7955 )),
7956 }
7957 }
7958 }
7959
7960 impl std::convert::From<&str> for RequirementMode {
7961 fn from(value: &str) -> Self {
7962 use std::string::ToString;
7963 match value {
7964 "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
7965 "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
7966 "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
7967 "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
7968 _ => Self::UnknownValue(requirement_mode::UnknownValue(
7969 wkt::internal::UnknownEnumValue::String(value.to_string()),
7970 )),
7971 }
7972 }
7973 }
7974
7975 impl serde::ser::Serialize for RequirementMode {
7976 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7977 where
7978 S: serde::Serializer,
7979 {
7980 match self {
7981 Self::Unspecified => serializer.serialize_i32(0),
7982 Self::PerformedBySameVehicle => serializer.serialize_i32(1),
7983 Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
7984 Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
7985 Self::UnknownValue(u) => u.0.serialize(serializer),
7986 }
7987 }
7988 }
7989
7990 impl<'de> serde::de::Deserialize<'de> for RequirementMode {
7991 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7992 where
7993 D: serde::Deserializer<'de>,
7994 {
7995 deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
7996 ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
7997 ))
7998 }
7999 }
8000}
8001
8002#[derive(Clone, Debug, Default, PartialEq)]
8007#[non_exhaustive]
8008pub struct RouteModifiers {
8009 pub avoid_tolls: bool,
8013
8014 pub avoid_highways: bool,
8018
8019 pub avoid_ferries: bool,
8023
8024 pub avoid_indoor: bool,
8028
8029 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8030}
8031
8032impl RouteModifiers {
8033 pub fn new() -> Self {
8034 std::default::Default::default()
8035 }
8036
8037 pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8039 self.avoid_tolls = v.into();
8040 self
8041 }
8042
8043 pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8045 self.avoid_highways = v.into();
8046 self
8047 }
8048
8049 pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8051 self.avoid_ferries = v.into();
8052 self
8053 }
8054
8055 pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8057 self.avoid_indoor = v.into();
8058 self
8059 }
8060}
8061
8062impl wkt::message::Message for RouteModifiers {
8063 fn typename() -> &'static str {
8064 "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
8065 }
8066}
8067
8068#[doc(hidden)]
8069impl<'de> serde::de::Deserialize<'de> for RouteModifiers {
8070 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8071 where
8072 D: serde::Deserializer<'de>,
8073 {
8074 #[allow(non_camel_case_types)]
8075 #[doc(hidden)]
8076 #[derive(PartialEq, Eq, Hash)]
8077 enum __FieldTag {
8078 __avoid_tolls,
8079 __avoid_highways,
8080 __avoid_ferries,
8081 __avoid_indoor,
8082 Unknown(std::string::String),
8083 }
8084 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8085 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8086 where
8087 D: serde::Deserializer<'de>,
8088 {
8089 struct Visitor;
8090 impl<'de> serde::de::Visitor<'de> for Visitor {
8091 type Value = __FieldTag;
8092 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8093 formatter.write_str("a field name for RouteModifiers")
8094 }
8095 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8096 where
8097 E: serde::de::Error,
8098 {
8099 use std::result::Result::Ok;
8100 use std::string::ToString;
8101 match value {
8102 "avoidTolls" => Ok(__FieldTag::__avoid_tolls),
8103 "avoid_tolls" => Ok(__FieldTag::__avoid_tolls),
8104 "avoidHighways" => Ok(__FieldTag::__avoid_highways),
8105 "avoid_highways" => Ok(__FieldTag::__avoid_highways),
8106 "avoidFerries" => Ok(__FieldTag::__avoid_ferries),
8107 "avoid_ferries" => Ok(__FieldTag::__avoid_ferries),
8108 "avoidIndoor" => Ok(__FieldTag::__avoid_indoor),
8109 "avoid_indoor" => Ok(__FieldTag::__avoid_indoor),
8110 _ => Ok(__FieldTag::Unknown(value.to_string())),
8111 }
8112 }
8113 }
8114 deserializer.deserialize_identifier(Visitor)
8115 }
8116 }
8117 struct Visitor;
8118 impl<'de> serde::de::Visitor<'de> for Visitor {
8119 type Value = RouteModifiers;
8120 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8121 formatter.write_str("struct RouteModifiers")
8122 }
8123 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8124 where
8125 A: serde::de::MapAccess<'de>,
8126 {
8127 #[allow(unused_imports)]
8128 use serde::de::Error;
8129 use std::option::Option::Some;
8130 let mut fields = std::collections::HashSet::new();
8131 let mut result = Self::Value::new();
8132 while let Some(tag) = map.next_key::<__FieldTag>()? {
8133 #[allow(clippy::match_single_binding)]
8134 match tag {
8135 __FieldTag::__avoid_tolls => {
8136 if !fields.insert(__FieldTag::__avoid_tolls) {
8137 return std::result::Result::Err(A::Error::duplicate_field(
8138 "multiple values for avoid_tolls",
8139 ));
8140 }
8141 result.avoid_tolls = map
8142 .next_value::<std::option::Option<bool>>()?
8143 .unwrap_or_default();
8144 }
8145 __FieldTag::__avoid_highways => {
8146 if !fields.insert(__FieldTag::__avoid_highways) {
8147 return std::result::Result::Err(A::Error::duplicate_field(
8148 "multiple values for avoid_highways",
8149 ));
8150 }
8151 result.avoid_highways = map
8152 .next_value::<std::option::Option<bool>>()?
8153 .unwrap_or_default();
8154 }
8155 __FieldTag::__avoid_ferries => {
8156 if !fields.insert(__FieldTag::__avoid_ferries) {
8157 return std::result::Result::Err(A::Error::duplicate_field(
8158 "multiple values for avoid_ferries",
8159 ));
8160 }
8161 result.avoid_ferries = map
8162 .next_value::<std::option::Option<bool>>()?
8163 .unwrap_or_default();
8164 }
8165 __FieldTag::__avoid_indoor => {
8166 if !fields.insert(__FieldTag::__avoid_indoor) {
8167 return std::result::Result::Err(A::Error::duplicate_field(
8168 "multiple values for avoid_indoor",
8169 ));
8170 }
8171 result.avoid_indoor = map
8172 .next_value::<std::option::Option<bool>>()?
8173 .unwrap_or_default();
8174 }
8175 __FieldTag::Unknown(key) => {
8176 let value = map.next_value::<serde_json::Value>()?;
8177 result._unknown_fields.insert(key, value);
8178 }
8179 }
8180 }
8181 std::result::Result::Ok(result)
8182 }
8183 }
8184 deserializer.deserialize_any(Visitor)
8185 }
8186}
8187
8188#[doc(hidden)]
8189impl serde::ser::Serialize for RouteModifiers {
8190 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8191 where
8192 S: serde::ser::Serializer,
8193 {
8194 use serde::ser::SerializeMap;
8195 #[allow(unused_imports)]
8196 use std::option::Option::Some;
8197 let mut state = serializer.serialize_map(std::option::Option::None)?;
8198 if !wkt::internal::is_default(&self.avoid_tolls) {
8199 state.serialize_entry("avoidTolls", &self.avoid_tolls)?;
8200 }
8201 if !wkt::internal::is_default(&self.avoid_highways) {
8202 state.serialize_entry("avoidHighways", &self.avoid_highways)?;
8203 }
8204 if !wkt::internal::is_default(&self.avoid_ferries) {
8205 state.serialize_entry("avoidFerries", &self.avoid_ferries)?;
8206 }
8207 if !wkt::internal::is_default(&self.avoid_indoor) {
8208 state.serialize_entry("avoidIndoor", &self.avoid_indoor)?;
8209 }
8210 if !self._unknown_fields.is_empty() {
8211 for (key, value) in self._unknown_fields.iter() {
8212 state.serialize_entry(key, &value)?;
8213 }
8214 }
8215 state.end()
8216 }
8217}
8218
8219#[derive(Clone, Debug, Default, PartialEq)]
8223#[non_exhaustive]
8224pub struct Vehicle {
8225 pub travel_mode: crate::model::vehicle::TravelMode,
8228
8229 pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
8232
8233 pub start_location: std::option::Option<gtype::model::LatLng>,
8238
8239 pub start_waypoint: std::option::Option<crate::model::Waypoint>,
8245
8246 pub end_location: std::option::Option<gtype::model::LatLng>,
8252
8253 pub end_waypoint: std::option::Option<crate::model::Waypoint>,
8260
8261 pub start_tags: std::vec::Vec<std::string::String>,
8265
8266 pub end_tags: std::vec::Vec<std::string::String>,
8270
8271 pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
8286
8287 pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
8302
8303 pub travel_duration_multiple: std::option::Option<f64>,
8317
8318 pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
8320
8321 pub load_limits:
8330 std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
8331
8332 pub cost_per_hour: f64,
8342
8343 pub cost_per_traveled_hour: f64,
8350
8351 pub cost_per_kilometer: f64,
8359
8360 pub fixed_cost: f64,
8362
8363 pub used_if_route_is_empty: bool,
8376
8377 pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
8381
8382 pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
8388
8389 pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
8395
8396 pub extra_visit_duration_for_visit_type:
8408 std::collections::HashMap<std::string::String, wkt::Duration>,
8409
8410 pub break_rule: std::option::Option<crate::model::BreakRule>,
8413
8414 pub label: std::string::String,
8420
8421 pub ignore: bool,
8435
8436 #[deprecated]
8445 pub break_rule_indices: std::vec::Vec<i32>,
8446
8447 #[deprecated]
8453 pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
8454
8455 #[deprecated]
8461 pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
8462
8463 #[deprecated]
8469 pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
8470
8471 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8472}
8473
8474impl Vehicle {
8475 pub fn new() -> Self {
8476 std::default::Default::default()
8477 }
8478
8479 pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
8481 mut self,
8482 v: T,
8483 ) -> Self {
8484 self.travel_mode = v.into();
8485 self
8486 }
8487
8488 pub fn set_route_modifiers<T>(mut self, v: T) -> Self
8490 where
8491 T: std::convert::Into<crate::model::RouteModifiers>,
8492 {
8493 self.route_modifiers = std::option::Option::Some(v.into());
8494 self
8495 }
8496
8497 pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
8499 where
8500 T: std::convert::Into<crate::model::RouteModifiers>,
8501 {
8502 self.route_modifiers = v.map(|x| x.into());
8503 self
8504 }
8505
8506 pub fn set_start_location<T>(mut self, v: T) -> Self
8508 where
8509 T: std::convert::Into<gtype::model::LatLng>,
8510 {
8511 self.start_location = std::option::Option::Some(v.into());
8512 self
8513 }
8514
8515 pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
8517 where
8518 T: std::convert::Into<gtype::model::LatLng>,
8519 {
8520 self.start_location = v.map(|x| x.into());
8521 self
8522 }
8523
8524 pub fn set_start_waypoint<T>(mut self, v: T) -> Self
8526 where
8527 T: std::convert::Into<crate::model::Waypoint>,
8528 {
8529 self.start_waypoint = std::option::Option::Some(v.into());
8530 self
8531 }
8532
8533 pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
8535 where
8536 T: std::convert::Into<crate::model::Waypoint>,
8537 {
8538 self.start_waypoint = v.map(|x| x.into());
8539 self
8540 }
8541
8542 pub fn set_end_location<T>(mut self, v: T) -> Self
8544 where
8545 T: std::convert::Into<gtype::model::LatLng>,
8546 {
8547 self.end_location = std::option::Option::Some(v.into());
8548 self
8549 }
8550
8551 pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
8553 where
8554 T: std::convert::Into<gtype::model::LatLng>,
8555 {
8556 self.end_location = v.map(|x| x.into());
8557 self
8558 }
8559
8560 pub fn set_end_waypoint<T>(mut self, v: T) -> Self
8562 where
8563 T: std::convert::Into<crate::model::Waypoint>,
8564 {
8565 self.end_waypoint = std::option::Option::Some(v.into());
8566 self
8567 }
8568
8569 pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
8571 where
8572 T: std::convert::Into<crate::model::Waypoint>,
8573 {
8574 self.end_waypoint = v.map(|x| x.into());
8575 self
8576 }
8577
8578 pub fn set_start_tags<T, V>(mut self, v: T) -> Self
8580 where
8581 T: std::iter::IntoIterator<Item = V>,
8582 V: std::convert::Into<std::string::String>,
8583 {
8584 use std::iter::Iterator;
8585 self.start_tags = v.into_iter().map(|i| i.into()).collect();
8586 self
8587 }
8588
8589 pub fn set_end_tags<T, V>(mut self, v: T) -> Self
8591 where
8592 T: std::iter::IntoIterator<Item = V>,
8593 V: std::convert::Into<std::string::String>,
8594 {
8595 use std::iter::Iterator;
8596 self.end_tags = v.into_iter().map(|i| i.into()).collect();
8597 self
8598 }
8599
8600 pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
8602 where
8603 T: std::iter::IntoIterator<Item = V>,
8604 V: std::convert::Into<crate::model::TimeWindow>,
8605 {
8606 use std::iter::Iterator;
8607 self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
8608 self
8609 }
8610
8611 pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
8613 where
8614 T: std::iter::IntoIterator<Item = V>,
8615 V: std::convert::Into<crate::model::TimeWindow>,
8616 {
8617 use std::iter::Iterator;
8618 self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
8619 self
8620 }
8621
8622 pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
8624 where
8625 T: std::convert::Into<f64>,
8626 {
8627 self.travel_duration_multiple = std::option::Option::Some(v.into());
8628 self
8629 }
8630
8631 pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
8633 where
8634 T: std::convert::Into<f64>,
8635 {
8636 self.travel_duration_multiple = v.map(|x| x.into());
8637 self
8638 }
8639
8640 pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
8642 mut self,
8643 v: T,
8644 ) -> Self {
8645 self.unloading_policy = v.into();
8646 self
8647 }
8648
8649 pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
8651 where
8652 T: std::iter::IntoIterator<Item = (K, V)>,
8653 K: std::convert::Into<std::string::String>,
8654 V: std::convert::Into<crate::model::vehicle::LoadLimit>,
8655 {
8656 use std::iter::Iterator;
8657 self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8658 self
8659 }
8660
8661 pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8663 self.cost_per_hour = v.into();
8664 self
8665 }
8666
8667 pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8669 self.cost_per_traveled_hour = v.into();
8670 self
8671 }
8672
8673 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8675 self.cost_per_kilometer = v.into();
8676 self
8677 }
8678
8679 pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8681 self.fixed_cost = v.into();
8682 self
8683 }
8684
8685 pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8687 self.used_if_route_is_empty = v.into();
8688 self
8689 }
8690
8691 pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
8693 where
8694 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
8695 {
8696 self.route_duration_limit = std::option::Option::Some(v.into());
8697 self
8698 }
8699
8700 pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
8702 where
8703 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
8704 {
8705 self.route_duration_limit = v.map(|x| x.into());
8706 self
8707 }
8708
8709 pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
8711 where
8712 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
8713 {
8714 self.travel_duration_limit = std::option::Option::Some(v.into());
8715 self
8716 }
8717
8718 pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
8720 where
8721 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
8722 {
8723 self.travel_duration_limit = v.map(|x| x.into());
8724 self
8725 }
8726
8727 pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
8729 where
8730 T: std::convert::Into<crate::model::DistanceLimit>,
8731 {
8732 self.route_distance_limit = std::option::Option::Some(v.into());
8733 self
8734 }
8735
8736 pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
8738 where
8739 T: std::convert::Into<crate::model::DistanceLimit>,
8740 {
8741 self.route_distance_limit = v.map(|x| x.into());
8742 self
8743 }
8744
8745 pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
8747 where
8748 T: std::iter::IntoIterator<Item = (K, V)>,
8749 K: std::convert::Into<std::string::String>,
8750 V: std::convert::Into<wkt::Duration>,
8751 {
8752 use std::iter::Iterator;
8753 self.extra_visit_duration_for_visit_type =
8754 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8755 self
8756 }
8757
8758 pub fn set_break_rule<T>(mut self, v: T) -> Self
8760 where
8761 T: std::convert::Into<crate::model::BreakRule>,
8762 {
8763 self.break_rule = std::option::Option::Some(v.into());
8764 self
8765 }
8766
8767 pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
8769 where
8770 T: std::convert::Into<crate::model::BreakRule>,
8771 {
8772 self.break_rule = v.map(|x| x.into());
8773 self
8774 }
8775
8776 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8778 self.label = v.into();
8779 self
8780 }
8781
8782 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8784 self.ignore = v.into();
8785 self
8786 }
8787
8788 #[deprecated]
8790 pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
8791 where
8792 T: std::iter::IntoIterator<Item = V>,
8793 V: std::convert::Into<i32>,
8794 {
8795 use std::iter::Iterator;
8796 self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
8797 self
8798 }
8799
8800 #[deprecated]
8802 pub fn set_capacities<T, V>(mut self, v: T) -> Self
8803 where
8804 T: std::iter::IntoIterator<Item = V>,
8805 V: std::convert::Into<crate::model::CapacityQuantity>,
8806 {
8807 use std::iter::Iterator;
8808 self.capacities = v.into_iter().map(|i| i.into()).collect();
8809 self
8810 }
8811
8812 #[deprecated]
8814 pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
8815 where
8816 T: std::iter::IntoIterator<Item = V>,
8817 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
8818 {
8819 use std::iter::Iterator;
8820 self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
8821 self
8822 }
8823
8824 #[deprecated]
8826 pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
8827 where
8828 T: std::iter::IntoIterator<Item = V>,
8829 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
8830 {
8831 use std::iter::Iterator;
8832 self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
8833 self
8834 }
8835}
8836
8837impl wkt::message::Message for Vehicle {
8838 fn typename() -> &'static str {
8839 "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
8840 }
8841}
8842
8843#[doc(hidden)]
8844impl<'de> serde::de::Deserialize<'de> for Vehicle {
8845 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8846 where
8847 D: serde::Deserializer<'de>,
8848 {
8849 #[allow(non_camel_case_types)]
8850 #[doc(hidden)]
8851 #[derive(PartialEq, Eq, Hash)]
8852 enum __FieldTag {
8853 __travel_mode,
8854 __route_modifiers,
8855 __start_location,
8856 __start_waypoint,
8857 __end_location,
8858 __end_waypoint,
8859 __start_tags,
8860 __end_tags,
8861 __start_time_windows,
8862 __end_time_windows,
8863 __travel_duration_multiple,
8864 __unloading_policy,
8865 __load_limits,
8866 __cost_per_hour,
8867 __cost_per_traveled_hour,
8868 __cost_per_kilometer,
8869 __fixed_cost,
8870 __used_if_route_is_empty,
8871 __route_duration_limit,
8872 __travel_duration_limit,
8873 __route_distance_limit,
8874 __extra_visit_duration_for_visit_type,
8875 __break_rule,
8876 __label,
8877 __ignore,
8878 __break_rule_indices,
8879 __capacities,
8880 __start_load_intervals,
8881 __end_load_intervals,
8882 Unknown(std::string::String),
8883 }
8884 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
8885 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8886 where
8887 D: serde::Deserializer<'de>,
8888 {
8889 struct Visitor;
8890 impl<'de> serde::de::Visitor<'de> for Visitor {
8891 type Value = __FieldTag;
8892 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8893 formatter.write_str("a field name for Vehicle")
8894 }
8895 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
8896 where
8897 E: serde::de::Error,
8898 {
8899 use std::result::Result::Ok;
8900 use std::string::ToString;
8901 match value {
8902 "travelMode" => Ok(__FieldTag::__travel_mode),
8903 "travel_mode" => Ok(__FieldTag::__travel_mode),
8904 "routeModifiers" => Ok(__FieldTag::__route_modifiers),
8905 "route_modifiers" => Ok(__FieldTag::__route_modifiers),
8906 "startLocation" => Ok(__FieldTag::__start_location),
8907 "start_location" => Ok(__FieldTag::__start_location),
8908 "startWaypoint" => Ok(__FieldTag::__start_waypoint),
8909 "start_waypoint" => Ok(__FieldTag::__start_waypoint),
8910 "endLocation" => Ok(__FieldTag::__end_location),
8911 "end_location" => Ok(__FieldTag::__end_location),
8912 "endWaypoint" => Ok(__FieldTag::__end_waypoint),
8913 "end_waypoint" => Ok(__FieldTag::__end_waypoint),
8914 "startTags" => Ok(__FieldTag::__start_tags),
8915 "start_tags" => Ok(__FieldTag::__start_tags),
8916 "endTags" => Ok(__FieldTag::__end_tags),
8917 "end_tags" => Ok(__FieldTag::__end_tags),
8918 "startTimeWindows" => Ok(__FieldTag::__start_time_windows),
8919 "start_time_windows" => Ok(__FieldTag::__start_time_windows),
8920 "endTimeWindows" => Ok(__FieldTag::__end_time_windows),
8921 "end_time_windows" => Ok(__FieldTag::__end_time_windows),
8922 "travelDurationMultiple" => Ok(__FieldTag::__travel_duration_multiple),
8923 "travel_duration_multiple" => {
8924 Ok(__FieldTag::__travel_duration_multiple)
8925 }
8926 "unloadingPolicy" => Ok(__FieldTag::__unloading_policy),
8927 "unloading_policy" => Ok(__FieldTag::__unloading_policy),
8928 "loadLimits" => Ok(__FieldTag::__load_limits),
8929 "load_limits" => Ok(__FieldTag::__load_limits),
8930 "costPerHour" => Ok(__FieldTag::__cost_per_hour),
8931 "cost_per_hour" => Ok(__FieldTag::__cost_per_hour),
8932 "costPerTraveledHour" => Ok(__FieldTag::__cost_per_traveled_hour),
8933 "cost_per_traveled_hour" => Ok(__FieldTag::__cost_per_traveled_hour),
8934 "costPerKilometer" => Ok(__FieldTag::__cost_per_kilometer),
8935 "cost_per_kilometer" => Ok(__FieldTag::__cost_per_kilometer),
8936 "fixedCost" => Ok(__FieldTag::__fixed_cost),
8937 "fixed_cost" => Ok(__FieldTag::__fixed_cost),
8938 "usedIfRouteIsEmpty" => Ok(__FieldTag::__used_if_route_is_empty),
8939 "used_if_route_is_empty" => Ok(__FieldTag::__used_if_route_is_empty),
8940 "routeDurationLimit" => Ok(__FieldTag::__route_duration_limit),
8941 "route_duration_limit" => Ok(__FieldTag::__route_duration_limit),
8942 "travelDurationLimit" => Ok(__FieldTag::__travel_duration_limit),
8943 "travel_duration_limit" => Ok(__FieldTag::__travel_duration_limit),
8944 "routeDistanceLimit" => Ok(__FieldTag::__route_distance_limit),
8945 "route_distance_limit" => Ok(__FieldTag::__route_distance_limit),
8946 "extraVisitDurationForVisitType" => {
8947 Ok(__FieldTag::__extra_visit_duration_for_visit_type)
8948 }
8949 "extra_visit_duration_for_visit_type" => {
8950 Ok(__FieldTag::__extra_visit_duration_for_visit_type)
8951 }
8952 "breakRule" => Ok(__FieldTag::__break_rule),
8953 "break_rule" => Ok(__FieldTag::__break_rule),
8954 "label" => Ok(__FieldTag::__label),
8955 "ignore" => Ok(__FieldTag::__ignore),
8956 "breakRuleIndices" => Ok(__FieldTag::__break_rule_indices),
8957 "break_rule_indices" => Ok(__FieldTag::__break_rule_indices),
8958 "capacities" => Ok(__FieldTag::__capacities),
8959 "startLoadIntervals" => Ok(__FieldTag::__start_load_intervals),
8960 "start_load_intervals" => Ok(__FieldTag::__start_load_intervals),
8961 "endLoadIntervals" => Ok(__FieldTag::__end_load_intervals),
8962 "end_load_intervals" => Ok(__FieldTag::__end_load_intervals),
8963 _ => Ok(__FieldTag::Unknown(value.to_string())),
8964 }
8965 }
8966 }
8967 deserializer.deserialize_identifier(Visitor)
8968 }
8969 }
8970 struct Visitor;
8971 impl<'de> serde::de::Visitor<'de> for Visitor {
8972 type Value = Vehicle;
8973 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
8974 formatter.write_str("struct Vehicle")
8975 }
8976 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
8977 where
8978 A: serde::de::MapAccess<'de>,
8979 {
8980 #[allow(unused_imports)]
8981 use serde::de::Error;
8982 use std::option::Option::Some;
8983 let mut fields = std::collections::HashSet::new();
8984 let mut result = Self::Value::new();
8985 while let Some(tag) = map.next_key::<__FieldTag>()? {
8986 #[allow(clippy::match_single_binding)]
8987 match tag {
8988 __FieldTag::__travel_mode => {
8989 if !fields.insert(__FieldTag::__travel_mode) {
8990 return std::result::Result::Err(A::Error::duplicate_field(
8991 "multiple values for travel_mode",
8992 ));
8993 }
8994 result.travel_mode = map.next_value::<std::option::Option<crate::model::vehicle::TravelMode>>()?.unwrap_or_default();
8995 }
8996 __FieldTag::__route_modifiers => {
8997 if !fields.insert(__FieldTag::__route_modifiers) {
8998 return std::result::Result::Err(A::Error::duplicate_field(
8999 "multiple values for route_modifiers",
9000 ));
9001 }
9002 result.route_modifiers = map
9003 .next_value::<std::option::Option<crate::model::RouteModifiers>>(
9004 )?;
9005 }
9006 __FieldTag::__start_location => {
9007 if !fields.insert(__FieldTag::__start_location) {
9008 return std::result::Result::Err(A::Error::duplicate_field(
9009 "multiple values for start_location",
9010 ));
9011 }
9012 result.start_location =
9013 map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
9014 }
9015 __FieldTag::__start_waypoint => {
9016 if !fields.insert(__FieldTag::__start_waypoint) {
9017 return std::result::Result::Err(A::Error::duplicate_field(
9018 "multiple values for start_waypoint",
9019 ));
9020 }
9021 result.start_waypoint =
9022 map.next_value::<std::option::Option<crate::model::Waypoint>>()?;
9023 }
9024 __FieldTag::__end_location => {
9025 if !fields.insert(__FieldTag::__end_location) {
9026 return std::result::Result::Err(A::Error::duplicate_field(
9027 "multiple values for end_location",
9028 ));
9029 }
9030 result.end_location =
9031 map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
9032 }
9033 __FieldTag::__end_waypoint => {
9034 if !fields.insert(__FieldTag::__end_waypoint) {
9035 return std::result::Result::Err(A::Error::duplicate_field(
9036 "multiple values for end_waypoint",
9037 ));
9038 }
9039 result.end_waypoint =
9040 map.next_value::<std::option::Option<crate::model::Waypoint>>()?;
9041 }
9042 __FieldTag::__start_tags => {
9043 if !fields.insert(__FieldTag::__start_tags) {
9044 return std::result::Result::Err(A::Error::duplicate_field(
9045 "multiple values for start_tags",
9046 ));
9047 }
9048 result.start_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
9049 }
9050 __FieldTag::__end_tags => {
9051 if !fields.insert(__FieldTag::__end_tags) {
9052 return std::result::Result::Err(A::Error::duplicate_field(
9053 "multiple values for end_tags",
9054 ));
9055 }
9056 result.end_tags = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
9057 }
9058 __FieldTag::__start_time_windows => {
9059 if !fields.insert(__FieldTag::__start_time_windows) {
9060 return std::result::Result::Err(A::Error::duplicate_field(
9061 "multiple values for start_time_windows",
9062 ));
9063 }
9064 result.start_time_windows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::TimeWindow>>>()?.unwrap_or_default();
9065 }
9066 __FieldTag::__end_time_windows => {
9067 if !fields.insert(__FieldTag::__end_time_windows) {
9068 return std::result::Result::Err(A::Error::duplicate_field(
9069 "multiple values for end_time_windows",
9070 ));
9071 }
9072 result.end_time_windows = map.next_value::<std::option::Option<std::vec::Vec<crate::model::TimeWindow>>>()?.unwrap_or_default();
9073 }
9074 __FieldTag::__travel_duration_multiple => {
9075 if !fields.insert(__FieldTag::__travel_duration_multiple) {
9076 return std::result::Result::Err(A::Error::duplicate_field(
9077 "multiple values for travel_duration_multiple",
9078 ));
9079 }
9080 struct __With(std::option::Option<f64>);
9081 impl<'de> serde::de::Deserialize<'de> for __With {
9082 fn deserialize<D>(
9083 deserializer: D,
9084 ) -> std::result::Result<Self, D::Error>
9085 where
9086 D: serde::de::Deserializer<'de>,
9087 {
9088 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9089 }
9090 }
9091 result.travel_duration_multiple = map.next_value::<__With>()?.0;
9092 }
9093 __FieldTag::__unloading_policy => {
9094 if !fields.insert(__FieldTag::__unloading_policy) {
9095 return std::result::Result::Err(A::Error::duplicate_field(
9096 "multiple values for unloading_policy",
9097 ));
9098 }
9099 result.unloading_policy = map.next_value::<std::option::Option<crate::model::vehicle::UnloadingPolicy>>()?.unwrap_or_default();
9100 }
9101 __FieldTag::__load_limits => {
9102 if !fields.insert(__FieldTag::__load_limits) {
9103 return std::result::Result::Err(A::Error::duplicate_field(
9104 "multiple values for load_limits",
9105 ));
9106 }
9107 result.load_limits = map
9108 .next_value::<std::option::Option<
9109 std::collections::HashMap<
9110 std::string::String,
9111 crate::model::vehicle::LoadLimit,
9112 >,
9113 >>()?
9114 .unwrap_or_default();
9115 }
9116 __FieldTag::__cost_per_hour => {
9117 if !fields.insert(__FieldTag::__cost_per_hour) {
9118 return std::result::Result::Err(A::Error::duplicate_field(
9119 "multiple values for cost_per_hour",
9120 ));
9121 }
9122 struct __With(std::option::Option<f64>);
9123 impl<'de> serde::de::Deserialize<'de> for __With {
9124 fn deserialize<D>(
9125 deserializer: D,
9126 ) -> std::result::Result<Self, D::Error>
9127 where
9128 D: serde::de::Deserializer<'de>,
9129 {
9130 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9131 }
9132 }
9133 result.cost_per_hour =
9134 map.next_value::<__With>()?.0.unwrap_or_default();
9135 }
9136 __FieldTag::__cost_per_traveled_hour => {
9137 if !fields.insert(__FieldTag::__cost_per_traveled_hour) {
9138 return std::result::Result::Err(A::Error::duplicate_field(
9139 "multiple values for cost_per_traveled_hour",
9140 ));
9141 }
9142 struct __With(std::option::Option<f64>);
9143 impl<'de> serde::de::Deserialize<'de> for __With {
9144 fn deserialize<D>(
9145 deserializer: D,
9146 ) -> std::result::Result<Self, D::Error>
9147 where
9148 D: serde::de::Deserializer<'de>,
9149 {
9150 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9151 }
9152 }
9153 result.cost_per_traveled_hour =
9154 map.next_value::<__With>()?.0.unwrap_or_default();
9155 }
9156 __FieldTag::__cost_per_kilometer => {
9157 if !fields.insert(__FieldTag::__cost_per_kilometer) {
9158 return std::result::Result::Err(A::Error::duplicate_field(
9159 "multiple values for cost_per_kilometer",
9160 ));
9161 }
9162 struct __With(std::option::Option<f64>);
9163 impl<'de> serde::de::Deserialize<'de> for __With {
9164 fn deserialize<D>(
9165 deserializer: D,
9166 ) -> std::result::Result<Self, D::Error>
9167 where
9168 D: serde::de::Deserializer<'de>,
9169 {
9170 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9171 }
9172 }
9173 result.cost_per_kilometer =
9174 map.next_value::<__With>()?.0.unwrap_or_default();
9175 }
9176 __FieldTag::__fixed_cost => {
9177 if !fields.insert(__FieldTag::__fixed_cost) {
9178 return std::result::Result::Err(A::Error::duplicate_field(
9179 "multiple values for fixed_cost",
9180 ));
9181 }
9182 struct __With(std::option::Option<f64>);
9183 impl<'de> serde::de::Deserialize<'de> for __With {
9184 fn deserialize<D>(
9185 deserializer: D,
9186 ) -> std::result::Result<Self, D::Error>
9187 where
9188 D: serde::de::Deserializer<'de>,
9189 {
9190 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9191 }
9192 }
9193 result.fixed_cost = map.next_value::<__With>()?.0.unwrap_or_default();
9194 }
9195 __FieldTag::__used_if_route_is_empty => {
9196 if !fields.insert(__FieldTag::__used_if_route_is_empty) {
9197 return std::result::Result::Err(A::Error::duplicate_field(
9198 "multiple values for used_if_route_is_empty",
9199 ));
9200 }
9201 result.used_if_route_is_empty = map
9202 .next_value::<std::option::Option<bool>>()?
9203 .unwrap_or_default();
9204 }
9205 __FieldTag::__route_duration_limit => {
9206 if !fields.insert(__FieldTag::__route_duration_limit) {
9207 return std::result::Result::Err(A::Error::duplicate_field(
9208 "multiple values for route_duration_limit",
9209 ));
9210 }
9211 result.route_duration_limit = map.next_value::<std::option::Option<crate::model::vehicle::DurationLimit>>()?
9212 ;
9213 }
9214 __FieldTag::__travel_duration_limit => {
9215 if !fields.insert(__FieldTag::__travel_duration_limit) {
9216 return std::result::Result::Err(A::Error::duplicate_field(
9217 "multiple values for travel_duration_limit",
9218 ));
9219 }
9220 result.travel_duration_limit = map.next_value::<std::option::Option<crate::model::vehicle::DurationLimit>>()?
9221 ;
9222 }
9223 __FieldTag::__route_distance_limit => {
9224 if !fields.insert(__FieldTag::__route_distance_limit) {
9225 return std::result::Result::Err(A::Error::duplicate_field(
9226 "multiple values for route_distance_limit",
9227 ));
9228 }
9229 result.route_distance_limit = map
9230 .next_value::<std::option::Option<crate::model::DistanceLimit>>()?;
9231 }
9232 __FieldTag::__extra_visit_duration_for_visit_type => {
9233 if !fields.insert(__FieldTag::__extra_visit_duration_for_visit_type) {
9234 return std::result::Result::Err(A::Error::duplicate_field(
9235 "multiple values for extra_visit_duration_for_visit_type",
9236 ));
9237 }
9238 result.extra_visit_duration_for_visit_type = map
9239 .next_value::<std::option::Option<
9240 std::collections::HashMap<std::string::String, wkt::Duration>,
9241 >>()?
9242 .unwrap_or_default();
9243 }
9244 __FieldTag::__break_rule => {
9245 if !fields.insert(__FieldTag::__break_rule) {
9246 return std::result::Result::Err(A::Error::duplicate_field(
9247 "multiple values for break_rule",
9248 ));
9249 }
9250 result.break_rule =
9251 map.next_value::<std::option::Option<crate::model::BreakRule>>()?;
9252 }
9253 __FieldTag::__label => {
9254 if !fields.insert(__FieldTag::__label) {
9255 return std::result::Result::Err(A::Error::duplicate_field(
9256 "multiple values for label",
9257 ));
9258 }
9259 result.label = map
9260 .next_value::<std::option::Option<std::string::String>>()?
9261 .unwrap_or_default();
9262 }
9263 __FieldTag::__ignore => {
9264 if !fields.insert(__FieldTag::__ignore) {
9265 return std::result::Result::Err(A::Error::duplicate_field(
9266 "multiple values for ignore",
9267 ));
9268 }
9269 result.ignore = map
9270 .next_value::<std::option::Option<bool>>()?
9271 .unwrap_or_default();
9272 }
9273 __FieldTag::__break_rule_indices => {
9274 if !fields.insert(__FieldTag::__break_rule_indices) {
9275 return std::result::Result::Err(A::Error::duplicate_field(
9276 "multiple values for break_rule_indices",
9277 ));
9278 }
9279 struct __With(std::option::Option<std::vec::Vec<i32>>);
9280 impl<'de> serde::de::Deserialize<'de> for __With {
9281 fn deserialize<D>(
9282 deserializer: D,
9283 ) -> std::result::Result<Self, D::Error>
9284 where
9285 D: serde::de::Deserializer<'de>,
9286 {
9287 serde_with::As::<
9288 std::option::Option<std::vec::Vec<wkt::internal::I32>>,
9289 >::deserialize(deserializer)
9290 .map(__With)
9291 }
9292 }
9293 result.break_rule_indices =
9294 map.next_value::<__With>()?.0.unwrap_or_default();
9295 }
9296 __FieldTag::__capacities => {
9297 if !fields.insert(__FieldTag::__capacities) {
9298 return std::result::Result::Err(A::Error::duplicate_field(
9299 "multiple values for capacities",
9300 ));
9301 }
9302 result.capacities =
9303 map.next_value::<std::option::Option<
9304 std::vec::Vec<crate::model::CapacityQuantity>,
9305 >>()?
9306 .unwrap_or_default();
9307 }
9308 __FieldTag::__start_load_intervals => {
9309 if !fields.insert(__FieldTag::__start_load_intervals) {
9310 return std::result::Result::Err(A::Error::duplicate_field(
9311 "multiple values for start_load_intervals",
9312 ));
9313 }
9314 result.start_load_intervals = map
9315 .next_value::<std::option::Option<
9316 std::vec::Vec<crate::model::CapacityQuantityInterval>,
9317 >>()?
9318 .unwrap_or_default();
9319 }
9320 __FieldTag::__end_load_intervals => {
9321 if !fields.insert(__FieldTag::__end_load_intervals) {
9322 return std::result::Result::Err(A::Error::duplicate_field(
9323 "multiple values for end_load_intervals",
9324 ));
9325 }
9326 result.end_load_intervals = map
9327 .next_value::<std::option::Option<
9328 std::vec::Vec<crate::model::CapacityQuantityInterval>,
9329 >>()?
9330 .unwrap_or_default();
9331 }
9332 __FieldTag::Unknown(key) => {
9333 let value = map.next_value::<serde_json::Value>()?;
9334 result._unknown_fields.insert(key, value);
9335 }
9336 }
9337 }
9338 std::result::Result::Ok(result)
9339 }
9340 }
9341 deserializer.deserialize_any(Visitor)
9342 }
9343}
9344
9345#[doc(hidden)]
9346impl serde::ser::Serialize for Vehicle {
9347 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9348 where
9349 S: serde::ser::Serializer,
9350 {
9351 use serde::ser::SerializeMap;
9352 #[allow(unused_imports)]
9353 use std::option::Option::Some;
9354 let mut state = serializer.serialize_map(std::option::Option::None)?;
9355 if !wkt::internal::is_default(&self.travel_mode) {
9356 state.serialize_entry("travelMode", &self.travel_mode)?;
9357 }
9358 if self.route_modifiers.is_some() {
9359 state.serialize_entry("routeModifiers", &self.route_modifiers)?;
9360 }
9361 if self.start_location.is_some() {
9362 state.serialize_entry("startLocation", &self.start_location)?;
9363 }
9364 if self.start_waypoint.is_some() {
9365 state.serialize_entry("startWaypoint", &self.start_waypoint)?;
9366 }
9367 if self.end_location.is_some() {
9368 state.serialize_entry("endLocation", &self.end_location)?;
9369 }
9370 if self.end_waypoint.is_some() {
9371 state.serialize_entry("endWaypoint", &self.end_waypoint)?;
9372 }
9373 if !self.start_tags.is_empty() {
9374 state.serialize_entry("startTags", &self.start_tags)?;
9375 }
9376 if !self.end_tags.is_empty() {
9377 state.serialize_entry("endTags", &self.end_tags)?;
9378 }
9379 if !self.start_time_windows.is_empty() {
9380 state.serialize_entry("startTimeWindows", &self.start_time_windows)?;
9381 }
9382 if !self.end_time_windows.is_empty() {
9383 state.serialize_entry("endTimeWindows", &self.end_time_windows)?;
9384 }
9385 if self.travel_duration_multiple.is_some() {
9386 struct __With<'a>(&'a std::option::Option<f64>);
9387 impl<'a> serde::ser::Serialize for __With<'a> {
9388 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9389 where
9390 S: serde::ser::Serializer,
9391 {
9392 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
9393 self.0, serializer,
9394 )
9395 }
9396 }
9397 state.serialize_entry(
9398 "travelDurationMultiple",
9399 &__With(&self.travel_duration_multiple),
9400 )?;
9401 }
9402 if !wkt::internal::is_default(&self.unloading_policy) {
9403 state.serialize_entry("unloadingPolicy", &self.unloading_policy)?;
9404 }
9405 if !self.load_limits.is_empty() {
9406 state.serialize_entry("loadLimits", &self.load_limits)?;
9407 }
9408 if !wkt::internal::is_default(&self.cost_per_hour) {
9409 struct __With<'a>(&'a f64);
9410 impl<'a> serde::ser::Serialize for __With<'a> {
9411 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9412 where
9413 S: serde::ser::Serializer,
9414 {
9415 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9416 }
9417 }
9418 state.serialize_entry("costPerHour", &__With(&self.cost_per_hour))?;
9419 }
9420 if !wkt::internal::is_default(&self.cost_per_traveled_hour) {
9421 struct __With<'a>(&'a f64);
9422 impl<'a> serde::ser::Serialize for __With<'a> {
9423 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9424 where
9425 S: serde::ser::Serializer,
9426 {
9427 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9428 }
9429 }
9430 state.serialize_entry("costPerTraveledHour", &__With(&self.cost_per_traveled_hour))?;
9431 }
9432 if !wkt::internal::is_default(&self.cost_per_kilometer) {
9433 struct __With<'a>(&'a f64);
9434 impl<'a> serde::ser::Serialize for __With<'a> {
9435 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9436 where
9437 S: serde::ser::Serializer,
9438 {
9439 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9440 }
9441 }
9442 state.serialize_entry("costPerKilometer", &__With(&self.cost_per_kilometer))?;
9443 }
9444 if !wkt::internal::is_default(&self.fixed_cost) {
9445 struct __With<'a>(&'a f64);
9446 impl<'a> serde::ser::Serialize for __With<'a> {
9447 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9448 where
9449 S: serde::ser::Serializer,
9450 {
9451 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9452 }
9453 }
9454 state.serialize_entry("fixedCost", &__With(&self.fixed_cost))?;
9455 }
9456 if !wkt::internal::is_default(&self.used_if_route_is_empty) {
9457 state.serialize_entry("usedIfRouteIsEmpty", &self.used_if_route_is_empty)?;
9458 }
9459 if self.route_duration_limit.is_some() {
9460 state.serialize_entry("routeDurationLimit", &self.route_duration_limit)?;
9461 }
9462 if self.travel_duration_limit.is_some() {
9463 state.serialize_entry("travelDurationLimit", &self.travel_duration_limit)?;
9464 }
9465 if self.route_distance_limit.is_some() {
9466 state.serialize_entry("routeDistanceLimit", &self.route_distance_limit)?;
9467 }
9468 if !self.extra_visit_duration_for_visit_type.is_empty() {
9469 state.serialize_entry(
9470 "extraVisitDurationForVisitType",
9471 &self.extra_visit_duration_for_visit_type,
9472 )?;
9473 }
9474 if self.break_rule.is_some() {
9475 state.serialize_entry("breakRule", &self.break_rule)?;
9476 }
9477 if !self.label.is_empty() {
9478 state.serialize_entry("label", &self.label)?;
9479 }
9480 if !wkt::internal::is_default(&self.ignore) {
9481 state.serialize_entry("ignore", &self.ignore)?;
9482 }
9483 if !self.break_rule_indices.is_empty() {
9484 struct __With<'a>(&'a std::vec::Vec<i32>);
9485 impl<'a> serde::ser::Serialize for __With<'a> {
9486 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9487 where
9488 S: serde::ser::Serializer,
9489 {
9490 serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
9491 self.0, serializer,
9492 )
9493 }
9494 }
9495 state.serialize_entry("breakRuleIndices", &__With(&self.break_rule_indices))?;
9496 }
9497 if !self.capacities.is_empty() {
9498 state.serialize_entry("capacities", &self.capacities)?;
9499 }
9500 if !self.start_load_intervals.is_empty() {
9501 state.serialize_entry("startLoadIntervals", &self.start_load_intervals)?;
9502 }
9503 if !self.end_load_intervals.is_empty() {
9504 state.serialize_entry("endLoadIntervals", &self.end_load_intervals)?;
9505 }
9506 if !self._unknown_fields.is_empty() {
9507 for (key, value) in self._unknown_fields.iter() {
9508 state.serialize_entry(key, &value)?;
9509 }
9510 }
9511 state.end()
9512 }
9513}
9514
9515pub mod vehicle {
9517 #[allow(unused_imports)]
9518 use super::*;
9519
9520 #[derive(Clone, Debug, Default, PartialEq)]
9526 #[non_exhaustive]
9527 pub struct LoadLimit {
9528 pub max_load: std::option::Option<i64>,
9530
9531 pub soft_max_load: i64,
9536
9537 pub cost_per_unit_above_soft_max: f64,
9551
9552 pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
9554
9555 pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
9557
9558 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9559 }
9560
9561 impl LoadLimit {
9562 pub fn new() -> Self {
9563 std::default::Default::default()
9564 }
9565
9566 pub fn set_max_load<T>(mut self, v: T) -> Self
9568 where
9569 T: std::convert::Into<i64>,
9570 {
9571 self.max_load = std::option::Option::Some(v.into());
9572 self
9573 }
9574
9575 pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
9577 where
9578 T: std::convert::Into<i64>,
9579 {
9580 self.max_load = v.map(|x| x.into());
9581 self
9582 }
9583
9584 pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9586 self.soft_max_load = v.into();
9587 self
9588 }
9589
9590 pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
9592 mut self,
9593 v: T,
9594 ) -> Self {
9595 self.cost_per_unit_above_soft_max = v.into();
9596 self
9597 }
9598
9599 pub fn set_start_load_interval<T>(mut self, v: T) -> Self
9601 where
9602 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
9603 {
9604 self.start_load_interval = std::option::Option::Some(v.into());
9605 self
9606 }
9607
9608 pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
9610 where
9611 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
9612 {
9613 self.start_load_interval = v.map(|x| x.into());
9614 self
9615 }
9616
9617 pub fn set_end_load_interval<T>(mut self, v: T) -> Self
9619 where
9620 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
9621 {
9622 self.end_load_interval = std::option::Option::Some(v.into());
9623 self
9624 }
9625
9626 pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
9628 where
9629 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
9630 {
9631 self.end_load_interval = v.map(|x| x.into());
9632 self
9633 }
9634 }
9635
9636 impl wkt::message::Message for LoadLimit {
9637 fn typename() -> &'static str {
9638 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
9639 }
9640 }
9641
9642 #[doc(hidden)]
9643 impl<'de> serde::de::Deserialize<'de> for LoadLimit {
9644 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9645 where
9646 D: serde::Deserializer<'de>,
9647 {
9648 #[allow(non_camel_case_types)]
9649 #[doc(hidden)]
9650 #[derive(PartialEq, Eq, Hash)]
9651 enum __FieldTag {
9652 __max_load,
9653 __soft_max_load,
9654 __cost_per_unit_above_soft_max,
9655 __start_load_interval,
9656 __end_load_interval,
9657 Unknown(std::string::String),
9658 }
9659 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9660 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9661 where
9662 D: serde::Deserializer<'de>,
9663 {
9664 struct Visitor;
9665 impl<'de> serde::de::Visitor<'de> for Visitor {
9666 type Value = __FieldTag;
9667 fn expecting(
9668 &self,
9669 formatter: &mut std::fmt::Formatter,
9670 ) -> std::fmt::Result {
9671 formatter.write_str("a field name for LoadLimit")
9672 }
9673 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
9674 where
9675 E: serde::de::Error,
9676 {
9677 use std::result::Result::Ok;
9678 use std::string::ToString;
9679 match value {
9680 "maxLoad" => Ok(__FieldTag::__max_load),
9681 "max_load" => Ok(__FieldTag::__max_load),
9682 "softMaxLoad" => Ok(__FieldTag::__soft_max_load),
9683 "soft_max_load" => Ok(__FieldTag::__soft_max_load),
9684 "costPerUnitAboveSoftMax" => {
9685 Ok(__FieldTag::__cost_per_unit_above_soft_max)
9686 }
9687 "cost_per_unit_above_soft_max" => {
9688 Ok(__FieldTag::__cost_per_unit_above_soft_max)
9689 }
9690 "startLoadInterval" => Ok(__FieldTag::__start_load_interval),
9691 "start_load_interval" => Ok(__FieldTag::__start_load_interval),
9692 "endLoadInterval" => Ok(__FieldTag::__end_load_interval),
9693 "end_load_interval" => Ok(__FieldTag::__end_load_interval),
9694 _ => Ok(__FieldTag::Unknown(value.to_string())),
9695 }
9696 }
9697 }
9698 deserializer.deserialize_identifier(Visitor)
9699 }
9700 }
9701 struct Visitor;
9702 impl<'de> serde::de::Visitor<'de> for Visitor {
9703 type Value = LoadLimit;
9704 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9705 formatter.write_str("struct LoadLimit")
9706 }
9707 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
9708 where
9709 A: serde::de::MapAccess<'de>,
9710 {
9711 #[allow(unused_imports)]
9712 use serde::de::Error;
9713 use std::option::Option::Some;
9714 let mut fields = std::collections::HashSet::new();
9715 let mut result = Self::Value::new();
9716 while let Some(tag) = map.next_key::<__FieldTag>()? {
9717 #[allow(clippy::match_single_binding)]
9718 match tag {
9719 __FieldTag::__max_load => {
9720 if !fields.insert(__FieldTag::__max_load) {
9721 return std::result::Result::Err(A::Error::duplicate_field(
9722 "multiple values for max_load",
9723 ));
9724 }
9725 struct __With(std::option::Option<i64>);
9726 impl<'de> serde::de::Deserialize<'de> for __With {
9727 fn deserialize<D>(
9728 deserializer: D,
9729 ) -> std::result::Result<Self, D::Error>
9730 where
9731 D: serde::de::Deserializer<'de>,
9732 {
9733 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
9734 }
9735 }
9736 result.max_load = map.next_value::<__With>()?.0;
9737 }
9738 __FieldTag::__soft_max_load => {
9739 if !fields.insert(__FieldTag::__soft_max_load) {
9740 return std::result::Result::Err(A::Error::duplicate_field(
9741 "multiple values for soft_max_load",
9742 ));
9743 }
9744 struct __With(std::option::Option<i64>);
9745 impl<'de> serde::de::Deserialize<'de> for __With {
9746 fn deserialize<D>(
9747 deserializer: D,
9748 ) -> std::result::Result<Self, D::Error>
9749 where
9750 D: serde::de::Deserializer<'de>,
9751 {
9752 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
9753 }
9754 }
9755 result.soft_max_load =
9756 map.next_value::<__With>()?.0.unwrap_or_default();
9757 }
9758 __FieldTag::__cost_per_unit_above_soft_max => {
9759 if !fields.insert(__FieldTag::__cost_per_unit_above_soft_max) {
9760 return std::result::Result::Err(A::Error::duplicate_field(
9761 "multiple values for cost_per_unit_above_soft_max",
9762 ));
9763 }
9764 struct __With(std::option::Option<f64>);
9765 impl<'de> serde::de::Deserialize<'de> for __With {
9766 fn deserialize<D>(
9767 deserializer: D,
9768 ) -> std::result::Result<Self, D::Error>
9769 where
9770 D: serde::de::Deserializer<'de>,
9771 {
9772 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
9773 }
9774 }
9775 result.cost_per_unit_above_soft_max =
9776 map.next_value::<__With>()?.0.unwrap_or_default();
9777 }
9778 __FieldTag::__start_load_interval => {
9779 if !fields.insert(__FieldTag::__start_load_interval) {
9780 return std::result::Result::Err(A::Error::duplicate_field(
9781 "multiple values for start_load_interval",
9782 ));
9783 }
9784 result.start_load_interval = map
9785 .next_value::<std::option::Option<
9786 crate::model::vehicle::load_limit::Interval,
9787 >>()?;
9788 }
9789 __FieldTag::__end_load_interval => {
9790 if !fields.insert(__FieldTag::__end_load_interval) {
9791 return std::result::Result::Err(A::Error::duplicate_field(
9792 "multiple values for end_load_interval",
9793 ));
9794 }
9795 result.end_load_interval = map
9796 .next_value::<std::option::Option<
9797 crate::model::vehicle::load_limit::Interval,
9798 >>()?;
9799 }
9800 __FieldTag::Unknown(key) => {
9801 let value = map.next_value::<serde_json::Value>()?;
9802 result._unknown_fields.insert(key, value);
9803 }
9804 }
9805 }
9806 std::result::Result::Ok(result)
9807 }
9808 }
9809 deserializer.deserialize_any(Visitor)
9810 }
9811 }
9812
9813 #[doc(hidden)]
9814 impl serde::ser::Serialize for LoadLimit {
9815 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9816 where
9817 S: serde::ser::Serializer,
9818 {
9819 use serde::ser::SerializeMap;
9820 #[allow(unused_imports)]
9821 use std::option::Option::Some;
9822 let mut state = serializer.serialize_map(std::option::Option::None)?;
9823 if self.max_load.is_some() {
9824 struct __With<'a>(&'a std::option::Option<i64>);
9825 impl<'a> serde::ser::Serialize for __With<'a> {
9826 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9827 where
9828 S: serde::ser::Serializer,
9829 {
9830 serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
9831 self.0, serializer,
9832 )
9833 }
9834 }
9835 state.serialize_entry("maxLoad", &__With(&self.max_load))?;
9836 }
9837 if !wkt::internal::is_default(&self.soft_max_load) {
9838 struct __With<'a>(&'a i64);
9839 impl<'a> serde::ser::Serialize for __With<'a> {
9840 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9841 where
9842 S: serde::ser::Serializer,
9843 {
9844 serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
9845 }
9846 }
9847 state.serialize_entry("softMaxLoad", &__With(&self.soft_max_load))?;
9848 }
9849 if !wkt::internal::is_default(&self.cost_per_unit_above_soft_max) {
9850 struct __With<'a>(&'a f64);
9851 impl<'a> serde::ser::Serialize for __With<'a> {
9852 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9853 where
9854 S: serde::ser::Serializer,
9855 {
9856 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
9857 }
9858 }
9859 state.serialize_entry(
9860 "costPerUnitAboveSoftMax",
9861 &__With(&self.cost_per_unit_above_soft_max),
9862 )?;
9863 }
9864 if self.start_load_interval.is_some() {
9865 state.serialize_entry("startLoadInterval", &self.start_load_interval)?;
9866 }
9867 if self.end_load_interval.is_some() {
9868 state.serialize_entry("endLoadInterval", &self.end_load_interval)?;
9869 }
9870 if !self._unknown_fields.is_empty() {
9871 for (key, value) in self._unknown_fields.iter() {
9872 state.serialize_entry(key, &value)?;
9873 }
9874 }
9875 state.end()
9876 }
9877 }
9878
9879 pub mod load_limit {
9881 #[allow(unused_imports)]
9882 use super::*;
9883
9884 #[derive(Clone, Debug, Default, PartialEq)]
9886 #[non_exhaustive]
9887 pub struct Interval {
9888 pub min: i64,
9897
9898 pub max: std::option::Option<i64>,
9908
9909 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9910 }
9911
9912 impl Interval {
9913 pub fn new() -> Self {
9914 std::default::Default::default()
9915 }
9916
9917 pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9919 self.min = v.into();
9920 self
9921 }
9922
9923 pub fn set_max<T>(mut self, v: T) -> Self
9925 where
9926 T: std::convert::Into<i64>,
9927 {
9928 self.max = std::option::Option::Some(v.into());
9929 self
9930 }
9931
9932 pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
9934 where
9935 T: std::convert::Into<i64>,
9936 {
9937 self.max = v.map(|x| x.into());
9938 self
9939 }
9940 }
9941
9942 impl wkt::message::Message for Interval {
9943 fn typename() -> &'static str {
9944 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
9945 }
9946 }
9947
9948 #[doc(hidden)]
9949 impl<'de> serde::de::Deserialize<'de> for Interval {
9950 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9951 where
9952 D: serde::Deserializer<'de>,
9953 {
9954 #[allow(non_camel_case_types)]
9955 #[doc(hidden)]
9956 #[derive(PartialEq, Eq, Hash)]
9957 enum __FieldTag {
9958 __min,
9959 __max,
9960 Unknown(std::string::String),
9961 }
9962 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
9963 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9964 where
9965 D: serde::Deserializer<'de>,
9966 {
9967 struct Visitor;
9968 impl<'de> serde::de::Visitor<'de> for Visitor {
9969 type Value = __FieldTag;
9970 fn expecting(
9971 &self,
9972 formatter: &mut std::fmt::Formatter,
9973 ) -> std::fmt::Result {
9974 formatter.write_str("a field name for Interval")
9975 }
9976 fn visit_str<E>(
9977 self,
9978 value: &str,
9979 ) -> std::result::Result<Self::Value, E>
9980 where
9981 E: serde::de::Error,
9982 {
9983 use std::result::Result::Ok;
9984 use std::string::ToString;
9985 match value {
9986 "min" => Ok(__FieldTag::__min),
9987 "max" => Ok(__FieldTag::__max),
9988 _ => Ok(__FieldTag::Unknown(value.to_string())),
9989 }
9990 }
9991 }
9992 deserializer.deserialize_identifier(Visitor)
9993 }
9994 }
9995 struct Visitor;
9996 impl<'de> serde::de::Visitor<'de> for Visitor {
9997 type Value = Interval;
9998 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
9999 formatter.write_str("struct Interval")
10000 }
10001 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10002 where
10003 A: serde::de::MapAccess<'de>,
10004 {
10005 #[allow(unused_imports)]
10006 use serde::de::Error;
10007 use std::option::Option::Some;
10008 let mut fields = std::collections::HashSet::new();
10009 let mut result = Self::Value::new();
10010 while let Some(tag) = map.next_key::<__FieldTag>()? {
10011 #[allow(clippy::match_single_binding)]
10012 match tag {
10013 __FieldTag::__min => {
10014 if !fields.insert(__FieldTag::__min) {
10015 return std::result::Result::Err(
10016 A::Error::duplicate_field("multiple values for min"),
10017 );
10018 }
10019 struct __With(std::option::Option<i64>);
10020 impl<'de> serde::de::Deserialize<'de> for __With {
10021 fn deserialize<D>(
10022 deserializer: D,
10023 ) -> std::result::Result<Self, D::Error>
10024 where
10025 D: serde::de::Deserializer<'de>,
10026 {
10027 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
10028 }
10029 }
10030 result.min = map.next_value::<__With>()?.0.unwrap_or_default();
10031 }
10032 __FieldTag::__max => {
10033 if !fields.insert(__FieldTag::__max) {
10034 return std::result::Result::Err(
10035 A::Error::duplicate_field("multiple values for max"),
10036 );
10037 }
10038 struct __With(std::option::Option<i64>);
10039 impl<'de> serde::de::Deserialize<'de> for __With {
10040 fn deserialize<D>(
10041 deserializer: D,
10042 ) -> std::result::Result<Self, D::Error>
10043 where
10044 D: serde::de::Deserializer<'de>,
10045 {
10046 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
10047 }
10048 }
10049 result.max = map.next_value::<__With>()?.0;
10050 }
10051 __FieldTag::Unknown(key) => {
10052 let value = map.next_value::<serde_json::Value>()?;
10053 result._unknown_fields.insert(key, value);
10054 }
10055 }
10056 }
10057 std::result::Result::Ok(result)
10058 }
10059 }
10060 deserializer.deserialize_any(Visitor)
10061 }
10062 }
10063
10064 #[doc(hidden)]
10065 impl serde::ser::Serialize for Interval {
10066 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10067 where
10068 S: serde::ser::Serializer,
10069 {
10070 use serde::ser::SerializeMap;
10071 #[allow(unused_imports)]
10072 use std::option::Option::Some;
10073 let mut state = serializer.serialize_map(std::option::Option::None)?;
10074 if !wkt::internal::is_default(&self.min) {
10075 struct __With<'a>(&'a i64);
10076 impl<'a> serde::ser::Serialize for __With<'a> {
10077 fn serialize<S>(
10078 &self,
10079 serializer: S,
10080 ) -> std::result::Result<S::Ok, S::Error>
10081 where
10082 S: serde::ser::Serializer,
10083 {
10084 serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
10085 }
10086 }
10087 state.serialize_entry("min", &__With(&self.min))?;
10088 }
10089 if self.max.is_some() {
10090 struct __With<'a>(&'a std::option::Option<i64>);
10091 impl<'a> serde::ser::Serialize for __With<'a> {
10092 fn serialize<S>(
10093 &self,
10094 serializer: S,
10095 ) -> std::result::Result<S::Ok, S::Error>
10096 where
10097 S: serde::ser::Serializer,
10098 {
10099 serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
10100 self.0, serializer,
10101 )
10102 }
10103 }
10104 state.serialize_entry("max", &__With(&self.max))?;
10105 }
10106 if !self._unknown_fields.is_empty() {
10107 for (key, value) in self._unknown_fields.iter() {
10108 state.serialize_entry(key, &value)?;
10109 }
10110 }
10111 state.end()
10112 }
10113 }
10114 }
10115
10116 #[derive(Clone, Debug, Default, PartialEq)]
10122 #[non_exhaustive]
10123 pub struct DurationLimit {
10124 pub max_duration: std::option::Option<wkt::Duration>,
10126
10127 pub soft_max_duration: std::option::Option<wkt::Duration>,
10134
10135 pub cost_per_hour_after_soft_max: std::option::Option<f64>,
10145
10146 pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
10157
10158 pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
10171
10172 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10173 }
10174
10175 impl DurationLimit {
10176 pub fn new() -> Self {
10177 std::default::Default::default()
10178 }
10179
10180 pub fn set_max_duration<T>(mut self, v: T) -> Self
10182 where
10183 T: std::convert::Into<wkt::Duration>,
10184 {
10185 self.max_duration = std::option::Option::Some(v.into());
10186 self
10187 }
10188
10189 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
10191 where
10192 T: std::convert::Into<wkt::Duration>,
10193 {
10194 self.max_duration = v.map(|x| x.into());
10195 self
10196 }
10197
10198 pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
10200 where
10201 T: std::convert::Into<wkt::Duration>,
10202 {
10203 self.soft_max_duration = std::option::Option::Some(v.into());
10204 self
10205 }
10206
10207 pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
10209 where
10210 T: std::convert::Into<wkt::Duration>,
10211 {
10212 self.soft_max_duration = v.map(|x| x.into());
10213 self
10214 }
10215
10216 pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
10218 where
10219 T: std::convert::Into<f64>,
10220 {
10221 self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
10222 self
10223 }
10224
10225 pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
10227 mut self,
10228 v: std::option::Option<T>,
10229 ) -> Self
10230 where
10231 T: std::convert::Into<f64>,
10232 {
10233 self.cost_per_hour_after_soft_max = v.map(|x| x.into());
10234 self
10235 }
10236
10237 pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
10239 where
10240 T: std::convert::Into<wkt::Duration>,
10241 {
10242 self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
10243 self
10244 }
10245
10246 pub fn set_or_clear_quadratic_soft_max_duration<T>(
10248 mut self,
10249 v: std::option::Option<T>,
10250 ) -> Self
10251 where
10252 T: std::convert::Into<wkt::Duration>,
10253 {
10254 self.quadratic_soft_max_duration = v.map(|x| x.into());
10255 self
10256 }
10257
10258 pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
10260 where
10261 T: std::convert::Into<f64>,
10262 {
10263 self.cost_per_square_hour_after_quadratic_soft_max =
10264 std::option::Option::Some(v.into());
10265 self
10266 }
10267
10268 pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
10270 mut self,
10271 v: std::option::Option<T>,
10272 ) -> Self
10273 where
10274 T: std::convert::Into<f64>,
10275 {
10276 self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
10277 self
10278 }
10279 }
10280
10281 impl wkt::message::Message for DurationLimit {
10282 fn typename() -> &'static str {
10283 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
10284 }
10285 }
10286
10287 #[doc(hidden)]
10288 impl<'de> serde::de::Deserialize<'de> for DurationLimit {
10289 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10290 where
10291 D: serde::Deserializer<'de>,
10292 {
10293 #[allow(non_camel_case_types)]
10294 #[doc(hidden)]
10295 #[derive(PartialEq, Eq, Hash)]
10296 enum __FieldTag {
10297 __max_duration,
10298 __soft_max_duration,
10299 __cost_per_hour_after_soft_max,
10300 __quadratic_soft_max_duration,
10301 __cost_per_square_hour_after_quadratic_soft_max,
10302 Unknown(std::string::String),
10303 }
10304 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
10305 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10306 where
10307 D: serde::Deserializer<'de>,
10308 {
10309 struct Visitor;
10310 impl<'de> serde::de::Visitor<'de> for Visitor {
10311 type Value = __FieldTag;
10312 fn expecting(
10313 &self,
10314 formatter: &mut std::fmt::Formatter,
10315 ) -> std::fmt::Result {
10316 formatter.write_str("a field name for DurationLimit")
10317 }
10318 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
10319 where
10320 E: serde::de::Error,
10321 {
10322 use std::result::Result::Ok;
10323 use std::string::ToString;
10324 match value {
10325 "maxDuration" => Ok(__FieldTag::__max_duration),
10326 "max_duration" => Ok(__FieldTag::__max_duration),
10327 "softMaxDuration" => Ok(__FieldTag::__soft_max_duration),
10328 "soft_max_duration" => Ok(__FieldTag::__soft_max_duration),
10329 "costPerHourAfterSoftMax" => {
10330 Ok(__FieldTag::__cost_per_hour_after_soft_max)
10331 }
10332 "cost_per_hour_after_soft_max" => {
10333 Ok(__FieldTag::__cost_per_hour_after_soft_max)
10334 }
10335 "quadraticSoftMaxDuration" => {
10336 Ok(__FieldTag::__quadratic_soft_max_duration)
10337 }
10338 "quadratic_soft_max_duration" => {
10339 Ok(__FieldTag::__quadratic_soft_max_duration)
10340 }
10341 "costPerSquareHourAfterQuadraticSoftMax" => {
10342 Ok(__FieldTag::__cost_per_square_hour_after_quadratic_soft_max)
10343 }
10344 "cost_per_square_hour_after_quadratic_soft_max" => {
10345 Ok(__FieldTag::__cost_per_square_hour_after_quadratic_soft_max)
10346 }
10347 _ => Ok(__FieldTag::Unknown(value.to_string())),
10348 }
10349 }
10350 }
10351 deserializer.deserialize_identifier(Visitor)
10352 }
10353 }
10354 struct Visitor;
10355 impl<'de> serde::de::Visitor<'de> for Visitor {
10356 type Value = DurationLimit;
10357 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
10358 formatter.write_str("struct DurationLimit")
10359 }
10360 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
10361 where
10362 A: serde::de::MapAccess<'de>,
10363 {
10364 #[allow(unused_imports)]
10365 use serde::de::Error;
10366 use std::option::Option::Some;
10367 let mut fields = std::collections::HashSet::new();
10368 let mut result = Self::Value::new();
10369 while let Some(tag) = map.next_key::<__FieldTag>()? {
10370 #[allow(clippy::match_single_binding)]
10371 match tag {
10372 __FieldTag::__max_duration => {
10373 if !fields.insert(__FieldTag::__max_duration) {
10374 return std::result::Result::Err(A::Error::duplicate_field(
10375 "multiple values for max_duration",
10376 ));
10377 }
10378 result.max_duration =
10379 map.next_value::<std::option::Option<wkt::Duration>>()?;
10380 }
10381 __FieldTag::__soft_max_duration => {
10382 if !fields.insert(__FieldTag::__soft_max_duration) {
10383 return std::result::Result::Err(A::Error::duplicate_field(
10384 "multiple values for soft_max_duration",
10385 ));
10386 }
10387 result.soft_max_duration =
10388 map.next_value::<std::option::Option<wkt::Duration>>()?;
10389 }
10390 __FieldTag::__cost_per_hour_after_soft_max => {
10391 if !fields.insert(__FieldTag::__cost_per_hour_after_soft_max) {
10392 return std::result::Result::Err(A::Error::duplicate_field(
10393 "multiple values for cost_per_hour_after_soft_max",
10394 ));
10395 }
10396 struct __With(std::option::Option<f64>);
10397 impl<'de> serde::de::Deserialize<'de> for __With {
10398 fn deserialize<D>(
10399 deserializer: D,
10400 ) -> std::result::Result<Self, D::Error>
10401 where
10402 D: serde::de::Deserializer<'de>,
10403 {
10404 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
10405 }
10406 }
10407 result.cost_per_hour_after_soft_max = map.next_value::<__With>()?.0;
10408 }
10409 __FieldTag::__quadratic_soft_max_duration => {
10410 if !fields.insert(__FieldTag::__quadratic_soft_max_duration) {
10411 return std::result::Result::Err(A::Error::duplicate_field(
10412 "multiple values for quadratic_soft_max_duration",
10413 ));
10414 }
10415 result.quadratic_soft_max_duration =
10416 map.next_value::<std::option::Option<wkt::Duration>>()?;
10417 }
10418 __FieldTag::__cost_per_square_hour_after_quadratic_soft_max => {
10419 if !fields.insert(
10420 __FieldTag::__cost_per_square_hour_after_quadratic_soft_max,
10421 ) {
10422 return std::result::Result::Err(A::Error::duplicate_field(
10423 "multiple values for cost_per_square_hour_after_quadratic_soft_max",
10424 ));
10425 }
10426 struct __With(std::option::Option<f64>);
10427 impl<'de> serde::de::Deserialize<'de> for __With {
10428 fn deserialize<D>(
10429 deserializer: D,
10430 ) -> std::result::Result<Self, D::Error>
10431 where
10432 D: serde::de::Deserializer<'de>,
10433 {
10434 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
10435 }
10436 }
10437 result.cost_per_square_hour_after_quadratic_soft_max =
10438 map.next_value::<__With>()?.0;
10439 }
10440 __FieldTag::Unknown(key) => {
10441 let value = map.next_value::<serde_json::Value>()?;
10442 result._unknown_fields.insert(key, value);
10443 }
10444 }
10445 }
10446 std::result::Result::Ok(result)
10447 }
10448 }
10449 deserializer.deserialize_any(Visitor)
10450 }
10451 }
10452
10453 #[doc(hidden)]
10454 impl serde::ser::Serialize for DurationLimit {
10455 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10456 where
10457 S: serde::ser::Serializer,
10458 {
10459 use serde::ser::SerializeMap;
10460 #[allow(unused_imports)]
10461 use std::option::Option::Some;
10462 let mut state = serializer.serialize_map(std::option::Option::None)?;
10463 if self.max_duration.is_some() {
10464 state.serialize_entry("maxDuration", &self.max_duration)?;
10465 }
10466 if self.soft_max_duration.is_some() {
10467 state.serialize_entry("softMaxDuration", &self.soft_max_duration)?;
10468 }
10469 if self.cost_per_hour_after_soft_max.is_some() {
10470 struct __With<'a>(&'a std::option::Option<f64>);
10471 impl<'a> serde::ser::Serialize for __With<'a> {
10472 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10473 where
10474 S: serde::ser::Serializer,
10475 {
10476 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
10477 self.0, serializer,
10478 )
10479 }
10480 }
10481 state.serialize_entry(
10482 "costPerHourAfterSoftMax",
10483 &__With(&self.cost_per_hour_after_soft_max),
10484 )?;
10485 }
10486 if self.quadratic_soft_max_duration.is_some() {
10487 state.serialize_entry(
10488 "quadraticSoftMaxDuration",
10489 &self.quadratic_soft_max_duration,
10490 )?;
10491 }
10492 if self.cost_per_square_hour_after_quadratic_soft_max.is_some() {
10493 struct __With<'a>(&'a std::option::Option<f64>);
10494 impl<'a> serde::ser::Serialize for __With<'a> {
10495 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10496 where
10497 S: serde::ser::Serializer,
10498 {
10499 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
10500 self.0, serializer,
10501 )
10502 }
10503 }
10504 state.serialize_entry(
10505 "costPerSquareHourAfterQuadraticSoftMax",
10506 &__With(&self.cost_per_square_hour_after_quadratic_soft_max),
10507 )?;
10508 }
10509 if !self._unknown_fields.is_empty() {
10510 for (key, value) in self._unknown_fields.iter() {
10511 state.serialize_entry(key, &value)?;
10512 }
10513 }
10514 state.end()
10515 }
10516 }
10517
10518 #[derive(Clone, Debug, PartialEq)]
10538 #[non_exhaustive]
10539 pub enum TravelMode {
10540 Unspecified,
10542 Driving,
10544 Walking,
10546 UnknownValue(travel_mode::UnknownValue),
10551 }
10552
10553 #[doc(hidden)]
10554 pub mod travel_mode {
10555 #[allow(unused_imports)]
10556 use super::*;
10557 #[derive(Clone, Debug, PartialEq)]
10558 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10559 }
10560
10561 impl TravelMode {
10562 pub fn value(&self) -> std::option::Option<i32> {
10567 match self {
10568 Self::Unspecified => std::option::Option::Some(0),
10569 Self::Driving => std::option::Option::Some(1),
10570 Self::Walking => std::option::Option::Some(2),
10571 Self::UnknownValue(u) => u.0.value(),
10572 }
10573 }
10574
10575 pub fn name(&self) -> std::option::Option<&str> {
10580 match self {
10581 Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
10582 Self::Driving => std::option::Option::Some("DRIVING"),
10583 Self::Walking => std::option::Option::Some("WALKING"),
10584 Self::UnknownValue(u) => u.0.name(),
10585 }
10586 }
10587 }
10588
10589 impl std::default::Default for TravelMode {
10590 fn default() -> Self {
10591 use std::convert::From;
10592 Self::from(0)
10593 }
10594 }
10595
10596 impl std::fmt::Display for TravelMode {
10597 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10598 wkt::internal::display_enum(f, self.name(), self.value())
10599 }
10600 }
10601
10602 impl std::convert::From<i32> for TravelMode {
10603 fn from(value: i32) -> Self {
10604 match value {
10605 0 => Self::Unspecified,
10606 1 => Self::Driving,
10607 2 => Self::Walking,
10608 _ => Self::UnknownValue(travel_mode::UnknownValue(
10609 wkt::internal::UnknownEnumValue::Integer(value),
10610 )),
10611 }
10612 }
10613 }
10614
10615 impl std::convert::From<&str> for TravelMode {
10616 fn from(value: &str) -> Self {
10617 use std::string::ToString;
10618 match value {
10619 "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
10620 "DRIVING" => Self::Driving,
10621 "WALKING" => Self::Walking,
10622 _ => Self::UnknownValue(travel_mode::UnknownValue(
10623 wkt::internal::UnknownEnumValue::String(value.to_string()),
10624 )),
10625 }
10626 }
10627 }
10628
10629 impl serde::ser::Serialize for TravelMode {
10630 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10631 where
10632 S: serde::Serializer,
10633 {
10634 match self {
10635 Self::Unspecified => serializer.serialize_i32(0),
10636 Self::Driving => serializer.serialize_i32(1),
10637 Self::Walking => serializer.serialize_i32(2),
10638 Self::UnknownValue(u) => u.0.serialize(serializer),
10639 }
10640 }
10641 }
10642
10643 impl<'de> serde::de::Deserialize<'de> for TravelMode {
10644 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10645 where
10646 D: serde::Deserializer<'de>,
10647 {
10648 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
10649 ".google.cloud.optimization.v1.Vehicle.TravelMode",
10650 ))
10651 }
10652 }
10653
10654 #[derive(Clone, Debug, PartialEq)]
10674 #[non_exhaustive]
10675 pub enum UnloadingPolicy {
10676 Unspecified,
10679 LastInFirstOut,
10681 FirstInFirstOut,
10683 UnknownValue(unloading_policy::UnknownValue),
10688 }
10689
10690 #[doc(hidden)]
10691 pub mod unloading_policy {
10692 #[allow(unused_imports)]
10693 use super::*;
10694 #[derive(Clone, Debug, PartialEq)]
10695 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10696 }
10697
10698 impl UnloadingPolicy {
10699 pub fn value(&self) -> std::option::Option<i32> {
10704 match self {
10705 Self::Unspecified => std::option::Option::Some(0),
10706 Self::LastInFirstOut => std::option::Option::Some(1),
10707 Self::FirstInFirstOut => std::option::Option::Some(2),
10708 Self::UnknownValue(u) => u.0.value(),
10709 }
10710 }
10711
10712 pub fn name(&self) -> std::option::Option<&str> {
10717 match self {
10718 Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
10719 Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
10720 Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
10721 Self::UnknownValue(u) => u.0.name(),
10722 }
10723 }
10724 }
10725
10726 impl std::default::Default for UnloadingPolicy {
10727 fn default() -> Self {
10728 use std::convert::From;
10729 Self::from(0)
10730 }
10731 }
10732
10733 impl std::fmt::Display for UnloadingPolicy {
10734 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10735 wkt::internal::display_enum(f, self.name(), self.value())
10736 }
10737 }
10738
10739 impl std::convert::From<i32> for UnloadingPolicy {
10740 fn from(value: i32) -> Self {
10741 match value {
10742 0 => Self::Unspecified,
10743 1 => Self::LastInFirstOut,
10744 2 => Self::FirstInFirstOut,
10745 _ => Self::UnknownValue(unloading_policy::UnknownValue(
10746 wkt::internal::UnknownEnumValue::Integer(value),
10747 )),
10748 }
10749 }
10750 }
10751
10752 impl std::convert::From<&str> for UnloadingPolicy {
10753 fn from(value: &str) -> Self {
10754 use std::string::ToString;
10755 match value {
10756 "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
10757 "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
10758 "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
10759 _ => Self::UnknownValue(unloading_policy::UnknownValue(
10760 wkt::internal::UnknownEnumValue::String(value.to_string()),
10761 )),
10762 }
10763 }
10764 }
10765
10766 impl serde::ser::Serialize for UnloadingPolicy {
10767 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10768 where
10769 S: serde::Serializer,
10770 {
10771 match self {
10772 Self::Unspecified => serializer.serialize_i32(0),
10773 Self::LastInFirstOut => serializer.serialize_i32(1),
10774 Self::FirstInFirstOut => serializer.serialize_i32(2),
10775 Self::UnknownValue(u) => u.0.serialize(serializer),
10776 }
10777 }
10778 }
10779
10780 impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
10781 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10782 where
10783 D: serde::Deserializer<'de>,
10784 {
10785 deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
10786 ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
10787 ))
10788 }
10789 }
10790}
10791
10792#[derive(Clone, Debug, Default, PartialEq)]
10818#[non_exhaustive]
10819pub struct TimeWindow {
10820 pub start_time: std::option::Option<wkt::Timestamp>,
10823
10824 pub end_time: std::option::Option<wkt::Timestamp>,
10827
10828 pub soft_start_time: std::option::Option<wkt::Timestamp>,
10830
10831 pub soft_end_time: std::option::Option<wkt::Timestamp>,
10833
10834 pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
10846
10847 pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
10859
10860 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10861}
10862
10863impl TimeWindow {
10864 pub fn new() -> Self {
10865 std::default::Default::default()
10866 }
10867
10868 pub fn set_start_time<T>(mut self, v: T) -> Self
10870 where
10871 T: std::convert::Into<wkt::Timestamp>,
10872 {
10873 self.start_time = std::option::Option::Some(v.into());
10874 self
10875 }
10876
10877 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
10879 where
10880 T: std::convert::Into<wkt::Timestamp>,
10881 {
10882 self.start_time = v.map(|x| x.into());
10883 self
10884 }
10885
10886 pub fn set_end_time<T>(mut self, v: T) -> Self
10888 where
10889 T: std::convert::Into<wkt::Timestamp>,
10890 {
10891 self.end_time = std::option::Option::Some(v.into());
10892 self
10893 }
10894
10895 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
10897 where
10898 T: std::convert::Into<wkt::Timestamp>,
10899 {
10900 self.end_time = v.map(|x| x.into());
10901 self
10902 }
10903
10904 pub fn set_soft_start_time<T>(mut self, v: T) -> Self
10906 where
10907 T: std::convert::Into<wkt::Timestamp>,
10908 {
10909 self.soft_start_time = std::option::Option::Some(v.into());
10910 self
10911 }
10912
10913 pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
10915 where
10916 T: std::convert::Into<wkt::Timestamp>,
10917 {
10918 self.soft_start_time = v.map(|x| x.into());
10919 self
10920 }
10921
10922 pub fn set_soft_end_time<T>(mut self, v: T) -> Self
10924 where
10925 T: std::convert::Into<wkt::Timestamp>,
10926 {
10927 self.soft_end_time = std::option::Option::Some(v.into());
10928 self
10929 }
10930
10931 pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
10933 where
10934 T: std::convert::Into<wkt::Timestamp>,
10935 {
10936 self.soft_end_time = v.map(|x| x.into());
10937 self
10938 }
10939
10940 pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
10942 where
10943 T: std::convert::Into<f64>,
10944 {
10945 self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
10946 self
10947 }
10948
10949 pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
10951 mut self,
10952 v: std::option::Option<T>,
10953 ) -> Self
10954 where
10955 T: std::convert::Into<f64>,
10956 {
10957 self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
10958 self
10959 }
10960
10961 pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
10963 where
10964 T: std::convert::Into<f64>,
10965 {
10966 self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
10967 self
10968 }
10969
10970 pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
10972 mut self,
10973 v: std::option::Option<T>,
10974 ) -> Self
10975 where
10976 T: std::convert::Into<f64>,
10977 {
10978 self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
10979 self
10980 }
10981}
10982
10983impl wkt::message::Message for TimeWindow {
10984 fn typename() -> &'static str {
10985 "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
10986 }
10987}
10988
10989#[doc(hidden)]
10990impl<'de> serde::de::Deserialize<'de> for TimeWindow {
10991 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10992 where
10993 D: serde::Deserializer<'de>,
10994 {
10995 #[allow(non_camel_case_types)]
10996 #[doc(hidden)]
10997 #[derive(PartialEq, Eq, Hash)]
10998 enum __FieldTag {
10999 __start_time,
11000 __end_time,
11001 __soft_start_time,
11002 __soft_end_time,
11003 __cost_per_hour_before_soft_start_time,
11004 __cost_per_hour_after_soft_end_time,
11005 Unknown(std::string::String),
11006 }
11007 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11008 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11009 where
11010 D: serde::Deserializer<'de>,
11011 {
11012 struct Visitor;
11013 impl<'de> serde::de::Visitor<'de> for Visitor {
11014 type Value = __FieldTag;
11015 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11016 formatter.write_str("a field name for TimeWindow")
11017 }
11018 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11019 where
11020 E: serde::de::Error,
11021 {
11022 use std::result::Result::Ok;
11023 use std::string::ToString;
11024 match value {
11025 "startTime" => Ok(__FieldTag::__start_time),
11026 "start_time" => Ok(__FieldTag::__start_time),
11027 "endTime" => Ok(__FieldTag::__end_time),
11028 "end_time" => Ok(__FieldTag::__end_time),
11029 "softStartTime" => Ok(__FieldTag::__soft_start_time),
11030 "soft_start_time" => Ok(__FieldTag::__soft_start_time),
11031 "softEndTime" => Ok(__FieldTag::__soft_end_time),
11032 "soft_end_time" => Ok(__FieldTag::__soft_end_time),
11033 "costPerHourBeforeSoftStartTime" => {
11034 Ok(__FieldTag::__cost_per_hour_before_soft_start_time)
11035 }
11036 "cost_per_hour_before_soft_start_time" => {
11037 Ok(__FieldTag::__cost_per_hour_before_soft_start_time)
11038 }
11039 "costPerHourAfterSoftEndTime" => {
11040 Ok(__FieldTag::__cost_per_hour_after_soft_end_time)
11041 }
11042 "cost_per_hour_after_soft_end_time" => {
11043 Ok(__FieldTag::__cost_per_hour_after_soft_end_time)
11044 }
11045 _ => Ok(__FieldTag::Unknown(value.to_string())),
11046 }
11047 }
11048 }
11049 deserializer.deserialize_identifier(Visitor)
11050 }
11051 }
11052 struct Visitor;
11053 impl<'de> serde::de::Visitor<'de> for Visitor {
11054 type Value = TimeWindow;
11055 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11056 formatter.write_str("struct TimeWindow")
11057 }
11058 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11059 where
11060 A: serde::de::MapAccess<'de>,
11061 {
11062 #[allow(unused_imports)]
11063 use serde::de::Error;
11064 use std::option::Option::Some;
11065 let mut fields = std::collections::HashSet::new();
11066 let mut result = Self::Value::new();
11067 while let Some(tag) = map.next_key::<__FieldTag>()? {
11068 #[allow(clippy::match_single_binding)]
11069 match tag {
11070 __FieldTag::__start_time => {
11071 if !fields.insert(__FieldTag::__start_time) {
11072 return std::result::Result::Err(A::Error::duplicate_field(
11073 "multiple values for start_time",
11074 ));
11075 }
11076 result.start_time =
11077 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11078 }
11079 __FieldTag::__end_time => {
11080 if !fields.insert(__FieldTag::__end_time) {
11081 return std::result::Result::Err(A::Error::duplicate_field(
11082 "multiple values for end_time",
11083 ));
11084 }
11085 result.end_time =
11086 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11087 }
11088 __FieldTag::__soft_start_time => {
11089 if !fields.insert(__FieldTag::__soft_start_time) {
11090 return std::result::Result::Err(A::Error::duplicate_field(
11091 "multiple values for soft_start_time",
11092 ));
11093 }
11094 result.soft_start_time =
11095 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11096 }
11097 __FieldTag::__soft_end_time => {
11098 if !fields.insert(__FieldTag::__soft_end_time) {
11099 return std::result::Result::Err(A::Error::duplicate_field(
11100 "multiple values for soft_end_time",
11101 ));
11102 }
11103 result.soft_end_time =
11104 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
11105 }
11106 __FieldTag::__cost_per_hour_before_soft_start_time => {
11107 if !fields.insert(__FieldTag::__cost_per_hour_before_soft_start_time) {
11108 return std::result::Result::Err(A::Error::duplicate_field(
11109 "multiple values for cost_per_hour_before_soft_start_time",
11110 ));
11111 }
11112 struct __With(std::option::Option<f64>);
11113 impl<'de> serde::de::Deserialize<'de> for __With {
11114 fn deserialize<D>(
11115 deserializer: D,
11116 ) -> std::result::Result<Self, D::Error>
11117 where
11118 D: serde::de::Deserializer<'de>,
11119 {
11120 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11121 }
11122 }
11123 result.cost_per_hour_before_soft_start_time =
11124 map.next_value::<__With>()?.0;
11125 }
11126 __FieldTag::__cost_per_hour_after_soft_end_time => {
11127 if !fields.insert(__FieldTag::__cost_per_hour_after_soft_end_time) {
11128 return std::result::Result::Err(A::Error::duplicate_field(
11129 "multiple values for cost_per_hour_after_soft_end_time",
11130 ));
11131 }
11132 struct __With(std::option::Option<f64>);
11133 impl<'de> serde::de::Deserialize<'de> for __With {
11134 fn deserialize<D>(
11135 deserializer: D,
11136 ) -> std::result::Result<Self, D::Error>
11137 where
11138 D: serde::de::Deserializer<'de>,
11139 {
11140 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11141 }
11142 }
11143 result.cost_per_hour_after_soft_end_time =
11144 map.next_value::<__With>()?.0;
11145 }
11146 __FieldTag::Unknown(key) => {
11147 let value = map.next_value::<serde_json::Value>()?;
11148 result._unknown_fields.insert(key, value);
11149 }
11150 }
11151 }
11152 std::result::Result::Ok(result)
11153 }
11154 }
11155 deserializer.deserialize_any(Visitor)
11156 }
11157}
11158
11159#[doc(hidden)]
11160impl serde::ser::Serialize for TimeWindow {
11161 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11162 where
11163 S: serde::ser::Serializer,
11164 {
11165 use serde::ser::SerializeMap;
11166 #[allow(unused_imports)]
11167 use std::option::Option::Some;
11168 let mut state = serializer.serialize_map(std::option::Option::None)?;
11169 if self.start_time.is_some() {
11170 state.serialize_entry("startTime", &self.start_time)?;
11171 }
11172 if self.end_time.is_some() {
11173 state.serialize_entry("endTime", &self.end_time)?;
11174 }
11175 if self.soft_start_time.is_some() {
11176 state.serialize_entry("softStartTime", &self.soft_start_time)?;
11177 }
11178 if self.soft_end_time.is_some() {
11179 state.serialize_entry("softEndTime", &self.soft_end_time)?;
11180 }
11181 if self.cost_per_hour_before_soft_start_time.is_some() {
11182 struct __With<'a>(&'a std::option::Option<f64>);
11183 impl<'a> serde::ser::Serialize for __With<'a> {
11184 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11185 where
11186 S: serde::ser::Serializer,
11187 {
11188 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
11189 self.0, serializer,
11190 )
11191 }
11192 }
11193 state.serialize_entry(
11194 "costPerHourBeforeSoftStartTime",
11195 &__With(&self.cost_per_hour_before_soft_start_time),
11196 )?;
11197 }
11198 if self.cost_per_hour_after_soft_end_time.is_some() {
11199 struct __With<'a>(&'a std::option::Option<f64>);
11200 impl<'a> serde::ser::Serialize for __With<'a> {
11201 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11202 where
11203 S: serde::ser::Serializer,
11204 {
11205 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
11206 self.0, serializer,
11207 )
11208 }
11209 }
11210 state.serialize_entry(
11211 "costPerHourAfterSoftEndTime",
11212 &__With(&self.cost_per_hour_after_soft_end_time),
11213 )?;
11214 }
11215 if !self._unknown_fields.is_empty() {
11216 for (key, value) in self._unknown_fields.iter() {
11217 state.serialize_entry(key, &value)?;
11218 }
11219 }
11220 state.end()
11221 }
11222}
11223
11224#[derive(Clone, Debug, Default, PartialEq)]
11230#[non_exhaustive]
11231#[deprecated]
11232pub struct CapacityQuantity {
11233 pub r#type: std::string::String,
11234
11235 pub value: i64,
11236
11237 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11238}
11239
11240impl CapacityQuantity {
11241 pub fn new() -> Self {
11242 std::default::Default::default()
11243 }
11244
11245 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11247 self.r#type = v.into();
11248 self
11249 }
11250
11251 pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
11253 self.value = v.into();
11254 self
11255 }
11256}
11257
11258impl wkt::message::Message for CapacityQuantity {
11259 fn typename() -> &'static str {
11260 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
11261 }
11262}
11263
11264#[doc(hidden)]
11265impl<'de> serde::de::Deserialize<'de> for CapacityQuantity {
11266 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11267 where
11268 D: serde::Deserializer<'de>,
11269 {
11270 #[allow(non_camel_case_types)]
11271 #[doc(hidden)]
11272 #[derive(PartialEq, Eq, Hash)]
11273 enum __FieldTag {
11274 __type,
11275 __value,
11276 Unknown(std::string::String),
11277 }
11278 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11279 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11280 where
11281 D: serde::Deserializer<'de>,
11282 {
11283 struct Visitor;
11284 impl<'de> serde::de::Visitor<'de> for Visitor {
11285 type Value = __FieldTag;
11286 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11287 formatter.write_str("a field name for CapacityQuantity")
11288 }
11289 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11290 where
11291 E: serde::de::Error,
11292 {
11293 use std::result::Result::Ok;
11294 use std::string::ToString;
11295 match value {
11296 "type" => Ok(__FieldTag::__type),
11297 "value" => Ok(__FieldTag::__value),
11298 _ => Ok(__FieldTag::Unknown(value.to_string())),
11299 }
11300 }
11301 }
11302 deserializer.deserialize_identifier(Visitor)
11303 }
11304 }
11305 struct Visitor;
11306 impl<'de> serde::de::Visitor<'de> for Visitor {
11307 type Value = CapacityQuantity;
11308 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11309 formatter.write_str("struct CapacityQuantity")
11310 }
11311 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11312 where
11313 A: serde::de::MapAccess<'de>,
11314 {
11315 #[allow(unused_imports)]
11316 use serde::de::Error;
11317 use std::option::Option::Some;
11318 let mut fields = std::collections::HashSet::new();
11319 let mut result = Self::Value::new();
11320 while let Some(tag) = map.next_key::<__FieldTag>()? {
11321 #[allow(clippy::match_single_binding)]
11322 match tag {
11323 __FieldTag::__type => {
11324 if !fields.insert(__FieldTag::__type) {
11325 return std::result::Result::Err(A::Error::duplicate_field(
11326 "multiple values for type",
11327 ));
11328 }
11329 result.r#type = map
11330 .next_value::<std::option::Option<std::string::String>>()?
11331 .unwrap_or_default();
11332 }
11333 __FieldTag::__value => {
11334 if !fields.insert(__FieldTag::__value) {
11335 return std::result::Result::Err(A::Error::duplicate_field(
11336 "multiple values for value",
11337 ));
11338 }
11339 struct __With(std::option::Option<i64>);
11340 impl<'de> serde::de::Deserialize<'de> for __With {
11341 fn deserialize<D>(
11342 deserializer: D,
11343 ) -> std::result::Result<Self, D::Error>
11344 where
11345 D: serde::de::Deserializer<'de>,
11346 {
11347 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11348 }
11349 }
11350 result.value = map.next_value::<__With>()?.0.unwrap_or_default();
11351 }
11352 __FieldTag::Unknown(key) => {
11353 let value = map.next_value::<serde_json::Value>()?;
11354 result._unknown_fields.insert(key, value);
11355 }
11356 }
11357 }
11358 std::result::Result::Ok(result)
11359 }
11360 }
11361 deserializer.deserialize_any(Visitor)
11362 }
11363}
11364
11365#[doc(hidden)]
11366impl serde::ser::Serialize for CapacityQuantity {
11367 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11368 where
11369 S: serde::ser::Serializer,
11370 {
11371 use serde::ser::SerializeMap;
11372 #[allow(unused_imports)]
11373 use std::option::Option::Some;
11374 let mut state = serializer.serialize_map(std::option::Option::None)?;
11375 if !self.r#type.is_empty() {
11376 state.serialize_entry("type", &self.r#type)?;
11377 }
11378 if !wkt::internal::is_default(&self.value) {
11379 struct __With<'a>(&'a i64);
11380 impl<'a> serde::ser::Serialize for __With<'a> {
11381 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11382 where
11383 S: serde::ser::Serializer,
11384 {
11385 serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
11386 }
11387 }
11388 state.serialize_entry("value", &__With(&self.value))?;
11389 }
11390 if !self._unknown_fields.is_empty() {
11391 for (key, value) in self._unknown_fields.iter() {
11392 state.serialize_entry(key, &value)?;
11393 }
11394 }
11395 state.end()
11396 }
11397}
11398
11399#[derive(Clone, Debug, Default, PartialEq)]
11405#[non_exhaustive]
11406#[deprecated]
11407pub struct CapacityQuantityInterval {
11408 pub r#type: std::string::String,
11409
11410 pub min_value: std::option::Option<i64>,
11411
11412 pub max_value: std::option::Option<i64>,
11413
11414 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11415}
11416
11417impl CapacityQuantityInterval {
11418 pub fn new() -> Self {
11419 std::default::Default::default()
11420 }
11421
11422 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11424 self.r#type = v.into();
11425 self
11426 }
11427
11428 pub fn set_min_value<T>(mut self, v: T) -> Self
11430 where
11431 T: std::convert::Into<i64>,
11432 {
11433 self.min_value = std::option::Option::Some(v.into());
11434 self
11435 }
11436
11437 pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
11439 where
11440 T: std::convert::Into<i64>,
11441 {
11442 self.min_value = v.map(|x| x.into());
11443 self
11444 }
11445
11446 pub fn set_max_value<T>(mut self, v: T) -> Self
11448 where
11449 T: std::convert::Into<i64>,
11450 {
11451 self.max_value = std::option::Option::Some(v.into());
11452 self
11453 }
11454
11455 pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
11457 where
11458 T: std::convert::Into<i64>,
11459 {
11460 self.max_value = v.map(|x| x.into());
11461 self
11462 }
11463}
11464
11465impl wkt::message::Message for CapacityQuantityInterval {
11466 fn typename() -> &'static str {
11467 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
11468 }
11469}
11470
11471#[doc(hidden)]
11472impl<'de> serde::de::Deserialize<'de> for CapacityQuantityInterval {
11473 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11474 where
11475 D: serde::Deserializer<'de>,
11476 {
11477 #[allow(non_camel_case_types)]
11478 #[doc(hidden)]
11479 #[derive(PartialEq, Eq, Hash)]
11480 enum __FieldTag {
11481 __type,
11482 __min_value,
11483 __max_value,
11484 Unknown(std::string::String),
11485 }
11486 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11487 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11488 where
11489 D: serde::Deserializer<'de>,
11490 {
11491 struct Visitor;
11492 impl<'de> serde::de::Visitor<'de> for Visitor {
11493 type Value = __FieldTag;
11494 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11495 formatter.write_str("a field name for CapacityQuantityInterval")
11496 }
11497 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11498 where
11499 E: serde::de::Error,
11500 {
11501 use std::result::Result::Ok;
11502 use std::string::ToString;
11503 match value {
11504 "type" => Ok(__FieldTag::__type),
11505 "minValue" => Ok(__FieldTag::__min_value),
11506 "min_value" => Ok(__FieldTag::__min_value),
11507 "maxValue" => Ok(__FieldTag::__max_value),
11508 "max_value" => Ok(__FieldTag::__max_value),
11509 _ => Ok(__FieldTag::Unknown(value.to_string())),
11510 }
11511 }
11512 }
11513 deserializer.deserialize_identifier(Visitor)
11514 }
11515 }
11516 struct Visitor;
11517 impl<'de> serde::de::Visitor<'de> for Visitor {
11518 type Value = CapacityQuantityInterval;
11519 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11520 formatter.write_str("struct CapacityQuantityInterval")
11521 }
11522 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11523 where
11524 A: serde::de::MapAccess<'de>,
11525 {
11526 #[allow(unused_imports)]
11527 use serde::de::Error;
11528 use std::option::Option::Some;
11529 let mut fields = std::collections::HashSet::new();
11530 let mut result = Self::Value::new();
11531 while let Some(tag) = map.next_key::<__FieldTag>()? {
11532 #[allow(clippy::match_single_binding)]
11533 match tag {
11534 __FieldTag::__type => {
11535 if !fields.insert(__FieldTag::__type) {
11536 return std::result::Result::Err(A::Error::duplicate_field(
11537 "multiple values for type",
11538 ));
11539 }
11540 result.r#type = map
11541 .next_value::<std::option::Option<std::string::String>>()?
11542 .unwrap_or_default();
11543 }
11544 __FieldTag::__min_value => {
11545 if !fields.insert(__FieldTag::__min_value) {
11546 return std::result::Result::Err(A::Error::duplicate_field(
11547 "multiple values for min_value",
11548 ));
11549 }
11550 struct __With(std::option::Option<i64>);
11551 impl<'de> serde::de::Deserialize<'de> for __With {
11552 fn deserialize<D>(
11553 deserializer: D,
11554 ) -> std::result::Result<Self, D::Error>
11555 where
11556 D: serde::de::Deserializer<'de>,
11557 {
11558 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11559 }
11560 }
11561 result.min_value = map.next_value::<__With>()?.0;
11562 }
11563 __FieldTag::__max_value => {
11564 if !fields.insert(__FieldTag::__max_value) {
11565 return std::result::Result::Err(A::Error::duplicate_field(
11566 "multiple values for max_value",
11567 ));
11568 }
11569 struct __With(std::option::Option<i64>);
11570 impl<'de> serde::de::Deserialize<'de> for __With {
11571 fn deserialize<D>(
11572 deserializer: D,
11573 ) -> std::result::Result<Self, D::Error>
11574 where
11575 D: serde::de::Deserializer<'de>,
11576 {
11577 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11578 }
11579 }
11580 result.max_value = map.next_value::<__With>()?.0;
11581 }
11582 __FieldTag::Unknown(key) => {
11583 let value = map.next_value::<serde_json::Value>()?;
11584 result._unknown_fields.insert(key, value);
11585 }
11586 }
11587 }
11588 std::result::Result::Ok(result)
11589 }
11590 }
11591 deserializer.deserialize_any(Visitor)
11592 }
11593}
11594
11595#[doc(hidden)]
11596impl serde::ser::Serialize for CapacityQuantityInterval {
11597 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11598 where
11599 S: serde::ser::Serializer,
11600 {
11601 use serde::ser::SerializeMap;
11602 #[allow(unused_imports)]
11603 use std::option::Option::Some;
11604 let mut state = serializer.serialize_map(std::option::Option::None)?;
11605 if !self.r#type.is_empty() {
11606 state.serialize_entry("type", &self.r#type)?;
11607 }
11608 if self.min_value.is_some() {
11609 struct __With<'a>(&'a std::option::Option<i64>);
11610 impl<'a> serde::ser::Serialize for __With<'a> {
11611 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11612 where
11613 S: serde::ser::Serializer,
11614 {
11615 serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
11616 self.0, serializer,
11617 )
11618 }
11619 }
11620 state.serialize_entry("minValue", &__With(&self.min_value))?;
11621 }
11622 if self.max_value.is_some() {
11623 struct __With<'a>(&'a std::option::Option<i64>);
11624 impl<'a> serde::ser::Serialize for __With<'a> {
11625 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11626 where
11627 S: serde::ser::Serializer,
11628 {
11629 serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
11630 self.0, serializer,
11631 )
11632 }
11633 }
11634 state.serialize_entry("maxValue", &__With(&self.max_value))?;
11635 }
11636 if !self._unknown_fields.is_empty() {
11637 for (key, value) in self._unknown_fields.iter() {
11638 state.serialize_entry(key, &value)?;
11639 }
11640 }
11641 state.end()
11642 }
11643}
11644
11645#[derive(Clone, Debug, Default, PartialEq)]
11651#[non_exhaustive]
11652pub struct DistanceLimit {
11653 pub max_meters: std::option::Option<i64>,
11656
11657 pub soft_max_meters: std::option::Option<i64>,
11664
11665 pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
11675
11676 pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
11687
11688 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11689}
11690
11691impl DistanceLimit {
11692 pub fn new() -> Self {
11693 std::default::Default::default()
11694 }
11695
11696 pub fn set_max_meters<T>(mut self, v: T) -> Self
11698 where
11699 T: std::convert::Into<i64>,
11700 {
11701 self.max_meters = std::option::Option::Some(v.into());
11702 self
11703 }
11704
11705 pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
11707 where
11708 T: std::convert::Into<i64>,
11709 {
11710 self.max_meters = v.map(|x| x.into());
11711 self
11712 }
11713
11714 pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
11716 where
11717 T: std::convert::Into<i64>,
11718 {
11719 self.soft_max_meters = std::option::Option::Some(v.into());
11720 self
11721 }
11722
11723 pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
11725 where
11726 T: std::convert::Into<i64>,
11727 {
11728 self.soft_max_meters = v.map(|x| x.into());
11729 self
11730 }
11731
11732 pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
11734 where
11735 T: std::convert::Into<f64>,
11736 {
11737 self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
11738 self
11739 }
11740
11741 pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
11743 mut self,
11744 v: std::option::Option<T>,
11745 ) -> Self
11746 where
11747 T: std::convert::Into<f64>,
11748 {
11749 self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
11750 self
11751 }
11752
11753 pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
11755 where
11756 T: std::convert::Into<f64>,
11757 {
11758 self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
11759 self
11760 }
11761
11762 pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
11764 mut self,
11765 v: std::option::Option<T>,
11766 ) -> Self
11767 where
11768 T: std::convert::Into<f64>,
11769 {
11770 self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
11771 self
11772 }
11773}
11774
11775impl wkt::message::Message for DistanceLimit {
11776 fn typename() -> &'static str {
11777 "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
11778 }
11779}
11780
11781#[doc(hidden)]
11782impl<'de> serde::de::Deserialize<'de> for DistanceLimit {
11783 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11784 where
11785 D: serde::Deserializer<'de>,
11786 {
11787 #[allow(non_camel_case_types)]
11788 #[doc(hidden)]
11789 #[derive(PartialEq, Eq, Hash)]
11790 enum __FieldTag {
11791 __max_meters,
11792 __soft_max_meters,
11793 __cost_per_kilometer_below_soft_max,
11794 __cost_per_kilometer_above_soft_max,
11795 Unknown(std::string::String),
11796 }
11797 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
11798 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11799 where
11800 D: serde::Deserializer<'de>,
11801 {
11802 struct Visitor;
11803 impl<'de> serde::de::Visitor<'de> for Visitor {
11804 type Value = __FieldTag;
11805 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11806 formatter.write_str("a field name for DistanceLimit")
11807 }
11808 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
11809 where
11810 E: serde::de::Error,
11811 {
11812 use std::result::Result::Ok;
11813 use std::string::ToString;
11814 match value {
11815 "maxMeters" => Ok(__FieldTag::__max_meters),
11816 "max_meters" => Ok(__FieldTag::__max_meters),
11817 "softMaxMeters" => Ok(__FieldTag::__soft_max_meters),
11818 "soft_max_meters" => Ok(__FieldTag::__soft_max_meters),
11819 "costPerKilometerBelowSoftMax" => {
11820 Ok(__FieldTag::__cost_per_kilometer_below_soft_max)
11821 }
11822 "cost_per_kilometer_below_soft_max" => {
11823 Ok(__FieldTag::__cost_per_kilometer_below_soft_max)
11824 }
11825 "costPerKilometerAboveSoftMax" => {
11826 Ok(__FieldTag::__cost_per_kilometer_above_soft_max)
11827 }
11828 "cost_per_kilometer_above_soft_max" => {
11829 Ok(__FieldTag::__cost_per_kilometer_above_soft_max)
11830 }
11831 _ => Ok(__FieldTag::Unknown(value.to_string())),
11832 }
11833 }
11834 }
11835 deserializer.deserialize_identifier(Visitor)
11836 }
11837 }
11838 struct Visitor;
11839 impl<'de> serde::de::Visitor<'de> for Visitor {
11840 type Value = DistanceLimit;
11841 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
11842 formatter.write_str("struct DistanceLimit")
11843 }
11844 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
11845 where
11846 A: serde::de::MapAccess<'de>,
11847 {
11848 #[allow(unused_imports)]
11849 use serde::de::Error;
11850 use std::option::Option::Some;
11851 let mut fields = std::collections::HashSet::new();
11852 let mut result = Self::Value::new();
11853 while let Some(tag) = map.next_key::<__FieldTag>()? {
11854 #[allow(clippy::match_single_binding)]
11855 match tag {
11856 __FieldTag::__max_meters => {
11857 if !fields.insert(__FieldTag::__max_meters) {
11858 return std::result::Result::Err(A::Error::duplicate_field(
11859 "multiple values for max_meters",
11860 ));
11861 }
11862 struct __With(std::option::Option<i64>);
11863 impl<'de> serde::de::Deserialize<'de> for __With {
11864 fn deserialize<D>(
11865 deserializer: D,
11866 ) -> std::result::Result<Self, D::Error>
11867 where
11868 D: serde::de::Deserializer<'de>,
11869 {
11870 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11871 }
11872 }
11873 result.max_meters = map.next_value::<__With>()?.0;
11874 }
11875 __FieldTag::__soft_max_meters => {
11876 if !fields.insert(__FieldTag::__soft_max_meters) {
11877 return std::result::Result::Err(A::Error::duplicate_field(
11878 "multiple values for soft_max_meters",
11879 ));
11880 }
11881 struct __With(std::option::Option<i64>);
11882 impl<'de> serde::de::Deserialize<'de> for __With {
11883 fn deserialize<D>(
11884 deserializer: D,
11885 ) -> std::result::Result<Self, D::Error>
11886 where
11887 D: serde::de::Deserializer<'de>,
11888 {
11889 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
11890 }
11891 }
11892 result.soft_max_meters = map.next_value::<__With>()?.0;
11893 }
11894 __FieldTag::__cost_per_kilometer_below_soft_max => {
11895 if !fields.insert(__FieldTag::__cost_per_kilometer_below_soft_max) {
11896 return std::result::Result::Err(A::Error::duplicate_field(
11897 "multiple values for cost_per_kilometer_below_soft_max",
11898 ));
11899 }
11900 struct __With(std::option::Option<f64>);
11901 impl<'de> serde::de::Deserialize<'de> for __With {
11902 fn deserialize<D>(
11903 deserializer: D,
11904 ) -> std::result::Result<Self, D::Error>
11905 where
11906 D: serde::de::Deserializer<'de>,
11907 {
11908 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11909 }
11910 }
11911 result.cost_per_kilometer_below_soft_max =
11912 map.next_value::<__With>()?.0;
11913 }
11914 __FieldTag::__cost_per_kilometer_above_soft_max => {
11915 if !fields.insert(__FieldTag::__cost_per_kilometer_above_soft_max) {
11916 return std::result::Result::Err(A::Error::duplicate_field(
11917 "multiple values for cost_per_kilometer_above_soft_max",
11918 ));
11919 }
11920 struct __With(std::option::Option<f64>);
11921 impl<'de> serde::de::Deserialize<'de> for __With {
11922 fn deserialize<D>(
11923 deserializer: D,
11924 ) -> std::result::Result<Self, D::Error>
11925 where
11926 D: serde::de::Deserializer<'de>,
11927 {
11928 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
11929 }
11930 }
11931 result.cost_per_kilometer_above_soft_max =
11932 map.next_value::<__With>()?.0;
11933 }
11934 __FieldTag::Unknown(key) => {
11935 let value = map.next_value::<serde_json::Value>()?;
11936 result._unknown_fields.insert(key, value);
11937 }
11938 }
11939 }
11940 std::result::Result::Ok(result)
11941 }
11942 }
11943 deserializer.deserialize_any(Visitor)
11944 }
11945}
11946
11947#[doc(hidden)]
11948impl serde::ser::Serialize for DistanceLimit {
11949 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11950 where
11951 S: serde::ser::Serializer,
11952 {
11953 use serde::ser::SerializeMap;
11954 #[allow(unused_imports)]
11955 use std::option::Option::Some;
11956 let mut state = serializer.serialize_map(std::option::Option::None)?;
11957 if self.max_meters.is_some() {
11958 struct __With<'a>(&'a std::option::Option<i64>);
11959 impl<'a> serde::ser::Serialize for __With<'a> {
11960 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11961 where
11962 S: serde::ser::Serializer,
11963 {
11964 serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
11965 self.0, serializer,
11966 )
11967 }
11968 }
11969 state.serialize_entry("maxMeters", &__With(&self.max_meters))?;
11970 }
11971 if self.soft_max_meters.is_some() {
11972 struct __With<'a>(&'a std::option::Option<i64>);
11973 impl<'a> serde::ser::Serialize for __With<'a> {
11974 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11975 where
11976 S: serde::ser::Serializer,
11977 {
11978 serde_with::As::<std::option::Option<wkt::internal::I64>>::serialize(
11979 self.0, serializer,
11980 )
11981 }
11982 }
11983 state.serialize_entry("softMaxMeters", &__With(&self.soft_max_meters))?;
11984 }
11985 if self.cost_per_kilometer_below_soft_max.is_some() {
11986 struct __With<'a>(&'a std::option::Option<f64>);
11987 impl<'a> serde::ser::Serialize for __With<'a> {
11988 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11989 where
11990 S: serde::ser::Serializer,
11991 {
11992 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
11993 self.0, serializer,
11994 )
11995 }
11996 }
11997 state.serialize_entry(
11998 "costPerKilometerBelowSoftMax",
11999 &__With(&self.cost_per_kilometer_below_soft_max),
12000 )?;
12001 }
12002 if self.cost_per_kilometer_above_soft_max.is_some() {
12003 struct __With<'a>(&'a std::option::Option<f64>);
12004 impl<'a> serde::ser::Serialize for __With<'a> {
12005 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12006 where
12007 S: serde::ser::Serializer,
12008 {
12009 serde_with::As::<std::option::Option<wkt::internal::F64>>::serialize(
12010 self.0, serializer,
12011 )
12012 }
12013 }
12014 state.serialize_entry(
12015 "costPerKilometerAboveSoftMax",
12016 &__With(&self.cost_per_kilometer_above_soft_max),
12017 )?;
12018 }
12019 if !self._unknown_fields.is_empty() {
12020 for (key, value) in self._unknown_fields.iter() {
12021 state.serialize_entry(key, &value)?;
12022 }
12023 }
12024 state.end()
12025 }
12026}
12027
12028#[derive(Clone, Debug, Default, PartialEq)]
12033#[non_exhaustive]
12034pub struct TransitionAttributes {
12035 pub src_tag: std::string::String,
12046
12047 pub excluded_src_tag: std::string::String,
12050
12051 pub dst_tag: std::string::String,
12060
12061 pub excluded_dst_tag: std::string::String,
12064
12065 pub cost: f64,
12069
12070 pub cost_per_kilometer: f64,
12077
12078 pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
12083
12084 pub delay: std::option::Option<wkt::Duration>,
12089
12090 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12091}
12092
12093impl TransitionAttributes {
12094 pub fn new() -> Self {
12095 std::default::Default::default()
12096 }
12097
12098 pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12100 self.src_tag = v.into();
12101 self
12102 }
12103
12104 pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
12106 mut self,
12107 v: T,
12108 ) -> Self {
12109 self.excluded_src_tag = v.into();
12110 self
12111 }
12112
12113 pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12115 self.dst_tag = v.into();
12116 self
12117 }
12118
12119 pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
12121 mut self,
12122 v: T,
12123 ) -> Self {
12124 self.excluded_dst_tag = v.into();
12125 self
12126 }
12127
12128 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
12130 self.cost = v.into();
12131 self
12132 }
12133
12134 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
12136 self.cost_per_kilometer = v.into();
12137 self
12138 }
12139
12140 pub fn set_distance_limit<T>(mut self, v: T) -> Self
12142 where
12143 T: std::convert::Into<crate::model::DistanceLimit>,
12144 {
12145 self.distance_limit = std::option::Option::Some(v.into());
12146 self
12147 }
12148
12149 pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
12151 where
12152 T: std::convert::Into<crate::model::DistanceLimit>,
12153 {
12154 self.distance_limit = v.map(|x| x.into());
12155 self
12156 }
12157
12158 pub fn set_delay<T>(mut self, v: T) -> Self
12160 where
12161 T: std::convert::Into<wkt::Duration>,
12162 {
12163 self.delay = std::option::Option::Some(v.into());
12164 self
12165 }
12166
12167 pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
12169 where
12170 T: std::convert::Into<wkt::Duration>,
12171 {
12172 self.delay = v.map(|x| x.into());
12173 self
12174 }
12175}
12176
12177impl wkt::message::Message for TransitionAttributes {
12178 fn typename() -> &'static str {
12179 "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
12180 }
12181}
12182
12183#[doc(hidden)]
12184impl<'de> serde::de::Deserialize<'de> for TransitionAttributes {
12185 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12186 where
12187 D: serde::Deserializer<'de>,
12188 {
12189 #[allow(non_camel_case_types)]
12190 #[doc(hidden)]
12191 #[derive(PartialEq, Eq, Hash)]
12192 enum __FieldTag {
12193 __src_tag,
12194 __excluded_src_tag,
12195 __dst_tag,
12196 __excluded_dst_tag,
12197 __cost,
12198 __cost_per_kilometer,
12199 __distance_limit,
12200 __delay,
12201 Unknown(std::string::String),
12202 }
12203 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12204 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12205 where
12206 D: serde::Deserializer<'de>,
12207 {
12208 struct Visitor;
12209 impl<'de> serde::de::Visitor<'de> for Visitor {
12210 type Value = __FieldTag;
12211 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12212 formatter.write_str("a field name for TransitionAttributes")
12213 }
12214 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12215 where
12216 E: serde::de::Error,
12217 {
12218 use std::result::Result::Ok;
12219 use std::string::ToString;
12220 match value {
12221 "srcTag" => Ok(__FieldTag::__src_tag),
12222 "src_tag" => Ok(__FieldTag::__src_tag),
12223 "excludedSrcTag" => Ok(__FieldTag::__excluded_src_tag),
12224 "excluded_src_tag" => Ok(__FieldTag::__excluded_src_tag),
12225 "dstTag" => Ok(__FieldTag::__dst_tag),
12226 "dst_tag" => Ok(__FieldTag::__dst_tag),
12227 "excludedDstTag" => Ok(__FieldTag::__excluded_dst_tag),
12228 "excluded_dst_tag" => Ok(__FieldTag::__excluded_dst_tag),
12229 "cost" => Ok(__FieldTag::__cost),
12230 "costPerKilometer" => Ok(__FieldTag::__cost_per_kilometer),
12231 "cost_per_kilometer" => Ok(__FieldTag::__cost_per_kilometer),
12232 "distanceLimit" => Ok(__FieldTag::__distance_limit),
12233 "distance_limit" => Ok(__FieldTag::__distance_limit),
12234 "delay" => Ok(__FieldTag::__delay),
12235 _ => Ok(__FieldTag::Unknown(value.to_string())),
12236 }
12237 }
12238 }
12239 deserializer.deserialize_identifier(Visitor)
12240 }
12241 }
12242 struct Visitor;
12243 impl<'de> serde::de::Visitor<'de> for Visitor {
12244 type Value = TransitionAttributes;
12245 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12246 formatter.write_str("struct TransitionAttributes")
12247 }
12248 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12249 where
12250 A: serde::de::MapAccess<'de>,
12251 {
12252 #[allow(unused_imports)]
12253 use serde::de::Error;
12254 use std::option::Option::Some;
12255 let mut fields = std::collections::HashSet::new();
12256 let mut result = Self::Value::new();
12257 while let Some(tag) = map.next_key::<__FieldTag>()? {
12258 #[allow(clippy::match_single_binding)]
12259 match tag {
12260 __FieldTag::__src_tag => {
12261 if !fields.insert(__FieldTag::__src_tag) {
12262 return std::result::Result::Err(A::Error::duplicate_field(
12263 "multiple values for src_tag",
12264 ));
12265 }
12266 result.src_tag = map
12267 .next_value::<std::option::Option<std::string::String>>()?
12268 .unwrap_or_default();
12269 }
12270 __FieldTag::__excluded_src_tag => {
12271 if !fields.insert(__FieldTag::__excluded_src_tag) {
12272 return std::result::Result::Err(A::Error::duplicate_field(
12273 "multiple values for excluded_src_tag",
12274 ));
12275 }
12276 result.excluded_src_tag = map
12277 .next_value::<std::option::Option<std::string::String>>()?
12278 .unwrap_or_default();
12279 }
12280 __FieldTag::__dst_tag => {
12281 if !fields.insert(__FieldTag::__dst_tag) {
12282 return std::result::Result::Err(A::Error::duplicate_field(
12283 "multiple values for dst_tag",
12284 ));
12285 }
12286 result.dst_tag = map
12287 .next_value::<std::option::Option<std::string::String>>()?
12288 .unwrap_or_default();
12289 }
12290 __FieldTag::__excluded_dst_tag => {
12291 if !fields.insert(__FieldTag::__excluded_dst_tag) {
12292 return std::result::Result::Err(A::Error::duplicate_field(
12293 "multiple values for excluded_dst_tag",
12294 ));
12295 }
12296 result.excluded_dst_tag = map
12297 .next_value::<std::option::Option<std::string::String>>()?
12298 .unwrap_or_default();
12299 }
12300 __FieldTag::__cost => {
12301 if !fields.insert(__FieldTag::__cost) {
12302 return std::result::Result::Err(A::Error::duplicate_field(
12303 "multiple values for cost",
12304 ));
12305 }
12306 struct __With(std::option::Option<f64>);
12307 impl<'de> serde::de::Deserialize<'de> for __With {
12308 fn deserialize<D>(
12309 deserializer: D,
12310 ) -> std::result::Result<Self, D::Error>
12311 where
12312 D: serde::de::Deserializer<'de>,
12313 {
12314 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
12315 }
12316 }
12317 result.cost = map.next_value::<__With>()?.0.unwrap_or_default();
12318 }
12319 __FieldTag::__cost_per_kilometer => {
12320 if !fields.insert(__FieldTag::__cost_per_kilometer) {
12321 return std::result::Result::Err(A::Error::duplicate_field(
12322 "multiple values for cost_per_kilometer",
12323 ));
12324 }
12325 struct __With(std::option::Option<f64>);
12326 impl<'de> serde::de::Deserialize<'de> for __With {
12327 fn deserialize<D>(
12328 deserializer: D,
12329 ) -> std::result::Result<Self, D::Error>
12330 where
12331 D: serde::de::Deserializer<'de>,
12332 {
12333 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
12334 }
12335 }
12336 result.cost_per_kilometer =
12337 map.next_value::<__With>()?.0.unwrap_or_default();
12338 }
12339 __FieldTag::__distance_limit => {
12340 if !fields.insert(__FieldTag::__distance_limit) {
12341 return std::result::Result::Err(A::Error::duplicate_field(
12342 "multiple values for distance_limit",
12343 ));
12344 }
12345 result.distance_limit = map
12346 .next_value::<std::option::Option<crate::model::DistanceLimit>>()?;
12347 }
12348 __FieldTag::__delay => {
12349 if !fields.insert(__FieldTag::__delay) {
12350 return std::result::Result::Err(A::Error::duplicate_field(
12351 "multiple values for delay",
12352 ));
12353 }
12354 result.delay =
12355 map.next_value::<std::option::Option<wkt::Duration>>()?;
12356 }
12357 __FieldTag::Unknown(key) => {
12358 let value = map.next_value::<serde_json::Value>()?;
12359 result._unknown_fields.insert(key, value);
12360 }
12361 }
12362 }
12363 std::result::Result::Ok(result)
12364 }
12365 }
12366 deserializer.deserialize_any(Visitor)
12367 }
12368}
12369
12370#[doc(hidden)]
12371impl serde::ser::Serialize for TransitionAttributes {
12372 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12373 where
12374 S: serde::ser::Serializer,
12375 {
12376 use serde::ser::SerializeMap;
12377 #[allow(unused_imports)]
12378 use std::option::Option::Some;
12379 let mut state = serializer.serialize_map(std::option::Option::None)?;
12380 if !self.src_tag.is_empty() {
12381 state.serialize_entry("srcTag", &self.src_tag)?;
12382 }
12383 if !self.excluded_src_tag.is_empty() {
12384 state.serialize_entry("excludedSrcTag", &self.excluded_src_tag)?;
12385 }
12386 if !self.dst_tag.is_empty() {
12387 state.serialize_entry("dstTag", &self.dst_tag)?;
12388 }
12389 if !self.excluded_dst_tag.is_empty() {
12390 state.serialize_entry("excludedDstTag", &self.excluded_dst_tag)?;
12391 }
12392 if !wkt::internal::is_default(&self.cost) {
12393 struct __With<'a>(&'a f64);
12394 impl<'a> serde::ser::Serialize for __With<'a> {
12395 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12396 where
12397 S: serde::ser::Serializer,
12398 {
12399 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
12400 }
12401 }
12402 state.serialize_entry("cost", &__With(&self.cost))?;
12403 }
12404 if !wkt::internal::is_default(&self.cost_per_kilometer) {
12405 struct __With<'a>(&'a f64);
12406 impl<'a> serde::ser::Serialize for __With<'a> {
12407 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12408 where
12409 S: serde::ser::Serializer,
12410 {
12411 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
12412 }
12413 }
12414 state.serialize_entry("costPerKilometer", &__With(&self.cost_per_kilometer))?;
12415 }
12416 if self.distance_limit.is_some() {
12417 state.serialize_entry("distanceLimit", &self.distance_limit)?;
12418 }
12419 if self.delay.is_some() {
12420 state.serialize_entry("delay", &self.delay)?;
12421 }
12422 if !self._unknown_fields.is_empty() {
12423 for (key, value) in self._unknown_fields.iter() {
12424 state.serialize_entry(key, &value)?;
12425 }
12426 }
12427 state.end()
12428 }
12429}
12430
12431#[derive(Clone, Debug, Default, PartialEq)]
12434#[non_exhaustive]
12435pub struct Waypoint {
12436 pub side_of_road: bool,
12443
12444 pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
12446
12447 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12448}
12449
12450impl Waypoint {
12451 pub fn new() -> Self {
12452 std::default::Default::default()
12453 }
12454
12455 pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
12457 self.side_of_road = v.into();
12458 self
12459 }
12460
12461 pub fn set_location_type<
12466 T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
12467 >(
12468 mut self,
12469 v: T,
12470 ) -> Self {
12471 self.location_type = v.into();
12472 self
12473 }
12474
12475 pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
12479 #[allow(unreachable_patterns)]
12480 self.location_type.as_ref().and_then(|v| match v {
12481 crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
12482 _ => std::option::Option::None,
12483 })
12484 }
12485
12486 pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
12492 mut self,
12493 v: T,
12494 ) -> Self {
12495 self.location_type =
12496 std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
12497 self
12498 }
12499
12500 pub fn place_id(&self) -> std::option::Option<&std::string::String> {
12504 #[allow(unreachable_patterns)]
12505 self.location_type.as_ref().and_then(|v| match v {
12506 crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
12507 _ => std::option::Option::None,
12508 })
12509 }
12510
12511 pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
12517 self.location_type =
12518 std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
12519 self
12520 }
12521}
12522
12523impl wkt::message::Message for Waypoint {
12524 fn typename() -> &'static str {
12525 "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
12526 }
12527}
12528
12529#[doc(hidden)]
12530impl<'de> serde::de::Deserialize<'de> for Waypoint {
12531 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12532 where
12533 D: serde::Deserializer<'de>,
12534 {
12535 #[allow(non_camel_case_types)]
12536 #[doc(hidden)]
12537 #[derive(PartialEq, Eq, Hash)]
12538 enum __FieldTag {
12539 __location,
12540 __place_id,
12541 __side_of_road,
12542 Unknown(std::string::String),
12543 }
12544 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12545 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12546 where
12547 D: serde::Deserializer<'de>,
12548 {
12549 struct Visitor;
12550 impl<'de> serde::de::Visitor<'de> for Visitor {
12551 type Value = __FieldTag;
12552 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12553 formatter.write_str("a field name for Waypoint")
12554 }
12555 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12556 where
12557 E: serde::de::Error,
12558 {
12559 use std::result::Result::Ok;
12560 use std::string::ToString;
12561 match value {
12562 "location" => Ok(__FieldTag::__location),
12563 "placeId" => Ok(__FieldTag::__place_id),
12564 "place_id" => Ok(__FieldTag::__place_id),
12565 "sideOfRoad" => Ok(__FieldTag::__side_of_road),
12566 "side_of_road" => Ok(__FieldTag::__side_of_road),
12567 _ => Ok(__FieldTag::Unknown(value.to_string())),
12568 }
12569 }
12570 }
12571 deserializer.deserialize_identifier(Visitor)
12572 }
12573 }
12574 struct Visitor;
12575 impl<'de> serde::de::Visitor<'de> for Visitor {
12576 type Value = Waypoint;
12577 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12578 formatter.write_str("struct Waypoint")
12579 }
12580 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12581 where
12582 A: serde::de::MapAccess<'de>,
12583 {
12584 #[allow(unused_imports)]
12585 use serde::de::Error;
12586 use std::option::Option::Some;
12587 let mut fields = std::collections::HashSet::new();
12588 let mut result = Self::Value::new();
12589 while let Some(tag) = map.next_key::<__FieldTag>()? {
12590 #[allow(clippy::match_single_binding)]
12591 match tag {
12592 __FieldTag::__location => {
12593 if !fields.insert(__FieldTag::__location) {
12594 return std::result::Result::Err(A::Error::duplicate_field(
12595 "multiple values for location",
12596 ));
12597 }
12598 if result.location_type.is_some() {
12599 return std::result::Result::Err(A::Error::duplicate_field(
12600 "multiple values for `location_type`, a oneof with full ID .google.cloud.optimization.v1.Waypoint.location, latest field was location",
12601 ));
12602 }
12603 result.location_type = std::option::Option::Some(
12604 crate::model::waypoint::LocationType::Location(
12605 map.next_value::<std::option::Option<
12606 std::boxed::Box<crate::model::Location>,
12607 >>()?
12608 .unwrap_or_default(),
12609 ),
12610 );
12611 }
12612 __FieldTag::__place_id => {
12613 if !fields.insert(__FieldTag::__place_id) {
12614 return std::result::Result::Err(A::Error::duplicate_field(
12615 "multiple values for place_id",
12616 ));
12617 }
12618 if result.location_type.is_some() {
12619 return std::result::Result::Err(A::Error::duplicate_field(
12620 "multiple values for `location_type`, a oneof with full ID .google.cloud.optimization.v1.Waypoint.place_id, latest field was placeId",
12621 ));
12622 }
12623 result.location_type = std::option::Option::Some(
12624 crate::model::waypoint::LocationType::PlaceId(
12625 map.next_value::<std::option::Option<std::string::String>>()?
12626 .unwrap_or_default(),
12627 ),
12628 );
12629 }
12630 __FieldTag::__side_of_road => {
12631 if !fields.insert(__FieldTag::__side_of_road) {
12632 return std::result::Result::Err(A::Error::duplicate_field(
12633 "multiple values for side_of_road",
12634 ));
12635 }
12636 result.side_of_road = map
12637 .next_value::<std::option::Option<bool>>()?
12638 .unwrap_or_default();
12639 }
12640 __FieldTag::Unknown(key) => {
12641 let value = map.next_value::<serde_json::Value>()?;
12642 result._unknown_fields.insert(key, value);
12643 }
12644 }
12645 }
12646 std::result::Result::Ok(result)
12647 }
12648 }
12649 deserializer.deserialize_any(Visitor)
12650 }
12651}
12652
12653#[doc(hidden)]
12654impl serde::ser::Serialize for Waypoint {
12655 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12656 where
12657 S: serde::ser::Serializer,
12658 {
12659 use serde::ser::SerializeMap;
12660 #[allow(unused_imports)]
12661 use std::option::Option::Some;
12662 let mut state = serializer.serialize_map(std::option::Option::None)?;
12663 if let Some(value) = self.location() {
12664 state.serialize_entry("location", value)?;
12665 }
12666 if let Some(value) = self.place_id() {
12667 state.serialize_entry("placeId", value)?;
12668 }
12669 if !wkt::internal::is_default(&self.side_of_road) {
12670 state.serialize_entry("sideOfRoad", &self.side_of_road)?;
12671 }
12672 if !self._unknown_fields.is_empty() {
12673 for (key, value) in self._unknown_fields.iter() {
12674 state.serialize_entry(key, &value)?;
12675 }
12676 }
12677 state.end()
12678 }
12679}
12680
12681pub mod waypoint {
12683 #[allow(unused_imports)]
12684 use super::*;
12685
12686 #[derive(Clone, Debug, PartialEq)]
12688 #[non_exhaustive]
12689 pub enum LocationType {
12690 Location(std::boxed::Box<crate::model::Location>),
12693 PlaceId(std::string::String),
12695 }
12696}
12697
12698#[derive(Clone, Debug, Default, PartialEq)]
12700#[non_exhaustive]
12701pub struct Location {
12702 pub lat_lng: std::option::Option<gtype::model::LatLng>,
12704
12705 pub heading: std::option::Option<i32>,
12710
12711 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12712}
12713
12714impl Location {
12715 pub fn new() -> Self {
12716 std::default::Default::default()
12717 }
12718
12719 pub fn set_lat_lng<T>(mut self, v: T) -> Self
12721 where
12722 T: std::convert::Into<gtype::model::LatLng>,
12723 {
12724 self.lat_lng = std::option::Option::Some(v.into());
12725 self
12726 }
12727
12728 pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
12730 where
12731 T: std::convert::Into<gtype::model::LatLng>,
12732 {
12733 self.lat_lng = v.map(|x| x.into());
12734 self
12735 }
12736
12737 pub fn set_heading<T>(mut self, v: T) -> Self
12739 where
12740 T: std::convert::Into<i32>,
12741 {
12742 self.heading = std::option::Option::Some(v.into());
12743 self
12744 }
12745
12746 pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
12748 where
12749 T: std::convert::Into<i32>,
12750 {
12751 self.heading = v.map(|x| x.into());
12752 self
12753 }
12754}
12755
12756impl wkt::message::Message for Location {
12757 fn typename() -> &'static str {
12758 "type.googleapis.com/google.cloud.optimization.v1.Location"
12759 }
12760}
12761
12762#[doc(hidden)]
12763impl<'de> serde::de::Deserialize<'de> for Location {
12764 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12765 where
12766 D: serde::Deserializer<'de>,
12767 {
12768 #[allow(non_camel_case_types)]
12769 #[doc(hidden)]
12770 #[derive(PartialEq, Eq, Hash)]
12771 enum __FieldTag {
12772 __lat_lng,
12773 __heading,
12774 Unknown(std::string::String),
12775 }
12776 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12777 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12778 where
12779 D: serde::Deserializer<'de>,
12780 {
12781 struct Visitor;
12782 impl<'de> serde::de::Visitor<'de> for Visitor {
12783 type Value = __FieldTag;
12784 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12785 formatter.write_str("a field name for Location")
12786 }
12787 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12788 where
12789 E: serde::de::Error,
12790 {
12791 use std::result::Result::Ok;
12792 use std::string::ToString;
12793 match value {
12794 "latLng" => Ok(__FieldTag::__lat_lng),
12795 "lat_lng" => Ok(__FieldTag::__lat_lng),
12796 "heading" => Ok(__FieldTag::__heading),
12797 _ => Ok(__FieldTag::Unknown(value.to_string())),
12798 }
12799 }
12800 }
12801 deserializer.deserialize_identifier(Visitor)
12802 }
12803 }
12804 struct Visitor;
12805 impl<'de> serde::de::Visitor<'de> for Visitor {
12806 type Value = Location;
12807 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12808 formatter.write_str("struct Location")
12809 }
12810 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
12811 where
12812 A: serde::de::MapAccess<'de>,
12813 {
12814 #[allow(unused_imports)]
12815 use serde::de::Error;
12816 use std::option::Option::Some;
12817 let mut fields = std::collections::HashSet::new();
12818 let mut result = Self::Value::new();
12819 while let Some(tag) = map.next_key::<__FieldTag>()? {
12820 #[allow(clippy::match_single_binding)]
12821 match tag {
12822 __FieldTag::__lat_lng => {
12823 if !fields.insert(__FieldTag::__lat_lng) {
12824 return std::result::Result::Err(A::Error::duplicate_field(
12825 "multiple values for lat_lng",
12826 ));
12827 }
12828 result.lat_lng =
12829 map.next_value::<std::option::Option<gtype::model::LatLng>>()?;
12830 }
12831 __FieldTag::__heading => {
12832 if !fields.insert(__FieldTag::__heading) {
12833 return std::result::Result::Err(A::Error::duplicate_field(
12834 "multiple values for heading",
12835 ));
12836 }
12837 struct __With(std::option::Option<i32>);
12838 impl<'de> serde::de::Deserialize<'de> for __With {
12839 fn deserialize<D>(
12840 deserializer: D,
12841 ) -> std::result::Result<Self, D::Error>
12842 where
12843 D: serde::de::Deserializer<'de>,
12844 {
12845 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
12846 }
12847 }
12848 result.heading = map.next_value::<__With>()?.0;
12849 }
12850 __FieldTag::Unknown(key) => {
12851 let value = map.next_value::<serde_json::Value>()?;
12852 result._unknown_fields.insert(key, value);
12853 }
12854 }
12855 }
12856 std::result::Result::Ok(result)
12857 }
12858 }
12859 deserializer.deserialize_any(Visitor)
12860 }
12861}
12862
12863#[doc(hidden)]
12864impl serde::ser::Serialize for Location {
12865 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12866 where
12867 S: serde::ser::Serializer,
12868 {
12869 use serde::ser::SerializeMap;
12870 #[allow(unused_imports)]
12871 use std::option::Option::Some;
12872 let mut state = serializer.serialize_map(std::option::Option::None)?;
12873 if self.lat_lng.is_some() {
12874 state.serialize_entry("latLng", &self.lat_lng)?;
12875 }
12876 if self.heading.is_some() {
12877 struct __With<'a>(&'a std::option::Option<i32>);
12878 impl<'a> serde::ser::Serialize for __With<'a> {
12879 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
12880 where
12881 S: serde::ser::Serializer,
12882 {
12883 serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
12884 self.0, serializer,
12885 )
12886 }
12887 }
12888 state.serialize_entry("heading", &__With(&self.heading))?;
12889 }
12890 if !self._unknown_fields.is_empty() {
12891 for (key, value) in self._unknown_fields.iter() {
12892 state.serialize_entry(key, &value)?;
12893 }
12894 }
12895 state.end()
12896 }
12897}
12898
12899#[derive(Clone, Debug, Default, PartialEq)]
12910#[non_exhaustive]
12911pub struct BreakRule {
12912 pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
12914
12915 pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
12918
12919 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
12920}
12921
12922impl BreakRule {
12923 pub fn new() -> Self {
12924 std::default::Default::default()
12925 }
12926
12927 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
12929 where
12930 T: std::iter::IntoIterator<Item = V>,
12931 V: std::convert::Into<crate::model::break_rule::BreakRequest>,
12932 {
12933 use std::iter::Iterator;
12934 self.break_requests = v.into_iter().map(|i| i.into()).collect();
12935 self
12936 }
12937
12938 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
12940 where
12941 T: std::iter::IntoIterator<Item = V>,
12942 V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
12943 {
12944 use std::iter::Iterator;
12945 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
12946 self
12947 }
12948}
12949
12950impl wkt::message::Message for BreakRule {
12951 fn typename() -> &'static str {
12952 "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
12953 }
12954}
12955
12956#[doc(hidden)]
12957impl<'de> serde::de::Deserialize<'de> for BreakRule {
12958 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12959 where
12960 D: serde::Deserializer<'de>,
12961 {
12962 #[allow(non_camel_case_types)]
12963 #[doc(hidden)]
12964 #[derive(PartialEq, Eq, Hash)]
12965 enum __FieldTag {
12966 __break_requests,
12967 __frequency_constraints,
12968 Unknown(std::string::String),
12969 }
12970 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
12971 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
12972 where
12973 D: serde::Deserializer<'de>,
12974 {
12975 struct Visitor;
12976 impl<'de> serde::de::Visitor<'de> for Visitor {
12977 type Value = __FieldTag;
12978 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
12979 formatter.write_str("a field name for BreakRule")
12980 }
12981 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
12982 where
12983 E: serde::de::Error,
12984 {
12985 use std::result::Result::Ok;
12986 use std::string::ToString;
12987 match value {
12988 "breakRequests" => Ok(__FieldTag::__break_requests),
12989 "break_requests" => Ok(__FieldTag::__break_requests),
12990 "frequencyConstraints" => Ok(__FieldTag::__frequency_constraints),
12991 "frequency_constraints" => Ok(__FieldTag::__frequency_constraints),
12992 _ => Ok(__FieldTag::Unknown(value.to_string())),
12993 }
12994 }
12995 }
12996 deserializer.deserialize_identifier(Visitor)
12997 }
12998 }
12999 struct Visitor;
13000 impl<'de> serde::de::Visitor<'de> for Visitor {
13001 type Value = BreakRule;
13002 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13003 formatter.write_str("struct BreakRule")
13004 }
13005 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13006 where
13007 A: serde::de::MapAccess<'de>,
13008 {
13009 #[allow(unused_imports)]
13010 use serde::de::Error;
13011 use std::option::Option::Some;
13012 let mut fields = std::collections::HashSet::new();
13013 let mut result = Self::Value::new();
13014 while let Some(tag) = map.next_key::<__FieldTag>()? {
13015 #[allow(clippy::match_single_binding)]
13016 match tag {
13017 __FieldTag::__break_requests => {
13018 if !fields.insert(__FieldTag::__break_requests) {
13019 return std::result::Result::Err(A::Error::duplicate_field(
13020 "multiple values for break_requests",
13021 ));
13022 }
13023 result.break_requests = map
13024 .next_value::<std::option::Option<
13025 std::vec::Vec<crate::model::break_rule::BreakRequest>,
13026 >>()?
13027 .unwrap_or_default();
13028 }
13029 __FieldTag::__frequency_constraints => {
13030 if !fields.insert(__FieldTag::__frequency_constraints) {
13031 return std::result::Result::Err(A::Error::duplicate_field(
13032 "multiple values for frequency_constraints",
13033 ));
13034 }
13035 result.frequency_constraints = map
13036 .next_value::<std::option::Option<
13037 std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
13038 >>()?
13039 .unwrap_or_default();
13040 }
13041 __FieldTag::Unknown(key) => {
13042 let value = map.next_value::<serde_json::Value>()?;
13043 result._unknown_fields.insert(key, value);
13044 }
13045 }
13046 }
13047 std::result::Result::Ok(result)
13048 }
13049 }
13050 deserializer.deserialize_any(Visitor)
13051 }
13052}
13053
13054#[doc(hidden)]
13055impl serde::ser::Serialize for BreakRule {
13056 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13057 where
13058 S: serde::ser::Serializer,
13059 {
13060 use serde::ser::SerializeMap;
13061 #[allow(unused_imports)]
13062 use std::option::Option::Some;
13063 let mut state = serializer.serialize_map(std::option::Option::None)?;
13064 if !self.break_requests.is_empty() {
13065 state.serialize_entry("breakRequests", &self.break_requests)?;
13066 }
13067 if !self.frequency_constraints.is_empty() {
13068 state.serialize_entry("frequencyConstraints", &self.frequency_constraints)?;
13069 }
13070 if !self._unknown_fields.is_empty() {
13071 for (key, value) in self._unknown_fields.iter() {
13072 state.serialize_entry(key, &value)?;
13073 }
13074 }
13075 state.end()
13076 }
13077}
13078
13079pub mod break_rule {
13081 #[allow(unused_imports)]
13082 use super::*;
13083
13084 #[derive(Clone, Debug, Default, PartialEq)]
13090 #[non_exhaustive]
13091 pub struct BreakRequest {
13092 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
13094
13095 pub latest_start_time: std::option::Option<wkt::Timestamp>,
13097
13098 pub min_duration: std::option::Option<wkt::Duration>,
13100
13101 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13102 }
13103
13104 impl BreakRequest {
13105 pub fn new() -> Self {
13106 std::default::Default::default()
13107 }
13108
13109 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
13111 where
13112 T: std::convert::Into<wkt::Timestamp>,
13113 {
13114 self.earliest_start_time = std::option::Option::Some(v.into());
13115 self
13116 }
13117
13118 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
13120 where
13121 T: std::convert::Into<wkt::Timestamp>,
13122 {
13123 self.earliest_start_time = v.map(|x| x.into());
13124 self
13125 }
13126
13127 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
13129 where
13130 T: std::convert::Into<wkt::Timestamp>,
13131 {
13132 self.latest_start_time = std::option::Option::Some(v.into());
13133 self
13134 }
13135
13136 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
13138 where
13139 T: std::convert::Into<wkt::Timestamp>,
13140 {
13141 self.latest_start_time = v.map(|x| x.into());
13142 self
13143 }
13144
13145 pub fn set_min_duration<T>(mut self, v: T) -> Self
13147 where
13148 T: std::convert::Into<wkt::Duration>,
13149 {
13150 self.min_duration = std::option::Option::Some(v.into());
13151 self
13152 }
13153
13154 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
13156 where
13157 T: std::convert::Into<wkt::Duration>,
13158 {
13159 self.min_duration = v.map(|x| x.into());
13160 self
13161 }
13162 }
13163
13164 impl wkt::message::Message for BreakRequest {
13165 fn typename() -> &'static str {
13166 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
13167 }
13168 }
13169
13170 #[doc(hidden)]
13171 impl<'de> serde::de::Deserialize<'de> for BreakRequest {
13172 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13173 where
13174 D: serde::Deserializer<'de>,
13175 {
13176 #[allow(non_camel_case_types)]
13177 #[doc(hidden)]
13178 #[derive(PartialEq, Eq, Hash)]
13179 enum __FieldTag {
13180 __earliest_start_time,
13181 __latest_start_time,
13182 __min_duration,
13183 Unknown(std::string::String),
13184 }
13185 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13186 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13187 where
13188 D: serde::Deserializer<'de>,
13189 {
13190 struct Visitor;
13191 impl<'de> serde::de::Visitor<'de> for Visitor {
13192 type Value = __FieldTag;
13193 fn expecting(
13194 &self,
13195 formatter: &mut std::fmt::Formatter,
13196 ) -> std::fmt::Result {
13197 formatter.write_str("a field name for BreakRequest")
13198 }
13199 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13200 where
13201 E: serde::de::Error,
13202 {
13203 use std::result::Result::Ok;
13204 use std::string::ToString;
13205 match value {
13206 "earliestStartTime" => Ok(__FieldTag::__earliest_start_time),
13207 "earliest_start_time" => Ok(__FieldTag::__earliest_start_time),
13208 "latestStartTime" => Ok(__FieldTag::__latest_start_time),
13209 "latest_start_time" => Ok(__FieldTag::__latest_start_time),
13210 "minDuration" => Ok(__FieldTag::__min_duration),
13211 "min_duration" => Ok(__FieldTag::__min_duration),
13212 _ => Ok(__FieldTag::Unknown(value.to_string())),
13213 }
13214 }
13215 }
13216 deserializer.deserialize_identifier(Visitor)
13217 }
13218 }
13219 struct Visitor;
13220 impl<'de> serde::de::Visitor<'de> for Visitor {
13221 type Value = BreakRequest;
13222 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13223 formatter.write_str("struct BreakRequest")
13224 }
13225 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13226 where
13227 A: serde::de::MapAccess<'de>,
13228 {
13229 #[allow(unused_imports)]
13230 use serde::de::Error;
13231 use std::option::Option::Some;
13232 let mut fields = std::collections::HashSet::new();
13233 let mut result = Self::Value::new();
13234 while let Some(tag) = map.next_key::<__FieldTag>()? {
13235 #[allow(clippy::match_single_binding)]
13236 match tag {
13237 __FieldTag::__earliest_start_time => {
13238 if !fields.insert(__FieldTag::__earliest_start_time) {
13239 return std::result::Result::Err(A::Error::duplicate_field(
13240 "multiple values for earliest_start_time",
13241 ));
13242 }
13243 result.earliest_start_time =
13244 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
13245 }
13246 __FieldTag::__latest_start_time => {
13247 if !fields.insert(__FieldTag::__latest_start_time) {
13248 return std::result::Result::Err(A::Error::duplicate_field(
13249 "multiple values for latest_start_time",
13250 ));
13251 }
13252 result.latest_start_time =
13253 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
13254 }
13255 __FieldTag::__min_duration => {
13256 if !fields.insert(__FieldTag::__min_duration) {
13257 return std::result::Result::Err(A::Error::duplicate_field(
13258 "multiple values for min_duration",
13259 ));
13260 }
13261 result.min_duration =
13262 map.next_value::<std::option::Option<wkt::Duration>>()?;
13263 }
13264 __FieldTag::Unknown(key) => {
13265 let value = map.next_value::<serde_json::Value>()?;
13266 result._unknown_fields.insert(key, value);
13267 }
13268 }
13269 }
13270 std::result::Result::Ok(result)
13271 }
13272 }
13273 deserializer.deserialize_any(Visitor)
13274 }
13275 }
13276
13277 #[doc(hidden)]
13278 impl serde::ser::Serialize for BreakRequest {
13279 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13280 where
13281 S: serde::ser::Serializer,
13282 {
13283 use serde::ser::SerializeMap;
13284 #[allow(unused_imports)]
13285 use std::option::Option::Some;
13286 let mut state = serializer.serialize_map(std::option::Option::None)?;
13287 if self.earliest_start_time.is_some() {
13288 state.serialize_entry("earliestStartTime", &self.earliest_start_time)?;
13289 }
13290 if self.latest_start_time.is_some() {
13291 state.serialize_entry("latestStartTime", &self.latest_start_time)?;
13292 }
13293 if self.min_duration.is_some() {
13294 state.serialize_entry("minDuration", &self.min_duration)?;
13295 }
13296 if !self._unknown_fields.is_empty() {
13297 for (key, value) in self._unknown_fields.iter() {
13298 state.serialize_entry(key, &value)?;
13299 }
13300 }
13301 state.end()
13302 }
13303 }
13304
13305 #[derive(Clone, Debug, Default, PartialEq)]
13341 #[non_exhaustive]
13342 pub struct FrequencyConstraint {
13343 pub min_break_duration: std::option::Option<wkt::Duration>,
13346
13347 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
13351
13352 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13353 }
13354
13355 impl FrequencyConstraint {
13356 pub fn new() -> Self {
13357 std::default::Default::default()
13358 }
13359
13360 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
13362 where
13363 T: std::convert::Into<wkt::Duration>,
13364 {
13365 self.min_break_duration = std::option::Option::Some(v.into());
13366 self
13367 }
13368
13369 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
13371 where
13372 T: std::convert::Into<wkt::Duration>,
13373 {
13374 self.min_break_duration = v.map(|x| x.into());
13375 self
13376 }
13377
13378 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
13380 where
13381 T: std::convert::Into<wkt::Duration>,
13382 {
13383 self.max_inter_break_duration = std::option::Option::Some(v.into());
13384 self
13385 }
13386
13387 pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
13389 where
13390 T: std::convert::Into<wkt::Duration>,
13391 {
13392 self.max_inter_break_duration = v.map(|x| x.into());
13393 self
13394 }
13395 }
13396
13397 impl wkt::message::Message for FrequencyConstraint {
13398 fn typename() -> &'static str {
13399 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
13400 }
13401 }
13402
13403 #[doc(hidden)]
13404 impl<'de> serde::de::Deserialize<'de> for FrequencyConstraint {
13405 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13406 where
13407 D: serde::Deserializer<'de>,
13408 {
13409 #[allow(non_camel_case_types)]
13410 #[doc(hidden)]
13411 #[derive(PartialEq, Eq, Hash)]
13412 enum __FieldTag {
13413 __min_break_duration,
13414 __max_inter_break_duration,
13415 Unknown(std::string::String),
13416 }
13417 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13418 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13419 where
13420 D: serde::Deserializer<'de>,
13421 {
13422 struct Visitor;
13423 impl<'de> serde::de::Visitor<'de> for Visitor {
13424 type Value = __FieldTag;
13425 fn expecting(
13426 &self,
13427 formatter: &mut std::fmt::Formatter,
13428 ) -> std::fmt::Result {
13429 formatter.write_str("a field name for FrequencyConstraint")
13430 }
13431 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
13432 where
13433 E: serde::de::Error,
13434 {
13435 use std::result::Result::Ok;
13436 use std::string::ToString;
13437 match value {
13438 "minBreakDuration" => Ok(__FieldTag::__min_break_duration),
13439 "min_break_duration" => Ok(__FieldTag::__min_break_duration),
13440 "maxInterBreakDuration" => {
13441 Ok(__FieldTag::__max_inter_break_duration)
13442 }
13443 "max_inter_break_duration" => {
13444 Ok(__FieldTag::__max_inter_break_duration)
13445 }
13446 _ => Ok(__FieldTag::Unknown(value.to_string())),
13447 }
13448 }
13449 }
13450 deserializer.deserialize_identifier(Visitor)
13451 }
13452 }
13453 struct Visitor;
13454 impl<'de> serde::de::Visitor<'de> for Visitor {
13455 type Value = FrequencyConstraint;
13456 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
13457 formatter.write_str("struct FrequencyConstraint")
13458 }
13459 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
13460 where
13461 A: serde::de::MapAccess<'de>,
13462 {
13463 #[allow(unused_imports)]
13464 use serde::de::Error;
13465 use std::option::Option::Some;
13466 let mut fields = std::collections::HashSet::new();
13467 let mut result = Self::Value::new();
13468 while let Some(tag) = map.next_key::<__FieldTag>()? {
13469 #[allow(clippy::match_single_binding)]
13470 match tag {
13471 __FieldTag::__min_break_duration => {
13472 if !fields.insert(__FieldTag::__min_break_duration) {
13473 return std::result::Result::Err(A::Error::duplicate_field(
13474 "multiple values for min_break_duration",
13475 ));
13476 }
13477 result.min_break_duration =
13478 map.next_value::<std::option::Option<wkt::Duration>>()?;
13479 }
13480 __FieldTag::__max_inter_break_duration => {
13481 if !fields.insert(__FieldTag::__max_inter_break_duration) {
13482 return std::result::Result::Err(A::Error::duplicate_field(
13483 "multiple values for max_inter_break_duration",
13484 ));
13485 }
13486 result.max_inter_break_duration =
13487 map.next_value::<std::option::Option<wkt::Duration>>()?;
13488 }
13489 __FieldTag::Unknown(key) => {
13490 let value = map.next_value::<serde_json::Value>()?;
13491 result._unknown_fields.insert(key, value);
13492 }
13493 }
13494 }
13495 std::result::Result::Ok(result)
13496 }
13497 }
13498 deserializer.deserialize_any(Visitor)
13499 }
13500 }
13501
13502 #[doc(hidden)]
13503 impl serde::ser::Serialize for FrequencyConstraint {
13504 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
13505 where
13506 S: serde::ser::Serializer,
13507 {
13508 use serde::ser::SerializeMap;
13509 #[allow(unused_imports)]
13510 use std::option::Option::Some;
13511 let mut state = serializer.serialize_map(std::option::Option::None)?;
13512 if self.min_break_duration.is_some() {
13513 state.serialize_entry("minBreakDuration", &self.min_break_duration)?;
13514 }
13515 if self.max_inter_break_duration.is_some() {
13516 state.serialize_entry("maxInterBreakDuration", &self.max_inter_break_duration)?;
13517 }
13518 if !self._unknown_fields.is_empty() {
13519 for (key, value) in self._unknown_fields.iter() {
13520 state.serialize_entry(key, &value)?;
13521 }
13522 }
13523 state.end()
13524 }
13525 }
13526}
13527
13528#[derive(Clone, Debug, Default, PartialEq)]
13618#[non_exhaustive]
13619pub struct ShipmentRoute {
13620 pub vehicle_index: i32,
13623
13624 pub vehicle_label: std::string::String,
13627
13628 pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
13630
13631 pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
13633
13634 pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
13638
13639 pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
13641
13642 pub has_traffic_infeasibilities: bool,
13663
13664 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
13671
13672 pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
13676
13677 pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
13689
13690 pub route_costs: std::collections::HashMap<std::string::String, f64>,
13699
13700 pub route_total_cost: f64,
13702
13703 #[deprecated]
13715 pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
13716
13717 #[deprecated]
13723 pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
13724
13725 #[deprecated]
13738 pub vehicle_detour: std::option::Option<wkt::Duration>,
13739
13740 #[deprecated]
13745 pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
13746
13747 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
13748}
13749
13750impl ShipmentRoute {
13751 pub fn new() -> Self {
13752 std::default::Default::default()
13753 }
13754
13755 pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
13757 self.vehicle_index = v.into();
13758 self
13759 }
13760
13761 pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
13763 self.vehicle_label = v.into();
13764 self
13765 }
13766
13767 pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
13769 where
13770 T: std::convert::Into<wkt::Timestamp>,
13771 {
13772 self.vehicle_start_time = std::option::Option::Some(v.into());
13773 self
13774 }
13775
13776 pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
13778 where
13779 T: std::convert::Into<wkt::Timestamp>,
13780 {
13781 self.vehicle_start_time = v.map(|x| x.into());
13782 self
13783 }
13784
13785 pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
13787 where
13788 T: std::convert::Into<wkt::Timestamp>,
13789 {
13790 self.vehicle_end_time = std::option::Option::Some(v.into());
13791 self
13792 }
13793
13794 pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
13796 where
13797 T: std::convert::Into<wkt::Timestamp>,
13798 {
13799 self.vehicle_end_time = v.map(|x| x.into());
13800 self
13801 }
13802
13803 pub fn set_visits<T, V>(mut self, v: T) -> Self
13805 where
13806 T: std::iter::IntoIterator<Item = V>,
13807 V: std::convert::Into<crate::model::shipment_route::Visit>,
13808 {
13809 use std::iter::Iterator;
13810 self.visits = v.into_iter().map(|i| i.into()).collect();
13811 self
13812 }
13813
13814 pub fn set_transitions<T, V>(mut self, v: T) -> Self
13816 where
13817 T: std::iter::IntoIterator<Item = V>,
13818 V: std::convert::Into<crate::model::shipment_route::Transition>,
13819 {
13820 use std::iter::Iterator;
13821 self.transitions = v.into_iter().map(|i| i.into()).collect();
13822 self
13823 }
13824
13825 pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
13827 self.has_traffic_infeasibilities = v.into();
13828 self
13829 }
13830
13831 pub fn set_route_polyline<T>(mut self, v: T) -> Self
13833 where
13834 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
13835 {
13836 self.route_polyline = std::option::Option::Some(v.into());
13837 self
13838 }
13839
13840 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
13842 where
13843 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
13844 {
13845 self.route_polyline = v.map(|x| x.into());
13846 self
13847 }
13848
13849 pub fn set_breaks<T, V>(mut self, v: T) -> Self
13851 where
13852 T: std::iter::IntoIterator<Item = V>,
13853 V: std::convert::Into<crate::model::shipment_route::Break>,
13854 {
13855 use std::iter::Iterator;
13856 self.breaks = v.into_iter().map(|i| i.into()).collect();
13857 self
13858 }
13859
13860 pub fn set_metrics<T>(mut self, v: T) -> Self
13862 where
13863 T: std::convert::Into<crate::model::AggregatedMetrics>,
13864 {
13865 self.metrics = std::option::Option::Some(v.into());
13866 self
13867 }
13868
13869 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
13871 where
13872 T: std::convert::Into<crate::model::AggregatedMetrics>,
13873 {
13874 self.metrics = v.map(|x| x.into());
13875 self
13876 }
13877
13878 pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
13880 where
13881 T: std::iter::IntoIterator<Item = (K, V)>,
13882 K: std::convert::Into<std::string::String>,
13883 V: std::convert::Into<f64>,
13884 {
13885 use std::iter::Iterator;
13886 self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
13887 self
13888 }
13889
13890 pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
13892 self.route_total_cost = v.into();
13893 self
13894 }
13895
13896 #[deprecated]
13898 pub fn set_end_loads<T, V>(mut self, v: T) -> Self
13899 where
13900 T: std::iter::IntoIterator<Item = V>,
13901 V: std::convert::Into<crate::model::CapacityQuantity>,
13902 {
13903 use std::iter::Iterator;
13904 self.end_loads = v.into_iter().map(|i| i.into()).collect();
13905 self
13906 }
13907
13908 #[deprecated]
13910 pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
13911 where
13912 T: std::iter::IntoIterator<Item = V>,
13913 V: std::convert::Into<crate::model::shipment_route::TravelStep>,
13914 {
13915 use std::iter::Iterator;
13916 self.travel_steps = v.into_iter().map(|i| i.into()).collect();
13917 self
13918 }
13919
13920 #[deprecated]
13922 pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
13923 where
13924 T: std::convert::Into<wkt::Duration>,
13925 {
13926 self.vehicle_detour = std::option::Option::Some(v.into());
13927 self
13928 }
13929
13930 #[deprecated]
13932 pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
13933 where
13934 T: std::convert::Into<wkt::Duration>,
13935 {
13936 self.vehicle_detour = v.map(|x| x.into());
13937 self
13938 }
13939
13940 #[deprecated]
13942 pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
13943 where
13944 T: std::convert::Into<crate::model::shipment_route::Delay>,
13945 {
13946 self.delay_before_vehicle_end = std::option::Option::Some(v.into());
13947 self
13948 }
13949
13950 #[deprecated]
13952 pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
13953 where
13954 T: std::convert::Into<crate::model::shipment_route::Delay>,
13955 {
13956 self.delay_before_vehicle_end = v.map(|x| x.into());
13957 self
13958 }
13959}
13960
13961impl wkt::message::Message for ShipmentRoute {
13962 fn typename() -> &'static str {
13963 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
13964 }
13965}
13966
13967#[doc(hidden)]
13968impl<'de> serde::de::Deserialize<'de> for ShipmentRoute {
13969 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13970 where
13971 D: serde::Deserializer<'de>,
13972 {
13973 #[allow(non_camel_case_types)]
13974 #[doc(hidden)]
13975 #[derive(PartialEq, Eq, Hash)]
13976 enum __FieldTag {
13977 __vehicle_index,
13978 __vehicle_label,
13979 __vehicle_start_time,
13980 __vehicle_end_time,
13981 __visits,
13982 __transitions,
13983 __has_traffic_infeasibilities,
13984 __route_polyline,
13985 __breaks,
13986 __metrics,
13987 __route_costs,
13988 __route_total_cost,
13989 __end_loads,
13990 __travel_steps,
13991 __vehicle_detour,
13992 __delay_before_vehicle_end,
13993 Unknown(std::string::String),
13994 }
13995 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
13996 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
13997 where
13998 D: serde::Deserializer<'de>,
13999 {
14000 struct Visitor;
14001 impl<'de> serde::de::Visitor<'de> for Visitor {
14002 type Value = __FieldTag;
14003 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14004 formatter.write_str("a field name for ShipmentRoute")
14005 }
14006 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14007 where
14008 E: serde::de::Error,
14009 {
14010 use std::result::Result::Ok;
14011 use std::string::ToString;
14012 match value {
14013 "vehicleIndex" => Ok(__FieldTag::__vehicle_index),
14014 "vehicle_index" => Ok(__FieldTag::__vehicle_index),
14015 "vehicleLabel" => Ok(__FieldTag::__vehicle_label),
14016 "vehicle_label" => Ok(__FieldTag::__vehicle_label),
14017 "vehicleStartTime" => Ok(__FieldTag::__vehicle_start_time),
14018 "vehicle_start_time" => Ok(__FieldTag::__vehicle_start_time),
14019 "vehicleEndTime" => Ok(__FieldTag::__vehicle_end_time),
14020 "vehicle_end_time" => Ok(__FieldTag::__vehicle_end_time),
14021 "visits" => Ok(__FieldTag::__visits),
14022 "transitions" => Ok(__FieldTag::__transitions),
14023 "hasTrafficInfeasibilities" => {
14024 Ok(__FieldTag::__has_traffic_infeasibilities)
14025 }
14026 "has_traffic_infeasibilities" => {
14027 Ok(__FieldTag::__has_traffic_infeasibilities)
14028 }
14029 "routePolyline" => Ok(__FieldTag::__route_polyline),
14030 "route_polyline" => Ok(__FieldTag::__route_polyline),
14031 "breaks" => Ok(__FieldTag::__breaks),
14032 "metrics" => Ok(__FieldTag::__metrics),
14033 "routeCosts" => Ok(__FieldTag::__route_costs),
14034 "route_costs" => Ok(__FieldTag::__route_costs),
14035 "routeTotalCost" => Ok(__FieldTag::__route_total_cost),
14036 "route_total_cost" => Ok(__FieldTag::__route_total_cost),
14037 "endLoads" => Ok(__FieldTag::__end_loads),
14038 "end_loads" => Ok(__FieldTag::__end_loads),
14039 "travelSteps" => Ok(__FieldTag::__travel_steps),
14040 "travel_steps" => Ok(__FieldTag::__travel_steps),
14041 "vehicleDetour" => Ok(__FieldTag::__vehicle_detour),
14042 "vehicle_detour" => Ok(__FieldTag::__vehicle_detour),
14043 "delayBeforeVehicleEnd" => Ok(__FieldTag::__delay_before_vehicle_end),
14044 "delay_before_vehicle_end" => {
14045 Ok(__FieldTag::__delay_before_vehicle_end)
14046 }
14047 _ => Ok(__FieldTag::Unknown(value.to_string())),
14048 }
14049 }
14050 }
14051 deserializer.deserialize_identifier(Visitor)
14052 }
14053 }
14054 struct Visitor;
14055 impl<'de> serde::de::Visitor<'de> for Visitor {
14056 type Value = ShipmentRoute;
14057 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14058 formatter.write_str("struct ShipmentRoute")
14059 }
14060 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14061 where
14062 A: serde::de::MapAccess<'de>,
14063 {
14064 #[allow(unused_imports)]
14065 use serde::de::Error;
14066 use std::option::Option::Some;
14067 let mut fields = std::collections::HashSet::new();
14068 let mut result = Self::Value::new();
14069 while let Some(tag) = map.next_key::<__FieldTag>()? {
14070 #[allow(clippy::match_single_binding)]
14071 match tag {
14072 __FieldTag::__vehicle_index => {
14073 if !fields.insert(__FieldTag::__vehicle_index) {
14074 return std::result::Result::Err(A::Error::duplicate_field(
14075 "multiple values for vehicle_index",
14076 ));
14077 }
14078 struct __With(std::option::Option<i32>);
14079 impl<'de> serde::de::Deserialize<'de> for __With {
14080 fn deserialize<D>(
14081 deserializer: D,
14082 ) -> std::result::Result<Self, D::Error>
14083 where
14084 D: serde::de::Deserializer<'de>,
14085 {
14086 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
14087 }
14088 }
14089 result.vehicle_index =
14090 map.next_value::<__With>()?.0.unwrap_or_default();
14091 }
14092 __FieldTag::__vehicle_label => {
14093 if !fields.insert(__FieldTag::__vehicle_label) {
14094 return std::result::Result::Err(A::Error::duplicate_field(
14095 "multiple values for vehicle_label",
14096 ));
14097 }
14098 result.vehicle_label = map
14099 .next_value::<std::option::Option<std::string::String>>()?
14100 .unwrap_or_default();
14101 }
14102 __FieldTag::__vehicle_start_time => {
14103 if !fields.insert(__FieldTag::__vehicle_start_time) {
14104 return std::result::Result::Err(A::Error::duplicate_field(
14105 "multiple values for vehicle_start_time",
14106 ));
14107 }
14108 result.vehicle_start_time =
14109 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14110 }
14111 __FieldTag::__vehicle_end_time => {
14112 if !fields.insert(__FieldTag::__vehicle_end_time) {
14113 return std::result::Result::Err(A::Error::duplicate_field(
14114 "multiple values for vehicle_end_time",
14115 ));
14116 }
14117 result.vehicle_end_time =
14118 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14119 }
14120 __FieldTag::__visits => {
14121 if !fields.insert(__FieldTag::__visits) {
14122 return std::result::Result::Err(A::Error::duplicate_field(
14123 "multiple values for visits",
14124 ));
14125 }
14126 result.visits = map
14127 .next_value::<std::option::Option<
14128 std::vec::Vec<crate::model::shipment_route::Visit>,
14129 >>()?
14130 .unwrap_or_default();
14131 }
14132 __FieldTag::__transitions => {
14133 if !fields.insert(__FieldTag::__transitions) {
14134 return std::result::Result::Err(A::Error::duplicate_field(
14135 "multiple values for transitions",
14136 ));
14137 }
14138 result.transitions = map
14139 .next_value::<std::option::Option<
14140 std::vec::Vec<crate::model::shipment_route::Transition>,
14141 >>()?
14142 .unwrap_or_default();
14143 }
14144 __FieldTag::__has_traffic_infeasibilities => {
14145 if !fields.insert(__FieldTag::__has_traffic_infeasibilities) {
14146 return std::result::Result::Err(A::Error::duplicate_field(
14147 "multiple values for has_traffic_infeasibilities",
14148 ));
14149 }
14150 result.has_traffic_infeasibilities = map
14151 .next_value::<std::option::Option<bool>>()?
14152 .unwrap_or_default();
14153 }
14154 __FieldTag::__route_polyline => {
14155 if !fields.insert(__FieldTag::__route_polyline) {
14156 return std::result::Result::Err(A::Error::duplicate_field(
14157 "multiple values for route_polyline",
14158 ));
14159 }
14160 result.route_polyline = map.next_value::<std::option::Option<
14161 crate::model::shipment_route::EncodedPolyline,
14162 >>()?;
14163 }
14164 __FieldTag::__breaks => {
14165 if !fields.insert(__FieldTag::__breaks) {
14166 return std::result::Result::Err(A::Error::duplicate_field(
14167 "multiple values for breaks",
14168 ));
14169 }
14170 result.breaks = map
14171 .next_value::<std::option::Option<
14172 std::vec::Vec<crate::model::shipment_route::Break>,
14173 >>()?
14174 .unwrap_or_default();
14175 }
14176 __FieldTag::__metrics => {
14177 if !fields.insert(__FieldTag::__metrics) {
14178 return std::result::Result::Err(A::Error::duplicate_field(
14179 "multiple values for metrics",
14180 ));
14181 }
14182 result.metrics = map
14183 .next_value::<std::option::Option<crate::model::AggregatedMetrics>>(
14184 )?;
14185 }
14186 __FieldTag::__route_costs => {
14187 if !fields.insert(__FieldTag::__route_costs) {
14188 return std::result::Result::Err(A::Error::duplicate_field(
14189 "multiple values for route_costs",
14190 ));
14191 }
14192 struct __With(
14193 std::option::Option<
14194 std::collections::HashMap<std::string::String, f64>,
14195 >,
14196 );
14197 impl<'de> serde::de::Deserialize<'de> for __With {
14198 fn deserialize<D>(
14199 deserializer: D,
14200 ) -> std::result::Result<Self, D::Error>
14201 where
14202 D: serde::de::Deserializer<'de>,
14203 {
14204 serde_with::As::<
14205 std::option::Option<
14206 std::collections::HashMap<
14207 serde_with::Same,
14208 wkt::internal::F64,
14209 >,
14210 >,
14211 >::deserialize(deserializer)
14212 .map(__With)
14213 }
14214 }
14215 result.route_costs = map.next_value::<__With>()?.0.unwrap_or_default();
14216 }
14217 __FieldTag::__route_total_cost => {
14218 if !fields.insert(__FieldTag::__route_total_cost) {
14219 return std::result::Result::Err(A::Error::duplicate_field(
14220 "multiple values for route_total_cost",
14221 ));
14222 }
14223 struct __With(std::option::Option<f64>);
14224 impl<'de> serde::de::Deserialize<'de> for __With {
14225 fn deserialize<D>(
14226 deserializer: D,
14227 ) -> std::result::Result<Self, D::Error>
14228 where
14229 D: serde::de::Deserializer<'de>,
14230 {
14231 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
14232 }
14233 }
14234 result.route_total_cost =
14235 map.next_value::<__With>()?.0.unwrap_or_default();
14236 }
14237 __FieldTag::__end_loads => {
14238 if !fields.insert(__FieldTag::__end_loads) {
14239 return std::result::Result::Err(A::Error::duplicate_field(
14240 "multiple values for end_loads",
14241 ));
14242 }
14243 result.end_loads =
14244 map.next_value::<std::option::Option<
14245 std::vec::Vec<crate::model::CapacityQuantity>,
14246 >>()?
14247 .unwrap_or_default();
14248 }
14249 __FieldTag::__travel_steps => {
14250 if !fields.insert(__FieldTag::__travel_steps) {
14251 return std::result::Result::Err(A::Error::duplicate_field(
14252 "multiple values for travel_steps",
14253 ));
14254 }
14255 result.travel_steps = map
14256 .next_value::<std::option::Option<
14257 std::vec::Vec<crate::model::shipment_route::TravelStep>,
14258 >>()?
14259 .unwrap_or_default();
14260 }
14261 __FieldTag::__vehicle_detour => {
14262 if !fields.insert(__FieldTag::__vehicle_detour) {
14263 return std::result::Result::Err(A::Error::duplicate_field(
14264 "multiple values for vehicle_detour",
14265 ));
14266 }
14267 result.vehicle_detour =
14268 map.next_value::<std::option::Option<wkt::Duration>>()?;
14269 }
14270 __FieldTag::__delay_before_vehicle_end => {
14271 if !fields.insert(__FieldTag::__delay_before_vehicle_end) {
14272 return std::result::Result::Err(A::Error::duplicate_field(
14273 "multiple values for delay_before_vehicle_end",
14274 ));
14275 }
14276 result.delay_before_vehicle_end = map.next_value::<std::option::Option<crate::model::shipment_route::Delay>>()?
14277 ;
14278 }
14279 __FieldTag::Unknown(key) => {
14280 let value = map.next_value::<serde_json::Value>()?;
14281 result._unknown_fields.insert(key, value);
14282 }
14283 }
14284 }
14285 std::result::Result::Ok(result)
14286 }
14287 }
14288 deserializer.deserialize_any(Visitor)
14289 }
14290}
14291
14292#[doc(hidden)]
14293impl serde::ser::Serialize for ShipmentRoute {
14294 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14295 where
14296 S: serde::ser::Serializer,
14297 {
14298 use serde::ser::SerializeMap;
14299 #[allow(unused_imports)]
14300 use std::option::Option::Some;
14301 let mut state = serializer.serialize_map(std::option::Option::None)?;
14302 if !wkt::internal::is_default(&self.vehicle_index) {
14303 struct __With<'a>(&'a i32);
14304 impl<'a> serde::ser::Serialize for __With<'a> {
14305 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14306 where
14307 S: serde::ser::Serializer,
14308 {
14309 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
14310 }
14311 }
14312 state.serialize_entry("vehicleIndex", &__With(&self.vehicle_index))?;
14313 }
14314 if !self.vehicle_label.is_empty() {
14315 state.serialize_entry("vehicleLabel", &self.vehicle_label)?;
14316 }
14317 if self.vehicle_start_time.is_some() {
14318 state.serialize_entry("vehicleStartTime", &self.vehicle_start_time)?;
14319 }
14320 if self.vehicle_end_time.is_some() {
14321 state.serialize_entry("vehicleEndTime", &self.vehicle_end_time)?;
14322 }
14323 if !self.visits.is_empty() {
14324 state.serialize_entry("visits", &self.visits)?;
14325 }
14326 if !self.transitions.is_empty() {
14327 state.serialize_entry("transitions", &self.transitions)?;
14328 }
14329 if !wkt::internal::is_default(&self.has_traffic_infeasibilities) {
14330 state.serialize_entry(
14331 "hasTrafficInfeasibilities",
14332 &self.has_traffic_infeasibilities,
14333 )?;
14334 }
14335 if self.route_polyline.is_some() {
14336 state.serialize_entry("routePolyline", &self.route_polyline)?;
14337 }
14338 if !self.breaks.is_empty() {
14339 state.serialize_entry("breaks", &self.breaks)?;
14340 }
14341 if self.metrics.is_some() {
14342 state.serialize_entry("metrics", &self.metrics)?;
14343 }
14344 if !self.route_costs.is_empty() {
14345 struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
14346 impl<'a> serde::ser::Serialize for __With<'a> {
14347 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14348 where
14349 S: serde::ser::Serializer,
14350 {
14351 serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::F64> >::serialize(self.0, serializer)
14352 }
14353 }
14354 state.serialize_entry("routeCosts", &__With(&self.route_costs))?;
14355 }
14356 if !wkt::internal::is_default(&self.route_total_cost) {
14357 struct __With<'a>(&'a f64);
14358 impl<'a> serde::ser::Serialize for __With<'a> {
14359 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14360 where
14361 S: serde::ser::Serializer,
14362 {
14363 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
14364 }
14365 }
14366 state.serialize_entry("routeTotalCost", &__With(&self.route_total_cost))?;
14367 }
14368 if !self.end_loads.is_empty() {
14369 state.serialize_entry("endLoads", &self.end_loads)?;
14370 }
14371 if !self.travel_steps.is_empty() {
14372 state.serialize_entry("travelSteps", &self.travel_steps)?;
14373 }
14374 if self.vehicle_detour.is_some() {
14375 state.serialize_entry("vehicleDetour", &self.vehicle_detour)?;
14376 }
14377 if self.delay_before_vehicle_end.is_some() {
14378 state.serialize_entry("delayBeforeVehicleEnd", &self.delay_before_vehicle_end)?;
14379 }
14380 if !self._unknown_fields.is_empty() {
14381 for (key, value) in self._unknown_fields.iter() {
14382 state.serialize_entry(key, &value)?;
14383 }
14384 }
14385 state.end()
14386 }
14387}
14388
14389pub mod shipment_route {
14391 #[allow(unused_imports)]
14392 use super::*;
14393
14394 #[derive(Clone, Debug, Default, PartialEq)]
14402 #[non_exhaustive]
14403 #[deprecated]
14404 pub struct Delay {
14405 pub start_time: std::option::Option<wkt::Timestamp>,
14407
14408 pub duration: std::option::Option<wkt::Duration>,
14410
14411 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14412 }
14413
14414 impl Delay {
14415 pub fn new() -> Self {
14416 std::default::Default::default()
14417 }
14418
14419 pub fn set_start_time<T>(mut self, v: T) -> Self
14421 where
14422 T: std::convert::Into<wkt::Timestamp>,
14423 {
14424 self.start_time = std::option::Option::Some(v.into());
14425 self
14426 }
14427
14428 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
14430 where
14431 T: std::convert::Into<wkt::Timestamp>,
14432 {
14433 self.start_time = v.map(|x| x.into());
14434 self
14435 }
14436
14437 pub fn set_duration<T>(mut self, v: T) -> Self
14439 where
14440 T: std::convert::Into<wkt::Duration>,
14441 {
14442 self.duration = std::option::Option::Some(v.into());
14443 self
14444 }
14445
14446 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
14448 where
14449 T: std::convert::Into<wkt::Duration>,
14450 {
14451 self.duration = v.map(|x| x.into());
14452 self
14453 }
14454 }
14455
14456 impl wkt::message::Message for Delay {
14457 fn typename() -> &'static str {
14458 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
14459 }
14460 }
14461
14462 #[doc(hidden)]
14463 impl<'de> serde::de::Deserialize<'de> for Delay {
14464 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14465 where
14466 D: serde::Deserializer<'de>,
14467 {
14468 #[allow(non_camel_case_types)]
14469 #[doc(hidden)]
14470 #[derive(PartialEq, Eq, Hash)]
14471 enum __FieldTag {
14472 __start_time,
14473 __duration,
14474 Unknown(std::string::String),
14475 }
14476 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14477 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14478 where
14479 D: serde::Deserializer<'de>,
14480 {
14481 struct Visitor;
14482 impl<'de> serde::de::Visitor<'de> for Visitor {
14483 type Value = __FieldTag;
14484 fn expecting(
14485 &self,
14486 formatter: &mut std::fmt::Formatter,
14487 ) -> std::fmt::Result {
14488 formatter.write_str("a field name for Delay")
14489 }
14490 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14491 where
14492 E: serde::de::Error,
14493 {
14494 use std::result::Result::Ok;
14495 use std::string::ToString;
14496 match value {
14497 "startTime" => Ok(__FieldTag::__start_time),
14498 "start_time" => Ok(__FieldTag::__start_time),
14499 "duration" => Ok(__FieldTag::__duration),
14500 _ => Ok(__FieldTag::Unknown(value.to_string())),
14501 }
14502 }
14503 }
14504 deserializer.deserialize_identifier(Visitor)
14505 }
14506 }
14507 struct Visitor;
14508 impl<'de> serde::de::Visitor<'de> for Visitor {
14509 type Value = Delay;
14510 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14511 formatter.write_str("struct Delay")
14512 }
14513 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14514 where
14515 A: serde::de::MapAccess<'de>,
14516 {
14517 #[allow(unused_imports)]
14518 use serde::de::Error;
14519 use std::option::Option::Some;
14520 let mut fields = std::collections::HashSet::new();
14521 let mut result = Self::Value::new();
14522 while let Some(tag) = map.next_key::<__FieldTag>()? {
14523 #[allow(clippy::match_single_binding)]
14524 match tag {
14525 __FieldTag::__start_time => {
14526 if !fields.insert(__FieldTag::__start_time) {
14527 return std::result::Result::Err(A::Error::duplicate_field(
14528 "multiple values for start_time",
14529 ));
14530 }
14531 result.start_time =
14532 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14533 }
14534 __FieldTag::__duration => {
14535 if !fields.insert(__FieldTag::__duration) {
14536 return std::result::Result::Err(A::Error::duplicate_field(
14537 "multiple values for duration",
14538 ));
14539 }
14540 result.duration =
14541 map.next_value::<std::option::Option<wkt::Duration>>()?;
14542 }
14543 __FieldTag::Unknown(key) => {
14544 let value = map.next_value::<serde_json::Value>()?;
14545 result._unknown_fields.insert(key, value);
14546 }
14547 }
14548 }
14549 std::result::Result::Ok(result)
14550 }
14551 }
14552 deserializer.deserialize_any(Visitor)
14553 }
14554 }
14555
14556 #[doc(hidden)]
14557 impl serde::ser::Serialize for Delay {
14558 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
14559 where
14560 S: serde::ser::Serializer,
14561 {
14562 use serde::ser::SerializeMap;
14563 #[allow(unused_imports)]
14564 use std::option::Option::Some;
14565 let mut state = serializer.serialize_map(std::option::Option::None)?;
14566 if self.start_time.is_some() {
14567 state.serialize_entry("startTime", &self.start_time)?;
14568 }
14569 if self.duration.is_some() {
14570 state.serialize_entry("duration", &self.duration)?;
14571 }
14572 if !self._unknown_fields.is_empty() {
14573 for (key, value) in self._unknown_fields.iter() {
14574 state.serialize_entry(key, &value)?;
14575 }
14576 }
14577 state.end()
14578 }
14579 }
14580
14581 #[derive(Clone, Debug, Default, PartialEq)]
14584 #[non_exhaustive]
14585 pub struct Visit {
14586 pub shipment_index: i32,
14591
14592 pub is_pickup: bool,
14595
14596 pub visit_request_index: i32,
14599
14600 pub start_time: std::option::Option<wkt::Timestamp>,
14604
14605 pub load_demands:
14613 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
14614
14615 pub detour: std::option::Option<wkt::Duration>,
14634
14635 pub shipment_label: std::string::String,
14638
14639 pub visit_label: std::string::String,
14645
14646 #[deprecated]
14659 pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
14660
14661 #[deprecated]
14667 pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
14668
14669 #[deprecated]
14675 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
14676
14677 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
14678 }
14679
14680 impl Visit {
14681 pub fn new() -> Self {
14682 std::default::Default::default()
14683 }
14684
14685 pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
14687 self.shipment_index = v.into();
14688 self
14689 }
14690
14691 pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
14693 self.is_pickup = v.into();
14694 self
14695 }
14696
14697 pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
14699 self.visit_request_index = v.into();
14700 self
14701 }
14702
14703 pub fn set_start_time<T>(mut self, v: T) -> Self
14705 where
14706 T: std::convert::Into<wkt::Timestamp>,
14707 {
14708 self.start_time = std::option::Option::Some(v.into());
14709 self
14710 }
14711
14712 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
14714 where
14715 T: std::convert::Into<wkt::Timestamp>,
14716 {
14717 self.start_time = v.map(|x| x.into());
14718 self
14719 }
14720
14721 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
14723 where
14724 T: std::iter::IntoIterator<Item = (K, V)>,
14725 K: std::convert::Into<std::string::String>,
14726 V: std::convert::Into<crate::model::shipment::Load>,
14727 {
14728 use std::iter::Iterator;
14729 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
14730 self
14731 }
14732
14733 pub fn set_detour<T>(mut self, v: T) -> Self
14735 where
14736 T: std::convert::Into<wkt::Duration>,
14737 {
14738 self.detour = std::option::Option::Some(v.into());
14739 self
14740 }
14741
14742 pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
14744 where
14745 T: std::convert::Into<wkt::Duration>,
14746 {
14747 self.detour = v.map(|x| x.into());
14748 self
14749 }
14750
14751 pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
14753 mut self,
14754 v: T,
14755 ) -> Self {
14756 self.shipment_label = v.into();
14757 self
14758 }
14759
14760 pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
14762 self.visit_label = v.into();
14763 self
14764 }
14765
14766 #[deprecated]
14768 pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
14769 where
14770 T: std::iter::IntoIterator<Item = V>,
14771 V: std::convert::Into<crate::model::CapacityQuantity>,
14772 {
14773 use std::iter::Iterator;
14774 self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
14775 self
14776 }
14777
14778 #[deprecated]
14780 pub fn set_delay_before_start<T>(mut self, v: T) -> Self
14781 where
14782 T: std::convert::Into<crate::model::shipment_route::Delay>,
14783 {
14784 self.delay_before_start = std::option::Option::Some(v.into());
14785 self
14786 }
14787
14788 #[deprecated]
14790 pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
14791 where
14792 T: std::convert::Into<crate::model::shipment_route::Delay>,
14793 {
14794 self.delay_before_start = v.map(|x| x.into());
14795 self
14796 }
14797
14798 #[deprecated]
14800 pub fn set_demands<T, V>(mut self, v: T) -> Self
14801 where
14802 T: std::iter::IntoIterator<Item = V>,
14803 V: std::convert::Into<crate::model::CapacityQuantity>,
14804 {
14805 use std::iter::Iterator;
14806 self.demands = v.into_iter().map(|i| i.into()).collect();
14807 self
14808 }
14809 }
14810
14811 impl wkt::message::Message for Visit {
14812 fn typename() -> &'static str {
14813 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
14814 }
14815 }
14816
14817 #[doc(hidden)]
14818 impl<'de> serde::de::Deserialize<'de> for Visit {
14819 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14820 where
14821 D: serde::Deserializer<'de>,
14822 {
14823 #[allow(non_camel_case_types)]
14824 #[doc(hidden)]
14825 #[derive(PartialEq, Eq, Hash)]
14826 enum __FieldTag {
14827 __shipment_index,
14828 __is_pickup,
14829 __visit_request_index,
14830 __start_time,
14831 __load_demands,
14832 __detour,
14833 __shipment_label,
14834 __visit_label,
14835 __arrival_loads,
14836 __delay_before_start,
14837 __demands,
14838 Unknown(std::string::String),
14839 }
14840 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
14841 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
14842 where
14843 D: serde::Deserializer<'de>,
14844 {
14845 struct Visitor;
14846 impl<'de> serde::de::Visitor<'de> for Visitor {
14847 type Value = __FieldTag;
14848 fn expecting(
14849 &self,
14850 formatter: &mut std::fmt::Formatter,
14851 ) -> std::fmt::Result {
14852 formatter.write_str("a field name for Visit")
14853 }
14854 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
14855 where
14856 E: serde::de::Error,
14857 {
14858 use std::result::Result::Ok;
14859 use std::string::ToString;
14860 match value {
14861 "shipmentIndex" => Ok(__FieldTag::__shipment_index),
14862 "shipment_index" => Ok(__FieldTag::__shipment_index),
14863 "isPickup" => Ok(__FieldTag::__is_pickup),
14864 "is_pickup" => Ok(__FieldTag::__is_pickup),
14865 "visitRequestIndex" => Ok(__FieldTag::__visit_request_index),
14866 "visit_request_index" => Ok(__FieldTag::__visit_request_index),
14867 "startTime" => Ok(__FieldTag::__start_time),
14868 "start_time" => Ok(__FieldTag::__start_time),
14869 "loadDemands" => Ok(__FieldTag::__load_demands),
14870 "load_demands" => Ok(__FieldTag::__load_demands),
14871 "detour" => Ok(__FieldTag::__detour),
14872 "shipmentLabel" => Ok(__FieldTag::__shipment_label),
14873 "shipment_label" => Ok(__FieldTag::__shipment_label),
14874 "visitLabel" => Ok(__FieldTag::__visit_label),
14875 "visit_label" => Ok(__FieldTag::__visit_label),
14876 "arrivalLoads" => Ok(__FieldTag::__arrival_loads),
14877 "arrival_loads" => Ok(__FieldTag::__arrival_loads),
14878 "delayBeforeStart" => Ok(__FieldTag::__delay_before_start),
14879 "delay_before_start" => Ok(__FieldTag::__delay_before_start),
14880 "demands" => Ok(__FieldTag::__demands),
14881 _ => Ok(__FieldTag::Unknown(value.to_string())),
14882 }
14883 }
14884 }
14885 deserializer.deserialize_identifier(Visitor)
14886 }
14887 }
14888 struct Visitor;
14889 impl<'de> serde::de::Visitor<'de> for Visitor {
14890 type Value = Visit;
14891 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
14892 formatter.write_str("struct Visit")
14893 }
14894 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
14895 where
14896 A: serde::de::MapAccess<'de>,
14897 {
14898 #[allow(unused_imports)]
14899 use serde::de::Error;
14900 use std::option::Option::Some;
14901 let mut fields = std::collections::HashSet::new();
14902 let mut result = Self::Value::new();
14903 while let Some(tag) = map.next_key::<__FieldTag>()? {
14904 #[allow(clippy::match_single_binding)]
14905 match tag {
14906 __FieldTag::__shipment_index => {
14907 if !fields.insert(__FieldTag::__shipment_index) {
14908 return std::result::Result::Err(A::Error::duplicate_field(
14909 "multiple values for shipment_index",
14910 ));
14911 }
14912 struct __With(std::option::Option<i32>);
14913 impl<'de> serde::de::Deserialize<'de> for __With {
14914 fn deserialize<D>(
14915 deserializer: D,
14916 ) -> std::result::Result<Self, D::Error>
14917 where
14918 D: serde::de::Deserializer<'de>,
14919 {
14920 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
14921 }
14922 }
14923 result.shipment_index =
14924 map.next_value::<__With>()?.0.unwrap_or_default();
14925 }
14926 __FieldTag::__is_pickup => {
14927 if !fields.insert(__FieldTag::__is_pickup) {
14928 return std::result::Result::Err(A::Error::duplicate_field(
14929 "multiple values for is_pickup",
14930 ));
14931 }
14932 result.is_pickup = map
14933 .next_value::<std::option::Option<bool>>()?
14934 .unwrap_or_default();
14935 }
14936 __FieldTag::__visit_request_index => {
14937 if !fields.insert(__FieldTag::__visit_request_index) {
14938 return std::result::Result::Err(A::Error::duplicate_field(
14939 "multiple values for visit_request_index",
14940 ));
14941 }
14942 struct __With(std::option::Option<i32>);
14943 impl<'de> serde::de::Deserialize<'de> for __With {
14944 fn deserialize<D>(
14945 deserializer: D,
14946 ) -> std::result::Result<Self, D::Error>
14947 where
14948 D: serde::de::Deserializer<'de>,
14949 {
14950 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
14951 }
14952 }
14953 result.visit_request_index =
14954 map.next_value::<__With>()?.0.unwrap_or_default();
14955 }
14956 __FieldTag::__start_time => {
14957 if !fields.insert(__FieldTag::__start_time) {
14958 return std::result::Result::Err(A::Error::duplicate_field(
14959 "multiple values for start_time",
14960 ));
14961 }
14962 result.start_time =
14963 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
14964 }
14965 __FieldTag::__load_demands => {
14966 if !fields.insert(__FieldTag::__load_demands) {
14967 return std::result::Result::Err(A::Error::duplicate_field(
14968 "multiple values for load_demands",
14969 ));
14970 }
14971 result.load_demands = map
14972 .next_value::<std::option::Option<
14973 std::collections::HashMap<
14974 std::string::String,
14975 crate::model::shipment::Load,
14976 >,
14977 >>()?
14978 .unwrap_or_default();
14979 }
14980 __FieldTag::__detour => {
14981 if !fields.insert(__FieldTag::__detour) {
14982 return std::result::Result::Err(A::Error::duplicate_field(
14983 "multiple values for detour",
14984 ));
14985 }
14986 result.detour =
14987 map.next_value::<std::option::Option<wkt::Duration>>()?;
14988 }
14989 __FieldTag::__shipment_label => {
14990 if !fields.insert(__FieldTag::__shipment_label) {
14991 return std::result::Result::Err(A::Error::duplicate_field(
14992 "multiple values for shipment_label",
14993 ));
14994 }
14995 result.shipment_label = map
14996 .next_value::<std::option::Option<std::string::String>>()?
14997 .unwrap_or_default();
14998 }
14999 __FieldTag::__visit_label => {
15000 if !fields.insert(__FieldTag::__visit_label) {
15001 return std::result::Result::Err(A::Error::duplicate_field(
15002 "multiple values for visit_label",
15003 ));
15004 }
15005 result.visit_label = map
15006 .next_value::<std::option::Option<std::string::String>>()?
15007 .unwrap_or_default();
15008 }
15009 __FieldTag::__arrival_loads => {
15010 if !fields.insert(__FieldTag::__arrival_loads) {
15011 return std::result::Result::Err(A::Error::duplicate_field(
15012 "multiple values for arrival_loads",
15013 ));
15014 }
15015 result.arrival_loads = map
15016 .next_value::<std::option::Option<
15017 std::vec::Vec<crate::model::CapacityQuantity>,
15018 >>()?
15019 .unwrap_or_default();
15020 }
15021 __FieldTag::__delay_before_start => {
15022 if !fields.insert(__FieldTag::__delay_before_start) {
15023 return std::result::Result::Err(A::Error::duplicate_field(
15024 "multiple values for delay_before_start",
15025 ));
15026 }
15027 result.delay_before_start = map.next_value::<std::option::Option<crate::model::shipment_route::Delay>>()?
15028 ;
15029 }
15030 __FieldTag::__demands => {
15031 if !fields.insert(__FieldTag::__demands) {
15032 return std::result::Result::Err(A::Error::duplicate_field(
15033 "multiple values for demands",
15034 ));
15035 }
15036 result.demands = map
15037 .next_value::<std::option::Option<
15038 std::vec::Vec<crate::model::CapacityQuantity>,
15039 >>()?
15040 .unwrap_or_default();
15041 }
15042 __FieldTag::Unknown(key) => {
15043 let value = map.next_value::<serde_json::Value>()?;
15044 result._unknown_fields.insert(key, value);
15045 }
15046 }
15047 }
15048 std::result::Result::Ok(result)
15049 }
15050 }
15051 deserializer.deserialize_any(Visitor)
15052 }
15053 }
15054
15055 #[doc(hidden)]
15056 impl serde::ser::Serialize for Visit {
15057 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15058 where
15059 S: serde::ser::Serializer,
15060 {
15061 use serde::ser::SerializeMap;
15062 #[allow(unused_imports)]
15063 use std::option::Option::Some;
15064 let mut state = serializer.serialize_map(std::option::Option::None)?;
15065 if !wkt::internal::is_default(&self.shipment_index) {
15066 struct __With<'a>(&'a i32);
15067 impl<'a> serde::ser::Serialize for __With<'a> {
15068 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15069 where
15070 S: serde::ser::Serializer,
15071 {
15072 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
15073 }
15074 }
15075 state.serialize_entry("shipmentIndex", &__With(&self.shipment_index))?;
15076 }
15077 if !wkt::internal::is_default(&self.is_pickup) {
15078 state.serialize_entry("isPickup", &self.is_pickup)?;
15079 }
15080 if !wkt::internal::is_default(&self.visit_request_index) {
15081 struct __With<'a>(&'a i32);
15082 impl<'a> serde::ser::Serialize for __With<'a> {
15083 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15084 where
15085 S: serde::ser::Serializer,
15086 {
15087 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
15088 }
15089 }
15090 state.serialize_entry("visitRequestIndex", &__With(&self.visit_request_index))?;
15091 }
15092 if self.start_time.is_some() {
15093 state.serialize_entry("startTime", &self.start_time)?;
15094 }
15095 if !self.load_demands.is_empty() {
15096 state.serialize_entry("loadDemands", &self.load_demands)?;
15097 }
15098 if self.detour.is_some() {
15099 state.serialize_entry("detour", &self.detour)?;
15100 }
15101 if !self.shipment_label.is_empty() {
15102 state.serialize_entry("shipmentLabel", &self.shipment_label)?;
15103 }
15104 if !self.visit_label.is_empty() {
15105 state.serialize_entry("visitLabel", &self.visit_label)?;
15106 }
15107 if !self.arrival_loads.is_empty() {
15108 state.serialize_entry("arrivalLoads", &self.arrival_loads)?;
15109 }
15110 if self.delay_before_start.is_some() {
15111 state.serialize_entry("delayBeforeStart", &self.delay_before_start)?;
15112 }
15113 if !self.demands.is_empty() {
15114 state.serialize_entry("demands", &self.demands)?;
15115 }
15116 if !self._unknown_fields.is_empty() {
15117 for (key, value) in self._unknown_fields.iter() {
15118 state.serialize_entry(key, &value)?;
15119 }
15120 }
15121 state.end()
15122 }
15123 }
15124
15125 #[derive(Clone, Debug, Default, PartialEq)]
15133 #[non_exhaustive]
15134 pub struct Transition {
15135 pub travel_duration: std::option::Option<wkt::Duration>,
15137
15138 pub travel_distance_meters: f64,
15140
15141 pub traffic_info_unavailable: bool,
15148
15149 pub delay_duration: std::option::Option<wkt::Duration>,
15156
15157 pub break_duration: std::option::Option<wkt::Duration>,
15163
15164 pub wait_duration: std::option::Option<wkt::Duration>,
15168
15169 pub total_duration: std::option::Option<wkt::Duration>,
15179
15180 pub start_time: std::option::Option<wkt::Timestamp>,
15182
15183 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
15189
15190 pub vehicle_loads: std::collections::HashMap<
15205 std::string::String,
15206 crate::model::shipment_route::VehicleLoad,
15207 >,
15208
15209 #[deprecated]
15215 pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
15216
15217 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15218 }
15219
15220 impl Transition {
15221 pub fn new() -> Self {
15222 std::default::Default::default()
15223 }
15224
15225 pub fn set_travel_duration<T>(mut self, v: T) -> Self
15227 where
15228 T: std::convert::Into<wkt::Duration>,
15229 {
15230 self.travel_duration = std::option::Option::Some(v.into());
15231 self
15232 }
15233
15234 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
15236 where
15237 T: std::convert::Into<wkt::Duration>,
15238 {
15239 self.travel_duration = v.map(|x| x.into());
15240 self
15241 }
15242
15243 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
15245 self.travel_distance_meters = v.into();
15246 self
15247 }
15248
15249 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
15251 self.traffic_info_unavailable = v.into();
15252 self
15253 }
15254
15255 pub fn set_delay_duration<T>(mut self, v: T) -> Self
15257 where
15258 T: std::convert::Into<wkt::Duration>,
15259 {
15260 self.delay_duration = std::option::Option::Some(v.into());
15261 self
15262 }
15263
15264 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
15266 where
15267 T: std::convert::Into<wkt::Duration>,
15268 {
15269 self.delay_duration = v.map(|x| x.into());
15270 self
15271 }
15272
15273 pub fn set_break_duration<T>(mut self, v: T) -> Self
15275 where
15276 T: std::convert::Into<wkt::Duration>,
15277 {
15278 self.break_duration = std::option::Option::Some(v.into());
15279 self
15280 }
15281
15282 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
15284 where
15285 T: std::convert::Into<wkt::Duration>,
15286 {
15287 self.break_duration = v.map(|x| x.into());
15288 self
15289 }
15290
15291 pub fn set_wait_duration<T>(mut self, v: T) -> Self
15293 where
15294 T: std::convert::Into<wkt::Duration>,
15295 {
15296 self.wait_duration = std::option::Option::Some(v.into());
15297 self
15298 }
15299
15300 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
15302 where
15303 T: std::convert::Into<wkt::Duration>,
15304 {
15305 self.wait_duration = v.map(|x| x.into());
15306 self
15307 }
15308
15309 pub fn set_total_duration<T>(mut self, v: T) -> Self
15311 where
15312 T: std::convert::Into<wkt::Duration>,
15313 {
15314 self.total_duration = std::option::Option::Some(v.into());
15315 self
15316 }
15317
15318 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
15320 where
15321 T: std::convert::Into<wkt::Duration>,
15322 {
15323 self.total_duration = v.map(|x| x.into());
15324 self
15325 }
15326
15327 pub fn set_start_time<T>(mut self, v: T) -> Self
15329 where
15330 T: std::convert::Into<wkt::Timestamp>,
15331 {
15332 self.start_time = std::option::Option::Some(v.into());
15333 self
15334 }
15335
15336 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
15338 where
15339 T: std::convert::Into<wkt::Timestamp>,
15340 {
15341 self.start_time = v.map(|x| x.into());
15342 self
15343 }
15344
15345 pub fn set_route_polyline<T>(mut self, v: T) -> Self
15347 where
15348 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
15349 {
15350 self.route_polyline = std::option::Option::Some(v.into());
15351 self
15352 }
15353
15354 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
15356 where
15357 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
15358 {
15359 self.route_polyline = v.map(|x| x.into());
15360 self
15361 }
15362
15363 pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
15365 where
15366 T: std::iter::IntoIterator<Item = (K, V)>,
15367 K: std::convert::Into<std::string::String>,
15368 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
15369 {
15370 use std::iter::Iterator;
15371 self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
15372 self
15373 }
15374
15375 #[deprecated]
15377 pub fn set_loads<T, V>(mut self, v: T) -> Self
15378 where
15379 T: std::iter::IntoIterator<Item = V>,
15380 V: std::convert::Into<crate::model::CapacityQuantity>,
15381 {
15382 use std::iter::Iterator;
15383 self.loads = v.into_iter().map(|i| i.into()).collect();
15384 self
15385 }
15386 }
15387
15388 impl wkt::message::Message for Transition {
15389 fn typename() -> &'static str {
15390 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
15391 }
15392 }
15393
15394 #[doc(hidden)]
15395 impl<'de> serde::de::Deserialize<'de> for Transition {
15396 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15397 where
15398 D: serde::Deserializer<'de>,
15399 {
15400 #[allow(non_camel_case_types)]
15401 #[doc(hidden)]
15402 #[derive(PartialEq, Eq, Hash)]
15403 enum __FieldTag {
15404 __travel_duration,
15405 __travel_distance_meters,
15406 __traffic_info_unavailable,
15407 __delay_duration,
15408 __break_duration,
15409 __wait_duration,
15410 __total_duration,
15411 __start_time,
15412 __route_polyline,
15413 __vehicle_loads,
15414 __loads,
15415 Unknown(std::string::String),
15416 }
15417 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15418 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15419 where
15420 D: serde::Deserializer<'de>,
15421 {
15422 struct Visitor;
15423 impl<'de> serde::de::Visitor<'de> for Visitor {
15424 type Value = __FieldTag;
15425 fn expecting(
15426 &self,
15427 formatter: &mut std::fmt::Formatter,
15428 ) -> std::fmt::Result {
15429 formatter.write_str("a field name for Transition")
15430 }
15431 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15432 where
15433 E: serde::de::Error,
15434 {
15435 use std::result::Result::Ok;
15436 use std::string::ToString;
15437 match value {
15438 "travelDuration" => Ok(__FieldTag::__travel_duration),
15439 "travel_duration" => Ok(__FieldTag::__travel_duration),
15440 "travelDistanceMeters" => Ok(__FieldTag::__travel_distance_meters),
15441 "travel_distance_meters" => {
15442 Ok(__FieldTag::__travel_distance_meters)
15443 }
15444 "trafficInfoUnavailable" => {
15445 Ok(__FieldTag::__traffic_info_unavailable)
15446 }
15447 "traffic_info_unavailable" => {
15448 Ok(__FieldTag::__traffic_info_unavailable)
15449 }
15450 "delayDuration" => Ok(__FieldTag::__delay_duration),
15451 "delay_duration" => Ok(__FieldTag::__delay_duration),
15452 "breakDuration" => Ok(__FieldTag::__break_duration),
15453 "break_duration" => Ok(__FieldTag::__break_duration),
15454 "waitDuration" => Ok(__FieldTag::__wait_duration),
15455 "wait_duration" => Ok(__FieldTag::__wait_duration),
15456 "totalDuration" => Ok(__FieldTag::__total_duration),
15457 "total_duration" => Ok(__FieldTag::__total_duration),
15458 "startTime" => Ok(__FieldTag::__start_time),
15459 "start_time" => Ok(__FieldTag::__start_time),
15460 "routePolyline" => Ok(__FieldTag::__route_polyline),
15461 "route_polyline" => Ok(__FieldTag::__route_polyline),
15462 "vehicleLoads" => Ok(__FieldTag::__vehicle_loads),
15463 "vehicle_loads" => Ok(__FieldTag::__vehicle_loads),
15464 "loads" => Ok(__FieldTag::__loads),
15465 _ => Ok(__FieldTag::Unknown(value.to_string())),
15466 }
15467 }
15468 }
15469 deserializer.deserialize_identifier(Visitor)
15470 }
15471 }
15472 struct Visitor;
15473 impl<'de> serde::de::Visitor<'de> for Visitor {
15474 type Value = Transition;
15475 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15476 formatter.write_str("struct Transition")
15477 }
15478 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15479 where
15480 A: serde::de::MapAccess<'de>,
15481 {
15482 #[allow(unused_imports)]
15483 use serde::de::Error;
15484 use std::option::Option::Some;
15485 let mut fields = std::collections::HashSet::new();
15486 let mut result = Self::Value::new();
15487 while let Some(tag) = map.next_key::<__FieldTag>()? {
15488 #[allow(clippy::match_single_binding)]
15489 match tag {
15490 __FieldTag::__travel_duration => {
15491 if !fields.insert(__FieldTag::__travel_duration) {
15492 return std::result::Result::Err(A::Error::duplicate_field(
15493 "multiple values for travel_duration",
15494 ));
15495 }
15496 result.travel_duration =
15497 map.next_value::<std::option::Option<wkt::Duration>>()?;
15498 }
15499 __FieldTag::__travel_distance_meters => {
15500 if !fields.insert(__FieldTag::__travel_distance_meters) {
15501 return std::result::Result::Err(A::Error::duplicate_field(
15502 "multiple values for travel_distance_meters",
15503 ));
15504 }
15505 struct __With(std::option::Option<f64>);
15506 impl<'de> serde::de::Deserialize<'de> for __With {
15507 fn deserialize<D>(
15508 deserializer: D,
15509 ) -> std::result::Result<Self, D::Error>
15510 where
15511 D: serde::de::Deserializer<'de>,
15512 {
15513 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
15514 }
15515 }
15516 result.travel_distance_meters =
15517 map.next_value::<__With>()?.0.unwrap_or_default();
15518 }
15519 __FieldTag::__traffic_info_unavailable => {
15520 if !fields.insert(__FieldTag::__traffic_info_unavailable) {
15521 return std::result::Result::Err(A::Error::duplicate_field(
15522 "multiple values for traffic_info_unavailable",
15523 ));
15524 }
15525 result.traffic_info_unavailable = map
15526 .next_value::<std::option::Option<bool>>()?
15527 .unwrap_or_default();
15528 }
15529 __FieldTag::__delay_duration => {
15530 if !fields.insert(__FieldTag::__delay_duration) {
15531 return std::result::Result::Err(A::Error::duplicate_field(
15532 "multiple values for delay_duration",
15533 ));
15534 }
15535 result.delay_duration =
15536 map.next_value::<std::option::Option<wkt::Duration>>()?;
15537 }
15538 __FieldTag::__break_duration => {
15539 if !fields.insert(__FieldTag::__break_duration) {
15540 return std::result::Result::Err(A::Error::duplicate_field(
15541 "multiple values for break_duration",
15542 ));
15543 }
15544 result.break_duration =
15545 map.next_value::<std::option::Option<wkt::Duration>>()?;
15546 }
15547 __FieldTag::__wait_duration => {
15548 if !fields.insert(__FieldTag::__wait_duration) {
15549 return std::result::Result::Err(A::Error::duplicate_field(
15550 "multiple values for wait_duration",
15551 ));
15552 }
15553 result.wait_duration =
15554 map.next_value::<std::option::Option<wkt::Duration>>()?;
15555 }
15556 __FieldTag::__total_duration => {
15557 if !fields.insert(__FieldTag::__total_duration) {
15558 return std::result::Result::Err(A::Error::duplicate_field(
15559 "multiple values for total_duration",
15560 ));
15561 }
15562 result.total_duration =
15563 map.next_value::<std::option::Option<wkt::Duration>>()?;
15564 }
15565 __FieldTag::__start_time => {
15566 if !fields.insert(__FieldTag::__start_time) {
15567 return std::result::Result::Err(A::Error::duplicate_field(
15568 "multiple values for start_time",
15569 ));
15570 }
15571 result.start_time =
15572 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
15573 }
15574 __FieldTag::__route_polyline => {
15575 if !fields.insert(__FieldTag::__route_polyline) {
15576 return std::result::Result::Err(A::Error::duplicate_field(
15577 "multiple values for route_polyline",
15578 ));
15579 }
15580 result.route_polyline = map.next_value::<std::option::Option<
15581 crate::model::shipment_route::EncodedPolyline,
15582 >>()?;
15583 }
15584 __FieldTag::__vehicle_loads => {
15585 if !fields.insert(__FieldTag::__vehicle_loads) {
15586 return std::result::Result::Err(A::Error::duplicate_field(
15587 "multiple values for vehicle_loads",
15588 ));
15589 }
15590 result.vehicle_loads = map
15591 .next_value::<std::option::Option<
15592 std::collections::HashMap<
15593 std::string::String,
15594 crate::model::shipment_route::VehicleLoad,
15595 >,
15596 >>()?
15597 .unwrap_or_default();
15598 }
15599 __FieldTag::__loads => {
15600 if !fields.insert(__FieldTag::__loads) {
15601 return std::result::Result::Err(A::Error::duplicate_field(
15602 "multiple values for loads",
15603 ));
15604 }
15605 result.loads = map
15606 .next_value::<std::option::Option<
15607 std::vec::Vec<crate::model::CapacityQuantity>,
15608 >>()?
15609 .unwrap_or_default();
15610 }
15611 __FieldTag::Unknown(key) => {
15612 let value = map.next_value::<serde_json::Value>()?;
15613 result._unknown_fields.insert(key, value);
15614 }
15615 }
15616 }
15617 std::result::Result::Ok(result)
15618 }
15619 }
15620 deserializer.deserialize_any(Visitor)
15621 }
15622 }
15623
15624 #[doc(hidden)]
15625 impl serde::ser::Serialize for Transition {
15626 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15627 where
15628 S: serde::ser::Serializer,
15629 {
15630 use serde::ser::SerializeMap;
15631 #[allow(unused_imports)]
15632 use std::option::Option::Some;
15633 let mut state = serializer.serialize_map(std::option::Option::None)?;
15634 if self.travel_duration.is_some() {
15635 state.serialize_entry("travelDuration", &self.travel_duration)?;
15636 }
15637 if !wkt::internal::is_default(&self.travel_distance_meters) {
15638 struct __With<'a>(&'a f64);
15639 impl<'a> serde::ser::Serialize for __With<'a> {
15640 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15641 where
15642 S: serde::ser::Serializer,
15643 {
15644 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
15645 }
15646 }
15647 state.serialize_entry(
15648 "travelDistanceMeters",
15649 &__With(&self.travel_distance_meters),
15650 )?;
15651 }
15652 if !wkt::internal::is_default(&self.traffic_info_unavailable) {
15653 state.serialize_entry("trafficInfoUnavailable", &self.traffic_info_unavailable)?;
15654 }
15655 if self.delay_duration.is_some() {
15656 state.serialize_entry("delayDuration", &self.delay_duration)?;
15657 }
15658 if self.break_duration.is_some() {
15659 state.serialize_entry("breakDuration", &self.break_duration)?;
15660 }
15661 if self.wait_duration.is_some() {
15662 state.serialize_entry("waitDuration", &self.wait_duration)?;
15663 }
15664 if self.total_duration.is_some() {
15665 state.serialize_entry("totalDuration", &self.total_duration)?;
15666 }
15667 if self.start_time.is_some() {
15668 state.serialize_entry("startTime", &self.start_time)?;
15669 }
15670 if self.route_polyline.is_some() {
15671 state.serialize_entry("routePolyline", &self.route_polyline)?;
15672 }
15673 if !self.vehicle_loads.is_empty() {
15674 state.serialize_entry("vehicleLoads", &self.vehicle_loads)?;
15675 }
15676 if !self.loads.is_empty() {
15677 state.serialize_entry("loads", &self.loads)?;
15678 }
15679 if !self._unknown_fields.is_empty() {
15680 for (key, value) in self._unknown_fields.iter() {
15681 state.serialize_entry(key, &value)?;
15682 }
15683 }
15684 state.end()
15685 }
15686 }
15687
15688 #[derive(Clone, Debug, Default, PartialEq)]
15694 #[non_exhaustive]
15695 pub struct VehicleLoad {
15696 pub amount: i64,
15702
15703 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15704 }
15705
15706 impl VehicleLoad {
15707 pub fn new() -> Self {
15708 std::default::Default::default()
15709 }
15710
15711 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
15713 self.amount = v.into();
15714 self
15715 }
15716 }
15717
15718 impl wkt::message::Message for VehicleLoad {
15719 fn typename() -> &'static str {
15720 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
15721 }
15722 }
15723
15724 #[doc(hidden)]
15725 impl<'de> serde::de::Deserialize<'de> for VehicleLoad {
15726 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15727 where
15728 D: serde::Deserializer<'de>,
15729 {
15730 #[allow(non_camel_case_types)]
15731 #[doc(hidden)]
15732 #[derive(PartialEq, Eq, Hash)]
15733 enum __FieldTag {
15734 __amount,
15735 Unknown(std::string::String),
15736 }
15737 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15738 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15739 where
15740 D: serde::Deserializer<'de>,
15741 {
15742 struct Visitor;
15743 impl<'de> serde::de::Visitor<'de> for Visitor {
15744 type Value = __FieldTag;
15745 fn expecting(
15746 &self,
15747 formatter: &mut std::fmt::Formatter,
15748 ) -> std::fmt::Result {
15749 formatter.write_str("a field name for VehicleLoad")
15750 }
15751 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15752 where
15753 E: serde::de::Error,
15754 {
15755 use std::result::Result::Ok;
15756 use std::string::ToString;
15757 match value {
15758 "amount" => Ok(__FieldTag::__amount),
15759 _ => Ok(__FieldTag::Unknown(value.to_string())),
15760 }
15761 }
15762 }
15763 deserializer.deserialize_identifier(Visitor)
15764 }
15765 }
15766 struct Visitor;
15767 impl<'de> serde::de::Visitor<'de> for Visitor {
15768 type Value = VehicleLoad;
15769 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15770 formatter.write_str("struct VehicleLoad")
15771 }
15772 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15773 where
15774 A: serde::de::MapAccess<'de>,
15775 {
15776 #[allow(unused_imports)]
15777 use serde::de::Error;
15778 use std::option::Option::Some;
15779 let mut fields = std::collections::HashSet::new();
15780 let mut result = Self::Value::new();
15781 while let Some(tag) = map.next_key::<__FieldTag>()? {
15782 #[allow(clippy::match_single_binding)]
15783 match tag {
15784 __FieldTag::__amount => {
15785 if !fields.insert(__FieldTag::__amount) {
15786 return std::result::Result::Err(A::Error::duplicate_field(
15787 "multiple values for amount",
15788 ));
15789 }
15790 struct __With(std::option::Option<i64>);
15791 impl<'de> serde::de::Deserialize<'de> for __With {
15792 fn deserialize<D>(
15793 deserializer: D,
15794 ) -> std::result::Result<Self, D::Error>
15795 where
15796 D: serde::de::Deserializer<'de>,
15797 {
15798 serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
15799 }
15800 }
15801 result.amount = map.next_value::<__With>()?.0.unwrap_or_default();
15802 }
15803 __FieldTag::Unknown(key) => {
15804 let value = map.next_value::<serde_json::Value>()?;
15805 result._unknown_fields.insert(key, value);
15806 }
15807 }
15808 }
15809 std::result::Result::Ok(result)
15810 }
15811 }
15812 deserializer.deserialize_any(Visitor)
15813 }
15814 }
15815
15816 #[doc(hidden)]
15817 impl serde::ser::Serialize for VehicleLoad {
15818 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15819 where
15820 S: serde::ser::Serializer,
15821 {
15822 use serde::ser::SerializeMap;
15823 #[allow(unused_imports)]
15824 use std::option::Option::Some;
15825 let mut state = serializer.serialize_map(std::option::Option::None)?;
15826 if !wkt::internal::is_default(&self.amount) {
15827 struct __With<'a>(&'a i64);
15828 impl<'a> serde::ser::Serialize for __With<'a> {
15829 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15830 where
15831 S: serde::ser::Serializer,
15832 {
15833 serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
15834 }
15835 }
15836 state.serialize_entry("amount", &__With(&self.amount))?;
15837 }
15838 if !self._unknown_fields.is_empty() {
15839 for (key, value) in self._unknown_fields.iter() {
15840 state.serialize_entry(key, &value)?;
15841 }
15842 }
15843 state.end()
15844 }
15845 }
15846
15847 #[derive(Clone, Debug, Default, PartialEq)]
15852 #[non_exhaustive]
15853 pub struct EncodedPolyline {
15854 pub points: std::string::String,
15856
15857 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15858 }
15859
15860 impl EncodedPolyline {
15861 pub fn new() -> Self {
15862 std::default::Default::default()
15863 }
15864
15865 pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
15867 self.points = v.into();
15868 self
15869 }
15870 }
15871
15872 impl wkt::message::Message for EncodedPolyline {
15873 fn typename() -> &'static str {
15874 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
15875 }
15876 }
15877
15878 #[doc(hidden)]
15879 impl<'de> serde::de::Deserialize<'de> for EncodedPolyline {
15880 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15881 where
15882 D: serde::Deserializer<'de>,
15883 {
15884 #[allow(non_camel_case_types)]
15885 #[doc(hidden)]
15886 #[derive(PartialEq, Eq, Hash)]
15887 enum __FieldTag {
15888 __points,
15889 Unknown(std::string::String),
15890 }
15891 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
15892 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
15893 where
15894 D: serde::Deserializer<'de>,
15895 {
15896 struct Visitor;
15897 impl<'de> serde::de::Visitor<'de> for Visitor {
15898 type Value = __FieldTag;
15899 fn expecting(
15900 &self,
15901 formatter: &mut std::fmt::Formatter,
15902 ) -> std::fmt::Result {
15903 formatter.write_str("a field name for EncodedPolyline")
15904 }
15905 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
15906 where
15907 E: serde::de::Error,
15908 {
15909 use std::result::Result::Ok;
15910 use std::string::ToString;
15911 match value {
15912 "points" => Ok(__FieldTag::__points),
15913 _ => Ok(__FieldTag::Unknown(value.to_string())),
15914 }
15915 }
15916 }
15917 deserializer.deserialize_identifier(Visitor)
15918 }
15919 }
15920 struct Visitor;
15921 impl<'de> serde::de::Visitor<'de> for Visitor {
15922 type Value = EncodedPolyline;
15923 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
15924 formatter.write_str("struct EncodedPolyline")
15925 }
15926 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
15927 where
15928 A: serde::de::MapAccess<'de>,
15929 {
15930 #[allow(unused_imports)]
15931 use serde::de::Error;
15932 use std::option::Option::Some;
15933 let mut fields = std::collections::HashSet::new();
15934 let mut result = Self::Value::new();
15935 while let Some(tag) = map.next_key::<__FieldTag>()? {
15936 #[allow(clippy::match_single_binding)]
15937 match tag {
15938 __FieldTag::__points => {
15939 if !fields.insert(__FieldTag::__points) {
15940 return std::result::Result::Err(A::Error::duplicate_field(
15941 "multiple values for points",
15942 ));
15943 }
15944 result.points = map
15945 .next_value::<std::option::Option<std::string::String>>()?
15946 .unwrap_or_default();
15947 }
15948 __FieldTag::Unknown(key) => {
15949 let value = map.next_value::<serde_json::Value>()?;
15950 result._unknown_fields.insert(key, value);
15951 }
15952 }
15953 }
15954 std::result::Result::Ok(result)
15955 }
15956 }
15957 deserializer.deserialize_any(Visitor)
15958 }
15959 }
15960
15961 #[doc(hidden)]
15962 impl serde::ser::Serialize for EncodedPolyline {
15963 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
15964 where
15965 S: serde::ser::Serializer,
15966 {
15967 use serde::ser::SerializeMap;
15968 #[allow(unused_imports)]
15969 use std::option::Option::Some;
15970 let mut state = serializer.serialize_map(std::option::Option::None)?;
15971 if !self.points.is_empty() {
15972 state.serialize_entry("points", &self.points)?;
15973 }
15974 if !self._unknown_fields.is_empty() {
15975 for (key, value) in self._unknown_fields.iter() {
15976 state.serialize_entry(key, &value)?;
15977 }
15978 }
15979 state.end()
15980 }
15981 }
15982
15983 #[derive(Clone, Debug, Default, PartialEq)]
15985 #[non_exhaustive]
15986 pub struct Break {
15987 pub start_time: std::option::Option<wkt::Timestamp>,
15989
15990 pub duration: std::option::Option<wkt::Duration>,
15992
15993 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
15994 }
15995
15996 impl Break {
15997 pub fn new() -> Self {
15998 std::default::Default::default()
15999 }
16000
16001 pub fn set_start_time<T>(mut self, v: T) -> Self
16003 where
16004 T: std::convert::Into<wkt::Timestamp>,
16005 {
16006 self.start_time = std::option::Option::Some(v.into());
16007 self
16008 }
16009
16010 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
16012 where
16013 T: std::convert::Into<wkt::Timestamp>,
16014 {
16015 self.start_time = v.map(|x| x.into());
16016 self
16017 }
16018
16019 pub fn set_duration<T>(mut self, v: T) -> Self
16021 where
16022 T: std::convert::Into<wkt::Duration>,
16023 {
16024 self.duration = std::option::Option::Some(v.into());
16025 self
16026 }
16027
16028 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
16030 where
16031 T: std::convert::Into<wkt::Duration>,
16032 {
16033 self.duration = v.map(|x| x.into());
16034 self
16035 }
16036 }
16037
16038 impl wkt::message::Message for Break {
16039 fn typename() -> &'static str {
16040 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
16041 }
16042 }
16043
16044 #[doc(hidden)]
16045 impl<'de> serde::de::Deserialize<'de> for Break {
16046 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16047 where
16048 D: serde::Deserializer<'de>,
16049 {
16050 #[allow(non_camel_case_types)]
16051 #[doc(hidden)]
16052 #[derive(PartialEq, Eq, Hash)]
16053 enum __FieldTag {
16054 __start_time,
16055 __duration,
16056 Unknown(std::string::String),
16057 }
16058 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16059 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16060 where
16061 D: serde::Deserializer<'de>,
16062 {
16063 struct Visitor;
16064 impl<'de> serde::de::Visitor<'de> for Visitor {
16065 type Value = __FieldTag;
16066 fn expecting(
16067 &self,
16068 formatter: &mut std::fmt::Formatter,
16069 ) -> std::fmt::Result {
16070 formatter.write_str("a field name for Break")
16071 }
16072 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16073 where
16074 E: serde::de::Error,
16075 {
16076 use std::result::Result::Ok;
16077 use std::string::ToString;
16078 match value {
16079 "startTime" => Ok(__FieldTag::__start_time),
16080 "start_time" => Ok(__FieldTag::__start_time),
16081 "duration" => Ok(__FieldTag::__duration),
16082 _ => Ok(__FieldTag::Unknown(value.to_string())),
16083 }
16084 }
16085 }
16086 deserializer.deserialize_identifier(Visitor)
16087 }
16088 }
16089 struct Visitor;
16090 impl<'de> serde::de::Visitor<'de> for Visitor {
16091 type Value = Break;
16092 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16093 formatter.write_str("struct Break")
16094 }
16095 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16096 where
16097 A: serde::de::MapAccess<'de>,
16098 {
16099 #[allow(unused_imports)]
16100 use serde::de::Error;
16101 use std::option::Option::Some;
16102 let mut fields = std::collections::HashSet::new();
16103 let mut result = Self::Value::new();
16104 while let Some(tag) = map.next_key::<__FieldTag>()? {
16105 #[allow(clippy::match_single_binding)]
16106 match tag {
16107 __FieldTag::__start_time => {
16108 if !fields.insert(__FieldTag::__start_time) {
16109 return std::result::Result::Err(A::Error::duplicate_field(
16110 "multiple values for start_time",
16111 ));
16112 }
16113 result.start_time =
16114 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
16115 }
16116 __FieldTag::__duration => {
16117 if !fields.insert(__FieldTag::__duration) {
16118 return std::result::Result::Err(A::Error::duplicate_field(
16119 "multiple values for duration",
16120 ));
16121 }
16122 result.duration =
16123 map.next_value::<std::option::Option<wkt::Duration>>()?;
16124 }
16125 __FieldTag::Unknown(key) => {
16126 let value = map.next_value::<serde_json::Value>()?;
16127 result._unknown_fields.insert(key, value);
16128 }
16129 }
16130 }
16131 std::result::Result::Ok(result)
16132 }
16133 }
16134 deserializer.deserialize_any(Visitor)
16135 }
16136 }
16137
16138 #[doc(hidden)]
16139 impl serde::ser::Serialize for Break {
16140 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16141 where
16142 S: serde::ser::Serializer,
16143 {
16144 use serde::ser::SerializeMap;
16145 #[allow(unused_imports)]
16146 use std::option::Option::Some;
16147 let mut state = serializer.serialize_map(std::option::Option::None)?;
16148 if self.start_time.is_some() {
16149 state.serialize_entry("startTime", &self.start_time)?;
16150 }
16151 if self.duration.is_some() {
16152 state.serialize_entry("duration", &self.duration)?;
16153 }
16154 if !self._unknown_fields.is_empty() {
16155 for (key, value) in self._unknown_fields.iter() {
16156 state.serialize_entry(key, &value)?;
16157 }
16158 }
16159 state.end()
16160 }
16161 }
16162
16163 #[derive(Clone, Debug, Default, PartialEq)]
16180 #[non_exhaustive]
16181 #[deprecated]
16182 pub struct TravelStep {
16183 pub duration: std::option::Option<wkt::Duration>,
16185
16186 pub distance_meters: f64,
16188
16189 pub traffic_info_unavailable: bool,
16197
16198 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
16207
16208 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16209 }
16210
16211 impl TravelStep {
16212 pub fn new() -> Self {
16213 std::default::Default::default()
16214 }
16215
16216 pub fn set_duration<T>(mut self, v: T) -> Self
16218 where
16219 T: std::convert::Into<wkt::Duration>,
16220 {
16221 self.duration = std::option::Option::Some(v.into());
16222 self
16223 }
16224
16225 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
16227 where
16228 T: std::convert::Into<wkt::Duration>,
16229 {
16230 self.duration = v.map(|x| x.into());
16231 self
16232 }
16233
16234 pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
16236 self.distance_meters = v.into();
16237 self
16238 }
16239
16240 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
16242 self.traffic_info_unavailable = v.into();
16243 self
16244 }
16245
16246 pub fn set_route_polyline<T>(mut self, v: T) -> Self
16248 where
16249 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
16250 {
16251 self.route_polyline = std::option::Option::Some(v.into());
16252 self
16253 }
16254
16255 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
16257 where
16258 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
16259 {
16260 self.route_polyline = v.map(|x| x.into());
16261 self
16262 }
16263 }
16264
16265 impl wkt::message::Message for TravelStep {
16266 fn typename() -> &'static str {
16267 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
16268 }
16269 }
16270
16271 #[doc(hidden)]
16272 impl<'de> serde::de::Deserialize<'de> for TravelStep {
16273 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16274 where
16275 D: serde::Deserializer<'de>,
16276 {
16277 #[allow(non_camel_case_types)]
16278 #[doc(hidden)]
16279 #[derive(PartialEq, Eq, Hash)]
16280 enum __FieldTag {
16281 __duration,
16282 __distance_meters,
16283 __traffic_info_unavailable,
16284 __route_polyline,
16285 Unknown(std::string::String),
16286 }
16287 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16288 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16289 where
16290 D: serde::Deserializer<'de>,
16291 {
16292 struct Visitor;
16293 impl<'de> serde::de::Visitor<'de> for Visitor {
16294 type Value = __FieldTag;
16295 fn expecting(
16296 &self,
16297 formatter: &mut std::fmt::Formatter,
16298 ) -> std::fmt::Result {
16299 formatter.write_str("a field name for TravelStep")
16300 }
16301 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16302 where
16303 E: serde::de::Error,
16304 {
16305 use std::result::Result::Ok;
16306 use std::string::ToString;
16307 match value {
16308 "duration" => Ok(__FieldTag::__duration),
16309 "distanceMeters" => Ok(__FieldTag::__distance_meters),
16310 "distance_meters" => Ok(__FieldTag::__distance_meters),
16311 "trafficInfoUnavailable" => {
16312 Ok(__FieldTag::__traffic_info_unavailable)
16313 }
16314 "traffic_info_unavailable" => {
16315 Ok(__FieldTag::__traffic_info_unavailable)
16316 }
16317 "routePolyline" => Ok(__FieldTag::__route_polyline),
16318 "route_polyline" => Ok(__FieldTag::__route_polyline),
16319 _ => Ok(__FieldTag::Unknown(value.to_string())),
16320 }
16321 }
16322 }
16323 deserializer.deserialize_identifier(Visitor)
16324 }
16325 }
16326 struct Visitor;
16327 impl<'de> serde::de::Visitor<'de> for Visitor {
16328 type Value = TravelStep;
16329 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16330 formatter.write_str("struct TravelStep")
16331 }
16332 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16333 where
16334 A: serde::de::MapAccess<'de>,
16335 {
16336 #[allow(unused_imports)]
16337 use serde::de::Error;
16338 use std::option::Option::Some;
16339 let mut fields = std::collections::HashSet::new();
16340 let mut result = Self::Value::new();
16341 while let Some(tag) = map.next_key::<__FieldTag>()? {
16342 #[allow(clippy::match_single_binding)]
16343 match tag {
16344 __FieldTag::__duration => {
16345 if !fields.insert(__FieldTag::__duration) {
16346 return std::result::Result::Err(A::Error::duplicate_field(
16347 "multiple values for duration",
16348 ));
16349 }
16350 result.duration =
16351 map.next_value::<std::option::Option<wkt::Duration>>()?;
16352 }
16353 __FieldTag::__distance_meters => {
16354 if !fields.insert(__FieldTag::__distance_meters) {
16355 return std::result::Result::Err(A::Error::duplicate_field(
16356 "multiple values for distance_meters",
16357 ));
16358 }
16359 struct __With(std::option::Option<f64>);
16360 impl<'de> serde::de::Deserialize<'de> for __With {
16361 fn deserialize<D>(
16362 deserializer: D,
16363 ) -> std::result::Result<Self, D::Error>
16364 where
16365 D: serde::de::Deserializer<'de>,
16366 {
16367 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
16368 }
16369 }
16370 result.distance_meters =
16371 map.next_value::<__With>()?.0.unwrap_or_default();
16372 }
16373 __FieldTag::__traffic_info_unavailable => {
16374 if !fields.insert(__FieldTag::__traffic_info_unavailable) {
16375 return std::result::Result::Err(A::Error::duplicate_field(
16376 "multiple values for traffic_info_unavailable",
16377 ));
16378 }
16379 result.traffic_info_unavailable = map
16380 .next_value::<std::option::Option<bool>>()?
16381 .unwrap_or_default();
16382 }
16383 __FieldTag::__route_polyline => {
16384 if !fields.insert(__FieldTag::__route_polyline) {
16385 return std::result::Result::Err(A::Error::duplicate_field(
16386 "multiple values for route_polyline",
16387 ));
16388 }
16389 result.route_polyline = map.next_value::<std::option::Option<
16390 crate::model::shipment_route::EncodedPolyline,
16391 >>()?;
16392 }
16393 __FieldTag::Unknown(key) => {
16394 let value = map.next_value::<serde_json::Value>()?;
16395 result._unknown_fields.insert(key, value);
16396 }
16397 }
16398 }
16399 std::result::Result::Ok(result)
16400 }
16401 }
16402 deserializer.deserialize_any(Visitor)
16403 }
16404 }
16405
16406 #[doc(hidden)]
16407 impl serde::ser::Serialize for TravelStep {
16408 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16409 where
16410 S: serde::ser::Serializer,
16411 {
16412 use serde::ser::SerializeMap;
16413 #[allow(unused_imports)]
16414 use std::option::Option::Some;
16415 let mut state = serializer.serialize_map(std::option::Option::None)?;
16416 if self.duration.is_some() {
16417 state.serialize_entry("duration", &self.duration)?;
16418 }
16419 if !wkt::internal::is_default(&self.distance_meters) {
16420 struct __With<'a>(&'a f64);
16421 impl<'a> serde::ser::Serialize for __With<'a> {
16422 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16423 where
16424 S: serde::ser::Serializer,
16425 {
16426 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
16427 }
16428 }
16429 state.serialize_entry("distanceMeters", &__With(&self.distance_meters))?;
16430 }
16431 if !wkt::internal::is_default(&self.traffic_info_unavailable) {
16432 state.serialize_entry("trafficInfoUnavailable", &self.traffic_info_unavailable)?;
16433 }
16434 if self.route_polyline.is_some() {
16435 state.serialize_entry("routePolyline", &self.route_polyline)?;
16436 }
16437 if !self._unknown_fields.is_empty() {
16438 for (key, value) in self._unknown_fields.iter() {
16439 state.serialize_entry(key, &value)?;
16440 }
16441 }
16442 state.end()
16443 }
16444 }
16445}
16446
16447#[derive(Clone, Debug, Default, PartialEq)]
16451#[non_exhaustive]
16452pub struct SkippedShipment {
16453 pub index: i32,
16456
16457 pub label: std::string::String,
16463
16464 pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
16467
16468 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16469}
16470
16471impl SkippedShipment {
16472 pub fn new() -> Self {
16473 std::default::Default::default()
16474 }
16475
16476 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
16478 self.index = v.into();
16479 self
16480 }
16481
16482 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
16484 self.label = v.into();
16485 self
16486 }
16487
16488 pub fn set_reasons<T, V>(mut self, v: T) -> Self
16490 where
16491 T: std::iter::IntoIterator<Item = V>,
16492 V: std::convert::Into<crate::model::skipped_shipment::Reason>,
16493 {
16494 use std::iter::Iterator;
16495 self.reasons = v.into_iter().map(|i| i.into()).collect();
16496 self
16497 }
16498}
16499
16500impl wkt::message::Message for SkippedShipment {
16501 fn typename() -> &'static str {
16502 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
16503 }
16504}
16505
16506#[doc(hidden)]
16507impl<'de> serde::de::Deserialize<'de> for SkippedShipment {
16508 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16509 where
16510 D: serde::Deserializer<'de>,
16511 {
16512 #[allow(non_camel_case_types)]
16513 #[doc(hidden)]
16514 #[derive(PartialEq, Eq, Hash)]
16515 enum __FieldTag {
16516 __index,
16517 __label,
16518 __reasons,
16519 Unknown(std::string::String),
16520 }
16521 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16522 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16523 where
16524 D: serde::Deserializer<'de>,
16525 {
16526 struct Visitor;
16527 impl<'de> serde::de::Visitor<'de> for Visitor {
16528 type Value = __FieldTag;
16529 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16530 formatter.write_str("a field name for SkippedShipment")
16531 }
16532 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16533 where
16534 E: serde::de::Error,
16535 {
16536 use std::result::Result::Ok;
16537 use std::string::ToString;
16538 match value {
16539 "index" => Ok(__FieldTag::__index),
16540 "label" => Ok(__FieldTag::__label),
16541 "reasons" => Ok(__FieldTag::__reasons),
16542 _ => Ok(__FieldTag::Unknown(value.to_string())),
16543 }
16544 }
16545 }
16546 deserializer.deserialize_identifier(Visitor)
16547 }
16548 }
16549 struct Visitor;
16550 impl<'de> serde::de::Visitor<'de> for Visitor {
16551 type Value = SkippedShipment;
16552 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16553 formatter.write_str("struct SkippedShipment")
16554 }
16555 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16556 where
16557 A: serde::de::MapAccess<'de>,
16558 {
16559 #[allow(unused_imports)]
16560 use serde::de::Error;
16561 use std::option::Option::Some;
16562 let mut fields = std::collections::HashSet::new();
16563 let mut result = Self::Value::new();
16564 while let Some(tag) = map.next_key::<__FieldTag>()? {
16565 #[allow(clippy::match_single_binding)]
16566 match tag {
16567 __FieldTag::__index => {
16568 if !fields.insert(__FieldTag::__index) {
16569 return std::result::Result::Err(A::Error::duplicate_field(
16570 "multiple values for index",
16571 ));
16572 }
16573 struct __With(std::option::Option<i32>);
16574 impl<'de> serde::de::Deserialize<'de> for __With {
16575 fn deserialize<D>(
16576 deserializer: D,
16577 ) -> std::result::Result<Self, D::Error>
16578 where
16579 D: serde::de::Deserializer<'de>,
16580 {
16581 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
16582 }
16583 }
16584 result.index = map.next_value::<__With>()?.0.unwrap_or_default();
16585 }
16586 __FieldTag::__label => {
16587 if !fields.insert(__FieldTag::__label) {
16588 return std::result::Result::Err(A::Error::duplicate_field(
16589 "multiple values for label",
16590 ));
16591 }
16592 result.label = map
16593 .next_value::<std::option::Option<std::string::String>>()?
16594 .unwrap_or_default();
16595 }
16596 __FieldTag::__reasons => {
16597 if !fields.insert(__FieldTag::__reasons) {
16598 return std::result::Result::Err(A::Error::duplicate_field(
16599 "multiple values for reasons",
16600 ));
16601 }
16602 result.reasons = map
16603 .next_value::<std::option::Option<
16604 std::vec::Vec<crate::model::skipped_shipment::Reason>,
16605 >>()?
16606 .unwrap_or_default();
16607 }
16608 __FieldTag::Unknown(key) => {
16609 let value = map.next_value::<serde_json::Value>()?;
16610 result._unknown_fields.insert(key, value);
16611 }
16612 }
16613 }
16614 std::result::Result::Ok(result)
16615 }
16616 }
16617 deserializer.deserialize_any(Visitor)
16618 }
16619}
16620
16621#[doc(hidden)]
16622impl serde::ser::Serialize for SkippedShipment {
16623 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16624 where
16625 S: serde::ser::Serializer,
16626 {
16627 use serde::ser::SerializeMap;
16628 #[allow(unused_imports)]
16629 use std::option::Option::Some;
16630 let mut state = serializer.serialize_map(std::option::Option::None)?;
16631 if !wkt::internal::is_default(&self.index) {
16632 struct __With<'a>(&'a i32);
16633 impl<'a> serde::ser::Serialize for __With<'a> {
16634 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16635 where
16636 S: serde::ser::Serializer,
16637 {
16638 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
16639 }
16640 }
16641 state.serialize_entry("index", &__With(&self.index))?;
16642 }
16643 if !self.label.is_empty() {
16644 state.serialize_entry("label", &self.label)?;
16645 }
16646 if !self.reasons.is_empty() {
16647 state.serialize_entry("reasons", &self.reasons)?;
16648 }
16649 if !self._unknown_fields.is_empty() {
16650 for (key, value) in self._unknown_fields.iter() {
16651 state.serialize_entry(key, &value)?;
16652 }
16653 }
16654 state.end()
16655 }
16656}
16657
16658pub mod skipped_shipment {
16660 #[allow(unused_imports)]
16661 use super::*;
16662
16663 #[derive(Clone, Debug, Default, PartialEq)]
16692 #[non_exhaustive]
16693 pub struct Reason {
16694 pub code: crate::model::skipped_shipment::reason::Code,
16696
16697 pub example_vehicle_index: std::option::Option<i32>,
16700
16701 pub example_exceeded_capacity_type: std::string::String,
16704
16705 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
16706 }
16707
16708 impl Reason {
16709 pub fn new() -> Self {
16710 std::default::Default::default()
16711 }
16712
16713 pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
16715 mut self,
16716 v: T,
16717 ) -> Self {
16718 self.code = v.into();
16719 self
16720 }
16721
16722 pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
16724 where
16725 T: std::convert::Into<i32>,
16726 {
16727 self.example_vehicle_index = std::option::Option::Some(v.into());
16728 self
16729 }
16730
16731 pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
16733 where
16734 T: std::convert::Into<i32>,
16735 {
16736 self.example_vehicle_index = v.map(|x| x.into());
16737 self
16738 }
16739
16740 pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
16742 mut self,
16743 v: T,
16744 ) -> Self {
16745 self.example_exceeded_capacity_type = v.into();
16746 self
16747 }
16748 }
16749
16750 impl wkt::message::Message for Reason {
16751 fn typename() -> &'static str {
16752 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
16753 }
16754 }
16755
16756 #[doc(hidden)]
16757 impl<'de> serde::de::Deserialize<'de> for Reason {
16758 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16759 where
16760 D: serde::Deserializer<'de>,
16761 {
16762 #[allow(non_camel_case_types)]
16763 #[doc(hidden)]
16764 #[derive(PartialEq, Eq, Hash)]
16765 enum __FieldTag {
16766 __code,
16767 __example_vehicle_index,
16768 __example_exceeded_capacity_type,
16769 Unknown(std::string::String),
16770 }
16771 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
16772 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
16773 where
16774 D: serde::Deserializer<'de>,
16775 {
16776 struct Visitor;
16777 impl<'de> serde::de::Visitor<'de> for Visitor {
16778 type Value = __FieldTag;
16779 fn expecting(
16780 &self,
16781 formatter: &mut std::fmt::Formatter,
16782 ) -> std::fmt::Result {
16783 formatter.write_str("a field name for Reason")
16784 }
16785 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
16786 where
16787 E: serde::de::Error,
16788 {
16789 use std::result::Result::Ok;
16790 use std::string::ToString;
16791 match value {
16792 "code" => Ok(__FieldTag::__code),
16793 "exampleVehicleIndex" => Ok(__FieldTag::__example_vehicle_index),
16794 "example_vehicle_index" => Ok(__FieldTag::__example_vehicle_index),
16795 "exampleExceededCapacityType" => {
16796 Ok(__FieldTag::__example_exceeded_capacity_type)
16797 }
16798 "example_exceeded_capacity_type" => {
16799 Ok(__FieldTag::__example_exceeded_capacity_type)
16800 }
16801 _ => Ok(__FieldTag::Unknown(value.to_string())),
16802 }
16803 }
16804 }
16805 deserializer.deserialize_identifier(Visitor)
16806 }
16807 }
16808 struct Visitor;
16809 impl<'de> serde::de::Visitor<'de> for Visitor {
16810 type Value = Reason;
16811 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
16812 formatter.write_str("struct Reason")
16813 }
16814 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
16815 where
16816 A: serde::de::MapAccess<'de>,
16817 {
16818 #[allow(unused_imports)]
16819 use serde::de::Error;
16820 use std::option::Option::Some;
16821 let mut fields = std::collections::HashSet::new();
16822 let mut result = Self::Value::new();
16823 while let Some(tag) = map.next_key::<__FieldTag>()? {
16824 #[allow(clippy::match_single_binding)]
16825 match tag {
16826 __FieldTag::__code => {
16827 if !fields.insert(__FieldTag::__code) {
16828 return std::result::Result::Err(A::Error::duplicate_field(
16829 "multiple values for code",
16830 ));
16831 }
16832 result.code = map
16833 .next_value::<std::option::Option<
16834 crate::model::skipped_shipment::reason::Code,
16835 >>()?
16836 .unwrap_or_default();
16837 }
16838 __FieldTag::__example_vehicle_index => {
16839 if !fields.insert(__FieldTag::__example_vehicle_index) {
16840 return std::result::Result::Err(A::Error::duplicate_field(
16841 "multiple values for example_vehicle_index",
16842 ));
16843 }
16844 struct __With(std::option::Option<i32>);
16845 impl<'de> serde::de::Deserialize<'de> for __With {
16846 fn deserialize<D>(
16847 deserializer: D,
16848 ) -> std::result::Result<Self, D::Error>
16849 where
16850 D: serde::de::Deserializer<'de>,
16851 {
16852 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
16853 }
16854 }
16855 result.example_vehicle_index = map.next_value::<__With>()?.0;
16856 }
16857 __FieldTag::__example_exceeded_capacity_type => {
16858 if !fields.insert(__FieldTag::__example_exceeded_capacity_type) {
16859 return std::result::Result::Err(A::Error::duplicate_field(
16860 "multiple values for example_exceeded_capacity_type",
16861 ));
16862 }
16863 result.example_exceeded_capacity_type = map
16864 .next_value::<std::option::Option<std::string::String>>()?
16865 .unwrap_or_default();
16866 }
16867 __FieldTag::Unknown(key) => {
16868 let value = map.next_value::<serde_json::Value>()?;
16869 result._unknown_fields.insert(key, value);
16870 }
16871 }
16872 }
16873 std::result::Result::Ok(result)
16874 }
16875 }
16876 deserializer.deserialize_any(Visitor)
16877 }
16878 }
16879
16880 #[doc(hidden)]
16881 impl serde::ser::Serialize for Reason {
16882 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16883 where
16884 S: serde::ser::Serializer,
16885 {
16886 use serde::ser::SerializeMap;
16887 #[allow(unused_imports)]
16888 use std::option::Option::Some;
16889 let mut state = serializer.serialize_map(std::option::Option::None)?;
16890 if !wkt::internal::is_default(&self.code) {
16891 state.serialize_entry("code", &self.code)?;
16892 }
16893 if self.example_vehicle_index.is_some() {
16894 struct __With<'a>(&'a std::option::Option<i32>);
16895 impl<'a> serde::ser::Serialize for __With<'a> {
16896 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
16897 where
16898 S: serde::ser::Serializer,
16899 {
16900 serde_with::As::<std::option::Option<wkt::internal::I32>>::serialize(
16901 self.0, serializer,
16902 )
16903 }
16904 }
16905 state
16906 .serialize_entry("exampleVehicleIndex", &__With(&self.example_vehicle_index))?;
16907 }
16908 if !self.example_exceeded_capacity_type.is_empty() {
16909 state.serialize_entry(
16910 "exampleExceededCapacityType",
16911 &self.example_exceeded_capacity_type,
16912 )?;
16913 }
16914 if !self._unknown_fields.is_empty() {
16915 for (key, value) in self._unknown_fields.iter() {
16916 state.serialize_entry(key, &value)?;
16917 }
16918 }
16919 state.end()
16920 }
16921 }
16922
16923 pub mod reason {
16925 #[allow(unused_imports)]
16926 use super::*;
16927
16928 #[derive(Clone, Debug, PartialEq)]
16946 #[non_exhaustive]
16947 pub enum Code {
16948 Unspecified,
16951 NoVehicle,
16953 DemandExceedsVehicleCapacity,
16956 CannotBePerformedWithinVehicleDistanceLimit,
16963 CannotBePerformedWithinVehicleDurationLimit,
16970 CannotBePerformedWithinVehicleTravelDurationLimit,
16973 CannotBePerformedWithinVehicleTimeWindows,
16978 VehicleNotAllowed,
16981 UnknownValue(code::UnknownValue),
16986 }
16987
16988 #[doc(hidden)]
16989 pub mod code {
16990 #[allow(unused_imports)]
16991 use super::*;
16992 #[derive(Clone, Debug, PartialEq)]
16993 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
16994 }
16995
16996 impl Code {
16997 pub fn value(&self) -> std::option::Option<i32> {
17002 match self {
17003 Self::Unspecified => std::option::Option::Some(0),
17004 Self::NoVehicle => std::option::Option::Some(1),
17005 Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
17006 Self::CannotBePerformedWithinVehicleDistanceLimit => {
17007 std::option::Option::Some(3)
17008 }
17009 Self::CannotBePerformedWithinVehicleDurationLimit => {
17010 std::option::Option::Some(4)
17011 }
17012 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17013 std::option::Option::Some(5)
17014 }
17015 Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
17016 Self::VehicleNotAllowed => std::option::Option::Some(7),
17017 Self::UnknownValue(u) => u.0.value(),
17018 }
17019 }
17020
17021 pub fn name(&self) -> std::option::Option<&str> {
17026 match self {
17027 Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
17028 Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
17029 Self::DemandExceedsVehicleCapacity => {
17030 std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
17031 }
17032 Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
17033 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
17034 ),
17035 Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
17036 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
17037 ),
17038 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17039 std::option::Option::Some(
17040 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
17041 )
17042 }
17043 Self::CannotBePerformedWithinVehicleTimeWindows => {
17044 std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
17045 }
17046 Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
17047 Self::UnknownValue(u) => u.0.name(),
17048 }
17049 }
17050 }
17051
17052 impl std::default::Default for Code {
17053 fn default() -> Self {
17054 use std::convert::From;
17055 Self::from(0)
17056 }
17057 }
17058
17059 impl std::fmt::Display for Code {
17060 fn fmt(
17061 &self,
17062 f: &mut std::fmt::Formatter<'_>,
17063 ) -> std::result::Result<(), std::fmt::Error> {
17064 wkt::internal::display_enum(f, self.name(), self.value())
17065 }
17066 }
17067
17068 impl std::convert::From<i32> for Code {
17069 fn from(value: i32) -> Self {
17070 match value {
17071 0 => Self::Unspecified,
17072 1 => Self::NoVehicle,
17073 2 => Self::DemandExceedsVehicleCapacity,
17074 3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
17075 4 => Self::CannotBePerformedWithinVehicleDurationLimit,
17076 5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
17077 6 => Self::CannotBePerformedWithinVehicleTimeWindows,
17078 7 => Self::VehicleNotAllowed,
17079 _ => Self::UnknownValue(code::UnknownValue(
17080 wkt::internal::UnknownEnumValue::Integer(value),
17081 )),
17082 }
17083 }
17084 }
17085
17086 impl std::convert::From<&str> for Code {
17087 fn from(value: &str) -> Self {
17088 use std::string::ToString;
17089 match value {
17090 "CODE_UNSPECIFIED" => Self::Unspecified,
17091 "NO_VEHICLE" => Self::NoVehicle,
17092 "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
17093 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
17094 Self::CannotBePerformedWithinVehicleDistanceLimit
17095 }
17096 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
17097 Self::CannotBePerformedWithinVehicleDurationLimit
17098 }
17099 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
17100 Self::CannotBePerformedWithinVehicleTravelDurationLimit
17101 }
17102 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
17103 Self::CannotBePerformedWithinVehicleTimeWindows
17104 }
17105 "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
17106 _ => Self::UnknownValue(code::UnknownValue(
17107 wkt::internal::UnknownEnumValue::String(value.to_string()),
17108 )),
17109 }
17110 }
17111 }
17112
17113 impl serde::ser::Serialize for Code {
17114 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17115 where
17116 S: serde::Serializer,
17117 {
17118 match self {
17119 Self::Unspecified => serializer.serialize_i32(0),
17120 Self::NoVehicle => serializer.serialize_i32(1),
17121 Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
17122 Self::CannotBePerformedWithinVehicleDistanceLimit => {
17123 serializer.serialize_i32(3)
17124 }
17125 Self::CannotBePerformedWithinVehicleDurationLimit => {
17126 serializer.serialize_i32(4)
17127 }
17128 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
17129 serializer.serialize_i32(5)
17130 }
17131 Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
17132 Self::VehicleNotAllowed => serializer.serialize_i32(7),
17133 Self::UnknownValue(u) => u.0.serialize(serializer),
17134 }
17135 }
17136 }
17137
17138 impl<'de> serde::de::Deserialize<'de> for Code {
17139 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17140 where
17141 D: serde::Deserializer<'de>,
17142 {
17143 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
17144 ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
17145 ))
17146 }
17147 }
17148 }
17149}
17150
17151#[derive(Clone, Debug, Default, PartialEq)]
17163#[non_exhaustive]
17164pub struct AggregatedMetrics {
17165 pub performed_shipment_count: i32,
17168
17169 pub travel_duration: std::option::Option<wkt::Duration>,
17171
17172 pub wait_duration: std::option::Option<wkt::Duration>,
17174
17175 pub delay_duration: std::option::Option<wkt::Duration>,
17177
17178 pub break_duration: std::option::Option<wkt::Duration>,
17180
17181 pub visit_duration: std::option::Option<wkt::Duration>,
17183
17184 pub total_duration: std::option::Option<wkt::Duration>,
17193
17194 pub travel_distance_meters: f64,
17196
17197 pub max_loads:
17207 std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
17208
17209 #[deprecated]
17218 pub costs: std::collections::HashMap<std::string::String, f64>,
17219
17220 #[deprecated]
17229 pub total_cost: f64,
17230
17231 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17232}
17233
17234impl AggregatedMetrics {
17235 pub fn new() -> Self {
17236 std::default::Default::default()
17237 }
17238
17239 pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
17241 self.performed_shipment_count = v.into();
17242 self
17243 }
17244
17245 pub fn set_travel_duration<T>(mut self, v: T) -> Self
17247 where
17248 T: std::convert::Into<wkt::Duration>,
17249 {
17250 self.travel_duration = std::option::Option::Some(v.into());
17251 self
17252 }
17253
17254 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
17256 where
17257 T: std::convert::Into<wkt::Duration>,
17258 {
17259 self.travel_duration = v.map(|x| x.into());
17260 self
17261 }
17262
17263 pub fn set_wait_duration<T>(mut self, v: T) -> Self
17265 where
17266 T: std::convert::Into<wkt::Duration>,
17267 {
17268 self.wait_duration = std::option::Option::Some(v.into());
17269 self
17270 }
17271
17272 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
17274 where
17275 T: std::convert::Into<wkt::Duration>,
17276 {
17277 self.wait_duration = v.map(|x| x.into());
17278 self
17279 }
17280
17281 pub fn set_delay_duration<T>(mut self, v: T) -> Self
17283 where
17284 T: std::convert::Into<wkt::Duration>,
17285 {
17286 self.delay_duration = std::option::Option::Some(v.into());
17287 self
17288 }
17289
17290 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
17292 where
17293 T: std::convert::Into<wkt::Duration>,
17294 {
17295 self.delay_duration = v.map(|x| x.into());
17296 self
17297 }
17298
17299 pub fn set_break_duration<T>(mut self, v: T) -> Self
17301 where
17302 T: std::convert::Into<wkt::Duration>,
17303 {
17304 self.break_duration = std::option::Option::Some(v.into());
17305 self
17306 }
17307
17308 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
17310 where
17311 T: std::convert::Into<wkt::Duration>,
17312 {
17313 self.break_duration = v.map(|x| x.into());
17314 self
17315 }
17316
17317 pub fn set_visit_duration<T>(mut self, v: T) -> Self
17319 where
17320 T: std::convert::Into<wkt::Duration>,
17321 {
17322 self.visit_duration = std::option::Option::Some(v.into());
17323 self
17324 }
17325
17326 pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
17328 where
17329 T: std::convert::Into<wkt::Duration>,
17330 {
17331 self.visit_duration = v.map(|x| x.into());
17332 self
17333 }
17334
17335 pub fn set_total_duration<T>(mut self, v: T) -> Self
17337 where
17338 T: std::convert::Into<wkt::Duration>,
17339 {
17340 self.total_duration = std::option::Option::Some(v.into());
17341 self
17342 }
17343
17344 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
17346 where
17347 T: std::convert::Into<wkt::Duration>,
17348 {
17349 self.total_duration = v.map(|x| x.into());
17350 self
17351 }
17352
17353 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
17355 self.travel_distance_meters = v.into();
17356 self
17357 }
17358
17359 pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
17361 where
17362 T: std::iter::IntoIterator<Item = (K, V)>,
17363 K: std::convert::Into<std::string::String>,
17364 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
17365 {
17366 use std::iter::Iterator;
17367 self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
17368 self
17369 }
17370
17371 #[deprecated]
17373 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
17374 where
17375 T: std::iter::IntoIterator<Item = (K, V)>,
17376 K: std::convert::Into<std::string::String>,
17377 V: std::convert::Into<f64>,
17378 {
17379 use std::iter::Iterator;
17380 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
17381 self
17382 }
17383
17384 #[deprecated]
17386 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
17387 self.total_cost = v.into();
17388 self
17389 }
17390}
17391
17392impl wkt::message::Message for AggregatedMetrics {
17393 fn typename() -> &'static str {
17394 "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
17395 }
17396}
17397
17398#[doc(hidden)]
17399impl<'de> serde::de::Deserialize<'de> for AggregatedMetrics {
17400 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17401 where
17402 D: serde::Deserializer<'de>,
17403 {
17404 #[allow(non_camel_case_types)]
17405 #[doc(hidden)]
17406 #[derive(PartialEq, Eq, Hash)]
17407 enum __FieldTag {
17408 __performed_shipment_count,
17409 __travel_duration,
17410 __wait_duration,
17411 __delay_duration,
17412 __break_duration,
17413 __visit_duration,
17414 __total_duration,
17415 __travel_distance_meters,
17416 __max_loads,
17417 __costs,
17418 __total_cost,
17419 Unknown(std::string::String),
17420 }
17421 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17422 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17423 where
17424 D: serde::Deserializer<'de>,
17425 {
17426 struct Visitor;
17427 impl<'de> serde::de::Visitor<'de> for Visitor {
17428 type Value = __FieldTag;
17429 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17430 formatter.write_str("a field name for AggregatedMetrics")
17431 }
17432 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17433 where
17434 E: serde::de::Error,
17435 {
17436 use std::result::Result::Ok;
17437 use std::string::ToString;
17438 match value {
17439 "performedShipmentCount" => Ok(__FieldTag::__performed_shipment_count),
17440 "performed_shipment_count" => {
17441 Ok(__FieldTag::__performed_shipment_count)
17442 }
17443 "travelDuration" => Ok(__FieldTag::__travel_duration),
17444 "travel_duration" => Ok(__FieldTag::__travel_duration),
17445 "waitDuration" => Ok(__FieldTag::__wait_duration),
17446 "wait_duration" => Ok(__FieldTag::__wait_duration),
17447 "delayDuration" => Ok(__FieldTag::__delay_duration),
17448 "delay_duration" => Ok(__FieldTag::__delay_duration),
17449 "breakDuration" => Ok(__FieldTag::__break_duration),
17450 "break_duration" => Ok(__FieldTag::__break_duration),
17451 "visitDuration" => Ok(__FieldTag::__visit_duration),
17452 "visit_duration" => Ok(__FieldTag::__visit_duration),
17453 "totalDuration" => Ok(__FieldTag::__total_duration),
17454 "total_duration" => Ok(__FieldTag::__total_duration),
17455 "travelDistanceMeters" => Ok(__FieldTag::__travel_distance_meters),
17456 "travel_distance_meters" => Ok(__FieldTag::__travel_distance_meters),
17457 "maxLoads" => Ok(__FieldTag::__max_loads),
17458 "max_loads" => Ok(__FieldTag::__max_loads),
17459 "costs" => Ok(__FieldTag::__costs),
17460 "totalCost" => Ok(__FieldTag::__total_cost),
17461 "total_cost" => Ok(__FieldTag::__total_cost),
17462 _ => Ok(__FieldTag::Unknown(value.to_string())),
17463 }
17464 }
17465 }
17466 deserializer.deserialize_identifier(Visitor)
17467 }
17468 }
17469 struct Visitor;
17470 impl<'de> serde::de::Visitor<'de> for Visitor {
17471 type Value = AggregatedMetrics;
17472 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17473 formatter.write_str("struct AggregatedMetrics")
17474 }
17475 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17476 where
17477 A: serde::de::MapAccess<'de>,
17478 {
17479 #[allow(unused_imports)]
17480 use serde::de::Error;
17481 use std::option::Option::Some;
17482 let mut fields = std::collections::HashSet::new();
17483 let mut result = Self::Value::new();
17484 while let Some(tag) = map.next_key::<__FieldTag>()? {
17485 #[allow(clippy::match_single_binding)]
17486 match tag {
17487 __FieldTag::__performed_shipment_count => {
17488 if !fields.insert(__FieldTag::__performed_shipment_count) {
17489 return std::result::Result::Err(A::Error::duplicate_field(
17490 "multiple values for performed_shipment_count",
17491 ));
17492 }
17493 struct __With(std::option::Option<i32>);
17494 impl<'de> serde::de::Deserialize<'de> for __With {
17495 fn deserialize<D>(
17496 deserializer: D,
17497 ) -> std::result::Result<Self, D::Error>
17498 where
17499 D: serde::de::Deserializer<'de>,
17500 {
17501 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
17502 }
17503 }
17504 result.performed_shipment_count =
17505 map.next_value::<__With>()?.0.unwrap_or_default();
17506 }
17507 __FieldTag::__travel_duration => {
17508 if !fields.insert(__FieldTag::__travel_duration) {
17509 return std::result::Result::Err(A::Error::duplicate_field(
17510 "multiple values for travel_duration",
17511 ));
17512 }
17513 result.travel_duration =
17514 map.next_value::<std::option::Option<wkt::Duration>>()?;
17515 }
17516 __FieldTag::__wait_duration => {
17517 if !fields.insert(__FieldTag::__wait_duration) {
17518 return std::result::Result::Err(A::Error::duplicate_field(
17519 "multiple values for wait_duration",
17520 ));
17521 }
17522 result.wait_duration =
17523 map.next_value::<std::option::Option<wkt::Duration>>()?;
17524 }
17525 __FieldTag::__delay_duration => {
17526 if !fields.insert(__FieldTag::__delay_duration) {
17527 return std::result::Result::Err(A::Error::duplicate_field(
17528 "multiple values for delay_duration",
17529 ));
17530 }
17531 result.delay_duration =
17532 map.next_value::<std::option::Option<wkt::Duration>>()?;
17533 }
17534 __FieldTag::__break_duration => {
17535 if !fields.insert(__FieldTag::__break_duration) {
17536 return std::result::Result::Err(A::Error::duplicate_field(
17537 "multiple values for break_duration",
17538 ));
17539 }
17540 result.break_duration =
17541 map.next_value::<std::option::Option<wkt::Duration>>()?;
17542 }
17543 __FieldTag::__visit_duration => {
17544 if !fields.insert(__FieldTag::__visit_duration) {
17545 return std::result::Result::Err(A::Error::duplicate_field(
17546 "multiple values for visit_duration",
17547 ));
17548 }
17549 result.visit_duration =
17550 map.next_value::<std::option::Option<wkt::Duration>>()?;
17551 }
17552 __FieldTag::__total_duration => {
17553 if !fields.insert(__FieldTag::__total_duration) {
17554 return std::result::Result::Err(A::Error::duplicate_field(
17555 "multiple values for total_duration",
17556 ));
17557 }
17558 result.total_duration =
17559 map.next_value::<std::option::Option<wkt::Duration>>()?;
17560 }
17561 __FieldTag::__travel_distance_meters => {
17562 if !fields.insert(__FieldTag::__travel_distance_meters) {
17563 return std::result::Result::Err(A::Error::duplicate_field(
17564 "multiple values for travel_distance_meters",
17565 ));
17566 }
17567 struct __With(std::option::Option<f64>);
17568 impl<'de> serde::de::Deserialize<'de> for __With {
17569 fn deserialize<D>(
17570 deserializer: D,
17571 ) -> std::result::Result<Self, D::Error>
17572 where
17573 D: serde::de::Deserializer<'de>,
17574 {
17575 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
17576 }
17577 }
17578 result.travel_distance_meters =
17579 map.next_value::<__With>()?.0.unwrap_or_default();
17580 }
17581 __FieldTag::__max_loads => {
17582 if !fields.insert(__FieldTag::__max_loads) {
17583 return std::result::Result::Err(A::Error::duplicate_field(
17584 "multiple values for max_loads",
17585 ));
17586 }
17587 result.max_loads = map
17588 .next_value::<std::option::Option<
17589 std::collections::HashMap<
17590 std::string::String,
17591 crate::model::shipment_route::VehicleLoad,
17592 >,
17593 >>()?
17594 .unwrap_or_default();
17595 }
17596 __FieldTag::__costs => {
17597 if !fields.insert(__FieldTag::__costs) {
17598 return std::result::Result::Err(A::Error::duplicate_field(
17599 "multiple values for costs",
17600 ));
17601 }
17602 struct __With(
17603 std::option::Option<
17604 std::collections::HashMap<std::string::String, f64>,
17605 >,
17606 );
17607 impl<'de> serde::de::Deserialize<'de> for __With {
17608 fn deserialize<D>(
17609 deserializer: D,
17610 ) -> std::result::Result<Self, D::Error>
17611 where
17612 D: serde::de::Deserializer<'de>,
17613 {
17614 serde_with::As::<
17615 std::option::Option<
17616 std::collections::HashMap<
17617 serde_with::Same,
17618 wkt::internal::F64,
17619 >,
17620 >,
17621 >::deserialize(deserializer)
17622 .map(__With)
17623 }
17624 }
17625 result.costs = map.next_value::<__With>()?.0.unwrap_or_default();
17626 }
17627 __FieldTag::__total_cost => {
17628 if !fields.insert(__FieldTag::__total_cost) {
17629 return std::result::Result::Err(A::Error::duplicate_field(
17630 "multiple values for total_cost",
17631 ));
17632 }
17633 struct __With(std::option::Option<f64>);
17634 impl<'de> serde::de::Deserialize<'de> for __With {
17635 fn deserialize<D>(
17636 deserializer: D,
17637 ) -> std::result::Result<Self, D::Error>
17638 where
17639 D: serde::de::Deserializer<'de>,
17640 {
17641 serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
17642 }
17643 }
17644 result.total_cost = map.next_value::<__With>()?.0.unwrap_or_default();
17645 }
17646 __FieldTag::Unknown(key) => {
17647 let value = map.next_value::<serde_json::Value>()?;
17648 result._unknown_fields.insert(key, value);
17649 }
17650 }
17651 }
17652 std::result::Result::Ok(result)
17653 }
17654 }
17655 deserializer.deserialize_any(Visitor)
17656 }
17657}
17658
17659#[doc(hidden)]
17660impl serde::ser::Serialize for AggregatedMetrics {
17661 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17662 where
17663 S: serde::ser::Serializer,
17664 {
17665 use serde::ser::SerializeMap;
17666 #[allow(unused_imports)]
17667 use std::option::Option::Some;
17668 let mut state = serializer.serialize_map(std::option::Option::None)?;
17669 if !wkt::internal::is_default(&self.performed_shipment_count) {
17670 struct __With<'a>(&'a i32);
17671 impl<'a> serde::ser::Serialize for __With<'a> {
17672 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17673 where
17674 S: serde::ser::Serializer,
17675 {
17676 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
17677 }
17678 }
17679 state.serialize_entry(
17680 "performedShipmentCount",
17681 &__With(&self.performed_shipment_count),
17682 )?;
17683 }
17684 if self.travel_duration.is_some() {
17685 state.serialize_entry("travelDuration", &self.travel_duration)?;
17686 }
17687 if self.wait_duration.is_some() {
17688 state.serialize_entry("waitDuration", &self.wait_duration)?;
17689 }
17690 if self.delay_duration.is_some() {
17691 state.serialize_entry("delayDuration", &self.delay_duration)?;
17692 }
17693 if self.break_duration.is_some() {
17694 state.serialize_entry("breakDuration", &self.break_duration)?;
17695 }
17696 if self.visit_duration.is_some() {
17697 state.serialize_entry("visitDuration", &self.visit_duration)?;
17698 }
17699 if self.total_duration.is_some() {
17700 state.serialize_entry("totalDuration", &self.total_duration)?;
17701 }
17702 if !wkt::internal::is_default(&self.travel_distance_meters) {
17703 struct __With<'a>(&'a f64);
17704 impl<'a> serde::ser::Serialize for __With<'a> {
17705 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17706 where
17707 S: serde::ser::Serializer,
17708 {
17709 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
17710 }
17711 }
17712 state.serialize_entry(
17713 "travelDistanceMeters",
17714 &__With(&self.travel_distance_meters),
17715 )?;
17716 }
17717 if !self.max_loads.is_empty() {
17718 state.serialize_entry("maxLoads", &self.max_loads)?;
17719 }
17720 if !self.costs.is_empty() {
17721 struct __With<'a>(&'a std::collections::HashMap<std::string::String, f64>);
17722 impl<'a> serde::ser::Serialize for __With<'a> {
17723 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17724 where
17725 S: serde::ser::Serializer,
17726 {
17727 serde_with::As::< std::collections::HashMap<serde_with::Same, wkt::internal::F64> >::serialize(self.0, serializer)
17728 }
17729 }
17730 state.serialize_entry("costs", &__With(&self.costs))?;
17731 }
17732 if !wkt::internal::is_default(&self.total_cost) {
17733 struct __With<'a>(&'a f64);
17734 impl<'a> serde::ser::Serialize for __With<'a> {
17735 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17736 where
17737 S: serde::ser::Serializer,
17738 {
17739 serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
17740 }
17741 }
17742 state.serialize_entry("totalCost", &__With(&self.total_cost))?;
17743 }
17744 if !self._unknown_fields.is_empty() {
17745 for (key, value) in self._unknown_fields.iter() {
17746 state.serialize_entry(key, &value)?;
17747 }
17748 }
17749 state.end()
17750 }
17751}
17752
17753#[derive(Clone, Debug, Default, PartialEq)]
17756#[non_exhaustive]
17757pub struct InjectedSolutionConstraint {
17758 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
17762
17763 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
17766
17767 pub constraint_relaxations:
17771 std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
17772
17773 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17774}
17775
17776impl InjectedSolutionConstraint {
17777 pub fn new() -> Self {
17778 std::default::Default::default()
17779 }
17780
17781 pub fn set_routes<T, V>(mut self, v: T) -> Self
17783 where
17784 T: std::iter::IntoIterator<Item = V>,
17785 V: std::convert::Into<crate::model::ShipmentRoute>,
17786 {
17787 use std::iter::Iterator;
17788 self.routes = v.into_iter().map(|i| i.into()).collect();
17789 self
17790 }
17791
17792 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
17794 where
17795 T: std::iter::IntoIterator<Item = V>,
17796 V: std::convert::Into<crate::model::SkippedShipment>,
17797 {
17798 use std::iter::Iterator;
17799 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
17800 self
17801 }
17802
17803 pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
17805 where
17806 T: std::iter::IntoIterator<Item = V>,
17807 V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
17808 {
17809 use std::iter::Iterator;
17810 self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
17811 self
17812 }
17813}
17814
17815impl wkt::message::Message for InjectedSolutionConstraint {
17816 fn typename() -> &'static str {
17817 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
17818 }
17819}
17820
17821#[doc(hidden)]
17822impl<'de> serde::de::Deserialize<'de> for InjectedSolutionConstraint {
17823 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17824 where
17825 D: serde::Deserializer<'de>,
17826 {
17827 #[allow(non_camel_case_types)]
17828 #[doc(hidden)]
17829 #[derive(PartialEq, Eq, Hash)]
17830 enum __FieldTag {
17831 __routes,
17832 __skipped_shipments,
17833 __constraint_relaxations,
17834 Unknown(std::string::String),
17835 }
17836 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
17837 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
17838 where
17839 D: serde::Deserializer<'de>,
17840 {
17841 struct Visitor;
17842 impl<'de> serde::de::Visitor<'de> for Visitor {
17843 type Value = __FieldTag;
17844 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17845 formatter.write_str("a field name for InjectedSolutionConstraint")
17846 }
17847 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
17848 where
17849 E: serde::de::Error,
17850 {
17851 use std::result::Result::Ok;
17852 use std::string::ToString;
17853 match value {
17854 "routes" => Ok(__FieldTag::__routes),
17855 "skippedShipments" => Ok(__FieldTag::__skipped_shipments),
17856 "skipped_shipments" => Ok(__FieldTag::__skipped_shipments),
17857 "constraintRelaxations" => Ok(__FieldTag::__constraint_relaxations),
17858 "constraint_relaxations" => Ok(__FieldTag::__constraint_relaxations),
17859 _ => Ok(__FieldTag::Unknown(value.to_string())),
17860 }
17861 }
17862 }
17863 deserializer.deserialize_identifier(Visitor)
17864 }
17865 }
17866 struct Visitor;
17867 impl<'de> serde::de::Visitor<'de> for Visitor {
17868 type Value = InjectedSolutionConstraint;
17869 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
17870 formatter.write_str("struct InjectedSolutionConstraint")
17871 }
17872 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
17873 where
17874 A: serde::de::MapAccess<'de>,
17875 {
17876 #[allow(unused_imports)]
17877 use serde::de::Error;
17878 use std::option::Option::Some;
17879 let mut fields = std::collections::HashSet::new();
17880 let mut result = Self::Value::new();
17881 while let Some(tag) = map.next_key::<__FieldTag>()? {
17882 #[allow(clippy::match_single_binding)]
17883 match tag {
17884 __FieldTag::__routes => {
17885 if !fields.insert(__FieldTag::__routes) {
17886 return std::result::Result::Err(A::Error::duplicate_field(
17887 "multiple values for routes",
17888 ));
17889 }
17890 result.routes = map.next_value::<std::option::Option<std::vec::Vec<crate::model::ShipmentRoute>>>()?.unwrap_or_default();
17891 }
17892 __FieldTag::__skipped_shipments => {
17893 if !fields.insert(__FieldTag::__skipped_shipments) {
17894 return std::result::Result::Err(A::Error::duplicate_field(
17895 "multiple values for skipped_shipments",
17896 ));
17897 }
17898 result.skipped_shipments =
17899 map.next_value::<std::option::Option<
17900 std::vec::Vec<crate::model::SkippedShipment>,
17901 >>()?
17902 .unwrap_or_default();
17903 }
17904 __FieldTag::__constraint_relaxations => {
17905 if !fields.insert(__FieldTag::__constraint_relaxations) {
17906 return std::result::Result::Err(A::Error::duplicate_field(
17907 "multiple values for constraint_relaxations",
17908 ));
17909 }
17910 result.constraint_relaxations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>>>()?.unwrap_or_default();
17911 }
17912 __FieldTag::Unknown(key) => {
17913 let value = map.next_value::<serde_json::Value>()?;
17914 result._unknown_fields.insert(key, value);
17915 }
17916 }
17917 }
17918 std::result::Result::Ok(result)
17919 }
17920 }
17921 deserializer.deserialize_any(Visitor)
17922 }
17923}
17924
17925#[doc(hidden)]
17926impl serde::ser::Serialize for InjectedSolutionConstraint {
17927 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
17928 where
17929 S: serde::ser::Serializer,
17930 {
17931 use serde::ser::SerializeMap;
17932 #[allow(unused_imports)]
17933 use std::option::Option::Some;
17934 let mut state = serializer.serialize_map(std::option::Option::None)?;
17935 if !self.routes.is_empty() {
17936 state.serialize_entry("routes", &self.routes)?;
17937 }
17938 if !self.skipped_shipments.is_empty() {
17939 state.serialize_entry("skippedShipments", &self.skipped_shipments)?;
17940 }
17941 if !self.constraint_relaxations.is_empty() {
17942 state.serialize_entry("constraintRelaxations", &self.constraint_relaxations)?;
17943 }
17944 if !self._unknown_fields.is_empty() {
17945 for (key, value) in self._unknown_fields.iter() {
17946 state.serialize_entry(key, &value)?;
17947 }
17948 }
17949 state.end()
17950 }
17951}
17952
17953pub mod injected_solution_constraint {
17955 #[allow(unused_imports)]
17956 use super::*;
17957
17958 #[derive(Clone, Debug, Default, PartialEq)]
17963 #[non_exhaustive]
17964 pub struct ConstraintRelaxation {
17965 pub relaxations: std::vec::Vec<
17968 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
17969 >,
17970
17971 pub vehicle_indices: std::vec::Vec<i32>,
17986
17987 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
17988 }
17989
17990 impl ConstraintRelaxation {
17991 pub fn new() -> Self {
17992 std::default::Default::default()
17993 }
17994
17995 pub fn set_relaxations<T, V>(mut self, v: T) -> Self
17997 where
17998 T: std::iter::IntoIterator<Item = V>,
17999 V: std::convert::Into<
18000 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
18001 >,
18002 {
18003 use std::iter::Iterator;
18004 self.relaxations = v.into_iter().map(|i| i.into()).collect();
18005 self
18006 }
18007
18008 pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
18010 where
18011 T: std::iter::IntoIterator<Item = V>,
18012 V: std::convert::Into<i32>,
18013 {
18014 use std::iter::Iterator;
18015 self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
18016 self
18017 }
18018 }
18019
18020 impl wkt::message::Message for ConstraintRelaxation {
18021 fn typename() -> &'static str {
18022 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
18023 }
18024 }
18025
18026 #[doc(hidden)]
18027 impl<'de> serde::de::Deserialize<'de> for ConstraintRelaxation {
18028 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18029 where
18030 D: serde::Deserializer<'de>,
18031 {
18032 #[allow(non_camel_case_types)]
18033 #[doc(hidden)]
18034 #[derive(PartialEq, Eq, Hash)]
18035 enum __FieldTag {
18036 __relaxations,
18037 __vehicle_indices,
18038 Unknown(std::string::String),
18039 }
18040 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18041 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18042 where
18043 D: serde::Deserializer<'de>,
18044 {
18045 struct Visitor;
18046 impl<'de> serde::de::Visitor<'de> for Visitor {
18047 type Value = __FieldTag;
18048 fn expecting(
18049 &self,
18050 formatter: &mut std::fmt::Formatter,
18051 ) -> std::fmt::Result {
18052 formatter.write_str("a field name for ConstraintRelaxation")
18053 }
18054 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
18055 where
18056 E: serde::de::Error,
18057 {
18058 use std::result::Result::Ok;
18059 use std::string::ToString;
18060 match value {
18061 "relaxations" => Ok(__FieldTag::__relaxations),
18062 "vehicleIndices" => Ok(__FieldTag::__vehicle_indices),
18063 "vehicle_indices" => Ok(__FieldTag::__vehicle_indices),
18064 _ => Ok(__FieldTag::Unknown(value.to_string())),
18065 }
18066 }
18067 }
18068 deserializer.deserialize_identifier(Visitor)
18069 }
18070 }
18071 struct Visitor;
18072 impl<'de> serde::de::Visitor<'de> for Visitor {
18073 type Value = ConstraintRelaxation;
18074 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18075 formatter.write_str("struct ConstraintRelaxation")
18076 }
18077 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18078 where
18079 A: serde::de::MapAccess<'de>,
18080 {
18081 #[allow(unused_imports)]
18082 use serde::de::Error;
18083 use std::option::Option::Some;
18084 let mut fields = std::collections::HashSet::new();
18085 let mut result = Self::Value::new();
18086 while let Some(tag) = map.next_key::<__FieldTag>()? {
18087 #[allow(clippy::match_single_binding)]
18088 match tag {
18089 __FieldTag::__relaxations => {
18090 if !fields.insert(__FieldTag::__relaxations) {
18091 return std::result::Result::Err(A::Error::duplicate_field(
18092 "multiple values for relaxations",
18093 ));
18094 }
18095 result.relaxations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::injected_solution_constraint::constraint_relaxation::Relaxation>>>()?.unwrap_or_default();
18096 }
18097 __FieldTag::__vehicle_indices => {
18098 if !fields.insert(__FieldTag::__vehicle_indices) {
18099 return std::result::Result::Err(A::Error::duplicate_field(
18100 "multiple values for vehicle_indices",
18101 ));
18102 }
18103 struct __With(std::option::Option<std::vec::Vec<i32>>);
18104 impl<'de> serde::de::Deserialize<'de> for __With {
18105 fn deserialize<D>(
18106 deserializer: D,
18107 ) -> std::result::Result<Self, D::Error>
18108 where
18109 D: serde::de::Deserializer<'de>,
18110 {
18111 serde_with::As::<
18112 std::option::Option<std::vec::Vec<wkt::internal::I32>>,
18113 >::deserialize(
18114 deserializer
18115 )
18116 .map(__With)
18117 }
18118 }
18119 result.vehicle_indices =
18120 map.next_value::<__With>()?.0.unwrap_or_default();
18121 }
18122 __FieldTag::Unknown(key) => {
18123 let value = map.next_value::<serde_json::Value>()?;
18124 result._unknown_fields.insert(key, value);
18125 }
18126 }
18127 }
18128 std::result::Result::Ok(result)
18129 }
18130 }
18131 deserializer.deserialize_any(Visitor)
18132 }
18133 }
18134
18135 #[doc(hidden)]
18136 impl serde::ser::Serialize for ConstraintRelaxation {
18137 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18138 where
18139 S: serde::ser::Serializer,
18140 {
18141 use serde::ser::SerializeMap;
18142 #[allow(unused_imports)]
18143 use std::option::Option::Some;
18144 let mut state = serializer.serialize_map(std::option::Option::None)?;
18145 if !self.relaxations.is_empty() {
18146 state.serialize_entry("relaxations", &self.relaxations)?;
18147 }
18148 if !self.vehicle_indices.is_empty() {
18149 struct __With<'a>(&'a std::vec::Vec<i32>);
18150 impl<'a> serde::ser::Serialize for __With<'a> {
18151 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18152 where
18153 S: serde::ser::Serializer,
18154 {
18155 serde_with::As::<std::vec::Vec<wkt::internal::I32>>::serialize(
18156 self.0, serializer,
18157 )
18158 }
18159 }
18160 state.serialize_entry("vehicleIndices", &__With(&self.vehicle_indices))?;
18161 }
18162 if !self._unknown_fields.is_empty() {
18163 for (key, value) in self._unknown_fields.iter() {
18164 state.serialize_entry(key, &value)?;
18165 }
18166 }
18167 state.end()
18168 }
18169 }
18170
18171 pub mod constraint_relaxation {
18173 #[allow(unused_imports)]
18174 use super::*;
18175
18176 #[derive(Clone, Debug, Default, PartialEq)]
18212 #[non_exhaustive]
18213 pub struct Relaxation {
18214
18215 pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
18219
18220 pub threshold_time: std::option::Option<wkt::Timestamp>,
18222
18223 pub threshold_visit_count: i32,
18231
18232 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18233 }
18234
18235 impl Relaxation {
18236 pub fn new() -> Self {
18237 std::default::Default::default()
18238 }
18239
18240 pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
18242 self.level = v.into();
18243 self
18244 }
18245
18246 pub fn set_threshold_time<T>(mut self, v: T) -> Self
18248 where
18249 T: std::convert::Into<wkt::Timestamp>,
18250 {
18251 self.threshold_time = std::option::Option::Some(v.into());
18252 self
18253 }
18254
18255 pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
18257 where
18258 T: std::convert::Into<wkt::Timestamp>,
18259 {
18260 self.threshold_time = v.map(|x| x.into());
18261 self
18262 }
18263
18264 pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
18266 self.threshold_visit_count = v.into();
18267 self
18268 }
18269 }
18270
18271 impl wkt::message::Message for Relaxation {
18272 fn typename() -> &'static str {
18273 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
18274 }
18275 }
18276
18277 #[doc(hidden)]
18278 impl<'de> serde::de::Deserialize<'de> for Relaxation {
18279 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18280 where
18281 D: serde::Deserializer<'de>,
18282 {
18283 #[allow(non_camel_case_types)]
18284 #[doc(hidden)]
18285 #[derive(PartialEq, Eq, Hash)]
18286 enum __FieldTag {
18287 __level,
18288 __threshold_time,
18289 __threshold_visit_count,
18290 Unknown(std::string::String),
18291 }
18292 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18293 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18294 where
18295 D: serde::Deserializer<'de>,
18296 {
18297 struct Visitor;
18298 impl<'de> serde::de::Visitor<'de> for Visitor {
18299 type Value = __FieldTag;
18300 fn expecting(
18301 &self,
18302 formatter: &mut std::fmt::Formatter,
18303 ) -> std::fmt::Result {
18304 formatter.write_str("a field name for Relaxation")
18305 }
18306 fn visit_str<E>(
18307 self,
18308 value: &str,
18309 ) -> std::result::Result<Self::Value, E>
18310 where
18311 E: serde::de::Error,
18312 {
18313 use std::result::Result::Ok;
18314 use std::string::ToString;
18315 match value {
18316 "level" => Ok(__FieldTag::__level),
18317 "thresholdTime" => Ok(__FieldTag::__threshold_time),
18318 "threshold_time" => Ok(__FieldTag::__threshold_time),
18319 "thresholdVisitCount" => {
18320 Ok(__FieldTag::__threshold_visit_count)
18321 }
18322 "threshold_visit_count" => {
18323 Ok(__FieldTag::__threshold_visit_count)
18324 }
18325 _ => Ok(__FieldTag::Unknown(value.to_string())),
18326 }
18327 }
18328 }
18329 deserializer.deserialize_identifier(Visitor)
18330 }
18331 }
18332 struct Visitor;
18333 impl<'de> serde::de::Visitor<'de> for Visitor {
18334 type Value = Relaxation;
18335 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
18336 formatter.write_str("struct Relaxation")
18337 }
18338 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
18339 where
18340 A: serde::de::MapAccess<'de>,
18341 {
18342 #[allow(unused_imports)]
18343 use serde::de::Error;
18344 use std::option::Option::Some;
18345 let mut fields = std::collections::HashSet::new();
18346 let mut result = Self::Value::new();
18347 while let Some(tag) = map.next_key::<__FieldTag>()? {
18348 #[allow(clippy::match_single_binding)]
18349 match tag {
18350 __FieldTag::__level => {
18351 if !fields.insert(__FieldTag::__level) {
18352 return std::result::Result::Err(
18353 A::Error::duplicate_field("multiple values for level"),
18354 );
18355 }
18356 result.level = map.next_value::<std::option::Option<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>()?.unwrap_or_default();
18357 }
18358 __FieldTag::__threshold_time => {
18359 if !fields.insert(__FieldTag::__threshold_time) {
18360 return std::result::Result::Err(
18361 A::Error::duplicate_field(
18362 "multiple values for threshold_time",
18363 ),
18364 );
18365 }
18366 result.threshold_time =
18367 map.next_value::<std::option::Option<wkt::Timestamp>>()?;
18368 }
18369 __FieldTag::__threshold_visit_count => {
18370 if !fields.insert(__FieldTag::__threshold_visit_count) {
18371 return std::result::Result::Err(
18372 A::Error::duplicate_field(
18373 "multiple values for threshold_visit_count",
18374 ),
18375 );
18376 }
18377 struct __With(std::option::Option<i32>);
18378 impl<'de> serde::de::Deserialize<'de> for __With {
18379 fn deserialize<D>(
18380 deserializer: D,
18381 ) -> std::result::Result<Self, D::Error>
18382 where
18383 D: serde::de::Deserializer<'de>,
18384 {
18385 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
18386 }
18387 }
18388 result.threshold_visit_count =
18389 map.next_value::<__With>()?.0.unwrap_or_default();
18390 }
18391 __FieldTag::Unknown(key) => {
18392 let value = map.next_value::<serde_json::Value>()?;
18393 result._unknown_fields.insert(key, value);
18394 }
18395 }
18396 }
18397 std::result::Result::Ok(result)
18398 }
18399 }
18400 deserializer.deserialize_any(Visitor)
18401 }
18402 }
18403
18404 #[doc(hidden)]
18405 impl serde::ser::Serialize for Relaxation {
18406 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18407 where
18408 S: serde::ser::Serializer,
18409 {
18410 use serde::ser::SerializeMap;
18411 #[allow(unused_imports)]
18412 use std::option::Option::Some;
18413 let mut state = serializer.serialize_map(std::option::Option::None)?;
18414 if !wkt::internal::is_default(&self.level) {
18415 state.serialize_entry("level", &self.level)?;
18416 }
18417 if self.threshold_time.is_some() {
18418 state.serialize_entry("thresholdTime", &self.threshold_time)?;
18419 }
18420 if !wkt::internal::is_default(&self.threshold_visit_count) {
18421 struct __With<'a>(&'a i32);
18422 impl<'a> serde::ser::Serialize for __With<'a> {
18423 fn serialize<S>(
18424 &self,
18425 serializer: S,
18426 ) -> std::result::Result<S::Ok, S::Error>
18427 where
18428 S: serde::ser::Serializer,
18429 {
18430 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
18431 }
18432 }
18433 state.serialize_entry(
18434 "thresholdVisitCount",
18435 &__With(&self.threshold_visit_count),
18436 )?;
18437 }
18438 if !self._unknown_fields.is_empty() {
18439 for (key, value) in self._unknown_fields.iter() {
18440 state.serialize_entry(key, &value)?;
18441 }
18442 }
18443 state.end()
18444 }
18445 }
18446
18447 pub mod relaxation {
18449 #[allow(unused_imports)]
18450 use super::*;
18451
18452 #[derive(Clone, Debug, PartialEq)]
18472 #[non_exhaustive]
18473 pub enum Level {
18474 Unspecified,
18479 RelaxVisitTimesAfterThreshold,
18484 RelaxVisitTimesAndSequenceAfterThreshold,
18488 RelaxAllAfterThreshold,
18492 UnknownValue(level::UnknownValue),
18497 }
18498
18499 #[doc(hidden)]
18500 pub mod level {
18501 #[allow(unused_imports)]
18502 use super::*;
18503 #[derive(Clone, Debug, PartialEq)]
18504 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
18505 }
18506
18507 impl Level {
18508 pub fn value(&self) -> std::option::Option<i32> {
18513 match self {
18514 Self::Unspecified => std::option::Option::Some(0),
18515 Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
18516 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
18517 std::option::Option::Some(2)
18518 }
18519 Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
18520 Self::UnknownValue(u) => u.0.value(),
18521 }
18522 }
18523
18524 pub fn name(&self) -> std::option::Option<&str> {
18529 match self {
18530 Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
18531 Self::RelaxVisitTimesAfterThreshold => {
18532 std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
18533 }
18534 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
18535 std::option::Option::Some(
18536 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
18537 )
18538 }
18539 Self::RelaxAllAfterThreshold => {
18540 std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
18541 }
18542 Self::UnknownValue(u) => u.0.name(),
18543 }
18544 }
18545 }
18546
18547 impl std::default::Default for Level {
18548 fn default() -> Self {
18549 use std::convert::From;
18550 Self::from(0)
18551 }
18552 }
18553
18554 impl std::fmt::Display for Level {
18555 fn fmt(
18556 &self,
18557 f: &mut std::fmt::Formatter<'_>,
18558 ) -> std::result::Result<(), std::fmt::Error> {
18559 wkt::internal::display_enum(f, self.name(), self.value())
18560 }
18561 }
18562
18563 impl std::convert::From<i32> for Level {
18564 fn from(value: i32) -> Self {
18565 match value {
18566 0 => Self::Unspecified,
18567 1 => Self::RelaxVisitTimesAfterThreshold,
18568 2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
18569 3 => Self::RelaxAllAfterThreshold,
18570 _ => Self::UnknownValue(level::UnknownValue(
18571 wkt::internal::UnknownEnumValue::Integer(value),
18572 )),
18573 }
18574 }
18575 }
18576
18577 impl std::convert::From<&str> for Level {
18578 fn from(value: &str) -> Self {
18579 use std::string::ToString;
18580 match value {
18581 "LEVEL_UNSPECIFIED" => Self::Unspecified,
18582 "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
18583 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
18584 Self::RelaxVisitTimesAndSequenceAfterThreshold
18585 }
18586 "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
18587 _ => Self::UnknownValue(level::UnknownValue(
18588 wkt::internal::UnknownEnumValue::String(value.to_string()),
18589 )),
18590 }
18591 }
18592 }
18593
18594 impl serde::ser::Serialize for Level {
18595 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
18596 where
18597 S: serde::Serializer,
18598 {
18599 match self {
18600 Self::Unspecified => serializer.serialize_i32(0),
18601 Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
18602 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
18603 serializer.serialize_i32(2)
18604 }
18605 Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
18606 Self::UnknownValue(u) => u.0.serialize(serializer),
18607 }
18608 }
18609 }
18610
18611 impl<'de> serde::de::Deserialize<'de> for Level {
18612 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18613 where
18614 D: serde::Deserializer<'de>,
18615 {
18616 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
18617 ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
18618 }
18619 }
18620 }
18621 }
18622}
18623
18624#[derive(Clone, Debug, Default, PartialEq)]
18626#[non_exhaustive]
18627pub struct OptimizeToursValidationError {
18628 pub code: i32,
18894
18895 pub display_name: std::string::String,
18897
18898 pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
18910
18911 pub error_message: std::string::String,
18918
18919 pub offending_values: std::string::String,
18923
18924 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
18925}
18926
18927impl OptimizeToursValidationError {
18928 pub fn new() -> Self {
18929 std::default::Default::default()
18930 }
18931
18932 pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
18934 self.code = v.into();
18935 self
18936 }
18937
18938 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18940 self.display_name = v.into();
18941 self
18942 }
18943
18944 pub fn set_fields<T, V>(mut self, v: T) -> Self
18946 where
18947 T: std::iter::IntoIterator<Item = V>,
18948 V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
18949 {
18950 use std::iter::Iterator;
18951 self.fields = v.into_iter().map(|i| i.into()).collect();
18952 self
18953 }
18954
18955 pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
18957 self.error_message = v.into();
18958 self
18959 }
18960
18961 pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
18963 mut self,
18964 v: T,
18965 ) -> Self {
18966 self.offending_values = v.into();
18967 self
18968 }
18969}
18970
18971impl wkt::message::Message for OptimizeToursValidationError {
18972 fn typename() -> &'static str {
18973 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
18974 }
18975}
18976
18977#[doc(hidden)]
18978impl<'de> serde::de::Deserialize<'de> for OptimizeToursValidationError {
18979 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18980 where
18981 D: serde::Deserializer<'de>,
18982 {
18983 #[allow(non_camel_case_types)]
18984 #[doc(hidden)]
18985 #[derive(PartialEq, Eq, Hash)]
18986 enum __FieldTag {
18987 __code,
18988 __display_name,
18989 __fields,
18990 __error_message,
18991 __offending_values,
18992 Unknown(std::string::String),
18993 }
18994 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
18995 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
18996 where
18997 D: serde::Deserializer<'de>,
18998 {
18999 struct Visitor;
19000 impl<'de> serde::de::Visitor<'de> for Visitor {
19001 type Value = __FieldTag;
19002 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19003 formatter.write_str("a field name for OptimizeToursValidationError")
19004 }
19005 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19006 where
19007 E: serde::de::Error,
19008 {
19009 use std::result::Result::Ok;
19010 use std::string::ToString;
19011 match value {
19012 "code" => Ok(__FieldTag::__code),
19013 "displayName" => Ok(__FieldTag::__display_name),
19014 "display_name" => Ok(__FieldTag::__display_name),
19015 "fields" => Ok(__FieldTag::__fields),
19016 "errorMessage" => Ok(__FieldTag::__error_message),
19017 "error_message" => Ok(__FieldTag::__error_message),
19018 "offendingValues" => Ok(__FieldTag::__offending_values),
19019 "offending_values" => Ok(__FieldTag::__offending_values),
19020 _ => Ok(__FieldTag::Unknown(value.to_string())),
19021 }
19022 }
19023 }
19024 deserializer.deserialize_identifier(Visitor)
19025 }
19026 }
19027 struct Visitor;
19028 impl<'de> serde::de::Visitor<'de> for Visitor {
19029 type Value = OptimizeToursValidationError;
19030 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19031 formatter.write_str("struct OptimizeToursValidationError")
19032 }
19033 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19034 where
19035 A: serde::de::MapAccess<'de>,
19036 {
19037 #[allow(unused_imports)]
19038 use serde::de::Error;
19039 use std::option::Option::Some;
19040 let mut fields = std::collections::HashSet::new();
19041 let mut result = Self::Value::new();
19042 while let Some(tag) = map.next_key::<__FieldTag>()? {
19043 #[allow(clippy::match_single_binding)]
19044 match tag {
19045 __FieldTag::__code => {
19046 if !fields.insert(__FieldTag::__code) {
19047 return std::result::Result::Err(A::Error::duplicate_field(
19048 "multiple values for code",
19049 ));
19050 }
19051 struct __With(std::option::Option<i32>);
19052 impl<'de> serde::de::Deserialize<'de> for __With {
19053 fn deserialize<D>(
19054 deserializer: D,
19055 ) -> std::result::Result<Self, D::Error>
19056 where
19057 D: serde::de::Deserializer<'de>,
19058 {
19059 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
19060 }
19061 }
19062 result.code = map.next_value::<__With>()?.0.unwrap_or_default();
19063 }
19064 __FieldTag::__display_name => {
19065 if !fields.insert(__FieldTag::__display_name) {
19066 return std::result::Result::Err(A::Error::duplicate_field(
19067 "multiple values for display_name",
19068 ));
19069 }
19070 result.display_name = map
19071 .next_value::<std::option::Option<std::string::String>>()?
19072 .unwrap_or_default();
19073 }
19074 __FieldTag::__fields => {
19075 if !fields.insert(__FieldTag::__fields) {
19076 return std::result::Result::Err(A::Error::duplicate_field(
19077 "multiple values for fields",
19078 ));
19079 }
19080 result.fields = map.next_value::<std::option::Option<std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>>>()?.unwrap_or_default();
19081 }
19082 __FieldTag::__error_message => {
19083 if !fields.insert(__FieldTag::__error_message) {
19084 return std::result::Result::Err(A::Error::duplicate_field(
19085 "multiple values for error_message",
19086 ));
19087 }
19088 result.error_message = map
19089 .next_value::<std::option::Option<std::string::String>>()?
19090 .unwrap_or_default();
19091 }
19092 __FieldTag::__offending_values => {
19093 if !fields.insert(__FieldTag::__offending_values) {
19094 return std::result::Result::Err(A::Error::duplicate_field(
19095 "multiple values for offending_values",
19096 ));
19097 }
19098 result.offending_values = map
19099 .next_value::<std::option::Option<std::string::String>>()?
19100 .unwrap_or_default();
19101 }
19102 __FieldTag::Unknown(key) => {
19103 let value = map.next_value::<serde_json::Value>()?;
19104 result._unknown_fields.insert(key, value);
19105 }
19106 }
19107 }
19108 std::result::Result::Ok(result)
19109 }
19110 }
19111 deserializer.deserialize_any(Visitor)
19112 }
19113}
19114
19115#[doc(hidden)]
19116impl serde::ser::Serialize for OptimizeToursValidationError {
19117 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19118 where
19119 S: serde::ser::Serializer,
19120 {
19121 use serde::ser::SerializeMap;
19122 #[allow(unused_imports)]
19123 use std::option::Option::Some;
19124 let mut state = serializer.serialize_map(std::option::Option::None)?;
19125 if !wkt::internal::is_default(&self.code) {
19126 struct __With<'a>(&'a i32);
19127 impl<'a> serde::ser::Serialize for __With<'a> {
19128 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19129 where
19130 S: serde::ser::Serializer,
19131 {
19132 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
19133 }
19134 }
19135 state.serialize_entry("code", &__With(&self.code))?;
19136 }
19137 if !self.display_name.is_empty() {
19138 state.serialize_entry("displayName", &self.display_name)?;
19139 }
19140 if !self.fields.is_empty() {
19141 state.serialize_entry("fields", &self.fields)?;
19142 }
19143 if !self.error_message.is_empty() {
19144 state.serialize_entry("errorMessage", &self.error_message)?;
19145 }
19146 if !self.offending_values.is_empty() {
19147 state.serialize_entry("offendingValues", &self.offending_values)?;
19148 }
19149 if !self._unknown_fields.is_empty() {
19150 for (key, value) in self._unknown_fields.iter() {
19151 state.serialize_entry(key, &value)?;
19152 }
19153 }
19154 state.end()
19155 }
19156}
19157
19158pub mod optimize_tours_validation_error {
19160 #[allow(unused_imports)]
19161 use super::*;
19162
19163 #[derive(Clone, Debug, Default, PartialEq)]
19175 #[non_exhaustive]
19176 pub struct FieldReference {
19177 pub name: std::string::String,
19179
19180 pub sub_field: std::option::Option<
19182 std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
19183 >,
19184
19185 pub index_or_key: std::option::Option<
19186 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
19187 >,
19188
19189 _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
19190 }
19191
19192 impl FieldReference {
19193 pub fn new() -> Self {
19194 std::default::Default::default()
19195 }
19196
19197 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19199 self.name = v.into();
19200 self
19201 }
19202
19203 pub fn set_sub_field<T>(mut self, v: T) -> Self
19205 where
19206 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
19207 {
19208 self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
19209 self
19210 }
19211
19212 pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
19214 where
19215 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
19216 {
19217 self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
19218 self
19219 }
19220
19221 pub fn set_index_or_key<
19226 T: std::convert::Into<
19227 std::option::Option<
19228 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
19229 >,
19230 >,
19231 >(
19232 mut self,
19233 v: T,
19234 ) -> Self {
19235 self.index_or_key = v.into();
19236 self
19237 }
19238
19239 pub fn index(&self) -> std::option::Option<&i32> {
19243 #[allow(unreachable_patterns)]
19244 self.index_or_key.as_ref().and_then(|v| match v {
19245 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
19246 _ => std::option::Option::None,
19247 })
19248 }
19249
19250 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
19256 self.index_or_key = std::option::Option::Some(
19257 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
19258 v.into(),
19259 ),
19260 );
19261 self
19262 }
19263
19264 pub fn key(&self) -> std::option::Option<&std::string::String> {
19268 #[allow(unreachable_patterns)]
19269 self.index_or_key.as_ref().and_then(|v| match v {
19270 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
19271 v,
19272 ) => std::option::Option::Some(v),
19273 _ => std::option::Option::None,
19274 })
19275 }
19276
19277 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
19283 self.index_or_key = std::option::Option::Some(
19284 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
19285 v.into(),
19286 ),
19287 );
19288 self
19289 }
19290 }
19291
19292 impl wkt::message::Message for FieldReference {
19293 fn typename() -> &'static str {
19294 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
19295 }
19296 }
19297
19298 #[doc(hidden)]
19299 impl<'de> serde::de::Deserialize<'de> for FieldReference {
19300 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19301 where
19302 D: serde::Deserializer<'de>,
19303 {
19304 #[allow(non_camel_case_types)]
19305 #[doc(hidden)]
19306 #[derive(PartialEq, Eq, Hash)]
19307 enum __FieldTag {
19308 __name,
19309 __index,
19310 __key,
19311 __sub_field,
19312 Unknown(std::string::String),
19313 }
19314 impl<'de> serde::de::Deserialize<'de> for __FieldTag {
19315 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19316 where
19317 D: serde::Deserializer<'de>,
19318 {
19319 struct Visitor;
19320 impl<'de> serde::de::Visitor<'de> for Visitor {
19321 type Value = __FieldTag;
19322 fn expecting(
19323 &self,
19324 formatter: &mut std::fmt::Formatter,
19325 ) -> std::fmt::Result {
19326 formatter.write_str("a field name for FieldReference")
19327 }
19328 fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
19329 where
19330 E: serde::de::Error,
19331 {
19332 use std::result::Result::Ok;
19333 use std::string::ToString;
19334 match value {
19335 "name" => Ok(__FieldTag::__name),
19336 "index" => Ok(__FieldTag::__index),
19337 "key" => Ok(__FieldTag::__key),
19338 "subField" => Ok(__FieldTag::__sub_field),
19339 "sub_field" => Ok(__FieldTag::__sub_field),
19340 _ => Ok(__FieldTag::Unknown(value.to_string())),
19341 }
19342 }
19343 }
19344 deserializer.deserialize_identifier(Visitor)
19345 }
19346 }
19347 struct Visitor;
19348 impl<'de> serde::de::Visitor<'de> for Visitor {
19349 type Value = FieldReference;
19350 fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
19351 formatter.write_str("struct FieldReference")
19352 }
19353 fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
19354 where
19355 A: serde::de::MapAccess<'de>,
19356 {
19357 #[allow(unused_imports)]
19358 use serde::de::Error;
19359 use std::option::Option::Some;
19360 let mut fields = std::collections::HashSet::new();
19361 let mut result = Self::Value::new();
19362 while let Some(tag) = map.next_key::<__FieldTag>()? {
19363 #[allow(clippy::match_single_binding)]
19364 match tag {
19365 __FieldTag::__name => {
19366 if !fields.insert(__FieldTag::__name) {
19367 return std::result::Result::Err(A::Error::duplicate_field(
19368 "multiple values for name",
19369 ));
19370 }
19371 result.name = map
19372 .next_value::<std::option::Option<std::string::String>>()?
19373 .unwrap_or_default();
19374 }
19375 __FieldTag::__index => {
19376 if !fields.insert(__FieldTag::__index) {
19377 return std::result::Result::Err(A::Error::duplicate_field(
19378 "multiple values for index",
19379 ));
19380 }
19381 struct __With(std::option::Option<i32>);
19382 impl<'de> serde::de::Deserialize<'de> for __With {
19383 fn deserialize<D>(
19384 deserializer: D,
19385 ) -> std::result::Result<Self, D::Error>
19386 where
19387 D: serde::de::Deserializer<'de>,
19388 {
19389 serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
19390 }
19391 }
19392 if result.index_or_key.is_some() {
19393 return std::result::Result::Err(A::Error::duplicate_field(
19394 "multiple values for `index_or_key`, a oneof with full ID .google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference.index, latest field was index",
19395 ));
19396 }
19397 result.index_or_key = std::option::Option::Some(
19398 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
19399 map.next_value::<__With>()?.0.unwrap_or_default()
19400 ),
19401 );
19402 }
19403 __FieldTag::__key => {
19404 if !fields.insert(__FieldTag::__key) {
19405 return std::result::Result::Err(A::Error::duplicate_field(
19406 "multiple values for key",
19407 ));
19408 }
19409 if result.index_or_key.is_some() {
19410 return std::result::Result::Err(A::Error::duplicate_field(
19411 "multiple values for `index_or_key`, a oneof with full ID .google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference.key, latest field was key",
19412 ));
19413 }
19414 result.index_or_key = std::option::Option::Some(
19415 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
19416 map.next_value::<std::option::Option<std::string::String>>()?.unwrap_or_default()
19417 ),
19418 );
19419 }
19420 __FieldTag::__sub_field => {
19421 if !fields.insert(__FieldTag::__sub_field) {
19422 return std::result::Result::Err(A::Error::duplicate_field(
19423 "multiple values for sub_field",
19424 ));
19425 }
19426 result.sub_field = map.next_value::<std::option::Option<std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>>>()?
19427 ;
19428 }
19429 __FieldTag::Unknown(key) => {
19430 let value = map.next_value::<serde_json::Value>()?;
19431 result._unknown_fields.insert(key, value);
19432 }
19433 }
19434 }
19435 std::result::Result::Ok(result)
19436 }
19437 }
19438 deserializer.deserialize_any(Visitor)
19439 }
19440 }
19441
19442 #[doc(hidden)]
19443 impl serde::ser::Serialize for FieldReference {
19444 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19445 where
19446 S: serde::ser::Serializer,
19447 {
19448 use serde::ser::SerializeMap;
19449 #[allow(unused_imports)]
19450 use std::option::Option::Some;
19451 let mut state = serializer.serialize_map(std::option::Option::None)?;
19452 if !self.name.is_empty() {
19453 state.serialize_entry("name", &self.name)?;
19454 }
19455 if let Some(value) = self.index() {
19456 struct __With<'a>(&'a i32);
19457 impl<'a> serde::ser::Serialize for __With<'a> {
19458 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19459 where
19460 S: serde::ser::Serializer,
19461 {
19462 serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
19463 }
19464 }
19465 state.serialize_entry("index", &__With(value))?;
19466 }
19467 if let Some(value) = self.key() {
19468 state.serialize_entry("key", value)?;
19469 }
19470 if self.sub_field.is_some() {
19471 state.serialize_entry("subField", &self.sub_field)?;
19472 }
19473 if !self._unknown_fields.is_empty() {
19474 for (key, value) in self._unknown_fields.iter() {
19475 state.serialize_entry(key, &value)?;
19476 }
19477 }
19478 state.end()
19479 }
19480 }
19481
19482 pub mod field_reference {
19484 #[allow(unused_imports)]
19485 use super::*;
19486
19487 #[derive(Clone, Debug, PartialEq)]
19488 #[non_exhaustive]
19489 pub enum IndexOrKey {
19490 Index(i32),
19492 Key(std::string::String),
19494 }
19495 }
19496}
19497
19498#[derive(Clone, Debug, PartialEq)]
19514#[non_exhaustive]
19515pub enum DataFormat {
19516 Unspecified,
19518 Json,
19520 String,
19522 UnknownValue(data_format::UnknownValue),
19527}
19528
19529#[doc(hidden)]
19530pub mod data_format {
19531 #[allow(unused_imports)]
19532 use super::*;
19533 #[derive(Clone, Debug, PartialEq)]
19534 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
19535}
19536
19537impl DataFormat {
19538 pub fn value(&self) -> std::option::Option<i32> {
19543 match self {
19544 Self::Unspecified => std::option::Option::Some(0),
19545 Self::Json => std::option::Option::Some(1),
19546 Self::String => std::option::Option::Some(2),
19547 Self::UnknownValue(u) => u.0.value(),
19548 }
19549 }
19550
19551 pub fn name(&self) -> std::option::Option<&str> {
19556 match self {
19557 Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
19558 Self::Json => std::option::Option::Some("JSON"),
19559 Self::String => std::option::Option::Some("STRING"),
19560 Self::UnknownValue(u) => u.0.name(),
19561 }
19562 }
19563}
19564
19565impl std::default::Default for DataFormat {
19566 fn default() -> Self {
19567 use std::convert::From;
19568 Self::from(0)
19569 }
19570}
19571
19572impl std::fmt::Display for DataFormat {
19573 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
19574 wkt::internal::display_enum(f, self.name(), self.value())
19575 }
19576}
19577
19578impl std::convert::From<i32> for DataFormat {
19579 fn from(value: i32) -> Self {
19580 match value {
19581 0 => Self::Unspecified,
19582 1 => Self::Json,
19583 2 => Self::String,
19584 _ => Self::UnknownValue(data_format::UnknownValue(
19585 wkt::internal::UnknownEnumValue::Integer(value),
19586 )),
19587 }
19588 }
19589}
19590
19591impl std::convert::From<&str> for DataFormat {
19592 fn from(value: &str) -> Self {
19593 use std::string::ToString;
19594 match value {
19595 "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
19596 "JSON" => Self::Json,
19597 "STRING" => Self::String,
19598 _ => Self::UnknownValue(data_format::UnknownValue(
19599 wkt::internal::UnknownEnumValue::String(value.to_string()),
19600 )),
19601 }
19602 }
19603}
19604
19605impl serde::ser::Serialize for DataFormat {
19606 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
19607 where
19608 S: serde::Serializer,
19609 {
19610 match self {
19611 Self::Unspecified => serializer.serialize_i32(0),
19612 Self::Json => serializer.serialize_i32(1),
19613 Self::String => serializer.serialize_i32(2),
19614 Self::UnknownValue(u) => u.0.serialize(serializer),
19615 }
19616 }
19617}
19618
19619impl<'de> serde::de::Deserialize<'de> for DataFormat {
19620 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
19621 where
19622 D: serde::Deserializer<'de>,
19623 {
19624 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
19625 ".google.cloud.optimization.v1.DataFormat",
19626 ))
19627 }
19628}