google_cloud_optimization_v1/model.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_longrunning;
25extern crate google_cloud_lro;
26extern crate google_cloud_type;
27extern crate lazy_static;
28extern crate serde;
29extern crate serde_json;
30extern crate serde_with;
31extern crate std;
32extern crate tracing;
33extern crate wkt;
34
35mod debug;
36mod deserialize;
37mod serialize;
38
39/// The desired input location information.
40#[derive(Clone, Default, PartialEq)]
41#[non_exhaustive]
42pub struct InputConfig {
43 /// The input data format that used to store the model in Cloud Storage.
44 pub data_format: crate::model::DataFormat,
45
46 /// The location of the input model in cloud storage.
47 /// Required.
48 pub source: std::option::Option<crate::model::input_config::Source>,
49
50 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
51}
52
53impl InputConfig {
54 pub fn new() -> Self {
55 std::default::Default::default()
56 }
57
58 /// Sets the value of [data_format][crate::model::InputConfig::data_format].
59 ///
60 /// # Example
61 /// ```ignore,no_run
62 /// # use google_cloud_optimization_v1::model::InputConfig;
63 /// use google_cloud_optimization_v1::model::DataFormat;
64 /// let x0 = InputConfig::new().set_data_format(DataFormat::Json);
65 /// let x1 = InputConfig::new().set_data_format(DataFormat::String);
66 /// ```
67 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
68 mut self,
69 v: T,
70 ) -> Self {
71 self.data_format = v.into();
72 self
73 }
74
75 /// Sets the value of [source][crate::model::InputConfig::source].
76 ///
77 /// Note that all the setters affecting `source` are mutually
78 /// exclusive.
79 ///
80 /// # Example
81 /// ```ignore,no_run
82 /// # use google_cloud_optimization_v1::model::InputConfig;
83 /// use google_cloud_optimization_v1::model::GcsSource;
84 /// let x = InputConfig::new().set_source(Some(
85 /// google_cloud_optimization_v1::model::input_config::Source::GcsSource(GcsSource::default().into())));
86 /// ```
87 pub fn set_source<
88 T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
89 >(
90 mut self,
91 v: T,
92 ) -> Self {
93 self.source = v.into();
94 self
95 }
96
97 /// The value of [source][crate::model::InputConfig::source]
98 /// if it holds a `GcsSource`, `None` if the field is not set or
99 /// holds a different branch.
100 pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
101 #[allow(unreachable_patterns)]
102 self.source.as_ref().and_then(|v| match v {
103 crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
104 _ => std::option::Option::None,
105 })
106 }
107
108 /// Sets the value of [source][crate::model::InputConfig::source]
109 /// to hold a `GcsSource`.
110 ///
111 /// Note that all the setters affecting `source` are
112 /// mutually exclusive.
113 ///
114 /// # Example
115 /// ```ignore,no_run
116 /// # use google_cloud_optimization_v1::model::InputConfig;
117 /// use google_cloud_optimization_v1::model::GcsSource;
118 /// let x = InputConfig::new().set_gcs_source(GcsSource::default()/* use setters */);
119 /// assert!(x.gcs_source().is_some());
120 /// ```
121 pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
122 mut self,
123 v: T,
124 ) -> Self {
125 self.source =
126 std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
127 self
128 }
129}
130
131impl wkt::message::Message for InputConfig {
132 fn typename() -> &'static str {
133 "type.googleapis.com/google.cloud.optimization.v1.InputConfig"
134 }
135}
136
137/// Defines additional types related to [InputConfig].
138pub mod input_config {
139 #[allow(unused_imports)]
140 use super::*;
141
142 /// The location of the input model in cloud storage.
143 /// Required.
144 #[derive(Clone, Debug, PartialEq)]
145 #[non_exhaustive]
146 pub enum Source {
147 /// The Google Cloud Storage location to read the input from. This must be a
148 /// single file.
149 GcsSource(std::boxed::Box<crate::model::GcsSource>),
150 }
151}
152
153/// The desired output location.
154#[derive(Clone, Default, PartialEq)]
155#[non_exhaustive]
156pub struct OutputConfig {
157 /// The output data format that used to store the results in Cloud Storage.
158 pub data_format: crate::model::DataFormat,
159
160 /// The location of the output result in cloud storage.
161 /// Required.
162 pub destination: std::option::Option<crate::model::output_config::Destination>,
163
164 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
165}
166
167impl OutputConfig {
168 pub fn new() -> Self {
169 std::default::Default::default()
170 }
171
172 /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
173 ///
174 /// # Example
175 /// ```ignore,no_run
176 /// # use google_cloud_optimization_v1::model::OutputConfig;
177 /// use google_cloud_optimization_v1::model::DataFormat;
178 /// let x0 = OutputConfig::new().set_data_format(DataFormat::Json);
179 /// let x1 = OutputConfig::new().set_data_format(DataFormat::String);
180 /// ```
181 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
182 mut self,
183 v: T,
184 ) -> Self {
185 self.data_format = v.into();
186 self
187 }
188
189 /// Sets the value of [destination][crate::model::OutputConfig::destination].
190 ///
191 /// Note that all the setters affecting `destination` are mutually
192 /// exclusive.
193 ///
194 /// # Example
195 /// ```ignore,no_run
196 /// # use google_cloud_optimization_v1::model::OutputConfig;
197 /// use google_cloud_optimization_v1::model::GcsDestination;
198 /// let x = OutputConfig::new().set_destination(Some(
199 /// google_cloud_optimization_v1::model::output_config::Destination::GcsDestination(GcsDestination::default().into())));
200 /// ```
201 pub fn set_destination<
202 T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
203 >(
204 mut self,
205 v: T,
206 ) -> Self {
207 self.destination = v.into();
208 self
209 }
210
211 /// The value of [destination][crate::model::OutputConfig::destination]
212 /// if it holds a `GcsDestination`, `None` if the field is not set or
213 /// holds a different branch.
214 pub fn gcs_destination(
215 &self,
216 ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
217 #[allow(unreachable_patterns)]
218 self.destination.as_ref().and_then(|v| match v {
219 crate::model::output_config::Destination::GcsDestination(v) => {
220 std::option::Option::Some(v)
221 }
222 _ => std::option::Option::None,
223 })
224 }
225
226 /// Sets the value of [destination][crate::model::OutputConfig::destination]
227 /// to hold a `GcsDestination`.
228 ///
229 /// Note that all the setters affecting `destination` are
230 /// mutually exclusive.
231 ///
232 /// # Example
233 /// ```ignore,no_run
234 /// # use google_cloud_optimization_v1::model::OutputConfig;
235 /// use google_cloud_optimization_v1::model::GcsDestination;
236 /// let x = OutputConfig::new().set_gcs_destination(GcsDestination::default()/* use setters */);
237 /// assert!(x.gcs_destination().is_some());
238 /// ```
239 pub fn set_gcs_destination<
240 T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
241 >(
242 mut self,
243 v: T,
244 ) -> Self {
245 self.destination = std::option::Option::Some(
246 crate::model::output_config::Destination::GcsDestination(v.into()),
247 );
248 self
249 }
250}
251
252impl wkt::message::Message for OutputConfig {
253 fn typename() -> &'static str {
254 "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
255 }
256}
257
258/// Defines additional types related to [OutputConfig].
259pub mod output_config {
260 #[allow(unused_imports)]
261 use super::*;
262
263 /// The location of the output result in cloud storage.
264 /// Required.
265 #[derive(Clone, Debug, PartialEq)]
266 #[non_exhaustive]
267 pub enum Destination {
268 /// The Google Cloud Storage location to write the output to.
269 GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
270 }
271}
272
273/// The Google Cloud Storage location where the input file will be read from.
274#[derive(Clone, Default, PartialEq)]
275#[non_exhaustive]
276pub struct GcsSource {
277 /// Required. URI of the Google Cloud Storage location.
278 pub uri: std::string::String,
279
280 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
281}
282
283impl GcsSource {
284 pub fn new() -> Self {
285 std::default::Default::default()
286 }
287
288 /// Sets the value of [uri][crate::model::GcsSource::uri].
289 ///
290 /// # Example
291 /// ```ignore,no_run
292 /// # use google_cloud_optimization_v1::model::GcsSource;
293 /// let x = GcsSource::new().set_uri("example");
294 /// ```
295 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
296 self.uri = v.into();
297 self
298 }
299}
300
301impl wkt::message::Message for GcsSource {
302 fn typename() -> &'static str {
303 "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
304 }
305}
306
307/// The Google Cloud Storage location where the output file will be written to.
308#[derive(Clone, Default, PartialEq)]
309#[non_exhaustive]
310pub struct GcsDestination {
311 /// Required. URI of the Google Cloud Storage location.
312 pub uri: std::string::String,
313
314 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
315}
316
317impl GcsDestination {
318 pub fn new() -> Self {
319 std::default::Default::default()
320 }
321
322 /// Sets the value of [uri][crate::model::GcsDestination::uri].
323 ///
324 /// # Example
325 /// ```ignore,no_run
326 /// # use google_cloud_optimization_v1::model::GcsDestination;
327 /// let x = GcsDestination::new().set_uri("example");
328 /// ```
329 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
330 self.uri = v.into();
331 self
332 }
333}
334
335impl wkt::message::Message for GcsDestination {
336 fn typename() -> &'static str {
337 "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
338 }
339}
340
341/// The long running operation metadata for async model related methods.
342#[derive(Clone, Default, PartialEq)]
343#[non_exhaustive]
344pub struct AsyncModelMetadata {
345 /// The state of the current operation.
346 pub state: crate::model::async_model_metadata::State,
347
348 /// A message providing more details about the current state of the operation.
349 /// For example, the error message if the operation is failed.
350 pub state_message: std::string::String,
351
352 /// The creation time of the operation.
353 pub create_time: std::option::Option<wkt::Timestamp>,
354
355 /// The last update time of the operation.
356 pub update_time: std::option::Option<wkt::Timestamp>,
357
358 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
359}
360
361impl AsyncModelMetadata {
362 pub fn new() -> Self {
363 std::default::Default::default()
364 }
365
366 /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
367 ///
368 /// # Example
369 /// ```ignore,no_run
370 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
371 /// use google_cloud_optimization_v1::model::async_model_metadata::State;
372 /// let x0 = AsyncModelMetadata::new().set_state(State::Running);
373 /// let x1 = AsyncModelMetadata::new().set_state(State::Succeeded);
374 /// let x2 = AsyncModelMetadata::new().set_state(State::Cancelled);
375 /// ```
376 pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
377 mut self,
378 v: T,
379 ) -> Self {
380 self.state = v.into();
381 self
382 }
383
384 /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
385 ///
386 /// # Example
387 /// ```ignore,no_run
388 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
389 /// let x = AsyncModelMetadata::new().set_state_message("example");
390 /// ```
391 pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
392 self.state_message = v.into();
393 self
394 }
395
396 /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
397 ///
398 /// # Example
399 /// ```ignore,no_run
400 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
401 /// use wkt::Timestamp;
402 /// let x = AsyncModelMetadata::new().set_create_time(Timestamp::default()/* use setters */);
403 /// ```
404 pub fn set_create_time<T>(mut self, v: T) -> Self
405 where
406 T: std::convert::Into<wkt::Timestamp>,
407 {
408 self.create_time = std::option::Option::Some(v.into());
409 self
410 }
411
412 /// Sets or clears the value of [create_time][crate::model::AsyncModelMetadata::create_time].
413 ///
414 /// # Example
415 /// ```ignore,no_run
416 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
417 /// use wkt::Timestamp;
418 /// let x = AsyncModelMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
419 /// let x = AsyncModelMetadata::new().set_or_clear_create_time(None::<Timestamp>);
420 /// ```
421 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
422 where
423 T: std::convert::Into<wkt::Timestamp>,
424 {
425 self.create_time = v.map(|x| x.into());
426 self
427 }
428
429 /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
430 ///
431 /// # Example
432 /// ```ignore,no_run
433 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
434 /// use wkt::Timestamp;
435 /// let x = AsyncModelMetadata::new().set_update_time(Timestamp::default()/* use setters */);
436 /// ```
437 pub fn set_update_time<T>(mut self, v: T) -> Self
438 where
439 T: std::convert::Into<wkt::Timestamp>,
440 {
441 self.update_time = std::option::Option::Some(v.into());
442 self
443 }
444
445 /// Sets or clears the value of [update_time][crate::model::AsyncModelMetadata::update_time].
446 ///
447 /// # Example
448 /// ```ignore,no_run
449 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
450 /// use wkt::Timestamp;
451 /// let x = AsyncModelMetadata::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
452 /// let x = AsyncModelMetadata::new().set_or_clear_update_time(None::<Timestamp>);
453 /// ```
454 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
455 where
456 T: std::convert::Into<wkt::Timestamp>,
457 {
458 self.update_time = v.map(|x| x.into());
459 self
460 }
461}
462
463impl wkt::message::Message for AsyncModelMetadata {
464 fn typename() -> &'static str {
465 "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
466 }
467}
468
469/// Defines additional types related to [AsyncModelMetadata].
470pub mod async_model_metadata {
471 #[allow(unused_imports)]
472 use super::*;
473
474 /// Possible states of the operation.
475 ///
476 /// # Working with unknown values
477 ///
478 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
479 /// additional enum variants at any time. Adding new variants is not considered
480 /// a breaking change. Applications should write their code in anticipation of:
481 ///
482 /// - New values appearing in future releases of the client library, **and**
483 /// - New values received dynamically, without application changes.
484 ///
485 /// Please consult the [Working with enums] section in the user guide for some
486 /// guidelines.
487 ///
488 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
489 #[derive(Clone, Debug, PartialEq)]
490 #[non_exhaustive]
491 pub enum State {
492 /// The default value. This value is used if the state is omitted.
493 Unspecified,
494 /// Request is being processed.
495 Running,
496 /// The operation completed successfully.
497 Succeeded,
498 /// The operation was cancelled.
499 Cancelled,
500 /// The operation has failed.
501 Failed,
502 /// If set, the enum was initialized with an unknown value.
503 ///
504 /// Applications can examine the value using [State::value] or
505 /// [State::name].
506 UnknownValue(state::UnknownValue),
507 }
508
509 #[doc(hidden)]
510 pub mod state {
511 #[allow(unused_imports)]
512 use super::*;
513 #[derive(Clone, Debug, PartialEq)]
514 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
515 }
516
517 impl State {
518 /// Gets the enum value.
519 ///
520 /// Returns `None` if the enum contains an unknown value deserialized from
521 /// the string representation of enums.
522 pub fn value(&self) -> std::option::Option<i32> {
523 match self {
524 Self::Unspecified => std::option::Option::Some(0),
525 Self::Running => std::option::Option::Some(1),
526 Self::Succeeded => std::option::Option::Some(2),
527 Self::Cancelled => std::option::Option::Some(3),
528 Self::Failed => std::option::Option::Some(4),
529 Self::UnknownValue(u) => u.0.value(),
530 }
531 }
532
533 /// Gets the enum value as a string.
534 ///
535 /// Returns `None` if the enum contains an unknown value deserialized from
536 /// the integer representation of enums.
537 pub fn name(&self) -> std::option::Option<&str> {
538 match self {
539 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
540 Self::Running => std::option::Option::Some("RUNNING"),
541 Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
542 Self::Cancelled => std::option::Option::Some("CANCELLED"),
543 Self::Failed => std::option::Option::Some("FAILED"),
544 Self::UnknownValue(u) => u.0.name(),
545 }
546 }
547 }
548
549 impl std::default::Default for State {
550 fn default() -> Self {
551 use std::convert::From;
552 Self::from(0)
553 }
554 }
555
556 impl std::fmt::Display for State {
557 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
558 wkt::internal::display_enum(f, self.name(), self.value())
559 }
560 }
561
562 impl std::convert::From<i32> for State {
563 fn from(value: i32) -> Self {
564 match value {
565 0 => Self::Unspecified,
566 1 => Self::Running,
567 2 => Self::Succeeded,
568 3 => Self::Cancelled,
569 4 => Self::Failed,
570 _ => Self::UnknownValue(state::UnknownValue(
571 wkt::internal::UnknownEnumValue::Integer(value),
572 )),
573 }
574 }
575 }
576
577 impl std::convert::From<&str> for State {
578 fn from(value: &str) -> Self {
579 use std::string::ToString;
580 match value {
581 "STATE_UNSPECIFIED" => Self::Unspecified,
582 "RUNNING" => Self::Running,
583 "SUCCEEDED" => Self::Succeeded,
584 "CANCELLED" => Self::Cancelled,
585 "FAILED" => Self::Failed,
586 _ => Self::UnknownValue(state::UnknownValue(
587 wkt::internal::UnknownEnumValue::String(value.to_string()),
588 )),
589 }
590 }
591 }
592
593 impl serde::ser::Serialize for State {
594 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
595 where
596 S: serde::Serializer,
597 {
598 match self {
599 Self::Unspecified => serializer.serialize_i32(0),
600 Self::Running => serializer.serialize_i32(1),
601 Self::Succeeded => serializer.serialize_i32(2),
602 Self::Cancelled => serializer.serialize_i32(3),
603 Self::Failed => serializer.serialize_i32(4),
604 Self::UnknownValue(u) => u.0.serialize(serializer),
605 }
606 }
607 }
608
609 impl<'de> serde::de::Deserialize<'de> for State {
610 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
611 where
612 D: serde::Deserializer<'de>,
613 {
614 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
615 ".google.cloud.optimization.v1.AsyncModelMetadata.State",
616 ))
617 }
618 }
619}
620
621/// Request to be given to a tour optimization solver which defines the
622/// shipment model to solve as well as optimization parameters.
623#[derive(Clone, Default, PartialEq)]
624#[non_exhaustive]
625pub struct OptimizeToursRequest {
626 /// Required. Target project and location to make a call.
627 ///
628 /// Format: `projects/{project-id}/locations/{location-id}`.
629 ///
630 /// If no location is specified, a region will be chosen automatically.
631 pub parent: std::string::String,
632
633 /// If this timeout is set, the server returns a response before the timeout
634 /// period has elapsed or the server deadline for synchronous requests is
635 /// reached, whichever is sooner.
636 ///
637 /// For asynchronous requests, the server will generate a solution (if
638 /// possible) before the timeout has elapsed.
639 pub timeout: std::option::Option<wkt::Duration>,
640
641 /// Shipment model to solve.
642 pub model: std::option::Option<crate::model::ShipmentModel>,
643
644 /// By default, the solving mode is `DEFAULT_SOLVE` (0).
645 pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
646
647 /// Search mode used to solve the request.
648 pub search_mode: crate::model::optimize_tours_request::SearchMode,
649
650 /// Guide the optimization algorithm in finding a first solution that is
651 /// similar to a previous solution.
652 ///
653 /// The model is constrained when the first solution is built.
654 /// Any shipments not performed on a route are implicitly skipped in the first
655 /// solution, but they may be performed in successive solutions.
656 ///
657 /// The solution must satisfy some basic validity assumptions:
658 ///
659 /// * for all routes, `vehicle_index` must be in range and not be duplicated.
660 /// * for all visits, `shipment_index` and `visit_request_index` must be
661 /// in range.
662 /// * a shipment may only be referenced on one route.
663 /// * the pickup of a pickup-delivery shipment must be performed before
664 /// the delivery.
665 /// * no more than one pickup alternative or delivery alternative of
666 /// a shipment may be performed.
667 /// * for all routes, times are increasing (i.e., `vehicle_start_time
668 /// <= visits[0].start_time <= visits[1].start_time ...
669 /// <= vehicle_end_time`).
670 /// * a shipment may only be performed on a vehicle that is allowed. A
671 /// vehicle is allowed if
672 /// [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
673 /// is empty or its `vehicle_index` is included in
674 /// [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
675 ///
676 /// If the injected solution is not feasible, a validation error is not
677 /// necessarily returned and an error indicating infeasibility may be returned
678 /// instead.
679 ///
680 /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
681 pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
682
683 /// Constrain the optimization algorithm to find a final solution that is
684 /// similar to a previous solution. For example, this may be used to freeze
685 /// portions of routes which have already been completed or which are to be
686 /// completed but must not be modified.
687 ///
688 /// If the injected solution is not feasible, a validation error is not
689 /// necessarily returned and an error indicating infeasibility may be returned
690 /// instead.
691 pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
692
693 /// If non-empty, the given routes will be refreshed, without modifying their
694 /// underlying sequence of visits or travel times: only other details will be
695 /// updated. This does not solve the model.
696 ///
697 /// As of 2020/11, this only populates the polylines of non-empty routes and
698 /// requires that `populate_polylines` is true.
699 ///
700 /// The `route_polyline` fields of the passed-in routes may be inconsistent
701 /// with route `transitions`.
702 ///
703 /// This field must not be used together with `injected_first_solution_routes`
704 /// or `injected_solution_constraint`.
705 ///
706 /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
707 /// Polylines are still populated between all visits in all non-empty routes
708 /// regardless of whether the related shipments or vehicles are ignored.
709 pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
710
711 /// If true:
712 ///
713 /// * uses
714 /// [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
715 /// instead of `vehicle_index` to
716 /// match routes in an injected solution with vehicles in the request;
717 /// reuses the mapping of original
718 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
719 /// to new
720 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
721 /// to update
722 /// [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
723 /// if non-empty, but the mapping must be unambiguous (i.e., multiple
724 /// `ShipmentRoute`s must not share the same original `vehicle_index`).
725 /// * uses
726 /// [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
727 /// instead of `shipment_index`
728 /// to match visits in an injected solution with shipments in the request;
729 /// * uses
730 /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
731 /// instead of
732 /// [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
733 /// to
734 /// match skipped shipments in the injected solution with request
735 /// shipments.
736 ///
737 /// This interpretation applies to the `injected_first_solution_routes`,
738 /// `injected_solution_constraint`, and `refresh_details_routes` fields.
739 /// It can be used when shipment or vehicle indices in the request have
740 /// changed since the solution was created, perhaps because shipments or
741 /// vehicles have been removed from or added to the request.
742 ///
743 /// If true, labels in the following categories must appear at most once in
744 /// their category:
745 ///
746 /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
747 /// request;
748 /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
749 /// request;
750 /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
751 /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
752 /// the injected solution (except pickup/delivery visit pairs, whose
753 /// `shipment_label` must appear twice).
754 ///
755 /// If a `vehicle_label` in the injected solution does not correspond to a
756 /// request vehicle, the corresponding route is removed from the solution
757 /// along with its visits. If a `shipment_label` in the injected solution does
758 /// not correspond to a request shipment, the corresponding visit is removed
759 /// from the solution. If a
760 /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
761 /// in the injected solution does not correspond to a request shipment, the
762 /// `SkippedShipment` is removed from the solution.
763 ///
764 /// Removing route visits or entire routes from an injected solution may
765 /// have an effect on the implied constraints, which may lead to change in
766 /// solution, validation errors, or infeasibility.
767 ///
768 /// NOTE: The caller must ensure that each
769 /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
770 /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
771 /// identifies a vehicle (resp. shipment) entity used across the two relevant
772 /// requests: the past request that produced the `OptimizeToursResponse` used
773 /// in the injected solution and the current request that includes the injected
774 /// solution. The uniqueness checks described above are not enough to guarantee
775 /// this requirement.
776 ///
777 /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
778 /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
779 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
780 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
781 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
782 /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
783 /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
784 /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
785 pub interpret_injected_solutions_using_labels: bool,
786
787 /// Consider traffic estimation in calculating `ShipmentRoute` fields
788 /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
789 /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
790 /// and `vehicle_end_time`; in setting the
791 /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
792 /// field, and in calculating the
793 /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
794 /// field.
795 ///
796 /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
797 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
798 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
799 /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
800 pub consider_road_traffic: bool,
801
802 /// If true, polylines will be populated in response `ShipmentRoute`s.
803 pub populate_polylines: bool,
804
805 /// If true, polylines will be populated in response
806 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
807 /// Note that in this case, the polylines will also be populated in the
808 /// deprecated `travel_steps`.
809 ///
810 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
811 pub populate_transition_polylines: bool,
812
813 /// If this is set, then the request can have a deadline
814 /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
815 /// Otherwise, the maximum deadline is only 30 minutes.
816 /// Note that long-lived requests have a significantly larger (but still small)
817 /// risk of interruption.
818 pub allow_large_deadline_despite_interruption_risk: bool,
819
820 /// If true, travel distances will be computed using geodesic distances instead
821 /// of Google Maps distances, and travel times will be computed using geodesic
822 /// distances with a speed defined by `geodesic_meters_per_second`.
823 pub use_geodesic_distances: bool,
824
825 /// When `use_geodesic_distances` is true, this field must be set and defines
826 /// the speed applied to compute travel times. Its value must be at least 1.0
827 /// meters/seconds.
828 pub geodesic_meters_per_second: std::option::Option<f64>,
829
830 /// Truncates the number of validation errors returned. These errors are
831 /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
832 /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
833 /// unless solving_mode=VALIDATE_ONLY: see the
834 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
835 /// field.
836 /// This defaults to 100 and is capped at 10,000.
837 ///
838 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
839 pub max_validation_errors: std::option::Option<i32>,
840
841 /// Label that may be used to identify this request, reported back in the
842 /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
843 ///
844 /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
845 pub label: std::string::String,
846
847 /// Deprecated: Use
848 /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
849 /// instead. If true, polylines will be populated in response
850 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
851 /// Note that in this case, the polylines will also be populated in the
852 /// deprecated `travel_steps`.
853 ///
854 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
855 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
856 #[deprecated]
857 pub populate_travel_step_polylines: bool,
858
859 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
860}
861
862impl OptimizeToursRequest {
863 pub fn new() -> Self {
864 std::default::Default::default()
865 }
866
867 /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
868 ///
869 /// # Example
870 /// ```ignore,no_run
871 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
872 /// let x = OptimizeToursRequest::new().set_parent("example");
873 /// ```
874 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
875 self.parent = v.into();
876 self
877 }
878
879 /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
880 ///
881 /// # Example
882 /// ```ignore,no_run
883 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
884 /// use wkt::Duration;
885 /// let x = OptimizeToursRequest::new().set_timeout(Duration::default()/* use setters */);
886 /// ```
887 pub fn set_timeout<T>(mut self, v: T) -> Self
888 where
889 T: std::convert::Into<wkt::Duration>,
890 {
891 self.timeout = std::option::Option::Some(v.into());
892 self
893 }
894
895 /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
896 ///
897 /// # Example
898 /// ```ignore,no_run
899 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
900 /// use wkt::Duration;
901 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(Some(Duration::default()/* use setters */));
902 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(None::<Duration>);
903 /// ```
904 pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
905 where
906 T: std::convert::Into<wkt::Duration>,
907 {
908 self.timeout = v.map(|x| x.into());
909 self
910 }
911
912 /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
913 ///
914 /// # Example
915 /// ```ignore,no_run
916 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
917 /// use google_cloud_optimization_v1::model::ShipmentModel;
918 /// let x = OptimizeToursRequest::new().set_model(ShipmentModel::default()/* use setters */);
919 /// ```
920 pub fn set_model<T>(mut self, v: T) -> Self
921 where
922 T: std::convert::Into<crate::model::ShipmentModel>,
923 {
924 self.model = std::option::Option::Some(v.into());
925 self
926 }
927
928 /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
929 ///
930 /// # Example
931 /// ```ignore,no_run
932 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
933 /// use google_cloud_optimization_v1::model::ShipmentModel;
934 /// let x = OptimizeToursRequest::new().set_or_clear_model(Some(ShipmentModel::default()/* use setters */));
935 /// let x = OptimizeToursRequest::new().set_or_clear_model(None::<ShipmentModel>);
936 /// ```
937 pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
938 where
939 T: std::convert::Into<crate::model::ShipmentModel>,
940 {
941 self.model = v.map(|x| x.into());
942 self
943 }
944
945 /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
946 ///
947 /// # Example
948 /// ```ignore,no_run
949 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
950 /// use google_cloud_optimization_v1::model::optimize_tours_request::SolvingMode;
951 /// let x0 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::ValidateOnly);
952 /// let x1 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::DetectSomeInfeasibleShipments);
953 /// ```
954 pub fn set_solving_mode<
955 T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
956 >(
957 mut self,
958 v: T,
959 ) -> Self {
960 self.solving_mode = v.into();
961 self
962 }
963
964 /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
965 ///
966 /// # Example
967 /// ```ignore,no_run
968 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
969 /// use google_cloud_optimization_v1::model::optimize_tours_request::SearchMode;
970 /// let x0 = OptimizeToursRequest::new().set_search_mode(SearchMode::ReturnFast);
971 /// let x1 = OptimizeToursRequest::new().set_search_mode(SearchMode::ConsumeAllAvailableTime);
972 /// ```
973 pub fn set_search_mode<
974 T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
975 >(
976 mut self,
977 v: T,
978 ) -> Self {
979 self.search_mode = v.into();
980 self
981 }
982
983 /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
984 ///
985 /// # Example
986 /// ```ignore,no_run
987 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
988 /// use google_cloud_optimization_v1::model::ShipmentRoute;
989 /// let x = OptimizeToursRequest::new()
990 /// .set_injected_first_solution_routes([
991 /// ShipmentRoute::default()/* use setters */,
992 /// ShipmentRoute::default()/* use (different) setters */,
993 /// ]);
994 /// ```
995 pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
996 where
997 T: std::iter::IntoIterator<Item = V>,
998 V: std::convert::Into<crate::model::ShipmentRoute>,
999 {
1000 use std::iter::Iterator;
1001 self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
1002 self
1003 }
1004
1005 /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1006 ///
1007 /// # Example
1008 /// ```ignore,no_run
1009 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1010 /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1011 /// let x = OptimizeToursRequest::new().set_injected_solution_constraint(InjectedSolutionConstraint::default()/* use setters */);
1012 /// ```
1013 pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
1014 where
1015 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1016 {
1017 self.injected_solution_constraint = std::option::Option::Some(v.into());
1018 self
1019 }
1020
1021 /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1022 ///
1023 /// # Example
1024 /// ```ignore,no_run
1025 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1026 /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1027 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(Some(InjectedSolutionConstraint::default()/* use setters */));
1028 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(None::<InjectedSolutionConstraint>);
1029 /// ```
1030 pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
1031 where
1032 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1033 {
1034 self.injected_solution_constraint = v.map(|x| x.into());
1035 self
1036 }
1037
1038 /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
1039 ///
1040 /// # Example
1041 /// ```ignore,no_run
1042 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1043 /// use google_cloud_optimization_v1::model::ShipmentRoute;
1044 /// let x = OptimizeToursRequest::new()
1045 /// .set_refresh_details_routes([
1046 /// ShipmentRoute::default()/* use setters */,
1047 /// ShipmentRoute::default()/* use (different) setters */,
1048 /// ]);
1049 /// ```
1050 pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
1051 where
1052 T: std::iter::IntoIterator<Item = V>,
1053 V: std::convert::Into<crate::model::ShipmentRoute>,
1054 {
1055 use std::iter::Iterator;
1056 self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
1057 self
1058 }
1059
1060 /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
1061 ///
1062 /// # Example
1063 /// ```ignore,no_run
1064 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1065 /// let x = OptimizeToursRequest::new().set_interpret_injected_solutions_using_labels(true);
1066 /// ```
1067 pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
1068 mut self,
1069 v: T,
1070 ) -> Self {
1071 self.interpret_injected_solutions_using_labels = v.into();
1072 self
1073 }
1074
1075 /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
1076 ///
1077 /// # Example
1078 /// ```ignore,no_run
1079 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1080 /// let x = OptimizeToursRequest::new().set_consider_road_traffic(true);
1081 /// ```
1082 pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1083 self.consider_road_traffic = v.into();
1084 self
1085 }
1086
1087 /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
1088 ///
1089 /// # Example
1090 /// ```ignore,no_run
1091 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1092 /// let x = OptimizeToursRequest::new().set_populate_polylines(true);
1093 /// ```
1094 pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1095 self.populate_polylines = v.into();
1096 self
1097 }
1098
1099 /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
1100 ///
1101 /// # Example
1102 /// ```ignore,no_run
1103 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1104 /// let x = OptimizeToursRequest::new().set_populate_transition_polylines(true);
1105 /// ```
1106 pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1107 self.populate_transition_polylines = v.into();
1108 self
1109 }
1110
1111 /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
1112 ///
1113 /// # Example
1114 /// ```ignore,no_run
1115 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1116 /// let x = OptimizeToursRequest::new().set_allow_large_deadline_despite_interruption_risk(true);
1117 /// ```
1118 pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1119 mut self,
1120 v: T,
1121 ) -> Self {
1122 self.allow_large_deadline_despite_interruption_risk = v.into();
1123 self
1124 }
1125
1126 /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
1127 ///
1128 /// # Example
1129 /// ```ignore,no_run
1130 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1131 /// let x = OptimizeToursRequest::new().set_use_geodesic_distances(true);
1132 /// ```
1133 pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1134 self.use_geodesic_distances = v.into();
1135 self
1136 }
1137
1138 /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1139 ///
1140 /// # Example
1141 /// ```ignore,no_run
1142 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1143 /// let x = OptimizeToursRequest::new().set_geodesic_meters_per_second(42.0);
1144 /// ```
1145 pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1146 where
1147 T: std::convert::Into<f64>,
1148 {
1149 self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1150 self
1151 }
1152
1153 /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1154 ///
1155 /// # Example
1156 /// ```ignore,no_run
1157 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1158 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(Some(42.0));
1159 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(None::<f32>);
1160 /// ```
1161 pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1162 where
1163 T: std::convert::Into<f64>,
1164 {
1165 self.geodesic_meters_per_second = v.map(|x| x.into());
1166 self
1167 }
1168
1169 /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1170 ///
1171 /// # Example
1172 /// ```ignore,no_run
1173 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1174 /// let x = OptimizeToursRequest::new().set_max_validation_errors(42);
1175 /// ```
1176 pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1177 where
1178 T: std::convert::Into<i32>,
1179 {
1180 self.max_validation_errors = std::option::Option::Some(v.into());
1181 self
1182 }
1183
1184 /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1185 ///
1186 /// # Example
1187 /// ```ignore,no_run
1188 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1189 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(Some(42));
1190 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(None::<i32>);
1191 /// ```
1192 pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1193 where
1194 T: std::convert::Into<i32>,
1195 {
1196 self.max_validation_errors = v.map(|x| x.into());
1197 self
1198 }
1199
1200 /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
1201 ///
1202 /// # Example
1203 /// ```ignore,no_run
1204 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1205 /// let x = OptimizeToursRequest::new().set_label("example");
1206 /// ```
1207 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1208 self.label = v.into();
1209 self
1210 }
1211
1212 /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
1213 ///
1214 /// # Example
1215 /// ```ignore,no_run
1216 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1217 /// let x = OptimizeToursRequest::new().set_populate_travel_step_polylines(true);
1218 /// ```
1219 #[deprecated]
1220 pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1221 self.populate_travel_step_polylines = v.into();
1222 self
1223 }
1224}
1225
1226impl wkt::message::Message for OptimizeToursRequest {
1227 fn typename() -> &'static str {
1228 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
1229 }
1230}
1231
1232/// Defines additional types related to [OptimizeToursRequest].
1233pub mod optimize_tours_request {
1234 #[allow(unused_imports)]
1235 use super::*;
1236
1237 /// Defines how the solver should handle the request. In all modes but
1238 /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
1239 /// `INVALID_REQUEST` error. See
1240 /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
1241 /// to cap the number of errors returned.
1242 ///
1243 /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
1244 ///
1245 /// # Working with unknown values
1246 ///
1247 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1248 /// additional enum variants at any time. Adding new variants is not considered
1249 /// a breaking change. Applications should write their code in anticipation of:
1250 ///
1251 /// - New values appearing in future releases of the client library, **and**
1252 /// - New values received dynamically, without application changes.
1253 ///
1254 /// Please consult the [Working with enums] section in the user guide for some
1255 /// guidelines.
1256 ///
1257 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1258 #[derive(Clone, Debug, PartialEq)]
1259 #[non_exhaustive]
1260 pub enum SolvingMode {
1261 /// Solve the model.
1262 DefaultSolve,
1263 /// Only validates the model without solving it: populates as many
1264 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1265 /// as possible.
1266 ///
1267 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1268 ValidateOnly,
1269 /// Only populates
1270 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1271 /// or
1272 /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
1273 /// and doesn't actually solve the rest of the request (`status` and `routes`
1274 /// are unset in the response).
1275 /// If infeasibilities in `injected_solution_constraint` routes are detected
1276 /// they are populated in the
1277 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1278 /// field and
1279 /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
1280 /// is left empty.
1281 ///
1282 /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
1283 /// ones that are detected as infeasible during preprocessing.
1284 ///
1285 /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
1286 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1287 DetectSomeInfeasibleShipments,
1288 /// If set, the enum was initialized with an unknown value.
1289 ///
1290 /// Applications can examine the value using [SolvingMode::value] or
1291 /// [SolvingMode::name].
1292 UnknownValue(solving_mode::UnknownValue),
1293 }
1294
1295 #[doc(hidden)]
1296 pub mod solving_mode {
1297 #[allow(unused_imports)]
1298 use super::*;
1299 #[derive(Clone, Debug, PartialEq)]
1300 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1301 }
1302
1303 impl SolvingMode {
1304 /// Gets the enum value.
1305 ///
1306 /// Returns `None` if the enum contains an unknown value deserialized from
1307 /// the string representation of enums.
1308 pub fn value(&self) -> std::option::Option<i32> {
1309 match self {
1310 Self::DefaultSolve => std::option::Option::Some(0),
1311 Self::ValidateOnly => std::option::Option::Some(1),
1312 Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
1313 Self::UnknownValue(u) => u.0.value(),
1314 }
1315 }
1316
1317 /// Gets the enum value as a string.
1318 ///
1319 /// Returns `None` if the enum contains an unknown value deserialized from
1320 /// the integer representation of enums.
1321 pub fn name(&self) -> std::option::Option<&str> {
1322 match self {
1323 Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
1324 Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
1325 Self::DetectSomeInfeasibleShipments => {
1326 std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
1327 }
1328 Self::UnknownValue(u) => u.0.name(),
1329 }
1330 }
1331 }
1332
1333 impl std::default::Default for SolvingMode {
1334 fn default() -> Self {
1335 use std::convert::From;
1336 Self::from(0)
1337 }
1338 }
1339
1340 impl std::fmt::Display for SolvingMode {
1341 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1342 wkt::internal::display_enum(f, self.name(), self.value())
1343 }
1344 }
1345
1346 impl std::convert::From<i32> for SolvingMode {
1347 fn from(value: i32) -> Self {
1348 match value {
1349 0 => Self::DefaultSolve,
1350 1 => Self::ValidateOnly,
1351 2 => Self::DetectSomeInfeasibleShipments,
1352 _ => Self::UnknownValue(solving_mode::UnknownValue(
1353 wkt::internal::UnknownEnumValue::Integer(value),
1354 )),
1355 }
1356 }
1357 }
1358
1359 impl std::convert::From<&str> for SolvingMode {
1360 fn from(value: &str) -> Self {
1361 use std::string::ToString;
1362 match value {
1363 "DEFAULT_SOLVE" => Self::DefaultSolve,
1364 "VALIDATE_ONLY" => Self::ValidateOnly,
1365 "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
1366 _ => Self::UnknownValue(solving_mode::UnknownValue(
1367 wkt::internal::UnknownEnumValue::String(value.to_string()),
1368 )),
1369 }
1370 }
1371 }
1372
1373 impl serde::ser::Serialize for SolvingMode {
1374 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1375 where
1376 S: serde::Serializer,
1377 {
1378 match self {
1379 Self::DefaultSolve => serializer.serialize_i32(0),
1380 Self::ValidateOnly => serializer.serialize_i32(1),
1381 Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
1382 Self::UnknownValue(u) => u.0.serialize(serializer),
1383 }
1384 }
1385 }
1386
1387 impl<'de> serde::de::Deserialize<'de> for SolvingMode {
1388 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1389 where
1390 D: serde::Deserializer<'de>,
1391 {
1392 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
1393 ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
1394 ))
1395 }
1396 }
1397
1398 /// Mode defining the behavior of the search, trading off latency versus
1399 /// solution quality. In all modes, the global request deadline is enforced.
1400 ///
1401 /// # Working with unknown values
1402 ///
1403 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1404 /// additional enum variants at any time. Adding new variants is not considered
1405 /// a breaking change. Applications should write their code in anticipation of:
1406 ///
1407 /// - New values appearing in future releases of the client library, **and**
1408 /// - New values received dynamically, without application changes.
1409 ///
1410 /// Please consult the [Working with enums] section in the user guide for some
1411 /// guidelines.
1412 ///
1413 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1414 #[derive(Clone, Debug, PartialEq)]
1415 #[non_exhaustive]
1416 pub enum SearchMode {
1417 /// Unspecified search mode, equivalent to `RETURN_FAST`.
1418 Unspecified,
1419 /// Stop the search after finding the first good solution.
1420 ReturnFast,
1421 /// Spend all the available time to search for better solutions.
1422 ConsumeAllAvailableTime,
1423 /// If set, the enum was initialized with an unknown value.
1424 ///
1425 /// Applications can examine the value using [SearchMode::value] or
1426 /// [SearchMode::name].
1427 UnknownValue(search_mode::UnknownValue),
1428 }
1429
1430 #[doc(hidden)]
1431 pub mod search_mode {
1432 #[allow(unused_imports)]
1433 use super::*;
1434 #[derive(Clone, Debug, PartialEq)]
1435 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1436 }
1437
1438 impl SearchMode {
1439 /// Gets the enum value.
1440 ///
1441 /// Returns `None` if the enum contains an unknown value deserialized from
1442 /// the string representation of enums.
1443 pub fn value(&self) -> std::option::Option<i32> {
1444 match self {
1445 Self::Unspecified => std::option::Option::Some(0),
1446 Self::ReturnFast => std::option::Option::Some(1),
1447 Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
1448 Self::UnknownValue(u) => u.0.value(),
1449 }
1450 }
1451
1452 /// Gets the enum value as a string.
1453 ///
1454 /// Returns `None` if the enum contains an unknown value deserialized from
1455 /// the integer representation of enums.
1456 pub fn name(&self) -> std::option::Option<&str> {
1457 match self {
1458 Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
1459 Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
1460 Self::ConsumeAllAvailableTime => {
1461 std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
1462 }
1463 Self::UnknownValue(u) => u.0.name(),
1464 }
1465 }
1466 }
1467
1468 impl std::default::Default for SearchMode {
1469 fn default() -> Self {
1470 use std::convert::From;
1471 Self::from(0)
1472 }
1473 }
1474
1475 impl std::fmt::Display for SearchMode {
1476 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1477 wkt::internal::display_enum(f, self.name(), self.value())
1478 }
1479 }
1480
1481 impl std::convert::From<i32> for SearchMode {
1482 fn from(value: i32) -> Self {
1483 match value {
1484 0 => Self::Unspecified,
1485 1 => Self::ReturnFast,
1486 2 => Self::ConsumeAllAvailableTime,
1487 _ => Self::UnknownValue(search_mode::UnknownValue(
1488 wkt::internal::UnknownEnumValue::Integer(value),
1489 )),
1490 }
1491 }
1492 }
1493
1494 impl std::convert::From<&str> for SearchMode {
1495 fn from(value: &str) -> Self {
1496 use std::string::ToString;
1497 match value {
1498 "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
1499 "RETURN_FAST" => Self::ReturnFast,
1500 "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
1501 _ => Self::UnknownValue(search_mode::UnknownValue(
1502 wkt::internal::UnknownEnumValue::String(value.to_string()),
1503 )),
1504 }
1505 }
1506 }
1507
1508 impl serde::ser::Serialize for SearchMode {
1509 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1510 where
1511 S: serde::Serializer,
1512 {
1513 match self {
1514 Self::Unspecified => serializer.serialize_i32(0),
1515 Self::ReturnFast => serializer.serialize_i32(1),
1516 Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
1517 Self::UnknownValue(u) => u.0.serialize(serializer),
1518 }
1519 }
1520 }
1521
1522 impl<'de> serde::de::Deserialize<'de> for SearchMode {
1523 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1524 where
1525 D: serde::Deserializer<'de>,
1526 {
1527 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
1528 ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
1529 ))
1530 }
1531 }
1532}
1533
1534/// Response after solving a tour optimization problem containing the routes
1535/// followed by each vehicle, the shipments which have been skipped and the
1536/// overall cost of the solution.
1537#[derive(Clone, Default, PartialEq)]
1538#[non_exhaustive]
1539pub struct OptimizeToursResponse {
1540 /// Routes computed for each vehicle; the i-th route corresponds to the i-th
1541 /// vehicle in the model.
1542 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
1543
1544 /// Copy of the
1545 /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
1546 /// if a label was specified in the request.
1547 ///
1548 /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
1549 pub request_label: std::string::String,
1550
1551 /// The list of all shipments skipped.
1552 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
1553
1554 /// List of all the validation errors that we were able to detect
1555 /// independently. See the "MULTIPLE ERRORS" explanation for the
1556 /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
1557 /// message.
1558 ///
1559 /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
1560 pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
1561
1562 /// Duration, distance and usage metrics for this solution.
1563 pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
1564
1565 /// Deprecated: Use
1566 /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
1567 /// instead. Total cost of the solution. This takes into account all costs:
1568 /// costs per per hour and travel hour, fixed vehicle costs, unperformed
1569 /// shipment penalty costs, global duration cost, etc.
1570 ///
1571 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
1572 #[deprecated]
1573 pub total_cost: f64,
1574
1575 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1576}
1577
1578impl OptimizeToursResponse {
1579 pub fn new() -> Self {
1580 std::default::Default::default()
1581 }
1582
1583 /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
1584 ///
1585 /// # Example
1586 /// ```ignore,no_run
1587 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1588 /// use google_cloud_optimization_v1::model::ShipmentRoute;
1589 /// let x = OptimizeToursResponse::new()
1590 /// .set_routes([
1591 /// ShipmentRoute::default()/* use setters */,
1592 /// ShipmentRoute::default()/* use (different) setters */,
1593 /// ]);
1594 /// ```
1595 pub fn set_routes<T, V>(mut self, v: T) -> Self
1596 where
1597 T: std::iter::IntoIterator<Item = V>,
1598 V: std::convert::Into<crate::model::ShipmentRoute>,
1599 {
1600 use std::iter::Iterator;
1601 self.routes = v.into_iter().map(|i| i.into()).collect();
1602 self
1603 }
1604
1605 /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
1606 ///
1607 /// # Example
1608 /// ```ignore,no_run
1609 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1610 /// let x = OptimizeToursResponse::new().set_request_label("example");
1611 /// ```
1612 pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1613 self.request_label = v.into();
1614 self
1615 }
1616
1617 /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
1618 ///
1619 /// # Example
1620 /// ```ignore,no_run
1621 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1622 /// use google_cloud_optimization_v1::model::SkippedShipment;
1623 /// let x = OptimizeToursResponse::new()
1624 /// .set_skipped_shipments([
1625 /// SkippedShipment::default()/* use setters */,
1626 /// SkippedShipment::default()/* use (different) setters */,
1627 /// ]);
1628 /// ```
1629 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
1630 where
1631 T: std::iter::IntoIterator<Item = V>,
1632 V: std::convert::Into<crate::model::SkippedShipment>,
1633 {
1634 use std::iter::Iterator;
1635 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
1636 self
1637 }
1638
1639 /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
1640 ///
1641 /// # Example
1642 /// ```ignore,no_run
1643 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1644 /// use google_cloud_optimization_v1::model::OptimizeToursValidationError;
1645 /// let x = OptimizeToursResponse::new()
1646 /// .set_validation_errors([
1647 /// OptimizeToursValidationError::default()/* use setters */,
1648 /// OptimizeToursValidationError::default()/* use (different) setters */,
1649 /// ]);
1650 /// ```
1651 pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
1652 where
1653 T: std::iter::IntoIterator<Item = V>,
1654 V: std::convert::Into<crate::model::OptimizeToursValidationError>,
1655 {
1656 use std::iter::Iterator;
1657 self.validation_errors = v.into_iter().map(|i| i.into()).collect();
1658 self
1659 }
1660
1661 /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1662 ///
1663 /// # Example
1664 /// ```ignore,no_run
1665 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1666 /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1667 /// let x = OptimizeToursResponse::new().set_metrics(Metrics::default()/* use setters */);
1668 /// ```
1669 pub fn set_metrics<T>(mut self, v: T) -> Self
1670 where
1671 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1672 {
1673 self.metrics = std::option::Option::Some(v.into());
1674 self
1675 }
1676
1677 /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1678 ///
1679 /// # Example
1680 /// ```ignore,no_run
1681 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1682 /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1683 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(Some(Metrics::default()/* use setters */));
1684 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(None::<Metrics>);
1685 /// ```
1686 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1687 where
1688 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1689 {
1690 self.metrics = v.map(|x| x.into());
1691 self
1692 }
1693
1694 /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
1695 ///
1696 /// # Example
1697 /// ```ignore,no_run
1698 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1699 /// let x = OptimizeToursResponse::new().set_total_cost(42.0);
1700 /// ```
1701 #[deprecated]
1702 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1703 self.total_cost = v.into();
1704 self
1705 }
1706}
1707
1708impl wkt::message::Message for OptimizeToursResponse {
1709 fn typename() -> &'static str {
1710 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
1711 }
1712}
1713
1714/// Defines additional types related to [OptimizeToursResponse].
1715pub mod optimize_tours_response {
1716 #[allow(unused_imports)]
1717 use super::*;
1718
1719 /// Overall metrics, aggregated over all routes.
1720 #[derive(Clone, Default, PartialEq)]
1721 #[non_exhaustive]
1722 pub struct Metrics {
1723 /// Aggregated over the routes. Each metric is the sum (or max, for loads)
1724 /// over all
1725 /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
1726 /// fields of the same name.
1727 ///
1728 /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
1729 pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
1730
1731 /// Number of mandatory shipments skipped.
1732 pub skipped_mandatory_shipment_count: i32,
1733
1734 /// Number of vehicles used. Note: if a vehicle route is empty and
1735 /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
1736 /// is true, the vehicle is considered used.
1737 ///
1738 /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
1739 pub used_vehicle_count: i32,
1740
1741 /// The earliest start time for a used vehicle, computed as the minimum over
1742 /// all used vehicles of
1743 /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
1744 ///
1745 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
1746 pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
1747
1748 /// The latest end time for a used vehicle, computed as the maximum over all
1749 /// used vehicles of
1750 /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
1751 ///
1752 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
1753 pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
1754
1755 /// Cost of the solution, broken down by cost-related request fields.
1756 /// The keys are proto paths, relative to the input OptimizeToursRequest,
1757 /// e.g. "model.shipments.pickups.cost", and the values are the total cost
1758 /// generated by the corresponding cost field, aggregated over the whole
1759 /// solution. In other words, costs["model.shipments.pickups.cost"] is the
1760 /// sum of all pickup costs over the solution. All costs defined in the model
1761 /// are reported in detail here with the exception of costs related to
1762 /// TransitionAttributes that are only reported in an aggregated way as of
1763 /// 2022/01.
1764 pub costs: std::collections::HashMap<std::string::String, f64>,
1765
1766 /// Total cost of the solution. The sum of all values in the costs map.
1767 pub total_cost: f64,
1768
1769 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1770 }
1771
1772 impl Metrics {
1773 pub fn new() -> Self {
1774 std::default::Default::default()
1775 }
1776
1777 /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1778 ///
1779 /// # Example
1780 /// ```ignore,no_run
1781 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1782 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1783 /// let x = Metrics::new().set_aggregated_route_metrics(AggregatedMetrics::default()/* use setters */);
1784 /// ```
1785 pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
1786 where
1787 T: std::convert::Into<crate::model::AggregatedMetrics>,
1788 {
1789 self.aggregated_route_metrics = std::option::Option::Some(v.into());
1790 self
1791 }
1792
1793 /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1794 ///
1795 /// # Example
1796 /// ```ignore,no_run
1797 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1798 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1799 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(Some(AggregatedMetrics::default()/* use setters */));
1800 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(None::<AggregatedMetrics>);
1801 /// ```
1802 pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1803 where
1804 T: std::convert::Into<crate::model::AggregatedMetrics>,
1805 {
1806 self.aggregated_route_metrics = v.map(|x| x.into());
1807 self
1808 }
1809
1810 /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
1811 ///
1812 /// # Example
1813 /// ```ignore,no_run
1814 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1815 /// let x = Metrics::new().set_skipped_mandatory_shipment_count(42);
1816 /// ```
1817 pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
1818 mut self,
1819 v: T,
1820 ) -> Self {
1821 self.skipped_mandatory_shipment_count = v.into();
1822 self
1823 }
1824
1825 /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
1826 ///
1827 /// # Example
1828 /// ```ignore,no_run
1829 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1830 /// let x = Metrics::new().set_used_vehicle_count(42);
1831 /// ```
1832 pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1833 self.used_vehicle_count = v.into();
1834 self
1835 }
1836
1837 /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1838 ///
1839 /// # Example
1840 /// ```ignore,no_run
1841 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1842 /// use wkt::Timestamp;
1843 /// let x = Metrics::new().set_earliest_vehicle_start_time(Timestamp::default()/* use setters */);
1844 /// ```
1845 pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
1846 where
1847 T: std::convert::Into<wkt::Timestamp>,
1848 {
1849 self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
1850 self
1851 }
1852
1853 /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1854 ///
1855 /// # Example
1856 /// ```ignore,no_run
1857 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1858 /// use wkt::Timestamp;
1859 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(Some(Timestamp::default()/* use setters */));
1860 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(None::<Timestamp>);
1861 /// ```
1862 pub fn set_or_clear_earliest_vehicle_start_time<T>(
1863 mut self,
1864 v: std::option::Option<T>,
1865 ) -> Self
1866 where
1867 T: std::convert::Into<wkt::Timestamp>,
1868 {
1869 self.earliest_vehicle_start_time = v.map(|x| x.into());
1870 self
1871 }
1872
1873 /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1874 ///
1875 /// # Example
1876 /// ```ignore,no_run
1877 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1878 /// use wkt::Timestamp;
1879 /// let x = Metrics::new().set_latest_vehicle_end_time(Timestamp::default()/* use setters */);
1880 /// ```
1881 pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
1882 where
1883 T: std::convert::Into<wkt::Timestamp>,
1884 {
1885 self.latest_vehicle_end_time = std::option::Option::Some(v.into());
1886 self
1887 }
1888
1889 /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1890 ///
1891 /// # Example
1892 /// ```ignore,no_run
1893 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1894 /// use wkt::Timestamp;
1895 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(Some(Timestamp::default()/* use setters */));
1896 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(None::<Timestamp>);
1897 /// ```
1898 pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1899 where
1900 T: std::convert::Into<wkt::Timestamp>,
1901 {
1902 self.latest_vehicle_end_time = v.map(|x| x.into());
1903 self
1904 }
1905
1906 /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
1907 ///
1908 /// # Example
1909 /// ```ignore,no_run
1910 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1911 /// let x = Metrics::new().set_costs([
1912 /// ("key0", 123.5),
1913 /// ("key1", 456.5),
1914 /// ]);
1915 /// ```
1916 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
1917 where
1918 T: std::iter::IntoIterator<Item = (K, V)>,
1919 K: std::convert::Into<std::string::String>,
1920 V: std::convert::Into<f64>,
1921 {
1922 use std::iter::Iterator;
1923 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1924 self
1925 }
1926
1927 /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
1928 ///
1929 /// # Example
1930 /// ```ignore,no_run
1931 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1932 /// let x = Metrics::new().set_total_cost(42.0);
1933 /// ```
1934 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1935 self.total_cost = v.into();
1936 self
1937 }
1938 }
1939
1940 impl wkt::message::Message for Metrics {
1941 fn typename() -> &'static str {
1942 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
1943 }
1944 }
1945}
1946
1947/// Request to batch optimize tours as an asynchronous operation.
1948/// Each input file should contain one `OptimizeToursRequest`, and each output
1949/// file will contain one `OptimizeToursResponse`. The request contains
1950/// information to read/write and parse the files. All the input and output files
1951/// should be under the same project.
1952#[derive(Clone, Default, PartialEq)]
1953#[non_exhaustive]
1954pub struct BatchOptimizeToursRequest {
1955 /// Required. Target project and location to make a call.
1956 ///
1957 /// Format: `projects/{project-id}/locations/{location-id}`.
1958 ///
1959 /// If no location is specified, a region will be chosen automatically.
1960 pub parent: std::string::String,
1961
1962 /// Required. Input/Output information each purchase model, such as file paths
1963 /// and data formats.
1964 pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1965
1966 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1967}
1968
1969impl BatchOptimizeToursRequest {
1970 pub fn new() -> Self {
1971 std::default::Default::default()
1972 }
1973
1974 /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
1975 ///
1976 /// # Example
1977 /// ```ignore,no_run
1978 /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1979 /// let x = BatchOptimizeToursRequest::new().set_parent("example");
1980 /// ```
1981 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1982 self.parent = v.into();
1983 self
1984 }
1985
1986 /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
1987 ///
1988 /// # Example
1989 /// ```ignore,no_run
1990 /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1991 /// use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
1992 /// let x = BatchOptimizeToursRequest::new()
1993 /// .set_model_configs([
1994 /// AsyncModelConfig::default()/* use setters */,
1995 /// AsyncModelConfig::default()/* use (different) setters */,
1996 /// ]);
1997 /// ```
1998 pub fn set_model_configs<T, V>(mut self, v: T) -> Self
1999 where
2000 T: std::iter::IntoIterator<Item = V>,
2001 V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
2002 {
2003 use std::iter::Iterator;
2004 self.model_configs = v.into_iter().map(|i| i.into()).collect();
2005 self
2006 }
2007}
2008
2009impl wkt::message::Message for BatchOptimizeToursRequest {
2010 fn typename() -> &'static str {
2011 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
2012 }
2013}
2014
2015/// Defines additional types related to [BatchOptimizeToursRequest].
2016pub mod batch_optimize_tours_request {
2017 #[allow(unused_imports)]
2018 use super::*;
2019
2020 /// Information for solving one optimization model asynchronously.
2021 #[derive(Clone, Default, PartialEq)]
2022 #[non_exhaustive]
2023 pub struct AsyncModelConfig {
2024 /// User defined model name, can be used as alias by users to keep track of
2025 /// models.
2026 pub display_name: std::string::String,
2027
2028 /// Required. Information about the input model.
2029 pub input_config: std::option::Option<crate::model::InputConfig>,
2030
2031 /// Required. The desired output location information.
2032 pub output_config: std::option::Option<crate::model::OutputConfig>,
2033
2034 /// If this is set, the model will be solved in the checkpoint mode. In this
2035 /// mode, the input model can have a deadline longer than 30 mins without the
2036 /// risk of interruption. The model will be solved in multiple short-running
2037 /// stages. Each stage generates an intermediate checkpoint
2038 /// and stores it in the user's Cloud Storage buckets. The checkpoint
2039 /// mode should be preferred over
2040 /// allow_large_deadline_despite_interruption_risk since it prevents the risk
2041 /// of interruption.
2042 pub enable_checkpoints: bool,
2043
2044 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2045 }
2046
2047 impl AsyncModelConfig {
2048 pub fn new() -> Self {
2049 std::default::Default::default()
2050 }
2051
2052 /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
2053 ///
2054 /// # Example
2055 /// ```ignore,no_run
2056 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2057 /// let x = AsyncModelConfig::new().set_display_name("example");
2058 /// ```
2059 pub fn set_display_name<T: std::convert::Into<std::string::String>>(
2060 mut self,
2061 v: T,
2062 ) -> Self {
2063 self.display_name = v.into();
2064 self
2065 }
2066
2067 /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2068 ///
2069 /// # Example
2070 /// ```ignore,no_run
2071 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2072 /// use google_cloud_optimization_v1::model::InputConfig;
2073 /// let x = AsyncModelConfig::new().set_input_config(InputConfig::default()/* use setters */);
2074 /// ```
2075 pub fn set_input_config<T>(mut self, v: T) -> Self
2076 where
2077 T: std::convert::Into<crate::model::InputConfig>,
2078 {
2079 self.input_config = std::option::Option::Some(v.into());
2080 self
2081 }
2082
2083 /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2084 ///
2085 /// # Example
2086 /// ```ignore,no_run
2087 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2088 /// use google_cloud_optimization_v1::model::InputConfig;
2089 /// let x = AsyncModelConfig::new().set_or_clear_input_config(Some(InputConfig::default()/* use setters */));
2090 /// let x = AsyncModelConfig::new().set_or_clear_input_config(None::<InputConfig>);
2091 /// ```
2092 pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
2093 where
2094 T: std::convert::Into<crate::model::InputConfig>,
2095 {
2096 self.input_config = v.map(|x| x.into());
2097 self
2098 }
2099
2100 /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2101 ///
2102 /// # Example
2103 /// ```ignore,no_run
2104 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2105 /// use google_cloud_optimization_v1::model::OutputConfig;
2106 /// let x = AsyncModelConfig::new().set_output_config(OutputConfig::default()/* use setters */);
2107 /// ```
2108 pub fn set_output_config<T>(mut self, v: T) -> Self
2109 where
2110 T: std::convert::Into<crate::model::OutputConfig>,
2111 {
2112 self.output_config = std::option::Option::Some(v.into());
2113 self
2114 }
2115
2116 /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2117 ///
2118 /// # Example
2119 /// ```ignore,no_run
2120 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2121 /// use google_cloud_optimization_v1::model::OutputConfig;
2122 /// let x = AsyncModelConfig::new().set_or_clear_output_config(Some(OutputConfig::default()/* use setters */));
2123 /// let x = AsyncModelConfig::new().set_or_clear_output_config(None::<OutputConfig>);
2124 /// ```
2125 pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
2126 where
2127 T: std::convert::Into<crate::model::OutputConfig>,
2128 {
2129 self.output_config = v.map(|x| x.into());
2130 self
2131 }
2132
2133 /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
2134 ///
2135 /// # Example
2136 /// ```ignore,no_run
2137 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2138 /// let x = AsyncModelConfig::new().set_enable_checkpoints(true);
2139 /// ```
2140 pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2141 self.enable_checkpoints = v.into();
2142 self
2143 }
2144 }
2145
2146 impl wkt::message::Message for AsyncModelConfig {
2147 fn typename() -> &'static str {
2148 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
2149 }
2150 }
2151}
2152
2153/// Response to a `BatchOptimizeToursRequest`. This is returned in
2154/// the LRO Operation after the operation is complete.
2155#[derive(Clone, Default, PartialEq)]
2156#[non_exhaustive]
2157pub struct BatchOptimizeToursResponse {
2158 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2159}
2160
2161impl BatchOptimizeToursResponse {
2162 pub fn new() -> Self {
2163 std::default::Default::default()
2164 }
2165}
2166
2167impl wkt::message::Message for BatchOptimizeToursResponse {
2168 fn typename() -> &'static str {
2169 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
2170 }
2171}
2172
2173/// A shipment model contains a set of shipments which must be performed by a
2174/// set of vehicles, while minimizing the overall cost, which is the sum of:
2175///
2176/// * the cost of routing the vehicles (sum of cost per total time, cost per
2177/// travel time, and fixed cost over all vehicles).
2178/// * the unperformed shipment penalties.
2179/// * the cost of the global duration of the shipments
2180#[derive(Clone, Default, PartialEq)]
2181#[non_exhaustive]
2182pub struct ShipmentModel {
2183 /// Set of shipments which must be performed in the model.
2184 pub shipments: std::vec::Vec<crate::model::Shipment>,
2185
2186 /// Set of vehicles which can be used to perform visits.
2187 pub vehicles: std::vec::Vec<crate::model::Vehicle>,
2188
2189 /// Constrains the maximum number of active vehicles. A vehicle is active if
2190 /// its route performs at least one shipment. This can be used to limit the
2191 /// number of routes in the case where there are fewer drivers than
2192 /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
2193 /// will then select the best subset of vehicles to use.
2194 /// Must be strictly positive.
2195 pub max_active_vehicles: std::option::Option<i32>,
2196
2197 /// Global start and end time of the model: no times outside of this range
2198 /// can be considered valid.
2199 ///
2200 /// The model's time span must be less than a year, i.e. the `global_end_time`
2201 /// and the `global_start_time` must be within 31536000 seconds of each other.
2202 ///
2203 /// When using `cost_per_*hour` fields, you might want to set this window to a
2204 /// smaller interval to increase performance (eg. if you model a single day,
2205 /// you should set the global time limits to that day).
2206 /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
2207 /// as default.
2208 pub global_start_time: std::option::Option<wkt::Timestamp>,
2209
2210 /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
2211 /// is used as default.
2212 pub global_end_time: std::option::Option<wkt::Timestamp>,
2213
2214 /// The "global duration" of the overall plan is the difference between the
2215 /// earliest effective start time and the latest effective end time of
2216 /// all vehicles. Users can assign a cost per hour to that quantity to try
2217 /// and optimize for earliest job completion, for example. This cost must be in
2218 /// the same unit as
2219 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
2220 ///
2221 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
2222 pub global_duration_cost_per_hour: f64,
2223
2224 /// Specifies duration and distance matrices used in the model. If this field
2225 /// is empty, Google Maps or geodesic distances will be used instead, depending
2226 /// on the value of the `use_geodesic_distances` field. If it is not empty,
2227 /// `use_geodesic_distances` cannot be true and neither
2228 /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
2229 /// can be empty.
2230 ///
2231 /// Usage examples:
2232 ///
2233 /// * There are two locations: locA and locB.
2234 /// * 1 vehicle starting its route at locA and ending it at locA.
2235 /// * 1 pickup visit request at locB.
2236 ///
2237 /// ```norust
2238 /// model {
2239 /// vehicles { start_tags: "locA" end_tags: "locA" }
2240 /// shipments { pickups { tags: "locB" } }
2241 /// duration_distance_matrix_src_tags: "locA"
2242 /// duration_distance_matrix_src_tags: "locB"
2243 /// duration_distance_matrix_dst_tags: "locA"
2244 /// duration_distance_matrix_dst_tags: "locB"
2245 /// duration_distance_matrices {
2246 /// rows { # from: locA
2247 /// durations { seconds: 0 } meters: 0 # to: locA
2248 /// durations { seconds: 100 } meters: 1000 # to: locB
2249 /// }
2250 /// rows { # from: locB
2251 /// durations { seconds: 102 } meters: 990 # to: locA
2252 /// durations { seconds: 0 } meters: 0 # to: locB
2253 /// }
2254 /// }
2255 /// }
2256 /// ```
2257 ///
2258 /// * There are three locations: locA, locB and locC.
2259 /// * 1 vehicle starting its route at locA and ending it at locB, using
2260 /// matrix "fast".
2261 /// * 1 vehicle starting its route at locB and ending it at locB, using
2262 /// matrix "slow".
2263 /// * 1 vehicle starting its route at locB and ending it at locB, using
2264 /// matrix "fast".
2265 /// * 1 pickup visit request at locC.
2266 ///
2267 /// ```norust
2268 /// model {
2269 /// vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
2270 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
2271 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
2272 /// shipments { pickups { tags: "locC" } }
2273 /// duration_distance_matrix_src_tags: "locA"
2274 /// duration_distance_matrix_src_tags: "locB"
2275 /// duration_distance_matrix_src_tags: "locC"
2276 /// duration_distance_matrix_dst_tags: "locB"
2277 /// duration_distance_matrix_dst_tags: "locC"
2278 /// duration_distance_matrices {
2279 /// vehicle_start_tag: "fast"
2280 /// rows { # from: locA
2281 /// durations { seconds: 1000 } meters: 2000 # to: locB
2282 /// durations { seconds: 600 } meters: 1000 # to: locC
2283 /// }
2284 /// rows { # from: locB
2285 /// durations { seconds: 0 } meters: 0 # to: locB
2286 /// durations { seconds: 700 } meters: 1200 # to: locC
2287 /// }
2288 /// rows { # from: locC
2289 /// durations { seconds: 702 } meters: 1190 # to: locB
2290 /// durations { seconds: 0 } meters: 0 # to: locC
2291 /// }
2292 /// }
2293 /// duration_distance_matrices {
2294 /// vehicle_start_tag: "slow"
2295 /// rows { # from: locA
2296 /// durations { seconds: 1800 } meters: 2001 # to: locB
2297 /// durations { seconds: 900 } meters: 1002 # to: locC
2298 /// }
2299 /// rows { # from: locB
2300 /// durations { seconds: 0 } meters: 0 # to: locB
2301 /// durations { seconds: 1000 } meters: 1202 # to: locC
2302 /// }
2303 /// rows { # from: locC
2304 /// durations { seconds: 1001 } meters: 1195 # to: locB
2305 /// durations { seconds: 0 } meters: 0 # to: locC
2306 /// }
2307 /// }
2308 /// }
2309 /// ```
2310 pub duration_distance_matrices:
2311 std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
2312
2313 /// Tags defining the sources of the duration and distance matrices;
2314 /// `duration_distance_matrices(i).rows(j)` defines durations and distances
2315 /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
2316 /// in matrix i.
2317 ///
2318 /// Tags correspond to
2319 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2320 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2321 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2322 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2323 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2324 /// the same. All tags must be different and cannot be empty strings. If this
2325 /// field is not empty, then `duration_distance_matrices` must not be empty.
2326 ///
2327 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2328 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2329 pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
2330
2331 /// Tags defining the destinations of the duration and distance matrices;
2332 /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
2333 /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
2334 /// (resp. the distance) of the travel from visits with tag
2335 /// `duration_distance_matrix_src_tags(j)` to visits with tag
2336 /// `duration_distance_matrix_dst_tags(k)` in matrix i.
2337 ///
2338 /// Tags correspond to
2339 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2340 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2341 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2342 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2343 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2344 /// the same. All tags must be different and cannot be empty strings. If this
2345 /// field is not empty, then `duration_distance_matrices` must not be empty.
2346 ///
2347 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2348 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2349 pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
2350
2351 /// Transition attributes added to the model.
2352 pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
2353
2354 /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
2355 pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
2356
2357 /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
2358 pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
2359
2360 /// Set of precedence rules which must be enforced in the model.
2361 pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
2362
2363 /// Deprecated: No longer used.
2364 /// Set of break rules used in the model.
2365 /// Each vehicle specifies the `BreakRule` that applies to it via the
2366 /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
2367 /// field (which must be a singleton).
2368 ///
2369 /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
2370 #[deprecated]
2371 pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
2372
2373 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2374}
2375
2376impl ShipmentModel {
2377 pub fn new() -> Self {
2378 std::default::Default::default()
2379 }
2380
2381 /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
2382 ///
2383 /// # Example
2384 /// ```ignore,no_run
2385 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2386 /// use google_cloud_optimization_v1::model::Shipment;
2387 /// let x = ShipmentModel::new()
2388 /// .set_shipments([
2389 /// Shipment::default()/* use setters */,
2390 /// Shipment::default()/* use (different) setters */,
2391 /// ]);
2392 /// ```
2393 pub fn set_shipments<T, V>(mut self, v: T) -> Self
2394 where
2395 T: std::iter::IntoIterator<Item = V>,
2396 V: std::convert::Into<crate::model::Shipment>,
2397 {
2398 use std::iter::Iterator;
2399 self.shipments = v.into_iter().map(|i| i.into()).collect();
2400 self
2401 }
2402
2403 /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
2404 ///
2405 /// # Example
2406 /// ```ignore,no_run
2407 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2408 /// use google_cloud_optimization_v1::model::Vehicle;
2409 /// let x = ShipmentModel::new()
2410 /// .set_vehicles([
2411 /// Vehicle::default()/* use setters */,
2412 /// Vehicle::default()/* use (different) setters */,
2413 /// ]);
2414 /// ```
2415 pub fn set_vehicles<T, V>(mut self, v: T) -> Self
2416 where
2417 T: std::iter::IntoIterator<Item = V>,
2418 V: std::convert::Into<crate::model::Vehicle>,
2419 {
2420 use std::iter::Iterator;
2421 self.vehicles = v.into_iter().map(|i| i.into()).collect();
2422 self
2423 }
2424
2425 /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2426 ///
2427 /// # Example
2428 /// ```ignore,no_run
2429 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2430 /// let x = ShipmentModel::new().set_max_active_vehicles(42);
2431 /// ```
2432 pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
2433 where
2434 T: std::convert::Into<i32>,
2435 {
2436 self.max_active_vehicles = std::option::Option::Some(v.into());
2437 self
2438 }
2439
2440 /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2441 ///
2442 /// # Example
2443 /// ```ignore,no_run
2444 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2445 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(Some(42));
2446 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(None::<i32>);
2447 /// ```
2448 pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
2449 where
2450 T: std::convert::Into<i32>,
2451 {
2452 self.max_active_vehicles = v.map(|x| x.into());
2453 self
2454 }
2455
2456 /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2457 ///
2458 /// # Example
2459 /// ```ignore,no_run
2460 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2461 /// use wkt::Timestamp;
2462 /// let x = ShipmentModel::new().set_global_start_time(Timestamp::default()/* use setters */);
2463 /// ```
2464 pub fn set_global_start_time<T>(mut self, v: T) -> Self
2465 where
2466 T: std::convert::Into<wkt::Timestamp>,
2467 {
2468 self.global_start_time = std::option::Option::Some(v.into());
2469 self
2470 }
2471
2472 /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2473 ///
2474 /// # Example
2475 /// ```ignore,no_run
2476 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2477 /// use wkt::Timestamp;
2478 /// let x = ShipmentModel::new().set_or_clear_global_start_time(Some(Timestamp::default()/* use setters */));
2479 /// let x = ShipmentModel::new().set_or_clear_global_start_time(None::<Timestamp>);
2480 /// ```
2481 pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2482 where
2483 T: std::convert::Into<wkt::Timestamp>,
2484 {
2485 self.global_start_time = v.map(|x| x.into());
2486 self
2487 }
2488
2489 /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2490 ///
2491 /// # Example
2492 /// ```ignore,no_run
2493 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2494 /// use wkt::Timestamp;
2495 /// let x = ShipmentModel::new().set_global_end_time(Timestamp::default()/* use setters */);
2496 /// ```
2497 pub fn set_global_end_time<T>(mut self, v: T) -> Self
2498 where
2499 T: std::convert::Into<wkt::Timestamp>,
2500 {
2501 self.global_end_time = std::option::Option::Some(v.into());
2502 self
2503 }
2504
2505 /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2506 ///
2507 /// # Example
2508 /// ```ignore,no_run
2509 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2510 /// use wkt::Timestamp;
2511 /// let x = ShipmentModel::new().set_or_clear_global_end_time(Some(Timestamp::default()/* use setters */));
2512 /// let x = ShipmentModel::new().set_or_clear_global_end_time(None::<Timestamp>);
2513 /// ```
2514 pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2515 where
2516 T: std::convert::Into<wkt::Timestamp>,
2517 {
2518 self.global_end_time = v.map(|x| x.into());
2519 self
2520 }
2521
2522 /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
2523 ///
2524 /// # Example
2525 /// ```ignore,no_run
2526 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2527 /// let x = ShipmentModel::new().set_global_duration_cost_per_hour(42.0);
2528 /// ```
2529 pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2530 self.global_duration_cost_per_hour = v.into();
2531 self
2532 }
2533
2534 /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
2535 ///
2536 /// # Example
2537 /// ```ignore,no_run
2538 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2539 /// use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2540 /// let x = ShipmentModel::new()
2541 /// .set_duration_distance_matrices([
2542 /// DurationDistanceMatrix::default()/* use setters */,
2543 /// DurationDistanceMatrix::default()/* use (different) setters */,
2544 /// ]);
2545 /// ```
2546 pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
2547 where
2548 T: std::iter::IntoIterator<Item = V>,
2549 V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
2550 {
2551 use std::iter::Iterator;
2552 self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
2553 self
2554 }
2555
2556 /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
2557 ///
2558 /// # Example
2559 /// ```ignore,no_run
2560 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2561 /// let x = ShipmentModel::new().set_duration_distance_matrix_src_tags(["a", "b", "c"]);
2562 /// ```
2563 pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
2564 where
2565 T: std::iter::IntoIterator<Item = V>,
2566 V: std::convert::Into<std::string::String>,
2567 {
2568 use std::iter::Iterator;
2569 self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
2570 self
2571 }
2572
2573 /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
2574 ///
2575 /// # Example
2576 /// ```ignore,no_run
2577 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2578 /// let x = ShipmentModel::new().set_duration_distance_matrix_dst_tags(["a", "b", "c"]);
2579 /// ```
2580 pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
2581 where
2582 T: std::iter::IntoIterator<Item = V>,
2583 V: std::convert::Into<std::string::String>,
2584 {
2585 use std::iter::Iterator;
2586 self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
2587 self
2588 }
2589
2590 /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
2591 ///
2592 /// # Example
2593 /// ```ignore,no_run
2594 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2595 /// use google_cloud_optimization_v1::model::TransitionAttributes;
2596 /// let x = ShipmentModel::new()
2597 /// .set_transition_attributes([
2598 /// TransitionAttributes::default()/* use setters */,
2599 /// TransitionAttributes::default()/* use (different) setters */,
2600 /// ]);
2601 /// ```
2602 pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
2603 where
2604 T: std::iter::IntoIterator<Item = V>,
2605 V: std::convert::Into<crate::model::TransitionAttributes>,
2606 {
2607 use std::iter::Iterator;
2608 self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
2609 self
2610 }
2611
2612 /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
2613 ///
2614 /// # Example
2615 /// ```ignore,no_run
2616 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2617 /// use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
2618 /// let x = ShipmentModel::new()
2619 /// .set_shipment_type_incompatibilities([
2620 /// ShipmentTypeIncompatibility::default()/* use setters */,
2621 /// ShipmentTypeIncompatibility::default()/* use (different) setters */,
2622 /// ]);
2623 /// ```
2624 pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
2625 where
2626 T: std::iter::IntoIterator<Item = V>,
2627 V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
2628 {
2629 use std::iter::Iterator;
2630 self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
2631 self
2632 }
2633
2634 /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
2635 ///
2636 /// # Example
2637 /// ```ignore,no_run
2638 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2639 /// use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
2640 /// let x = ShipmentModel::new()
2641 /// .set_shipment_type_requirements([
2642 /// ShipmentTypeRequirement::default()/* use setters */,
2643 /// ShipmentTypeRequirement::default()/* use (different) setters */,
2644 /// ]);
2645 /// ```
2646 pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
2647 where
2648 T: std::iter::IntoIterator<Item = V>,
2649 V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
2650 {
2651 use std::iter::Iterator;
2652 self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
2653 self
2654 }
2655
2656 /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
2657 ///
2658 /// # Example
2659 /// ```ignore,no_run
2660 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2661 /// use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2662 /// let x = ShipmentModel::new()
2663 /// .set_precedence_rules([
2664 /// PrecedenceRule::default()/* use setters */,
2665 /// PrecedenceRule::default()/* use (different) setters */,
2666 /// ]);
2667 /// ```
2668 pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
2669 where
2670 T: std::iter::IntoIterator<Item = V>,
2671 V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
2672 {
2673 use std::iter::Iterator;
2674 self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
2675 self
2676 }
2677
2678 /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
2679 ///
2680 /// # Example
2681 /// ```ignore,no_run
2682 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2683 /// use google_cloud_optimization_v1::model::shipment_model::BreakRule;
2684 /// let x = ShipmentModel::new()
2685 /// .set_break_rules([
2686 /// BreakRule::default()/* use setters */,
2687 /// BreakRule::default()/* use (different) setters */,
2688 /// ]);
2689 /// ```
2690 #[deprecated]
2691 pub fn set_break_rules<T, V>(mut self, v: T) -> Self
2692 where
2693 T: std::iter::IntoIterator<Item = V>,
2694 V: std::convert::Into<crate::model::shipment_model::BreakRule>,
2695 {
2696 use std::iter::Iterator;
2697 self.break_rules = v.into_iter().map(|i| i.into()).collect();
2698 self
2699 }
2700}
2701
2702impl wkt::message::Message for ShipmentModel {
2703 fn typename() -> &'static str {
2704 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
2705 }
2706}
2707
2708/// Defines additional types related to [ShipmentModel].
2709pub mod shipment_model {
2710 #[allow(unused_imports)]
2711 use super::*;
2712
2713 /// Specifies a duration and distance matrix from visit and vehicle start
2714 /// locations to visit and vehicle end locations.
2715 #[derive(Clone, Default, PartialEq)]
2716 #[non_exhaustive]
2717 pub struct DurationDistanceMatrix {
2718 /// Specifies the rows of the duration and distance matrix. It must have as
2719 /// many elements as
2720 /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
2721 ///
2722 /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
2723 pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
2724
2725 /// Tag defining to which vehicles this duration and distance matrix applies.
2726 /// If empty, this applies to all vehicles, and there can only be a single
2727 /// matrix.
2728 ///
2729 /// Each vehicle start must match exactly one matrix, i.e. exactly one of
2730 /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
2731 /// (and of that matrix only).
2732 ///
2733 /// All matrices must have a different `vehicle_start_tag`.
2734 pub vehicle_start_tag: std::string::String,
2735
2736 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2737 }
2738
2739 impl DurationDistanceMatrix {
2740 pub fn new() -> Self {
2741 std::default::Default::default()
2742 }
2743
2744 /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
2745 ///
2746 /// # Example
2747 /// ```ignore,no_run
2748 /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2749 /// use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2750 /// let x = DurationDistanceMatrix::new()
2751 /// .set_rows([
2752 /// Row::default()/* use setters */,
2753 /// Row::default()/* use (different) setters */,
2754 /// ]);
2755 /// ```
2756 pub fn set_rows<T, V>(mut self, v: T) -> Self
2757 where
2758 T: std::iter::IntoIterator<Item = V>,
2759 V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
2760 {
2761 use std::iter::Iterator;
2762 self.rows = v.into_iter().map(|i| i.into()).collect();
2763 self
2764 }
2765
2766 /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
2767 ///
2768 /// # Example
2769 /// ```ignore,no_run
2770 /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2771 /// let x = DurationDistanceMatrix::new().set_vehicle_start_tag("example");
2772 /// ```
2773 pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
2774 mut self,
2775 v: T,
2776 ) -> Self {
2777 self.vehicle_start_tag = v.into();
2778 self
2779 }
2780 }
2781
2782 impl wkt::message::Message for DurationDistanceMatrix {
2783 fn typename() -> &'static str {
2784 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
2785 }
2786 }
2787
2788 /// Defines additional types related to [DurationDistanceMatrix].
2789 pub mod duration_distance_matrix {
2790 #[allow(unused_imports)]
2791 use super::*;
2792
2793 /// Specifies a row of the duration and distance matrix.
2794 #[derive(Clone, Default, PartialEq)]
2795 #[non_exhaustive]
2796 pub struct Row {
2797 /// Duration values for a given row. It must have as many elements as
2798 /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
2799 ///
2800 /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
2801 pub durations: std::vec::Vec<wkt::Duration>,
2802
2803 /// Distance values for a given row. If no costs or constraints refer to
2804 /// distances in the model, this can be left empty; otherwise it must have
2805 /// as many elements as `durations`.
2806 pub meters: std::vec::Vec<f64>,
2807
2808 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2809 }
2810
2811 impl Row {
2812 pub fn new() -> Self {
2813 std::default::Default::default()
2814 }
2815
2816 /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
2817 ///
2818 /// # Example
2819 /// ```ignore,no_run
2820 /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2821 /// use wkt::Duration;
2822 /// let x = Row::new()
2823 /// .set_durations([
2824 /// Duration::default()/* use setters */,
2825 /// Duration::default()/* use (different) setters */,
2826 /// ]);
2827 /// ```
2828 pub fn set_durations<T, V>(mut self, v: T) -> Self
2829 where
2830 T: std::iter::IntoIterator<Item = V>,
2831 V: std::convert::Into<wkt::Duration>,
2832 {
2833 use std::iter::Iterator;
2834 self.durations = v.into_iter().map(|i| i.into()).collect();
2835 self
2836 }
2837
2838 /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
2839 ///
2840 /// # Example
2841 /// ```ignore,no_run
2842 /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2843 /// let x = Row::new().set_meters([1.0, 2.0, 3.0]);
2844 /// ```
2845 pub fn set_meters<T, V>(mut self, v: T) -> Self
2846 where
2847 T: std::iter::IntoIterator<Item = V>,
2848 V: std::convert::Into<f64>,
2849 {
2850 use std::iter::Iterator;
2851 self.meters = v.into_iter().map(|i| i.into()).collect();
2852 self
2853 }
2854 }
2855
2856 impl wkt::message::Message for Row {
2857 fn typename() -> &'static str {
2858 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
2859 }
2860 }
2861 }
2862
2863 /// A precedence rule between two events (each event is the pickup or the
2864 /// delivery of a shipment): the "second" event has to start at least
2865 /// `offset_duration` after "first" has started.
2866 ///
2867 /// Several precedences can refer to the same (or related) events, e.g.,
2868 /// "pickup of B happens after delivery of A" and "pickup of C happens after
2869 /// pickup of B".
2870 ///
2871 /// Furthermore, precedences only apply when both shipments are performed and
2872 /// are otherwise ignored.
2873 #[derive(Clone, Default, PartialEq)]
2874 #[non_exhaustive]
2875 pub struct PrecedenceRule {
2876 /// Shipment index of the "first" event. This field must be specified.
2877 pub first_index: std::option::Option<i32>,
2878
2879 /// Indicates if the "first" event is a delivery.
2880 pub first_is_delivery: bool,
2881
2882 /// Shipment index of the "second" event. This field must be specified.
2883 pub second_index: std::option::Option<i32>,
2884
2885 /// Indicates if the "second" event is a delivery.
2886 pub second_is_delivery: bool,
2887
2888 /// The offset between the "first" and "second" event. It can be negative.
2889 pub offset_duration: std::option::Option<wkt::Duration>,
2890
2891 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2892 }
2893
2894 impl PrecedenceRule {
2895 pub fn new() -> Self {
2896 std::default::Default::default()
2897 }
2898
2899 /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2900 ///
2901 /// # Example
2902 /// ```ignore,no_run
2903 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2904 /// let x = PrecedenceRule::new().set_first_index(42);
2905 /// ```
2906 pub fn set_first_index<T>(mut self, v: T) -> Self
2907 where
2908 T: std::convert::Into<i32>,
2909 {
2910 self.first_index = std::option::Option::Some(v.into());
2911 self
2912 }
2913
2914 /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2915 ///
2916 /// # Example
2917 /// ```ignore,no_run
2918 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2919 /// let x = PrecedenceRule::new().set_or_clear_first_index(Some(42));
2920 /// let x = PrecedenceRule::new().set_or_clear_first_index(None::<i32>);
2921 /// ```
2922 pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
2923 where
2924 T: std::convert::Into<i32>,
2925 {
2926 self.first_index = v.map(|x| x.into());
2927 self
2928 }
2929
2930 /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
2931 ///
2932 /// # Example
2933 /// ```ignore,no_run
2934 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2935 /// let x = PrecedenceRule::new().set_first_is_delivery(true);
2936 /// ```
2937 pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2938 self.first_is_delivery = v.into();
2939 self
2940 }
2941
2942 /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2943 ///
2944 /// # Example
2945 /// ```ignore,no_run
2946 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2947 /// let x = PrecedenceRule::new().set_second_index(42);
2948 /// ```
2949 pub fn set_second_index<T>(mut self, v: T) -> Self
2950 where
2951 T: std::convert::Into<i32>,
2952 {
2953 self.second_index = std::option::Option::Some(v.into());
2954 self
2955 }
2956
2957 /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2958 ///
2959 /// # Example
2960 /// ```ignore,no_run
2961 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2962 /// let x = PrecedenceRule::new().set_or_clear_second_index(Some(42));
2963 /// let x = PrecedenceRule::new().set_or_clear_second_index(None::<i32>);
2964 /// ```
2965 pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
2966 where
2967 T: std::convert::Into<i32>,
2968 {
2969 self.second_index = v.map(|x| x.into());
2970 self
2971 }
2972
2973 /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
2974 ///
2975 /// # Example
2976 /// ```ignore,no_run
2977 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2978 /// let x = PrecedenceRule::new().set_second_is_delivery(true);
2979 /// ```
2980 pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2981 self.second_is_delivery = v.into();
2982 self
2983 }
2984
2985 /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
2986 ///
2987 /// # Example
2988 /// ```ignore,no_run
2989 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2990 /// use wkt::Duration;
2991 /// let x = PrecedenceRule::new().set_offset_duration(Duration::default()/* use setters */);
2992 /// ```
2993 pub fn set_offset_duration<T>(mut self, v: T) -> Self
2994 where
2995 T: std::convert::Into<wkt::Duration>,
2996 {
2997 self.offset_duration = std::option::Option::Some(v.into());
2998 self
2999 }
3000
3001 /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
3002 ///
3003 /// # Example
3004 /// ```ignore,no_run
3005 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
3006 /// use wkt::Duration;
3007 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(Some(Duration::default()/* use setters */));
3008 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(None::<Duration>);
3009 /// ```
3010 pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
3011 where
3012 T: std::convert::Into<wkt::Duration>,
3013 {
3014 self.offset_duration = v.map(|x| x.into());
3015 self
3016 }
3017 }
3018
3019 impl wkt::message::Message for PrecedenceRule {
3020 fn typename() -> &'static str {
3021 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
3022 }
3023 }
3024
3025 /// Deprecated: Use top level
3026 /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
3027 /// Rules to generate time breaks for a vehicle (e.g. lunch
3028 /// breaks). A break is a contiguous period of time during which the vehicle
3029 /// remains idle at its current position and cannot perform any visit. A break
3030 /// may occur:
3031 ///
3032 /// * during the travel between two visits (which includes the time right
3033 /// before or right after a visit, but not in the middle of a visit), in
3034 /// which case it extends the corresponding transit time between the visits
3035 /// * before the vehicle start (the vehicle may not start in the middle of
3036 /// a break), in which case it does not affect the vehicle start time.
3037 /// * after the vehicle end (ditto, with the vehicle end time).
3038 ///
3039 /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
3040 #[derive(Clone, Default, PartialEq)]
3041 #[non_exhaustive]
3042 #[deprecated]
3043 pub struct BreakRule {
3044 /// Sequence of breaks. See the `BreakRequest` message.
3045 pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
3046
3047 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
3048 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
3049 pub frequency_constraints:
3050 std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3051
3052 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3053 }
3054
3055 impl BreakRule {
3056 pub fn new() -> Self {
3057 std::default::Default::default()
3058 }
3059
3060 /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
3061 ///
3062 /// # Example
3063 /// ```ignore,no_run
3064 /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3065 /// use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3066 /// let x = BreakRule::new()
3067 /// .set_break_requests([
3068 /// BreakRequest::default()/* use setters */,
3069 /// BreakRequest::default()/* use (different) setters */,
3070 /// ]);
3071 /// ```
3072 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
3073 where
3074 T: std::iter::IntoIterator<Item = V>,
3075 V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
3076 {
3077 use std::iter::Iterator;
3078 self.break_requests = v.into_iter().map(|i| i.into()).collect();
3079 self
3080 }
3081
3082 /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
3083 ///
3084 /// # Example
3085 /// ```ignore,no_run
3086 /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3087 /// use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3088 /// let x = BreakRule::new()
3089 /// .set_frequency_constraints([
3090 /// FrequencyConstraint::default()/* use setters */,
3091 /// FrequencyConstraint::default()/* use (different) setters */,
3092 /// ]);
3093 /// ```
3094 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
3095 where
3096 T: std::iter::IntoIterator<Item = V>,
3097 V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3098 {
3099 use std::iter::Iterator;
3100 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
3101 self
3102 }
3103 }
3104
3105 impl wkt::message::Message for BreakRule {
3106 fn typename() -> &'static str {
3107 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
3108 }
3109 }
3110
3111 /// Defines additional types related to [BreakRule].
3112 pub mod break_rule {
3113 #[allow(unused_imports)]
3114 use super::*;
3115
3116 /// The sequence of breaks (i.e. their number and order) that apply to each
3117 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
3118 /// that sequence, in the order in which they must occur. Their time windows
3119 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
3120 /// be compatible with the order (this is checked).
3121 #[derive(Clone, Default, PartialEq)]
3122 #[non_exhaustive]
3123 pub struct BreakRequest {
3124 /// Required. Lower bound (inclusive) on the start of the break.
3125 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
3126
3127 /// Required. Upper bound (inclusive) on the start of the break.
3128 pub latest_start_time: std::option::Option<wkt::Timestamp>,
3129
3130 /// Required. Minimum duration of the break. Must be positive.
3131 pub min_duration: std::option::Option<wkt::Duration>,
3132
3133 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3134 }
3135
3136 impl BreakRequest {
3137 pub fn new() -> Self {
3138 std::default::Default::default()
3139 }
3140
3141 /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3142 ///
3143 /// # Example
3144 /// ```ignore,no_run
3145 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3146 /// use wkt::Timestamp;
3147 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
3148 /// ```
3149 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
3150 where
3151 T: std::convert::Into<wkt::Timestamp>,
3152 {
3153 self.earliest_start_time = std::option::Option::Some(v.into());
3154 self
3155 }
3156
3157 /// Sets or clears the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3158 ///
3159 /// # Example
3160 /// ```ignore,no_run
3161 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3162 /// use wkt::Timestamp;
3163 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
3164 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
3165 /// ```
3166 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3167 where
3168 T: std::convert::Into<wkt::Timestamp>,
3169 {
3170 self.earliest_start_time = v.map(|x| x.into());
3171 self
3172 }
3173
3174 /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3175 ///
3176 /// # Example
3177 /// ```ignore,no_run
3178 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3179 /// use wkt::Timestamp;
3180 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
3181 /// ```
3182 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
3183 where
3184 T: std::convert::Into<wkt::Timestamp>,
3185 {
3186 self.latest_start_time = std::option::Option::Some(v.into());
3187 self
3188 }
3189
3190 /// Sets or clears the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3191 ///
3192 /// # Example
3193 /// ```ignore,no_run
3194 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3195 /// use wkt::Timestamp;
3196 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
3197 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
3198 /// ```
3199 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3200 where
3201 T: std::convert::Into<wkt::Timestamp>,
3202 {
3203 self.latest_start_time = v.map(|x| x.into());
3204 self
3205 }
3206
3207 /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3208 ///
3209 /// # Example
3210 /// ```ignore,no_run
3211 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3212 /// use wkt::Duration;
3213 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
3214 /// ```
3215 pub fn set_min_duration<T>(mut self, v: T) -> Self
3216 where
3217 T: std::convert::Into<wkt::Duration>,
3218 {
3219 self.min_duration = std::option::Option::Some(v.into());
3220 self
3221 }
3222
3223 /// Sets or clears the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3224 ///
3225 /// # Example
3226 /// ```ignore,no_run
3227 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3228 /// use wkt::Duration;
3229 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
3230 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
3231 /// ```
3232 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
3233 where
3234 T: std::convert::Into<wkt::Duration>,
3235 {
3236 self.min_duration = v.map(|x| x.into());
3237 self
3238 }
3239 }
3240
3241 impl wkt::message::Message for BreakRequest {
3242 fn typename() -> &'static str {
3243 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
3244 }
3245 }
3246
3247 /// One may further constrain the frequency and duration of the breaks
3248 /// specified above, by enforcing a minimum break frequency, such as
3249 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
3250 /// this can be interpreted as "Within any sliding time window of 12h, there
3251 /// must be at least one break of at least one hour", that example would
3252 /// translate to the following `FrequencyConstraint`:
3253 ///
3254 /// ```norust
3255 /// {
3256 /// min_break_duration { seconds: 3600 } # 1 hour.
3257 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
3258 /// }
3259 /// ```
3260 ///
3261 /// The timing and duration of the breaks in the solution will respect all
3262 /// such constraints, in addition to the time windows and minimum durations
3263 /// already specified in the `BreakRequest`.
3264 ///
3265 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
3266 /// For example, the following schedule honors the "1h every 12h" example:
3267 ///
3268 /// ```norust
3269 /// 04:00 vehicle start
3270 /// .. performing travel and visits ..
3271 /// 09:00 1 hour break
3272 /// 10:00 end of the break
3273 /// .. performing travel and visits ..
3274 /// 12:00 20-min lunch break
3275 /// 12:20 end of the break
3276 /// .. performing travel and visits ..
3277 /// 21:00 1 hour break
3278 /// 22:00 end of the break
3279 /// .. performing travel and visits ..
3280 /// 23:59 vehicle end
3281 /// ```
3282 #[derive(Clone, Default, PartialEq)]
3283 #[non_exhaustive]
3284 pub struct FrequencyConstraint {
3285 /// Required. Minimum break duration for this constraint. Nonnegative.
3286 /// See description of `FrequencyConstraint`.
3287 pub min_break_duration: std::option::Option<wkt::Duration>,
3288
3289 /// Required. Maximum allowed span of any interval of time in the route
3290 /// that does not include at least partially a break of `duration >=
3291 /// min_break_duration`. Must be positive.
3292 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
3293
3294 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3295 }
3296
3297 impl FrequencyConstraint {
3298 pub fn new() -> Self {
3299 std::default::Default::default()
3300 }
3301
3302 /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3303 ///
3304 /// # Example
3305 /// ```ignore,no_run
3306 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3307 /// use wkt::Duration;
3308 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
3309 /// ```
3310 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
3311 where
3312 T: std::convert::Into<wkt::Duration>,
3313 {
3314 self.min_break_duration = std::option::Option::Some(v.into());
3315 self
3316 }
3317
3318 /// Sets or clears the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3319 ///
3320 /// # Example
3321 /// ```ignore,no_run
3322 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3323 /// use wkt::Duration;
3324 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
3325 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
3326 /// ```
3327 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
3328 where
3329 T: std::convert::Into<wkt::Duration>,
3330 {
3331 self.min_break_duration = v.map(|x| x.into());
3332 self
3333 }
3334
3335 /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3336 ///
3337 /// # Example
3338 /// ```ignore,no_run
3339 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3340 /// use wkt::Duration;
3341 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
3342 /// ```
3343 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
3344 where
3345 T: std::convert::Into<wkt::Duration>,
3346 {
3347 self.max_inter_break_duration = std::option::Option::Some(v.into());
3348 self
3349 }
3350
3351 /// Sets or clears the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3352 ///
3353 /// # Example
3354 /// ```ignore,no_run
3355 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3356 /// use wkt::Duration;
3357 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
3358 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
3359 /// ```
3360 pub fn set_or_clear_max_inter_break_duration<T>(
3361 mut self,
3362 v: std::option::Option<T>,
3363 ) -> Self
3364 where
3365 T: std::convert::Into<wkt::Duration>,
3366 {
3367 self.max_inter_break_duration = v.map(|x| x.into());
3368 self
3369 }
3370 }
3371
3372 impl wkt::message::Message for FrequencyConstraint {
3373 fn typename() -> &'static str {
3374 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
3375 }
3376 }
3377 }
3378}
3379
3380/// The shipment of a single item, from one of its pickups to one of its
3381/// deliveries. For the shipment to be considered as performed, a unique vehicle
3382/// must visit one of its pickup locations (and decrease its spare capacities
3383/// accordingly), then visit one of its delivery locations later on (and
3384/// therefore re-increase its spare capacities accordingly).
3385#[derive(Clone, Default, PartialEq)]
3386#[non_exhaustive]
3387pub struct Shipment {
3388 /// Set of pickup alternatives associated to the shipment. If not specified,
3389 /// the vehicle only needs to visit a location corresponding to the deliveries.
3390 pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
3391
3392 /// Set of delivery alternatives associated to the shipment. If not specified,
3393 /// the vehicle only needs to visit a location corresponding to the pickups.
3394 pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
3395
3396 /// Load demands of the shipment (for example weight, volume, number of
3397 /// pallets etc). The keys in the map should be identifiers describing the type
3398 /// of the corresponding load, ideally also including the units.
3399 /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
3400 /// If a given key does not appear in the map, the corresponding load is
3401 /// considered as null.
3402 pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3403
3404 /// If the shipment is not completed, this penalty is added to the overall
3405 /// cost of the routes. A shipment is considered completed if one of its pickup
3406 /// and delivery alternatives is visited. The cost may be expressed in the
3407 /// same unit used for all other cost-related fields in the model and must be
3408 /// positive.
3409 ///
3410 /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
3411 /// i.e. the shipment must be completed.
3412 pub penalty_cost: std::option::Option<f64>,
3413
3414 /// The set of vehicles that may perform this shipment. If empty, all vehicles
3415 /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
3416 /// `vehicles` list.
3417 pub allowed_vehicle_indices: std::vec::Vec<i32>,
3418
3419 /// Specifies the cost that is incurred when this shipment is delivered by each
3420 /// vehicle. If specified, it must have EITHER:
3421 ///
3422 /// * the same number of elements as `costs_per_vehicle_indices`.
3423 /// `costs_per_vehicle[i]` corresponds to vehicle
3424 /// `costs_per_vehicle_indices[i]` of the model.
3425 /// * the same number of elements as there are vehicles in the model. The
3426 /// i-th element corresponds to vehicle #i of the model.
3427 ///
3428 /// These costs must be in the same unit as `penalty_cost` and must not be
3429 /// negative. Leave this field empty, if there are no such costs.
3430 pub costs_per_vehicle: std::vec::Vec<f64>,
3431
3432 /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
3433 /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
3434 /// index may not be specified more than once. If a vehicle is excluded from
3435 /// `costs_per_vehicle_indices`, its cost is zero.
3436 pub costs_per_vehicle_indices: std::vec::Vec<i32>,
3437
3438 /// Specifies the maximum relative detour time compared to the shortest path
3439 /// from pickup to delivery. If specified, it must be nonnegative, and the
3440 /// shipment must contain at least a pickup and a delivery.
3441 ///
3442 /// For example, let t be the shortest time taken to go from the selected
3443 /// pickup alternative directly to the selected delivery alternative. Then
3444 /// setting `pickup_to_delivery_relative_detour_limit` enforces:
3445 ///
3446 /// ```norust
3447 /// start_time(delivery) - start_time(pickup) <=
3448 /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
3449 /// ```
3450 ///
3451 /// If both relative and absolute limits are specified on the same shipment,
3452 /// the more constraining limit is used for each possible pickup/delivery pair.
3453 /// As of 2017/10, detours are only supported when travel durations do not
3454 /// depend on vehicles.
3455 pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
3456
3457 /// Specifies the maximum absolute detour time compared to the shortest path
3458 /// from pickup to delivery. If specified, it must be nonnegative, and the
3459 /// shipment must contain at least a pickup and a delivery.
3460 ///
3461 /// For example, let t be the shortest time taken to go from the selected
3462 /// pickup alternative directly to the selected delivery alternative. Then
3463 /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
3464 ///
3465 /// ```norust
3466 /// start_time(delivery) - start_time(pickup) <=
3467 /// t + pickup_to_delivery_absolute_detour_limit
3468 /// ```
3469 ///
3470 /// If both relative and absolute limits are specified on the same shipment,
3471 /// the more constraining limit is used for each possible pickup/delivery pair.
3472 /// As of 2017/10, detours are only supported when travel durations do not
3473 /// depend on vehicles.
3474 pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
3475
3476 /// Specifies the maximum duration from start of pickup to start of delivery of
3477 /// a shipment. If specified, it must be nonnegative, and the shipment must
3478 /// contain at least a pickup and a delivery. This does not depend on which
3479 /// alternatives are selected for pickup and delivery, nor on vehicle speed.
3480 /// This can be specified alongside maximum detour constraints: the solution
3481 /// will respect both specifications.
3482 pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
3483
3484 /// Non-empty string specifying a "type" for this shipment.
3485 /// This feature can be used to define incompatibilities or requirements
3486 /// between `shipment_types` (see `shipment_type_incompatibilities` and
3487 /// `shipment_type_requirements` in `ShipmentModel`).
3488 ///
3489 /// Differs from `visit_types` which is specified for a single visit: All
3490 /// pickup/deliveries belonging to the same shipment share the same
3491 /// `shipment_type`.
3492 pub shipment_type: std::string::String,
3493
3494 /// Specifies a label for this shipment. This label is reported in the response
3495 /// in the `shipment_label` of the corresponding
3496 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3497 ///
3498 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3499 pub label: std::string::String,
3500
3501 /// If true, skip this shipment, but don't apply a `penalty_cost`.
3502 ///
3503 /// Ignoring a shipment results in a validation error when there are any
3504 /// `shipment_type_requirements` in the model.
3505 ///
3506 /// Ignoring a shipment that is performed in `injected_first_solution_routes`
3507 /// or `injected_solution_constraint` is permitted; the solver removes the
3508 /// related pickup/delivery visits from the performing route.
3509 /// `precedence_rules` that reference ignored shipments will also be ignored.
3510 pub ignore: bool,
3511
3512 /// Deprecated: Use
3513 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3514 /// instead.
3515 ///
3516 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3517 #[deprecated]
3518 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3519
3520 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3521}
3522
3523impl Shipment {
3524 pub fn new() -> Self {
3525 std::default::Default::default()
3526 }
3527
3528 /// Sets the value of [pickups][crate::model::Shipment::pickups].
3529 ///
3530 /// # Example
3531 /// ```ignore,no_run
3532 /// # use google_cloud_optimization_v1::model::Shipment;
3533 /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3534 /// let x = Shipment::new()
3535 /// .set_pickups([
3536 /// VisitRequest::default()/* use setters */,
3537 /// VisitRequest::default()/* use (different) setters */,
3538 /// ]);
3539 /// ```
3540 pub fn set_pickups<T, V>(mut self, v: T) -> Self
3541 where
3542 T: std::iter::IntoIterator<Item = V>,
3543 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3544 {
3545 use std::iter::Iterator;
3546 self.pickups = v.into_iter().map(|i| i.into()).collect();
3547 self
3548 }
3549
3550 /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
3551 ///
3552 /// # Example
3553 /// ```ignore,no_run
3554 /// # use google_cloud_optimization_v1::model::Shipment;
3555 /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3556 /// let x = Shipment::new()
3557 /// .set_deliveries([
3558 /// VisitRequest::default()/* use setters */,
3559 /// VisitRequest::default()/* use (different) setters */,
3560 /// ]);
3561 /// ```
3562 pub fn set_deliveries<T, V>(mut self, v: T) -> Self
3563 where
3564 T: std::iter::IntoIterator<Item = V>,
3565 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3566 {
3567 use std::iter::Iterator;
3568 self.deliveries = v.into_iter().map(|i| i.into()).collect();
3569 self
3570 }
3571
3572 /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
3573 ///
3574 /// # Example
3575 /// ```ignore,no_run
3576 /// # use google_cloud_optimization_v1::model::Shipment;
3577 /// use google_cloud_optimization_v1::model::shipment::Load;
3578 /// let x = Shipment::new().set_load_demands([
3579 /// ("key0", Load::default()/* use setters */),
3580 /// ("key1", Load::default()/* use (different) setters */),
3581 /// ]);
3582 /// ```
3583 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
3584 where
3585 T: std::iter::IntoIterator<Item = (K, V)>,
3586 K: std::convert::Into<std::string::String>,
3587 V: std::convert::Into<crate::model::shipment::Load>,
3588 {
3589 use std::iter::Iterator;
3590 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3591 self
3592 }
3593
3594 /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3595 ///
3596 /// # Example
3597 /// ```ignore,no_run
3598 /// # use google_cloud_optimization_v1::model::Shipment;
3599 /// let x = Shipment::new().set_penalty_cost(42.0);
3600 /// ```
3601 pub fn set_penalty_cost<T>(mut self, v: T) -> Self
3602 where
3603 T: std::convert::Into<f64>,
3604 {
3605 self.penalty_cost = std::option::Option::Some(v.into());
3606 self
3607 }
3608
3609 /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3610 ///
3611 /// # Example
3612 /// ```ignore,no_run
3613 /// # use google_cloud_optimization_v1::model::Shipment;
3614 /// let x = Shipment::new().set_or_clear_penalty_cost(Some(42.0));
3615 /// let x = Shipment::new().set_or_clear_penalty_cost(None::<f32>);
3616 /// ```
3617 pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
3618 where
3619 T: std::convert::Into<f64>,
3620 {
3621 self.penalty_cost = v.map(|x| x.into());
3622 self
3623 }
3624
3625 /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
3626 ///
3627 /// # Example
3628 /// ```ignore,no_run
3629 /// # use google_cloud_optimization_v1::model::Shipment;
3630 /// let x = Shipment::new().set_allowed_vehicle_indices([1, 2, 3]);
3631 /// ```
3632 pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
3633 where
3634 T: std::iter::IntoIterator<Item = V>,
3635 V: std::convert::Into<i32>,
3636 {
3637 use std::iter::Iterator;
3638 self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3639 self
3640 }
3641
3642 /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
3643 ///
3644 /// # Example
3645 /// ```ignore,no_run
3646 /// # use google_cloud_optimization_v1::model::Shipment;
3647 /// let x = Shipment::new().set_costs_per_vehicle([1.0, 2.0, 3.0]);
3648 /// ```
3649 pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
3650 where
3651 T: std::iter::IntoIterator<Item = V>,
3652 V: std::convert::Into<f64>,
3653 {
3654 use std::iter::Iterator;
3655 self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
3656 self
3657 }
3658
3659 /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
3660 ///
3661 /// # Example
3662 /// ```ignore,no_run
3663 /// # use google_cloud_optimization_v1::model::Shipment;
3664 /// let x = Shipment::new().set_costs_per_vehicle_indices([1, 2, 3]);
3665 /// ```
3666 pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
3667 where
3668 T: std::iter::IntoIterator<Item = V>,
3669 V: std::convert::Into<i32>,
3670 {
3671 use std::iter::Iterator;
3672 self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3673 self
3674 }
3675
3676 /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3677 ///
3678 /// # Example
3679 /// ```ignore,no_run
3680 /// # use google_cloud_optimization_v1::model::Shipment;
3681 /// let x = Shipment::new().set_pickup_to_delivery_relative_detour_limit(42.0);
3682 /// ```
3683 pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
3684 where
3685 T: std::convert::Into<f64>,
3686 {
3687 self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
3688 self
3689 }
3690
3691 /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3692 ///
3693 /// # Example
3694 /// ```ignore,no_run
3695 /// # use google_cloud_optimization_v1::model::Shipment;
3696 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(Some(42.0));
3697 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(None::<f32>);
3698 /// ```
3699 pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
3700 mut self,
3701 v: std::option::Option<T>,
3702 ) -> Self
3703 where
3704 T: std::convert::Into<f64>,
3705 {
3706 self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
3707 self
3708 }
3709
3710 /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3711 ///
3712 /// # Example
3713 /// ```ignore,no_run
3714 /// # use google_cloud_optimization_v1::model::Shipment;
3715 /// use wkt::Duration;
3716 /// let x = Shipment::new().set_pickup_to_delivery_absolute_detour_limit(Duration::default()/* use setters */);
3717 /// ```
3718 pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
3719 where
3720 T: std::convert::Into<wkt::Duration>,
3721 {
3722 self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
3723 self
3724 }
3725
3726 /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3727 ///
3728 /// # Example
3729 /// ```ignore,no_run
3730 /// # use google_cloud_optimization_v1::model::Shipment;
3731 /// use wkt::Duration;
3732 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(Some(Duration::default()/* use setters */));
3733 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(None::<Duration>);
3734 /// ```
3735 pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
3736 mut self,
3737 v: std::option::Option<T>,
3738 ) -> Self
3739 where
3740 T: std::convert::Into<wkt::Duration>,
3741 {
3742 self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
3743 self
3744 }
3745
3746 /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3747 ///
3748 /// # Example
3749 /// ```ignore,no_run
3750 /// # use google_cloud_optimization_v1::model::Shipment;
3751 /// use wkt::Duration;
3752 /// let x = Shipment::new().set_pickup_to_delivery_time_limit(Duration::default()/* use setters */);
3753 /// ```
3754 pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
3755 where
3756 T: std::convert::Into<wkt::Duration>,
3757 {
3758 self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
3759 self
3760 }
3761
3762 /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3763 ///
3764 /// # Example
3765 /// ```ignore,no_run
3766 /// # use google_cloud_optimization_v1::model::Shipment;
3767 /// use wkt::Duration;
3768 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(Some(Duration::default()/* use setters */));
3769 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(None::<Duration>);
3770 /// ```
3771 pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
3772 mut self,
3773 v: std::option::Option<T>,
3774 ) -> Self
3775 where
3776 T: std::convert::Into<wkt::Duration>,
3777 {
3778 self.pickup_to_delivery_time_limit = v.map(|x| x.into());
3779 self
3780 }
3781
3782 /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
3783 ///
3784 /// # Example
3785 /// ```ignore,no_run
3786 /// # use google_cloud_optimization_v1::model::Shipment;
3787 /// let x = Shipment::new().set_shipment_type("example");
3788 /// ```
3789 pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3790 self.shipment_type = v.into();
3791 self
3792 }
3793
3794 /// Sets the value of [label][crate::model::Shipment::label].
3795 ///
3796 /// # Example
3797 /// ```ignore,no_run
3798 /// # use google_cloud_optimization_v1::model::Shipment;
3799 /// let x = Shipment::new().set_label("example");
3800 /// ```
3801 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3802 self.label = v.into();
3803 self
3804 }
3805
3806 /// Sets the value of [ignore][crate::model::Shipment::ignore].
3807 ///
3808 /// # Example
3809 /// ```ignore,no_run
3810 /// # use google_cloud_optimization_v1::model::Shipment;
3811 /// let x = Shipment::new().set_ignore(true);
3812 /// ```
3813 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3814 self.ignore = v.into();
3815 self
3816 }
3817
3818 /// Sets the value of [demands][crate::model::Shipment::demands].
3819 ///
3820 /// # Example
3821 /// ```ignore,no_run
3822 /// # use google_cloud_optimization_v1::model::Shipment;
3823 /// use google_cloud_optimization_v1::model::CapacityQuantity;
3824 /// let x = Shipment::new()
3825 /// .set_demands([
3826 /// CapacityQuantity::default()/* use setters */,
3827 /// CapacityQuantity::default()/* use (different) setters */,
3828 /// ]);
3829 /// ```
3830 #[deprecated]
3831 pub fn set_demands<T, V>(mut self, v: T) -> Self
3832 where
3833 T: std::iter::IntoIterator<Item = V>,
3834 V: std::convert::Into<crate::model::CapacityQuantity>,
3835 {
3836 use std::iter::Iterator;
3837 self.demands = v.into_iter().map(|i| i.into()).collect();
3838 self
3839 }
3840}
3841
3842impl wkt::message::Message for Shipment {
3843 fn typename() -> &'static str {
3844 "type.googleapis.com/google.cloud.optimization.v1.Shipment"
3845 }
3846}
3847
3848/// Defines additional types related to [Shipment].
3849pub mod shipment {
3850 #[allow(unused_imports)]
3851 use super::*;
3852
3853 /// Request for a visit which can be done by a vehicle: it has a geo-location
3854 /// (or two, see below), opening and closing times represented by time windows,
3855 /// and a service duration time (time spent by the vehicle once it has arrived
3856 /// to pickup or drop off goods).
3857 #[derive(Clone, Default, PartialEq)]
3858 #[non_exhaustive]
3859 pub struct VisitRequest {
3860 /// The geo-location where the vehicle arrives when performing this
3861 /// `VisitRequest`. If the shipment model has duration distance matrices,
3862 /// `arrival_location` must not be specified.
3863 pub arrival_location: std::option::Option<google_cloud_type::model::LatLng>,
3864
3865 /// The waypoint where the vehicle arrives when performing this
3866 /// `VisitRequest`. If the shipment model has duration distance matrices,
3867 /// `arrival_waypoint` must not be specified.
3868 pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
3869
3870 /// The geo-location where the vehicle departs after completing this
3871 /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
3872 /// If the shipment model has duration distance matrices,
3873 /// `departure_location` must not be specified.
3874 pub departure_location: std::option::Option<google_cloud_type::model::LatLng>,
3875
3876 /// The waypoint where the vehicle departs after completing this
3877 /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
3878 /// If the shipment model has duration distance matrices,
3879 /// `departure_waypoint` must not be specified.
3880 pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
3881
3882 /// Specifies tags attached to the visit request.
3883 /// Empty or duplicate strings are not allowed.
3884 pub tags: std::vec::Vec<std::string::String>,
3885
3886 /// Time windows which constrain the arrival time at a visit.
3887 /// Note that a vehicle may depart outside of the arrival time window, i.e.
3888 /// arrival time + duration do not need to be inside a time window. This can
3889 /// result in waiting time if the vehicle arrives before
3890 /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
3891 ///
3892 /// The absence of `TimeWindow` means that the vehicle can perform this visit
3893 /// at any time.
3894 ///
3895 /// Time windows must be disjoint, i.e. no time window must overlap with or
3896 /// be adjacent to another, and they must be in increasing order.
3897 ///
3898 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
3899 /// be set if there is a single time window.
3900 ///
3901 /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
3902 pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
3903
3904 /// Duration of the visit, i.e. time spent by the vehicle between arrival
3905 /// and departure (to be added to the possible waiting time; see
3906 /// `time_windows`).
3907 pub duration: std::option::Option<wkt::Duration>,
3908
3909 /// Cost to service this visit request on a vehicle route. This can be used
3910 /// to pay different costs for each alternative pickup or delivery of a
3911 /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
3912 /// and must not be negative.
3913 pub cost: f64,
3914
3915 /// Load demands of this visit request. This is just like
3916 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3917 /// field, except that it only applies to this
3918 /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
3919 /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
3920 /// The demands listed here are added to the demands listed in
3921 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
3922 ///
3923 /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
3924 /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
3925 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3926 pub load_demands:
3927 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3928
3929 /// Specifies the types of the visit. This may be used to allocate additional
3930 /// time required for a vehicle to complete this visit (see
3931 /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
3932 ///
3933 /// A type can only appear once.
3934 ///
3935 /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
3936 pub visit_types: std::vec::Vec<std::string::String>,
3937
3938 /// Specifies a label for this `VisitRequest`. This label is reported in the
3939 /// response as `visit_label` in the corresponding
3940 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3941 ///
3942 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3943 pub label: std::string::String,
3944
3945 /// Deprecated: Use
3946 /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
3947 /// instead.
3948 ///
3949 /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
3950 #[deprecated]
3951 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3952
3953 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3954 }
3955
3956 impl VisitRequest {
3957 pub fn new() -> Self {
3958 std::default::Default::default()
3959 }
3960
3961 /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3962 ///
3963 /// # Example
3964 /// ```ignore,no_run
3965 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3966 /// use google_cloud_type::model::LatLng;
3967 /// let x = VisitRequest::new().set_arrival_location(LatLng::default()/* use setters */);
3968 /// ```
3969 pub fn set_arrival_location<T>(mut self, v: T) -> Self
3970 where
3971 T: std::convert::Into<google_cloud_type::model::LatLng>,
3972 {
3973 self.arrival_location = std::option::Option::Some(v.into());
3974 self
3975 }
3976
3977 /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3978 ///
3979 /// # Example
3980 /// ```ignore,no_run
3981 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3982 /// use google_cloud_type::model::LatLng;
3983 /// let x = VisitRequest::new().set_or_clear_arrival_location(Some(LatLng::default()/* use setters */));
3984 /// let x = VisitRequest::new().set_or_clear_arrival_location(None::<LatLng>);
3985 /// ```
3986 pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
3987 where
3988 T: std::convert::Into<google_cloud_type::model::LatLng>,
3989 {
3990 self.arrival_location = v.map(|x| x.into());
3991 self
3992 }
3993
3994 /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
3995 ///
3996 /// # Example
3997 /// ```ignore,no_run
3998 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3999 /// use google_cloud_optimization_v1::model::Waypoint;
4000 /// let x = VisitRequest::new().set_arrival_waypoint(Waypoint::default()/* use setters */);
4001 /// ```
4002 pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
4003 where
4004 T: std::convert::Into<crate::model::Waypoint>,
4005 {
4006 self.arrival_waypoint = std::option::Option::Some(v.into());
4007 self
4008 }
4009
4010 /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
4011 ///
4012 /// # Example
4013 /// ```ignore,no_run
4014 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4015 /// use google_cloud_optimization_v1::model::Waypoint;
4016 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(Some(Waypoint::default()/* use setters */));
4017 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(None::<Waypoint>);
4018 /// ```
4019 pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4020 where
4021 T: std::convert::Into<crate::model::Waypoint>,
4022 {
4023 self.arrival_waypoint = v.map(|x| x.into());
4024 self
4025 }
4026
4027 /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4028 ///
4029 /// # Example
4030 /// ```ignore,no_run
4031 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4032 /// use google_cloud_type::model::LatLng;
4033 /// let x = VisitRequest::new().set_departure_location(LatLng::default()/* use setters */);
4034 /// ```
4035 pub fn set_departure_location<T>(mut self, v: T) -> Self
4036 where
4037 T: std::convert::Into<google_cloud_type::model::LatLng>,
4038 {
4039 self.departure_location = std::option::Option::Some(v.into());
4040 self
4041 }
4042
4043 /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4044 ///
4045 /// # Example
4046 /// ```ignore,no_run
4047 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4048 /// use google_cloud_type::model::LatLng;
4049 /// let x = VisitRequest::new().set_or_clear_departure_location(Some(LatLng::default()/* use setters */));
4050 /// let x = VisitRequest::new().set_or_clear_departure_location(None::<LatLng>);
4051 /// ```
4052 pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
4053 where
4054 T: std::convert::Into<google_cloud_type::model::LatLng>,
4055 {
4056 self.departure_location = v.map(|x| x.into());
4057 self
4058 }
4059
4060 /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4061 ///
4062 /// # Example
4063 /// ```ignore,no_run
4064 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4065 /// use google_cloud_optimization_v1::model::Waypoint;
4066 /// let x = VisitRequest::new().set_departure_waypoint(Waypoint::default()/* use setters */);
4067 /// ```
4068 pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
4069 where
4070 T: std::convert::Into<crate::model::Waypoint>,
4071 {
4072 self.departure_waypoint = std::option::Option::Some(v.into());
4073 self
4074 }
4075
4076 /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4077 ///
4078 /// # Example
4079 /// ```ignore,no_run
4080 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4081 /// use google_cloud_optimization_v1::model::Waypoint;
4082 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(Some(Waypoint::default()/* use setters */));
4083 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(None::<Waypoint>);
4084 /// ```
4085 pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4086 where
4087 T: std::convert::Into<crate::model::Waypoint>,
4088 {
4089 self.departure_waypoint = v.map(|x| x.into());
4090 self
4091 }
4092
4093 /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
4094 ///
4095 /// # Example
4096 /// ```ignore,no_run
4097 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4098 /// let x = VisitRequest::new().set_tags(["a", "b", "c"]);
4099 /// ```
4100 pub fn set_tags<T, V>(mut self, v: T) -> Self
4101 where
4102 T: std::iter::IntoIterator<Item = V>,
4103 V: std::convert::Into<std::string::String>,
4104 {
4105 use std::iter::Iterator;
4106 self.tags = v.into_iter().map(|i| i.into()).collect();
4107 self
4108 }
4109
4110 /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
4111 ///
4112 /// # Example
4113 /// ```ignore,no_run
4114 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4115 /// use google_cloud_optimization_v1::model::TimeWindow;
4116 /// let x = VisitRequest::new()
4117 /// .set_time_windows([
4118 /// TimeWindow::default()/* use setters */,
4119 /// TimeWindow::default()/* use (different) setters */,
4120 /// ]);
4121 /// ```
4122 pub fn set_time_windows<T, V>(mut self, v: T) -> Self
4123 where
4124 T: std::iter::IntoIterator<Item = V>,
4125 V: std::convert::Into<crate::model::TimeWindow>,
4126 {
4127 use std::iter::Iterator;
4128 self.time_windows = v.into_iter().map(|i| i.into()).collect();
4129 self
4130 }
4131
4132 /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
4133 ///
4134 /// # Example
4135 /// ```ignore,no_run
4136 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4137 /// use wkt::Duration;
4138 /// let x = VisitRequest::new().set_duration(Duration::default()/* use setters */);
4139 /// ```
4140 pub fn set_duration<T>(mut self, v: T) -> Self
4141 where
4142 T: std::convert::Into<wkt::Duration>,
4143 {
4144 self.duration = std::option::Option::Some(v.into());
4145 self
4146 }
4147
4148 /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
4149 ///
4150 /// # Example
4151 /// ```ignore,no_run
4152 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4153 /// use wkt::Duration;
4154 /// let x = VisitRequest::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
4155 /// let x = VisitRequest::new().set_or_clear_duration(None::<Duration>);
4156 /// ```
4157 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
4158 where
4159 T: std::convert::Into<wkt::Duration>,
4160 {
4161 self.duration = v.map(|x| x.into());
4162 self
4163 }
4164
4165 /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
4166 ///
4167 /// # Example
4168 /// ```ignore,no_run
4169 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4170 /// let x = VisitRequest::new().set_cost(42.0);
4171 /// ```
4172 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4173 self.cost = v.into();
4174 self
4175 }
4176
4177 /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
4178 ///
4179 /// # Example
4180 /// ```ignore,no_run
4181 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4182 /// use google_cloud_optimization_v1::model::shipment::Load;
4183 /// let x = VisitRequest::new().set_load_demands([
4184 /// ("key0", Load::default()/* use setters */),
4185 /// ("key1", Load::default()/* use (different) setters */),
4186 /// ]);
4187 /// ```
4188 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
4189 where
4190 T: std::iter::IntoIterator<Item = (K, V)>,
4191 K: std::convert::Into<std::string::String>,
4192 V: std::convert::Into<crate::model::shipment::Load>,
4193 {
4194 use std::iter::Iterator;
4195 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4196 self
4197 }
4198
4199 /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
4200 ///
4201 /// # Example
4202 /// ```ignore,no_run
4203 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4204 /// let x = VisitRequest::new().set_visit_types(["a", "b", "c"]);
4205 /// ```
4206 pub fn set_visit_types<T, V>(mut self, v: T) -> Self
4207 where
4208 T: std::iter::IntoIterator<Item = V>,
4209 V: std::convert::Into<std::string::String>,
4210 {
4211 use std::iter::Iterator;
4212 self.visit_types = v.into_iter().map(|i| i.into()).collect();
4213 self
4214 }
4215
4216 /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
4217 ///
4218 /// # Example
4219 /// ```ignore,no_run
4220 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4221 /// let x = VisitRequest::new().set_label("example");
4222 /// ```
4223 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4224 self.label = v.into();
4225 self
4226 }
4227
4228 /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
4229 ///
4230 /// # Example
4231 /// ```ignore,no_run
4232 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4233 /// use google_cloud_optimization_v1::model::CapacityQuantity;
4234 /// let x = VisitRequest::new()
4235 /// .set_demands([
4236 /// CapacityQuantity::default()/* use setters */,
4237 /// CapacityQuantity::default()/* use (different) setters */,
4238 /// ]);
4239 /// ```
4240 #[deprecated]
4241 pub fn set_demands<T, V>(mut self, v: T) -> Self
4242 where
4243 T: std::iter::IntoIterator<Item = V>,
4244 V: std::convert::Into<crate::model::CapacityQuantity>,
4245 {
4246 use std::iter::Iterator;
4247 self.demands = v.into_iter().map(|i| i.into()).collect();
4248 self
4249 }
4250 }
4251
4252 impl wkt::message::Message for VisitRequest {
4253 fn typename() -> &'static str {
4254 "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
4255 }
4256 }
4257
4258 /// When performing a visit, a predefined amount may be added to the vehicle
4259 /// load if it's a pickup, or subtracted if it's a delivery. This message
4260 /// defines such amount. See
4261 /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
4262 ///
4263 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4264 #[derive(Clone, Default, PartialEq)]
4265 #[non_exhaustive]
4266 pub struct Load {
4267 /// The amount by which the load of the vehicle performing the corresponding
4268 /// visit will vary. Since it is an integer, users are advised to choose an
4269 /// appropriate unit to avoid loss of precision. Must be ≥ 0.
4270 pub amount: i64,
4271
4272 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4273 }
4274
4275 impl Load {
4276 pub fn new() -> Self {
4277 std::default::Default::default()
4278 }
4279
4280 /// Sets the value of [amount][crate::model::shipment::Load::amount].
4281 ///
4282 /// # Example
4283 /// ```ignore,no_run
4284 /// # use google_cloud_optimization_v1::model::shipment::Load;
4285 /// let x = Load::new().set_amount(42);
4286 /// ```
4287 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4288 self.amount = v.into();
4289 self
4290 }
4291 }
4292
4293 impl wkt::message::Message for Load {
4294 fn typename() -> &'static str {
4295 "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
4296 }
4297 }
4298}
4299
4300/// Specifies incompatibilties between shipments depending on their
4301/// shipment_type. The appearance of incompatible shipments on the same route is
4302/// restricted based on the incompatibility mode.
4303#[derive(Clone, Default, PartialEq)]
4304#[non_exhaustive]
4305pub struct ShipmentTypeIncompatibility {
4306 /// List of incompatible types. Two shipments having different `shipment_types`
4307 /// among those listed are "incompatible".
4308 pub types: std::vec::Vec<std::string::String>,
4309
4310 /// Mode applied to the incompatibility.
4311 pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
4312
4313 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4314}
4315
4316impl ShipmentTypeIncompatibility {
4317 pub fn new() -> Self {
4318 std::default::Default::default()
4319 }
4320
4321 /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
4322 ///
4323 /// # Example
4324 /// ```ignore,no_run
4325 /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4326 /// let x = ShipmentTypeIncompatibility::new().set_types(["a", "b", "c"]);
4327 /// ```
4328 pub fn set_types<T, V>(mut self, v: T) -> Self
4329 where
4330 T: std::iter::IntoIterator<Item = V>,
4331 V: std::convert::Into<std::string::String>,
4332 {
4333 use std::iter::Iterator;
4334 self.types = v.into_iter().map(|i| i.into()).collect();
4335 self
4336 }
4337
4338 /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
4339 ///
4340 /// # Example
4341 /// ```ignore,no_run
4342 /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4343 /// use google_cloud_optimization_v1::model::shipment_type_incompatibility::IncompatibilityMode;
4344 /// let x0 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotPerformedBySameVehicle);
4345 /// let x1 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotInSameVehicleSimultaneously);
4346 /// ```
4347 pub fn set_incompatibility_mode<
4348 T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
4349 >(
4350 mut self,
4351 v: T,
4352 ) -> Self {
4353 self.incompatibility_mode = v.into();
4354 self
4355 }
4356}
4357
4358impl wkt::message::Message for ShipmentTypeIncompatibility {
4359 fn typename() -> &'static str {
4360 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
4361 }
4362}
4363
4364/// Defines additional types related to [ShipmentTypeIncompatibility].
4365pub mod shipment_type_incompatibility {
4366 #[allow(unused_imports)]
4367 use super::*;
4368
4369 /// Modes defining how the appearance of incompatible shipments are restricted
4370 /// on the same route.
4371 ///
4372 /// # Working with unknown values
4373 ///
4374 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4375 /// additional enum variants at any time. Adding new variants is not considered
4376 /// a breaking change. Applications should write their code in anticipation of:
4377 ///
4378 /// - New values appearing in future releases of the client library, **and**
4379 /// - New values received dynamically, without application changes.
4380 ///
4381 /// Please consult the [Working with enums] section in the user guide for some
4382 /// guidelines.
4383 ///
4384 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4385 #[derive(Clone, Debug, PartialEq)]
4386 #[non_exhaustive]
4387 pub enum IncompatibilityMode {
4388 /// Unspecified incompatibility mode. This value should never be used.
4389 Unspecified,
4390 /// In this mode, two shipments with incompatible types can never share the
4391 /// same vehicle.
4392 NotPerformedBySameVehicle,
4393 /// For two shipments with incompatible types with the
4394 /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
4395 ///
4396 /// * If both are pickups only (no deliveries) or deliveries only (no
4397 /// pickups), they cannot share the same vehicle at all.
4398 /// * If one of the shipments has a delivery and the other a pickup, the two
4399 /// shipments can share the same vehicle iff the former shipment is
4400 /// delivered before the latter is picked up.
4401 NotInSameVehicleSimultaneously,
4402 /// If set, the enum was initialized with an unknown value.
4403 ///
4404 /// Applications can examine the value using [IncompatibilityMode::value] or
4405 /// [IncompatibilityMode::name].
4406 UnknownValue(incompatibility_mode::UnknownValue),
4407 }
4408
4409 #[doc(hidden)]
4410 pub mod incompatibility_mode {
4411 #[allow(unused_imports)]
4412 use super::*;
4413 #[derive(Clone, Debug, PartialEq)]
4414 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4415 }
4416
4417 impl IncompatibilityMode {
4418 /// Gets the enum value.
4419 ///
4420 /// Returns `None` if the enum contains an unknown value deserialized from
4421 /// the string representation of enums.
4422 pub fn value(&self) -> std::option::Option<i32> {
4423 match self {
4424 Self::Unspecified => std::option::Option::Some(0),
4425 Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
4426 Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
4427 Self::UnknownValue(u) => u.0.value(),
4428 }
4429 }
4430
4431 /// Gets the enum value as a string.
4432 ///
4433 /// Returns `None` if the enum contains an unknown value deserialized from
4434 /// the integer representation of enums.
4435 pub fn name(&self) -> std::option::Option<&str> {
4436 match self {
4437 Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
4438 Self::NotPerformedBySameVehicle => {
4439 std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
4440 }
4441 Self::NotInSameVehicleSimultaneously => {
4442 std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
4443 }
4444 Self::UnknownValue(u) => u.0.name(),
4445 }
4446 }
4447 }
4448
4449 impl std::default::Default for IncompatibilityMode {
4450 fn default() -> Self {
4451 use std::convert::From;
4452 Self::from(0)
4453 }
4454 }
4455
4456 impl std::fmt::Display for IncompatibilityMode {
4457 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4458 wkt::internal::display_enum(f, self.name(), self.value())
4459 }
4460 }
4461
4462 impl std::convert::From<i32> for IncompatibilityMode {
4463 fn from(value: i32) -> Self {
4464 match value {
4465 0 => Self::Unspecified,
4466 1 => Self::NotPerformedBySameVehicle,
4467 2 => Self::NotInSameVehicleSimultaneously,
4468 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4469 wkt::internal::UnknownEnumValue::Integer(value),
4470 )),
4471 }
4472 }
4473 }
4474
4475 impl std::convert::From<&str> for IncompatibilityMode {
4476 fn from(value: &str) -> Self {
4477 use std::string::ToString;
4478 match value {
4479 "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
4480 "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
4481 "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
4482 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4483 wkt::internal::UnknownEnumValue::String(value.to_string()),
4484 )),
4485 }
4486 }
4487 }
4488
4489 impl serde::ser::Serialize for IncompatibilityMode {
4490 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4491 where
4492 S: serde::Serializer,
4493 {
4494 match self {
4495 Self::Unspecified => serializer.serialize_i32(0),
4496 Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
4497 Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
4498 Self::UnknownValue(u) => u.0.serialize(serializer),
4499 }
4500 }
4501 }
4502
4503 impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
4504 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4505 where
4506 D: serde::Deserializer<'de>,
4507 {
4508 deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
4509 ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
4510 ))
4511 }
4512 }
4513}
4514
4515/// Specifies requirements between shipments based on their shipment_type.
4516/// The specifics of the requirement are defined by the requirement mode.
4517#[derive(Clone, Default, PartialEq)]
4518#[non_exhaustive]
4519pub struct ShipmentTypeRequirement {
4520 /// List of alternative shipment types required by the
4521 /// `dependent_shipment_types`.
4522 pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
4523
4524 /// All shipments with a type in the `dependent_shipment_types` field require
4525 /// at least one shipment of type `required_shipment_type_alternatives` to be
4526 /// visited on the same route.
4527 ///
4528 /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
4529 /// are not allowed.
4530 pub dependent_shipment_types: std::vec::Vec<std::string::String>,
4531
4532 /// Mode applied to the requirement.
4533 pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
4534
4535 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4536}
4537
4538impl ShipmentTypeRequirement {
4539 pub fn new() -> Self {
4540 std::default::Default::default()
4541 }
4542
4543 /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
4544 ///
4545 /// # Example
4546 /// ```ignore,no_run
4547 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4548 /// let x = ShipmentTypeRequirement::new().set_required_shipment_type_alternatives(["a", "b", "c"]);
4549 /// ```
4550 pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
4551 where
4552 T: std::iter::IntoIterator<Item = V>,
4553 V: std::convert::Into<std::string::String>,
4554 {
4555 use std::iter::Iterator;
4556 self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
4557 self
4558 }
4559
4560 /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
4561 ///
4562 /// # Example
4563 /// ```ignore,no_run
4564 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4565 /// let x = ShipmentTypeRequirement::new().set_dependent_shipment_types(["a", "b", "c"]);
4566 /// ```
4567 pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
4568 where
4569 T: std::iter::IntoIterator<Item = V>,
4570 V: std::convert::Into<std::string::String>,
4571 {
4572 use std::iter::Iterator;
4573 self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
4574 self
4575 }
4576
4577 /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
4578 ///
4579 /// # Example
4580 /// ```ignore,no_run
4581 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4582 /// use google_cloud_optimization_v1::model::shipment_type_requirement::RequirementMode;
4583 /// let x0 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::PerformedBySameVehicle);
4584 /// let x1 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtPickupTime);
4585 /// let x2 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtDeliveryTime);
4586 /// ```
4587 pub fn set_requirement_mode<
4588 T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
4589 >(
4590 mut self,
4591 v: T,
4592 ) -> Self {
4593 self.requirement_mode = v.into();
4594 self
4595 }
4596}
4597
4598impl wkt::message::Message for ShipmentTypeRequirement {
4599 fn typename() -> &'static str {
4600 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
4601 }
4602}
4603
4604/// Defines additional types related to [ShipmentTypeRequirement].
4605pub mod shipment_type_requirement {
4606 #[allow(unused_imports)]
4607 use super::*;
4608
4609 /// Modes defining the appearance of dependent shipments on a route.
4610 ///
4611 /// # Working with unknown values
4612 ///
4613 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4614 /// additional enum variants at any time. Adding new variants is not considered
4615 /// a breaking change. Applications should write their code in anticipation of:
4616 ///
4617 /// - New values appearing in future releases of the client library, **and**
4618 /// - New values received dynamically, without application changes.
4619 ///
4620 /// Please consult the [Working with enums] section in the user guide for some
4621 /// guidelines.
4622 ///
4623 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4624 #[derive(Clone, Debug, PartialEq)]
4625 #[non_exhaustive]
4626 pub enum RequirementMode {
4627 /// Unspecified requirement mode. This value should never be used.
4628 Unspecified,
4629 /// In this mode, all "dependent" shipments must share the same vehicle as at
4630 /// least one of their "required" shipments.
4631 PerformedBySameVehicle,
4632 /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
4633 /// shipments need to have at least one "required" shipment on their vehicle
4634 /// at the time of their pickup.
4635 ///
4636 /// A "dependent" shipment pickup must therefore have either:
4637 ///
4638 /// * A delivery-only "required" shipment delivered on the route after, or
4639 /// * A "required" shipment picked up on the route before it, and if the
4640 /// "required" shipment has a delivery, this delivery must be performed
4641 /// after the "dependent" shipment's pickup.
4642 InSameVehicleAtPickupTime,
4643 /// Same as before, except the "dependent" shipments need to have a
4644 /// "required" shipment on their vehicle at the time of their *delivery*.
4645 InSameVehicleAtDeliveryTime,
4646 /// If set, the enum was initialized with an unknown value.
4647 ///
4648 /// Applications can examine the value using [RequirementMode::value] or
4649 /// [RequirementMode::name].
4650 UnknownValue(requirement_mode::UnknownValue),
4651 }
4652
4653 #[doc(hidden)]
4654 pub mod requirement_mode {
4655 #[allow(unused_imports)]
4656 use super::*;
4657 #[derive(Clone, Debug, PartialEq)]
4658 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4659 }
4660
4661 impl RequirementMode {
4662 /// Gets the enum value.
4663 ///
4664 /// Returns `None` if the enum contains an unknown value deserialized from
4665 /// the string representation of enums.
4666 pub fn value(&self) -> std::option::Option<i32> {
4667 match self {
4668 Self::Unspecified => std::option::Option::Some(0),
4669 Self::PerformedBySameVehicle => std::option::Option::Some(1),
4670 Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
4671 Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
4672 Self::UnknownValue(u) => u.0.value(),
4673 }
4674 }
4675
4676 /// Gets the enum value as a string.
4677 ///
4678 /// Returns `None` if the enum contains an unknown value deserialized from
4679 /// the integer representation of enums.
4680 pub fn name(&self) -> std::option::Option<&str> {
4681 match self {
4682 Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
4683 Self::PerformedBySameVehicle => {
4684 std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
4685 }
4686 Self::InSameVehicleAtPickupTime => {
4687 std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
4688 }
4689 Self::InSameVehicleAtDeliveryTime => {
4690 std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
4691 }
4692 Self::UnknownValue(u) => u.0.name(),
4693 }
4694 }
4695 }
4696
4697 impl std::default::Default for RequirementMode {
4698 fn default() -> Self {
4699 use std::convert::From;
4700 Self::from(0)
4701 }
4702 }
4703
4704 impl std::fmt::Display for RequirementMode {
4705 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4706 wkt::internal::display_enum(f, self.name(), self.value())
4707 }
4708 }
4709
4710 impl std::convert::From<i32> for RequirementMode {
4711 fn from(value: i32) -> Self {
4712 match value {
4713 0 => Self::Unspecified,
4714 1 => Self::PerformedBySameVehicle,
4715 2 => Self::InSameVehicleAtPickupTime,
4716 3 => Self::InSameVehicleAtDeliveryTime,
4717 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4718 wkt::internal::UnknownEnumValue::Integer(value),
4719 )),
4720 }
4721 }
4722 }
4723
4724 impl std::convert::From<&str> for RequirementMode {
4725 fn from(value: &str) -> Self {
4726 use std::string::ToString;
4727 match value {
4728 "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
4729 "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
4730 "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
4731 "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
4732 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4733 wkt::internal::UnknownEnumValue::String(value.to_string()),
4734 )),
4735 }
4736 }
4737 }
4738
4739 impl serde::ser::Serialize for RequirementMode {
4740 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4741 where
4742 S: serde::Serializer,
4743 {
4744 match self {
4745 Self::Unspecified => serializer.serialize_i32(0),
4746 Self::PerformedBySameVehicle => serializer.serialize_i32(1),
4747 Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
4748 Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
4749 Self::UnknownValue(u) => u.0.serialize(serializer),
4750 }
4751 }
4752 }
4753
4754 impl<'de> serde::de::Deserialize<'de> for RequirementMode {
4755 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4756 where
4757 D: serde::Deserializer<'de>,
4758 {
4759 deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
4760 ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
4761 ))
4762 }
4763 }
4764}
4765
4766/// Encapsulates a set of optional conditions to satisfy when calculating
4767/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
4768/// Platform API; see:
4769/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
4770#[derive(Clone, Default, PartialEq)]
4771#[non_exhaustive]
4772pub struct RouteModifiers {
4773 /// Specifies whether to avoid toll roads where reasonable. Preference will be
4774 /// given to routes not containing toll roads. Applies only to motorized travel
4775 /// modes.
4776 pub avoid_tolls: bool,
4777
4778 /// Specifies whether to avoid highways where reasonable. Preference will be
4779 /// given to routes not containing highways. Applies only to motorized travel
4780 /// modes.
4781 pub avoid_highways: bool,
4782
4783 /// Specifies whether to avoid ferries where reasonable. Preference will be
4784 /// given to routes not containing travel by ferries. Applies only to motorized
4785 /// travel modes.
4786 pub avoid_ferries: bool,
4787
4788 /// Optional. Specifies whether to avoid navigating indoors where reasonable.
4789 /// Preference will be given to routes not containing indoor navigation.
4790 /// Applies only to the `WALKING` travel mode.
4791 pub avoid_indoor: bool,
4792
4793 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4794}
4795
4796impl RouteModifiers {
4797 pub fn new() -> Self {
4798 std::default::Default::default()
4799 }
4800
4801 /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
4802 ///
4803 /// # Example
4804 /// ```ignore,no_run
4805 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4806 /// let x = RouteModifiers::new().set_avoid_tolls(true);
4807 /// ```
4808 pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4809 self.avoid_tolls = v.into();
4810 self
4811 }
4812
4813 /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
4814 ///
4815 /// # Example
4816 /// ```ignore,no_run
4817 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4818 /// let x = RouteModifiers::new().set_avoid_highways(true);
4819 /// ```
4820 pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4821 self.avoid_highways = v.into();
4822 self
4823 }
4824
4825 /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
4826 ///
4827 /// # Example
4828 /// ```ignore,no_run
4829 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4830 /// let x = RouteModifiers::new().set_avoid_ferries(true);
4831 /// ```
4832 pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4833 self.avoid_ferries = v.into();
4834 self
4835 }
4836
4837 /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
4838 ///
4839 /// # Example
4840 /// ```ignore,no_run
4841 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4842 /// let x = RouteModifiers::new().set_avoid_indoor(true);
4843 /// ```
4844 pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4845 self.avoid_indoor = v.into();
4846 self
4847 }
4848}
4849
4850impl wkt::message::Message for RouteModifiers {
4851 fn typename() -> &'static str {
4852 "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
4853 }
4854}
4855
4856/// Models a vehicle in a shipment problem. Solving a shipment problem will
4857/// build a route starting from `start_location` and ending at `end_location`
4858/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
4859#[derive(Clone, Default, PartialEq)]
4860#[non_exhaustive]
4861pub struct Vehicle {
4862 /// The travel mode which affects the roads usable by the vehicle and its
4863 /// speed. See also `travel_duration_multiple`.
4864 pub travel_mode: crate::model::vehicle::TravelMode,
4865
4866 /// Optional. A set of conditions to satisfy that affect the way routes are
4867 /// calculated for the given vehicle.
4868 pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
4869
4870 /// Geographic location where the vehicle starts before picking up any
4871 /// shipments. If not specified, the vehicle starts at its first pickup.
4872 /// If the shipment model has duration and distance matrices, `start_location`
4873 /// must not be specified.
4874 pub start_location: std::option::Option<google_cloud_type::model::LatLng>,
4875
4876 /// Waypoint representing a geographic location where the vehicle starts before
4877 /// picking up any shipments. If neither `start_waypoint` nor `start_location`
4878 /// is specified, the vehicle starts at its first pickup.
4879 /// If the shipment model has duration and distance matrices, `start_waypoint`
4880 /// must not be specified.
4881 pub start_waypoint: std::option::Option<crate::model::Waypoint>,
4882
4883 /// Geographic location where the vehicle ends after it has completed its last
4884 /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
4885 /// immediately when it completes its last `VisitRequest`.
4886 /// If the shipment model has duration and distance matrices, `end_location`
4887 /// must not be specified.
4888 pub end_location: std::option::Option<google_cloud_type::model::LatLng>,
4889
4890 /// Waypoint representing a geographic location where the vehicle ends after
4891 /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
4892 /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
4893 /// when it completes its last `VisitRequest`.
4894 /// If the shipment model has duration and distance matrices, `end_waypoint`
4895 /// must not be specified.
4896 pub end_waypoint: std::option::Option<crate::model::Waypoint>,
4897
4898 /// Specifies tags attached to the start of the vehicle's route.
4899 ///
4900 /// Empty or duplicate strings are not allowed.
4901 pub start_tags: std::vec::Vec<std::string::String>,
4902
4903 /// Specifies tags attached to the end of the vehicle's route.
4904 ///
4905 /// Empty or duplicate strings are not allowed.
4906 pub end_tags: std::vec::Vec<std::string::String>,
4907
4908 /// Time windows during which the vehicle may depart its start location.
4909 /// They must be within the global time limits (see
4910 /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4911 /// fields). If unspecified, there is no limitation besides those global time
4912 /// limits.
4913 ///
4914 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4915 /// time window can overlap with or be adjacent to another, and they must be in
4916 /// chronological order.
4917 ///
4918 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4919 /// there is a single time window.
4920 ///
4921 /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4922 pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4923
4924 /// Time windows during which the vehicle may arrive at its end location.
4925 /// They must be within the global time limits (see
4926 /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4927 /// fields). If unspecified, there is no limitation besides those global time
4928 /// limits.
4929 ///
4930 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4931 /// time window can overlap with or be adjacent to another, and they must be in
4932 /// chronological order.
4933 ///
4934 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4935 /// there is a single time window.
4936 ///
4937 /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4938 pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4939
4940 /// Specifies a multiplicative factor that can be used to increase or decrease
4941 /// travel times of this vehicle. For example, setting this to 2.0 means
4942 /// that this vehicle is slower and has travel times that are twice what they
4943 /// are for standard vehicles. This multiple does not affect visit durations.
4944 /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
4945 /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
4946 /// is standard, and this multiple is considered 1.0.
4947 ///
4948 /// WARNING: Travel times will be rounded to the nearest second after this
4949 /// multiple is applied but before performing any numerical operations, thus,
4950 /// a small multiple may result in a loss of precision.
4951 ///
4952 /// See also `extra_visit_duration_for_visit_type` below.
4953 pub travel_duration_multiple: std::option::Option<f64>,
4954
4955 /// Unloading policy enforced on the vehicle.
4956 pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
4957
4958 /// Capacities of the vehicle (weight, volume, # of pallets for example).
4959 /// The keys in the map are the identifiers of the type of load, consistent
4960 /// with the keys of the
4961 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
4962 /// field. If a given key is absent from this map, the corresponding capacity
4963 /// is considered to be limitless.
4964 ///
4965 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4966 pub load_limits:
4967 std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
4968
4969 /// Vehicle costs: all costs add up and must be in the same unit as
4970 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
4971 ///
4972 /// Cost per hour of the vehicle route. This cost is applied to the total time
4973 /// taken by the route, and includes travel time, waiting time, and visit time.
4974 /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
4975 /// in additional latency.
4976 ///
4977 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
4978 pub cost_per_hour: f64,
4979
4980 /// Cost per traveled hour of the vehicle route. This cost is applied only to
4981 /// travel time taken by the route (i.e., that reported in
4982 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
4983 /// and excludes waiting time and visit time.
4984 ///
4985 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
4986 pub cost_per_traveled_hour: f64,
4987
4988 /// Cost per kilometer of the vehicle route. This cost is applied to the
4989 /// distance reported in the
4990 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
4991 /// and does not apply to any distance implicitly traveled from the
4992 /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
4993 ///
4994 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
4995 pub cost_per_kilometer: f64,
4996
4997 /// Fixed cost applied if this vehicle is used to handle a shipment.
4998 pub fixed_cost: f64,
4999
5000 /// This field only applies to vehicles when their route does not serve any
5001 /// shipments. It indicates if the vehicle should be considered as used or not
5002 /// in this case.
5003 ///
5004 /// If true, the vehicle goes from its start to its end location even if it
5005 /// doesn't serve any shipments, and time and distance costs resulting from its
5006 /// start --> end travel are taken into account.
5007 ///
5008 /// Otherwise, it doesn't travel from its start to its end location, and no
5009 /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
5010 /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
5011 /// information except for the vehicle index and label.
5012 pub used_if_route_is_empty: bool,
5013
5014 /// Limit applied to the total duration of the vehicle's route. In a given
5015 /// `OptimizeToursResponse`, the route duration of a vehicle is the
5016 /// difference between its `vehicle_end_time` and `vehicle_start_time`.
5017 pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5018
5019 /// Limit applied to the travel duration of the vehicle's route. In a given
5020 /// `OptimizeToursResponse`, the route travel duration is the sum of all its
5021 /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
5022 ///
5023 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
5024 pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5025
5026 /// Limit applied to the total distance of the vehicle's route. In a given
5027 /// `OptimizeToursResponse`, the route distance is the sum of all its
5028 /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
5029 ///
5030 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
5031 pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
5032
5033 /// Specifies a map from visit_types strings to durations. The duration is time
5034 /// in addition to
5035 /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
5036 /// to be taken at visits with the specified `visit_types`. This extra visit
5037 /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
5038 /// `visit_types`) cannot be empty strings.
5039 ///
5040 /// If a visit request has multiple types, a duration will be added for each
5041 /// type in the map.
5042 ///
5043 /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
5044 pub extra_visit_duration_for_visit_type:
5045 std::collections::HashMap<std::string::String, wkt::Duration>,
5046
5047 /// Describes the break schedule to be enforced on this vehicle.
5048 /// If empty, no breaks will be scheduled for this vehicle.
5049 pub break_rule: std::option::Option<crate::model::BreakRule>,
5050
5051 /// Specifies a label for this vehicle. This label is reported in the response
5052 /// as the `vehicle_label` of the corresponding
5053 /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
5054 ///
5055 /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
5056 pub label: std::string::String,
5057
5058 /// If true, `used_if_route_is_empty` must be false, and this vehicle will
5059 /// remain unused.
5060 ///
5061 /// If a shipment is performed by an ignored vehicle in
5062 /// `injected_first_solution_routes`, it is skipped in the first solution but
5063 /// is free to be performed in the response.
5064 ///
5065 /// If a shipment is performed by an ignored vehicle in
5066 /// `injected_solution_constraint` and any related pickup/delivery is
5067 /// constrained to remain on the vehicle (i.e., not relaxed to level
5068 /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
5069 /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
5070 /// the allowed vehicles are ignored, it is skipped in the response.
5071 pub ignore: bool,
5072
5073 /// Deprecated: No longer used.
5074 /// Indices in the `break_rule` field in the source
5075 /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
5076 /// correspond to break rules enforced on the vehicle.
5077 ///
5078 /// As of 2018/03, at most one rule index per vehicle can be specified.
5079 ///
5080 /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
5081 #[deprecated]
5082 pub break_rule_indices: std::vec::Vec<i32>,
5083
5084 /// Deprecated: Use
5085 /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
5086 /// instead.
5087 ///
5088 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5089 #[deprecated]
5090 pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
5091
5092 /// Deprecated: Use
5093 /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
5094 /// instead.
5095 ///
5096 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
5097 #[deprecated]
5098 pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5099
5100 /// Deprecated: Use
5101 /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
5102 /// instead.
5103 ///
5104 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
5105 #[deprecated]
5106 pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5107
5108 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5109}
5110
5111impl Vehicle {
5112 pub fn new() -> Self {
5113 std::default::Default::default()
5114 }
5115
5116 /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
5117 ///
5118 /// # Example
5119 /// ```ignore,no_run
5120 /// # use google_cloud_optimization_v1::model::Vehicle;
5121 /// use google_cloud_optimization_v1::model::vehicle::TravelMode;
5122 /// let x0 = Vehicle::new().set_travel_mode(TravelMode::Driving);
5123 /// let x1 = Vehicle::new().set_travel_mode(TravelMode::Walking);
5124 /// ```
5125 pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
5126 mut self,
5127 v: T,
5128 ) -> Self {
5129 self.travel_mode = v.into();
5130 self
5131 }
5132
5133 /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5134 ///
5135 /// # Example
5136 /// ```ignore,no_run
5137 /// # use google_cloud_optimization_v1::model::Vehicle;
5138 /// use google_cloud_optimization_v1::model::RouteModifiers;
5139 /// let x = Vehicle::new().set_route_modifiers(RouteModifiers::default()/* use setters */);
5140 /// ```
5141 pub fn set_route_modifiers<T>(mut self, v: T) -> Self
5142 where
5143 T: std::convert::Into<crate::model::RouteModifiers>,
5144 {
5145 self.route_modifiers = std::option::Option::Some(v.into());
5146 self
5147 }
5148
5149 /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5150 ///
5151 /// # Example
5152 /// ```ignore,no_run
5153 /// # use google_cloud_optimization_v1::model::Vehicle;
5154 /// use google_cloud_optimization_v1::model::RouteModifiers;
5155 /// let x = Vehicle::new().set_or_clear_route_modifiers(Some(RouteModifiers::default()/* use setters */));
5156 /// let x = Vehicle::new().set_or_clear_route_modifiers(None::<RouteModifiers>);
5157 /// ```
5158 pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
5159 where
5160 T: std::convert::Into<crate::model::RouteModifiers>,
5161 {
5162 self.route_modifiers = v.map(|x| x.into());
5163 self
5164 }
5165
5166 /// Sets the value of [start_location][crate::model::Vehicle::start_location].
5167 ///
5168 /// # Example
5169 /// ```ignore,no_run
5170 /// # use google_cloud_optimization_v1::model::Vehicle;
5171 /// use google_cloud_type::model::LatLng;
5172 /// let x = Vehicle::new().set_start_location(LatLng::default()/* use setters */);
5173 /// ```
5174 pub fn set_start_location<T>(mut self, v: T) -> Self
5175 where
5176 T: std::convert::Into<google_cloud_type::model::LatLng>,
5177 {
5178 self.start_location = std::option::Option::Some(v.into());
5179 self
5180 }
5181
5182 /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
5183 ///
5184 /// # Example
5185 /// ```ignore,no_run
5186 /// # use google_cloud_optimization_v1::model::Vehicle;
5187 /// use google_cloud_type::model::LatLng;
5188 /// let x = Vehicle::new().set_or_clear_start_location(Some(LatLng::default()/* use setters */));
5189 /// let x = Vehicle::new().set_or_clear_start_location(None::<LatLng>);
5190 /// ```
5191 pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
5192 where
5193 T: std::convert::Into<google_cloud_type::model::LatLng>,
5194 {
5195 self.start_location = v.map(|x| x.into());
5196 self
5197 }
5198
5199 /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5200 ///
5201 /// # Example
5202 /// ```ignore,no_run
5203 /// # use google_cloud_optimization_v1::model::Vehicle;
5204 /// use google_cloud_optimization_v1::model::Waypoint;
5205 /// let x = Vehicle::new().set_start_waypoint(Waypoint::default()/* use setters */);
5206 /// ```
5207 pub fn set_start_waypoint<T>(mut self, v: T) -> Self
5208 where
5209 T: std::convert::Into<crate::model::Waypoint>,
5210 {
5211 self.start_waypoint = std::option::Option::Some(v.into());
5212 self
5213 }
5214
5215 /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5216 ///
5217 /// # Example
5218 /// ```ignore,no_run
5219 /// # use google_cloud_optimization_v1::model::Vehicle;
5220 /// use google_cloud_optimization_v1::model::Waypoint;
5221 /// let x = Vehicle::new().set_or_clear_start_waypoint(Some(Waypoint::default()/* use setters */));
5222 /// let x = Vehicle::new().set_or_clear_start_waypoint(None::<Waypoint>);
5223 /// ```
5224 pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5225 where
5226 T: std::convert::Into<crate::model::Waypoint>,
5227 {
5228 self.start_waypoint = v.map(|x| x.into());
5229 self
5230 }
5231
5232 /// Sets the value of [end_location][crate::model::Vehicle::end_location].
5233 ///
5234 /// # Example
5235 /// ```ignore,no_run
5236 /// # use google_cloud_optimization_v1::model::Vehicle;
5237 /// use google_cloud_type::model::LatLng;
5238 /// let x = Vehicle::new().set_end_location(LatLng::default()/* use setters */);
5239 /// ```
5240 pub fn set_end_location<T>(mut self, v: T) -> Self
5241 where
5242 T: std::convert::Into<google_cloud_type::model::LatLng>,
5243 {
5244 self.end_location = std::option::Option::Some(v.into());
5245 self
5246 }
5247
5248 /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
5249 ///
5250 /// # Example
5251 /// ```ignore,no_run
5252 /// # use google_cloud_optimization_v1::model::Vehicle;
5253 /// use google_cloud_type::model::LatLng;
5254 /// let x = Vehicle::new().set_or_clear_end_location(Some(LatLng::default()/* use setters */));
5255 /// let x = Vehicle::new().set_or_clear_end_location(None::<LatLng>);
5256 /// ```
5257 pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
5258 where
5259 T: std::convert::Into<google_cloud_type::model::LatLng>,
5260 {
5261 self.end_location = v.map(|x| x.into());
5262 self
5263 }
5264
5265 /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5266 ///
5267 /// # Example
5268 /// ```ignore,no_run
5269 /// # use google_cloud_optimization_v1::model::Vehicle;
5270 /// use google_cloud_optimization_v1::model::Waypoint;
5271 /// let x = Vehicle::new().set_end_waypoint(Waypoint::default()/* use setters */);
5272 /// ```
5273 pub fn set_end_waypoint<T>(mut self, v: T) -> Self
5274 where
5275 T: std::convert::Into<crate::model::Waypoint>,
5276 {
5277 self.end_waypoint = std::option::Option::Some(v.into());
5278 self
5279 }
5280
5281 /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5282 ///
5283 /// # Example
5284 /// ```ignore,no_run
5285 /// # use google_cloud_optimization_v1::model::Vehicle;
5286 /// use google_cloud_optimization_v1::model::Waypoint;
5287 /// let x = Vehicle::new().set_or_clear_end_waypoint(Some(Waypoint::default()/* use setters */));
5288 /// let x = Vehicle::new().set_or_clear_end_waypoint(None::<Waypoint>);
5289 /// ```
5290 pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5291 where
5292 T: std::convert::Into<crate::model::Waypoint>,
5293 {
5294 self.end_waypoint = v.map(|x| x.into());
5295 self
5296 }
5297
5298 /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
5299 ///
5300 /// # Example
5301 /// ```ignore,no_run
5302 /// # use google_cloud_optimization_v1::model::Vehicle;
5303 /// let x = Vehicle::new().set_start_tags(["a", "b", "c"]);
5304 /// ```
5305 pub fn set_start_tags<T, V>(mut self, v: T) -> Self
5306 where
5307 T: std::iter::IntoIterator<Item = V>,
5308 V: std::convert::Into<std::string::String>,
5309 {
5310 use std::iter::Iterator;
5311 self.start_tags = v.into_iter().map(|i| i.into()).collect();
5312 self
5313 }
5314
5315 /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
5316 ///
5317 /// # Example
5318 /// ```ignore,no_run
5319 /// # use google_cloud_optimization_v1::model::Vehicle;
5320 /// let x = Vehicle::new().set_end_tags(["a", "b", "c"]);
5321 /// ```
5322 pub fn set_end_tags<T, V>(mut self, v: T) -> Self
5323 where
5324 T: std::iter::IntoIterator<Item = V>,
5325 V: std::convert::Into<std::string::String>,
5326 {
5327 use std::iter::Iterator;
5328 self.end_tags = v.into_iter().map(|i| i.into()).collect();
5329 self
5330 }
5331
5332 /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
5333 ///
5334 /// # Example
5335 /// ```ignore,no_run
5336 /// # use google_cloud_optimization_v1::model::Vehicle;
5337 /// use google_cloud_optimization_v1::model::TimeWindow;
5338 /// let x = Vehicle::new()
5339 /// .set_start_time_windows([
5340 /// TimeWindow::default()/* use setters */,
5341 /// TimeWindow::default()/* use (different) setters */,
5342 /// ]);
5343 /// ```
5344 pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
5345 where
5346 T: std::iter::IntoIterator<Item = V>,
5347 V: std::convert::Into<crate::model::TimeWindow>,
5348 {
5349 use std::iter::Iterator;
5350 self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
5351 self
5352 }
5353
5354 /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
5355 ///
5356 /// # Example
5357 /// ```ignore,no_run
5358 /// # use google_cloud_optimization_v1::model::Vehicle;
5359 /// use google_cloud_optimization_v1::model::TimeWindow;
5360 /// let x = Vehicle::new()
5361 /// .set_end_time_windows([
5362 /// TimeWindow::default()/* use setters */,
5363 /// TimeWindow::default()/* use (different) setters */,
5364 /// ]);
5365 /// ```
5366 pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
5367 where
5368 T: std::iter::IntoIterator<Item = V>,
5369 V: std::convert::Into<crate::model::TimeWindow>,
5370 {
5371 use std::iter::Iterator;
5372 self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
5373 self
5374 }
5375
5376 /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5377 ///
5378 /// # Example
5379 /// ```ignore,no_run
5380 /// # use google_cloud_optimization_v1::model::Vehicle;
5381 /// let x = Vehicle::new().set_travel_duration_multiple(42.0);
5382 /// ```
5383 pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
5384 where
5385 T: std::convert::Into<f64>,
5386 {
5387 self.travel_duration_multiple = std::option::Option::Some(v.into());
5388 self
5389 }
5390
5391 /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5392 ///
5393 /// # Example
5394 /// ```ignore,no_run
5395 /// # use google_cloud_optimization_v1::model::Vehicle;
5396 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(Some(42.0));
5397 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(None::<f32>);
5398 /// ```
5399 pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
5400 where
5401 T: std::convert::Into<f64>,
5402 {
5403 self.travel_duration_multiple = v.map(|x| x.into());
5404 self
5405 }
5406
5407 /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
5408 ///
5409 /// # Example
5410 /// ```ignore,no_run
5411 /// # use google_cloud_optimization_v1::model::Vehicle;
5412 /// use google_cloud_optimization_v1::model::vehicle::UnloadingPolicy;
5413 /// let x0 = Vehicle::new().set_unloading_policy(UnloadingPolicy::LastInFirstOut);
5414 /// let x1 = Vehicle::new().set_unloading_policy(UnloadingPolicy::FirstInFirstOut);
5415 /// ```
5416 pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
5417 mut self,
5418 v: T,
5419 ) -> Self {
5420 self.unloading_policy = v.into();
5421 self
5422 }
5423
5424 /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
5425 ///
5426 /// # Example
5427 /// ```ignore,no_run
5428 /// # use google_cloud_optimization_v1::model::Vehicle;
5429 /// use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5430 /// let x = Vehicle::new().set_load_limits([
5431 /// ("key0", LoadLimit::default()/* use setters */),
5432 /// ("key1", LoadLimit::default()/* use (different) setters */),
5433 /// ]);
5434 /// ```
5435 pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
5436 where
5437 T: std::iter::IntoIterator<Item = (K, V)>,
5438 K: std::convert::Into<std::string::String>,
5439 V: std::convert::Into<crate::model::vehicle::LoadLimit>,
5440 {
5441 use std::iter::Iterator;
5442 self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5443 self
5444 }
5445
5446 /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
5447 ///
5448 /// # Example
5449 /// ```ignore,no_run
5450 /// # use google_cloud_optimization_v1::model::Vehicle;
5451 /// let x = Vehicle::new().set_cost_per_hour(42.0);
5452 /// ```
5453 pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5454 self.cost_per_hour = v.into();
5455 self
5456 }
5457
5458 /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
5459 ///
5460 /// # Example
5461 /// ```ignore,no_run
5462 /// # use google_cloud_optimization_v1::model::Vehicle;
5463 /// let x = Vehicle::new().set_cost_per_traveled_hour(42.0);
5464 /// ```
5465 pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5466 self.cost_per_traveled_hour = v.into();
5467 self
5468 }
5469
5470 /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
5471 ///
5472 /// # Example
5473 /// ```ignore,no_run
5474 /// # use google_cloud_optimization_v1::model::Vehicle;
5475 /// let x = Vehicle::new().set_cost_per_kilometer(42.0);
5476 /// ```
5477 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5478 self.cost_per_kilometer = v.into();
5479 self
5480 }
5481
5482 /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
5483 ///
5484 /// # Example
5485 /// ```ignore,no_run
5486 /// # use google_cloud_optimization_v1::model::Vehicle;
5487 /// let x = Vehicle::new().set_fixed_cost(42.0);
5488 /// ```
5489 pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5490 self.fixed_cost = v.into();
5491 self
5492 }
5493
5494 /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
5495 ///
5496 /// # Example
5497 /// ```ignore,no_run
5498 /// # use google_cloud_optimization_v1::model::Vehicle;
5499 /// let x = Vehicle::new().set_used_if_route_is_empty(true);
5500 /// ```
5501 pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5502 self.used_if_route_is_empty = v.into();
5503 self
5504 }
5505
5506 /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5507 ///
5508 /// # Example
5509 /// ```ignore,no_run
5510 /// # use google_cloud_optimization_v1::model::Vehicle;
5511 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5512 /// let x = Vehicle::new().set_route_duration_limit(DurationLimit::default()/* use setters */);
5513 /// ```
5514 pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
5515 where
5516 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5517 {
5518 self.route_duration_limit = std::option::Option::Some(v.into());
5519 self
5520 }
5521
5522 /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5523 ///
5524 /// # Example
5525 /// ```ignore,no_run
5526 /// # use google_cloud_optimization_v1::model::Vehicle;
5527 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5528 /// let x = Vehicle::new().set_or_clear_route_duration_limit(Some(DurationLimit::default()/* use setters */));
5529 /// let x = Vehicle::new().set_or_clear_route_duration_limit(None::<DurationLimit>);
5530 /// ```
5531 pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5532 where
5533 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5534 {
5535 self.route_duration_limit = v.map(|x| x.into());
5536 self
5537 }
5538
5539 /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5540 ///
5541 /// # Example
5542 /// ```ignore,no_run
5543 /// # use google_cloud_optimization_v1::model::Vehicle;
5544 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5545 /// let x = Vehicle::new().set_travel_duration_limit(DurationLimit::default()/* use setters */);
5546 /// ```
5547 pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
5548 where
5549 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5550 {
5551 self.travel_duration_limit = std::option::Option::Some(v.into());
5552 self
5553 }
5554
5555 /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5556 ///
5557 /// # Example
5558 /// ```ignore,no_run
5559 /// # use google_cloud_optimization_v1::model::Vehicle;
5560 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5561 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(Some(DurationLimit::default()/* use setters */));
5562 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(None::<DurationLimit>);
5563 /// ```
5564 pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5565 where
5566 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5567 {
5568 self.travel_duration_limit = v.map(|x| x.into());
5569 self
5570 }
5571
5572 /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5573 ///
5574 /// # Example
5575 /// ```ignore,no_run
5576 /// # use google_cloud_optimization_v1::model::Vehicle;
5577 /// use google_cloud_optimization_v1::model::DistanceLimit;
5578 /// let x = Vehicle::new().set_route_distance_limit(DistanceLimit::default()/* use setters */);
5579 /// ```
5580 pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
5581 where
5582 T: std::convert::Into<crate::model::DistanceLimit>,
5583 {
5584 self.route_distance_limit = std::option::Option::Some(v.into());
5585 self
5586 }
5587
5588 /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5589 ///
5590 /// # Example
5591 /// ```ignore,no_run
5592 /// # use google_cloud_optimization_v1::model::Vehicle;
5593 /// use google_cloud_optimization_v1::model::DistanceLimit;
5594 /// let x = Vehicle::new().set_or_clear_route_distance_limit(Some(DistanceLimit::default()/* use setters */));
5595 /// let x = Vehicle::new().set_or_clear_route_distance_limit(None::<DistanceLimit>);
5596 /// ```
5597 pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
5598 where
5599 T: std::convert::Into<crate::model::DistanceLimit>,
5600 {
5601 self.route_distance_limit = v.map(|x| x.into());
5602 self
5603 }
5604
5605 /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
5606 ///
5607 /// # Example
5608 /// ```ignore,no_run
5609 /// # use google_cloud_optimization_v1::model::Vehicle;
5610 /// use wkt::Duration;
5611 /// let x = Vehicle::new().set_extra_visit_duration_for_visit_type([
5612 /// ("key0", Duration::default()/* use setters */),
5613 /// ("key1", Duration::default()/* use (different) setters */),
5614 /// ]);
5615 /// ```
5616 pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
5617 where
5618 T: std::iter::IntoIterator<Item = (K, V)>,
5619 K: std::convert::Into<std::string::String>,
5620 V: std::convert::Into<wkt::Duration>,
5621 {
5622 use std::iter::Iterator;
5623 self.extra_visit_duration_for_visit_type =
5624 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5625 self
5626 }
5627
5628 /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
5629 ///
5630 /// # Example
5631 /// ```ignore,no_run
5632 /// # use google_cloud_optimization_v1::model::Vehicle;
5633 /// use google_cloud_optimization_v1::model::BreakRule;
5634 /// let x = Vehicle::new().set_break_rule(BreakRule::default()/* use setters */);
5635 /// ```
5636 pub fn set_break_rule<T>(mut self, v: T) -> Self
5637 where
5638 T: std::convert::Into<crate::model::BreakRule>,
5639 {
5640 self.break_rule = std::option::Option::Some(v.into());
5641 self
5642 }
5643
5644 /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
5645 ///
5646 /// # Example
5647 /// ```ignore,no_run
5648 /// # use google_cloud_optimization_v1::model::Vehicle;
5649 /// use google_cloud_optimization_v1::model::BreakRule;
5650 /// let x = Vehicle::new().set_or_clear_break_rule(Some(BreakRule::default()/* use setters */));
5651 /// let x = Vehicle::new().set_or_clear_break_rule(None::<BreakRule>);
5652 /// ```
5653 pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
5654 where
5655 T: std::convert::Into<crate::model::BreakRule>,
5656 {
5657 self.break_rule = v.map(|x| x.into());
5658 self
5659 }
5660
5661 /// Sets the value of [label][crate::model::Vehicle::label].
5662 ///
5663 /// # Example
5664 /// ```ignore,no_run
5665 /// # use google_cloud_optimization_v1::model::Vehicle;
5666 /// let x = Vehicle::new().set_label("example");
5667 /// ```
5668 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5669 self.label = v.into();
5670 self
5671 }
5672
5673 /// Sets the value of [ignore][crate::model::Vehicle::ignore].
5674 ///
5675 /// # Example
5676 /// ```ignore,no_run
5677 /// # use google_cloud_optimization_v1::model::Vehicle;
5678 /// let x = Vehicle::new().set_ignore(true);
5679 /// ```
5680 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5681 self.ignore = v.into();
5682 self
5683 }
5684
5685 /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
5686 ///
5687 /// # Example
5688 /// ```ignore,no_run
5689 /// # use google_cloud_optimization_v1::model::Vehicle;
5690 /// let x = Vehicle::new().set_break_rule_indices([1, 2, 3]);
5691 /// ```
5692 #[deprecated]
5693 pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
5694 where
5695 T: std::iter::IntoIterator<Item = V>,
5696 V: std::convert::Into<i32>,
5697 {
5698 use std::iter::Iterator;
5699 self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
5700 self
5701 }
5702
5703 /// Sets the value of [capacities][crate::model::Vehicle::capacities].
5704 ///
5705 /// # Example
5706 /// ```ignore,no_run
5707 /// # use google_cloud_optimization_v1::model::Vehicle;
5708 /// use google_cloud_optimization_v1::model::CapacityQuantity;
5709 /// let x = Vehicle::new()
5710 /// .set_capacities([
5711 /// CapacityQuantity::default()/* use setters */,
5712 /// CapacityQuantity::default()/* use (different) setters */,
5713 /// ]);
5714 /// ```
5715 #[deprecated]
5716 pub fn set_capacities<T, V>(mut self, v: T) -> Self
5717 where
5718 T: std::iter::IntoIterator<Item = V>,
5719 V: std::convert::Into<crate::model::CapacityQuantity>,
5720 {
5721 use std::iter::Iterator;
5722 self.capacities = v.into_iter().map(|i| i.into()).collect();
5723 self
5724 }
5725
5726 /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
5727 ///
5728 /// # Example
5729 /// ```ignore,no_run
5730 /// # use google_cloud_optimization_v1::model::Vehicle;
5731 /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5732 /// let x = Vehicle::new()
5733 /// .set_start_load_intervals([
5734 /// CapacityQuantityInterval::default()/* use setters */,
5735 /// CapacityQuantityInterval::default()/* use (different) setters */,
5736 /// ]);
5737 /// ```
5738 #[deprecated]
5739 pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
5740 where
5741 T: std::iter::IntoIterator<Item = V>,
5742 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5743 {
5744 use std::iter::Iterator;
5745 self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
5746 self
5747 }
5748
5749 /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
5750 ///
5751 /// # Example
5752 /// ```ignore,no_run
5753 /// # use google_cloud_optimization_v1::model::Vehicle;
5754 /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5755 /// let x = Vehicle::new()
5756 /// .set_end_load_intervals([
5757 /// CapacityQuantityInterval::default()/* use setters */,
5758 /// CapacityQuantityInterval::default()/* use (different) setters */,
5759 /// ]);
5760 /// ```
5761 #[deprecated]
5762 pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
5763 where
5764 T: std::iter::IntoIterator<Item = V>,
5765 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5766 {
5767 use std::iter::Iterator;
5768 self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
5769 self
5770 }
5771}
5772
5773impl wkt::message::Message for Vehicle {
5774 fn typename() -> &'static str {
5775 "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
5776 }
5777}
5778
5779/// Defines additional types related to [Vehicle].
5780pub mod vehicle {
5781 #[allow(unused_imports)]
5782 use super::*;
5783
5784 /// Defines a load limit applying to a vehicle, e.g. "this truck may only
5785 /// carry up to 3500 kg". See
5786 /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
5787 ///
5788 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5789 #[derive(Clone, Default, PartialEq)]
5790 #[non_exhaustive]
5791 pub struct LoadLimit {
5792 /// The maximum acceptable amount of load.
5793 pub max_load: std::option::Option<i64>,
5794
5795 /// A soft limit of the load. See
5796 /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
5797 ///
5798 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5799 pub soft_max_load: i64,
5800
5801 /// If the load ever exceeds
5802 /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
5803 /// along this vehicle's route, the following cost penalty applies (only once
5804 /// per vehicle): (load -
5805 /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
5806 ///
5807 /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
5808 /// add up and must be in the same unit as
5809 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
5810 ///
5811 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
5812 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5813 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
5814 pub cost_per_unit_above_soft_max: f64,
5815
5816 /// The acceptable load interval of the vehicle at the start of the route.
5817 pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5818
5819 /// The acceptable load interval of the vehicle at the end of the route.
5820 pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5821
5822 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5823 }
5824
5825 impl LoadLimit {
5826 pub fn new() -> Self {
5827 std::default::Default::default()
5828 }
5829
5830 /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5831 ///
5832 /// # Example
5833 /// ```ignore,no_run
5834 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5835 /// let x = LoadLimit::new().set_max_load(42);
5836 /// ```
5837 pub fn set_max_load<T>(mut self, v: T) -> Self
5838 where
5839 T: std::convert::Into<i64>,
5840 {
5841 self.max_load = std::option::Option::Some(v.into());
5842 self
5843 }
5844
5845 /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5846 ///
5847 /// # Example
5848 /// ```ignore,no_run
5849 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5850 /// let x = LoadLimit::new().set_or_clear_max_load(Some(42));
5851 /// let x = LoadLimit::new().set_or_clear_max_load(None::<i32>);
5852 /// ```
5853 pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
5854 where
5855 T: std::convert::Into<i64>,
5856 {
5857 self.max_load = v.map(|x| x.into());
5858 self
5859 }
5860
5861 /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
5862 ///
5863 /// # Example
5864 /// ```ignore,no_run
5865 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5866 /// let x = LoadLimit::new().set_soft_max_load(42);
5867 /// ```
5868 pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5869 self.soft_max_load = v.into();
5870 self
5871 }
5872
5873 /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
5874 ///
5875 /// # Example
5876 /// ```ignore,no_run
5877 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5878 /// let x = LoadLimit::new().set_cost_per_unit_above_soft_max(42.0);
5879 /// ```
5880 pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
5881 mut self,
5882 v: T,
5883 ) -> Self {
5884 self.cost_per_unit_above_soft_max = v.into();
5885 self
5886 }
5887
5888 /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5889 ///
5890 /// # Example
5891 /// ```ignore,no_run
5892 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5893 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5894 /// let x = LoadLimit::new().set_start_load_interval(Interval::default()/* use setters */);
5895 /// ```
5896 pub fn set_start_load_interval<T>(mut self, v: T) -> Self
5897 where
5898 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5899 {
5900 self.start_load_interval = std::option::Option::Some(v.into());
5901 self
5902 }
5903
5904 /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5905 ///
5906 /// # Example
5907 /// ```ignore,no_run
5908 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5909 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5910 /// let x = LoadLimit::new().set_or_clear_start_load_interval(Some(Interval::default()/* use setters */));
5911 /// let x = LoadLimit::new().set_or_clear_start_load_interval(None::<Interval>);
5912 /// ```
5913 pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5914 where
5915 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5916 {
5917 self.start_load_interval = v.map(|x| x.into());
5918 self
5919 }
5920
5921 /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5922 ///
5923 /// # Example
5924 /// ```ignore,no_run
5925 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5926 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5927 /// let x = LoadLimit::new().set_end_load_interval(Interval::default()/* use setters */);
5928 /// ```
5929 pub fn set_end_load_interval<T>(mut self, v: T) -> Self
5930 where
5931 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5932 {
5933 self.end_load_interval = std::option::Option::Some(v.into());
5934 self
5935 }
5936
5937 /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5938 ///
5939 /// # Example
5940 /// ```ignore,no_run
5941 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5942 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5943 /// let x = LoadLimit::new().set_or_clear_end_load_interval(Some(Interval::default()/* use setters */));
5944 /// let x = LoadLimit::new().set_or_clear_end_load_interval(None::<Interval>);
5945 /// ```
5946 pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5947 where
5948 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5949 {
5950 self.end_load_interval = v.map(|x| x.into());
5951 self
5952 }
5953 }
5954
5955 impl wkt::message::Message for LoadLimit {
5956 fn typename() -> &'static str {
5957 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
5958 }
5959 }
5960
5961 /// Defines additional types related to [LoadLimit].
5962 pub mod load_limit {
5963 #[allow(unused_imports)]
5964 use super::*;
5965
5966 /// Interval of acceptable load amounts.
5967 #[derive(Clone, Default, PartialEq)]
5968 #[non_exhaustive]
5969 pub struct Interval {
5970 /// A minimum acceptable load. Must be ≥ 0.
5971 /// If they're both specified,
5972 /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
5973 /// be ≤
5974 /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
5975 ///
5976 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
5977 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
5978 pub min: i64,
5979
5980 /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
5981 /// load is unrestricted by this message.
5982 /// If they're both specified,
5983 /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
5984 /// be ≤
5985 /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
5986 ///
5987 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
5988 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
5989 pub max: std::option::Option<i64>,
5990
5991 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5992 }
5993
5994 impl Interval {
5995 pub fn new() -> Self {
5996 std::default::Default::default()
5997 }
5998
5999 /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
6000 ///
6001 /// # Example
6002 /// ```ignore,no_run
6003 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6004 /// let x = Interval::new().set_min(42);
6005 /// ```
6006 pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6007 self.min = v.into();
6008 self
6009 }
6010
6011 /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
6012 ///
6013 /// # Example
6014 /// ```ignore,no_run
6015 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6016 /// let x = Interval::new().set_max(42);
6017 /// ```
6018 pub fn set_max<T>(mut self, v: T) -> Self
6019 where
6020 T: std::convert::Into<i64>,
6021 {
6022 self.max = std::option::Option::Some(v.into());
6023 self
6024 }
6025
6026 /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
6027 ///
6028 /// # Example
6029 /// ```ignore,no_run
6030 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6031 /// let x = Interval::new().set_or_clear_max(Some(42));
6032 /// let x = Interval::new().set_or_clear_max(None::<i32>);
6033 /// ```
6034 pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
6035 where
6036 T: std::convert::Into<i64>,
6037 {
6038 self.max = v.map(|x| x.into());
6039 self
6040 }
6041 }
6042
6043 impl wkt::message::Message for Interval {
6044 fn typename() -> &'static str {
6045 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
6046 }
6047 }
6048 }
6049
6050 /// A limit defining a maximum duration of the route of a vehicle. It can be
6051 /// either hard or soft.
6052 ///
6053 /// When a soft limit field is defined, both the soft max threshold and its
6054 /// associated cost must be defined together.
6055 #[derive(Clone, Default, PartialEq)]
6056 #[non_exhaustive]
6057 pub struct DurationLimit {
6058 /// A hard limit constraining the duration to be at most max_duration.
6059 pub max_duration: std::option::Option<wkt::Duration>,
6060
6061 /// A soft limit not enforcing a maximum duration limit, but when violated
6062 /// makes the route incur a cost. This cost adds up to other costs defined in
6063 /// the model, with the same unit.
6064 ///
6065 /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
6066 /// also defined, `soft_max_duration` must be less than max_duration.
6067 pub soft_max_duration: std::option::Option<wkt::Duration>,
6068
6069 /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
6070 /// The additional cost is 0 if the duration is under the threshold,
6071 /// otherwise the cost depends on the duration as follows:
6072 ///
6073 /// ```norust
6074 /// cost_per_hour_after_soft_max * (duration - soft_max_duration)
6075 /// ```
6076 ///
6077 /// The cost must be nonnegative.
6078 pub cost_per_hour_after_soft_max: std::option::Option<f64>,
6079
6080 /// A soft limit not enforcing a maximum duration limit, but when violated
6081 /// makes the route incur a cost, quadratic in the duration. This cost adds
6082 /// up to other costs defined in the model, with the same unit.
6083 ///
6084 /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
6085 /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
6086 /// less than `max_duration`, and the difference must be no larger than one
6087 /// day:
6088 ///
6089 /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
6090 pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
6091
6092 /// Cost per square hour incurred if the
6093 /// `quadratic_soft_max_duration` threshold is violated.
6094 ///
6095 /// The additional cost is 0 if the duration is under the threshold,
6096 /// otherwise the cost depends on the duration as follows:
6097 ///
6098 /// ```norust
6099 /// cost_per_square_hour_after_quadratic_soft_max *
6100 /// (duration - quadratic_soft_max_duration)^2
6101 /// ```
6102 ///
6103 /// The cost must be nonnegative.
6104 pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
6105
6106 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6107 }
6108
6109 impl DurationLimit {
6110 pub fn new() -> Self {
6111 std::default::Default::default()
6112 }
6113
6114 /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6115 ///
6116 /// # Example
6117 /// ```ignore,no_run
6118 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6119 /// use wkt::Duration;
6120 /// let x = DurationLimit::new().set_max_duration(Duration::default()/* use setters */);
6121 /// ```
6122 pub fn set_max_duration<T>(mut self, v: T) -> Self
6123 where
6124 T: std::convert::Into<wkt::Duration>,
6125 {
6126 self.max_duration = std::option::Option::Some(v.into());
6127 self
6128 }
6129
6130 /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6131 ///
6132 /// # Example
6133 /// ```ignore,no_run
6134 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6135 /// use wkt::Duration;
6136 /// let x = DurationLimit::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
6137 /// let x = DurationLimit::new().set_or_clear_max_duration(None::<Duration>);
6138 /// ```
6139 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6140 where
6141 T: std::convert::Into<wkt::Duration>,
6142 {
6143 self.max_duration = v.map(|x| x.into());
6144 self
6145 }
6146
6147 /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6148 ///
6149 /// # Example
6150 /// ```ignore,no_run
6151 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6152 /// use wkt::Duration;
6153 /// let x = DurationLimit::new().set_soft_max_duration(Duration::default()/* use setters */);
6154 /// ```
6155 pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
6156 where
6157 T: std::convert::Into<wkt::Duration>,
6158 {
6159 self.soft_max_duration = std::option::Option::Some(v.into());
6160 self
6161 }
6162
6163 /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6164 ///
6165 /// # Example
6166 /// ```ignore,no_run
6167 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6168 /// use wkt::Duration;
6169 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(Some(Duration::default()/* use setters */));
6170 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(None::<Duration>);
6171 /// ```
6172 pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6173 where
6174 T: std::convert::Into<wkt::Duration>,
6175 {
6176 self.soft_max_duration = v.map(|x| x.into());
6177 self
6178 }
6179
6180 /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6181 ///
6182 /// # Example
6183 /// ```ignore,no_run
6184 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6185 /// let x = DurationLimit::new().set_cost_per_hour_after_soft_max(42.0);
6186 /// ```
6187 pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
6188 where
6189 T: std::convert::Into<f64>,
6190 {
6191 self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
6192 self
6193 }
6194
6195 /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6196 ///
6197 /// # Example
6198 /// ```ignore,no_run
6199 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6200 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(Some(42.0));
6201 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(None::<f32>);
6202 /// ```
6203 pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
6204 mut self,
6205 v: std::option::Option<T>,
6206 ) -> Self
6207 where
6208 T: std::convert::Into<f64>,
6209 {
6210 self.cost_per_hour_after_soft_max = v.map(|x| x.into());
6211 self
6212 }
6213
6214 /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6215 ///
6216 /// # Example
6217 /// ```ignore,no_run
6218 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6219 /// use wkt::Duration;
6220 /// let x = DurationLimit::new().set_quadratic_soft_max_duration(Duration::default()/* use setters */);
6221 /// ```
6222 pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
6223 where
6224 T: std::convert::Into<wkt::Duration>,
6225 {
6226 self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
6227 self
6228 }
6229
6230 /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6231 ///
6232 /// # Example
6233 /// ```ignore,no_run
6234 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6235 /// use wkt::Duration;
6236 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(Some(Duration::default()/* use setters */));
6237 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(None::<Duration>);
6238 /// ```
6239 pub fn set_or_clear_quadratic_soft_max_duration<T>(
6240 mut self,
6241 v: std::option::Option<T>,
6242 ) -> Self
6243 where
6244 T: std::convert::Into<wkt::Duration>,
6245 {
6246 self.quadratic_soft_max_duration = v.map(|x| x.into());
6247 self
6248 }
6249
6250 /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6251 ///
6252 /// # Example
6253 /// ```ignore,no_run
6254 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6255 /// let x = DurationLimit::new().set_cost_per_square_hour_after_quadratic_soft_max(42.0);
6256 /// ```
6257 pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
6258 where
6259 T: std::convert::Into<f64>,
6260 {
6261 self.cost_per_square_hour_after_quadratic_soft_max =
6262 std::option::Option::Some(v.into());
6263 self
6264 }
6265
6266 /// Sets or clears the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6267 ///
6268 /// # Example
6269 /// ```ignore,no_run
6270 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6271 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(Some(42.0));
6272 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(None::<f32>);
6273 /// ```
6274 pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
6275 mut self,
6276 v: std::option::Option<T>,
6277 ) -> Self
6278 where
6279 T: std::convert::Into<f64>,
6280 {
6281 self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
6282 self
6283 }
6284 }
6285
6286 impl wkt::message::Message for DurationLimit {
6287 fn typename() -> &'static str {
6288 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
6289 }
6290 }
6291
6292 /// Travel modes which can be used by vehicles.
6293 ///
6294 /// These should be a subset of the Google Maps Platform Routes Preferred API
6295 /// travel modes, see:
6296 /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
6297 ///
6298 /// # Working with unknown values
6299 ///
6300 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6301 /// additional enum variants at any time. Adding new variants is not considered
6302 /// a breaking change. Applications should write their code in anticipation of:
6303 ///
6304 /// - New values appearing in future releases of the client library, **and**
6305 /// - New values received dynamically, without application changes.
6306 ///
6307 /// Please consult the [Working with enums] section in the user guide for some
6308 /// guidelines.
6309 ///
6310 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
6311 #[derive(Clone, Debug, PartialEq)]
6312 #[non_exhaustive]
6313 pub enum TravelMode {
6314 /// Unspecified travel mode, equivalent to `DRIVING`.
6315 Unspecified,
6316 /// Travel mode corresponding to driving directions (car, ...).
6317 Driving,
6318 /// Travel mode corresponding to walking directions.
6319 Walking,
6320 /// If set, the enum was initialized with an unknown value.
6321 ///
6322 /// Applications can examine the value using [TravelMode::value] or
6323 /// [TravelMode::name].
6324 UnknownValue(travel_mode::UnknownValue),
6325 }
6326
6327 #[doc(hidden)]
6328 pub mod travel_mode {
6329 #[allow(unused_imports)]
6330 use super::*;
6331 #[derive(Clone, Debug, PartialEq)]
6332 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6333 }
6334
6335 impl TravelMode {
6336 /// Gets the enum value.
6337 ///
6338 /// Returns `None` if the enum contains an unknown value deserialized from
6339 /// the string representation of enums.
6340 pub fn value(&self) -> std::option::Option<i32> {
6341 match self {
6342 Self::Unspecified => std::option::Option::Some(0),
6343 Self::Driving => std::option::Option::Some(1),
6344 Self::Walking => std::option::Option::Some(2),
6345 Self::UnknownValue(u) => u.0.value(),
6346 }
6347 }
6348
6349 /// Gets the enum value as a string.
6350 ///
6351 /// Returns `None` if the enum contains an unknown value deserialized from
6352 /// the integer representation of enums.
6353 pub fn name(&self) -> std::option::Option<&str> {
6354 match self {
6355 Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
6356 Self::Driving => std::option::Option::Some("DRIVING"),
6357 Self::Walking => std::option::Option::Some("WALKING"),
6358 Self::UnknownValue(u) => u.0.name(),
6359 }
6360 }
6361 }
6362
6363 impl std::default::Default for TravelMode {
6364 fn default() -> Self {
6365 use std::convert::From;
6366 Self::from(0)
6367 }
6368 }
6369
6370 impl std::fmt::Display for TravelMode {
6371 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6372 wkt::internal::display_enum(f, self.name(), self.value())
6373 }
6374 }
6375
6376 impl std::convert::From<i32> for TravelMode {
6377 fn from(value: i32) -> Self {
6378 match value {
6379 0 => Self::Unspecified,
6380 1 => Self::Driving,
6381 2 => Self::Walking,
6382 _ => Self::UnknownValue(travel_mode::UnknownValue(
6383 wkt::internal::UnknownEnumValue::Integer(value),
6384 )),
6385 }
6386 }
6387 }
6388
6389 impl std::convert::From<&str> for TravelMode {
6390 fn from(value: &str) -> Self {
6391 use std::string::ToString;
6392 match value {
6393 "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
6394 "DRIVING" => Self::Driving,
6395 "WALKING" => Self::Walking,
6396 _ => Self::UnknownValue(travel_mode::UnknownValue(
6397 wkt::internal::UnknownEnumValue::String(value.to_string()),
6398 )),
6399 }
6400 }
6401 }
6402
6403 impl serde::ser::Serialize for TravelMode {
6404 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6405 where
6406 S: serde::Serializer,
6407 {
6408 match self {
6409 Self::Unspecified => serializer.serialize_i32(0),
6410 Self::Driving => serializer.serialize_i32(1),
6411 Self::Walking => serializer.serialize_i32(2),
6412 Self::UnknownValue(u) => u.0.serialize(serializer),
6413 }
6414 }
6415 }
6416
6417 impl<'de> serde::de::Deserialize<'de> for TravelMode {
6418 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6419 where
6420 D: serde::Deserializer<'de>,
6421 {
6422 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
6423 ".google.cloud.optimization.v1.Vehicle.TravelMode",
6424 ))
6425 }
6426 }
6427
6428 /// Policy on how a vehicle can be unloaded. Applies only to shipments having
6429 /// both a pickup and a delivery.
6430 ///
6431 /// Other shipments are free to occur anywhere on the route independent of
6432 /// `unloading_policy`.
6433 ///
6434 /// # Working with unknown values
6435 ///
6436 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6437 /// additional enum variants at any time. Adding new variants is not considered
6438 /// a breaking change. Applications should write their code in anticipation of:
6439 ///
6440 /// - New values appearing in future releases of the client library, **and**
6441 /// - New values received dynamically, without application changes.
6442 ///
6443 /// Please consult the [Working with enums] section in the user guide for some
6444 /// guidelines.
6445 ///
6446 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
6447 #[derive(Clone, Debug, PartialEq)]
6448 #[non_exhaustive]
6449 pub enum UnloadingPolicy {
6450 /// Unspecified unloading policy; deliveries must just occur after their
6451 /// corresponding pickups.
6452 Unspecified,
6453 /// Deliveries must occur in reverse order of pickups
6454 LastInFirstOut,
6455 /// Deliveries must occur in the same order as pickups
6456 FirstInFirstOut,
6457 /// If set, the enum was initialized with an unknown value.
6458 ///
6459 /// Applications can examine the value using [UnloadingPolicy::value] or
6460 /// [UnloadingPolicy::name].
6461 UnknownValue(unloading_policy::UnknownValue),
6462 }
6463
6464 #[doc(hidden)]
6465 pub mod unloading_policy {
6466 #[allow(unused_imports)]
6467 use super::*;
6468 #[derive(Clone, Debug, PartialEq)]
6469 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6470 }
6471
6472 impl UnloadingPolicy {
6473 /// Gets the enum value.
6474 ///
6475 /// Returns `None` if the enum contains an unknown value deserialized from
6476 /// the string representation of enums.
6477 pub fn value(&self) -> std::option::Option<i32> {
6478 match self {
6479 Self::Unspecified => std::option::Option::Some(0),
6480 Self::LastInFirstOut => std::option::Option::Some(1),
6481 Self::FirstInFirstOut => std::option::Option::Some(2),
6482 Self::UnknownValue(u) => u.0.value(),
6483 }
6484 }
6485
6486 /// Gets the enum value as a string.
6487 ///
6488 /// Returns `None` if the enum contains an unknown value deserialized from
6489 /// the integer representation of enums.
6490 pub fn name(&self) -> std::option::Option<&str> {
6491 match self {
6492 Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
6493 Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
6494 Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
6495 Self::UnknownValue(u) => u.0.name(),
6496 }
6497 }
6498 }
6499
6500 impl std::default::Default for UnloadingPolicy {
6501 fn default() -> Self {
6502 use std::convert::From;
6503 Self::from(0)
6504 }
6505 }
6506
6507 impl std::fmt::Display for UnloadingPolicy {
6508 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6509 wkt::internal::display_enum(f, self.name(), self.value())
6510 }
6511 }
6512
6513 impl std::convert::From<i32> for UnloadingPolicy {
6514 fn from(value: i32) -> Self {
6515 match value {
6516 0 => Self::Unspecified,
6517 1 => Self::LastInFirstOut,
6518 2 => Self::FirstInFirstOut,
6519 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6520 wkt::internal::UnknownEnumValue::Integer(value),
6521 )),
6522 }
6523 }
6524 }
6525
6526 impl std::convert::From<&str> for UnloadingPolicy {
6527 fn from(value: &str) -> Self {
6528 use std::string::ToString;
6529 match value {
6530 "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
6531 "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
6532 "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
6533 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6534 wkt::internal::UnknownEnumValue::String(value.to_string()),
6535 )),
6536 }
6537 }
6538 }
6539
6540 impl serde::ser::Serialize for UnloadingPolicy {
6541 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6542 where
6543 S: serde::Serializer,
6544 {
6545 match self {
6546 Self::Unspecified => serializer.serialize_i32(0),
6547 Self::LastInFirstOut => serializer.serialize_i32(1),
6548 Self::FirstInFirstOut => serializer.serialize_i32(2),
6549 Self::UnknownValue(u) => u.0.serialize(serializer),
6550 }
6551 }
6552 }
6553
6554 impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
6555 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6556 where
6557 D: serde::Deserializer<'de>,
6558 {
6559 deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
6560 ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
6561 ))
6562 }
6563 }
6564}
6565
6566/// Time windows constrain the time of an event, such as the arrival time at a
6567/// visit, or the start and end time of a vehicle.
6568///
6569/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
6570/// and latest time of the event, such that `start_time <= event_time <=
6571/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
6572/// preference for the event to happen at or after `soft_start_time` by incurring
6573/// a cost proportional to how long before soft_start_time the event occurs. The
6574/// soft time window upper bound, `soft_end_time`, expresses a preference for the
6575/// event to happen at or before `soft_end_time` by incurring a cost proportional
6576/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
6577/// `soft_start_time` and `soft_end_time` should be within the global time limits
6578/// (see
6579/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
6580/// and
6581/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
6582/// and should respect:
6583///
6584/// ```norust
6585/// 0 <= `start_time` <= `soft_start_time` <= `end_time` and
6586/// 0 <= `start_time` <= `soft_end_time` <= `end_time`.
6587/// ```
6588///
6589/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
6590/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
6591#[derive(Clone, Default, PartialEq)]
6592#[non_exhaustive]
6593pub struct TimeWindow {
6594 /// The hard time window start time. If unspecified it will be set to
6595 /// `ShipmentModel.global_start_time`.
6596 pub start_time: std::option::Option<wkt::Timestamp>,
6597
6598 /// The hard time window end time. If unspecified it will be set to
6599 /// `ShipmentModel.global_end_time`.
6600 pub end_time: std::option::Option<wkt::Timestamp>,
6601
6602 /// The soft start time of the time window.
6603 pub soft_start_time: std::option::Option<wkt::Timestamp>,
6604
6605 /// The soft end time of the time window.
6606 pub soft_end_time: std::option::Option<wkt::Timestamp>,
6607
6608 /// A cost per hour added to other costs in the model if the event occurs
6609 /// before soft_start_time, computed as:
6610 ///
6611 /// ```norust
6612 /// max(0, soft_start_time - t.seconds)
6613 /// * cost_per_hour_before_soft_start_time / 3600,
6614 /// t being the time of the event.
6615 /// ```
6616 ///
6617 /// This cost must be positive, and the field can only be set if
6618 /// soft_start_time has been set.
6619 pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
6620
6621 /// A cost per hour added to other costs in the model if the event occurs after
6622 /// `soft_end_time`, computed as:
6623 ///
6624 /// ```norust
6625 /// max(0, t.seconds - soft_end_time.seconds)
6626 /// * cost_per_hour_after_soft_end_time / 3600,
6627 /// t being the time of the event.
6628 /// ```
6629 ///
6630 /// This cost must be positive, and the field can only be set if
6631 /// `soft_end_time` has been set.
6632 pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
6633
6634 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6635}
6636
6637impl TimeWindow {
6638 pub fn new() -> Self {
6639 std::default::Default::default()
6640 }
6641
6642 /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
6643 ///
6644 /// # Example
6645 /// ```ignore,no_run
6646 /// # use google_cloud_optimization_v1::model::TimeWindow;
6647 /// use wkt::Timestamp;
6648 /// let x = TimeWindow::new().set_start_time(Timestamp::default()/* use setters */);
6649 /// ```
6650 pub fn set_start_time<T>(mut self, v: T) -> Self
6651 where
6652 T: std::convert::Into<wkt::Timestamp>,
6653 {
6654 self.start_time = std::option::Option::Some(v.into());
6655 self
6656 }
6657
6658 /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
6659 ///
6660 /// # Example
6661 /// ```ignore,no_run
6662 /// # use google_cloud_optimization_v1::model::TimeWindow;
6663 /// use wkt::Timestamp;
6664 /// let x = TimeWindow::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
6665 /// let x = TimeWindow::new().set_or_clear_start_time(None::<Timestamp>);
6666 /// ```
6667 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6668 where
6669 T: std::convert::Into<wkt::Timestamp>,
6670 {
6671 self.start_time = v.map(|x| x.into());
6672 self
6673 }
6674
6675 /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
6676 ///
6677 /// # Example
6678 /// ```ignore,no_run
6679 /// # use google_cloud_optimization_v1::model::TimeWindow;
6680 /// use wkt::Timestamp;
6681 /// let x = TimeWindow::new().set_end_time(Timestamp::default()/* use setters */);
6682 /// ```
6683 pub fn set_end_time<T>(mut self, v: T) -> Self
6684 where
6685 T: std::convert::Into<wkt::Timestamp>,
6686 {
6687 self.end_time = std::option::Option::Some(v.into());
6688 self
6689 }
6690
6691 /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
6692 ///
6693 /// # Example
6694 /// ```ignore,no_run
6695 /// # use google_cloud_optimization_v1::model::TimeWindow;
6696 /// use wkt::Timestamp;
6697 /// let x = TimeWindow::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
6698 /// let x = TimeWindow::new().set_or_clear_end_time(None::<Timestamp>);
6699 /// ```
6700 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6701 where
6702 T: std::convert::Into<wkt::Timestamp>,
6703 {
6704 self.end_time = v.map(|x| x.into());
6705 self
6706 }
6707
6708 /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6709 ///
6710 /// # Example
6711 /// ```ignore,no_run
6712 /// # use google_cloud_optimization_v1::model::TimeWindow;
6713 /// use wkt::Timestamp;
6714 /// let x = TimeWindow::new().set_soft_start_time(Timestamp::default()/* use setters */);
6715 /// ```
6716 pub fn set_soft_start_time<T>(mut self, v: T) -> Self
6717 where
6718 T: std::convert::Into<wkt::Timestamp>,
6719 {
6720 self.soft_start_time = std::option::Option::Some(v.into());
6721 self
6722 }
6723
6724 /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6725 ///
6726 /// # Example
6727 /// ```ignore,no_run
6728 /// # use google_cloud_optimization_v1::model::TimeWindow;
6729 /// use wkt::Timestamp;
6730 /// let x = TimeWindow::new().set_or_clear_soft_start_time(Some(Timestamp::default()/* use setters */));
6731 /// let x = TimeWindow::new().set_or_clear_soft_start_time(None::<Timestamp>);
6732 /// ```
6733 pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6734 where
6735 T: std::convert::Into<wkt::Timestamp>,
6736 {
6737 self.soft_start_time = v.map(|x| x.into());
6738 self
6739 }
6740
6741 /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6742 ///
6743 /// # Example
6744 /// ```ignore,no_run
6745 /// # use google_cloud_optimization_v1::model::TimeWindow;
6746 /// use wkt::Timestamp;
6747 /// let x = TimeWindow::new().set_soft_end_time(Timestamp::default()/* use setters */);
6748 /// ```
6749 pub fn set_soft_end_time<T>(mut self, v: T) -> Self
6750 where
6751 T: std::convert::Into<wkt::Timestamp>,
6752 {
6753 self.soft_end_time = std::option::Option::Some(v.into());
6754 self
6755 }
6756
6757 /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6758 ///
6759 /// # Example
6760 /// ```ignore,no_run
6761 /// # use google_cloud_optimization_v1::model::TimeWindow;
6762 /// use wkt::Timestamp;
6763 /// let x = TimeWindow::new().set_or_clear_soft_end_time(Some(Timestamp::default()/* use setters */));
6764 /// let x = TimeWindow::new().set_or_clear_soft_end_time(None::<Timestamp>);
6765 /// ```
6766 pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6767 where
6768 T: std::convert::Into<wkt::Timestamp>,
6769 {
6770 self.soft_end_time = v.map(|x| x.into());
6771 self
6772 }
6773
6774 /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6775 ///
6776 /// # Example
6777 /// ```ignore,no_run
6778 /// # use google_cloud_optimization_v1::model::TimeWindow;
6779 /// let x = TimeWindow::new().set_cost_per_hour_before_soft_start_time(42.0);
6780 /// ```
6781 pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
6782 where
6783 T: std::convert::Into<f64>,
6784 {
6785 self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
6786 self
6787 }
6788
6789 /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6790 ///
6791 /// # Example
6792 /// ```ignore,no_run
6793 /// # use google_cloud_optimization_v1::model::TimeWindow;
6794 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(Some(42.0));
6795 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(None::<f32>);
6796 /// ```
6797 pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
6798 mut self,
6799 v: std::option::Option<T>,
6800 ) -> Self
6801 where
6802 T: std::convert::Into<f64>,
6803 {
6804 self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
6805 self
6806 }
6807
6808 /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6809 ///
6810 /// # Example
6811 /// ```ignore,no_run
6812 /// # use google_cloud_optimization_v1::model::TimeWindow;
6813 /// let x = TimeWindow::new().set_cost_per_hour_after_soft_end_time(42.0);
6814 /// ```
6815 pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
6816 where
6817 T: std::convert::Into<f64>,
6818 {
6819 self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
6820 self
6821 }
6822
6823 /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6824 ///
6825 /// # Example
6826 /// ```ignore,no_run
6827 /// # use google_cloud_optimization_v1::model::TimeWindow;
6828 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(Some(42.0));
6829 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(None::<f32>);
6830 /// ```
6831 pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
6832 mut self,
6833 v: std::option::Option<T>,
6834 ) -> Self
6835 where
6836 T: std::convert::Into<f64>,
6837 {
6838 self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
6839 self
6840 }
6841}
6842
6843impl wkt::message::Message for TimeWindow {
6844 fn typename() -> &'static str {
6845 "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
6846 }
6847}
6848
6849/// Deprecated: Use
6850/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6851/// instead.
6852///
6853/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6854#[derive(Clone, Default, PartialEq)]
6855#[non_exhaustive]
6856#[deprecated]
6857pub struct CapacityQuantity {
6858 pub r#type: std::string::String,
6859
6860 pub value: i64,
6861
6862 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6863}
6864
6865impl CapacityQuantity {
6866 pub fn new() -> Self {
6867 std::default::Default::default()
6868 }
6869
6870 /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
6871 ///
6872 /// # Example
6873 /// ```ignore,no_run
6874 /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6875 /// let x = CapacityQuantity::new().set_type("example");
6876 /// ```
6877 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6878 self.r#type = v.into();
6879 self
6880 }
6881
6882 /// Sets the value of [value][crate::model::CapacityQuantity::value].
6883 ///
6884 /// # Example
6885 /// ```ignore,no_run
6886 /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6887 /// let x = CapacityQuantity::new().set_value(42);
6888 /// ```
6889 pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6890 self.value = v.into();
6891 self
6892 }
6893}
6894
6895impl wkt::message::Message for CapacityQuantity {
6896 fn typename() -> &'static str {
6897 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
6898 }
6899}
6900
6901/// Deprecated: Use
6902/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6903/// instead.
6904///
6905/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6906#[derive(Clone, Default, PartialEq)]
6907#[non_exhaustive]
6908#[deprecated]
6909pub struct CapacityQuantityInterval {
6910 pub r#type: std::string::String,
6911
6912 pub min_value: std::option::Option<i64>,
6913
6914 pub max_value: std::option::Option<i64>,
6915
6916 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6917}
6918
6919impl CapacityQuantityInterval {
6920 pub fn new() -> Self {
6921 std::default::Default::default()
6922 }
6923
6924 /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
6925 ///
6926 /// # Example
6927 /// ```ignore,no_run
6928 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6929 /// let x = CapacityQuantityInterval::new().set_type("example");
6930 /// ```
6931 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6932 self.r#type = v.into();
6933 self
6934 }
6935
6936 /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6937 ///
6938 /// # Example
6939 /// ```ignore,no_run
6940 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6941 /// let x = CapacityQuantityInterval::new().set_min_value(42);
6942 /// ```
6943 pub fn set_min_value<T>(mut self, v: T) -> Self
6944 where
6945 T: std::convert::Into<i64>,
6946 {
6947 self.min_value = std::option::Option::Some(v.into());
6948 self
6949 }
6950
6951 /// Sets or clears the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6952 ///
6953 /// # Example
6954 /// ```ignore,no_run
6955 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6956 /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(Some(42));
6957 /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(None::<i32>);
6958 /// ```
6959 pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
6960 where
6961 T: std::convert::Into<i64>,
6962 {
6963 self.min_value = v.map(|x| x.into());
6964 self
6965 }
6966
6967 /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
6968 ///
6969 /// # Example
6970 /// ```ignore,no_run
6971 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6972 /// let x = CapacityQuantityInterval::new().set_max_value(42);
6973 /// ```
6974 pub fn set_max_value<T>(mut self, v: T) -> Self
6975 where
6976 T: std::convert::Into<i64>,
6977 {
6978 self.max_value = std::option::Option::Some(v.into());
6979 self
6980 }
6981
6982 /// Sets or clears the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
6983 ///
6984 /// # Example
6985 /// ```ignore,no_run
6986 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6987 /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(Some(42));
6988 /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(None::<i32>);
6989 /// ```
6990 pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
6991 where
6992 T: std::convert::Into<i64>,
6993 {
6994 self.max_value = v.map(|x| x.into());
6995 self
6996 }
6997}
6998
6999impl wkt::message::Message for CapacityQuantityInterval {
7000 fn typename() -> &'static str {
7001 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
7002 }
7003}
7004
7005/// A limit defining a maximum distance which can be traveled. It can be either
7006/// hard or soft.
7007///
7008/// If a soft limit is defined, both `soft_max_meters` and
7009/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
7010#[derive(Clone, Default, PartialEq)]
7011#[non_exhaustive]
7012pub struct DistanceLimit {
7013 /// A hard limit constraining the distance to be at most max_meters. The limit
7014 /// must be nonnegative.
7015 pub max_meters: std::option::Option<i64>,
7016
7017 /// A soft limit not enforcing a maximum distance limit, but when violated
7018 /// results in a cost which adds up to other costs defined in the model,
7019 /// with the same unit.
7020 ///
7021 /// If defined soft_max_meters must be less than max_meters and must be
7022 /// nonnegative.
7023 pub soft_max_meters: std::option::Option<i64>,
7024
7025 /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
7026 /// formula:
7027 ///
7028 /// ```norust
7029 /// min(distance_meters, soft_max_meters) / 1000.0 *
7030 /// cost_per_kilometer_below_soft_max.
7031 /// ```
7032 ///
7033 /// This cost is not supported in `route_distance_limit`.
7034 pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
7035
7036 /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
7037 /// The additional cost is 0 if the distance is under the limit, otherwise the
7038 /// formula used to compute the cost is the following:
7039 ///
7040 /// ```norust
7041 /// (distance_meters - soft_max_meters) / 1000.0 *
7042 /// cost_per_kilometer_above_soft_max.
7043 /// ```
7044 ///
7045 /// The cost must be nonnegative.
7046 pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
7047
7048 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7049}
7050
7051impl DistanceLimit {
7052 pub fn new() -> Self {
7053 std::default::Default::default()
7054 }
7055
7056 /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
7057 ///
7058 /// # Example
7059 /// ```ignore,no_run
7060 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7061 /// let x = DistanceLimit::new().set_max_meters(42);
7062 /// ```
7063 pub fn set_max_meters<T>(mut self, v: T) -> Self
7064 where
7065 T: std::convert::Into<i64>,
7066 {
7067 self.max_meters = std::option::Option::Some(v.into());
7068 self
7069 }
7070
7071 /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
7072 ///
7073 /// # Example
7074 /// ```ignore,no_run
7075 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7076 /// let x = DistanceLimit::new().set_or_clear_max_meters(Some(42));
7077 /// let x = DistanceLimit::new().set_or_clear_max_meters(None::<i32>);
7078 /// ```
7079 pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7080 where
7081 T: std::convert::Into<i64>,
7082 {
7083 self.max_meters = v.map(|x| x.into());
7084 self
7085 }
7086
7087 /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7088 ///
7089 /// # Example
7090 /// ```ignore,no_run
7091 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7092 /// let x = DistanceLimit::new().set_soft_max_meters(42);
7093 /// ```
7094 pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
7095 where
7096 T: std::convert::Into<i64>,
7097 {
7098 self.soft_max_meters = std::option::Option::Some(v.into());
7099 self
7100 }
7101
7102 /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7103 ///
7104 /// # Example
7105 /// ```ignore,no_run
7106 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7107 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(Some(42));
7108 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(None::<i32>);
7109 /// ```
7110 pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7111 where
7112 T: std::convert::Into<i64>,
7113 {
7114 self.soft_max_meters = v.map(|x| x.into());
7115 self
7116 }
7117
7118 /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7119 ///
7120 /// # Example
7121 /// ```ignore,no_run
7122 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7123 /// let x = DistanceLimit::new().set_cost_per_kilometer_below_soft_max(42.0);
7124 /// ```
7125 pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
7126 where
7127 T: std::convert::Into<f64>,
7128 {
7129 self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
7130 self
7131 }
7132
7133 /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7134 ///
7135 /// # Example
7136 /// ```ignore,no_run
7137 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7138 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(Some(42.0));
7139 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(None::<f32>);
7140 /// ```
7141 pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
7142 mut self,
7143 v: std::option::Option<T>,
7144 ) -> Self
7145 where
7146 T: std::convert::Into<f64>,
7147 {
7148 self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
7149 self
7150 }
7151
7152 /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7153 ///
7154 /// # Example
7155 /// ```ignore,no_run
7156 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7157 /// let x = DistanceLimit::new().set_cost_per_kilometer_above_soft_max(42.0);
7158 /// ```
7159 pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
7160 where
7161 T: std::convert::Into<f64>,
7162 {
7163 self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
7164 self
7165 }
7166
7167 /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7168 ///
7169 /// # Example
7170 /// ```ignore,no_run
7171 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7172 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(Some(42.0));
7173 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(None::<f32>);
7174 /// ```
7175 pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
7176 mut self,
7177 v: std::option::Option<T>,
7178 ) -> Self
7179 where
7180 T: std::convert::Into<f64>,
7181 {
7182 self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
7183 self
7184 }
7185}
7186
7187impl wkt::message::Message for DistanceLimit {
7188 fn typename() -> &'static str {
7189 "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
7190 }
7191}
7192
7193/// Specifies attributes of transitions between two consecutive visits on a
7194/// route. Several `TransitionAttributes` may apply to the same transition: in
7195/// that case, all extra costs add up and the strictest constraint or limit
7196/// applies (following natural "AND" semantics).
7197#[derive(Clone, Default, PartialEq)]
7198#[non_exhaustive]
7199pub struct TransitionAttributes {
7200 /// Tags defining the set of (src->dst) transitions these attributes apply to.
7201 ///
7202 /// A source visit or vehicle start matches iff its
7203 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7204 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
7205 /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
7206 /// on which of these two fields is non-empty).
7207 ///
7208 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7209 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
7210 pub src_tag: std::string::String,
7211
7212 /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
7213 /// non-empty.
7214 pub excluded_src_tag: std::string::String,
7215
7216 /// A destination visit or vehicle end matches iff its
7217 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7218 /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
7219 /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
7220 /// which of these two fields is non-empty).
7221 ///
7222 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7223 /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
7224 pub dst_tag: std::string::String,
7225
7226 /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
7227 /// non-empty.
7228 pub excluded_dst_tag: std::string::String,
7229
7230 /// Specifies a cost for performing this transition. This is in the same unit
7231 /// as all other costs in the model and must not be negative. It is applied on
7232 /// top of all other existing costs.
7233 pub cost: f64,
7234
7235 /// Specifies a cost per kilometer applied to the distance traveled while
7236 /// performing this transition. It adds up to any
7237 /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
7238 /// specified on vehicles.
7239 ///
7240 /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
7241 pub cost_per_kilometer: f64,
7242
7243 /// Specifies a limit on the distance traveled while performing this
7244 /// transition.
7245 ///
7246 /// As of 2021/06, only soft limits are supported.
7247 pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
7248
7249 /// Specifies a delay incurred when performing this transition.
7250 ///
7251 /// This delay always occurs *after* finishing the source visit and *before*
7252 /// starting the destination visit.
7253 pub delay: std::option::Option<wkt::Duration>,
7254
7255 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7256}
7257
7258impl TransitionAttributes {
7259 pub fn new() -> Self {
7260 std::default::Default::default()
7261 }
7262
7263 /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
7264 ///
7265 /// # Example
7266 /// ```ignore,no_run
7267 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7268 /// let x = TransitionAttributes::new().set_src_tag("example");
7269 /// ```
7270 pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7271 self.src_tag = v.into();
7272 self
7273 }
7274
7275 /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
7276 ///
7277 /// # Example
7278 /// ```ignore,no_run
7279 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7280 /// let x = TransitionAttributes::new().set_excluded_src_tag("example");
7281 /// ```
7282 pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
7283 mut self,
7284 v: T,
7285 ) -> Self {
7286 self.excluded_src_tag = v.into();
7287 self
7288 }
7289
7290 /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
7291 ///
7292 /// # Example
7293 /// ```ignore,no_run
7294 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7295 /// let x = TransitionAttributes::new().set_dst_tag("example");
7296 /// ```
7297 pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7298 self.dst_tag = v.into();
7299 self
7300 }
7301
7302 /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
7303 ///
7304 /// # Example
7305 /// ```ignore,no_run
7306 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7307 /// let x = TransitionAttributes::new().set_excluded_dst_tag("example");
7308 /// ```
7309 pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
7310 mut self,
7311 v: T,
7312 ) -> Self {
7313 self.excluded_dst_tag = v.into();
7314 self
7315 }
7316
7317 /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
7318 ///
7319 /// # Example
7320 /// ```ignore,no_run
7321 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7322 /// let x = TransitionAttributes::new().set_cost(42.0);
7323 /// ```
7324 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7325 self.cost = v.into();
7326 self
7327 }
7328
7329 /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
7330 ///
7331 /// # Example
7332 /// ```ignore,no_run
7333 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7334 /// let x = TransitionAttributes::new().set_cost_per_kilometer(42.0);
7335 /// ```
7336 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7337 self.cost_per_kilometer = v.into();
7338 self
7339 }
7340
7341 /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7342 ///
7343 /// # Example
7344 /// ```ignore,no_run
7345 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7346 /// use google_cloud_optimization_v1::model::DistanceLimit;
7347 /// let x = TransitionAttributes::new().set_distance_limit(DistanceLimit::default()/* use setters */);
7348 /// ```
7349 pub fn set_distance_limit<T>(mut self, v: T) -> Self
7350 where
7351 T: std::convert::Into<crate::model::DistanceLimit>,
7352 {
7353 self.distance_limit = std::option::Option::Some(v.into());
7354 self
7355 }
7356
7357 /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7358 ///
7359 /// # Example
7360 /// ```ignore,no_run
7361 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7362 /// use google_cloud_optimization_v1::model::DistanceLimit;
7363 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(Some(DistanceLimit::default()/* use setters */));
7364 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(None::<DistanceLimit>);
7365 /// ```
7366 pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
7367 where
7368 T: std::convert::Into<crate::model::DistanceLimit>,
7369 {
7370 self.distance_limit = v.map(|x| x.into());
7371 self
7372 }
7373
7374 /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
7375 ///
7376 /// # Example
7377 /// ```ignore,no_run
7378 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7379 /// use wkt::Duration;
7380 /// let x = TransitionAttributes::new().set_delay(Duration::default()/* use setters */);
7381 /// ```
7382 pub fn set_delay<T>(mut self, v: T) -> Self
7383 where
7384 T: std::convert::Into<wkt::Duration>,
7385 {
7386 self.delay = std::option::Option::Some(v.into());
7387 self
7388 }
7389
7390 /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
7391 ///
7392 /// # Example
7393 /// ```ignore,no_run
7394 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7395 /// use wkt::Duration;
7396 /// let x = TransitionAttributes::new().set_or_clear_delay(Some(Duration::default()/* use setters */));
7397 /// let x = TransitionAttributes::new().set_or_clear_delay(None::<Duration>);
7398 /// ```
7399 pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
7400 where
7401 T: std::convert::Into<wkt::Duration>,
7402 {
7403 self.delay = v.map(|x| x.into());
7404 self
7405 }
7406}
7407
7408impl wkt::message::Message for TransitionAttributes {
7409 fn typename() -> &'static str {
7410 "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
7411 }
7412}
7413
7414/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
7415/// VisitRequests, and start and end locations of Vehicles.
7416#[derive(Clone, Default, PartialEq)]
7417#[non_exhaustive]
7418pub struct Waypoint {
7419 /// Indicates that the location of this waypoint is meant to have a preference
7420 /// for the vehicle to stop at a particular side of road. When you set this
7421 /// value, the route will pass through the location so that the vehicle can
7422 /// stop at the side of road that the location is biased towards from the
7423 /// center of the road. This option works only for the 'DRIVING' travel mode,
7424 /// and when the 'location_type' is set to 'location'.
7425 pub side_of_road: bool,
7426
7427 /// Different ways to represent a location.
7428 pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
7429
7430 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7431}
7432
7433impl Waypoint {
7434 pub fn new() -> Self {
7435 std::default::Default::default()
7436 }
7437
7438 /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
7439 ///
7440 /// # Example
7441 /// ```ignore,no_run
7442 /// # use google_cloud_optimization_v1::model::Waypoint;
7443 /// let x = Waypoint::new().set_side_of_road(true);
7444 /// ```
7445 pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7446 self.side_of_road = v.into();
7447 self
7448 }
7449
7450 /// Sets the value of [location_type][crate::model::Waypoint::location_type].
7451 ///
7452 /// Note that all the setters affecting `location_type` are mutually
7453 /// exclusive.
7454 ///
7455 /// # Example
7456 /// ```ignore,no_run
7457 /// # use google_cloud_optimization_v1::model::Waypoint;
7458 /// use google_cloud_optimization_v1::model::waypoint::LocationType;
7459 /// let x = Waypoint::new().set_location_type(Some(LocationType::PlaceId("example".to_string())));
7460 /// ```
7461 pub fn set_location_type<
7462 T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
7463 >(
7464 mut self,
7465 v: T,
7466 ) -> Self {
7467 self.location_type = v.into();
7468 self
7469 }
7470
7471 /// The value of [location_type][crate::model::Waypoint::location_type]
7472 /// if it holds a `Location`, `None` if the field is not set or
7473 /// holds a different branch.
7474 pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
7475 #[allow(unreachable_patterns)]
7476 self.location_type.as_ref().and_then(|v| match v {
7477 crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
7478 _ => std::option::Option::None,
7479 })
7480 }
7481
7482 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7483 /// to hold a `Location`.
7484 ///
7485 /// Note that all the setters affecting `location_type` are
7486 /// mutually exclusive.
7487 ///
7488 /// # Example
7489 /// ```ignore,no_run
7490 /// # use google_cloud_optimization_v1::model::Waypoint;
7491 /// use google_cloud_optimization_v1::model::Location;
7492 /// let x = Waypoint::new().set_location(Location::default()/* use setters */);
7493 /// assert!(x.location().is_some());
7494 /// assert!(x.place_id().is_none());
7495 /// ```
7496 pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
7497 mut self,
7498 v: T,
7499 ) -> Self {
7500 self.location_type =
7501 std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
7502 self
7503 }
7504
7505 /// The value of [location_type][crate::model::Waypoint::location_type]
7506 /// if it holds a `PlaceId`, `None` if the field is not set or
7507 /// holds a different branch.
7508 pub fn place_id(&self) -> std::option::Option<&std::string::String> {
7509 #[allow(unreachable_patterns)]
7510 self.location_type.as_ref().and_then(|v| match v {
7511 crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
7512 _ => std::option::Option::None,
7513 })
7514 }
7515
7516 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7517 /// to hold a `PlaceId`.
7518 ///
7519 /// Note that all the setters affecting `location_type` are
7520 /// mutually exclusive.
7521 ///
7522 /// # Example
7523 /// ```ignore,no_run
7524 /// # use google_cloud_optimization_v1::model::Waypoint;
7525 /// let x = Waypoint::new().set_place_id("example");
7526 /// assert!(x.place_id().is_some());
7527 /// assert!(x.location().is_none());
7528 /// ```
7529 pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7530 self.location_type =
7531 std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
7532 self
7533 }
7534}
7535
7536impl wkt::message::Message for Waypoint {
7537 fn typename() -> &'static str {
7538 "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
7539 }
7540}
7541
7542/// Defines additional types related to [Waypoint].
7543pub mod waypoint {
7544 #[allow(unused_imports)]
7545 use super::*;
7546
7547 /// Different ways to represent a location.
7548 #[derive(Clone, Debug, PartialEq)]
7549 #[non_exhaustive]
7550 pub enum LocationType {
7551 /// A point specified using geographic coordinates, including an optional
7552 /// heading.
7553 Location(std::boxed::Box<crate::model::Location>),
7554 /// The POI Place ID associated with the waypoint.
7555 PlaceId(std::string::String),
7556 }
7557}
7558
7559/// Encapsulates a location (a geographic point, and an optional heading).
7560#[derive(Clone, Default, PartialEq)]
7561#[non_exhaustive]
7562pub struct Location {
7563 /// The waypoint's geographic coordinates.
7564 pub lat_lng: std::option::Option<google_cloud_type::model::LatLng>,
7565
7566 /// The compass heading associated with the direction of the flow of traffic.
7567 /// This value is used to specify the side of the road to use for pickup and
7568 /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
7569 /// of due North, 90 specifies a heading of due East, etc.
7570 pub heading: std::option::Option<i32>,
7571
7572 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7573}
7574
7575impl Location {
7576 pub fn new() -> Self {
7577 std::default::Default::default()
7578 }
7579
7580 /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
7581 ///
7582 /// # Example
7583 /// ```ignore,no_run
7584 /// # use google_cloud_optimization_v1::model::Location;
7585 /// use google_cloud_type::model::LatLng;
7586 /// let x = Location::new().set_lat_lng(LatLng::default()/* use setters */);
7587 /// ```
7588 pub fn set_lat_lng<T>(mut self, v: T) -> Self
7589 where
7590 T: std::convert::Into<google_cloud_type::model::LatLng>,
7591 {
7592 self.lat_lng = std::option::Option::Some(v.into());
7593 self
7594 }
7595
7596 /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
7597 ///
7598 /// # Example
7599 /// ```ignore,no_run
7600 /// # use google_cloud_optimization_v1::model::Location;
7601 /// use google_cloud_type::model::LatLng;
7602 /// let x = Location::new().set_or_clear_lat_lng(Some(LatLng::default()/* use setters */));
7603 /// let x = Location::new().set_or_clear_lat_lng(None::<LatLng>);
7604 /// ```
7605 pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
7606 where
7607 T: std::convert::Into<google_cloud_type::model::LatLng>,
7608 {
7609 self.lat_lng = v.map(|x| x.into());
7610 self
7611 }
7612
7613 /// Sets the value of [heading][crate::model::Location::heading].
7614 ///
7615 /// # Example
7616 /// ```ignore,no_run
7617 /// # use google_cloud_optimization_v1::model::Location;
7618 /// let x = Location::new().set_heading(42);
7619 /// ```
7620 pub fn set_heading<T>(mut self, v: T) -> Self
7621 where
7622 T: std::convert::Into<i32>,
7623 {
7624 self.heading = std::option::Option::Some(v.into());
7625 self
7626 }
7627
7628 /// Sets or clears the value of [heading][crate::model::Location::heading].
7629 ///
7630 /// # Example
7631 /// ```ignore,no_run
7632 /// # use google_cloud_optimization_v1::model::Location;
7633 /// let x = Location::new().set_or_clear_heading(Some(42));
7634 /// let x = Location::new().set_or_clear_heading(None::<i32>);
7635 /// ```
7636 pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
7637 where
7638 T: std::convert::Into<i32>,
7639 {
7640 self.heading = v.map(|x| x.into());
7641 self
7642 }
7643}
7644
7645impl wkt::message::Message for Location {
7646 fn typename() -> &'static str {
7647 "type.googleapis.com/google.cloud.optimization.v1.Location"
7648 }
7649}
7650
7651/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
7652/// is a contiguous period of time during which the vehicle remains idle at its
7653/// current position and cannot perform any visit. A break may occur:
7654///
7655/// * during the travel between two visits (which includes the time right
7656/// before or right after a visit, but not in the middle of a visit), in
7657/// which case it extends the corresponding transit time between the visits,
7658/// * or before the vehicle start (the vehicle may not start in the middle of
7659/// a break), in which case it does not affect the vehicle start time.
7660/// * or after the vehicle end (ditto, with the vehicle end time).
7661#[derive(Clone, Default, PartialEq)]
7662#[non_exhaustive]
7663pub struct BreakRule {
7664 /// Sequence of breaks. See the `BreakRequest` message.
7665 pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
7666
7667 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
7668 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
7669 pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
7670
7671 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7672}
7673
7674impl BreakRule {
7675 pub fn new() -> Self {
7676 std::default::Default::default()
7677 }
7678
7679 /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
7680 ///
7681 /// # Example
7682 /// ```ignore,no_run
7683 /// # use google_cloud_optimization_v1::model::BreakRule;
7684 /// use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7685 /// let x = BreakRule::new()
7686 /// .set_break_requests([
7687 /// BreakRequest::default()/* use setters */,
7688 /// BreakRequest::default()/* use (different) setters */,
7689 /// ]);
7690 /// ```
7691 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
7692 where
7693 T: std::iter::IntoIterator<Item = V>,
7694 V: std::convert::Into<crate::model::break_rule::BreakRequest>,
7695 {
7696 use std::iter::Iterator;
7697 self.break_requests = v.into_iter().map(|i| i.into()).collect();
7698 self
7699 }
7700
7701 /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
7702 ///
7703 /// # Example
7704 /// ```ignore,no_run
7705 /// # use google_cloud_optimization_v1::model::BreakRule;
7706 /// use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7707 /// let x = BreakRule::new()
7708 /// .set_frequency_constraints([
7709 /// FrequencyConstraint::default()/* use setters */,
7710 /// FrequencyConstraint::default()/* use (different) setters */,
7711 /// ]);
7712 /// ```
7713 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
7714 where
7715 T: std::iter::IntoIterator<Item = V>,
7716 V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
7717 {
7718 use std::iter::Iterator;
7719 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
7720 self
7721 }
7722}
7723
7724impl wkt::message::Message for BreakRule {
7725 fn typename() -> &'static str {
7726 "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
7727 }
7728}
7729
7730/// Defines additional types related to [BreakRule].
7731pub mod break_rule {
7732 #[allow(unused_imports)]
7733 use super::*;
7734
7735 /// The sequence of breaks (i.e. their number and order) that apply to each
7736 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
7737 /// that sequence, in the order in which they must occur. Their time windows
7738 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
7739 /// be compatible with the order (this is checked).
7740 #[derive(Clone, Default, PartialEq)]
7741 #[non_exhaustive]
7742 pub struct BreakRequest {
7743 /// Required. Lower bound (inclusive) on the start of the break.
7744 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
7745
7746 /// Required. Upper bound (inclusive) on the start of the break.
7747 pub latest_start_time: std::option::Option<wkt::Timestamp>,
7748
7749 /// Required. Minimum duration of the break. Must be positive.
7750 pub min_duration: std::option::Option<wkt::Duration>,
7751
7752 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7753 }
7754
7755 impl BreakRequest {
7756 pub fn new() -> Self {
7757 std::default::Default::default()
7758 }
7759
7760 /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7761 ///
7762 /// # Example
7763 /// ```ignore,no_run
7764 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7765 /// use wkt::Timestamp;
7766 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
7767 /// ```
7768 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
7769 where
7770 T: std::convert::Into<wkt::Timestamp>,
7771 {
7772 self.earliest_start_time = std::option::Option::Some(v.into());
7773 self
7774 }
7775
7776 /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7777 ///
7778 /// # Example
7779 /// ```ignore,no_run
7780 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7781 /// use wkt::Timestamp;
7782 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
7783 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
7784 /// ```
7785 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7786 where
7787 T: std::convert::Into<wkt::Timestamp>,
7788 {
7789 self.earliest_start_time = v.map(|x| x.into());
7790 self
7791 }
7792
7793 /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7794 ///
7795 /// # Example
7796 /// ```ignore,no_run
7797 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7798 /// use wkt::Timestamp;
7799 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
7800 /// ```
7801 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
7802 where
7803 T: std::convert::Into<wkt::Timestamp>,
7804 {
7805 self.latest_start_time = std::option::Option::Some(v.into());
7806 self
7807 }
7808
7809 /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7810 ///
7811 /// # Example
7812 /// ```ignore,no_run
7813 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7814 /// use wkt::Timestamp;
7815 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
7816 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
7817 /// ```
7818 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7819 where
7820 T: std::convert::Into<wkt::Timestamp>,
7821 {
7822 self.latest_start_time = v.map(|x| x.into());
7823 self
7824 }
7825
7826 /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7827 ///
7828 /// # Example
7829 /// ```ignore,no_run
7830 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7831 /// use wkt::Duration;
7832 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
7833 /// ```
7834 pub fn set_min_duration<T>(mut self, v: T) -> Self
7835 where
7836 T: std::convert::Into<wkt::Duration>,
7837 {
7838 self.min_duration = std::option::Option::Some(v.into());
7839 self
7840 }
7841
7842 /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7843 ///
7844 /// # Example
7845 /// ```ignore,no_run
7846 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7847 /// use wkt::Duration;
7848 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
7849 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
7850 /// ```
7851 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
7852 where
7853 T: std::convert::Into<wkt::Duration>,
7854 {
7855 self.min_duration = v.map(|x| x.into());
7856 self
7857 }
7858 }
7859
7860 impl wkt::message::Message for BreakRequest {
7861 fn typename() -> &'static str {
7862 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
7863 }
7864 }
7865
7866 /// One may further constrain the frequency and duration of the breaks
7867 /// specified above, by enforcing a minimum break frequency, such as
7868 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
7869 /// this can be interpreted as "Within any sliding time window of 12h, there
7870 /// must be at least one break of at least one hour", that example would
7871 /// translate to the following `FrequencyConstraint`:
7872 ///
7873 /// ```norust
7874 /// {
7875 /// min_break_duration { seconds: 3600 } # 1 hour.
7876 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
7877 /// }
7878 /// ```
7879 ///
7880 /// The timing and duration of the breaks in the solution will respect all
7881 /// such constraints, in addition to the time windows and minimum durations
7882 /// already specified in the `BreakRequest`.
7883 ///
7884 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
7885 /// For example, the following schedule honors the "1h every 12h" example:
7886 ///
7887 /// ```norust
7888 /// 04:00 vehicle start
7889 /// .. performing travel and visits ..
7890 /// 09:00 1 hour break
7891 /// 10:00 end of the break
7892 /// .. performing travel and visits ..
7893 /// 12:00 20-min lunch break
7894 /// 12:20 end of the break
7895 /// .. performing travel and visits ..
7896 /// 21:00 1 hour break
7897 /// 22:00 end of the break
7898 /// .. performing travel and visits ..
7899 /// 23:59 vehicle end
7900 /// ```
7901 #[derive(Clone, Default, PartialEq)]
7902 #[non_exhaustive]
7903 pub struct FrequencyConstraint {
7904 /// Required. Minimum break duration for this constraint. Nonnegative.
7905 /// See description of `FrequencyConstraint`.
7906 pub min_break_duration: std::option::Option<wkt::Duration>,
7907
7908 /// Required. Maximum allowed span of any interval of time in the route that
7909 /// does not include at least partially a break of `duration >=
7910 /// min_break_duration`. Must be positive.
7911 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
7912
7913 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7914 }
7915
7916 impl FrequencyConstraint {
7917 pub fn new() -> Self {
7918 std::default::Default::default()
7919 }
7920
7921 /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7922 ///
7923 /// # Example
7924 /// ```ignore,no_run
7925 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7926 /// use wkt::Duration;
7927 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
7928 /// ```
7929 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
7930 where
7931 T: std::convert::Into<wkt::Duration>,
7932 {
7933 self.min_break_duration = std::option::Option::Some(v.into());
7934 self
7935 }
7936
7937 /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7938 ///
7939 /// # Example
7940 /// ```ignore,no_run
7941 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7942 /// use wkt::Duration;
7943 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
7944 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
7945 /// ```
7946 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7947 where
7948 T: std::convert::Into<wkt::Duration>,
7949 {
7950 self.min_break_duration = v.map(|x| x.into());
7951 self
7952 }
7953
7954 /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7955 ///
7956 /// # Example
7957 /// ```ignore,no_run
7958 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7959 /// use wkt::Duration;
7960 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
7961 /// ```
7962 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
7963 where
7964 T: std::convert::Into<wkt::Duration>,
7965 {
7966 self.max_inter_break_duration = std::option::Option::Some(v.into());
7967 self
7968 }
7969
7970 /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7971 ///
7972 /// # Example
7973 /// ```ignore,no_run
7974 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7975 /// use wkt::Duration;
7976 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
7977 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
7978 /// ```
7979 pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7980 where
7981 T: std::convert::Into<wkt::Duration>,
7982 {
7983 self.max_inter_break_duration = v.map(|x| x.into());
7984 self
7985 }
7986 }
7987
7988 impl wkt::message::Message for FrequencyConstraint {
7989 fn typename() -> &'static str {
7990 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
7991 }
7992 }
7993}
7994
7995/// A vehicle's route can be decomposed, along the time axis, like this (we
7996/// assume there are n visits):
7997///
7998/// ```norust
7999/// | | | | | T[2], | | |
8000/// | Transition | Visit #0 | | | V[2], | | |
8001/// | #0 | aka | T[1] | V[1] | ... | V[n-1] | T[n] |
8002/// | aka T[0] | V[0] | | | V[n-2],| | |
8003/// | | | | | T[n-1] | | |
8004/// ^ ^ ^ ^ ^ ^ ^ ^
8005/// vehicle V[0].start V[0].end V[1]. V[1]. V[n]. V[n]. vehicle
8006/// start (arrival) (departure) start end start end end
8007/// ```
8008///
8009/// Note that we make a difference between:
8010///
8011/// * "punctual events", such as the vehicle start and end and each visit's start
8012/// and end (aka arrival and departure). They happen at a given second.
8013/// * "time intervals", such as the visits themselves, and the transition between
8014/// visits. Though time intervals can sometimes have zero duration, i.e. start
8015/// and end at the same second, they often have a positive duration.
8016///
8017/// Invariants:
8018///
8019/// * If there are n visits, there are n+1 transitions.
8020/// * A visit is always surrounded by a transition before it (same index) and a
8021/// transition after it (index + 1).
8022/// * The vehicle start is always followed by transition #0.
8023/// * The vehicle end is always preceded by transition #n.
8024///
8025/// Zooming in, here is what happens during a `Transition` and a `Visit`:
8026///
8027/// ```norust
8028/// ---+-------------------------------------+-----------------------------+-->
8029/// | TRANSITION[i] | VISIT[i] |
8030/// | | |
8031/// | * TRAVEL: the vehicle moves from | PERFORM the visit: |
8032/// | VISIT[i-1].departure_location to | |
8033/// | VISIT[i].arrival_location, which | * Spend some time: |
8034/// | takes a given travel duration | the "visit duration". |
8035/// | and distance | |
8036/// | | * Load or unload |
8037/// | * BREAKS: the driver may have | some quantities from the |
8038/// | breaks (e.g. lunch break). | vehicle: the "demand". |
8039/// | | |
8040/// | * WAIT: the driver/vehicle does | |
8041/// | nothing. This can happen for | |
8042/// | many reasons, for example when | |
8043/// | the vehicle reaches the next | |
8044/// | event's destination before the | |
8045/// | start of its time window | |
8046/// | | |
8047/// | * DELAY: *right before* the next | |
8048/// | arrival. E.g. the vehicle and/or | |
8049/// | driver spends time unloading. | |
8050/// | | |
8051/// ---+-------------------------------------+-----------------------------+-->
8052/// ^ ^ ^
8053/// V[i-1].end V[i].start V[i].end
8054/// ```
8055///
8056/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
8057/// during a transition.
8058///
8059/// * They don't overlap.
8060/// * The DELAY is unique and *must* be a contiguous period of time right
8061/// before the next visit (or vehicle end). Thus, it suffice to know the
8062/// delay duration to know its start and end time.
8063/// * The BREAKS are contiguous, non-overlapping periods of time. The
8064/// response specifies the start time and duration of each break.
8065/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
8066/// during this transition. Clients can assume that travel happens "as soon as
8067/// possible" and that "wait" fills the remaining time.
8068///
8069/// A (complex) example:
8070///
8071/// ```norust
8072/// TRANSITION[i]
8073/// --++-----+-----------------------------------------------------------++-->
8074/// || | | | | | | ||
8075/// || T | B | T | | B | | D ||
8076/// || r | r | r | W | r | W | e ||
8077/// || a | e | a | a | e | a | l ||
8078/// || v | a | v | i | a | i | a ||
8079/// || e | k | e | t | k | t | y ||
8080/// || l | | l | | | | ||
8081/// || | | | | | | ||
8082/// --++-----------------------------------------------------------------++-->
8083/// ```
8084#[derive(Clone, Default, PartialEq)]
8085#[non_exhaustive]
8086pub struct ShipmentRoute {
8087 /// Vehicle performing the route, identified by its index in the source
8088 /// `ShipmentModel`.
8089 pub vehicle_index: i32,
8090
8091 /// Label of the vehicle performing this route, equal to
8092 /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
8093 pub vehicle_label: std::string::String,
8094
8095 /// Time at which the vehicle starts its route.
8096 pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
8097
8098 /// Time at which the vehicle finishes its route.
8099 pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
8100
8101 /// Ordered sequence of visits representing a route.
8102 /// visits[i] is the i-th visit in the route.
8103 /// If this field is empty, the vehicle is considered as unused.
8104 pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
8105
8106 /// Ordered list of transitions for the route.
8107 pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
8108
8109 /// When
8110 /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
8111 /// is set to true, this field indicates that inconsistencies in route timings
8112 /// are predicted using traffic-based travel duration estimates. There may be
8113 /// insufficient time to complete traffic-adjusted travel, delays, and breaks
8114 /// between visits, before the first visit, or after the last visit, while
8115 /// still satisfying the visit and vehicle time windows. For example,
8116 ///
8117 /// ```norust
8118 /// start_time(previous_visit) + duration(previous_visit) +
8119 /// travel_duration(previous_visit, next_visit) > start_time(next_visit)
8120 /// ```
8121 ///
8122 /// Arrival at next_visit will likely happen later than its current
8123 /// time window due the increased estimate of travel time
8124 /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
8125 /// may be forced to overlap with a visit due to an increase in travel time
8126 /// estimates and visit or break time window restrictions.
8127 ///
8128 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
8129 pub has_traffic_infeasibilities: bool,
8130
8131 /// The encoded polyline representation of the route.
8132 /// This field is only populated if
8133 /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
8134 /// is set to true.
8135 ///
8136 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
8137 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
8138
8139 /// Breaks scheduled for the vehicle performing this route.
8140 /// The `breaks` sequence represents time intervals, each starting at the
8141 /// corresponding `start_time` and lasting `duration` seconds.
8142 pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
8143
8144 /// Duration, distance and load metrics for this route. The fields of
8145 /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
8146 /// summed over all
8147 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8148 /// or
8149 /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
8150 /// depending on the context.
8151 ///
8152 /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
8153 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8154 /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
8155 pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
8156
8157 /// Cost of the route, broken down by cost-related request fields.
8158 /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
8159 /// "model.shipments.pickups.cost", and the values are the total cost
8160 /// generated by the corresponding cost field, aggregated over the whole route.
8161 /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
8162 /// pickup costs over the route. All costs defined in the model are reported in
8163 /// detail here with the exception of costs related to TransitionAttributes
8164 /// that are only reported in an aggregated way as of 2022/01.
8165 pub route_costs: std::collections::HashMap<std::string::String, f64>,
8166
8167 /// Total cost of the route. The sum of all costs in the cost map.
8168 pub route_total_cost: f64,
8169
8170 /// Deprecated: Use
8171 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8172 /// instead. Vehicle loads upon arrival at its end location, for each type
8173 /// specified in
8174 /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8175 /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
8176 /// loads for quantity types unconstrained by intervals and that don't have any
8177 /// non-zero demand on the route.
8178 ///
8179 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8180 /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8181 #[deprecated]
8182 pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8183
8184 /// Deprecated: Use
8185 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8186 /// instead. Ordered list of travel steps for the route.
8187 ///
8188 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8189 #[deprecated]
8190 pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
8191
8192 /// Deprecated: No longer used.
8193 /// This field will only be populated at the
8194 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
8195 /// level.
8196 ///
8197 /// This field is the extra detour time due to the shipments visited on the
8198 /// route.
8199 ///
8200 /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
8201 /// from the vehicle's start_location to its `end_location`.
8202 ///
8203 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
8204 #[deprecated]
8205 pub vehicle_detour: std::option::Option<wkt::Duration>,
8206
8207 /// Deprecated: Delay occurring before the vehicle end. See
8208 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8209 ///
8210 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8211 #[deprecated]
8212 pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
8213
8214 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8215}
8216
8217impl ShipmentRoute {
8218 pub fn new() -> Self {
8219 std::default::Default::default()
8220 }
8221
8222 /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
8223 ///
8224 /// # Example
8225 /// ```ignore,no_run
8226 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8227 /// let x = ShipmentRoute::new().set_vehicle_index(42);
8228 /// ```
8229 pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8230 self.vehicle_index = v.into();
8231 self
8232 }
8233
8234 /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
8235 ///
8236 /// # Example
8237 /// ```ignore,no_run
8238 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8239 /// let x = ShipmentRoute::new().set_vehicle_label("example");
8240 /// ```
8241 pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8242 self.vehicle_label = v.into();
8243 self
8244 }
8245
8246 /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8247 ///
8248 /// # Example
8249 /// ```ignore,no_run
8250 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8251 /// use wkt::Timestamp;
8252 /// let x = ShipmentRoute::new().set_vehicle_start_time(Timestamp::default()/* use setters */);
8253 /// ```
8254 pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
8255 where
8256 T: std::convert::Into<wkt::Timestamp>,
8257 {
8258 self.vehicle_start_time = std::option::Option::Some(v.into());
8259 self
8260 }
8261
8262 /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8263 ///
8264 /// # Example
8265 /// ```ignore,no_run
8266 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8267 /// use wkt::Timestamp;
8268 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(Some(Timestamp::default()/* use setters */));
8269 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(None::<Timestamp>);
8270 /// ```
8271 pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8272 where
8273 T: std::convert::Into<wkt::Timestamp>,
8274 {
8275 self.vehicle_start_time = v.map(|x| x.into());
8276 self
8277 }
8278
8279 /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8280 ///
8281 /// # Example
8282 /// ```ignore,no_run
8283 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8284 /// use wkt::Timestamp;
8285 /// let x = ShipmentRoute::new().set_vehicle_end_time(Timestamp::default()/* use setters */);
8286 /// ```
8287 pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
8288 where
8289 T: std::convert::Into<wkt::Timestamp>,
8290 {
8291 self.vehicle_end_time = std::option::Option::Some(v.into());
8292 self
8293 }
8294
8295 /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8296 ///
8297 /// # Example
8298 /// ```ignore,no_run
8299 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8300 /// use wkt::Timestamp;
8301 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(Some(Timestamp::default()/* use setters */));
8302 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(None::<Timestamp>);
8303 /// ```
8304 pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
8305 where
8306 T: std::convert::Into<wkt::Timestamp>,
8307 {
8308 self.vehicle_end_time = v.map(|x| x.into());
8309 self
8310 }
8311
8312 /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
8313 ///
8314 /// # Example
8315 /// ```ignore,no_run
8316 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8317 /// use google_cloud_optimization_v1::model::shipment_route::Visit;
8318 /// let x = ShipmentRoute::new()
8319 /// .set_visits([
8320 /// Visit::default()/* use setters */,
8321 /// Visit::default()/* use (different) setters */,
8322 /// ]);
8323 /// ```
8324 pub fn set_visits<T, V>(mut self, v: T) -> Self
8325 where
8326 T: std::iter::IntoIterator<Item = V>,
8327 V: std::convert::Into<crate::model::shipment_route::Visit>,
8328 {
8329 use std::iter::Iterator;
8330 self.visits = v.into_iter().map(|i| i.into()).collect();
8331 self
8332 }
8333
8334 /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
8335 ///
8336 /// # Example
8337 /// ```ignore,no_run
8338 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8339 /// use google_cloud_optimization_v1::model::shipment_route::Transition;
8340 /// let x = ShipmentRoute::new()
8341 /// .set_transitions([
8342 /// Transition::default()/* use setters */,
8343 /// Transition::default()/* use (different) setters */,
8344 /// ]);
8345 /// ```
8346 pub fn set_transitions<T, V>(mut self, v: T) -> Self
8347 where
8348 T: std::iter::IntoIterator<Item = V>,
8349 V: std::convert::Into<crate::model::shipment_route::Transition>,
8350 {
8351 use std::iter::Iterator;
8352 self.transitions = v.into_iter().map(|i| i.into()).collect();
8353 self
8354 }
8355
8356 /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
8357 ///
8358 /// # Example
8359 /// ```ignore,no_run
8360 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8361 /// let x = ShipmentRoute::new().set_has_traffic_infeasibilities(true);
8362 /// ```
8363 pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8364 self.has_traffic_infeasibilities = v.into();
8365 self
8366 }
8367
8368 /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8369 ///
8370 /// # Example
8371 /// ```ignore,no_run
8372 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8373 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8374 /// let x = ShipmentRoute::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
8375 /// ```
8376 pub fn set_route_polyline<T>(mut self, v: T) -> Self
8377 where
8378 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8379 {
8380 self.route_polyline = std::option::Option::Some(v.into());
8381 self
8382 }
8383
8384 /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8385 ///
8386 /// # Example
8387 /// ```ignore,no_run
8388 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8389 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8390 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
8391 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
8392 /// ```
8393 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
8394 where
8395 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8396 {
8397 self.route_polyline = v.map(|x| x.into());
8398 self
8399 }
8400
8401 /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
8402 ///
8403 /// # Example
8404 /// ```ignore,no_run
8405 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8406 /// use google_cloud_optimization_v1::model::shipment_route::Break;
8407 /// let x = ShipmentRoute::new()
8408 /// .set_breaks([
8409 /// Break::default()/* use setters */,
8410 /// Break::default()/* use (different) setters */,
8411 /// ]);
8412 /// ```
8413 pub fn set_breaks<T, V>(mut self, v: T) -> Self
8414 where
8415 T: std::iter::IntoIterator<Item = V>,
8416 V: std::convert::Into<crate::model::shipment_route::Break>,
8417 {
8418 use std::iter::Iterator;
8419 self.breaks = v.into_iter().map(|i| i.into()).collect();
8420 self
8421 }
8422
8423 /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
8424 ///
8425 /// # Example
8426 /// ```ignore,no_run
8427 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8428 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8429 /// let x = ShipmentRoute::new().set_metrics(AggregatedMetrics::default()/* use setters */);
8430 /// ```
8431 pub fn set_metrics<T>(mut self, v: T) -> Self
8432 where
8433 T: std::convert::Into<crate::model::AggregatedMetrics>,
8434 {
8435 self.metrics = std::option::Option::Some(v.into());
8436 self
8437 }
8438
8439 /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
8440 ///
8441 /// # Example
8442 /// ```ignore,no_run
8443 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8444 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8445 /// let x = ShipmentRoute::new().set_or_clear_metrics(Some(AggregatedMetrics::default()/* use setters */));
8446 /// let x = ShipmentRoute::new().set_or_clear_metrics(None::<AggregatedMetrics>);
8447 /// ```
8448 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
8449 where
8450 T: std::convert::Into<crate::model::AggregatedMetrics>,
8451 {
8452 self.metrics = v.map(|x| x.into());
8453 self
8454 }
8455
8456 /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
8457 ///
8458 /// # Example
8459 /// ```ignore,no_run
8460 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8461 /// let x = ShipmentRoute::new().set_route_costs([
8462 /// ("key0", 123.5),
8463 /// ("key1", 456.5),
8464 /// ]);
8465 /// ```
8466 pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
8467 where
8468 T: std::iter::IntoIterator<Item = (K, V)>,
8469 K: std::convert::Into<std::string::String>,
8470 V: std::convert::Into<f64>,
8471 {
8472 use std::iter::Iterator;
8473 self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8474 self
8475 }
8476
8477 /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
8478 ///
8479 /// # Example
8480 /// ```ignore,no_run
8481 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8482 /// let x = ShipmentRoute::new().set_route_total_cost(42.0);
8483 /// ```
8484 pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8485 self.route_total_cost = v.into();
8486 self
8487 }
8488
8489 /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
8490 ///
8491 /// # Example
8492 /// ```ignore,no_run
8493 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8494 /// use google_cloud_optimization_v1::model::CapacityQuantity;
8495 /// let x = ShipmentRoute::new()
8496 /// .set_end_loads([
8497 /// CapacityQuantity::default()/* use setters */,
8498 /// CapacityQuantity::default()/* use (different) setters */,
8499 /// ]);
8500 /// ```
8501 #[deprecated]
8502 pub fn set_end_loads<T, V>(mut self, v: T) -> Self
8503 where
8504 T: std::iter::IntoIterator<Item = V>,
8505 V: std::convert::Into<crate::model::CapacityQuantity>,
8506 {
8507 use std::iter::Iterator;
8508 self.end_loads = v.into_iter().map(|i| i.into()).collect();
8509 self
8510 }
8511
8512 /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
8513 ///
8514 /// # Example
8515 /// ```ignore,no_run
8516 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8517 /// use google_cloud_optimization_v1::model::shipment_route::TravelStep;
8518 /// let x = ShipmentRoute::new()
8519 /// .set_travel_steps([
8520 /// TravelStep::default()/* use setters */,
8521 /// TravelStep::default()/* use (different) setters */,
8522 /// ]);
8523 /// ```
8524 #[deprecated]
8525 pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
8526 where
8527 T: std::iter::IntoIterator<Item = V>,
8528 V: std::convert::Into<crate::model::shipment_route::TravelStep>,
8529 {
8530 use std::iter::Iterator;
8531 self.travel_steps = v.into_iter().map(|i| i.into()).collect();
8532 self
8533 }
8534
8535 /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8536 ///
8537 /// # Example
8538 /// ```ignore,no_run
8539 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8540 /// use wkt::Duration;
8541 /// let x = ShipmentRoute::new().set_vehicle_detour(Duration::default()/* use setters */);
8542 /// ```
8543 #[deprecated]
8544 pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
8545 where
8546 T: std::convert::Into<wkt::Duration>,
8547 {
8548 self.vehicle_detour = std::option::Option::Some(v.into());
8549 self
8550 }
8551
8552 /// Sets or clears the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8553 ///
8554 /// # Example
8555 /// ```ignore,no_run
8556 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8557 /// use wkt::Duration;
8558 /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(Some(Duration::default()/* use setters */));
8559 /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(None::<Duration>);
8560 /// ```
8561 #[deprecated]
8562 pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
8563 where
8564 T: std::convert::Into<wkt::Duration>,
8565 {
8566 self.vehicle_detour = v.map(|x| x.into());
8567 self
8568 }
8569
8570 /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8571 ///
8572 /// # Example
8573 /// ```ignore,no_run
8574 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8575 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8576 /// let x = ShipmentRoute::new().set_delay_before_vehicle_end(Delay::default()/* use setters */);
8577 /// ```
8578 #[deprecated]
8579 pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
8580 where
8581 T: std::convert::Into<crate::model::shipment_route::Delay>,
8582 {
8583 self.delay_before_vehicle_end = std::option::Option::Some(v.into());
8584 self
8585 }
8586
8587 /// Sets or clears the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8588 ///
8589 /// # Example
8590 /// ```ignore,no_run
8591 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8592 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8593 /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(Some(Delay::default()/* use setters */));
8594 /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(None::<Delay>);
8595 /// ```
8596 #[deprecated]
8597 pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
8598 where
8599 T: std::convert::Into<crate::model::shipment_route::Delay>,
8600 {
8601 self.delay_before_vehicle_end = v.map(|x| x.into());
8602 self
8603 }
8604}
8605
8606impl wkt::message::Message for ShipmentRoute {
8607 fn typename() -> &'static str {
8608 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
8609 }
8610}
8611
8612/// Defines additional types related to [ShipmentRoute].
8613pub mod shipment_route {
8614 #[allow(unused_imports)]
8615 use super::*;
8616
8617 /// Deprecated: Use
8618 /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8619 /// instead. Time interval spent on the route resulting from a
8620 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8621 ///
8622 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8623 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8624 #[derive(Clone, Default, PartialEq)]
8625 #[non_exhaustive]
8626 #[deprecated]
8627 pub struct Delay {
8628 /// Start of the delay.
8629 pub start_time: std::option::Option<wkt::Timestamp>,
8630
8631 /// Duration of the delay.
8632 pub duration: std::option::Option<wkt::Duration>,
8633
8634 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8635 }
8636
8637 impl Delay {
8638 pub fn new() -> Self {
8639 std::default::Default::default()
8640 }
8641
8642 /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
8643 ///
8644 /// # Example
8645 /// ```ignore,no_run
8646 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8647 /// use wkt::Timestamp;
8648 /// let x = Delay::new().set_start_time(Timestamp::default()/* use setters */);
8649 /// ```
8650 pub fn set_start_time<T>(mut self, v: T) -> Self
8651 where
8652 T: std::convert::Into<wkt::Timestamp>,
8653 {
8654 self.start_time = std::option::Option::Some(v.into());
8655 self
8656 }
8657
8658 /// Sets or clears the value of [start_time][crate::model::shipment_route::Delay::start_time].
8659 ///
8660 /// # Example
8661 /// ```ignore,no_run
8662 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8663 /// use wkt::Timestamp;
8664 /// let x = Delay::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8665 /// let x = Delay::new().set_or_clear_start_time(None::<Timestamp>);
8666 /// ```
8667 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8668 where
8669 T: std::convert::Into<wkt::Timestamp>,
8670 {
8671 self.start_time = v.map(|x| x.into());
8672 self
8673 }
8674
8675 /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
8676 ///
8677 /// # Example
8678 /// ```ignore,no_run
8679 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8680 /// use wkt::Duration;
8681 /// let x = Delay::new().set_duration(Duration::default()/* use setters */);
8682 /// ```
8683 pub fn set_duration<T>(mut self, v: T) -> Self
8684 where
8685 T: std::convert::Into<wkt::Duration>,
8686 {
8687 self.duration = std::option::Option::Some(v.into());
8688 self
8689 }
8690
8691 /// Sets or clears the value of [duration][crate::model::shipment_route::Delay::duration].
8692 ///
8693 /// # Example
8694 /// ```ignore,no_run
8695 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8696 /// use wkt::Duration;
8697 /// let x = Delay::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
8698 /// let x = Delay::new().set_or_clear_duration(None::<Duration>);
8699 /// ```
8700 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
8701 where
8702 T: std::convert::Into<wkt::Duration>,
8703 {
8704 self.duration = v.map(|x| x.into());
8705 self
8706 }
8707 }
8708
8709 impl wkt::message::Message for Delay {
8710 fn typename() -> &'static str {
8711 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
8712 }
8713 }
8714
8715 /// A visit performed during a route. This visit corresponds to a pickup or a
8716 /// delivery of a `Shipment`.
8717 #[derive(Clone, Default, PartialEq)]
8718 #[non_exhaustive]
8719 pub struct Visit {
8720 /// Index of the `shipments` field in the source
8721 /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
8722 ///
8723 /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
8724 pub shipment_index: i32,
8725
8726 /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
8727 /// corresponds to a delivery.
8728 pub is_pickup: bool,
8729
8730 /// Index of `VisitRequest` in either the pickup or delivery field of the
8731 /// `Shipment` (see `is_pickup`).
8732 pub visit_request_index: i32,
8733
8734 /// Time at which the visit starts. Note that the vehicle may arrive earlier
8735 /// than this at the visit location. Times are consistent with the
8736 /// `ShipmentModel`.
8737 pub start_time: std::option::Option<wkt::Timestamp>,
8738
8739 /// Total visit load demand as the sum of the shipment and the visit request
8740 /// `load_demands`. The values are negative if the visit is a delivery.
8741 /// Demands are reported for the same types as the
8742 /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
8743 /// (see this field).
8744 ///
8745 /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
8746 pub load_demands:
8747 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
8748
8749 /// Extra detour time due to the shipments visited on the route before the
8750 /// visit and to the potential waiting time induced by time windows.
8751 /// If the visit is a delivery, the detour is computed from the corresponding
8752 /// pickup visit and is equal to:
8753 ///
8754 /// ```norust
8755 /// start_time(delivery) - start_time(pickup)
8756 /// - (duration(pickup) + travel duration from the pickup location
8757 /// to the delivery location).
8758 /// ```
8759 ///
8760 /// Otherwise, it is computed from the vehicle `start_location` and is equal
8761 /// to:
8762 ///
8763 /// ```norust
8764 /// start_time - vehicle_start_time - travel duration from
8765 /// the vehicle's `start_location` to the visit.
8766 /// ```
8767 pub detour: std::option::Option<wkt::Duration>,
8768
8769 /// Copy of the corresponding `Shipment.label`, if specified in the
8770 /// `Shipment`.
8771 pub shipment_label: std::string::String,
8772
8773 /// Copy of the corresponding
8774 /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
8775 /// if specified in the `VisitRequest`.
8776 ///
8777 /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
8778 pub visit_label: std::string::String,
8779
8780 /// Deprecated: Use
8781 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8782 /// instead. Vehicle loads upon arrival at the visit location, for each type
8783 /// specified in
8784 /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8785 /// `start_load_intervals`, `end_load_intervals` or `demands`.
8786 ///
8787 /// Exception: we omit loads for quantity types unconstrained by intervals
8788 /// and that don't have any non-zero demand on the route.
8789 ///
8790 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8791 /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8792 #[deprecated]
8793 pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8794
8795 /// Deprecated: Use
8796 /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8797 /// instead. Delay occurring before the visit starts.
8798 ///
8799 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8800 #[deprecated]
8801 pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
8802
8803 /// Deprecated: Use
8804 /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
8805 /// instead.
8806 ///
8807 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
8808 #[deprecated]
8809 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
8810
8811 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8812 }
8813
8814 impl Visit {
8815 pub fn new() -> Self {
8816 std::default::Default::default()
8817 }
8818
8819 /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
8820 ///
8821 /// # Example
8822 /// ```ignore,no_run
8823 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8824 /// let x = Visit::new().set_shipment_index(42);
8825 /// ```
8826 pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8827 self.shipment_index = v.into();
8828 self
8829 }
8830
8831 /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
8832 ///
8833 /// # Example
8834 /// ```ignore,no_run
8835 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8836 /// let x = Visit::new().set_is_pickup(true);
8837 /// ```
8838 pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8839 self.is_pickup = v.into();
8840 self
8841 }
8842
8843 /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
8844 ///
8845 /// # Example
8846 /// ```ignore,no_run
8847 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8848 /// let x = Visit::new().set_visit_request_index(42);
8849 /// ```
8850 pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8851 self.visit_request_index = v.into();
8852 self
8853 }
8854
8855 /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
8856 ///
8857 /// # Example
8858 /// ```ignore,no_run
8859 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8860 /// use wkt::Timestamp;
8861 /// let x = Visit::new().set_start_time(Timestamp::default()/* use setters */);
8862 /// ```
8863 pub fn set_start_time<T>(mut self, v: T) -> Self
8864 where
8865 T: std::convert::Into<wkt::Timestamp>,
8866 {
8867 self.start_time = std::option::Option::Some(v.into());
8868 self
8869 }
8870
8871 /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
8872 ///
8873 /// # Example
8874 /// ```ignore,no_run
8875 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8876 /// use wkt::Timestamp;
8877 /// let x = Visit::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8878 /// let x = Visit::new().set_or_clear_start_time(None::<Timestamp>);
8879 /// ```
8880 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8881 where
8882 T: std::convert::Into<wkt::Timestamp>,
8883 {
8884 self.start_time = v.map(|x| x.into());
8885 self
8886 }
8887
8888 /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
8889 ///
8890 /// # Example
8891 /// ```ignore,no_run
8892 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8893 /// use google_cloud_optimization_v1::model::shipment::Load;
8894 /// let x = Visit::new().set_load_demands([
8895 /// ("key0", Load::default()/* use setters */),
8896 /// ("key1", Load::default()/* use (different) setters */),
8897 /// ]);
8898 /// ```
8899 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
8900 where
8901 T: std::iter::IntoIterator<Item = (K, V)>,
8902 K: std::convert::Into<std::string::String>,
8903 V: std::convert::Into<crate::model::shipment::Load>,
8904 {
8905 use std::iter::Iterator;
8906 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8907 self
8908 }
8909
8910 /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
8911 ///
8912 /// # Example
8913 /// ```ignore,no_run
8914 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8915 /// use wkt::Duration;
8916 /// let x = Visit::new().set_detour(Duration::default()/* use setters */);
8917 /// ```
8918 pub fn set_detour<T>(mut self, v: T) -> Self
8919 where
8920 T: std::convert::Into<wkt::Duration>,
8921 {
8922 self.detour = std::option::Option::Some(v.into());
8923 self
8924 }
8925
8926 /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
8927 ///
8928 /// # Example
8929 /// ```ignore,no_run
8930 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8931 /// use wkt::Duration;
8932 /// let x = Visit::new().set_or_clear_detour(Some(Duration::default()/* use setters */));
8933 /// let x = Visit::new().set_or_clear_detour(None::<Duration>);
8934 /// ```
8935 pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
8936 where
8937 T: std::convert::Into<wkt::Duration>,
8938 {
8939 self.detour = v.map(|x| x.into());
8940 self
8941 }
8942
8943 /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
8944 ///
8945 /// # Example
8946 /// ```ignore,no_run
8947 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8948 /// let x = Visit::new().set_shipment_label("example");
8949 /// ```
8950 pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
8951 mut self,
8952 v: T,
8953 ) -> Self {
8954 self.shipment_label = v.into();
8955 self
8956 }
8957
8958 /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
8959 ///
8960 /// # Example
8961 /// ```ignore,no_run
8962 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8963 /// let x = Visit::new().set_visit_label("example");
8964 /// ```
8965 pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8966 self.visit_label = v.into();
8967 self
8968 }
8969
8970 /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
8971 ///
8972 /// # Example
8973 /// ```ignore,no_run
8974 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8975 /// use google_cloud_optimization_v1::model::CapacityQuantity;
8976 /// let x = Visit::new()
8977 /// .set_arrival_loads([
8978 /// CapacityQuantity::default()/* use setters */,
8979 /// CapacityQuantity::default()/* use (different) setters */,
8980 /// ]);
8981 /// ```
8982 #[deprecated]
8983 pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
8984 where
8985 T: std::iter::IntoIterator<Item = V>,
8986 V: std::convert::Into<crate::model::CapacityQuantity>,
8987 {
8988 use std::iter::Iterator;
8989 self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
8990 self
8991 }
8992
8993 /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
8994 ///
8995 /// # Example
8996 /// ```ignore,no_run
8997 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8998 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8999 /// let x = Visit::new().set_delay_before_start(Delay::default()/* use setters */);
9000 /// ```
9001 #[deprecated]
9002 pub fn set_delay_before_start<T>(mut self, v: T) -> Self
9003 where
9004 T: std::convert::Into<crate::model::shipment_route::Delay>,
9005 {
9006 self.delay_before_start = std::option::Option::Some(v.into());
9007 self
9008 }
9009
9010 /// Sets or clears the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
9011 ///
9012 /// # Example
9013 /// ```ignore,no_run
9014 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9015 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
9016 /// let x = Visit::new().set_or_clear_delay_before_start(Some(Delay::default()/* use setters */));
9017 /// let x = Visit::new().set_or_clear_delay_before_start(None::<Delay>);
9018 /// ```
9019 #[deprecated]
9020 pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
9021 where
9022 T: std::convert::Into<crate::model::shipment_route::Delay>,
9023 {
9024 self.delay_before_start = v.map(|x| x.into());
9025 self
9026 }
9027
9028 /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
9029 ///
9030 /// # Example
9031 /// ```ignore,no_run
9032 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9033 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9034 /// let x = Visit::new()
9035 /// .set_demands([
9036 /// CapacityQuantity::default()/* use setters */,
9037 /// CapacityQuantity::default()/* use (different) setters */,
9038 /// ]);
9039 /// ```
9040 #[deprecated]
9041 pub fn set_demands<T, V>(mut self, v: T) -> Self
9042 where
9043 T: std::iter::IntoIterator<Item = V>,
9044 V: std::convert::Into<crate::model::CapacityQuantity>,
9045 {
9046 use std::iter::Iterator;
9047 self.demands = v.into_iter().map(|i| i.into()).collect();
9048 self
9049 }
9050 }
9051
9052 impl wkt::message::Message for Visit {
9053 fn typename() -> &'static str {
9054 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
9055 }
9056 }
9057
9058 /// Transition between two events on the route. See the description of
9059 /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
9060 ///
9061 /// If the vehicle does not have a `start_location` and/or `end_location`, the
9062 /// corresponding travel metrics are 0.
9063 ///
9064 /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
9065 #[derive(Clone, Default, PartialEq)]
9066 #[non_exhaustive]
9067 pub struct Transition {
9068 /// Travel duration during this transition.
9069 pub travel_duration: std::option::Option<wkt::Duration>,
9070
9071 /// Distance traveled during the transition.
9072 pub travel_distance_meters: f64,
9073
9074 /// When traffic is requested via
9075 /// [OptimizeToursRequest.consider_road_traffic]
9076 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9077 /// and the traffic info couldn't be retrieved for a `Transition`, this
9078 /// boolean is set to true. This may be temporary (rare hiccup in the
9079 /// realtime traffic servers) or permanent (no data for this location).
9080 pub traffic_info_unavailable: bool,
9081
9082 /// Sum of the delay durations applied to this transition. If any, the delay
9083 /// starts exactly `delay_duration` seconds before the next event (visit or
9084 /// vehicle end). See
9085 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
9086 ///
9087 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
9088 pub delay_duration: std::option::Option<wkt::Duration>,
9089
9090 /// Sum of the duration of the breaks occurring during this transition, if
9091 /// any. Details about each break's start time and duration are stored in
9092 /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
9093 ///
9094 /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
9095 pub break_duration: std::option::Option<wkt::Duration>,
9096
9097 /// Time spent waiting during this transition. Wait duration corresponds to
9098 /// idle time and does not include break time. Also note that this wait time
9099 /// may be split into several non-contiguous intervals.
9100 pub wait_duration: std::option::Option<wkt::Duration>,
9101
9102 /// Total duration of the transition, provided for convenience. It is equal
9103 /// to:
9104 ///
9105 /// * next visit `start_time` (or `vehicle_end_time` if this is the last
9106 /// transition) - this transition's `start_time`;
9107 /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
9108 /// additionally holds: `total_duration = travel_duration + delay_duration
9109 ///
9110 /// + break_duration + wait_duration`.
9111 pub total_duration: std::option::Option<wkt::Duration>,
9112
9113 /// Start time of this transition.
9114 pub start_time: std::option::Option<wkt::Timestamp>,
9115
9116 /// The encoded polyline representation of the route followed during the
9117 /// transition.
9118 /// This field is only populated if [populate_transition_polylines]
9119 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
9120 /// is set to true.
9121 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9122
9123 /// Vehicle loads during this transition, for each type that either appears
9124 /// in this vehicle's
9125 /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
9126 /// or that have non-zero
9127 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
9128 /// on some shipment performed on this route.
9129 ///
9130 /// The loads during the first transition are the starting loads of the
9131 /// vehicle route. Then, after each visit, the visit's `load_demands` are
9132 /// either added or subtracted to get the next transition's loads, depending
9133 /// on whether the visit was a pickup or a delivery.
9134 ///
9135 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
9136 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
9137 pub vehicle_loads: std::collections::HashMap<
9138 std::string::String,
9139 crate::model::shipment_route::VehicleLoad,
9140 >,
9141
9142 /// Deprecated: Use
9143 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
9144 /// instead.
9145 ///
9146 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9147 #[deprecated]
9148 pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
9149
9150 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9151 }
9152
9153 impl Transition {
9154 pub fn new() -> Self {
9155 std::default::Default::default()
9156 }
9157
9158 /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9159 ///
9160 /// # Example
9161 /// ```ignore,no_run
9162 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9163 /// use wkt::Duration;
9164 /// let x = Transition::new().set_travel_duration(Duration::default()/* use setters */);
9165 /// ```
9166 pub fn set_travel_duration<T>(mut self, v: T) -> Self
9167 where
9168 T: std::convert::Into<wkt::Duration>,
9169 {
9170 self.travel_duration = std::option::Option::Some(v.into());
9171 self
9172 }
9173
9174 /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9175 ///
9176 /// # Example
9177 /// ```ignore,no_run
9178 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9179 /// use wkt::Duration;
9180 /// let x = Transition::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
9181 /// let x = Transition::new().set_or_clear_travel_duration(None::<Duration>);
9182 /// ```
9183 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
9184 where
9185 T: std::convert::Into<wkt::Duration>,
9186 {
9187 self.travel_duration = v.map(|x| x.into());
9188 self
9189 }
9190
9191 /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
9192 ///
9193 /// # Example
9194 /// ```ignore,no_run
9195 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9196 /// let x = Transition::new().set_travel_distance_meters(42.0);
9197 /// ```
9198 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9199 self.travel_distance_meters = v.into();
9200 self
9201 }
9202
9203 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
9204 ///
9205 /// # Example
9206 /// ```ignore,no_run
9207 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9208 /// let x = Transition::new().set_traffic_info_unavailable(true);
9209 /// ```
9210 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9211 self.traffic_info_unavailable = v.into();
9212 self
9213 }
9214
9215 /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9216 ///
9217 /// # Example
9218 /// ```ignore,no_run
9219 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9220 /// use wkt::Duration;
9221 /// let x = Transition::new().set_delay_duration(Duration::default()/* use setters */);
9222 /// ```
9223 pub fn set_delay_duration<T>(mut self, v: T) -> Self
9224 where
9225 T: std::convert::Into<wkt::Duration>,
9226 {
9227 self.delay_duration = std::option::Option::Some(v.into());
9228 self
9229 }
9230
9231 /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9232 ///
9233 /// # Example
9234 /// ```ignore,no_run
9235 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9236 /// use wkt::Duration;
9237 /// let x = Transition::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
9238 /// let x = Transition::new().set_or_clear_delay_duration(None::<Duration>);
9239 /// ```
9240 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
9241 where
9242 T: std::convert::Into<wkt::Duration>,
9243 {
9244 self.delay_duration = v.map(|x| x.into());
9245 self
9246 }
9247
9248 /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9249 ///
9250 /// # Example
9251 /// ```ignore,no_run
9252 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9253 /// use wkt::Duration;
9254 /// let x = Transition::new().set_break_duration(Duration::default()/* use setters */);
9255 /// ```
9256 pub fn set_break_duration<T>(mut self, v: T) -> Self
9257 where
9258 T: std::convert::Into<wkt::Duration>,
9259 {
9260 self.break_duration = std::option::Option::Some(v.into());
9261 self
9262 }
9263
9264 /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9265 ///
9266 /// # Example
9267 /// ```ignore,no_run
9268 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9269 /// use wkt::Duration;
9270 /// let x = Transition::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
9271 /// let x = Transition::new().set_or_clear_break_duration(None::<Duration>);
9272 /// ```
9273 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
9274 where
9275 T: std::convert::Into<wkt::Duration>,
9276 {
9277 self.break_duration = v.map(|x| x.into());
9278 self
9279 }
9280
9281 /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9282 ///
9283 /// # Example
9284 /// ```ignore,no_run
9285 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9286 /// use wkt::Duration;
9287 /// let x = Transition::new().set_wait_duration(Duration::default()/* use setters */);
9288 /// ```
9289 pub fn set_wait_duration<T>(mut self, v: T) -> Self
9290 where
9291 T: std::convert::Into<wkt::Duration>,
9292 {
9293 self.wait_duration = std::option::Option::Some(v.into());
9294 self
9295 }
9296
9297 /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9298 ///
9299 /// # Example
9300 /// ```ignore,no_run
9301 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9302 /// use wkt::Duration;
9303 /// let x = Transition::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
9304 /// let x = Transition::new().set_or_clear_wait_duration(None::<Duration>);
9305 /// ```
9306 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
9307 where
9308 T: std::convert::Into<wkt::Duration>,
9309 {
9310 self.wait_duration = v.map(|x| x.into());
9311 self
9312 }
9313
9314 /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9315 ///
9316 /// # Example
9317 /// ```ignore,no_run
9318 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9319 /// use wkt::Duration;
9320 /// let x = Transition::new().set_total_duration(Duration::default()/* use setters */);
9321 /// ```
9322 pub fn set_total_duration<T>(mut self, v: T) -> Self
9323 where
9324 T: std::convert::Into<wkt::Duration>,
9325 {
9326 self.total_duration = std::option::Option::Some(v.into());
9327 self
9328 }
9329
9330 /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9331 ///
9332 /// # Example
9333 /// ```ignore,no_run
9334 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9335 /// use wkt::Duration;
9336 /// let x = Transition::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
9337 /// let x = Transition::new().set_or_clear_total_duration(None::<Duration>);
9338 /// ```
9339 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
9340 where
9341 T: std::convert::Into<wkt::Duration>,
9342 {
9343 self.total_duration = v.map(|x| x.into());
9344 self
9345 }
9346
9347 /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
9348 ///
9349 /// # Example
9350 /// ```ignore,no_run
9351 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9352 /// use wkt::Timestamp;
9353 /// let x = Transition::new().set_start_time(Timestamp::default()/* use setters */);
9354 /// ```
9355 pub fn set_start_time<T>(mut self, v: T) -> Self
9356 where
9357 T: std::convert::Into<wkt::Timestamp>,
9358 {
9359 self.start_time = std::option::Option::Some(v.into());
9360 self
9361 }
9362
9363 /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
9364 ///
9365 /// # Example
9366 /// ```ignore,no_run
9367 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9368 /// use wkt::Timestamp;
9369 /// let x = Transition::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9370 /// let x = Transition::new().set_or_clear_start_time(None::<Timestamp>);
9371 /// ```
9372 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9373 where
9374 T: std::convert::Into<wkt::Timestamp>,
9375 {
9376 self.start_time = v.map(|x| x.into());
9377 self
9378 }
9379
9380 /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9381 ///
9382 /// # Example
9383 /// ```ignore,no_run
9384 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9385 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9386 /// let x = Transition::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9387 /// ```
9388 pub fn set_route_polyline<T>(mut self, v: T) -> Self
9389 where
9390 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9391 {
9392 self.route_polyline = std::option::Option::Some(v.into());
9393 self
9394 }
9395
9396 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9397 ///
9398 /// # Example
9399 /// ```ignore,no_run
9400 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9401 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9402 /// let x = Transition::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9403 /// let x = Transition::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9404 /// ```
9405 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9406 where
9407 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9408 {
9409 self.route_polyline = v.map(|x| x.into());
9410 self
9411 }
9412
9413 /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
9414 ///
9415 /// # Example
9416 /// ```ignore,no_run
9417 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9418 /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9419 /// let x = Transition::new().set_vehicle_loads([
9420 /// ("key0", VehicleLoad::default()/* use setters */),
9421 /// ("key1", VehicleLoad::default()/* use (different) setters */),
9422 /// ]);
9423 /// ```
9424 pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
9425 where
9426 T: std::iter::IntoIterator<Item = (K, V)>,
9427 K: std::convert::Into<std::string::String>,
9428 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
9429 {
9430 use std::iter::Iterator;
9431 self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
9432 self
9433 }
9434
9435 /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
9436 ///
9437 /// # Example
9438 /// ```ignore,no_run
9439 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9440 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9441 /// let x = Transition::new()
9442 /// .set_loads([
9443 /// CapacityQuantity::default()/* use setters */,
9444 /// CapacityQuantity::default()/* use (different) setters */,
9445 /// ]);
9446 /// ```
9447 #[deprecated]
9448 pub fn set_loads<T, V>(mut self, v: T) -> Self
9449 where
9450 T: std::iter::IntoIterator<Item = V>,
9451 V: std::convert::Into<crate::model::CapacityQuantity>,
9452 {
9453 use std::iter::Iterator;
9454 self.loads = v.into_iter().map(|i| i.into()).collect();
9455 self
9456 }
9457 }
9458
9459 impl wkt::message::Message for Transition {
9460 fn typename() -> &'static str {
9461 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
9462 }
9463 }
9464
9465 /// Reports the actual load of the vehicle at some point along the route,
9466 /// for a given type (see
9467 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
9468 ///
9469 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9470 #[derive(Clone, Default, PartialEq)]
9471 #[non_exhaustive]
9472 pub struct VehicleLoad {
9473 /// The amount of load on the vehicle, for the given type. The unit of load
9474 /// is usually indicated by the type. See
9475 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
9476 ///
9477 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9478 pub amount: i64,
9479
9480 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9481 }
9482
9483 impl VehicleLoad {
9484 pub fn new() -> Self {
9485 std::default::Default::default()
9486 }
9487
9488 /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
9489 ///
9490 /// # Example
9491 /// ```ignore,no_run
9492 /// # use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9493 /// let x = VehicleLoad::new().set_amount(42);
9494 /// ```
9495 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9496 self.amount = v.into();
9497 self
9498 }
9499 }
9500
9501 impl wkt::message::Message for VehicleLoad {
9502 fn typename() -> &'static str {
9503 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
9504 }
9505 }
9506
9507 /// The encoded representation of a polyline. More information on polyline
9508 /// encoding can be found here:
9509 /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
9510 /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
9511 #[derive(Clone, Default, PartialEq)]
9512 #[non_exhaustive]
9513 pub struct EncodedPolyline {
9514 /// String representing encoded points of the polyline.
9515 pub points: std::string::String,
9516
9517 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9518 }
9519
9520 impl EncodedPolyline {
9521 pub fn new() -> Self {
9522 std::default::Default::default()
9523 }
9524
9525 /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
9526 ///
9527 /// # Example
9528 /// ```ignore,no_run
9529 /// # use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9530 /// let x = EncodedPolyline::new().set_points("example");
9531 /// ```
9532 pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9533 self.points = v.into();
9534 self
9535 }
9536 }
9537
9538 impl wkt::message::Message for EncodedPolyline {
9539 fn typename() -> &'static str {
9540 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
9541 }
9542 }
9543
9544 /// Data representing the execution of a break.
9545 #[derive(Clone, Default, PartialEq)]
9546 #[non_exhaustive]
9547 pub struct Break {
9548 /// Start time of a break.
9549 pub start_time: std::option::Option<wkt::Timestamp>,
9550
9551 /// Duration of a break.
9552 pub duration: std::option::Option<wkt::Duration>,
9553
9554 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9555 }
9556
9557 impl Break {
9558 pub fn new() -> Self {
9559 std::default::Default::default()
9560 }
9561
9562 /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
9563 ///
9564 /// # Example
9565 /// ```ignore,no_run
9566 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9567 /// use wkt::Timestamp;
9568 /// let x = Break::new().set_start_time(Timestamp::default()/* use setters */);
9569 /// ```
9570 pub fn set_start_time<T>(mut self, v: T) -> Self
9571 where
9572 T: std::convert::Into<wkt::Timestamp>,
9573 {
9574 self.start_time = std::option::Option::Some(v.into());
9575 self
9576 }
9577
9578 /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
9579 ///
9580 /// # Example
9581 /// ```ignore,no_run
9582 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9583 /// use wkt::Timestamp;
9584 /// let x = Break::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9585 /// let x = Break::new().set_or_clear_start_time(None::<Timestamp>);
9586 /// ```
9587 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9588 where
9589 T: std::convert::Into<wkt::Timestamp>,
9590 {
9591 self.start_time = v.map(|x| x.into());
9592 self
9593 }
9594
9595 /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
9596 ///
9597 /// # Example
9598 /// ```ignore,no_run
9599 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9600 /// use wkt::Duration;
9601 /// let x = Break::new().set_duration(Duration::default()/* use setters */);
9602 /// ```
9603 pub fn set_duration<T>(mut self, v: T) -> Self
9604 where
9605 T: std::convert::Into<wkt::Duration>,
9606 {
9607 self.duration = std::option::Option::Some(v.into());
9608 self
9609 }
9610
9611 /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
9612 ///
9613 /// # Example
9614 /// ```ignore,no_run
9615 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9616 /// use wkt::Duration;
9617 /// let x = Break::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9618 /// let x = Break::new().set_or_clear_duration(None::<Duration>);
9619 /// ```
9620 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9621 where
9622 T: std::convert::Into<wkt::Duration>,
9623 {
9624 self.duration = v.map(|x| x.into());
9625 self
9626 }
9627 }
9628
9629 impl wkt::message::Message for Break {
9630 fn typename() -> &'static str {
9631 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
9632 }
9633 }
9634
9635 /// Deprecated: Use
9636 /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
9637 /// instead. Travel between each visit along the route: from the vehicle's
9638 /// `start_location` to the first visit's `arrival_location`, then from the
9639 /// first visit's `departure_location` to the second visit's
9640 /// `arrival_location`, and so on until the vehicle's `end_location`. This
9641 /// accounts only for the actual travel between visits, not counting the
9642 /// waiting time, the time spent performing a visit, nor the distance covered
9643 /// during a visit.
9644 ///
9645 /// Invariant: `travel_steps_size() == visits_size() + 1`.
9646 ///
9647 /// If the vehicle does not have a start_ and/or end_location, the
9648 /// corresponding travel metrics are 0 and/or empty.
9649 ///
9650 /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
9651 #[derive(Clone, Default, PartialEq)]
9652 #[non_exhaustive]
9653 #[deprecated]
9654 pub struct TravelStep {
9655 /// Duration of the travel step.
9656 pub duration: std::option::Option<wkt::Duration>,
9657
9658 /// Distance traveled during the step.
9659 pub distance_meters: f64,
9660
9661 /// When traffic is requested via
9662 /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9663 /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
9664 /// is set to true. This may be temporary (rare hiccup in the realtime
9665 /// traffic servers) or permanent (no data for this location).
9666 ///
9667 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
9668 pub traffic_info_unavailable: bool,
9669
9670 /// The encoded polyline representation of the route followed during the
9671 /// step.
9672 ///
9673 /// This field is only populated if
9674 /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
9675 /// is set to true.
9676 ///
9677 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
9678 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9679
9680 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9681 }
9682
9683 impl TravelStep {
9684 pub fn new() -> Self {
9685 std::default::Default::default()
9686 }
9687
9688 /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
9689 ///
9690 /// # Example
9691 /// ```ignore,no_run
9692 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9693 /// use wkt::Duration;
9694 /// let x = TravelStep::new().set_duration(Duration::default()/* use setters */);
9695 /// ```
9696 pub fn set_duration<T>(mut self, v: T) -> Self
9697 where
9698 T: std::convert::Into<wkt::Duration>,
9699 {
9700 self.duration = std::option::Option::Some(v.into());
9701 self
9702 }
9703
9704 /// Sets or clears the value of [duration][crate::model::shipment_route::TravelStep::duration].
9705 ///
9706 /// # Example
9707 /// ```ignore,no_run
9708 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9709 /// use wkt::Duration;
9710 /// let x = TravelStep::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9711 /// let x = TravelStep::new().set_or_clear_duration(None::<Duration>);
9712 /// ```
9713 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9714 where
9715 T: std::convert::Into<wkt::Duration>,
9716 {
9717 self.duration = v.map(|x| x.into());
9718 self
9719 }
9720
9721 /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
9722 ///
9723 /// # Example
9724 /// ```ignore,no_run
9725 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9726 /// let x = TravelStep::new().set_distance_meters(42.0);
9727 /// ```
9728 pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9729 self.distance_meters = v.into();
9730 self
9731 }
9732
9733 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
9734 ///
9735 /// # Example
9736 /// ```ignore,no_run
9737 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9738 /// let x = TravelStep::new().set_traffic_info_unavailable(true);
9739 /// ```
9740 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9741 self.traffic_info_unavailable = v.into();
9742 self
9743 }
9744
9745 /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9746 ///
9747 /// # Example
9748 /// ```ignore,no_run
9749 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9750 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9751 /// let x = TravelStep::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9752 /// ```
9753 pub fn set_route_polyline<T>(mut self, v: T) -> Self
9754 where
9755 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9756 {
9757 self.route_polyline = std::option::Option::Some(v.into());
9758 self
9759 }
9760
9761 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9762 ///
9763 /// # Example
9764 /// ```ignore,no_run
9765 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9766 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9767 /// let x = TravelStep::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9768 /// let x = TravelStep::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9769 /// ```
9770 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9771 where
9772 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9773 {
9774 self.route_polyline = v.map(|x| x.into());
9775 self
9776 }
9777 }
9778
9779 impl wkt::message::Message for TravelStep {
9780 fn typename() -> &'static str {
9781 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
9782 }
9783 }
9784}
9785
9786/// Specifies details of unperformed shipments in a solution. For trivial cases
9787/// and/or if we are able to identify the cause for skipping, we report the
9788/// reason here.
9789#[derive(Clone, Default, PartialEq)]
9790#[non_exhaustive]
9791pub struct SkippedShipment {
9792 /// The index corresponds to the index of the shipment in the source
9793 /// `ShipmentModel`.
9794 pub index: i32,
9795
9796 /// Copy of the corresponding
9797 /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
9798 /// in the `Shipment`.
9799 ///
9800 /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
9801 pub label: std::string::String,
9802
9803 /// A list of reasons that explain why the shipment was skipped. See comment
9804 /// above `Reason`.
9805 pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
9806
9807 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9808}
9809
9810impl SkippedShipment {
9811 pub fn new() -> Self {
9812 std::default::Default::default()
9813 }
9814
9815 /// Sets the value of [index][crate::model::SkippedShipment::index].
9816 ///
9817 /// # Example
9818 /// ```ignore,no_run
9819 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9820 /// let x = SkippedShipment::new().set_index(42);
9821 /// ```
9822 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9823 self.index = v.into();
9824 self
9825 }
9826
9827 /// Sets the value of [label][crate::model::SkippedShipment::label].
9828 ///
9829 /// # Example
9830 /// ```ignore,no_run
9831 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9832 /// let x = SkippedShipment::new().set_label("example");
9833 /// ```
9834 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9835 self.label = v.into();
9836 self
9837 }
9838
9839 /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
9840 ///
9841 /// # Example
9842 /// ```ignore,no_run
9843 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9844 /// use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9845 /// let x = SkippedShipment::new()
9846 /// .set_reasons([
9847 /// Reason::default()/* use setters */,
9848 /// Reason::default()/* use (different) setters */,
9849 /// ]);
9850 /// ```
9851 pub fn set_reasons<T, V>(mut self, v: T) -> Self
9852 where
9853 T: std::iter::IntoIterator<Item = V>,
9854 V: std::convert::Into<crate::model::skipped_shipment::Reason>,
9855 {
9856 use std::iter::Iterator;
9857 self.reasons = v.into_iter().map(|i| i.into()).collect();
9858 self
9859 }
9860}
9861
9862impl wkt::message::Message for SkippedShipment {
9863 fn typename() -> &'static str {
9864 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
9865 }
9866}
9867
9868/// Defines additional types related to [SkippedShipment].
9869pub mod skipped_shipment {
9870 #[allow(unused_imports)]
9871 use super::*;
9872
9873 /// If we can explain why the shipment was skipped, reasons will be listed
9874 /// here. If the reason is not the same for all vehicles, `reason` will have
9875 /// more than 1 element. A skipped shipment cannot have duplicate reasons,
9876 /// i.e. where all fields are the same except for `example_vehicle_index`.
9877 /// Example:
9878 ///
9879 /// ```norust
9880 /// reasons {
9881 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9882 /// example_vehicle_index: 1
9883 /// example_exceeded_capacity_type: "Apples"
9884 /// }
9885 /// reasons {
9886 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9887 /// example_vehicle_index: 3
9888 /// example_exceeded_capacity_type: "Pears"
9889 /// }
9890 /// reasons {
9891 /// code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
9892 /// example_vehicle_index: 1
9893 /// }
9894 /// ```
9895 ///
9896 /// The skipped shipment is incompatible with all vehicles. The reasons may
9897 /// be different for all vehicles but at least one vehicle's "Apples"
9898 /// capacity would be exceeded (including vehicle 1), at least one vehicle's
9899 /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
9900 /// vehicle's distance limit would be exceeded (including vehicle 1).
9901 #[derive(Clone, Default, PartialEq)]
9902 #[non_exhaustive]
9903 pub struct Reason {
9904 /// Refer to the comments of Code.
9905 pub code: crate::model::skipped_shipment::reason::Code,
9906
9907 /// If the reason is related to a shipment-vehicle incompatibility, this
9908 /// field provides the index of one relevant vehicle.
9909 pub example_vehicle_index: std::option::Option<i32>,
9910
9911 /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
9912 /// capacity type that is exceeded.
9913 pub example_exceeded_capacity_type: std::string::String,
9914
9915 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9916 }
9917
9918 impl Reason {
9919 pub fn new() -> Self {
9920 std::default::Default::default()
9921 }
9922
9923 /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
9924 ///
9925 /// # Example
9926 /// ```ignore,no_run
9927 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9928 /// use google_cloud_optimization_v1::model::skipped_shipment::reason::Code;
9929 /// let x0 = Reason::new().set_code(Code::NoVehicle);
9930 /// let x1 = Reason::new().set_code(Code::DemandExceedsVehicleCapacity);
9931 /// let x2 = Reason::new().set_code(Code::CannotBePerformedWithinVehicleDistanceLimit);
9932 /// ```
9933 pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
9934 mut self,
9935 v: T,
9936 ) -> Self {
9937 self.code = v.into();
9938 self
9939 }
9940
9941 /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9942 ///
9943 /// # Example
9944 /// ```ignore,no_run
9945 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9946 /// let x = Reason::new().set_example_vehicle_index(42);
9947 /// ```
9948 pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
9949 where
9950 T: std::convert::Into<i32>,
9951 {
9952 self.example_vehicle_index = std::option::Option::Some(v.into());
9953 self
9954 }
9955
9956 /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9957 ///
9958 /// # Example
9959 /// ```ignore,no_run
9960 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9961 /// let x = Reason::new().set_or_clear_example_vehicle_index(Some(42));
9962 /// let x = Reason::new().set_or_clear_example_vehicle_index(None::<i32>);
9963 /// ```
9964 pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
9965 where
9966 T: std::convert::Into<i32>,
9967 {
9968 self.example_vehicle_index = v.map(|x| x.into());
9969 self
9970 }
9971
9972 /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
9973 ///
9974 /// # Example
9975 /// ```ignore,no_run
9976 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9977 /// let x = Reason::new().set_example_exceeded_capacity_type("example");
9978 /// ```
9979 pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
9980 mut self,
9981 v: T,
9982 ) -> Self {
9983 self.example_exceeded_capacity_type = v.into();
9984 self
9985 }
9986 }
9987
9988 impl wkt::message::Message for Reason {
9989 fn typename() -> &'static str {
9990 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
9991 }
9992 }
9993
9994 /// Defines additional types related to [Reason].
9995 pub mod reason {
9996 #[allow(unused_imports)]
9997 use super::*;
9998
9999 /// Code identifying the reason type. The order here is meaningless. In
10000 /// particular, it gives no indication of whether a given reason will
10001 /// appear before another in the solution, if both apply.
10002 ///
10003 /// # Working with unknown values
10004 ///
10005 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10006 /// additional enum variants at any time. Adding new variants is not considered
10007 /// a breaking change. Applications should write their code in anticipation of:
10008 ///
10009 /// - New values appearing in future releases of the client library, **and**
10010 /// - New values received dynamically, without application changes.
10011 ///
10012 /// Please consult the [Working with enums] section in the user guide for some
10013 /// guidelines.
10014 ///
10015 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
10016 #[derive(Clone, Debug, PartialEq)]
10017 #[non_exhaustive]
10018 pub enum Code {
10019 /// This should never be used. If we are unable to understand why a
10020 /// shipment was skipped, we simply return an empty set of reasons.
10021 Unspecified,
10022 /// There is no vehicle in the model making all shipments infeasible.
10023 NoVehicle,
10024 /// The demand of the shipment exceeds a vehicle's capacity for some
10025 /// capacity types, one of which is `example_exceeded_capacity_type`.
10026 DemandExceedsVehicleCapacity,
10027 /// The minimum distance necessary to perform this shipment, i.e. from
10028 /// the vehicle's `start_location` to the shipment's pickup and/or delivery
10029 /// locations and to the vehicle's end location exceeds the vehicle's
10030 /// `route_distance_limit`.
10031 ///
10032 /// Note that for this computation we use the geodesic distances.
10033 CannotBePerformedWithinVehicleDistanceLimit,
10034 /// The minimum time necessary to perform this shipment, including travel
10035 /// time, wait time and service time exceeds the vehicle's
10036 /// `route_duration_limit`.
10037 ///
10038 /// Note: travel time is computed in the best-case scenario, namely as
10039 /// geodesic distance x 36 m/s (roughly 130 km/hour).
10040 CannotBePerformedWithinVehicleDurationLimit,
10041 /// Same as above but we only compare minimum travel time and the
10042 /// vehicle's `travel_duration_limit`.
10043 CannotBePerformedWithinVehicleTravelDurationLimit,
10044 /// The vehicle cannot perform this shipment in the best-case scenario
10045 /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
10046 /// computation) if it starts at its earliest start time: the total time
10047 /// would make the vehicle end after its latest end time.
10048 CannotBePerformedWithinVehicleTimeWindows,
10049 /// The `allowed_vehicle_indices` field of the shipment is not empty and
10050 /// this vehicle does not belong to it.
10051 VehicleNotAllowed,
10052 /// If set, the enum was initialized with an unknown value.
10053 ///
10054 /// Applications can examine the value using [Code::value] or
10055 /// [Code::name].
10056 UnknownValue(code::UnknownValue),
10057 }
10058
10059 #[doc(hidden)]
10060 pub mod code {
10061 #[allow(unused_imports)]
10062 use super::*;
10063 #[derive(Clone, Debug, PartialEq)]
10064 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10065 }
10066
10067 impl Code {
10068 /// Gets the enum value.
10069 ///
10070 /// Returns `None` if the enum contains an unknown value deserialized from
10071 /// the string representation of enums.
10072 pub fn value(&self) -> std::option::Option<i32> {
10073 match self {
10074 Self::Unspecified => std::option::Option::Some(0),
10075 Self::NoVehicle => std::option::Option::Some(1),
10076 Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
10077 Self::CannotBePerformedWithinVehicleDistanceLimit => {
10078 std::option::Option::Some(3)
10079 }
10080 Self::CannotBePerformedWithinVehicleDurationLimit => {
10081 std::option::Option::Some(4)
10082 }
10083 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10084 std::option::Option::Some(5)
10085 }
10086 Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
10087 Self::VehicleNotAllowed => std::option::Option::Some(7),
10088 Self::UnknownValue(u) => u.0.value(),
10089 }
10090 }
10091
10092 /// Gets the enum value as a string.
10093 ///
10094 /// Returns `None` if the enum contains an unknown value deserialized from
10095 /// the integer representation of enums.
10096 pub fn name(&self) -> std::option::Option<&str> {
10097 match self {
10098 Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
10099 Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
10100 Self::DemandExceedsVehicleCapacity => {
10101 std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
10102 }
10103 Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
10104 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
10105 ),
10106 Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
10107 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
10108 ),
10109 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10110 std::option::Option::Some(
10111 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
10112 )
10113 }
10114 Self::CannotBePerformedWithinVehicleTimeWindows => {
10115 std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
10116 }
10117 Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
10118 Self::UnknownValue(u) => u.0.name(),
10119 }
10120 }
10121 }
10122
10123 impl std::default::Default for Code {
10124 fn default() -> Self {
10125 use std::convert::From;
10126 Self::from(0)
10127 }
10128 }
10129
10130 impl std::fmt::Display for Code {
10131 fn fmt(
10132 &self,
10133 f: &mut std::fmt::Formatter<'_>,
10134 ) -> std::result::Result<(), std::fmt::Error> {
10135 wkt::internal::display_enum(f, self.name(), self.value())
10136 }
10137 }
10138
10139 impl std::convert::From<i32> for Code {
10140 fn from(value: i32) -> Self {
10141 match value {
10142 0 => Self::Unspecified,
10143 1 => Self::NoVehicle,
10144 2 => Self::DemandExceedsVehicleCapacity,
10145 3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
10146 4 => Self::CannotBePerformedWithinVehicleDurationLimit,
10147 5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
10148 6 => Self::CannotBePerformedWithinVehicleTimeWindows,
10149 7 => Self::VehicleNotAllowed,
10150 _ => Self::UnknownValue(code::UnknownValue(
10151 wkt::internal::UnknownEnumValue::Integer(value),
10152 )),
10153 }
10154 }
10155 }
10156
10157 impl std::convert::From<&str> for Code {
10158 fn from(value: &str) -> Self {
10159 use std::string::ToString;
10160 match value {
10161 "CODE_UNSPECIFIED" => Self::Unspecified,
10162 "NO_VEHICLE" => Self::NoVehicle,
10163 "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
10164 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
10165 Self::CannotBePerformedWithinVehicleDistanceLimit
10166 }
10167 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
10168 Self::CannotBePerformedWithinVehicleDurationLimit
10169 }
10170 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
10171 Self::CannotBePerformedWithinVehicleTravelDurationLimit
10172 }
10173 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
10174 Self::CannotBePerformedWithinVehicleTimeWindows
10175 }
10176 "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
10177 _ => Self::UnknownValue(code::UnknownValue(
10178 wkt::internal::UnknownEnumValue::String(value.to_string()),
10179 )),
10180 }
10181 }
10182 }
10183
10184 impl serde::ser::Serialize for Code {
10185 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10186 where
10187 S: serde::Serializer,
10188 {
10189 match self {
10190 Self::Unspecified => serializer.serialize_i32(0),
10191 Self::NoVehicle => serializer.serialize_i32(1),
10192 Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
10193 Self::CannotBePerformedWithinVehicleDistanceLimit => {
10194 serializer.serialize_i32(3)
10195 }
10196 Self::CannotBePerformedWithinVehicleDurationLimit => {
10197 serializer.serialize_i32(4)
10198 }
10199 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10200 serializer.serialize_i32(5)
10201 }
10202 Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
10203 Self::VehicleNotAllowed => serializer.serialize_i32(7),
10204 Self::UnknownValue(u) => u.0.serialize(serializer),
10205 }
10206 }
10207 }
10208
10209 impl<'de> serde::de::Deserialize<'de> for Code {
10210 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10211 where
10212 D: serde::Deserializer<'de>,
10213 {
10214 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
10215 ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
10216 ))
10217 }
10218 }
10219 }
10220}
10221
10222/// Aggregated metrics for
10223/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
10224/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
10225/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
10226/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
10227/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
10228///
10229/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
10230/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
10231/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
10232/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
10233#[derive(Clone, Default, PartialEq)]
10234#[non_exhaustive]
10235pub struct AggregatedMetrics {
10236 /// Number of shipments performed. Note that a pickup and delivery pair only
10237 /// counts once.
10238 pub performed_shipment_count: i32,
10239
10240 /// Total travel duration for a route or a solution.
10241 pub travel_duration: std::option::Option<wkt::Duration>,
10242
10243 /// Total wait duration for a route or a solution.
10244 pub wait_duration: std::option::Option<wkt::Duration>,
10245
10246 /// Total delay duration for a route or a solution.
10247 pub delay_duration: std::option::Option<wkt::Duration>,
10248
10249 /// Total break duration for a route or a solution.
10250 pub break_duration: std::option::Option<wkt::Duration>,
10251
10252 /// Total visit duration for a route or a solution.
10253 pub visit_duration: std::option::Option<wkt::Duration>,
10254
10255 /// The total duration should be equal to the sum of all durations above.
10256 /// For routes, it also corresponds to:
10257 /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
10258 /// `-`
10259 /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
10260 ///
10261 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
10262 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
10263 pub total_duration: std::option::Option<wkt::Duration>,
10264
10265 /// Total travel distance for a route or a solution.
10266 pub travel_distance_meters: f64,
10267
10268 /// Maximum load achieved over the entire route (resp. solution), for each of
10269 /// the quantities on this route (resp. solution), computed as the maximum over
10270 /// all
10271 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
10272 /// (resp.
10273 /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
10274 ///
10275 /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
10276 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
10277 pub max_loads:
10278 std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
10279
10280 /// Deprecated: Use
10281 /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
10282 /// and
10283 /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
10284 /// instead.
10285 ///
10286 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
10287 /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
10288 #[deprecated]
10289 pub costs: std::collections::HashMap<std::string::String, f64>,
10290
10291 /// Deprecated: Use
10292 /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
10293 /// and
10294 /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
10295 /// instead.
10296 ///
10297 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
10298 /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
10299 #[deprecated]
10300 pub total_cost: f64,
10301
10302 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10303}
10304
10305impl AggregatedMetrics {
10306 pub fn new() -> Self {
10307 std::default::Default::default()
10308 }
10309
10310 /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
10311 ///
10312 /// # Example
10313 /// ```ignore,no_run
10314 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10315 /// let x = AggregatedMetrics::new().set_performed_shipment_count(42);
10316 /// ```
10317 pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10318 self.performed_shipment_count = v.into();
10319 self
10320 }
10321
10322 /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10323 ///
10324 /// # Example
10325 /// ```ignore,no_run
10326 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10327 /// use wkt::Duration;
10328 /// let x = AggregatedMetrics::new().set_travel_duration(Duration::default()/* use setters */);
10329 /// ```
10330 pub fn set_travel_duration<T>(mut self, v: T) -> Self
10331 where
10332 T: std::convert::Into<wkt::Duration>,
10333 {
10334 self.travel_duration = std::option::Option::Some(v.into());
10335 self
10336 }
10337
10338 /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10339 ///
10340 /// # Example
10341 /// ```ignore,no_run
10342 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10343 /// use wkt::Duration;
10344 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
10345 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(None::<Duration>);
10346 /// ```
10347 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
10348 where
10349 T: std::convert::Into<wkt::Duration>,
10350 {
10351 self.travel_duration = v.map(|x| x.into());
10352 self
10353 }
10354
10355 /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10356 ///
10357 /// # Example
10358 /// ```ignore,no_run
10359 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10360 /// use wkt::Duration;
10361 /// let x = AggregatedMetrics::new().set_wait_duration(Duration::default()/* use setters */);
10362 /// ```
10363 pub fn set_wait_duration<T>(mut self, v: T) -> Self
10364 where
10365 T: std::convert::Into<wkt::Duration>,
10366 {
10367 self.wait_duration = std::option::Option::Some(v.into());
10368 self
10369 }
10370
10371 /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10372 ///
10373 /// # Example
10374 /// ```ignore,no_run
10375 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10376 /// use wkt::Duration;
10377 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
10378 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(None::<Duration>);
10379 /// ```
10380 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
10381 where
10382 T: std::convert::Into<wkt::Duration>,
10383 {
10384 self.wait_duration = v.map(|x| x.into());
10385 self
10386 }
10387
10388 /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10389 ///
10390 /// # Example
10391 /// ```ignore,no_run
10392 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10393 /// use wkt::Duration;
10394 /// let x = AggregatedMetrics::new().set_delay_duration(Duration::default()/* use setters */);
10395 /// ```
10396 pub fn set_delay_duration<T>(mut self, v: T) -> Self
10397 where
10398 T: std::convert::Into<wkt::Duration>,
10399 {
10400 self.delay_duration = std::option::Option::Some(v.into());
10401 self
10402 }
10403
10404 /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10405 ///
10406 /// # Example
10407 /// ```ignore,no_run
10408 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10409 /// use wkt::Duration;
10410 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
10411 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(None::<Duration>);
10412 /// ```
10413 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
10414 where
10415 T: std::convert::Into<wkt::Duration>,
10416 {
10417 self.delay_duration = v.map(|x| x.into());
10418 self
10419 }
10420
10421 /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10422 ///
10423 /// # Example
10424 /// ```ignore,no_run
10425 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10426 /// use wkt::Duration;
10427 /// let x = AggregatedMetrics::new().set_break_duration(Duration::default()/* use setters */);
10428 /// ```
10429 pub fn set_break_duration<T>(mut self, v: T) -> Self
10430 where
10431 T: std::convert::Into<wkt::Duration>,
10432 {
10433 self.break_duration = std::option::Option::Some(v.into());
10434 self
10435 }
10436
10437 /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10438 ///
10439 /// # Example
10440 /// ```ignore,no_run
10441 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10442 /// use wkt::Duration;
10443 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
10444 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(None::<Duration>);
10445 /// ```
10446 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
10447 where
10448 T: std::convert::Into<wkt::Duration>,
10449 {
10450 self.break_duration = v.map(|x| x.into());
10451 self
10452 }
10453
10454 /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10455 ///
10456 /// # Example
10457 /// ```ignore,no_run
10458 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10459 /// use wkt::Duration;
10460 /// let x = AggregatedMetrics::new().set_visit_duration(Duration::default()/* use setters */);
10461 /// ```
10462 pub fn set_visit_duration<T>(mut self, v: T) -> Self
10463 where
10464 T: std::convert::Into<wkt::Duration>,
10465 {
10466 self.visit_duration = std::option::Option::Some(v.into());
10467 self
10468 }
10469
10470 /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10471 ///
10472 /// # Example
10473 /// ```ignore,no_run
10474 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10475 /// use wkt::Duration;
10476 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(Some(Duration::default()/* use setters */));
10477 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(None::<Duration>);
10478 /// ```
10479 pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
10480 where
10481 T: std::convert::Into<wkt::Duration>,
10482 {
10483 self.visit_duration = v.map(|x| x.into());
10484 self
10485 }
10486
10487 /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10488 ///
10489 /// # Example
10490 /// ```ignore,no_run
10491 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10492 /// use wkt::Duration;
10493 /// let x = AggregatedMetrics::new().set_total_duration(Duration::default()/* use setters */);
10494 /// ```
10495 pub fn set_total_duration<T>(mut self, v: T) -> Self
10496 where
10497 T: std::convert::Into<wkt::Duration>,
10498 {
10499 self.total_duration = std::option::Option::Some(v.into());
10500 self
10501 }
10502
10503 /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10504 ///
10505 /// # Example
10506 /// ```ignore,no_run
10507 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10508 /// use wkt::Duration;
10509 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
10510 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(None::<Duration>);
10511 /// ```
10512 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
10513 where
10514 T: std::convert::Into<wkt::Duration>,
10515 {
10516 self.total_duration = v.map(|x| x.into());
10517 self
10518 }
10519
10520 /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
10521 ///
10522 /// # Example
10523 /// ```ignore,no_run
10524 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10525 /// let x = AggregatedMetrics::new().set_travel_distance_meters(42.0);
10526 /// ```
10527 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10528 self.travel_distance_meters = v.into();
10529 self
10530 }
10531
10532 /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
10533 ///
10534 /// # Example
10535 /// ```ignore,no_run
10536 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10537 /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
10538 /// let x = AggregatedMetrics::new().set_max_loads([
10539 /// ("key0", VehicleLoad::default()/* use setters */),
10540 /// ("key1", VehicleLoad::default()/* use (different) setters */),
10541 /// ]);
10542 /// ```
10543 pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
10544 where
10545 T: std::iter::IntoIterator<Item = (K, V)>,
10546 K: std::convert::Into<std::string::String>,
10547 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
10548 {
10549 use std::iter::Iterator;
10550 self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10551 self
10552 }
10553
10554 /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
10555 ///
10556 /// # Example
10557 /// ```ignore,no_run
10558 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10559 /// let x = AggregatedMetrics::new().set_costs([
10560 /// ("key0", 123.5),
10561 /// ("key1", 456.5),
10562 /// ]);
10563 /// ```
10564 #[deprecated]
10565 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
10566 where
10567 T: std::iter::IntoIterator<Item = (K, V)>,
10568 K: std::convert::Into<std::string::String>,
10569 V: std::convert::Into<f64>,
10570 {
10571 use std::iter::Iterator;
10572 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10573 self
10574 }
10575
10576 /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
10577 ///
10578 /// # Example
10579 /// ```ignore,no_run
10580 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10581 /// let x = AggregatedMetrics::new().set_total_cost(42.0);
10582 /// ```
10583 #[deprecated]
10584 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10585 self.total_cost = v.into();
10586 self
10587 }
10588}
10589
10590impl wkt::message::Message for AggregatedMetrics {
10591 fn typename() -> &'static str {
10592 "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
10593 }
10594}
10595
10596/// Solution injected in the request including information about which visits
10597/// must be constrained and how they must be constrained.
10598#[derive(Clone, Default, PartialEq)]
10599#[non_exhaustive]
10600pub struct InjectedSolutionConstraint {
10601 /// Routes of the solution to inject. Some routes may be omitted from the
10602 /// original solution. The routes and skipped shipments must satisfy the basic
10603 /// validity assumptions listed for `injected_first_solution_routes`.
10604 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
10605
10606 /// Skipped shipments of the solution to inject. Some may be omitted from the
10607 /// original solution. See the `routes` field.
10608 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
10609
10610 /// For zero or more groups of vehicles, specifies when and how much to relax
10611 /// constraints. If this field is empty, all non-empty vehicle routes are
10612 /// fully constrained.
10613 pub constraint_relaxations:
10614 std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10615
10616 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10617}
10618
10619impl InjectedSolutionConstraint {
10620 pub fn new() -> Self {
10621 std::default::Default::default()
10622 }
10623
10624 /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
10625 ///
10626 /// # Example
10627 /// ```ignore,no_run
10628 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10629 /// use google_cloud_optimization_v1::model::ShipmentRoute;
10630 /// let x = InjectedSolutionConstraint::new()
10631 /// .set_routes([
10632 /// ShipmentRoute::default()/* use setters */,
10633 /// ShipmentRoute::default()/* use (different) setters */,
10634 /// ]);
10635 /// ```
10636 pub fn set_routes<T, V>(mut self, v: T) -> Self
10637 where
10638 T: std::iter::IntoIterator<Item = V>,
10639 V: std::convert::Into<crate::model::ShipmentRoute>,
10640 {
10641 use std::iter::Iterator;
10642 self.routes = v.into_iter().map(|i| i.into()).collect();
10643 self
10644 }
10645
10646 /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
10647 ///
10648 /// # Example
10649 /// ```ignore,no_run
10650 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10651 /// use google_cloud_optimization_v1::model::SkippedShipment;
10652 /// let x = InjectedSolutionConstraint::new()
10653 /// .set_skipped_shipments([
10654 /// SkippedShipment::default()/* use setters */,
10655 /// SkippedShipment::default()/* use (different) setters */,
10656 /// ]);
10657 /// ```
10658 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
10659 where
10660 T: std::iter::IntoIterator<Item = V>,
10661 V: std::convert::Into<crate::model::SkippedShipment>,
10662 {
10663 use std::iter::Iterator;
10664 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
10665 self
10666 }
10667
10668 /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
10669 ///
10670 /// # Example
10671 /// ```ignore,no_run
10672 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10673 /// use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10674 /// let x = InjectedSolutionConstraint::new()
10675 /// .set_constraint_relaxations([
10676 /// ConstraintRelaxation::default()/* use setters */,
10677 /// ConstraintRelaxation::default()/* use (different) setters */,
10678 /// ]);
10679 /// ```
10680 pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
10681 where
10682 T: std::iter::IntoIterator<Item = V>,
10683 V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10684 {
10685 use std::iter::Iterator;
10686 self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
10687 self
10688 }
10689}
10690
10691impl wkt::message::Message for InjectedSolutionConstraint {
10692 fn typename() -> &'static str {
10693 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
10694 }
10695}
10696
10697/// Defines additional types related to [InjectedSolutionConstraint].
10698pub mod injected_solution_constraint {
10699 #[allow(unused_imports)]
10700 use super::*;
10701
10702 /// For a group of vehicles, specifies at what threshold(s) constraints on
10703 /// visits will be relaxed and to which level. Shipments listed in
10704 /// the `skipped_shipment` field are constrained to be skipped; i.e., they
10705 /// cannot be performed.
10706 #[derive(Clone, Default, PartialEq)]
10707 #[non_exhaustive]
10708 pub struct ConstraintRelaxation {
10709 /// All the visit constraint relaxations that will apply to visits on
10710 /// routes with vehicles in `vehicle_indices`.
10711 pub relaxations: std::vec::Vec<
10712 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10713 >,
10714
10715 /// Specifies the vehicle indices to which the visit constraint
10716 /// `relaxations` apply. If empty, this is considered the default and the
10717 /// `relaxations` apply to all vehicles that are not specified in other
10718 /// `constraint_relaxations`. There can be at most one default, i.e., at
10719 /// most one constraint relaxation field is allowed empty
10720 /// `vehicle_indices`. A vehicle index can only be listed once, even within
10721 /// several `constraint_relaxations`.
10722 ///
10723 /// A vehicle index is mapped the same as
10724 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
10725 /// if `interpret_injected_solutions_using_labels` is true (see `fields`
10726 /// comment).
10727 ///
10728 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
10729 pub vehicle_indices: std::vec::Vec<i32>,
10730
10731 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10732 }
10733
10734 impl ConstraintRelaxation {
10735 pub fn new() -> Self {
10736 std::default::Default::default()
10737 }
10738
10739 /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
10740 ///
10741 /// # Example
10742 /// ```ignore,no_run
10743 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10744 /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10745 /// let x = ConstraintRelaxation::new()
10746 /// .set_relaxations([
10747 /// Relaxation::default()/* use setters */,
10748 /// Relaxation::default()/* use (different) setters */,
10749 /// ]);
10750 /// ```
10751 pub fn set_relaxations<T, V>(mut self, v: T) -> Self
10752 where
10753 T: std::iter::IntoIterator<Item = V>,
10754 V: std::convert::Into<
10755 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10756 >,
10757 {
10758 use std::iter::Iterator;
10759 self.relaxations = v.into_iter().map(|i| i.into()).collect();
10760 self
10761 }
10762
10763 /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
10764 ///
10765 /// # Example
10766 /// ```ignore,no_run
10767 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10768 /// let x = ConstraintRelaxation::new().set_vehicle_indices([1, 2, 3]);
10769 /// ```
10770 pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
10771 where
10772 T: std::iter::IntoIterator<Item = V>,
10773 V: std::convert::Into<i32>,
10774 {
10775 use std::iter::Iterator;
10776 self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
10777 self
10778 }
10779 }
10780
10781 impl wkt::message::Message for ConstraintRelaxation {
10782 fn typename() -> &'static str {
10783 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
10784 }
10785 }
10786
10787 /// Defines additional types related to [ConstraintRelaxation].
10788 pub mod constraint_relaxation {
10789 #[allow(unused_imports)]
10790 use super::*;
10791
10792 /// If `relaxations` is empty, the start time and sequence of all visits
10793 /// on `routes` are fully constrained and no new visits may be inserted or
10794 /// added to those routes. Also, a vehicle's start and end time in
10795 /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
10796 /// visits and has `used_if_route_is_empty` set to false in the model).
10797 ///
10798 /// `relaxations(i).level` specifies the constraint relaxation level applied
10799 /// to a visit #j that satisfies:
10800 ///
10801 /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
10802 /// * `j + 1 >= relaxations(i).threshold_visit_count`
10803 ///
10804 /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
10805 /// satisfies:
10806 ///
10807 /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
10808 /// * `relaxations(i).threshold_visit_count == 0`
10809 /// and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
10810 /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
10811 /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
10812 ///
10813 /// To apply a relaxation level if a visit meets the `threshold_visit_count`
10814 /// OR the `threshold_time` add two `relaxations` with the same `level`:
10815 /// one with only `threshold_visit_count` set and the other with only
10816 /// `threshold_time` set. If a visit satisfies the conditions of multiple
10817 /// `relaxations`, the most relaxed level applies. As a result, from the
10818 /// vehicle start through the route visits in order to the vehicle end, the
10819 /// relaxation level becomes more relaxed: i.e., the relaxation level is
10820 /// non-decreasing as the route progresses.
10821 ///
10822 /// The timing and sequence of route visits that do not satisfy the
10823 /// threshold conditions of any `relaxations` are fully constrained
10824 /// and no visits may be inserted into these sequences. Also, if a
10825 /// vehicle start or end does not satisfy the conditions of any
10826 /// relaxation the time is fixed, unless the vehicle is empty.
10827 #[derive(Clone, Default, PartialEq)]
10828 #[non_exhaustive]
10829 pub struct Relaxation {
10830
10831 /// The constraint relaxation level that applies when the conditions
10832 /// at or after `threshold_time` AND at least `threshold_visit_count` are
10833 /// satisfied.
10834 pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
10835
10836 /// The time at or after which the relaxation `level` may be applied.
10837 pub threshold_time: std::option::Option<wkt::Timestamp>,
10838
10839 /// The number of visits at or after which the relaxation `level` may be
10840 /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
10841 /// applied directly at the vehicle start.
10842 ///
10843 /// If it is `route.visits_size() + 1`, the `level` may only be applied to
10844 /// the vehicle end. If it is more than `route.visits_size() + 1`,
10845 /// `level` is not applied at all for that route.
10846 pub threshold_visit_count: i32,
10847
10848 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10849 }
10850
10851 impl Relaxation {
10852 pub fn new() -> Self {
10853 std::default::Default::default()
10854 }
10855
10856 /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
10857 ///
10858 /// # Example
10859 /// ```ignore,no_run
10860 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10861 /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::relaxation::Level;
10862 /// let x0 = Relaxation::new().set_level(Level::RelaxVisitTimesAfterThreshold);
10863 /// let x1 = Relaxation::new().set_level(Level::RelaxVisitTimesAndSequenceAfterThreshold);
10864 /// let x2 = Relaxation::new().set_level(Level::RelaxAllAfterThreshold);
10865 /// ```
10866 pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
10867 self.level = v.into();
10868 self
10869 }
10870
10871 /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10872 ///
10873 /// # Example
10874 /// ```ignore,no_run
10875 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10876 /// use wkt::Timestamp;
10877 /// let x = Relaxation::new().set_threshold_time(Timestamp::default()/* use setters */);
10878 /// ```
10879 pub fn set_threshold_time<T>(mut self, v: T) -> Self
10880 where
10881 T: std::convert::Into<wkt::Timestamp>,
10882 {
10883 self.threshold_time = std::option::Option::Some(v.into());
10884 self
10885 }
10886
10887 /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10888 ///
10889 /// # Example
10890 /// ```ignore,no_run
10891 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10892 /// use wkt::Timestamp;
10893 /// let x = Relaxation::new().set_or_clear_threshold_time(Some(Timestamp::default()/* use setters */));
10894 /// let x = Relaxation::new().set_or_clear_threshold_time(None::<Timestamp>);
10895 /// ```
10896 pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
10897 where
10898 T: std::convert::Into<wkt::Timestamp>,
10899 {
10900 self.threshold_time = v.map(|x| x.into());
10901 self
10902 }
10903
10904 /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
10905 ///
10906 /// # Example
10907 /// ```ignore,no_run
10908 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10909 /// let x = Relaxation::new().set_threshold_visit_count(42);
10910 /// ```
10911 pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10912 self.threshold_visit_count = v.into();
10913 self
10914 }
10915 }
10916
10917 impl wkt::message::Message for Relaxation {
10918 fn typename() -> &'static str {
10919 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
10920 }
10921 }
10922
10923 /// Defines additional types related to [Relaxation].
10924 pub mod relaxation {
10925 #[allow(unused_imports)]
10926 use super::*;
10927
10928 /// Expresses the different constraint relaxation levels, which are
10929 /// applied for a visit and those that follow when it satisfies the
10930 /// threshold conditions.
10931 ///
10932 /// The enumeration below is in order of increasing relaxation.
10933 ///
10934 /// # Working with unknown values
10935 ///
10936 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10937 /// additional enum variants at any time. Adding new variants is not considered
10938 /// a breaking change. Applications should write their code in anticipation of:
10939 ///
10940 /// - New values appearing in future releases of the client library, **and**
10941 /// - New values received dynamically, without application changes.
10942 ///
10943 /// Please consult the [Working with enums] section in the user guide for some
10944 /// guidelines.
10945 ///
10946 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
10947 #[derive(Clone, Debug, PartialEq)]
10948 #[non_exhaustive]
10949 pub enum Level {
10950 /// Implicit default relaxation level: no constraints are relaxed,
10951 /// i.e., all visits are fully constrained.
10952 ///
10953 /// This value must not be explicitly used in `level`.
10954 Unspecified,
10955 /// Visit start times and vehicle start/end times will be relaxed, but
10956 /// each visit remains bound to the same vehicle and the visit sequence
10957 /// must be observed: no visit can be inserted between them or before
10958 /// them.
10959 RelaxVisitTimesAfterThreshold,
10960 /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
10961 /// is also relaxed: visits can only be performed by this vehicle, but
10962 /// can potentially become unperformed.
10963 RelaxVisitTimesAndSequenceAfterThreshold,
10964 /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
10965 /// vehicle is also relaxed: visits are completely free at or after the
10966 /// threshold time and can potentially become unperformed.
10967 RelaxAllAfterThreshold,
10968 /// If set, the enum was initialized with an unknown value.
10969 ///
10970 /// Applications can examine the value using [Level::value] or
10971 /// [Level::name].
10972 UnknownValue(level::UnknownValue),
10973 }
10974
10975 #[doc(hidden)]
10976 pub mod level {
10977 #[allow(unused_imports)]
10978 use super::*;
10979 #[derive(Clone, Debug, PartialEq)]
10980 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10981 }
10982
10983 impl Level {
10984 /// Gets the enum value.
10985 ///
10986 /// Returns `None` if the enum contains an unknown value deserialized from
10987 /// the string representation of enums.
10988 pub fn value(&self) -> std::option::Option<i32> {
10989 match self {
10990 Self::Unspecified => std::option::Option::Some(0),
10991 Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
10992 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
10993 std::option::Option::Some(2)
10994 }
10995 Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
10996 Self::UnknownValue(u) => u.0.value(),
10997 }
10998 }
10999
11000 /// Gets the enum value as a string.
11001 ///
11002 /// Returns `None` if the enum contains an unknown value deserialized from
11003 /// the integer representation of enums.
11004 pub fn name(&self) -> std::option::Option<&str> {
11005 match self {
11006 Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
11007 Self::RelaxVisitTimesAfterThreshold => {
11008 std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
11009 }
11010 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11011 std::option::Option::Some(
11012 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
11013 )
11014 }
11015 Self::RelaxAllAfterThreshold => {
11016 std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
11017 }
11018 Self::UnknownValue(u) => u.0.name(),
11019 }
11020 }
11021 }
11022
11023 impl std::default::Default for Level {
11024 fn default() -> Self {
11025 use std::convert::From;
11026 Self::from(0)
11027 }
11028 }
11029
11030 impl std::fmt::Display for Level {
11031 fn fmt(
11032 &self,
11033 f: &mut std::fmt::Formatter<'_>,
11034 ) -> std::result::Result<(), std::fmt::Error> {
11035 wkt::internal::display_enum(f, self.name(), self.value())
11036 }
11037 }
11038
11039 impl std::convert::From<i32> for Level {
11040 fn from(value: i32) -> Self {
11041 match value {
11042 0 => Self::Unspecified,
11043 1 => Self::RelaxVisitTimesAfterThreshold,
11044 2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
11045 3 => Self::RelaxAllAfterThreshold,
11046 _ => Self::UnknownValue(level::UnknownValue(
11047 wkt::internal::UnknownEnumValue::Integer(value),
11048 )),
11049 }
11050 }
11051 }
11052
11053 impl std::convert::From<&str> for Level {
11054 fn from(value: &str) -> Self {
11055 use std::string::ToString;
11056 match value {
11057 "LEVEL_UNSPECIFIED" => Self::Unspecified,
11058 "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
11059 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
11060 Self::RelaxVisitTimesAndSequenceAfterThreshold
11061 }
11062 "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
11063 _ => Self::UnknownValue(level::UnknownValue(
11064 wkt::internal::UnknownEnumValue::String(value.to_string()),
11065 )),
11066 }
11067 }
11068 }
11069
11070 impl serde::ser::Serialize for Level {
11071 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11072 where
11073 S: serde::Serializer,
11074 {
11075 match self {
11076 Self::Unspecified => serializer.serialize_i32(0),
11077 Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
11078 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11079 serializer.serialize_i32(2)
11080 }
11081 Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
11082 Self::UnknownValue(u) => u.0.serialize(serializer),
11083 }
11084 }
11085 }
11086
11087 impl<'de> serde::de::Deserialize<'de> for Level {
11088 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11089 where
11090 D: serde::Deserializer<'de>,
11091 {
11092 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
11093 ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
11094 }
11095 }
11096 }
11097 }
11098}
11099
11100/// Describes an error encountered when validating an `OptimizeToursRequest`.
11101#[derive(Clone, Default, PartialEq)]
11102#[non_exhaustive]
11103pub struct OptimizeToursValidationError {
11104 /// A validation error is defined by the pair (`code`, `display_name`) which
11105 /// are always present.
11106 ///
11107 /// Other fields (below) provide more context about the error.
11108 ///
11109 /// *MULTIPLE ERRORS*:
11110 /// When there are multiple errors, the validation process tries to output
11111 /// several of them. Much like a compiler, this is an imperfect process. Some
11112 /// validation errors will be "fatal", meaning that they stop the entire
11113 /// validation process. This is the case for `display_name="UNSPECIFIED"`
11114 /// errors, among others. Some may cause the validation process to skip other
11115 /// errors.
11116 ///
11117 /// *STABILITY*:
11118 /// `code` and `display_name` should be very stable. But new codes and
11119 /// display names may appear over time, which may cause a given (invalid)
11120 /// request to yield a different (`code`, `display_name`) pair because the new
11121 /// error hid the old one (see "MULTIPLE ERRORS").
11122 ///
11123 /// *REFERENCE*: A list of all (code, name) pairs:
11124 ///
11125 /// * UNSPECIFIED = 0;
11126 ///
11127 /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
11128 /// the deadline.
11129 ///
11130 /// * REQUEST_OPTIONS_ERROR = 12;
11131 ///
11132 /// * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
11133 /// * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
11134 /// * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
11135 /// * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
11136 /// * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
11137 /// * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
11138 /// = 1207;
11139 /// * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
11140 /// * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
11141 /// * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
11142 /// * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
11143 /// * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
11144 /// * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
11145 /// * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
11146 /// * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
11147 /// * INJECTED_SOLUTION_ERROR = 20;
11148 ///
11149 /// * INJECTED_SOLUTION_MISSING_LABEL = 2000;
11150 /// * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
11151 /// * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
11152 /// * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
11153 /// * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
11154 /// * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
11155 /// * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
11156 /// * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
11157 /// * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
11158 /// * SHIPMENT_MODEL_ERROR = 22;
11159 ///
11160 /// * SHIPMENT_MODEL_TOO_LARGE = 2200;
11161 /// * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
11162 /// * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
11163 /// * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
11164 /// * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
11165 /// * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
11166 /// * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
11167 /// * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
11168 /// * INDEX_ERROR = 24;
11169 ///
11170 /// * TAG_ERROR = 26;
11171 ///
11172 /// * TIME_WINDOW_ERROR = 28;
11173 ///
11174 /// * TIME_WINDOW_INVALID_START_TIME = 2800;
11175 /// * TIME_WINDOW_INVALID_END_TIME = 2801;
11176 /// * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
11177 /// * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
11178 /// * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
11179 /// * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
11180 /// * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
11181 /// * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
11182 /// * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
11183 /// = 2808;
11184 /// * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
11185 /// * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
11186 /// = 2810;
11187 /// * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
11188 /// * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
11189 /// * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
11190 /// * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
11191 /// * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
11192 /// * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
11193 /// * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
11194 /// = 2817;
11195 /// * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
11196 /// * TRANSITION_ATTRIBUTES_ERROR = 30;
11197 /// * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
11198 /// * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
11199 /// * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
11200 /// * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
11201 /// * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
11202 /// * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
11203 /// * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
11204 /// * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
11205 /// * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
11206 /// * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
11207 /// * AMOUNT_ERROR = 31;
11208 ///
11209 /// * AMOUNT_NEGATIVE_VALUE = 3100;
11210 /// * LOAD_LIMIT_ERROR = 33;
11211 ///
11212 /// * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
11213 /// * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
11214 /// * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
11215 /// * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
11216 /// * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
11217 /// * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
11218 /// * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
11219 /// * INTERVAL_ERROR = 34;
11220 ///
11221 /// * INTERVAL_MIN_EXCEEDS_MAX = 3401;
11222 /// * INTERVAL_NEGATIVE_MIN = 3402;
11223 /// * INTERVAL_NEGATIVE_MAX = 3403;
11224 /// * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
11225 /// * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
11226 /// * DISTANCE_LIMIT_ERROR = 36;
11227 ///
11228 /// * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
11229 /// * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
11230 /// * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
11231 /// * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
11232 /// * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
11233 /// * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
11234 /// * DURATION_LIMIT_ERROR = 38;
11235 ///
11236 /// * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
11237 /// * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
11238 /// * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
11239 /// * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
11240 /// * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
11241 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
11242 /// * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
11243 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
11244 /// = 3807;
11245 /// * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
11246 /// = 3808;
11247 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
11248 /// * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
11249 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
11250 /// * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
11251 /// = 3812;
11252 /// * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
11253 /// * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
11254 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
11255 /// = 3815;
11256 /// * SHIPMENT_ERROR = 40;
11257 ///
11258 /// * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
11259 /// * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
11260 /// * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
11261 /// = 4001;
11262 /// * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
11263 /// * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
11264 /// * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
11265 /// * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
11266 /// * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
11267 /// * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
11268 /// * SHIPMENT_INVALID_PENALTY_COST = 4006;
11269 /// * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
11270 /// * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
11271 /// * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
11272 /// * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
11273 /// * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
11274 /// * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
11275 /// * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
11276 /// * VEHICLE_ERROR = 42;
11277 ///
11278 /// * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
11279 /// * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
11280 /// * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
11281 /// * VEHICLE_EMPTY_START_TAG = 4203;
11282 /// * VEHICLE_DUPLICATE_START_TAG = 4204;
11283 /// * VEHICLE_EMPTY_END_TAG = 4205;
11284 /// * VEHICLE_DUPLICATE_END_TAG = 4206;
11285 /// * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
11286 /// * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
11287 /// * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
11288 /// * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
11289 /// * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
11290 /// * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
11291 /// * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
11292 /// * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
11293 /// * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
11294 /// * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
11295 /// * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
11296 /// * VEHICLE_INVALID_COST_PER_HOUR = 4218;
11297 /// * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
11298 /// * VEHICLE_INVALID_FIXED_COST = 4220;
11299 /// * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
11300 /// * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
11301 /// = 4223;
11302 /// * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
11303 /// * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
11304 /// * VISIT_REQUEST_ERROR = 44;
11305 ///
11306 /// * VISIT_REQUEST_EMPTY_TAG = 4400;
11307 /// * VISIT_REQUEST_DUPLICATE_TAG = 4401;
11308 /// * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
11309 /// * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
11310 /// * PRECEDENCE_ERROR = 46;
11311 ///
11312 /// * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
11313 /// * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
11314 /// * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
11315 /// * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
11316 /// * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
11317 /// * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
11318 /// * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
11319 /// * BREAK_ERROR = 48;
11320 ///
11321 /// * BREAK_RULE_EMPTY = 4800;
11322 /// * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
11323 /// * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
11324 /// * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
11325 /// * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
11326 /// * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
11327 /// * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
11328 /// * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
11329 /// * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
11330 /// * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
11331 /// * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
11332 /// * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
11333 /// * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
11334 /// = 4812;
11335 /// * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
11336 /// * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
11337 /// * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
11338 /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
11339 ///
11340 /// * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
11341 /// * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
11342 /// * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
11343 /// * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
11344 /// * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
11345 /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
11346 ///
11347 /// * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
11348 /// * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
11349 /// * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
11350 /// * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
11351 /// * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
11352 /// * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
11353 /// * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
11354 /// * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
11355 /// * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
11356 /// * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
11357 /// * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
11358 /// * VEHICLE_OPERATOR_ERROR = 54;
11359 ///
11360 /// * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
11361 /// * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
11362 /// * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
11363 /// * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
11364 /// * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
11365 /// * DURATION_SECONDS_MATRIX_ERROR = 56;
11366 ///
11367 /// * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
11368 /// * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
11369 pub code: i32,
11370
11371 /// The error display name.
11372 pub display_name: std::string::String,
11373
11374 /// An error context may involve 0, 1 (most of the time) or more fields. For
11375 /// example, referring to vehicle #4 and shipment #2's first pickup can be
11376 /// done as follows:
11377 ///
11378 /// ```norust
11379 /// fields { name: "vehicles" index: 4}
11380 /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
11381 /// ```
11382 ///
11383 /// Note, however, that the cardinality of `fields` should not change for a
11384 /// given error code.
11385 pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
11386
11387 /// Human-readable string describing the error. There is a 1:1 mapping
11388 /// between `code` and `error_message` (when code != "UNSPECIFIED").
11389 ///
11390 /// *STABILITY*: Not stable: the error message associated to a given `code` may
11391 /// change (hopefully to clarify it) over time. Please rely on the
11392 /// `display_name` and `code` instead.
11393 pub error_message: std::string::String,
11394
11395 /// May contain the value(s) of the field(s). This is not always available. You
11396 /// should absolutely not rely on it and use it only for manual model
11397 /// debugging.
11398 pub offending_values: std::string::String,
11399
11400 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11401}
11402
11403impl OptimizeToursValidationError {
11404 pub fn new() -> Self {
11405 std::default::Default::default()
11406 }
11407
11408 /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
11409 ///
11410 /// # Example
11411 /// ```ignore,no_run
11412 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11413 /// let x = OptimizeToursValidationError::new().set_code(42);
11414 /// ```
11415 pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11416 self.code = v.into();
11417 self
11418 }
11419
11420 /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
11421 ///
11422 /// # Example
11423 /// ```ignore,no_run
11424 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11425 /// let x = OptimizeToursValidationError::new().set_display_name("example");
11426 /// ```
11427 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11428 self.display_name = v.into();
11429 self
11430 }
11431
11432 /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
11433 ///
11434 /// # Example
11435 /// ```ignore,no_run
11436 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11437 /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11438 /// let x = OptimizeToursValidationError::new()
11439 /// .set_fields([
11440 /// FieldReference::default()/* use setters */,
11441 /// FieldReference::default()/* use (different) setters */,
11442 /// ]);
11443 /// ```
11444 pub fn set_fields<T, V>(mut self, v: T) -> Self
11445 where
11446 T: std::iter::IntoIterator<Item = V>,
11447 V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11448 {
11449 use std::iter::Iterator;
11450 self.fields = v.into_iter().map(|i| i.into()).collect();
11451 self
11452 }
11453
11454 /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
11455 ///
11456 /// # Example
11457 /// ```ignore,no_run
11458 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11459 /// let x = OptimizeToursValidationError::new().set_error_message("example");
11460 /// ```
11461 pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11462 self.error_message = v.into();
11463 self
11464 }
11465
11466 /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
11467 ///
11468 /// # Example
11469 /// ```ignore,no_run
11470 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11471 /// let x = OptimizeToursValidationError::new().set_offending_values("example");
11472 /// ```
11473 pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
11474 mut self,
11475 v: T,
11476 ) -> Self {
11477 self.offending_values = v.into();
11478 self
11479 }
11480}
11481
11482impl wkt::message::Message for OptimizeToursValidationError {
11483 fn typename() -> &'static str {
11484 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
11485 }
11486}
11487
11488/// Defines additional types related to [OptimizeToursValidationError].
11489pub mod optimize_tours_validation_error {
11490 #[allow(unused_imports)]
11491 use super::*;
11492
11493 /// Specifies a context for the validation error. A `FieldReference` always
11494 /// refers to a given field in this file and follows the same hierarchical
11495 /// structure. For example, we may specify element #2 of `start_time_windows`
11496 /// of vehicle #5 using:
11497 ///
11498 /// ```norust
11499 /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
11500 /// ```
11501 ///
11502 /// We however omit top-level entities such as `OptimizeToursRequest` or
11503 /// `ShipmentModel` to avoid crowding the message.
11504 #[derive(Clone, Default, PartialEq)]
11505 #[non_exhaustive]
11506 pub struct FieldReference {
11507 /// Name of the field, e.g., "vehicles".
11508 pub name: std::string::String,
11509
11510 /// Recursively nested sub-field, if needed.
11511 pub sub_field: std::option::Option<
11512 std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
11513 >,
11514
11515 pub index_or_key: std::option::Option<
11516 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11517 >,
11518
11519 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11520 }
11521
11522 impl FieldReference {
11523 pub fn new() -> Self {
11524 std::default::Default::default()
11525 }
11526
11527 /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
11528 ///
11529 /// # Example
11530 /// ```ignore,no_run
11531 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11532 /// let x = FieldReference::new().set_name("example");
11533 /// ```
11534 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11535 self.name = v.into();
11536 self
11537 }
11538
11539 /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11540 ///
11541 /// # Example
11542 /// ```ignore,no_run
11543 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11544 /// let x = FieldReference::new().set_sub_field(FieldReference::default()/* use setters */);
11545 /// ```
11546 pub fn set_sub_field<T>(mut self, v: T) -> Self
11547 where
11548 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11549 {
11550 self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
11551 self
11552 }
11553
11554 /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11555 ///
11556 /// # Example
11557 /// ```ignore,no_run
11558 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11559 /// let x = FieldReference::new().set_or_clear_sub_field(Some(FieldReference::default()/* use setters */));
11560 /// let x = FieldReference::new().set_or_clear_sub_field(None::<FieldReference>);
11561 /// ```
11562 pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
11563 where
11564 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11565 {
11566 self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
11567 self
11568 }
11569
11570 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
11571 ///
11572 /// Note that all the setters affecting `index_or_key` are mutually
11573 /// exclusive.
11574 ///
11575 /// # Example
11576 /// ```ignore,no_run
11577 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11578 /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::field_reference::IndexOrKey;
11579 /// let x = FieldReference::new().set_index_or_key(Some(IndexOrKey::Index(42)));
11580 /// ```
11581 pub fn set_index_or_key<
11582 T: std::convert::Into<
11583 std::option::Option<
11584 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11585 >,
11586 >,
11587 >(
11588 mut self,
11589 v: T,
11590 ) -> Self {
11591 self.index_or_key = v.into();
11592 self
11593 }
11594
11595 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11596 /// if it holds a `Index`, `None` if the field is not set or
11597 /// holds a different branch.
11598 pub fn index(&self) -> std::option::Option<&i32> {
11599 #[allow(unreachable_patterns)]
11600 self.index_or_key.as_ref().and_then(|v| match v {
11601 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
11602 _ => std::option::Option::None,
11603 })
11604 }
11605
11606 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11607 /// to hold a `Index`.
11608 ///
11609 /// Note that all the setters affecting `index_or_key` are
11610 /// mutually exclusive.
11611 ///
11612 /// # Example
11613 /// ```ignore,no_run
11614 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11615 /// let x = FieldReference::new().set_index(42);
11616 /// assert!(x.index().is_some());
11617 /// assert!(x.key().is_none());
11618 /// ```
11619 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11620 self.index_or_key = std::option::Option::Some(
11621 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
11622 v.into(),
11623 ),
11624 );
11625 self
11626 }
11627
11628 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11629 /// if it holds a `Key`, `None` if the field is not set or
11630 /// holds a different branch.
11631 pub fn key(&self) -> std::option::Option<&std::string::String> {
11632 #[allow(unreachable_patterns)]
11633 self.index_or_key.as_ref().and_then(|v| match v {
11634 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11635 v,
11636 ) => std::option::Option::Some(v),
11637 _ => std::option::Option::None,
11638 })
11639 }
11640
11641 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11642 /// to hold a `Key`.
11643 ///
11644 /// Note that all the setters affecting `index_or_key` are
11645 /// mutually exclusive.
11646 ///
11647 /// # Example
11648 /// ```ignore,no_run
11649 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11650 /// let x = FieldReference::new().set_key("example");
11651 /// assert!(x.key().is_some());
11652 /// assert!(x.index().is_none());
11653 /// ```
11654 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11655 self.index_or_key = std::option::Option::Some(
11656 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11657 v.into(),
11658 ),
11659 );
11660 self
11661 }
11662 }
11663
11664 impl wkt::message::Message for FieldReference {
11665 fn typename() -> &'static str {
11666 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
11667 }
11668 }
11669
11670 /// Defines additional types related to [FieldReference].
11671 pub mod field_reference {
11672 #[allow(unused_imports)]
11673 use super::*;
11674
11675 #[derive(Clone, Debug, PartialEq)]
11676 #[non_exhaustive]
11677 pub enum IndexOrKey {
11678 /// Index of the field if repeated.
11679 Index(i32),
11680 /// Key if the field is a map.
11681 Key(std::string::String),
11682 }
11683 }
11684}
11685
11686/// Data formats for input and output files.
11687///
11688/// # Working with unknown values
11689///
11690/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11691/// additional enum variants at any time. Adding new variants is not considered
11692/// a breaking change. Applications should write their code in anticipation of:
11693///
11694/// - New values appearing in future releases of the client library, **and**
11695/// - New values received dynamically, without application changes.
11696///
11697/// Please consult the [Working with enums] section in the user guide for some
11698/// guidelines.
11699///
11700/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
11701#[derive(Clone, Debug, PartialEq)]
11702#[non_exhaustive]
11703pub enum DataFormat {
11704 /// Default value.
11705 Unspecified,
11706 /// Input data in json format.
11707 Json,
11708 /// Input data in string format.
11709 String,
11710 /// If set, the enum was initialized with an unknown value.
11711 ///
11712 /// Applications can examine the value using [DataFormat::value] or
11713 /// [DataFormat::name].
11714 UnknownValue(data_format::UnknownValue),
11715}
11716
11717#[doc(hidden)]
11718pub mod data_format {
11719 #[allow(unused_imports)]
11720 use super::*;
11721 #[derive(Clone, Debug, PartialEq)]
11722 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11723}
11724
11725impl DataFormat {
11726 /// Gets the enum value.
11727 ///
11728 /// Returns `None` if the enum contains an unknown value deserialized from
11729 /// the string representation of enums.
11730 pub fn value(&self) -> std::option::Option<i32> {
11731 match self {
11732 Self::Unspecified => std::option::Option::Some(0),
11733 Self::Json => std::option::Option::Some(1),
11734 Self::String => std::option::Option::Some(2),
11735 Self::UnknownValue(u) => u.0.value(),
11736 }
11737 }
11738
11739 /// Gets the enum value as a string.
11740 ///
11741 /// Returns `None` if the enum contains an unknown value deserialized from
11742 /// the integer representation of enums.
11743 pub fn name(&self) -> std::option::Option<&str> {
11744 match self {
11745 Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
11746 Self::Json => std::option::Option::Some("JSON"),
11747 Self::String => std::option::Option::Some("STRING"),
11748 Self::UnknownValue(u) => u.0.name(),
11749 }
11750 }
11751}
11752
11753impl std::default::Default for DataFormat {
11754 fn default() -> Self {
11755 use std::convert::From;
11756 Self::from(0)
11757 }
11758}
11759
11760impl std::fmt::Display for DataFormat {
11761 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11762 wkt::internal::display_enum(f, self.name(), self.value())
11763 }
11764}
11765
11766impl std::convert::From<i32> for DataFormat {
11767 fn from(value: i32) -> Self {
11768 match value {
11769 0 => Self::Unspecified,
11770 1 => Self::Json,
11771 2 => Self::String,
11772 _ => Self::UnknownValue(data_format::UnknownValue(
11773 wkt::internal::UnknownEnumValue::Integer(value),
11774 )),
11775 }
11776 }
11777}
11778
11779impl std::convert::From<&str> for DataFormat {
11780 fn from(value: &str) -> Self {
11781 use std::string::ToString;
11782 match value {
11783 "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
11784 "JSON" => Self::Json,
11785 "STRING" => Self::String,
11786 _ => Self::UnknownValue(data_format::UnknownValue(
11787 wkt::internal::UnknownEnumValue::String(value.to_string()),
11788 )),
11789 }
11790 }
11791}
11792
11793impl serde::ser::Serialize for DataFormat {
11794 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11795 where
11796 S: serde::Serializer,
11797 {
11798 match self {
11799 Self::Unspecified => serializer.serialize_i32(0),
11800 Self::Json => serializer.serialize_i32(1),
11801 Self::String => serializer.serialize_i32(2),
11802 Self::UnknownValue(u) => u.0.serialize(serializer),
11803 }
11804 }
11805}
11806
11807impl<'de> serde::de::Deserialize<'de> for DataFormat {
11808 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11809 where
11810 D: serde::Deserializer<'de>,
11811 {
11812 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
11813 ".google.cloud.optimization.v1.DataFormat",
11814 ))
11815 }
11816}