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 serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34mod debug;
35mod deserialize;
36mod serialize;
37
38/// The desired input location information.
39#[derive(Clone, Default, PartialEq)]
40#[non_exhaustive]
41pub struct InputConfig {
42 /// The input data format that used to store the model in Cloud Storage.
43 pub data_format: crate::model::DataFormat,
44
45 /// The location of the input model in cloud storage.
46 /// Required.
47 pub source: std::option::Option<crate::model::input_config::Source>,
48
49 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
50}
51
52impl InputConfig {
53 pub fn new() -> Self {
54 std::default::Default::default()
55 }
56
57 /// Sets the value of [data_format][crate::model::InputConfig::data_format].
58 ///
59 /// # Example
60 /// ```ignore,no_run
61 /// # use google_cloud_optimization_v1::model::InputConfig;
62 /// use google_cloud_optimization_v1::model::DataFormat;
63 /// let x0 = InputConfig::new().set_data_format(DataFormat::Json);
64 /// let x1 = InputConfig::new().set_data_format(DataFormat::String);
65 /// ```
66 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
67 mut self,
68 v: T,
69 ) -> Self {
70 self.data_format = v.into();
71 self
72 }
73
74 /// Sets the value of [source][crate::model::InputConfig::source].
75 ///
76 /// Note that all the setters affecting `source` are mutually
77 /// exclusive.
78 ///
79 /// # Example
80 /// ```ignore,no_run
81 /// # use google_cloud_optimization_v1::model::InputConfig;
82 /// use google_cloud_optimization_v1::model::GcsSource;
83 /// let x = InputConfig::new().set_source(Some(
84 /// google_cloud_optimization_v1::model::input_config::Source::GcsSource(GcsSource::default().into())));
85 /// ```
86 pub fn set_source<
87 T: std::convert::Into<std::option::Option<crate::model::input_config::Source>>,
88 >(
89 mut self,
90 v: T,
91 ) -> Self {
92 self.source = v.into();
93 self
94 }
95
96 /// The value of [source][crate::model::InputConfig::source]
97 /// if it holds a `GcsSource`, `None` if the field is not set or
98 /// holds a different branch.
99 pub fn gcs_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::GcsSource>> {
100 #[allow(unreachable_patterns)]
101 self.source.as_ref().and_then(|v| match v {
102 crate::model::input_config::Source::GcsSource(v) => std::option::Option::Some(v),
103 _ => std::option::Option::None,
104 })
105 }
106
107 /// Sets the value of [source][crate::model::InputConfig::source]
108 /// to hold a `GcsSource`.
109 ///
110 /// Note that all the setters affecting `source` are
111 /// mutually exclusive.
112 ///
113 /// # Example
114 /// ```ignore,no_run
115 /// # use google_cloud_optimization_v1::model::InputConfig;
116 /// use google_cloud_optimization_v1::model::GcsSource;
117 /// let x = InputConfig::new().set_gcs_source(GcsSource::default()/* use setters */);
118 /// assert!(x.gcs_source().is_some());
119 /// ```
120 pub fn set_gcs_source<T: std::convert::Into<std::boxed::Box<crate::model::GcsSource>>>(
121 mut self,
122 v: T,
123 ) -> Self {
124 self.source =
125 std::option::Option::Some(crate::model::input_config::Source::GcsSource(v.into()));
126 self
127 }
128}
129
130impl wkt::message::Message for InputConfig {
131 fn typename() -> &'static str {
132 "type.googleapis.com/google.cloud.optimization.v1.InputConfig"
133 }
134}
135
136/// Defines additional types related to [InputConfig].
137pub mod input_config {
138 #[allow(unused_imports)]
139 use super::*;
140
141 /// The location of the input model in cloud storage.
142 /// Required.
143 #[derive(Clone, Debug, PartialEq)]
144 #[non_exhaustive]
145 pub enum Source {
146 /// The Google Cloud Storage location to read the input from. This must be a
147 /// single file.
148 GcsSource(std::boxed::Box<crate::model::GcsSource>),
149 }
150}
151
152/// The desired output location.
153#[derive(Clone, Default, PartialEq)]
154#[non_exhaustive]
155pub struct OutputConfig {
156 /// The output data format that used to store the results in Cloud Storage.
157 pub data_format: crate::model::DataFormat,
158
159 /// The location of the output result in cloud storage.
160 /// Required.
161 pub destination: std::option::Option<crate::model::output_config::Destination>,
162
163 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
164}
165
166impl OutputConfig {
167 pub fn new() -> Self {
168 std::default::Default::default()
169 }
170
171 /// Sets the value of [data_format][crate::model::OutputConfig::data_format].
172 ///
173 /// # Example
174 /// ```ignore,no_run
175 /// # use google_cloud_optimization_v1::model::OutputConfig;
176 /// use google_cloud_optimization_v1::model::DataFormat;
177 /// let x0 = OutputConfig::new().set_data_format(DataFormat::Json);
178 /// let x1 = OutputConfig::new().set_data_format(DataFormat::String);
179 /// ```
180 pub fn set_data_format<T: std::convert::Into<crate::model::DataFormat>>(
181 mut self,
182 v: T,
183 ) -> Self {
184 self.data_format = v.into();
185 self
186 }
187
188 /// Sets the value of [destination][crate::model::OutputConfig::destination].
189 ///
190 /// Note that all the setters affecting `destination` are mutually
191 /// exclusive.
192 ///
193 /// # Example
194 /// ```ignore,no_run
195 /// # use google_cloud_optimization_v1::model::OutputConfig;
196 /// use google_cloud_optimization_v1::model::GcsDestination;
197 /// let x = OutputConfig::new().set_destination(Some(
198 /// google_cloud_optimization_v1::model::output_config::Destination::GcsDestination(GcsDestination::default().into())));
199 /// ```
200 pub fn set_destination<
201 T: std::convert::Into<std::option::Option<crate::model::output_config::Destination>>,
202 >(
203 mut self,
204 v: T,
205 ) -> Self {
206 self.destination = v.into();
207 self
208 }
209
210 /// The value of [destination][crate::model::OutputConfig::destination]
211 /// if it holds a `GcsDestination`, `None` if the field is not set or
212 /// holds a different branch.
213 pub fn gcs_destination(
214 &self,
215 ) -> std::option::Option<&std::boxed::Box<crate::model::GcsDestination>> {
216 #[allow(unreachable_patterns)]
217 self.destination.as_ref().and_then(|v| match v {
218 crate::model::output_config::Destination::GcsDestination(v) => {
219 std::option::Option::Some(v)
220 }
221 _ => std::option::Option::None,
222 })
223 }
224
225 /// Sets the value of [destination][crate::model::OutputConfig::destination]
226 /// to hold a `GcsDestination`.
227 ///
228 /// Note that all the setters affecting `destination` are
229 /// mutually exclusive.
230 ///
231 /// # Example
232 /// ```ignore,no_run
233 /// # use google_cloud_optimization_v1::model::OutputConfig;
234 /// use google_cloud_optimization_v1::model::GcsDestination;
235 /// let x = OutputConfig::new().set_gcs_destination(GcsDestination::default()/* use setters */);
236 /// assert!(x.gcs_destination().is_some());
237 /// ```
238 pub fn set_gcs_destination<
239 T: std::convert::Into<std::boxed::Box<crate::model::GcsDestination>>,
240 >(
241 mut self,
242 v: T,
243 ) -> Self {
244 self.destination = std::option::Option::Some(
245 crate::model::output_config::Destination::GcsDestination(v.into()),
246 );
247 self
248 }
249}
250
251impl wkt::message::Message for OutputConfig {
252 fn typename() -> &'static str {
253 "type.googleapis.com/google.cloud.optimization.v1.OutputConfig"
254 }
255}
256
257/// Defines additional types related to [OutputConfig].
258pub mod output_config {
259 #[allow(unused_imports)]
260 use super::*;
261
262 /// The location of the output result in cloud storage.
263 /// Required.
264 #[derive(Clone, Debug, PartialEq)]
265 #[non_exhaustive]
266 pub enum Destination {
267 /// The Google Cloud Storage location to write the output to.
268 GcsDestination(std::boxed::Box<crate::model::GcsDestination>),
269 }
270}
271
272/// The Google Cloud Storage location where the input file will be read from.
273#[derive(Clone, Default, PartialEq)]
274#[non_exhaustive]
275pub struct GcsSource {
276 /// Required. URI of the Google Cloud Storage location.
277 pub uri: std::string::String,
278
279 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
280}
281
282impl GcsSource {
283 pub fn new() -> Self {
284 std::default::Default::default()
285 }
286
287 /// Sets the value of [uri][crate::model::GcsSource::uri].
288 ///
289 /// # Example
290 /// ```ignore,no_run
291 /// # use google_cloud_optimization_v1::model::GcsSource;
292 /// let x = GcsSource::new().set_uri("example");
293 /// ```
294 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
295 self.uri = v.into();
296 self
297 }
298}
299
300impl wkt::message::Message for GcsSource {
301 fn typename() -> &'static str {
302 "type.googleapis.com/google.cloud.optimization.v1.GcsSource"
303 }
304}
305
306/// The Google Cloud Storage location where the output file will be written to.
307#[derive(Clone, Default, PartialEq)]
308#[non_exhaustive]
309pub struct GcsDestination {
310 /// Required. URI of the Google Cloud Storage location.
311 pub uri: std::string::String,
312
313 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
314}
315
316impl GcsDestination {
317 pub fn new() -> Self {
318 std::default::Default::default()
319 }
320
321 /// Sets the value of [uri][crate::model::GcsDestination::uri].
322 ///
323 /// # Example
324 /// ```ignore,no_run
325 /// # use google_cloud_optimization_v1::model::GcsDestination;
326 /// let x = GcsDestination::new().set_uri("example");
327 /// ```
328 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
329 self.uri = v.into();
330 self
331 }
332}
333
334impl wkt::message::Message for GcsDestination {
335 fn typename() -> &'static str {
336 "type.googleapis.com/google.cloud.optimization.v1.GcsDestination"
337 }
338}
339
340/// The long running operation metadata for async model related methods.
341#[derive(Clone, Default, PartialEq)]
342#[non_exhaustive]
343pub struct AsyncModelMetadata {
344 /// The state of the current operation.
345 pub state: crate::model::async_model_metadata::State,
346
347 /// A message providing more details about the current state of the operation.
348 /// For example, the error message if the operation is failed.
349 pub state_message: std::string::String,
350
351 /// The creation time of the operation.
352 pub create_time: std::option::Option<wkt::Timestamp>,
353
354 /// The last update time of the operation.
355 pub update_time: std::option::Option<wkt::Timestamp>,
356
357 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
358}
359
360impl AsyncModelMetadata {
361 pub fn new() -> Self {
362 std::default::Default::default()
363 }
364
365 /// Sets the value of [state][crate::model::AsyncModelMetadata::state].
366 ///
367 /// # Example
368 /// ```ignore,no_run
369 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
370 /// use google_cloud_optimization_v1::model::async_model_metadata::State;
371 /// let x0 = AsyncModelMetadata::new().set_state(State::Running);
372 /// let x1 = AsyncModelMetadata::new().set_state(State::Succeeded);
373 /// let x2 = AsyncModelMetadata::new().set_state(State::Cancelled);
374 /// ```
375 pub fn set_state<T: std::convert::Into<crate::model::async_model_metadata::State>>(
376 mut self,
377 v: T,
378 ) -> Self {
379 self.state = v.into();
380 self
381 }
382
383 /// Sets the value of [state_message][crate::model::AsyncModelMetadata::state_message].
384 ///
385 /// # Example
386 /// ```ignore,no_run
387 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
388 /// let x = AsyncModelMetadata::new().set_state_message("example");
389 /// ```
390 pub fn set_state_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
391 self.state_message = v.into();
392 self
393 }
394
395 /// Sets the value of [create_time][crate::model::AsyncModelMetadata::create_time].
396 ///
397 /// # Example
398 /// ```ignore,no_run
399 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
400 /// use wkt::Timestamp;
401 /// let x = AsyncModelMetadata::new().set_create_time(Timestamp::default()/* use setters */);
402 /// ```
403 pub fn set_create_time<T>(mut self, v: T) -> Self
404 where
405 T: std::convert::Into<wkt::Timestamp>,
406 {
407 self.create_time = std::option::Option::Some(v.into());
408 self
409 }
410
411 /// Sets or clears the value of [create_time][crate::model::AsyncModelMetadata::create_time].
412 ///
413 /// # Example
414 /// ```ignore,no_run
415 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
416 /// use wkt::Timestamp;
417 /// let x = AsyncModelMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
418 /// let x = AsyncModelMetadata::new().set_or_clear_create_time(None::<Timestamp>);
419 /// ```
420 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
421 where
422 T: std::convert::Into<wkt::Timestamp>,
423 {
424 self.create_time = v.map(|x| x.into());
425 self
426 }
427
428 /// Sets the value of [update_time][crate::model::AsyncModelMetadata::update_time].
429 ///
430 /// # Example
431 /// ```ignore,no_run
432 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
433 /// use wkt::Timestamp;
434 /// let x = AsyncModelMetadata::new().set_update_time(Timestamp::default()/* use setters */);
435 /// ```
436 pub fn set_update_time<T>(mut self, v: T) -> Self
437 where
438 T: std::convert::Into<wkt::Timestamp>,
439 {
440 self.update_time = std::option::Option::Some(v.into());
441 self
442 }
443
444 /// Sets or clears the value of [update_time][crate::model::AsyncModelMetadata::update_time].
445 ///
446 /// # Example
447 /// ```ignore,no_run
448 /// # use google_cloud_optimization_v1::model::AsyncModelMetadata;
449 /// use wkt::Timestamp;
450 /// let x = AsyncModelMetadata::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
451 /// let x = AsyncModelMetadata::new().set_or_clear_update_time(None::<Timestamp>);
452 /// ```
453 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
454 where
455 T: std::convert::Into<wkt::Timestamp>,
456 {
457 self.update_time = v.map(|x| x.into());
458 self
459 }
460}
461
462impl wkt::message::Message for AsyncModelMetadata {
463 fn typename() -> &'static str {
464 "type.googleapis.com/google.cloud.optimization.v1.AsyncModelMetadata"
465 }
466}
467
468/// Defines additional types related to [AsyncModelMetadata].
469pub mod async_model_metadata {
470 #[allow(unused_imports)]
471 use super::*;
472
473 /// Possible states of the operation.
474 ///
475 /// # Working with unknown values
476 ///
477 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
478 /// additional enum variants at any time. Adding new variants is not considered
479 /// a breaking change. Applications should write their code in anticipation of:
480 ///
481 /// - New values appearing in future releases of the client library, **and**
482 /// - New values received dynamically, without application changes.
483 ///
484 /// Please consult the [Working with enums] section in the user guide for some
485 /// guidelines.
486 ///
487 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
488 #[derive(Clone, Debug, PartialEq)]
489 #[non_exhaustive]
490 pub enum State {
491 /// The default value. This value is used if the state is omitted.
492 Unspecified,
493 /// Request is being processed.
494 Running,
495 /// The operation completed successfully.
496 Succeeded,
497 /// The operation was cancelled.
498 Cancelled,
499 /// The operation has failed.
500 Failed,
501 /// If set, the enum was initialized with an unknown value.
502 ///
503 /// Applications can examine the value using [State::value] or
504 /// [State::name].
505 UnknownValue(state::UnknownValue),
506 }
507
508 #[doc(hidden)]
509 pub mod state {
510 #[allow(unused_imports)]
511 use super::*;
512 #[derive(Clone, Debug, PartialEq)]
513 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
514 }
515
516 impl State {
517 /// Gets the enum value.
518 ///
519 /// Returns `None` if the enum contains an unknown value deserialized from
520 /// the string representation of enums.
521 pub fn value(&self) -> std::option::Option<i32> {
522 match self {
523 Self::Unspecified => std::option::Option::Some(0),
524 Self::Running => std::option::Option::Some(1),
525 Self::Succeeded => std::option::Option::Some(2),
526 Self::Cancelled => std::option::Option::Some(3),
527 Self::Failed => std::option::Option::Some(4),
528 Self::UnknownValue(u) => u.0.value(),
529 }
530 }
531
532 /// Gets the enum value as a string.
533 ///
534 /// Returns `None` if the enum contains an unknown value deserialized from
535 /// the integer representation of enums.
536 pub fn name(&self) -> std::option::Option<&str> {
537 match self {
538 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
539 Self::Running => std::option::Option::Some("RUNNING"),
540 Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
541 Self::Cancelled => std::option::Option::Some("CANCELLED"),
542 Self::Failed => std::option::Option::Some("FAILED"),
543 Self::UnknownValue(u) => u.0.name(),
544 }
545 }
546 }
547
548 impl std::default::Default for State {
549 fn default() -> Self {
550 use std::convert::From;
551 Self::from(0)
552 }
553 }
554
555 impl std::fmt::Display for State {
556 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
557 wkt::internal::display_enum(f, self.name(), self.value())
558 }
559 }
560
561 impl std::convert::From<i32> for State {
562 fn from(value: i32) -> Self {
563 match value {
564 0 => Self::Unspecified,
565 1 => Self::Running,
566 2 => Self::Succeeded,
567 3 => Self::Cancelled,
568 4 => Self::Failed,
569 _ => Self::UnknownValue(state::UnknownValue(
570 wkt::internal::UnknownEnumValue::Integer(value),
571 )),
572 }
573 }
574 }
575
576 impl std::convert::From<&str> for State {
577 fn from(value: &str) -> Self {
578 use std::string::ToString;
579 match value {
580 "STATE_UNSPECIFIED" => Self::Unspecified,
581 "RUNNING" => Self::Running,
582 "SUCCEEDED" => Self::Succeeded,
583 "CANCELLED" => Self::Cancelled,
584 "FAILED" => Self::Failed,
585 _ => Self::UnknownValue(state::UnknownValue(
586 wkt::internal::UnknownEnumValue::String(value.to_string()),
587 )),
588 }
589 }
590 }
591
592 impl serde::ser::Serialize for State {
593 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
594 where
595 S: serde::Serializer,
596 {
597 match self {
598 Self::Unspecified => serializer.serialize_i32(0),
599 Self::Running => serializer.serialize_i32(1),
600 Self::Succeeded => serializer.serialize_i32(2),
601 Self::Cancelled => serializer.serialize_i32(3),
602 Self::Failed => serializer.serialize_i32(4),
603 Self::UnknownValue(u) => u.0.serialize(serializer),
604 }
605 }
606 }
607
608 impl<'de> serde::de::Deserialize<'de> for State {
609 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
610 where
611 D: serde::Deserializer<'de>,
612 {
613 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
614 ".google.cloud.optimization.v1.AsyncModelMetadata.State",
615 ))
616 }
617 }
618}
619
620/// Request to be given to a tour optimization solver which defines the
621/// shipment model to solve as well as optimization parameters.
622#[derive(Clone, Default, PartialEq)]
623#[non_exhaustive]
624pub struct OptimizeToursRequest {
625 /// Required. Target project and location to make a call.
626 ///
627 /// Format: `projects/{project-id}/locations/{location-id}`.
628 ///
629 /// If no location is specified, a region will be chosen automatically.
630 pub parent: std::string::String,
631
632 /// If this timeout is set, the server returns a response before the timeout
633 /// period has elapsed or the server deadline for synchronous requests is
634 /// reached, whichever is sooner.
635 ///
636 /// For asynchronous requests, the server will generate a solution (if
637 /// possible) before the timeout has elapsed.
638 pub timeout: std::option::Option<wkt::Duration>,
639
640 /// Shipment model to solve.
641 pub model: std::option::Option<crate::model::ShipmentModel>,
642
643 /// By default, the solving mode is `DEFAULT_SOLVE` (0).
644 pub solving_mode: crate::model::optimize_tours_request::SolvingMode,
645
646 /// Search mode used to solve the request.
647 pub search_mode: crate::model::optimize_tours_request::SearchMode,
648
649 /// Guide the optimization algorithm in finding a first solution that is
650 /// similar to a previous solution.
651 ///
652 /// The model is constrained when the first solution is built.
653 /// Any shipments not performed on a route are implicitly skipped in the first
654 /// solution, but they may be performed in successive solutions.
655 ///
656 /// The solution must satisfy some basic validity assumptions:
657 ///
658 /// * for all routes, `vehicle_index` must be in range and not be duplicated.
659 /// * for all visits, `shipment_index` and `visit_request_index` must be
660 /// in range.
661 /// * a shipment may only be referenced on one route.
662 /// * the pickup of a pickup-delivery shipment must be performed before
663 /// the delivery.
664 /// * no more than one pickup alternative or delivery alternative of
665 /// a shipment may be performed.
666 /// * for all routes, times are increasing (i.e., `vehicle_start_time
667 /// <= visits[0].start_time <= visits[1].start_time ...
668 /// <= vehicle_end_time`).
669 /// * a shipment may only be performed on a vehicle that is allowed. A
670 /// vehicle is allowed if
671 /// [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]
672 /// is empty or its `vehicle_index` is included in
673 /// [Shipment.allowed_vehicle_indices][google.cloud.optimization.v1.Shipment.allowed_vehicle_indices].
674 ///
675 /// If the injected solution is not feasible, a validation error is not
676 /// necessarily returned and an error indicating infeasibility may be returned
677 /// instead.
678 ///
679 /// [google.cloud.optimization.v1.Shipment.allowed_vehicle_indices]: crate::model::Shipment::allowed_vehicle_indices
680 pub injected_first_solution_routes: std::vec::Vec<crate::model::ShipmentRoute>,
681
682 /// Constrain the optimization algorithm to find a final solution that is
683 /// similar to a previous solution. For example, this may be used to freeze
684 /// portions of routes which have already been completed or which are to be
685 /// completed but must not be modified.
686 ///
687 /// If the injected solution is not feasible, a validation error is not
688 /// necessarily returned and an error indicating infeasibility may be returned
689 /// instead.
690 pub injected_solution_constraint: std::option::Option<crate::model::InjectedSolutionConstraint>,
691
692 /// If non-empty, the given routes will be refreshed, without modifying their
693 /// underlying sequence of visits or travel times: only other details will be
694 /// updated. This does not solve the model.
695 ///
696 /// As of 2020/11, this only populates the polylines of non-empty routes and
697 /// requires that `populate_polylines` is true.
698 ///
699 /// The `route_polyline` fields of the passed-in routes may be inconsistent
700 /// with route `transitions`.
701 ///
702 /// This field must not be used together with `injected_first_solution_routes`
703 /// or `injected_solution_constraint`.
704 ///
705 /// `Shipment.ignore` and `Vehicle.ignore` have no effect on the behavior.
706 /// Polylines are still populated between all visits in all non-empty routes
707 /// regardless of whether the related shipments or vehicles are ignored.
708 pub refresh_details_routes: std::vec::Vec<crate::model::ShipmentRoute>,
709
710 /// If true:
711 ///
712 /// * uses
713 /// [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label]
714 /// instead of `vehicle_index` to
715 /// match routes in an injected solution with vehicles in the request;
716 /// reuses the mapping of original
717 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
718 /// to new
719 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index]
720 /// to update
721 /// [ConstraintRelaxation.vehicle_indices][google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]
722 /// if non-empty, but the mapping must be unambiguous (i.e., multiple
723 /// `ShipmentRoute`s must not share the same original `vehicle_index`).
724 /// * uses
725 /// [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]
726 /// instead of `shipment_index`
727 /// to match visits in an injected solution with shipments in the request;
728 /// * uses
729 /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
730 /// instead of
731 /// [SkippedShipment.index][google.cloud.optimization.v1.SkippedShipment.index]
732 /// to
733 /// match skipped shipments in the injected solution with request
734 /// shipments.
735 ///
736 /// This interpretation applies to the `injected_first_solution_routes`,
737 /// `injected_solution_constraint`, and `refresh_details_routes` fields.
738 /// It can be used when shipment or vehicle indices in the request have
739 /// changed since the solution was created, perhaps because shipments or
740 /// vehicles have been removed from or added to the request.
741 ///
742 /// If true, labels in the following categories must appear at most once in
743 /// their category:
744 ///
745 /// * [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] in the
746 /// request;
747 /// * [Shipment.label][google.cloud.optimization.v1.Shipment.label] in the
748 /// request;
749 /// * [ShipmentRoute.vehicle_label][google.cloud.optimization.v1.ShipmentRoute.vehicle_label] in the injected solution;
750 /// * [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label] and [ShipmentRoute.Visit.shipment_label][google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label] in
751 /// the injected solution (except pickup/delivery visit pairs, whose
752 /// `shipment_label` must appear twice).
753 ///
754 /// If a `vehicle_label` in the injected solution does not correspond to a
755 /// request vehicle, the corresponding route is removed from the solution
756 /// along with its visits. If a `shipment_label` in the injected solution does
757 /// not correspond to a request shipment, the corresponding visit is removed
758 /// from the solution. If a
759 /// [SkippedShipment.label][google.cloud.optimization.v1.SkippedShipment.label]
760 /// in the injected solution does not correspond to a request shipment, the
761 /// `SkippedShipment` is removed from the solution.
762 ///
763 /// Removing route visits or entire routes from an injected solution may
764 /// have an effect on the implied constraints, which may lead to change in
765 /// solution, validation errors, or infeasibility.
766 ///
767 /// NOTE: The caller must ensure that each
768 /// [Vehicle.label][google.cloud.optimization.v1.Vehicle.label] (resp.
769 /// [Shipment.label][google.cloud.optimization.v1.Shipment.label]) uniquely
770 /// identifies a vehicle (resp. shipment) entity used across the two relevant
771 /// requests: the past request that produced the `OptimizeToursResponse` used
772 /// in the injected solution and the current request that includes the injected
773 /// solution. The uniqueness checks described above are not enough to guarantee
774 /// this requirement.
775 ///
776 /// [google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.vehicle_indices]: crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices
777 /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
778 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.shipment_label]: crate::model::shipment_route::Visit::shipment_label
779 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
780 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_label]: crate::model::ShipmentRoute::vehicle_label
781 /// [google.cloud.optimization.v1.SkippedShipment.index]: crate::model::SkippedShipment::index
782 /// [google.cloud.optimization.v1.SkippedShipment.label]: crate::model::SkippedShipment::label
783 /// [google.cloud.optimization.v1.Vehicle.label]: crate::model::Vehicle::label
784 pub interpret_injected_solutions_using_labels: bool,
785
786 /// Consider traffic estimation in calculating `ShipmentRoute` fields
787 /// [Transition.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration],
788 /// [Visit.start_time][google.cloud.optimization.v1.ShipmentRoute.Visit.start_time],
789 /// and `vehicle_end_time`; in setting the
790 /// [ShipmentRoute.has_traffic_infeasibilities][google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]
791 /// field, and in calculating the
792 /// [OptimizeToursResponse.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.total_cost]
793 /// field.
794 ///
795 /// [google.cloud.optimization.v1.OptimizeToursResponse.total_cost]: crate::model::OptimizeToursResponse::total_cost
796 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
797 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.start_time]: crate::model::shipment_route::Visit::start_time
798 /// [google.cloud.optimization.v1.ShipmentRoute.has_traffic_infeasibilities]: crate::model::ShipmentRoute::has_traffic_infeasibilities
799 pub consider_road_traffic: bool,
800
801 /// If true, polylines will be populated in response `ShipmentRoute`s.
802 pub populate_polylines: bool,
803
804 /// If true, polylines will be populated in response
805 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
806 /// Note that in this case, the polylines will also be populated in the
807 /// deprecated `travel_steps`.
808 ///
809 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
810 pub populate_transition_polylines: bool,
811
812 /// If this is set, then the request can have a deadline
813 /// (see <https://grpc.io/blog/deadlines>) of up to 60 minutes.
814 /// Otherwise, the maximum deadline is only 30 minutes.
815 /// Note that long-lived requests have a significantly larger (but still small)
816 /// risk of interruption.
817 pub allow_large_deadline_despite_interruption_risk: bool,
818
819 /// If true, travel distances will be computed using geodesic distances instead
820 /// of Google Maps distances, and travel times will be computed using geodesic
821 /// distances with a speed defined by `geodesic_meters_per_second`.
822 pub use_geodesic_distances: bool,
823
824 /// When `use_geodesic_distances` is true, this field must be set and defines
825 /// the speed applied to compute travel times. Its value must be at least 1.0
826 /// meters/seconds.
827 pub geodesic_meters_per_second: std::option::Option<f64>,
828
829 /// Truncates the number of validation errors returned. These errors are
830 /// typically attached to an INVALID_ARGUMENT error payload as a BadRequest
831 /// error detail (<https://cloud.google.com/apis/design/errors#error_details>),
832 /// unless solving_mode=VALIDATE_ONLY: see the
833 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
834 /// field.
835 /// This defaults to 100 and is capped at 10,000.
836 ///
837 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
838 pub max_validation_errors: std::option::Option<i32>,
839
840 /// Label that may be used to identify this request, reported back in the
841 /// [OptimizeToursResponse.request_label][google.cloud.optimization.v1.OptimizeToursResponse.request_label].
842 ///
843 /// [google.cloud.optimization.v1.OptimizeToursResponse.request_label]: crate::model::OptimizeToursResponse::request_label
844 pub label: std::string::String,
845
846 /// Deprecated: Use
847 /// [OptimizeToursRequest.populate_transition_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
848 /// instead. If true, polylines will be populated in response
849 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions].
850 /// Note that in this case, the polylines will also be populated in the
851 /// deprecated `travel_steps`.
852 ///
853 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]: crate::model::OptimizeToursRequest::populate_transition_polylines
854 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
855 #[deprecated]
856 pub populate_travel_step_polylines: bool,
857
858 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
859}
860
861impl OptimizeToursRequest {
862 pub fn new() -> Self {
863 std::default::Default::default()
864 }
865
866 /// Sets the value of [parent][crate::model::OptimizeToursRequest::parent].
867 ///
868 /// # Example
869 /// ```ignore,no_run
870 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
871 /// let x = OptimizeToursRequest::new().set_parent("example");
872 /// ```
873 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
874 self.parent = v.into();
875 self
876 }
877
878 /// Sets the value of [timeout][crate::model::OptimizeToursRequest::timeout].
879 ///
880 /// # Example
881 /// ```ignore,no_run
882 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
883 /// use wkt::Duration;
884 /// let x = OptimizeToursRequest::new().set_timeout(Duration::default()/* use setters */);
885 /// ```
886 pub fn set_timeout<T>(mut self, v: T) -> Self
887 where
888 T: std::convert::Into<wkt::Duration>,
889 {
890 self.timeout = std::option::Option::Some(v.into());
891 self
892 }
893
894 /// Sets or clears the value of [timeout][crate::model::OptimizeToursRequest::timeout].
895 ///
896 /// # Example
897 /// ```ignore,no_run
898 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
899 /// use wkt::Duration;
900 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(Some(Duration::default()/* use setters */));
901 /// let x = OptimizeToursRequest::new().set_or_clear_timeout(None::<Duration>);
902 /// ```
903 pub fn set_or_clear_timeout<T>(mut self, v: std::option::Option<T>) -> Self
904 where
905 T: std::convert::Into<wkt::Duration>,
906 {
907 self.timeout = v.map(|x| x.into());
908 self
909 }
910
911 /// Sets the value of [model][crate::model::OptimizeToursRequest::model].
912 ///
913 /// # Example
914 /// ```ignore,no_run
915 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
916 /// use google_cloud_optimization_v1::model::ShipmentModel;
917 /// let x = OptimizeToursRequest::new().set_model(ShipmentModel::default()/* use setters */);
918 /// ```
919 pub fn set_model<T>(mut self, v: T) -> Self
920 where
921 T: std::convert::Into<crate::model::ShipmentModel>,
922 {
923 self.model = std::option::Option::Some(v.into());
924 self
925 }
926
927 /// Sets or clears the value of [model][crate::model::OptimizeToursRequest::model].
928 ///
929 /// # Example
930 /// ```ignore,no_run
931 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
932 /// use google_cloud_optimization_v1::model::ShipmentModel;
933 /// let x = OptimizeToursRequest::new().set_or_clear_model(Some(ShipmentModel::default()/* use setters */));
934 /// let x = OptimizeToursRequest::new().set_or_clear_model(None::<ShipmentModel>);
935 /// ```
936 pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
937 where
938 T: std::convert::Into<crate::model::ShipmentModel>,
939 {
940 self.model = v.map(|x| x.into());
941 self
942 }
943
944 /// Sets the value of [solving_mode][crate::model::OptimizeToursRequest::solving_mode].
945 ///
946 /// # Example
947 /// ```ignore,no_run
948 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
949 /// use google_cloud_optimization_v1::model::optimize_tours_request::SolvingMode;
950 /// let x0 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::ValidateOnly);
951 /// let x1 = OptimizeToursRequest::new().set_solving_mode(SolvingMode::DetectSomeInfeasibleShipments);
952 /// ```
953 pub fn set_solving_mode<
954 T: std::convert::Into<crate::model::optimize_tours_request::SolvingMode>,
955 >(
956 mut self,
957 v: T,
958 ) -> Self {
959 self.solving_mode = v.into();
960 self
961 }
962
963 /// Sets the value of [search_mode][crate::model::OptimizeToursRequest::search_mode].
964 ///
965 /// # Example
966 /// ```ignore,no_run
967 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
968 /// use google_cloud_optimization_v1::model::optimize_tours_request::SearchMode;
969 /// let x0 = OptimizeToursRequest::new().set_search_mode(SearchMode::ReturnFast);
970 /// let x1 = OptimizeToursRequest::new().set_search_mode(SearchMode::ConsumeAllAvailableTime);
971 /// ```
972 pub fn set_search_mode<
973 T: std::convert::Into<crate::model::optimize_tours_request::SearchMode>,
974 >(
975 mut self,
976 v: T,
977 ) -> Self {
978 self.search_mode = v.into();
979 self
980 }
981
982 /// Sets the value of [injected_first_solution_routes][crate::model::OptimizeToursRequest::injected_first_solution_routes].
983 ///
984 /// # Example
985 /// ```ignore,no_run
986 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
987 /// use google_cloud_optimization_v1::model::ShipmentRoute;
988 /// let x = OptimizeToursRequest::new()
989 /// .set_injected_first_solution_routes([
990 /// ShipmentRoute::default()/* use setters */,
991 /// ShipmentRoute::default()/* use (different) setters */,
992 /// ]);
993 /// ```
994 pub fn set_injected_first_solution_routes<T, V>(mut self, v: T) -> Self
995 where
996 T: std::iter::IntoIterator<Item = V>,
997 V: std::convert::Into<crate::model::ShipmentRoute>,
998 {
999 use std::iter::Iterator;
1000 self.injected_first_solution_routes = v.into_iter().map(|i| i.into()).collect();
1001 self
1002 }
1003
1004 /// Sets the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1005 ///
1006 /// # Example
1007 /// ```ignore,no_run
1008 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1009 /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1010 /// let x = OptimizeToursRequest::new().set_injected_solution_constraint(InjectedSolutionConstraint::default()/* use setters */);
1011 /// ```
1012 pub fn set_injected_solution_constraint<T>(mut self, v: T) -> Self
1013 where
1014 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1015 {
1016 self.injected_solution_constraint = std::option::Option::Some(v.into());
1017 self
1018 }
1019
1020 /// Sets or clears the value of [injected_solution_constraint][crate::model::OptimizeToursRequest::injected_solution_constraint].
1021 ///
1022 /// # Example
1023 /// ```ignore,no_run
1024 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1025 /// use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
1026 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(Some(InjectedSolutionConstraint::default()/* use setters */));
1027 /// let x = OptimizeToursRequest::new().set_or_clear_injected_solution_constraint(None::<InjectedSolutionConstraint>);
1028 /// ```
1029 pub fn set_or_clear_injected_solution_constraint<T>(mut self, v: std::option::Option<T>) -> Self
1030 where
1031 T: std::convert::Into<crate::model::InjectedSolutionConstraint>,
1032 {
1033 self.injected_solution_constraint = v.map(|x| x.into());
1034 self
1035 }
1036
1037 /// Sets the value of [refresh_details_routes][crate::model::OptimizeToursRequest::refresh_details_routes].
1038 ///
1039 /// # Example
1040 /// ```ignore,no_run
1041 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1042 /// use google_cloud_optimization_v1::model::ShipmentRoute;
1043 /// let x = OptimizeToursRequest::new()
1044 /// .set_refresh_details_routes([
1045 /// ShipmentRoute::default()/* use setters */,
1046 /// ShipmentRoute::default()/* use (different) setters */,
1047 /// ]);
1048 /// ```
1049 pub fn set_refresh_details_routes<T, V>(mut self, v: T) -> Self
1050 where
1051 T: std::iter::IntoIterator<Item = V>,
1052 V: std::convert::Into<crate::model::ShipmentRoute>,
1053 {
1054 use std::iter::Iterator;
1055 self.refresh_details_routes = v.into_iter().map(|i| i.into()).collect();
1056 self
1057 }
1058
1059 /// Sets the value of [interpret_injected_solutions_using_labels][crate::model::OptimizeToursRequest::interpret_injected_solutions_using_labels].
1060 ///
1061 /// # Example
1062 /// ```ignore,no_run
1063 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1064 /// let x = OptimizeToursRequest::new().set_interpret_injected_solutions_using_labels(true);
1065 /// ```
1066 pub fn set_interpret_injected_solutions_using_labels<T: std::convert::Into<bool>>(
1067 mut self,
1068 v: T,
1069 ) -> Self {
1070 self.interpret_injected_solutions_using_labels = v.into();
1071 self
1072 }
1073
1074 /// Sets the value of [consider_road_traffic][crate::model::OptimizeToursRequest::consider_road_traffic].
1075 ///
1076 /// # Example
1077 /// ```ignore,no_run
1078 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1079 /// let x = OptimizeToursRequest::new().set_consider_road_traffic(true);
1080 /// ```
1081 pub fn set_consider_road_traffic<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1082 self.consider_road_traffic = v.into();
1083 self
1084 }
1085
1086 /// Sets the value of [populate_polylines][crate::model::OptimizeToursRequest::populate_polylines].
1087 ///
1088 /// # Example
1089 /// ```ignore,no_run
1090 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1091 /// let x = OptimizeToursRequest::new().set_populate_polylines(true);
1092 /// ```
1093 pub fn set_populate_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1094 self.populate_polylines = v.into();
1095 self
1096 }
1097
1098 /// Sets the value of [populate_transition_polylines][crate::model::OptimizeToursRequest::populate_transition_polylines].
1099 ///
1100 /// # Example
1101 /// ```ignore,no_run
1102 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1103 /// let x = OptimizeToursRequest::new().set_populate_transition_polylines(true);
1104 /// ```
1105 pub fn set_populate_transition_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1106 self.populate_transition_polylines = v.into();
1107 self
1108 }
1109
1110 /// Sets the value of [allow_large_deadline_despite_interruption_risk][crate::model::OptimizeToursRequest::allow_large_deadline_despite_interruption_risk].
1111 ///
1112 /// # Example
1113 /// ```ignore,no_run
1114 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1115 /// let x = OptimizeToursRequest::new().set_allow_large_deadline_despite_interruption_risk(true);
1116 /// ```
1117 pub fn set_allow_large_deadline_despite_interruption_risk<T: std::convert::Into<bool>>(
1118 mut self,
1119 v: T,
1120 ) -> Self {
1121 self.allow_large_deadline_despite_interruption_risk = v.into();
1122 self
1123 }
1124
1125 /// Sets the value of [use_geodesic_distances][crate::model::OptimizeToursRequest::use_geodesic_distances].
1126 ///
1127 /// # Example
1128 /// ```ignore,no_run
1129 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1130 /// let x = OptimizeToursRequest::new().set_use_geodesic_distances(true);
1131 /// ```
1132 pub fn set_use_geodesic_distances<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1133 self.use_geodesic_distances = v.into();
1134 self
1135 }
1136
1137 /// Sets the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1138 ///
1139 /// # Example
1140 /// ```ignore,no_run
1141 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1142 /// let x = OptimizeToursRequest::new().set_geodesic_meters_per_second(42.0);
1143 /// ```
1144 pub fn set_geodesic_meters_per_second<T>(mut self, v: T) -> Self
1145 where
1146 T: std::convert::Into<f64>,
1147 {
1148 self.geodesic_meters_per_second = std::option::Option::Some(v.into());
1149 self
1150 }
1151
1152 /// Sets or clears the value of [geodesic_meters_per_second][crate::model::OptimizeToursRequest::geodesic_meters_per_second].
1153 ///
1154 /// # Example
1155 /// ```ignore,no_run
1156 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1157 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(Some(42.0));
1158 /// let x = OptimizeToursRequest::new().set_or_clear_geodesic_meters_per_second(None::<f32>);
1159 /// ```
1160 pub fn set_or_clear_geodesic_meters_per_second<T>(mut self, v: std::option::Option<T>) -> Self
1161 where
1162 T: std::convert::Into<f64>,
1163 {
1164 self.geodesic_meters_per_second = v.map(|x| x.into());
1165 self
1166 }
1167
1168 /// Sets the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1169 ///
1170 /// # Example
1171 /// ```ignore,no_run
1172 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1173 /// let x = OptimizeToursRequest::new().set_max_validation_errors(42);
1174 /// ```
1175 pub fn set_max_validation_errors<T>(mut self, v: T) -> Self
1176 where
1177 T: std::convert::Into<i32>,
1178 {
1179 self.max_validation_errors = std::option::Option::Some(v.into());
1180 self
1181 }
1182
1183 /// Sets or clears the value of [max_validation_errors][crate::model::OptimizeToursRequest::max_validation_errors].
1184 ///
1185 /// # Example
1186 /// ```ignore,no_run
1187 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1188 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(Some(42));
1189 /// let x = OptimizeToursRequest::new().set_or_clear_max_validation_errors(None::<i32>);
1190 /// ```
1191 pub fn set_or_clear_max_validation_errors<T>(mut self, v: std::option::Option<T>) -> Self
1192 where
1193 T: std::convert::Into<i32>,
1194 {
1195 self.max_validation_errors = v.map(|x| x.into());
1196 self
1197 }
1198
1199 /// Sets the value of [label][crate::model::OptimizeToursRequest::label].
1200 ///
1201 /// # Example
1202 /// ```ignore,no_run
1203 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1204 /// let x = OptimizeToursRequest::new().set_label("example");
1205 /// ```
1206 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1207 self.label = v.into();
1208 self
1209 }
1210
1211 /// Sets the value of [populate_travel_step_polylines][crate::model::OptimizeToursRequest::populate_travel_step_polylines].
1212 ///
1213 /// # Example
1214 /// ```ignore,no_run
1215 /// # use google_cloud_optimization_v1::model::OptimizeToursRequest;
1216 /// let x = OptimizeToursRequest::new().set_populate_travel_step_polylines(true);
1217 /// ```
1218 #[deprecated]
1219 pub fn set_populate_travel_step_polylines<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1220 self.populate_travel_step_polylines = v.into();
1221 self
1222 }
1223}
1224
1225impl wkt::message::Message for OptimizeToursRequest {
1226 fn typename() -> &'static str {
1227 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursRequest"
1228 }
1229}
1230
1231/// Defines additional types related to [OptimizeToursRequest].
1232pub mod optimize_tours_request {
1233 #[allow(unused_imports)]
1234 use super::*;
1235
1236 /// Defines how the solver should handle the request. In all modes but
1237 /// `VALIDATE_ONLY`, if the request is invalid, you will receive an
1238 /// `INVALID_REQUEST` error. See
1239 /// [max_validation_errors][google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]
1240 /// to cap the number of errors returned.
1241 ///
1242 /// [google.cloud.optimization.v1.OptimizeToursRequest.max_validation_errors]: crate::model::OptimizeToursRequest::max_validation_errors
1243 ///
1244 /// # Working with unknown values
1245 ///
1246 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1247 /// additional enum variants at any time. Adding new variants is not considered
1248 /// a breaking change. Applications should write their code in anticipation of:
1249 ///
1250 /// - New values appearing in future releases of the client library, **and**
1251 /// - New values received dynamically, without application changes.
1252 ///
1253 /// Please consult the [Working with enums] section in the user guide for some
1254 /// guidelines.
1255 ///
1256 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1257 #[derive(Clone, Debug, PartialEq)]
1258 #[non_exhaustive]
1259 pub enum SolvingMode {
1260 /// Solve the model.
1261 DefaultSolve,
1262 /// Only validates the model without solving it: populates as many
1263 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1264 /// as possible.
1265 ///
1266 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1267 ValidateOnly,
1268 /// Only populates
1269 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1270 /// or
1271 /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments],
1272 /// and doesn't actually solve the rest of the request (`status` and `routes`
1273 /// are unset in the response).
1274 /// If infeasibilities in `injected_solution_constraint` routes are detected
1275 /// they are populated in the
1276 /// [OptimizeToursResponse.validation_errors][google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]
1277 /// field and
1278 /// [OptimizeToursResponse.skipped_shipments][google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]
1279 /// is left empty.
1280 ///
1281 /// *IMPORTANT*: not all infeasible shipments are returned here, but only the
1282 /// ones that are detected as infeasible during preprocessing.
1283 ///
1284 /// [google.cloud.optimization.v1.OptimizeToursResponse.skipped_shipments]: crate::model::OptimizeToursResponse::skipped_shipments
1285 /// [google.cloud.optimization.v1.OptimizeToursResponse.validation_errors]: crate::model::OptimizeToursResponse::validation_errors
1286 DetectSomeInfeasibleShipments,
1287 /// If set, the enum was initialized with an unknown value.
1288 ///
1289 /// Applications can examine the value using [SolvingMode::value] or
1290 /// [SolvingMode::name].
1291 UnknownValue(solving_mode::UnknownValue),
1292 }
1293
1294 #[doc(hidden)]
1295 pub mod solving_mode {
1296 #[allow(unused_imports)]
1297 use super::*;
1298 #[derive(Clone, Debug, PartialEq)]
1299 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1300 }
1301
1302 impl SolvingMode {
1303 /// Gets the enum value.
1304 ///
1305 /// Returns `None` if the enum contains an unknown value deserialized from
1306 /// the string representation of enums.
1307 pub fn value(&self) -> std::option::Option<i32> {
1308 match self {
1309 Self::DefaultSolve => std::option::Option::Some(0),
1310 Self::ValidateOnly => std::option::Option::Some(1),
1311 Self::DetectSomeInfeasibleShipments => std::option::Option::Some(2),
1312 Self::UnknownValue(u) => u.0.value(),
1313 }
1314 }
1315
1316 /// Gets the enum value as a string.
1317 ///
1318 /// Returns `None` if the enum contains an unknown value deserialized from
1319 /// the integer representation of enums.
1320 pub fn name(&self) -> std::option::Option<&str> {
1321 match self {
1322 Self::DefaultSolve => std::option::Option::Some("DEFAULT_SOLVE"),
1323 Self::ValidateOnly => std::option::Option::Some("VALIDATE_ONLY"),
1324 Self::DetectSomeInfeasibleShipments => {
1325 std::option::Option::Some("DETECT_SOME_INFEASIBLE_SHIPMENTS")
1326 }
1327 Self::UnknownValue(u) => u.0.name(),
1328 }
1329 }
1330 }
1331
1332 impl std::default::Default for SolvingMode {
1333 fn default() -> Self {
1334 use std::convert::From;
1335 Self::from(0)
1336 }
1337 }
1338
1339 impl std::fmt::Display for SolvingMode {
1340 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1341 wkt::internal::display_enum(f, self.name(), self.value())
1342 }
1343 }
1344
1345 impl std::convert::From<i32> for SolvingMode {
1346 fn from(value: i32) -> Self {
1347 match value {
1348 0 => Self::DefaultSolve,
1349 1 => Self::ValidateOnly,
1350 2 => Self::DetectSomeInfeasibleShipments,
1351 _ => Self::UnknownValue(solving_mode::UnknownValue(
1352 wkt::internal::UnknownEnumValue::Integer(value),
1353 )),
1354 }
1355 }
1356 }
1357
1358 impl std::convert::From<&str> for SolvingMode {
1359 fn from(value: &str) -> Self {
1360 use std::string::ToString;
1361 match value {
1362 "DEFAULT_SOLVE" => Self::DefaultSolve,
1363 "VALIDATE_ONLY" => Self::ValidateOnly,
1364 "DETECT_SOME_INFEASIBLE_SHIPMENTS" => Self::DetectSomeInfeasibleShipments,
1365 _ => Self::UnknownValue(solving_mode::UnknownValue(
1366 wkt::internal::UnknownEnumValue::String(value.to_string()),
1367 )),
1368 }
1369 }
1370 }
1371
1372 impl serde::ser::Serialize for SolvingMode {
1373 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1374 where
1375 S: serde::Serializer,
1376 {
1377 match self {
1378 Self::DefaultSolve => serializer.serialize_i32(0),
1379 Self::ValidateOnly => serializer.serialize_i32(1),
1380 Self::DetectSomeInfeasibleShipments => serializer.serialize_i32(2),
1381 Self::UnknownValue(u) => u.0.serialize(serializer),
1382 }
1383 }
1384 }
1385
1386 impl<'de> serde::de::Deserialize<'de> for SolvingMode {
1387 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1388 where
1389 D: serde::Deserializer<'de>,
1390 {
1391 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SolvingMode>::new(
1392 ".google.cloud.optimization.v1.OptimizeToursRequest.SolvingMode",
1393 ))
1394 }
1395 }
1396
1397 /// Mode defining the behavior of the search, trading off latency versus
1398 /// solution quality. In all modes, the global request deadline is enforced.
1399 ///
1400 /// # Working with unknown values
1401 ///
1402 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1403 /// additional enum variants at any time. Adding new variants is not considered
1404 /// a breaking change. Applications should write their code in anticipation of:
1405 ///
1406 /// - New values appearing in future releases of the client library, **and**
1407 /// - New values received dynamically, without application changes.
1408 ///
1409 /// Please consult the [Working with enums] section in the user guide for some
1410 /// guidelines.
1411 ///
1412 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1413 #[derive(Clone, Debug, PartialEq)]
1414 #[non_exhaustive]
1415 pub enum SearchMode {
1416 /// Unspecified search mode, equivalent to `RETURN_FAST`.
1417 Unspecified,
1418 /// Stop the search after finding the first good solution.
1419 ReturnFast,
1420 /// Spend all the available time to search for better solutions.
1421 ConsumeAllAvailableTime,
1422 /// If set, the enum was initialized with an unknown value.
1423 ///
1424 /// Applications can examine the value using [SearchMode::value] or
1425 /// [SearchMode::name].
1426 UnknownValue(search_mode::UnknownValue),
1427 }
1428
1429 #[doc(hidden)]
1430 pub mod search_mode {
1431 #[allow(unused_imports)]
1432 use super::*;
1433 #[derive(Clone, Debug, PartialEq)]
1434 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1435 }
1436
1437 impl SearchMode {
1438 /// Gets the enum value.
1439 ///
1440 /// Returns `None` if the enum contains an unknown value deserialized from
1441 /// the string representation of enums.
1442 pub fn value(&self) -> std::option::Option<i32> {
1443 match self {
1444 Self::Unspecified => std::option::Option::Some(0),
1445 Self::ReturnFast => std::option::Option::Some(1),
1446 Self::ConsumeAllAvailableTime => std::option::Option::Some(2),
1447 Self::UnknownValue(u) => u.0.value(),
1448 }
1449 }
1450
1451 /// Gets the enum value as a string.
1452 ///
1453 /// Returns `None` if the enum contains an unknown value deserialized from
1454 /// the integer representation of enums.
1455 pub fn name(&self) -> std::option::Option<&str> {
1456 match self {
1457 Self::Unspecified => std::option::Option::Some("SEARCH_MODE_UNSPECIFIED"),
1458 Self::ReturnFast => std::option::Option::Some("RETURN_FAST"),
1459 Self::ConsumeAllAvailableTime => {
1460 std::option::Option::Some("CONSUME_ALL_AVAILABLE_TIME")
1461 }
1462 Self::UnknownValue(u) => u.0.name(),
1463 }
1464 }
1465 }
1466
1467 impl std::default::Default for SearchMode {
1468 fn default() -> Self {
1469 use std::convert::From;
1470 Self::from(0)
1471 }
1472 }
1473
1474 impl std::fmt::Display for SearchMode {
1475 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1476 wkt::internal::display_enum(f, self.name(), self.value())
1477 }
1478 }
1479
1480 impl std::convert::From<i32> for SearchMode {
1481 fn from(value: i32) -> Self {
1482 match value {
1483 0 => Self::Unspecified,
1484 1 => Self::ReturnFast,
1485 2 => Self::ConsumeAllAvailableTime,
1486 _ => Self::UnknownValue(search_mode::UnknownValue(
1487 wkt::internal::UnknownEnumValue::Integer(value),
1488 )),
1489 }
1490 }
1491 }
1492
1493 impl std::convert::From<&str> for SearchMode {
1494 fn from(value: &str) -> Self {
1495 use std::string::ToString;
1496 match value {
1497 "SEARCH_MODE_UNSPECIFIED" => Self::Unspecified,
1498 "RETURN_FAST" => Self::ReturnFast,
1499 "CONSUME_ALL_AVAILABLE_TIME" => Self::ConsumeAllAvailableTime,
1500 _ => Self::UnknownValue(search_mode::UnknownValue(
1501 wkt::internal::UnknownEnumValue::String(value.to_string()),
1502 )),
1503 }
1504 }
1505 }
1506
1507 impl serde::ser::Serialize for SearchMode {
1508 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1509 where
1510 S: serde::Serializer,
1511 {
1512 match self {
1513 Self::Unspecified => serializer.serialize_i32(0),
1514 Self::ReturnFast => serializer.serialize_i32(1),
1515 Self::ConsumeAllAvailableTime => serializer.serialize_i32(2),
1516 Self::UnknownValue(u) => u.0.serialize(serializer),
1517 }
1518 }
1519 }
1520
1521 impl<'de> serde::de::Deserialize<'de> for SearchMode {
1522 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1523 where
1524 D: serde::Deserializer<'de>,
1525 {
1526 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SearchMode>::new(
1527 ".google.cloud.optimization.v1.OptimizeToursRequest.SearchMode",
1528 ))
1529 }
1530 }
1531}
1532
1533/// Response after solving a tour optimization problem containing the routes
1534/// followed by each vehicle, the shipments which have been skipped and the
1535/// overall cost of the solution.
1536#[derive(Clone, Default, PartialEq)]
1537#[non_exhaustive]
1538pub struct OptimizeToursResponse {
1539 /// Routes computed for each vehicle; the i-th route corresponds to the i-th
1540 /// vehicle in the model.
1541 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
1542
1543 /// Copy of the
1544 /// [OptimizeToursRequest.label][google.cloud.optimization.v1.OptimizeToursRequest.label],
1545 /// if a label was specified in the request.
1546 ///
1547 /// [google.cloud.optimization.v1.OptimizeToursRequest.label]: crate::model::OptimizeToursRequest::label
1548 pub request_label: std::string::String,
1549
1550 /// The list of all shipments skipped.
1551 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
1552
1553 /// List of all the validation errors that we were able to detect
1554 /// independently. See the "MULTIPLE ERRORS" explanation for the
1555 /// [OptimizeToursValidationError][google.cloud.optimization.v1.OptimizeToursValidationError]
1556 /// message.
1557 ///
1558 /// [google.cloud.optimization.v1.OptimizeToursValidationError]: crate::model::OptimizeToursValidationError
1559 pub validation_errors: std::vec::Vec<crate::model::OptimizeToursValidationError>,
1560
1561 /// Duration, distance and usage metrics for this solution.
1562 pub metrics: std::option::Option<crate::model::optimize_tours_response::Metrics>,
1563
1564 /// Deprecated: Use
1565 /// [Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
1566 /// instead. Total cost of the solution. This takes into account all costs:
1567 /// costs per per hour and travel hour, fixed vehicle costs, unperformed
1568 /// shipment penalty costs, global duration cost, etc.
1569 ///
1570 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
1571 #[deprecated]
1572 pub total_cost: f64,
1573
1574 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1575}
1576
1577impl OptimizeToursResponse {
1578 pub fn new() -> Self {
1579 std::default::Default::default()
1580 }
1581
1582 /// Sets the value of [routes][crate::model::OptimizeToursResponse::routes].
1583 ///
1584 /// # Example
1585 /// ```ignore,no_run
1586 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1587 /// use google_cloud_optimization_v1::model::ShipmentRoute;
1588 /// let x = OptimizeToursResponse::new()
1589 /// .set_routes([
1590 /// ShipmentRoute::default()/* use setters */,
1591 /// ShipmentRoute::default()/* use (different) setters */,
1592 /// ]);
1593 /// ```
1594 pub fn set_routes<T, V>(mut self, v: T) -> Self
1595 where
1596 T: std::iter::IntoIterator<Item = V>,
1597 V: std::convert::Into<crate::model::ShipmentRoute>,
1598 {
1599 use std::iter::Iterator;
1600 self.routes = v.into_iter().map(|i| i.into()).collect();
1601 self
1602 }
1603
1604 /// Sets the value of [request_label][crate::model::OptimizeToursResponse::request_label].
1605 ///
1606 /// # Example
1607 /// ```ignore,no_run
1608 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1609 /// let x = OptimizeToursResponse::new().set_request_label("example");
1610 /// ```
1611 pub fn set_request_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1612 self.request_label = v.into();
1613 self
1614 }
1615
1616 /// Sets the value of [skipped_shipments][crate::model::OptimizeToursResponse::skipped_shipments].
1617 ///
1618 /// # Example
1619 /// ```ignore,no_run
1620 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1621 /// use google_cloud_optimization_v1::model::SkippedShipment;
1622 /// let x = OptimizeToursResponse::new()
1623 /// .set_skipped_shipments([
1624 /// SkippedShipment::default()/* use setters */,
1625 /// SkippedShipment::default()/* use (different) setters */,
1626 /// ]);
1627 /// ```
1628 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
1629 where
1630 T: std::iter::IntoIterator<Item = V>,
1631 V: std::convert::Into<crate::model::SkippedShipment>,
1632 {
1633 use std::iter::Iterator;
1634 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
1635 self
1636 }
1637
1638 /// Sets the value of [validation_errors][crate::model::OptimizeToursResponse::validation_errors].
1639 ///
1640 /// # Example
1641 /// ```ignore,no_run
1642 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1643 /// use google_cloud_optimization_v1::model::OptimizeToursValidationError;
1644 /// let x = OptimizeToursResponse::new()
1645 /// .set_validation_errors([
1646 /// OptimizeToursValidationError::default()/* use setters */,
1647 /// OptimizeToursValidationError::default()/* use (different) setters */,
1648 /// ]);
1649 /// ```
1650 pub fn set_validation_errors<T, V>(mut self, v: T) -> Self
1651 where
1652 T: std::iter::IntoIterator<Item = V>,
1653 V: std::convert::Into<crate::model::OptimizeToursValidationError>,
1654 {
1655 use std::iter::Iterator;
1656 self.validation_errors = v.into_iter().map(|i| i.into()).collect();
1657 self
1658 }
1659
1660 /// Sets the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1661 ///
1662 /// # Example
1663 /// ```ignore,no_run
1664 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1665 /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1666 /// let x = OptimizeToursResponse::new().set_metrics(Metrics::default()/* use setters */);
1667 /// ```
1668 pub fn set_metrics<T>(mut self, v: T) -> Self
1669 where
1670 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1671 {
1672 self.metrics = std::option::Option::Some(v.into());
1673 self
1674 }
1675
1676 /// Sets or clears the value of [metrics][crate::model::OptimizeToursResponse::metrics].
1677 ///
1678 /// # Example
1679 /// ```ignore,no_run
1680 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1681 /// use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1682 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(Some(Metrics::default()/* use setters */));
1683 /// let x = OptimizeToursResponse::new().set_or_clear_metrics(None::<Metrics>);
1684 /// ```
1685 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1686 where
1687 T: std::convert::Into<crate::model::optimize_tours_response::Metrics>,
1688 {
1689 self.metrics = v.map(|x| x.into());
1690 self
1691 }
1692
1693 /// Sets the value of [total_cost][crate::model::OptimizeToursResponse::total_cost].
1694 ///
1695 /// # Example
1696 /// ```ignore,no_run
1697 /// # use google_cloud_optimization_v1::model::OptimizeToursResponse;
1698 /// let x = OptimizeToursResponse::new().set_total_cost(42.0);
1699 /// ```
1700 #[deprecated]
1701 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1702 self.total_cost = v.into();
1703 self
1704 }
1705}
1706
1707impl wkt::message::Message for OptimizeToursResponse {
1708 fn typename() -> &'static str {
1709 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse"
1710 }
1711}
1712
1713/// Defines additional types related to [OptimizeToursResponse].
1714pub mod optimize_tours_response {
1715 #[allow(unused_imports)]
1716 use super::*;
1717
1718 /// Overall metrics, aggregated over all routes.
1719 #[derive(Clone, Default, PartialEq)]
1720 #[non_exhaustive]
1721 pub struct Metrics {
1722 /// Aggregated over the routes. Each metric is the sum (or max, for loads)
1723 /// over all
1724 /// [ShipmentRoute.metrics][google.cloud.optimization.v1.ShipmentRoute.metrics]
1725 /// fields of the same name.
1726 ///
1727 /// [google.cloud.optimization.v1.ShipmentRoute.metrics]: crate::model::ShipmentRoute::metrics
1728 pub aggregated_route_metrics: std::option::Option<crate::model::AggregatedMetrics>,
1729
1730 /// Number of mandatory shipments skipped.
1731 pub skipped_mandatory_shipment_count: i32,
1732
1733 /// Number of vehicles used. Note: if a vehicle route is empty and
1734 /// [Vehicle.used_if_route_is_empty][google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]
1735 /// is true, the vehicle is considered used.
1736 ///
1737 /// [google.cloud.optimization.v1.Vehicle.used_if_route_is_empty]: crate::model::Vehicle::used_if_route_is_empty
1738 pub used_vehicle_count: i32,
1739
1740 /// The earliest start time for a used vehicle, computed as the minimum over
1741 /// all used vehicles of
1742 /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time].
1743 ///
1744 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
1745 pub earliest_vehicle_start_time: std::option::Option<wkt::Timestamp>,
1746
1747 /// The latest end time for a used vehicle, computed as the maximum over all
1748 /// used vehicles of
1749 /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time].
1750 ///
1751 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
1752 pub latest_vehicle_end_time: std::option::Option<wkt::Timestamp>,
1753
1754 /// Cost of the solution, broken down by cost-related request fields.
1755 /// The keys are proto paths, relative to the input OptimizeToursRequest,
1756 /// e.g. "model.shipments.pickups.cost", and the values are the total cost
1757 /// generated by the corresponding cost field, aggregated over the whole
1758 /// solution. In other words, costs["model.shipments.pickups.cost"] is the
1759 /// sum of all pickup costs over the solution. All costs defined in the model
1760 /// are reported in detail here with the exception of costs related to
1761 /// TransitionAttributes that are only reported in an aggregated way as of
1762 /// 2022/01.
1763 pub costs: std::collections::HashMap<std::string::String, f64>,
1764
1765 /// Total cost of the solution. The sum of all values in the costs map.
1766 pub total_cost: f64,
1767
1768 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1769 }
1770
1771 impl Metrics {
1772 pub fn new() -> Self {
1773 std::default::Default::default()
1774 }
1775
1776 /// Sets the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1777 ///
1778 /// # Example
1779 /// ```ignore,no_run
1780 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1781 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1782 /// let x = Metrics::new().set_aggregated_route_metrics(AggregatedMetrics::default()/* use setters */);
1783 /// ```
1784 pub fn set_aggregated_route_metrics<T>(mut self, v: T) -> Self
1785 where
1786 T: std::convert::Into<crate::model::AggregatedMetrics>,
1787 {
1788 self.aggregated_route_metrics = std::option::Option::Some(v.into());
1789 self
1790 }
1791
1792 /// Sets or clears the value of [aggregated_route_metrics][crate::model::optimize_tours_response::Metrics::aggregated_route_metrics].
1793 ///
1794 /// # Example
1795 /// ```ignore,no_run
1796 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1797 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
1798 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(Some(AggregatedMetrics::default()/* use setters */));
1799 /// let x = Metrics::new().set_or_clear_aggregated_route_metrics(None::<AggregatedMetrics>);
1800 /// ```
1801 pub fn set_or_clear_aggregated_route_metrics<T>(mut self, v: std::option::Option<T>) -> Self
1802 where
1803 T: std::convert::Into<crate::model::AggregatedMetrics>,
1804 {
1805 self.aggregated_route_metrics = v.map(|x| x.into());
1806 self
1807 }
1808
1809 /// Sets the value of [skipped_mandatory_shipment_count][crate::model::optimize_tours_response::Metrics::skipped_mandatory_shipment_count].
1810 ///
1811 /// # Example
1812 /// ```ignore,no_run
1813 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1814 /// let x = Metrics::new().set_skipped_mandatory_shipment_count(42);
1815 /// ```
1816 pub fn set_skipped_mandatory_shipment_count<T: std::convert::Into<i32>>(
1817 mut self,
1818 v: T,
1819 ) -> Self {
1820 self.skipped_mandatory_shipment_count = v.into();
1821 self
1822 }
1823
1824 /// Sets the value of [used_vehicle_count][crate::model::optimize_tours_response::Metrics::used_vehicle_count].
1825 ///
1826 /// # Example
1827 /// ```ignore,no_run
1828 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1829 /// let x = Metrics::new().set_used_vehicle_count(42);
1830 /// ```
1831 pub fn set_used_vehicle_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1832 self.used_vehicle_count = v.into();
1833 self
1834 }
1835
1836 /// Sets the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1837 ///
1838 /// # Example
1839 /// ```ignore,no_run
1840 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1841 /// use wkt::Timestamp;
1842 /// let x = Metrics::new().set_earliest_vehicle_start_time(Timestamp::default()/* use setters */);
1843 /// ```
1844 pub fn set_earliest_vehicle_start_time<T>(mut self, v: T) -> Self
1845 where
1846 T: std::convert::Into<wkt::Timestamp>,
1847 {
1848 self.earliest_vehicle_start_time = std::option::Option::Some(v.into());
1849 self
1850 }
1851
1852 /// Sets or clears the value of [earliest_vehicle_start_time][crate::model::optimize_tours_response::Metrics::earliest_vehicle_start_time].
1853 ///
1854 /// # Example
1855 /// ```ignore,no_run
1856 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1857 /// use wkt::Timestamp;
1858 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(Some(Timestamp::default()/* use setters */));
1859 /// let x = Metrics::new().set_or_clear_earliest_vehicle_start_time(None::<Timestamp>);
1860 /// ```
1861 pub fn set_or_clear_earliest_vehicle_start_time<T>(
1862 mut self,
1863 v: std::option::Option<T>,
1864 ) -> Self
1865 where
1866 T: std::convert::Into<wkt::Timestamp>,
1867 {
1868 self.earliest_vehicle_start_time = v.map(|x| x.into());
1869 self
1870 }
1871
1872 /// Sets the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1873 ///
1874 /// # Example
1875 /// ```ignore,no_run
1876 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1877 /// use wkt::Timestamp;
1878 /// let x = Metrics::new().set_latest_vehicle_end_time(Timestamp::default()/* use setters */);
1879 /// ```
1880 pub fn set_latest_vehicle_end_time<T>(mut self, v: T) -> Self
1881 where
1882 T: std::convert::Into<wkt::Timestamp>,
1883 {
1884 self.latest_vehicle_end_time = std::option::Option::Some(v.into());
1885 self
1886 }
1887
1888 /// Sets or clears the value of [latest_vehicle_end_time][crate::model::optimize_tours_response::Metrics::latest_vehicle_end_time].
1889 ///
1890 /// # Example
1891 /// ```ignore,no_run
1892 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1893 /// use wkt::Timestamp;
1894 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(Some(Timestamp::default()/* use setters */));
1895 /// let x = Metrics::new().set_or_clear_latest_vehicle_end_time(None::<Timestamp>);
1896 /// ```
1897 pub fn set_or_clear_latest_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1898 where
1899 T: std::convert::Into<wkt::Timestamp>,
1900 {
1901 self.latest_vehicle_end_time = v.map(|x| x.into());
1902 self
1903 }
1904
1905 /// Sets the value of [costs][crate::model::optimize_tours_response::Metrics::costs].
1906 ///
1907 /// # Example
1908 /// ```ignore,no_run
1909 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1910 /// let x = Metrics::new().set_costs([
1911 /// ("key0", 123.5),
1912 /// ("key1", 456.5),
1913 /// ]);
1914 /// ```
1915 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
1916 where
1917 T: std::iter::IntoIterator<Item = (K, V)>,
1918 K: std::convert::Into<std::string::String>,
1919 V: std::convert::Into<f64>,
1920 {
1921 use std::iter::Iterator;
1922 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1923 self
1924 }
1925
1926 /// Sets the value of [total_cost][crate::model::optimize_tours_response::Metrics::total_cost].
1927 ///
1928 /// # Example
1929 /// ```ignore,no_run
1930 /// # use google_cloud_optimization_v1::model::optimize_tours_response::Metrics;
1931 /// let x = Metrics::new().set_total_cost(42.0);
1932 /// ```
1933 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1934 self.total_cost = v.into();
1935 self
1936 }
1937 }
1938
1939 impl wkt::message::Message for Metrics {
1940 fn typename() -> &'static str {
1941 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursResponse.Metrics"
1942 }
1943 }
1944}
1945
1946/// Request to batch optimize tours as an asynchronous operation.
1947/// Each input file should contain one `OptimizeToursRequest`, and each output
1948/// file will contain one `OptimizeToursResponse`. The request contains
1949/// information to read/write and parse the files. All the input and output files
1950/// should be under the same project.
1951#[derive(Clone, Default, PartialEq)]
1952#[non_exhaustive]
1953pub struct BatchOptimizeToursRequest {
1954 /// Required. Target project and location to make a call.
1955 ///
1956 /// Format: `projects/{project-id}/locations/{location-id}`.
1957 ///
1958 /// If no location is specified, a region will be chosen automatically.
1959 pub parent: std::string::String,
1960
1961 /// Required. Input/Output information each purchase model, such as file paths
1962 /// and data formats.
1963 pub model_configs: std::vec::Vec<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
1964
1965 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1966}
1967
1968impl BatchOptimizeToursRequest {
1969 pub fn new() -> Self {
1970 std::default::Default::default()
1971 }
1972
1973 /// Sets the value of [parent][crate::model::BatchOptimizeToursRequest::parent].
1974 ///
1975 /// # Example
1976 /// ```ignore,no_run
1977 /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1978 /// let x = BatchOptimizeToursRequest::new().set_parent("example");
1979 /// ```
1980 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1981 self.parent = v.into();
1982 self
1983 }
1984
1985 /// Sets the value of [model_configs][crate::model::BatchOptimizeToursRequest::model_configs].
1986 ///
1987 /// # Example
1988 /// ```ignore,no_run
1989 /// # use google_cloud_optimization_v1::model::BatchOptimizeToursRequest;
1990 /// use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
1991 /// let x = BatchOptimizeToursRequest::new()
1992 /// .set_model_configs([
1993 /// AsyncModelConfig::default()/* use setters */,
1994 /// AsyncModelConfig::default()/* use (different) setters */,
1995 /// ]);
1996 /// ```
1997 pub fn set_model_configs<T, V>(mut self, v: T) -> Self
1998 where
1999 T: std::iter::IntoIterator<Item = V>,
2000 V: std::convert::Into<crate::model::batch_optimize_tours_request::AsyncModelConfig>,
2001 {
2002 use std::iter::Iterator;
2003 self.model_configs = v.into_iter().map(|i| i.into()).collect();
2004 self
2005 }
2006}
2007
2008impl wkt::message::Message for BatchOptimizeToursRequest {
2009 fn typename() -> &'static str {
2010 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest"
2011 }
2012}
2013
2014/// Defines additional types related to [BatchOptimizeToursRequest].
2015pub mod batch_optimize_tours_request {
2016 #[allow(unused_imports)]
2017 use super::*;
2018
2019 /// Information for solving one optimization model asynchronously.
2020 #[derive(Clone, Default, PartialEq)]
2021 #[non_exhaustive]
2022 pub struct AsyncModelConfig {
2023 /// User defined model name, can be used as alias by users to keep track of
2024 /// models.
2025 pub display_name: std::string::String,
2026
2027 /// Required. Information about the input model.
2028 pub input_config: std::option::Option<crate::model::InputConfig>,
2029
2030 /// Required. The desired output location information.
2031 pub output_config: std::option::Option<crate::model::OutputConfig>,
2032
2033 /// If this is set, the model will be solved in the checkpoint mode. In this
2034 /// mode, the input model can have a deadline longer than 30 mins without the
2035 /// risk of interruption. The model will be solved in multiple short-running
2036 /// stages. Each stage generates an intermediate checkpoint
2037 /// and stores it in the user's Cloud Storage buckets. The checkpoint
2038 /// mode should be preferred over
2039 /// allow_large_deadline_despite_interruption_risk since it prevents the risk
2040 /// of interruption.
2041 pub enable_checkpoints: bool,
2042
2043 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2044 }
2045
2046 impl AsyncModelConfig {
2047 pub fn new() -> Self {
2048 std::default::Default::default()
2049 }
2050
2051 /// Sets the value of [display_name][crate::model::batch_optimize_tours_request::AsyncModelConfig::display_name].
2052 ///
2053 /// # Example
2054 /// ```ignore,no_run
2055 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2056 /// let x = AsyncModelConfig::new().set_display_name("example");
2057 /// ```
2058 pub fn set_display_name<T: std::convert::Into<std::string::String>>(
2059 mut self,
2060 v: T,
2061 ) -> Self {
2062 self.display_name = v.into();
2063 self
2064 }
2065
2066 /// Sets the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2067 ///
2068 /// # Example
2069 /// ```ignore,no_run
2070 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2071 /// use google_cloud_optimization_v1::model::InputConfig;
2072 /// let x = AsyncModelConfig::new().set_input_config(InputConfig::default()/* use setters */);
2073 /// ```
2074 pub fn set_input_config<T>(mut self, v: T) -> Self
2075 where
2076 T: std::convert::Into<crate::model::InputConfig>,
2077 {
2078 self.input_config = std::option::Option::Some(v.into());
2079 self
2080 }
2081
2082 /// Sets or clears the value of [input_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::input_config].
2083 ///
2084 /// # Example
2085 /// ```ignore,no_run
2086 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2087 /// use google_cloud_optimization_v1::model::InputConfig;
2088 /// let x = AsyncModelConfig::new().set_or_clear_input_config(Some(InputConfig::default()/* use setters */));
2089 /// let x = AsyncModelConfig::new().set_or_clear_input_config(None::<InputConfig>);
2090 /// ```
2091 pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
2092 where
2093 T: std::convert::Into<crate::model::InputConfig>,
2094 {
2095 self.input_config = v.map(|x| x.into());
2096 self
2097 }
2098
2099 /// Sets the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2100 ///
2101 /// # Example
2102 /// ```ignore,no_run
2103 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2104 /// use google_cloud_optimization_v1::model::OutputConfig;
2105 /// let x = AsyncModelConfig::new().set_output_config(OutputConfig::default()/* use setters */);
2106 /// ```
2107 pub fn set_output_config<T>(mut self, v: T) -> Self
2108 where
2109 T: std::convert::Into<crate::model::OutputConfig>,
2110 {
2111 self.output_config = std::option::Option::Some(v.into());
2112 self
2113 }
2114
2115 /// Sets or clears the value of [output_config][crate::model::batch_optimize_tours_request::AsyncModelConfig::output_config].
2116 ///
2117 /// # Example
2118 /// ```ignore,no_run
2119 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2120 /// use google_cloud_optimization_v1::model::OutputConfig;
2121 /// let x = AsyncModelConfig::new().set_or_clear_output_config(Some(OutputConfig::default()/* use setters */));
2122 /// let x = AsyncModelConfig::new().set_or_clear_output_config(None::<OutputConfig>);
2123 /// ```
2124 pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
2125 where
2126 T: std::convert::Into<crate::model::OutputConfig>,
2127 {
2128 self.output_config = v.map(|x| x.into());
2129 self
2130 }
2131
2132 /// Sets the value of [enable_checkpoints][crate::model::batch_optimize_tours_request::AsyncModelConfig::enable_checkpoints].
2133 ///
2134 /// # Example
2135 /// ```ignore,no_run
2136 /// # use google_cloud_optimization_v1::model::batch_optimize_tours_request::AsyncModelConfig;
2137 /// let x = AsyncModelConfig::new().set_enable_checkpoints(true);
2138 /// ```
2139 pub fn set_enable_checkpoints<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2140 self.enable_checkpoints = v.into();
2141 self
2142 }
2143 }
2144
2145 impl wkt::message::Message for AsyncModelConfig {
2146 fn typename() -> &'static str {
2147 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursRequest.AsyncModelConfig"
2148 }
2149 }
2150}
2151
2152/// Response to a `BatchOptimizeToursRequest`. This is returned in
2153/// the LRO Operation after the operation is complete.
2154#[derive(Clone, Default, PartialEq)]
2155#[non_exhaustive]
2156pub struct BatchOptimizeToursResponse {
2157 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2158}
2159
2160impl BatchOptimizeToursResponse {
2161 pub fn new() -> Self {
2162 std::default::Default::default()
2163 }
2164}
2165
2166impl wkt::message::Message for BatchOptimizeToursResponse {
2167 fn typename() -> &'static str {
2168 "type.googleapis.com/google.cloud.optimization.v1.BatchOptimizeToursResponse"
2169 }
2170}
2171
2172/// A shipment model contains a set of shipments which must be performed by a
2173/// set of vehicles, while minimizing the overall cost, which is the sum of:
2174///
2175/// * the cost of routing the vehicles (sum of cost per total time, cost per
2176/// travel time, and fixed cost over all vehicles).
2177/// * the unperformed shipment penalties.
2178/// * the cost of the global duration of the shipments
2179#[derive(Clone, Default, PartialEq)]
2180#[non_exhaustive]
2181pub struct ShipmentModel {
2182 /// Set of shipments which must be performed in the model.
2183 pub shipments: std::vec::Vec<crate::model::Shipment>,
2184
2185 /// Set of vehicles which can be used to perform visits.
2186 pub vehicles: std::vec::Vec<crate::model::Vehicle>,
2187
2188 /// Constrains the maximum number of active vehicles. A vehicle is active if
2189 /// its route performs at least one shipment. This can be used to limit the
2190 /// number of routes in the case where there are fewer drivers than
2191 /// vehicles and that the fleet of vehicles is heterogeneous. The optimization
2192 /// will then select the best subset of vehicles to use.
2193 /// Must be strictly positive.
2194 pub max_active_vehicles: std::option::Option<i32>,
2195
2196 /// Global start and end time of the model: no times outside of this range
2197 /// can be considered valid.
2198 ///
2199 /// The model's time span must be less than a year, i.e. the `global_end_time`
2200 /// and the `global_start_time` must be within 31536000 seconds of each other.
2201 ///
2202 /// When using `cost_per_*hour` fields, you might want to set this window to a
2203 /// smaller interval to increase performance (eg. if you model a single day,
2204 /// you should set the global time limits to that day).
2205 /// If unset, 00:00:00 UTC, January 1, 1970 (i.e. seconds: 0, nanos: 0) is used
2206 /// as default.
2207 pub global_start_time: std::option::Option<wkt::Timestamp>,
2208
2209 /// If unset, 00:00:00 UTC, January 1, 1971 (i.e. seconds: 31536000, nanos: 0)
2210 /// is used as default.
2211 pub global_end_time: std::option::Option<wkt::Timestamp>,
2212
2213 /// The "global duration" of the overall plan is the difference between the
2214 /// earliest effective start time and the latest effective end time of
2215 /// all vehicles. Users can assign a cost per hour to that quantity to try
2216 /// and optimize for earliest job completion, for example. This cost must be in
2217 /// the same unit as
2218 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
2219 ///
2220 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
2221 pub global_duration_cost_per_hour: f64,
2222
2223 /// Specifies duration and distance matrices used in the model. If this field
2224 /// is empty, Google Maps or geodesic distances will be used instead, depending
2225 /// on the value of the `use_geodesic_distances` field. If it is not empty,
2226 /// `use_geodesic_distances` cannot be true and neither
2227 /// `duration_distance_matrix_src_tags` nor `duration_distance_matrix_dst_tags`
2228 /// can be empty.
2229 ///
2230 /// Usage examples:
2231 ///
2232 /// * There are two locations: locA and locB.
2233 /// * 1 vehicle starting its route at locA and ending it at locA.
2234 /// * 1 pickup visit request at locB.
2235 ///
2236 /// ```norust
2237 /// model {
2238 /// vehicles { start_tags: "locA" end_tags: "locA" }
2239 /// shipments { pickups { tags: "locB" } }
2240 /// duration_distance_matrix_src_tags: "locA"
2241 /// duration_distance_matrix_src_tags: "locB"
2242 /// duration_distance_matrix_dst_tags: "locA"
2243 /// duration_distance_matrix_dst_tags: "locB"
2244 /// duration_distance_matrices {
2245 /// rows { # from: locA
2246 /// durations { seconds: 0 } meters: 0 # to: locA
2247 /// durations { seconds: 100 } meters: 1000 # to: locB
2248 /// }
2249 /// rows { # from: locB
2250 /// durations { seconds: 102 } meters: 990 # to: locA
2251 /// durations { seconds: 0 } meters: 0 # to: locB
2252 /// }
2253 /// }
2254 /// }
2255 /// ```
2256 ///
2257 /// * There are three locations: locA, locB and locC.
2258 /// * 1 vehicle starting its route at locA and ending it at locB, using
2259 /// matrix "fast".
2260 /// * 1 vehicle starting its route at locB and ending it at locB, using
2261 /// matrix "slow".
2262 /// * 1 vehicle starting its route at locB and ending it at locB, using
2263 /// matrix "fast".
2264 /// * 1 pickup visit request at locC.
2265 ///
2266 /// ```norust
2267 /// model {
2268 /// vehicles { start_tags: "locA" end_tags: "locB" start_tags: "fast" }
2269 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "slow" }
2270 /// vehicles { start_tags: "locB" end_tags: "locB" start_tags: "fast" }
2271 /// shipments { pickups { tags: "locC" } }
2272 /// duration_distance_matrix_src_tags: "locA"
2273 /// duration_distance_matrix_src_tags: "locB"
2274 /// duration_distance_matrix_src_tags: "locC"
2275 /// duration_distance_matrix_dst_tags: "locB"
2276 /// duration_distance_matrix_dst_tags: "locC"
2277 /// duration_distance_matrices {
2278 /// vehicle_start_tag: "fast"
2279 /// rows { # from: locA
2280 /// durations { seconds: 1000 } meters: 2000 # to: locB
2281 /// durations { seconds: 600 } meters: 1000 # to: locC
2282 /// }
2283 /// rows { # from: locB
2284 /// durations { seconds: 0 } meters: 0 # to: locB
2285 /// durations { seconds: 700 } meters: 1200 # to: locC
2286 /// }
2287 /// rows { # from: locC
2288 /// durations { seconds: 702 } meters: 1190 # to: locB
2289 /// durations { seconds: 0 } meters: 0 # to: locC
2290 /// }
2291 /// }
2292 /// duration_distance_matrices {
2293 /// vehicle_start_tag: "slow"
2294 /// rows { # from: locA
2295 /// durations { seconds: 1800 } meters: 2001 # to: locB
2296 /// durations { seconds: 900 } meters: 1002 # to: locC
2297 /// }
2298 /// rows { # from: locB
2299 /// durations { seconds: 0 } meters: 0 # to: locB
2300 /// durations { seconds: 1000 } meters: 1202 # to: locC
2301 /// }
2302 /// rows { # from: locC
2303 /// durations { seconds: 1001 } meters: 1195 # to: locB
2304 /// durations { seconds: 0 } meters: 0 # to: locC
2305 /// }
2306 /// }
2307 /// }
2308 /// ```
2309 pub duration_distance_matrices:
2310 std::vec::Vec<crate::model::shipment_model::DurationDistanceMatrix>,
2311
2312 /// Tags defining the sources of the duration and distance matrices;
2313 /// `duration_distance_matrices(i).rows(j)` defines durations and distances
2314 /// from visits with tag `duration_distance_matrix_src_tags(j)` to other visits
2315 /// in matrix i.
2316 ///
2317 /// Tags correspond to
2318 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2319 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2320 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2321 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2322 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2323 /// the same. All tags must be different and cannot be empty strings. If this
2324 /// field is not empty, then `duration_distance_matrices` must not be empty.
2325 ///
2326 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2327 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2328 pub duration_distance_matrix_src_tags: std::vec::Vec<std::string::String>,
2329
2330 /// Tags defining the destinations of the duration and distance matrices;
2331 /// `duration_distance_matrices(i).rows(j).durations(k)` (resp.
2332 /// `duration_distance_matrices(i).rows(j).meters(k))` defines the duration
2333 /// (resp. the distance) of the travel from visits with tag
2334 /// `duration_distance_matrix_src_tags(j)` to visits with tag
2335 /// `duration_distance_matrix_dst_tags(k)` in matrix i.
2336 ///
2337 /// Tags correspond to
2338 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
2339 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags].
2340 /// A given `VisitRequest` or `Vehicle` must match exactly one tag in this
2341 /// field. Note that a `Vehicle`'s source, destination and matrix tags may be
2342 /// the same; similarly a `VisitRequest`'s source and destination tags may be
2343 /// the same. All tags must be different and cannot be empty strings. If this
2344 /// field is not empty, then `duration_distance_matrices` must not be empty.
2345 ///
2346 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
2347 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
2348 pub duration_distance_matrix_dst_tags: std::vec::Vec<std::string::String>,
2349
2350 /// Transition attributes added to the model.
2351 pub transition_attributes: std::vec::Vec<crate::model::TransitionAttributes>,
2352
2353 /// Sets of incompatible shipment_types (see `ShipmentTypeIncompatibility`).
2354 pub shipment_type_incompatibilities: std::vec::Vec<crate::model::ShipmentTypeIncompatibility>,
2355
2356 /// Sets of `shipment_type` requirements (see `ShipmentTypeRequirement`).
2357 pub shipment_type_requirements: std::vec::Vec<crate::model::ShipmentTypeRequirement>,
2358
2359 /// Set of precedence rules which must be enforced in the model.
2360 pub precedence_rules: std::vec::Vec<crate::model::shipment_model::PrecedenceRule>,
2361
2362 /// Deprecated: No longer used.
2363 /// Set of break rules used in the model.
2364 /// Each vehicle specifies the `BreakRule` that applies to it via the
2365 /// [Vehicle.break_rule_indices][google.cloud.optimization.v1.Vehicle.break_rule_indices]
2366 /// field (which must be a singleton).
2367 ///
2368 /// [google.cloud.optimization.v1.Vehicle.break_rule_indices]: crate::model::Vehicle::break_rule_indices
2369 #[deprecated]
2370 pub break_rules: std::vec::Vec<crate::model::shipment_model::BreakRule>,
2371
2372 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2373}
2374
2375impl ShipmentModel {
2376 pub fn new() -> Self {
2377 std::default::Default::default()
2378 }
2379
2380 /// Sets the value of [shipments][crate::model::ShipmentModel::shipments].
2381 ///
2382 /// # Example
2383 /// ```ignore,no_run
2384 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2385 /// use google_cloud_optimization_v1::model::Shipment;
2386 /// let x = ShipmentModel::new()
2387 /// .set_shipments([
2388 /// Shipment::default()/* use setters */,
2389 /// Shipment::default()/* use (different) setters */,
2390 /// ]);
2391 /// ```
2392 pub fn set_shipments<T, V>(mut self, v: T) -> Self
2393 where
2394 T: std::iter::IntoIterator<Item = V>,
2395 V: std::convert::Into<crate::model::Shipment>,
2396 {
2397 use std::iter::Iterator;
2398 self.shipments = v.into_iter().map(|i| i.into()).collect();
2399 self
2400 }
2401
2402 /// Sets the value of [vehicles][crate::model::ShipmentModel::vehicles].
2403 ///
2404 /// # Example
2405 /// ```ignore,no_run
2406 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2407 /// use google_cloud_optimization_v1::model::Vehicle;
2408 /// let x = ShipmentModel::new()
2409 /// .set_vehicles([
2410 /// Vehicle::default()/* use setters */,
2411 /// Vehicle::default()/* use (different) setters */,
2412 /// ]);
2413 /// ```
2414 pub fn set_vehicles<T, V>(mut self, v: T) -> Self
2415 where
2416 T: std::iter::IntoIterator<Item = V>,
2417 V: std::convert::Into<crate::model::Vehicle>,
2418 {
2419 use std::iter::Iterator;
2420 self.vehicles = v.into_iter().map(|i| i.into()).collect();
2421 self
2422 }
2423
2424 /// Sets the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2425 ///
2426 /// # Example
2427 /// ```ignore,no_run
2428 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2429 /// let x = ShipmentModel::new().set_max_active_vehicles(42);
2430 /// ```
2431 pub fn set_max_active_vehicles<T>(mut self, v: T) -> Self
2432 where
2433 T: std::convert::Into<i32>,
2434 {
2435 self.max_active_vehicles = std::option::Option::Some(v.into());
2436 self
2437 }
2438
2439 /// Sets or clears the value of [max_active_vehicles][crate::model::ShipmentModel::max_active_vehicles].
2440 ///
2441 /// # Example
2442 /// ```ignore,no_run
2443 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2444 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(Some(42));
2445 /// let x = ShipmentModel::new().set_or_clear_max_active_vehicles(None::<i32>);
2446 /// ```
2447 pub fn set_or_clear_max_active_vehicles<T>(mut self, v: std::option::Option<T>) -> Self
2448 where
2449 T: std::convert::Into<i32>,
2450 {
2451 self.max_active_vehicles = v.map(|x| x.into());
2452 self
2453 }
2454
2455 /// Sets the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2456 ///
2457 /// # Example
2458 /// ```ignore,no_run
2459 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2460 /// use wkt::Timestamp;
2461 /// let x = ShipmentModel::new().set_global_start_time(Timestamp::default()/* use setters */);
2462 /// ```
2463 pub fn set_global_start_time<T>(mut self, v: T) -> Self
2464 where
2465 T: std::convert::Into<wkt::Timestamp>,
2466 {
2467 self.global_start_time = std::option::Option::Some(v.into());
2468 self
2469 }
2470
2471 /// Sets or clears the value of [global_start_time][crate::model::ShipmentModel::global_start_time].
2472 ///
2473 /// # Example
2474 /// ```ignore,no_run
2475 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2476 /// use wkt::Timestamp;
2477 /// let x = ShipmentModel::new().set_or_clear_global_start_time(Some(Timestamp::default()/* use setters */));
2478 /// let x = ShipmentModel::new().set_or_clear_global_start_time(None::<Timestamp>);
2479 /// ```
2480 pub fn set_or_clear_global_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2481 where
2482 T: std::convert::Into<wkt::Timestamp>,
2483 {
2484 self.global_start_time = v.map(|x| x.into());
2485 self
2486 }
2487
2488 /// Sets the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2489 ///
2490 /// # Example
2491 /// ```ignore,no_run
2492 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2493 /// use wkt::Timestamp;
2494 /// let x = ShipmentModel::new().set_global_end_time(Timestamp::default()/* use setters */);
2495 /// ```
2496 pub fn set_global_end_time<T>(mut self, v: T) -> Self
2497 where
2498 T: std::convert::Into<wkt::Timestamp>,
2499 {
2500 self.global_end_time = std::option::Option::Some(v.into());
2501 self
2502 }
2503
2504 /// Sets or clears the value of [global_end_time][crate::model::ShipmentModel::global_end_time].
2505 ///
2506 /// # Example
2507 /// ```ignore,no_run
2508 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2509 /// use wkt::Timestamp;
2510 /// let x = ShipmentModel::new().set_or_clear_global_end_time(Some(Timestamp::default()/* use setters */));
2511 /// let x = ShipmentModel::new().set_or_clear_global_end_time(None::<Timestamp>);
2512 /// ```
2513 pub fn set_or_clear_global_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2514 where
2515 T: std::convert::Into<wkt::Timestamp>,
2516 {
2517 self.global_end_time = v.map(|x| x.into());
2518 self
2519 }
2520
2521 /// Sets the value of [global_duration_cost_per_hour][crate::model::ShipmentModel::global_duration_cost_per_hour].
2522 ///
2523 /// # Example
2524 /// ```ignore,no_run
2525 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2526 /// let x = ShipmentModel::new().set_global_duration_cost_per_hour(42.0);
2527 /// ```
2528 pub fn set_global_duration_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2529 self.global_duration_cost_per_hour = v.into();
2530 self
2531 }
2532
2533 /// Sets the value of [duration_distance_matrices][crate::model::ShipmentModel::duration_distance_matrices].
2534 ///
2535 /// # Example
2536 /// ```ignore,no_run
2537 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2538 /// use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2539 /// let x = ShipmentModel::new()
2540 /// .set_duration_distance_matrices([
2541 /// DurationDistanceMatrix::default()/* use setters */,
2542 /// DurationDistanceMatrix::default()/* use (different) setters */,
2543 /// ]);
2544 /// ```
2545 pub fn set_duration_distance_matrices<T, V>(mut self, v: T) -> Self
2546 where
2547 T: std::iter::IntoIterator<Item = V>,
2548 V: std::convert::Into<crate::model::shipment_model::DurationDistanceMatrix>,
2549 {
2550 use std::iter::Iterator;
2551 self.duration_distance_matrices = v.into_iter().map(|i| i.into()).collect();
2552 self
2553 }
2554
2555 /// Sets the value of [duration_distance_matrix_src_tags][crate::model::ShipmentModel::duration_distance_matrix_src_tags].
2556 ///
2557 /// # Example
2558 /// ```ignore,no_run
2559 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2560 /// let x = ShipmentModel::new().set_duration_distance_matrix_src_tags(["a", "b", "c"]);
2561 /// ```
2562 pub fn set_duration_distance_matrix_src_tags<T, V>(mut self, v: T) -> Self
2563 where
2564 T: std::iter::IntoIterator<Item = V>,
2565 V: std::convert::Into<std::string::String>,
2566 {
2567 use std::iter::Iterator;
2568 self.duration_distance_matrix_src_tags = v.into_iter().map(|i| i.into()).collect();
2569 self
2570 }
2571
2572 /// Sets the value of [duration_distance_matrix_dst_tags][crate::model::ShipmentModel::duration_distance_matrix_dst_tags].
2573 ///
2574 /// # Example
2575 /// ```ignore,no_run
2576 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2577 /// let x = ShipmentModel::new().set_duration_distance_matrix_dst_tags(["a", "b", "c"]);
2578 /// ```
2579 pub fn set_duration_distance_matrix_dst_tags<T, V>(mut self, v: T) -> Self
2580 where
2581 T: std::iter::IntoIterator<Item = V>,
2582 V: std::convert::Into<std::string::String>,
2583 {
2584 use std::iter::Iterator;
2585 self.duration_distance_matrix_dst_tags = v.into_iter().map(|i| i.into()).collect();
2586 self
2587 }
2588
2589 /// Sets the value of [transition_attributes][crate::model::ShipmentModel::transition_attributes].
2590 ///
2591 /// # Example
2592 /// ```ignore,no_run
2593 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2594 /// use google_cloud_optimization_v1::model::TransitionAttributes;
2595 /// let x = ShipmentModel::new()
2596 /// .set_transition_attributes([
2597 /// TransitionAttributes::default()/* use setters */,
2598 /// TransitionAttributes::default()/* use (different) setters */,
2599 /// ]);
2600 /// ```
2601 pub fn set_transition_attributes<T, V>(mut self, v: T) -> Self
2602 where
2603 T: std::iter::IntoIterator<Item = V>,
2604 V: std::convert::Into<crate::model::TransitionAttributes>,
2605 {
2606 use std::iter::Iterator;
2607 self.transition_attributes = v.into_iter().map(|i| i.into()).collect();
2608 self
2609 }
2610
2611 /// Sets the value of [shipment_type_incompatibilities][crate::model::ShipmentModel::shipment_type_incompatibilities].
2612 ///
2613 /// # Example
2614 /// ```ignore,no_run
2615 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2616 /// use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
2617 /// let x = ShipmentModel::new()
2618 /// .set_shipment_type_incompatibilities([
2619 /// ShipmentTypeIncompatibility::default()/* use setters */,
2620 /// ShipmentTypeIncompatibility::default()/* use (different) setters */,
2621 /// ]);
2622 /// ```
2623 pub fn set_shipment_type_incompatibilities<T, V>(mut self, v: T) -> Self
2624 where
2625 T: std::iter::IntoIterator<Item = V>,
2626 V: std::convert::Into<crate::model::ShipmentTypeIncompatibility>,
2627 {
2628 use std::iter::Iterator;
2629 self.shipment_type_incompatibilities = v.into_iter().map(|i| i.into()).collect();
2630 self
2631 }
2632
2633 /// Sets the value of [shipment_type_requirements][crate::model::ShipmentModel::shipment_type_requirements].
2634 ///
2635 /// # Example
2636 /// ```ignore,no_run
2637 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2638 /// use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
2639 /// let x = ShipmentModel::new()
2640 /// .set_shipment_type_requirements([
2641 /// ShipmentTypeRequirement::default()/* use setters */,
2642 /// ShipmentTypeRequirement::default()/* use (different) setters */,
2643 /// ]);
2644 /// ```
2645 pub fn set_shipment_type_requirements<T, V>(mut self, v: T) -> Self
2646 where
2647 T: std::iter::IntoIterator<Item = V>,
2648 V: std::convert::Into<crate::model::ShipmentTypeRequirement>,
2649 {
2650 use std::iter::Iterator;
2651 self.shipment_type_requirements = v.into_iter().map(|i| i.into()).collect();
2652 self
2653 }
2654
2655 /// Sets the value of [precedence_rules][crate::model::ShipmentModel::precedence_rules].
2656 ///
2657 /// # Example
2658 /// ```ignore,no_run
2659 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2660 /// use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2661 /// let x = ShipmentModel::new()
2662 /// .set_precedence_rules([
2663 /// PrecedenceRule::default()/* use setters */,
2664 /// PrecedenceRule::default()/* use (different) setters */,
2665 /// ]);
2666 /// ```
2667 pub fn set_precedence_rules<T, V>(mut self, v: T) -> Self
2668 where
2669 T: std::iter::IntoIterator<Item = V>,
2670 V: std::convert::Into<crate::model::shipment_model::PrecedenceRule>,
2671 {
2672 use std::iter::Iterator;
2673 self.precedence_rules = v.into_iter().map(|i| i.into()).collect();
2674 self
2675 }
2676
2677 /// Sets the value of [break_rules][crate::model::ShipmentModel::break_rules].
2678 ///
2679 /// # Example
2680 /// ```ignore,no_run
2681 /// # use google_cloud_optimization_v1::model::ShipmentModel;
2682 /// use google_cloud_optimization_v1::model::shipment_model::BreakRule;
2683 /// let x = ShipmentModel::new()
2684 /// .set_break_rules([
2685 /// BreakRule::default()/* use setters */,
2686 /// BreakRule::default()/* use (different) setters */,
2687 /// ]);
2688 /// ```
2689 #[deprecated]
2690 pub fn set_break_rules<T, V>(mut self, v: T) -> Self
2691 where
2692 T: std::iter::IntoIterator<Item = V>,
2693 V: std::convert::Into<crate::model::shipment_model::BreakRule>,
2694 {
2695 use std::iter::Iterator;
2696 self.break_rules = v.into_iter().map(|i| i.into()).collect();
2697 self
2698 }
2699}
2700
2701impl wkt::message::Message for ShipmentModel {
2702 fn typename() -> &'static str {
2703 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel"
2704 }
2705}
2706
2707/// Defines additional types related to [ShipmentModel].
2708pub mod shipment_model {
2709 #[allow(unused_imports)]
2710 use super::*;
2711
2712 /// Specifies a duration and distance matrix from visit and vehicle start
2713 /// locations to visit and vehicle end locations.
2714 #[derive(Clone, Default, PartialEq)]
2715 #[non_exhaustive]
2716 pub struct DurationDistanceMatrix {
2717 /// Specifies the rows of the duration and distance matrix. It must have as
2718 /// many elements as
2719 /// [ShipmentModel.duration_distance_matrix_src_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags].
2720 ///
2721 /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_src_tags]: crate::model::ShipmentModel::duration_distance_matrix_src_tags
2722 pub rows: std::vec::Vec<crate::model::shipment_model::duration_distance_matrix::Row>,
2723
2724 /// Tag defining to which vehicles this duration and distance matrix applies.
2725 /// If empty, this applies to all vehicles, and there can only be a single
2726 /// matrix.
2727 ///
2728 /// Each vehicle start must match exactly one matrix, i.e. exactly one of
2729 /// their `start_tags` field must match the `vehicle_start_tag` of a matrix
2730 /// (and of that matrix only).
2731 ///
2732 /// All matrices must have a different `vehicle_start_tag`.
2733 pub vehicle_start_tag: std::string::String,
2734
2735 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2736 }
2737
2738 impl DurationDistanceMatrix {
2739 pub fn new() -> Self {
2740 std::default::Default::default()
2741 }
2742
2743 /// Sets the value of [rows][crate::model::shipment_model::DurationDistanceMatrix::rows].
2744 ///
2745 /// # Example
2746 /// ```ignore,no_run
2747 /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2748 /// use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2749 /// let x = DurationDistanceMatrix::new()
2750 /// .set_rows([
2751 /// Row::default()/* use setters */,
2752 /// Row::default()/* use (different) setters */,
2753 /// ]);
2754 /// ```
2755 pub fn set_rows<T, V>(mut self, v: T) -> Self
2756 where
2757 T: std::iter::IntoIterator<Item = V>,
2758 V: std::convert::Into<crate::model::shipment_model::duration_distance_matrix::Row>,
2759 {
2760 use std::iter::Iterator;
2761 self.rows = v.into_iter().map(|i| i.into()).collect();
2762 self
2763 }
2764
2765 /// Sets the value of [vehicle_start_tag][crate::model::shipment_model::DurationDistanceMatrix::vehicle_start_tag].
2766 ///
2767 /// # Example
2768 /// ```ignore,no_run
2769 /// # use google_cloud_optimization_v1::model::shipment_model::DurationDistanceMatrix;
2770 /// let x = DurationDistanceMatrix::new().set_vehicle_start_tag("example");
2771 /// ```
2772 pub fn set_vehicle_start_tag<T: std::convert::Into<std::string::String>>(
2773 mut self,
2774 v: T,
2775 ) -> Self {
2776 self.vehicle_start_tag = v.into();
2777 self
2778 }
2779 }
2780
2781 impl wkt::message::Message for DurationDistanceMatrix {
2782 fn typename() -> &'static str {
2783 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix"
2784 }
2785 }
2786
2787 /// Defines additional types related to [DurationDistanceMatrix].
2788 pub mod duration_distance_matrix {
2789 #[allow(unused_imports)]
2790 use super::*;
2791
2792 /// Specifies a row of the duration and distance matrix.
2793 #[derive(Clone, Default, PartialEq)]
2794 #[non_exhaustive]
2795 pub struct Row {
2796 /// Duration values for a given row. It must have as many elements as
2797 /// [ShipmentModel.duration_distance_matrix_dst_tags][google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags].
2798 ///
2799 /// [google.cloud.optimization.v1.ShipmentModel.duration_distance_matrix_dst_tags]: crate::model::ShipmentModel::duration_distance_matrix_dst_tags
2800 pub durations: std::vec::Vec<wkt::Duration>,
2801
2802 /// Distance values for a given row. If no costs or constraints refer to
2803 /// distances in the model, this can be left empty; otherwise it must have
2804 /// as many elements as `durations`.
2805 pub meters: std::vec::Vec<f64>,
2806
2807 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2808 }
2809
2810 impl Row {
2811 pub fn new() -> Self {
2812 std::default::Default::default()
2813 }
2814
2815 /// Sets the value of [durations][crate::model::shipment_model::duration_distance_matrix::Row::durations].
2816 ///
2817 /// # Example
2818 /// ```ignore,no_run
2819 /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2820 /// use wkt::Duration;
2821 /// let x = Row::new()
2822 /// .set_durations([
2823 /// Duration::default()/* use setters */,
2824 /// Duration::default()/* use (different) setters */,
2825 /// ]);
2826 /// ```
2827 pub fn set_durations<T, V>(mut self, v: T) -> Self
2828 where
2829 T: std::iter::IntoIterator<Item = V>,
2830 V: std::convert::Into<wkt::Duration>,
2831 {
2832 use std::iter::Iterator;
2833 self.durations = v.into_iter().map(|i| i.into()).collect();
2834 self
2835 }
2836
2837 /// Sets the value of [meters][crate::model::shipment_model::duration_distance_matrix::Row::meters].
2838 ///
2839 /// # Example
2840 /// ```ignore,no_run
2841 /// # use google_cloud_optimization_v1::model::shipment_model::duration_distance_matrix::Row;
2842 /// let x = Row::new().set_meters([1.0, 2.0, 3.0]);
2843 /// ```
2844 pub fn set_meters<T, V>(mut self, v: T) -> Self
2845 where
2846 T: std::iter::IntoIterator<Item = V>,
2847 V: std::convert::Into<f64>,
2848 {
2849 use std::iter::Iterator;
2850 self.meters = v.into_iter().map(|i| i.into()).collect();
2851 self
2852 }
2853 }
2854
2855 impl wkt::message::Message for Row {
2856 fn typename() -> &'static str {
2857 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.DurationDistanceMatrix.Row"
2858 }
2859 }
2860 }
2861
2862 /// A precedence rule between two events (each event is the pickup or the
2863 /// delivery of a shipment): the "second" event has to start at least
2864 /// `offset_duration` after "first" has started.
2865 ///
2866 /// Several precedences can refer to the same (or related) events, e.g.,
2867 /// "pickup of B happens after delivery of A" and "pickup of C happens after
2868 /// pickup of B".
2869 ///
2870 /// Furthermore, precedences only apply when both shipments are performed and
2871 /// are otherwise ignored.
2872 #[derive(Clone, Default, PartialEq)]
2873 #[non_exhaustive]
2874 pub struct PrecedenceRule {
2875 /// Shipment index of the "first" event. This field must be specified.
2876 pub first_index: std::option::Option<i32>,
2877
2878 /// Indicates if the "first" event is a delivery.
2879 pub first_is_delivery: bool,
2880
2881 /// Shipment index of the "second" event. This field must be specified.
2882 pub second_index: std::option::Option<i32>,
2883
2884 /// Indicates if the "second" event is a delivery.
2885 pub second_is_delivery: bool,
2886
2887 /// The offset between the "first" and "second" event. It can be negative.
2888 pub offset_duration: std::option::Option<wkt::Duration>,
2889
2890 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2891 }
2892
2893 impl PrecedenceRule {
2894 pub fn new() -> Self {
2895 std::default::Default::default()
2896 }
2897
2898 /// Sets the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2899 ///
2900 /// # Example
2901 /// ```ignore,no_run
2902 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2903 /// let x = PrecedenceRule::new().set_first_index(42);
2904 /// ```
2905 pub fn set_first_index<T>(mut self, v: T) -> Self
2906 where
2907 T: std::convert::Into<i32>,
2908 {
2909 self.first_index = std::option::Option::Some(v.into());
2910 self
2911 }
2912
2913 /// Sets or clears the value of [first_index][crate::model::shipment_model::PrecedenceRule::first_index].
2914 ///
2915 /// # Example
2916 /// ```ignore,no_run
2917 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2918 /// let x = PrecedenceRule::new().set_or_clear_first_index(Some(42));
2919 /// let x = PrecedenceRule::new().set_or_clear_first_index(None::<i32>);
2920 /// ```
2921 pub fn set_or_clear_first_index<T>(mut self, v: std::option::Option<T>) -> Self
2922 where
2923 T: std::convert::Into<i32>,
2924 {
2925 self.first_index = v.map(|x| x.into());
2926 self
2927 }
2928
2929 /// Sets the value of [first_is_delivery][crate::model::shipment_model::PrecedenceRule::first_is_delivery].
2930 ///
2931 /// # Example
2932 /// ```ignore,no_run
2933 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2934 /// let x = PrecedenceRule::new().set_first_is_delivery(true);
2935 /// ```
2936 pub fn set_first_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2937 self.first_is_delivery = v.into();
2938 self
2939 }
2940
2941 /// Sets the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2942 ///
2943 /// # Example
2944 /// ```ignore,no_run
2945 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2946 /// let x = PrecedenceRule::new().set_second_index(42);
2947 /// ```
2948 pub fn set_second_index<T>(mut self, v: T) -> Self
2949 where
2950 T: std::convert::Into<i32>,
2951 {
2952 self.second_index = std::option::Option::Some(v.into());
2953 self
2954 }
2955
2956 /// Sets or clears the value of [second_index][crate::model::shipment_model::PrecedenceRule::second_index].
2957 ///
2958 /// # Example
2959 /// ```ignore,no_run
2960 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2961 /// let x = PrecedenceRule::new().set_or_clear_second_index(Some(42));
2962 /// let x = PrecedenceRule::new().set_or_clear_second_index(None::<i32>);
2963 /// ```
2964 pub fn set_or_clear_second_index<T>(mut self, v: std::option::Option<T>) -> Self
2965 where
2966 T: std::convert::Into<i32>,
2967 {
2968 self.second_index = v.map(|x| x.into());
2969 self
2970 }
2971
2972 /// Sets the value of [second_is_delivery][crate::model::shipment_model::PrecedenceRule::second_is_delivery].
2973 ///
2974 /// # Example
2975 /// ```ignore,no_run
2976 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2977 /// let x = PrecedenceRule::new().set_second_is_delivery(true);
2978 /// ```
2979 pub fn set_second_is_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2980 self.second_is_delivery = v.into();
2981 self
2982 }
2983
2984 /// Sets the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
2985 ///
2986 /// # Example
2987 /// ```ignore,no_run
2988 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
2989 /// use wkt::Duration;
2990 /// let x = PrecedenceRule::new().set_offset_duration(Duration::default()/* use setters */);
2991 /// ```
2992 pub fn set_offset_duration<T>(mut self, v: T) -> Self
2993 where
2994 T: std::convert::Into<wkt::Duration>,
2995 {
2996 self.offset_duration = std::option::Option::Some(v.into());
2997 self
2998 }
2999
3000 /// Sets or clears the value of [offset_duration][crate::model::shipment_model::PrecedenceRule::offset_duration].
3001 ///
3002 /// # Example
3003 /// ```ignore,no_run
3004 /// # use google_cloud_optimization_v1::model::shipment_model::PrecedenceRule;
3005 /// use wkt::Duration;
3006 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(Some(Duration::default()/* use setters */));
3007 /// let x = PrecedenceRule::new().set_or_clear_offset_duration(None::<Duration>);
3008 /// ```
3009 pub fn set_or_clear_offset_duration<T>(mut self, v: std::option::Option<T>) -> Self
3010 where
3011 T: std::convert::Into<wkt::Duration>,
3012 {
3013 self.offset_duration = v.map(|x| x.into());
3014 self
3015 }
3016 }
3017
3018 impl wkt::message::Message for PrecedenceRule {
3019 fn typename() -> &'static str {
3020 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.PrecedenceRule"
3021 }
3022 }
3023
3024 /// Deprecated: Use top level
3025 /// [BreakRule][google.cloud.optimization.v1.ShipmentModel.BreakRule] instead.
3026 /// Rules to generate time breaks for a vehicle (e.g. lunch
3027 /// breaks). A break is a contiguous period of time during which the vehicle
3028 /// remains idle at its current position and cannot perform any visit. A break
3029 /// may occur:
3030 ///
3031 /// * during the travel between two visits (which includes the time right
3032 /// before or right after a visit, but not in the middle of a visit), in
3033 /// which case it extends the corresponding transit time between the visits
3034 /// * before the vehicle start (the vehicle may not start in the middle of
3035 /// a break), in which case it does not affect the vehicle start time.
3036 /// * after the vehicle end (ditto, with the vehicle end time).
3037 ///
3038 /// [google.cloud.optimization.v1.ShipmentModel.BreakRule]: crate::model::shipment_model::BreakRule
3039 #[derive(Clone, Default, PartialEq)]
3040 #[non_exhaustive]
3041 #[deprecated]
3042 pub struct BreakRule {
3043 /// Sequence of breaks. See the `BreakRequest` message.
3044 pub break_requests: std::vec::Vec<crate::model::shipment_model::break_rule::BreakRequest>,
3045
3046 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
3047 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
3048 pub frequency_constraints:
3049 std::vec::Vec<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3050
3051 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3052 }
3053
3054 impl BreakRule {
3055 pub fn new() -> Self {
3056 std::default::Default::default()
3057 }
3058
3059 /// Sets the value of [break_requests][crate::model::shipment_model::BreakRule::break_requests].
3060 ///
3061 /// # Example
3062 /// ```ignore,no_run
3063 /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3064 /// use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3065 /// let x = BreakRule::new()
3066 /// .set_break_requests([
3067 /// BreakRequest::default()/* use setters */,
3068 /// BreakRequest::default()/* use (different) setters */,
3069 /// ]);
3070 /// ```
3071 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
3072 where
3073 T: std::iter::IntoIterator<Item = V>,
3074 V: std::convert::Into<crate::model::shipment_model::break_rule::BreakRequest>,
3075 {
3076 use std::iter::Iterator;
3077 self.break_requests = v.into_iter().map(|i| i.into()).collect();
3078 self
3079 }
3080
3081 /// Sets the value of [frequency_constraints][crate::model::shipment_model::BreakRule::frequency_constraints].
3082 ///
3083 /// # Example
3084 /// ```ignore,no_run
3085 /// # use google_cloud_optimization_v1::model::shipment_model::BreakRule;
3086 /// use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3087 /// let x = BreakRule::new()
3088 /// .set_frequency_constraints([
3089 /// FrequencyConstraint::default()/* use setters */,
3090 /// FrequencyConstraint::default()/* use (different) setters */,
3091 /// ]);
3092 /// ```
3093 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
3094 where
3095 T: std::iter::IntoIterator<Item = V>,
3096 V: std::convert::Into<crate::model::shipment_model::break_rule::FrequencyConstraint>,
3097 {
3098 use std::iter::Iterator;
3099 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
3100 self
3101 }
3102 }
3103
3104 impl wkt::message::Message for BreakRule {
3105 fn typename() -> &'static str {
3106 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule"
3107 }
3108 }
3109
3110 /// Defines additional types related to [BreakRule].
3111 pub mod break_rule {
3112 #[allow(unused_imports)]
3113 use super::*;
3114
3115 /// The sequence of breaks (i.e. their number and order) that apply to each
3116 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
3117 /// that sequence, in the order in which they must occur. Their time windows
3118 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
3119 /// be compatible with the order (this is checked).
3120 #[derive(Clone, Default, PartialEq)]
3121 #[non_exhaustive]
3122 pub struct BreakRequest {
3123 /// Required. Lower bound (inclusive) on the start of the break.
3124 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
3125
3126 /// Required. Upper bound (inclusive) on the start of the break.
3127 pub latest_start_time: std::option::Option<wkt::Timestamp>,
3128
3129 /// Required. Minimum duration of the break. Must be positive.
3130 pub min_duration: std::option::Option<wkt::Duration>,
3131
3132 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3133 }
3134
3135 impl BreakRequest {
3136 pub fn new() -> Self {
3137 std::default::Default::default()
3138 }
3139
3140 /// Sets the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3141 ///
3142 /// # Example
3143 /// ```ignore,no_run
3144 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3145 /// use wkt::Timestamp;
3146 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
3147 /// ```
3148 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
3149 where
3150 T: std::convert::Into<wkt::Timestamp>,
3151 {
3152 self.earliest_start_time = std::option::Option::Some(v.into());
3153 self
3154 }
3155
3156 /// Sets or clears the value of [earliest_start_time][crate::model::shipment_model::break_rule::BreakRequest::earliest_start_time].
3157 ///
3158 /// # Example
3159 /// ```ignore,no_run
3160 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3161 /// use wkt::Timestamp;
3162 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
3163 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
3164 /// ```
3165 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3166 where
3167 T: std::convert::Into<wkt::Timestamp>,
3168 {
3169 self.earliest_start_time = v.map(|x| x.into());
3170 self
3171 }
3172
3173 /// Sets the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3174 ///
3175 /// # Example
3176 /// ```ignore,no_run
3177 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3178 /// use wkt::Timestamp;
3179 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
3180 /// ```
3181 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
3182 where
3183 T: std::convert::Into<wkt::Timestamp>,
3184 {
3185 self.latest_start_time = std::option::Option::Some(v.into());
3186 self
3187 }
3188
3189 /// Sets or clears the value of [latest_start_time][crate::model::shipment_model::break_rule::BreakRequest::latest_start_time].
3190 ///
3191 /// # Example
3192 /// ```ignore,no_run
3193 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3194 /// use wkt::Timestamp;
3195 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
3196 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
3197 /// ```
3198 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3199 where
3200 T: std::convert::Into<wkt::Timestamp>,
3201 {
3202 self.latest_start_time = v.map(|x| x.into());
3203 self
3204 }
3205
3206 /// Sets the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3207 ///
3208 /// # Example
3209 /// ```ignore,no_run
3210 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3211 /// use wkt::Duration;
3212 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
3213 /// ```
3214 pub fn set_min_duration<T>(mut self, v: T) -> Self
3215 where
3216 T: std::convert::Into<wkt::Duration>,
3217 {
3218 self.min_duration = std::option::Option::Some(v.into());
3219 self
3220 }
3221
3222 /// Sets or clears the value of [min_duration][crate::model::shipment_model::break_rule::BreakRequest::min_duration].
3223 ///
3224 /// # Example
3225 /// ```ignore,no_run
3226 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::BreakRequest;
3227 /// use wkt::Duration;
3228 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
3229 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
3230 /// ```
3231 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
3232 where
3233 T: std::convert::Into<wkt::Duration>,
3234 {
3235 self.min_duration = v.map(|x| x.into());
3236 self
3237 }
3238 }
3239
3240 impl wkt::message::Message for BreakRequest {
3241 fn typename() -> &'static str {
3242 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.BreakRequest"
3243 }
3244 }
3245
3246 /// One may further constrain the frequency and duration of the breaks
3247 /// specified above, by enforcing a minimum break frequency, such as
3248 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
3249 /// this can be interpreted as "Within any sliding time window of 12h, there
3250 /// must be at least one break of at least one hour", that example would
3251 /// translate to the following `FrequencyConstraint`:
3252 ///
3253 /// ```norust
3254 /// {
3255 /// min_break_duration { seconds: 3600 } # 1 hour.
3256 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
3257 /// }
3258 /// ```
3259 ///
3260 /// The timing and duration of the breaks in the solution will respect all
3261 /// such constraints, in addition to the time windows and minimum durations
3262 /// already specified in the `BreakRequest`.
3263 ///
3264 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
3265 /// For example, the following schedule honors the "1h every 12h" example:
3266 ///
3267 /// ```norust
3268 /// 04:00 vehicle start
3269 /// .. performing travel and visits ..
3270 /// 09:00 1 hour break
3271 /// 10:00 end of the break
3272 /// .. performing travel and visits ..
3273 /// 12:00 20-min lunch break
3274 /// 12:20 end of the break
3275 /// .. performing travel and visits ..
3276 /// 21:00 1 hour break
3277 /// 22:00 end of the break
3278 /// .. performing travel and visits ..
3279 /// 23:59 vehicle end
3280 /// ```
3281 #[derive(Clone, Default, PartialEq)]
3282 #[non_exhaustive]
3283 pub struct FrequencyConstraint {
3284 /// Required. Minimum break duration for this constraint. Nonnegative.
3285 /// See description of `FrequencyConstraint`.
3286 pub min_break_duration: std::option::Option<wkt::Duration>,
3287
3288 /// Required. Maximum allowed span of any interval of time in the route
3289 /// that does not include at least partially a break of `duration >=
3290 /// min_break_duration`. Must be positive.
3291 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
3292
3293 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3294 }
3295
3296 impl FrequencyConstraint {
3297 pub fn new() -> Self {
3298 std::default::Default::default()
3299 }
3300
3301 /// Sets the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3302 ///
3303 /// # Example
3304 /// ```ignore,no_run
3305 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3306 /// use wkt::Duration;
3307 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
3308 /// ```
3309 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
3310 where
3311 T: std::convert::Into<wkt::Duration>,
3312 {
3313 self.min_break_duration = std::option::Option::Some(v.into());
3314 self
3315 }
3316
3317 /// Sets or clears the value of [min_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::min_break_duration].
3318 ///
3319 /// # Example
3320 /// ```ignore,no_run
3321 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3322 /// use wkt::Duration;
3323 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
3324 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
3325 /// ```
3326 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
3327 where
3328 T: std::convert::Into<wkt::Duration>,
3329 {
3330 self.min_break_duration = v.map(|x| x.into());
3331 self
3332 }
3333
3334 /// Sets the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3335 ///
3336 /// # Example
3337 /// ```ignore,no_run
3338 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3339 /// use wkt::Duration;
3340 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
3341 /// ```
3342 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
3343 where
3344 T: std::convert::Into<wkt::Duration>,
3345 {
3346 self.max_inter_break_duration = std::option::Option::Some(v.into());
3347 self
3348 }
3349
3350 /// Sets or clears the value of [max_inter_break_duration][crate::model::shipment_model::break_rule::FrequencyConstraint::max_inter_break_duration].
3351 ///
3352 /// # Example
3353 /// ```ignore,no_run
3354 /// # use google_cloud_optimization_v1::model::shipment_model::break_rule::FrequencyConstraint;
3355 /// use wkt::Duration;
3356 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
3357 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
3358 /// ```
3359 pub fn set_or_clear_max_inter_break_duration<T>(
3360 mut self,
3361 v: std::option::Option<T>,
3362 ) -> Self
3363 where
3364 T: std::convert::Into<wkt::Duration>,
3365 {
3366 self.max_inter_break_duration = v.map(|x| x.into());
3367 self
3368 }
3369 }
3370
3371 impl wkt::message::Message for FrequencyConstraint {
3372 fn typename() -> &'static str {
3373 "type.googleapis.com/google.cloud.optimization.v1.ShipmentModel.BreakRule.FrequencyConstraint"
3374 }
3375 }
3376 }
3377}
3378
3379/// The shipment of a single item, from one of its pickups to one of its
3380/// deliveries. For the shipment to be considered as performed, a unique vehicle
3381/// must visit one of its pickup locations (and decrease its spare capacities
3382/// accordingly), then visit one of its delivery locations later on (and
3383/// therefore re-increase its spare capacities accordingly).
3384#[derive(Clone, Default, PartialEq)]
3385#[non_exhaustive]
3386pub struct Shipment {
3387 /// Set of pickup alternatives associated to the shipment. If not specified,
3388 /// the vehicle only needs to visit a location corresponding to the deliveries.
3389 pub pickups: std::vec::Vec<crate::model::shipment::VisitRequest>,
3390
3391 /// Set of delivery alternatives associated to the shipment. If not specified,
3392 /// the vehicle only needs to visit a location corresponding to the pickups.
3393 pub deliveries: std::vec::Vec<crate::model::shipment::VisitRequest>,
3394
3395 /// Load demands of the shipment (for example weight, volume, number of
3396 /// pallets etc). The keys in the map should be identifiers describing the type
3397 /// of the corresponding load, ideally also including the units.
3398 /// For example: "weight_kg", "volume_gallons", "pallet_count", etc.
3399 /// If a given key does not appear in the map, the corresponding load is
3400 /// considered as null.
3401 pub load_demands: std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3402
3403 /// If the shipment is not completed, this penalty is added to the overall
3404 /// cost of the routes. A shipment is considered completed if one of its pickup
3405 /// and delivery alternatives is visited. The cost may be expressed in the
3406 /// same unit used for all other cost-related fields in the model and must be
3407 /// positive.
3408 ///
3409 /// *IMPORTANT*: If this penalty is not specified, it is considered infinite,
3410 /// i.e. the shipment must be completed.
3411 pub penalty_cost: std::option::Option<f64>,
3412
3413 /// The set of vehicles that may perform this shipment. If empty, all vehicles
3414 /// may perform it. Vehicles are given by their index in the `ShipmentModel`'s
3415 /// `vehicles` list.
3416 pub allowed_vehicle_indices: std::vec::Vec<i32>,
3417
3418 /// Specifies the cost that is incurred when this shipment is delivered by each
3419 /// vehicle. If specified, it must have EITHER:
3420 ///
3421 /// * the same number of elements as `costs_per_vehicle_indices`.
3422 /// `costs_per_vehicle[i]` corresponds to vehicle
3423 /// `costs_per_vehicle_indices[i]` of the model.
3424 /// * the same number of elements as there are vehicles in the model. The
3425 /// i-th element corresponds to vehicle #i of the model.
3426 ///
3427 /// These costs must be in the same unit as `penalty_cost` and must not be
3428 /// negative. Leave this field empty, if there are no such costs.
3429 pub costs_per_vehicle: std::vec::Vec<f64>,
3430
3431 /// Indices of the vehicles to which `costs_per_vehicle` applies. If non-empty,
3432 /// it must have the same number of elements as `costs_per_vehicle`. A vehicle
3433 /// index may not be specified more than once. If a vehicle is excluded from
3434 /// `costs_per_vehicle_indices`, its cost is zero.
3435 pub costs_per_vehicle_indices: std::vec::Vec<i32>,
3436
3437 /// Specifies the maximum relative detour time compared to the shortest path
3438 /// from pickup to delivery. If specified, it must be nonnegative, and the
3439 /// shipment must contain at least a pickup and a delivery.
3440 ///
3441 /// For example, let t be the shortest time taken to go from the selected
3442 /// pickup alternative directly to the selected delivery alternative. Then
3443 /// setting `pickup_to_delivery_relative_detour_limit` enforces:
3444 ///
3445 /// ```norust
3446 /// start_time(delivery) - start_time(pickup) <=
3447 /// std::ceil(t * (1.0 + pickup_to_delivery_relative_detour_limit))
3448 /// ```
3449 ///
3450 /// If both relative and absolute limits are specified on the same shipment,
3451 /// the more constraining limit is used for each possible pickup/delivery pair.
3452 /// As of 2017/10, detours are only supported when travel durations do not
3453 /// depend on vehicles.
3454 pub pickup_to_delivery_relative_detour_limit: std::option::Option<f64>,
3455
3456 /// Specifies the maximum absolute detour time compared to the shortest path
3457 /// from pickup to delivery. If specified, it must be nonnegative, and the
3458 /// shipment must contain at least a pickup and a delivery.
3459 ///
3460 /// For example, let t be the shortest time taken to go from the selected
3461 /// pickup alternative directly to the selected delivery alternative. Then
3462 /// setting `pickup_to_delivery_absolute_detour_limit` enforces:
3463 ///
3464 /// ```norust
3465 /// start_time(delivery) - start_time(pickup) <=
3466 /// t + pickup_to_delivery_absolute_detour_limit
3467 /// ```
3468 ///
3469 /// If both relative and absolute limits are specified on the same shipment,
3470 /// the more constraining limit is used for each possible pickup/delivery pair.
3471 /// As of 2017/10, detours are only supported when travel durations do not
3472 /// depend on vehicles.
3473 pub pickup_to_delivery_absolute_detour_limit: std::option::Option<wkt::Duration>,
3474
3475 /// Specifies the maximum duration from start of pickup to start of delivery of
3476 /// a shipment. If specified, it must be nonnegative, and the shipment must
3477 /// contain at least a pickup and a delivery. This does not depend on which
3478 /// alternatives are selected for pickup and delivery, nor on vehicle speed.
3479 /// This can be specified alongside maximum detour constraints: the solution
3480 /// will respect both specifications.
3481 pub pickup_to_delivery_time_limit: std::option::Option<wkt::Duration>,
3482
3483 /// Non-empty string specifying a "type" for this shipment.
3484 /// This feature can be used to define incompatibilities or requirements
3485 /// between `shipment_types` (see `shipment_type_incompatibilities` and
3486 /// `shipment_type_requirements` in `ShipmentModel`).
3487 ///
3488 /// Differs from `visit_types` which is specified for a single visit: All
3489 /// pickup/deliveries belonging to the same shipment share the same
3490 /// `shipment_type`.
3491 pub shipment_type: std::string::String,
3492
3493 /// Specifies a label for this shipment. This label is reported in the response
3494 /// in the `shipment_label` of the corresponding
3495 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3496 ///
3497 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3498 pub label: std::string::String,
3499
3500 /// If true, skip this shipment, but don't apply a `penalty_cost`.
3501 ///
3502 /// Ignoring a shipment results in a validation error when there are any
3503 /// `shipment_type_requirements` in the model.
3504 ///
3505 /// Ignoring a shipment that is performed in `injected_first_solution_routes`
3506 /// or `injected_solution_constraint` is permitted; the solver removes the
3507 /// related pickup/delivery visits from the performing route.
3508 /// `precedence_rules` that reference ignored shipments will also be ignored.
3509 pub ignore: bool,
3510
3511 /// Deprecated: Use
3512 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3513 /// instead.
3514 ///
3515 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3516 #[deprecated]
3517 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3518
3519 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3520}
3521
3522impl Shipment {
3523 pub fn new() -> Self {
3524 std::default::Default::default()
3525 }
3526
3527 /// Sets the value of [pickups][crate::model::Shipment::pickups].
3528 ///
3529 /// # Example
3530 /// ```ignore,no_run
3531 /// # use google_cloud_optimization_v1::model::Shipment;
3532 /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3533 /// let x = Shipment::new()
3534 /// .set_pickups([
3535 /// VisitRequest::default()/* use setters */,
3536 /// VisitRequest::default()/* use (different) setters */,
3537 /// ]);
3538 /// ```
3539 pub fn set_pickups<T, V>(mut self, v: T) -> Self
3540 where
3541 T: std::iter::IntoIterator<Item = V>,
3542 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3543 {
3544 use std::iter::Iterator;
3545 self.pickups = v.into_iter().map(|i| i.into()).collect();
3546 self
3547 }
3548
3549 /// Sets the value of [deliveries][crate::model::Shipment::deliveries].
3550 ///
3551 /// # Example
3552 /// ```ignore,no_run
3553 /// # use google_cloud_optimization_v1::model::Shipment;
3554 /// use google_cloud_optimization_v1::model::shipment::VisitRequest;
3555 /// let x = Shipment::new()
3556 /// .set_deliveries([
3557 /// VisitRequest::default()/* use setters */,
3558 /// VisitRequest::default()/* use (different) setters */,
3559 /// ]);
3560 /// ```
3561 pub fn set_deliveries<T, V>(mut self, v: T) -> Self
3562 where
3563 T: std::iter::IntoIterator<Item = V>,
3564 V: std::convert::Into<crate::model::shipment::VisitRequest>,
3565 {
3566 use std::iter::Iterator;
3567 self.deliveries = v.into_iter().map(|i| i.into()).collect();
3568 self
3569 }
3570
3571 /// Sets the value of [load_demands][crate::model::Shipment::load_demands].
3572 ///
3573 /// # Example
3574 /// ```ignore,no_run
3575 /// # use google_cloud_optimization_v1::model::Shipment;
3576 /// use google_cloud_optimization_v1::model::shipment::Load;
3577 /// let x = Shipment::new().set_load_demands([
3578 /// ("key0", Load::default()/* use setters */),
3579 /// ("key1", Load::default()/* use (different) setters */),
3580 /// ]);
3581 /// ```
3582 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
3583 where
3584 T: std::iter::IntoIterator<Item = (K, V)>,
3585 K: std::convert::Into<std::string::String>,
3586 V: std::convert::Into<crate::model::shipment::Load>,
3587 {
3588 use std::iter::Iterator;
3589 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3590 self
3591 }
3592
3593 /// Sets the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3594 ///
3595 /// # Example
3596 /// ```ignore,no_run
3597 /// # use google_cloud_optimization_v1::model::Shipment;
3598 /// let x = Shipment::new().set_penalty_cost(42.0);
3599 /// ```
3600 pub fn set_penalty_cost<T>(mut self, v: T) -> Self
3601 where
3602 T: std::convert::Into<f64>,
3603 {
3604 self.penalty_cost = std::option::Option::Some(v.into());
3605 self
3606 }
3607
3608 /// Sets or clears the value of [penalty_cost][crate::model::Shipment::penalty_cost].
3609 ///
3610 /// # Example
3611 /// ```ignore,no_run
3612 /// # use google_cloud_optimization_v1::model::Shipment;
3613 /// let x = Shipment::new().set_or_clear_penalty_cost(Some(42.0));
3614 /// let x = Shipment::new().set_or_clear_penalty_cost(None::<f32>);
3615 /// ```
3616 pub fn set_or_clear_penalty_cost<T>(mut self, v: std::option::Option<T>) -> Self
3617 where
3618 T: std::convert::Into<f64>,
3619 {
3620 self.penalty_cost = v.map(|x| x.into());
3621 self
3622 }
3623
3624 /// Sets the value of [allowed_vehicle_indices][crate::model::Shipment::allowed_vehicle_indices].
3625 ///
3626 /// # Example
3627 /// ```ignore,no_run
3628 /// # use google_cloud_optimization_v1::model::Shipment;
3629 /// let x = Shipment::new().set_allowed_vehicle_indices([1, 2, 3]);
3630 /// ```
3631 pub fn set_allowed_vehicle_indices<T, V>(mut self, v: T) -> Self
3632 where
3633 T: std::iter::IntoIterator<Item = V>,
3634 V: std::convert::Into<i32>,
3635 {
3636 use std::iter::Iterator;
3637 self.allowed_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3638 self
3639 }
3640
3641 /// Sets the value of [costs_per_vehicle][crate::model::Shipment::costs_per_vehicle].
3642 ///
3643 /// # Example
3644 /// ```ignore,no_run
3645 /// # use google_cloud_optimization_v1::model::Shipment;
3646 /// let x = Shipment::new().set_costs_per_vehicle([1.0, 2.0, 3.0]);
3647 /// ```
3648 pub fn set_costs_per_vehicle<T, V>(mut self, v: T) -> Self
3649 where
3650 T: std::iter::IntoIterator<Item = V>,
3651 V: std::convert::Into<f64>,
3652 {
3653 use std::iter::Iterator;
3654 self.costs_per_vehicle = v.into_iter().map(|i| i.into()).collect();
3655 self
3656 }
3657
3658 /// Sets the value of [costs_per_vehicle_indices][crate::model::Shipment::costs_per_vehicle_indices].
3659 ///
3660 /// # Example
3661 /// ```ignore,no_run
3662 /// # use google_cloud_optimization_v1::model::Shipment;
3663 /// let x = Shipment::new().set_costs_per_vehicle_indices([1, 2, 3]);
3664 /// ```
3665 pub fn set_costs_per_vehicle_indices<T, V>(mut self, v: T) -> Self
3666 where
3667 T: std::iter::IntoIterator<Item = V>,
3668 V: std::convert::Into<i32>,
3669 {
3670 use std::iter::Iterator;
3671 self.costs_per_vehicle_indices = v.into_iter().map(|i| i.into()).collect();
3672 self
3673 }
3674
3675 /// Sets the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3676 ///
3677 /// # Example
3678 /// ```ignore,no_run
3679 /// # use google_cloud_optimization_v1::model::Shipment;
3680 /// let x = Shipment::new().set_pickup_to_delivery_relative_detour_limit(42.0);
3681 /// ```
3682 pub fn set_pickup_to_delivery_relative_detour_limit<T>(mut self, v: T) -> Self
3683 where
3684 T: std::convert::Into<f64>,
3685 {
3686 self.pickup_to_delivery_relative_detour_limit = std::option::Option::Some(v.into());
3687 self
3688 }
3689
3690 /// Sets or clears the value of [pickup_to_delivery_relative_detour_limit][crate::model::Shipment::pickup_to_delivery_relative_detour_limit].
3691 ///
3692 /// # Example
3693 /// ```ignore,no_run
3694 /// # use google_cloud_optimization_v1::model::Shipment;
3695 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(Some(42.0));
3696 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_relative_detour_limit(None::<f32>);
3697 /// ```
3698 pub fn set_or_clear_pickup_to_delivery_relative_detour_limit<T>(
3699 mut self,
3700 v: std::option::Option<T>,
3701 ) -> Self
3702 where
3703 T: std::convert::Into<f64>,
3704 {
3705 self.pickup_to_delivery_relative_detour_limit = v.map(|x| x.into());
3706 self
3707 }
3708
3709 /// Sets the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3710 ///
3711 /// # Example
3712 /// ```ignore,no_run
3713 /// # use google_cloud_optimization_v1::model::Shipment;
3714 /// use wkt::Duration;
3715 /// let x = Shipment::new().set_pickup_to_delivery_absolute_detour_limit(Duration::default()/* use setters */);
3716 /// ```
3717 pub fn set_pickup_to_delivery_absolute_detour_limit<T>(mut self, v: T) -> Self
3718 where
3719 T: std::convert::Into<wkt::Duration>,
3720 {
3721 self.pickup_to_delivery_absolute_detour_limit = std::option::Option::Some(v.into());
3722 self
3723 }
3724
3725 /// Sets or clears the value of [pickup_to_delivery_absolute_detour_limit][crate::model::Shipment::pickup_to_delivery_absolute_detour_limit].
3726 ///
3727 /// # Example
3728 /// ```ignore,no_run
3729 /// # use google_cloud_optimization_v1::model::Shipment;
3730 /// use wkt::Duration;
3731 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(Some(Duration::default()/* use setters */));
3732 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_absolute_detour_limit(None::<Duration>);
3733 /// ```
3734 pub fn set_or_clear_pickup_to_delivery_absolute_detour_limit<T>(
3735 mut self,
3736 v: std::option::Option<T>,
3737 ) -> Self
3738 where
3739 T: std::convert::Into<wkt::Duration>,
3740 {
3741 self.pickup_to_delivery_absolute_detour_limit = v.map(|x| x.into());
3742 self
3743 }
3744
3745 /// Sets the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3746 ///
3747 /// # Example
3748 /// ```ignore,no_run
3749 /// # use google_cloud_optimization_v1::model::Shipment;
3750 /// use wkt::Duration;
3751 /// let x = Shipment::new().set_pickup_to_delivery_time_limit(Duration::default()/* use setters */);
3752 /// ```
3753 pub fn set_pickup_to_delivery_time_limit<T>(mut self, v: T) -> Self
3754 where
3755 T: std::convert::Into<wkt::Duration>,
3756 {
3757 self.pickup_to_delivery_time_limit = std::option::Option::Some(v.into());
3758 self
3759 }
3760
3761 /// Sets or clears the value of [pickup_to_delivery_time_limit][crate::model::Shipment::pickup_to_delivery_time_limit].
3762 ///
3763 /// # Example
3764 /// ```ignore,no_run
3765 /// # use google_cloud_optimization_v1::model::Shipment;
3766 /// use wkt::Duration;
3767 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(Some(Duration::default()/* use setters */));
3768 /// let x = Shipment::new().set_or_clear_pickup_to_delivery_time_limit(None::<Duration>);
3769 /// ```
3770 pub fn set_or_clear_pickup_to_delivery_time_limit<T>(
3771 mut self,
3772 v: std::option::Option<T>,
3773 ) -> Self
3774 where
3775 T: std::convert::Into<wkt::Duration>,
3776 {
3777 self.pickup_to_delivery_time_limit = v.map(|x| x.into());
3778 self
3779 }
3780
3781 /// Sets the value of [shipment_type][crate::model::Shipment::shipment_type].
3782 ///
3783 /// # Example
3784 /// ```ignore,no_run
3785 /// # use google_cloud_optimization_v1::model::Shipment;
3786 /// let x = Shipment::new().set_shipment_type("example");
3787 /// ```
3788 pub fn set_shipment_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3789 self.shipment_type = v.into();
3790 self
3791 }
3792
3793 /// Sets the value of [label][crate::model::Shipment::label].
3794 ///
3795 /// # Example
3796 /// ```ignore,no_run
3797 /// # use google_cloud_optimization_v1::model::Shipment;
3798 /// let x = Shipment::new().set_label("example");
3799 /// ```
3800 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3801 self.label = v.into();
3802 self
3803 }
3804
3805 /// Sets the value of [ignore][crate::model::Shipment::ignore].
3806 ///
3807 /// # Example
3808 /// ```ignore,no_run
3809 /// # use google_cloud_optimization_v1::model::Shipment;
3810 /// let x = Shipment::new().set_ignore(true);
3811 /// ```
3812 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3813 self.ignore = v.into();
3814 self
3815 }
3816
3817 /// Sets the value of [demands][crate::model::Shipment::demands].
3818 ///
3819 /// # Example
3820 /// ```ignore,no_run
3821 /// # use google_cloud_optimization_v1::model::Shipment;
3822 /// use google_cloud_optimization_v1::model::CapacityQuantity;
3823 /// let x = Shipment::new()
3824 /// .set_demands([
3825 /// CapacityQuantity::default()/* use setters */,
3826 /// CapacityQuantity::default()/* use (different) setters */,
3827 /// ]);
3828 /// ```
3829 #[deprecated]
3830 pub fn set_demands<T, V>(mut self, v: T) -> Self
3831 where
3832 T: std::iter::IntoIterator<Item = V>,
3833 V: std::convert::Into<crate::model::CapacityQuantity>,
3834 {
3835 use std::iter::Iterator;
3836 self.demands = v.into_iter().map(|i| i.into()).collect();
3837 self
3838 }
3839}
3840
3841impl wkt::message::Message for Shipment {
3842 fn typename() -> &'static str {
3843 "type.googleapis.com/google.cloud.optimization.v1.Shipment"
3844 }
3845}
3846
3847/// Defines additional types related to [Shipment].
3848pub mod shipment {
3849 #[allow(unused_imports)]
3850 use super::*;
3851
3852 /// Request for a visit which can be done by a vehicle: it has a geo-location
3853 /// (or two, see below), opening and closing times represented by time windows,
3854 /// and a service duration time (time spent by the vehicle once it has arrived
3855 /// to pickup or drop off goods).
3856 #[derive(Clone, Default, PartialEq)]
3857 #[non_exhaustive]
3858 pub struct VisitRequest {
3859 /// The geo-location where the vehicle arrives when performing this
3860 /// `VisitRequest`. If the shipment model has duration distance matrices,
3861 /// `arrival_location` must not be specified.
3862 pub arrival_location: std::option::Option<google_cloud_type::model::LatLng>,
3863
3864 /// The waypoint where the vehicle arrives when performing this
3865 /// `VisitRequest`. If the shipment model has duration distance matrices,
3866 /// `arrival_waypoint` must not be specified.
3867 pub arrival_waypoint: std::option::Option<crate::model::Waypoint>,
3868
3869 /// The geo-location where the vehicle departs after completing this
3870 /// `VisitRequest`. Can be omitted if it is the same as `arrival_location`.
3871 /// If the shipment model has duration distance matrices,
3872 /// `departure_location` must not be specified.
3873 pub departure_location: std::option::Option<google_cloud_type::model::LatLng>,
3874
3875 /// The waypoint where the vehicle departs after completing this
3876 /// `VisitRequest`. Can be omitted if it is the same as `arrival_waypoint`.
3877 /// If the shipment model has duration distance matrices,
3878 /// `departure_waypoint` must not be specified.
3879 pub departure_waypoint: std::option::Option<crate::model::Waypoint>,
3880
3881 /// Specifies tags attached to the visit request.
3882 /// Empty or duplicate strings are not allowed.
3883 pub tags: std::vec::Vec<std::string::String>,
3884
3885 /// Time windows which constrain the arrival time at a visit.
3886 /// Note that a vehicle may depart outside of the arrival time window, i.e.
3887 /// arrival time + duration do not need to be inside a time window. This can
3888 /// result in waiting time if the vehicle arrives before
3889 /// [TimeWindow.start_time][google.cloud.optimization.v1.TimeWindow.start_time].
3890 ///
3891 /// The absence of `TimeWindow` means that the vehicle can perform this visit
3892 /// at any time.
3893 ///
3894 /// Time windows must be disjoint, i.e. no time window must overlap with or
3895 /// be adjacent to another, and they must be in increasing order.
3896 ///
3897 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only
3898 /// be set if there is a single time window.
3899 ///
3900 /// [google.cloud.optimization.v1.TimeWindow.start_time]: crate::model::TimeWindow::start_time
3901 pub time_windows: std::vec::Vec<crate::model::TimeWindow>,
3902
3903 /// Duration of the visit, i.e. time spent by the vehicle between arrival
3904 /// and departure (to be added to the possible waiting time; see
3905 /// `time_windows`).
3906 pub duration: std::option::Option<wkt::Duration>,
3907
3908 /// Cost to service this visit request on a vehicle route. This can be used
3909 /// to pay different costs for each alternative pickup or delivery of a
3910 /// shipment. This cost must be in the same unit as `Shipment.penalty_cost`
3911 /// and must not be negative.
3912 pub cost: f64,
3913
3914 /// Load demands of this visit request. This is just like
3915 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
3916 /// field, except that it only applies to this
3917 /// [VisitRequest][google.cloud.optimization.v1.Shipment.VisitRequest]
3918 /// instead of the whole [Shipment][google.cloud.optimization.v1.Shipment].
3919 /// The demands listed here are added to the demands listed in
3920 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands].
3921 ///
3922 /// [google.cloud.optimization.v1.Shipment]: crate::model::Shipment
3923 /// [google.cloud.optimization.v1.Shipment.VisitRequest]: crate::model::shipment::VisitRequest
3924 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
3925 pub load_demands:
3926 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
3927
3928 /// Specifies the types of the visit. This may be used to allocate additional
3929 /// time required for a vehicle to complete this visit (see
3930 /// [Vehicle.extra_visit_duration_for_visit_type][google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]).
3931 ///
3932 /// A type can only appear once.
3933 ///
3934 /// [google.cloud.optimization.v1.Vehicle.extra_visit_duration_for_visit_type]: crate::model::Vehicle::extra_visit_duration_for_visit_type
3935 pub visit_types: std::vec::Vec<std::string::String>,
3936
3937 /// Specifies a label for this `VisitRequest`. This label is reported in the
3938 /// response as `visit_label` in the corresponding
3939 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit].
3940 ///
3941 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
3942 pub label: std::string::String,
3943
3944 /// Deprecated: Use
3945 /// [VisitRequest.load_demands][google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]
3946 /// instead.
3947 ///
3948 /// [google.cloud.optimization.v1.Shipment.VisitRequest.load_demands]: crate::model::shipment::VisitRequest::load_demands
3949 #[deprecated]
3950 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
3951
3952 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3953 }
3954
3955 impl VisitRequest {
3956 pub fn new() -> Self {
3957 std::default::Default::default()
3958 }
3959
3960 /// Sets the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3961 ///
3962 /// # Example
3963 /// ```ignore,no_run
3964 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3965 /// use google_cloud_type::model::LatLng;
3966 /// let x = VisitRequest::new().set_arrival_location(LatLng::default()/* use setters */);
3967 /// ```
3968 pub fn set_arrival_location<T>(mut self, v: T) -> Self
3969 where
3970 T: std::convert::Into<google_cloud_type::model::LatLng>,
3971 {
3972 self.arrival_location = std::option::Option::Some(v.into());
3973 self
3974 }
3975
3976 /// Sets or clears the value of [arrival_location][crate::model::shipment::VisitRequest::arrival_location].
3977 ///
3978 /// # Example
3979 /// ```ignore,no_run
3980 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3981 /// use google_cloud_type::model::LatLng;
3982 /// let x = VisitRequest::new().set_or_clear_arrival_location(Some(LatLng::default()/* use setters */));
3983 /// let x = VisitRequest::new().set_or_clear_arrival_location(None::<LatLng>);
3984 /// ```
3985 pub fn set_or_clear_arrival_location<T>(mut self, v: std::option::Option<T>) -> Self
3986 where
3987 T: std::convert::Into<google_cloud_type::model::LatLng>,
3988 {
3989 self.arrival_location = v.map(|x| x.into());
3990 self
3991 }
3992
3993 /// Sets the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
3994 ///
3995 /// # Example
3996 /// ```ignore,no_run
3997 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
3998 /// use google_cloud_optimization_v1::model::Waypoint;
3999 /// let x = VisitRequest::new().set_arrival_waypoint(Waypoint::default()/* use setters */);
4000 /// ```
4001 pub fn set_arrival_waypoint<T>(mut self, v: T) -> Self
4002 where
4003 T: std::convert::Into<crate::model::Waypoint>,
4004 {
4005 self.arrival_waypoint = std::option::Option::Some(v.into());
4006 self
4007 }
4008
4009 /// Sets or clears the value of [arrival_waypoint][crate::model::shipment::VisitRequest::arrival_waypoint].
4010 ///
4011 /// # Example
4012 /// ```ignore,no_run
4013 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4014 /// use google_cloud_optimization_v1::model::Waypoint;
4015 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(Some(Waypoint::default()/* use setters */));
4016 /// let x = VisitRequest::new().set_or_clear_arrival_waypoint(None::<Waypoint>);
4017 /// ```
4018 pub fn set_or_clear_arrival_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4019 where
4020 T: std::convert::Into<crate::model::Waypoint>,
4021 {
4022 self.arrival_waypoint = v.map(|x| x.into());
4023 self
4024 }
4025
4026 /// Sets the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4027 ///
4028 /// # Example
4029 /// ```ignore,no_run
4030 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4031 /// use google_cloud_type::model::LatLng;
4032 /// let x = VisitRequest::new().set_departure_location(LatLng::default()/* use setters */);
4033 /// ```
4034 pub fn set_departure_location<T>(mut self, v: T) -> Self
4035 where
4036 T: std::convert::Into<google_cloud_type::model::LatLng>,
4037 {
4038 self.departure_location = std::option::Option::Some(v.into());
4039 self
4040 }
4041
4042 /// Sets or clears the value of [departure_location][crate::model::shipment::VisitRequest::departure_location].
4043 ///
4044 /// # Example
4045 /// ```ignore,no_run
4046 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4047 /// use google_cloud_type::model::LatLng;
4048 /// let x = VisitRequest::new().set_or_clear_departure_location(Some(LatLng::default()/* use setters */));
4049 /// let x = VisitRequest::new().set_or_clear_departure_location(None::<LatLng>);
4050 /// ```
4051 pub fn set_or_clear_departure_location<T>(mut self, v: std::option::Option<T>) -> Self
4052 where
4053 T: std::convert::Into<google_cloud_type::model::LatLng>,
4054 {
4055 self.departure_location = v.map(|x| x.into());
4056 self
4057 }
4058
4059 /// Sets the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4060 ///
4061 /// # Example
4062 /// ```ignore,no_run
4063 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4064 /// use google_cloud_optimization_v1::model::Waypoint;
4065 /// let x = VisitRequest::new().set_departure_waypoint(Waypoint::default()/* use setters */);
4066 /// ```
4067 pub fn set_departure_waypoint<T>(mut self, v: T) -> Self
4068 where
4069 T: std::convert::Into<crate::model::Waypoint>,
4070 {
4071 self.departure_waypoint = std::option::Option::Some(v.into());
4072 self
4073 }
4074
4075 /// Sets or clears the value of [departure_waypoint][crate::model::shipment::VisitRequest::departure_waypoint].
4076 ///
4077 /// # Example
4078 /// ```ignore,no_run
4079 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4080 /// use google_cloud_optimization_v1::model::Waypoint;
4081 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(Some(Waypoint::default()/* use setters */));
4082 /// let x = VisitRequest::new().set_or_clear_departure_waypoint(None::<Waypoint>);
4083 /// ```
4084 pub fn set_or_clear_departure_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
4085 where
4086 T: std::convert::Into<crate::model::Waypoint>,
4087 {
4088 self.departure_waypoint = v.map(|x| x.into());
4089 self
4090 }
4091
4092 /// Sets the value of [tags][crate::model::shipment::VisitRequest::tags].
4093 ///
4094 /// # Example
4095 /// ```ignore,no_run
4096 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4097 /// let x = VisitRequest::new().set_tags(["a", "b", "c"]);
4098 /// ```
4099 pub fn set_tags<T, V>(mut self, v: T) -> Self
4100 where
4101 T: std::iter::IntoIterator<Item = V>,
4102 V: std::convert::Into<std::string::String>,
4103 {
4104 use std::iter::Iterator;
4105 self.tags = v.into_iter().map(|i| i.into()).collect();
4106 self
4107 }
4108
4109 /// Sets the value of [time_windows][crate::model::shipment::VisitRequest::time_windows].
4110 ///
4111 /// # Example
4112 /// ```ignore,no_run
4113 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4114 /// use google_cloud_optimization_v1::model::TimeWindow;
4115 /// let x = VisitRequest::new()
4116 /// .set_time_windows([
4117 /// TimeWindow::default()/* use setters */,
4118 /// TimeWindow::default()/* use (different) setters */,
4119 /// ]);
4120 /// ```
4121 pub fn set_time_windows<T, V>(mut self, v: T) -> Self
4122 where
4123 T: std::iter::IntoIterator<Item = V>,
4124 V: std::convert::Into<crate::model::TimeWindow>,
4125 {
4126 use std::iter::Iterator;
4127 self.time_windows = v.into_iter().map(|i| i.into()).collect();
4128 self
4129 }
4130
4131 /// Sets the value of [duration][crate::model::shipment::VisitRequest::duration].
4132 ///
4133 /// # Example
4134 /// ```ignore,no_run
4135 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4136 /// use wkt::Duration;
4137 /// let x = VisitRequest::new().set_duration(Duration::default()/* use setters */);
4138 /// ```
4139 pub fn set_duration<T>(mut self, v: T) -> Self
4140 where
4141 T: std::convert::Into<wkt::Duration>,
4142 {
4143 self.duration = std::option::Option::Some(v.into());
4144 self
4145 }
4146
4147 /// Sets or clears the value of [duration][crate::model::shipment::VisitRequest::duration].
4148 ///
4149 /// # Example
4150 /// ```ignore,no_run
4151 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4152 /// use wkt::Duration;
4153 /// let x = VisitRequest::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
4154 /// let x = VisitRequest::new().set_or_clear_duration(None::<Duration>);
4155 /// ```
4156 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
4157 where
4158 T: std::convert::Into<wkt::Duration>,
4159 {
4160 self.duration = v.map(|x| x.into());
4161 self
4162 }
4163
4164 /// Sets the value of [cost][crate::model::shipment::VisitRequest::cost].
4165 ///
4166 /// # Example
4167 /// ```ignore,no_run
4168 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4169 /// let x = VisitRequest::new().set_cost(42.0);
4170 /// ```
4171 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4172 self.cost = v.into();
4173 self
4174 }
4175
4176 /// Sets the value of [load_demands][crate::model::shipment::VisitRequest::load_demands].
4177 ///
4178 /// # Example
4179 /// ```ignore,no_run
4180 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4181 /// use google_cloud_optimization_v1::model::shipment::Load;
4182 /// let x = VisitRequest::new().set_load_demands([
4183 /// ("key0", Load::default()/* use setters */),
4184 /// ("key1", Load::default()/* use (different) setters */),
4185 /// ]);
4186 /// ```
4187 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
4188 where
4189 T: std::iter::IntoIterator<Item = (K, V)>,
4190 K: std::convert::Into<std::string::String>,
4191 V: std::convert::Into<crate::model::shipment::Load>,
4192 {
4193 use std::iter::Iterator;
4194 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4195 self
4196 }
4197
4198 /// Sets the value of [visit_types][crate::model::shipment::VisitRequest::visit_types].
4199 ///
4200 /// # Example
4201 /// ```ignore,no_run
4202 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4203 /// let x = VisitRequest::new().set_visit_types(["a", "b", "c"]);
4204 /// ```
4205 pub fn set_visit_types<T, V>(mut self, v: T) -> Self
4206 where
4207 T: std::iter::IntoIterator<Item = V>,
4208 V: std::convert::Into<std::string::String>,
4209 {
4210 use std::iter::Iterator;
4211 self.visit_types = v.into_iter().map(|i| i.into()).collect();
4212 self
4213 }
4214
4215 /// Sets the value of [label][crate::model::shipment::VisitRequest::label].
4216 ///
4217 /// # Example
4218 /// ```ignore,no_run
4219 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4220 /// let x = VisitRequest::new().set_label("example");
4221 /// ```
4222 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4223 self.label = v.into();
4224 self
4225 }
4226
4227 /// Sets the value of [demands][crate::model::shipment::VisitRequest::demands].
4228 ///
4229 /// # Example
4230 /// ```ignore,no_run
4231 /// # use google_cloud_optimization_v1::model::shipment::VisitRequest;
4232 /// use google_cloud_optimization_v1::model::CapacityQuantity;
4233 /// let x = VisitRequest::new()
4234 /// .set_demands([
4235 /// CapacityQuantity::default()/* use setters */,
4236 /// CapacityQuantity::default()/* use (different) setters */,
4237 /// ]);
4238 /// ```
4239 #[deprecated]
4240 pub fn set_demands<T, V>(mut self, v: T) -> Self
4241 where
4242 T: std::iter::IntoIterator<Item = V>,
4243 V: std::convert::Into<crate::model::CapacityQuantity>,
4244 {
4245 use std::iter::Iterator;
4246 self.demands = v.into_iter().map(|i| i.into()).collect();
4247 self
4248 }
4249 }
4250
4251 impl wkt::message::Message for VisitRequest {
4252 fn typename() -> &'static str {
4253 "type.googleapis.com/google.cloud.optimization.v1.Shipment.VisitRequest"
4254 }
4255 }
4256
4257 /// When performing a visit, a predefined amount may be added to the vehicle
4258 /// load if it's a pickup, or subtracted if it's a delivery. This message
4259 /// defines such amount. See
4260 /// [load_demands][google.cloud.optimization.v1.Shipment.load_demands].
4261 ///
4262 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4263 #[derive(Clone, Default, PartialEq)]
4264 #[non_exhaustive]
4265 pub struct Load {
4266 /// The amount by which the load of the vehicle performing the corresponding
4267 /// visit will vary. Since it is an integer, users are advised to choose an
4268 /// appropriate unit to avoid loss of precision. Must be ≥ 0.
4269 pub amount: i64,
4270
4271 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4272 }
4273
4274 impl Load {
4275 pub fn new() -> Self {
4276 std::default::Default::default()
4277 }
4278
4279 /// Sets the value of [amount][crate::model::shipment::Load::amount].
4280 ///
4281 /// # Example
4282 /// ```ignore,no_run
4283 /// # use google_cloud_optimization_v1::model::shipment::Load;
4284 /// let x = Load::new().set_amount(42);
4285 /// ```
4286 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4287 self.amount = v.into();
4288 self
4289 }
4290 }
4291
4292 impl wkt::message::Message for Load {
4293 fn typename() -> &'static str {
4294 "type.googleapis.com/google.cloud.optimization.v1.Shipment.Load"
4295 }
4296 }
4297}
4298
4299/// Specifies incompatibilties between shipments depending on their
4300/// shipment_type. The appearance of incompatible shipments on the same route is
4301/// restricted based on the incompatibility mode.
4302#[derive(Clone, Default, PartialEq)]
4303#[non_exhaustive]
4304pub struct ShipmentTypeIncompatibility {
4305 /// List of incompatible types. Two shipments having different `shipment_types`
4306 /// among those listed are "incompatible".
4307 pub types: std::vec::Vec<std::string::String>,
4308
4309 /// Mode applied to the incompatibility.
4310 pub incompatibility_mode: crate::model::shipment_type_incompatibility::IncompatibilityMode,
4311
4312 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4313}
4314
4315impl ShipmentTypeIncompatibility {
4316 pub fn new() -> Self {
4317 std::default::Default::default()
4318 }
4319
4320 /// Sets the value of [types][crate::model::ShipmentTypeIncompatibility::types].
4321 ///
4322 /// # Example
4323 /// ```ignore,no_run
4324 /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4325 /// let x = ShipmentTypeIncompatibility::new().set_types(["a", "b", "c"]);
4326 /// ```
4327 pub fn set_types<T, V>(mut self, v: T) -> Self
4328 where
4329 T: std::iter::IntoIterator<Item = V>,
4330 V: std::convert::Into<std::string::String>,
4331 {
4332 use std::iter::Iterator;
4333 self.types = v.into_iter().map(|i| i.into()).collect();
4334 self
4335 }
4336
4337 /// Sets the value of [incompatibility_mode][crate::model::ShipmentTypeIncompatibility::incompatibility_mode].
4338 ///
4339 /// # Example
4340 /// ```ignore,no_run
4341 /// # use google_cloud_optimization_v1::model::ShipmentTypeIncompatibility;
4342 /// use google_cloud_optimization_v1::model::shipment_type_incompatibility::IncompatibilityMode;
4343 /// let x0 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotPerformedBySameVehicle);
4344 /// let x1 = ShipmentTypeIncompatibility::new().set_incompatibility_mode(IncompatibilityMode::NotInSameVehicleSimultaneously);
4345 /// ```
4346 pub fn set_incompatibility_mode<
4347 T: std::convert::Into<crate::model::shipment_type_incompatibility::IncompatibilityMode>,
4348 >(
4349 mut self,
4350 v: T,
4351 ) -> Self {
4352 self.incompatibility_mode = v.into();
4353 self
4354 }
4355}
4356
4357impl wkt::message::Message for ShipmentTypeIncompatibility {
4358 fn typename() -> &'static str {
4359 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeIncompatibility"
4360 }
4361}
4362
4363/// Defines additional types related to [ShipmentTypeIncompatibility].
4364pub mod shipment_type_incompatibility {
4365 #[allow(unused_imports)]
4366 use super::*;
4367
4368 /// Modes defining how the appearance of incompatible shipments are restricted
4369 /// on the same route.
4370 ///
4371 /// # Working with unknown values
4372 ///
4373 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4374 /// additional enum variants at any time. Adding new variants is not considered
4375 /// a breaking change. Applications should write their code in anticipation of:
4376 ///
4377 /// - New values appearing in future releases of the client library, **and**
4378 /// - New values received dynamically, without application changes.
4379 ///
4380 /// Please consult the [Working with enums] section in the user guide for some
4381 /// guidelines.
4382 ///
4383 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4384 #[derive(Clone, Debug, PartialEq)]
4385 #[non_exhaustive]
4386 pub enum IncompatibilityMode {
4387 /// Unspecified incompatibility mode. This value should never be used.
4388 Unspecified,
4389 /// In this mode, two shipments with incompatible types can never share the
4390 /// same vehicle.
4391 NotPerformedBySameVehicle,
4392 /// For two shipments with incompatible types with the
4393 /// `NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY` incompatibility mode:
4394 ///
4395 /// * If both are pickups only (no deliveries) or deliveries only (no
4396 /// pickups), they cannot share the same vehicle at all.
4397 /// * If one of the shipments has a delivery and the other a pickup, the two
4398 /// shipments can share the same vehicle iff the former shipment is
4399 /// delivered before the latter is picked up.
4400 NotInSameVehicleSimultaneously,
4401 /// If set, the enum was initialized with an unknown value.
4402 ///
4403 /// Applications can examine the value using [IncompatibilityMode::value] or
4404 /// [IncompatibilityMode::name].
4405 UnknownValue(incompatibility_mode::UnknownValue),
4406 }
4407
4408 #[doc(hidden)]
4409 pub mod incompatibility_mode {
4410 #[allow(unused_imports)]
4411 use super::*;
4412 #[derive(Clone, Debug, PartialEq)]
4413 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4414 }
4415
4416 impl IncompatibilityMode {
4417 /// Gets the enum value.
4418 ///
4419 /// Returns `None` if the enum contains an unknown value deserialized from
4420 /// the string representation of enums.
4421 pub fn value(&self) -> std::option::Option<i32> {
4422 match self {
4423 Self::Unspecified => std::option::Option::Some(0),
4424 Self::NotPerformedBySameVehicle => std::option::Option::Some(1),
4425 Self::NotInSameVehicleSimultaneously => std::option::Option::Some(2),
4426 Self::UnknownValue(u) => u.0.value(),
4427 }
4428 }
4429
4430 /// Gets the enum value as a string.
4431 ///
4432 /// Returns `None` if the enum contains an unknown value deserialized from
4433 /// the integer representation of enums.
4434 pub fn name(&self) -> std::option::Option<&str> {
4435 match self {
4436 Self::Unspecified => std::option::Option::Some("INCOMPATIBILITY_MODE_UNSPECIFIED"),
4437 Self::NotPerformedBySameVehicle => {
4438 std::option::Option::Some("NOT_PERFORMED_BY_SAME_VEHICLE")
4439 }
4440 Self::NotInSameVehicleSimultaneously => {
4441 std::option::Option::Some("NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY")
4442 }
4443 Self::UnknownValue(u) => u.0.name(),
4444 }
4445 }
4446 }
4447
4448 impl std::default::Default for IncompatibilityMode {
4449 fn default() -> Self {
4450 use std::convert::From;
4451 Self::from(0)
4452 }
4453 }
4454
4455 impl std::fmt::Display for IncompatibilityMode {
4456 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4457 wkt::internal::display_enum(f, self.name(), self.value())
4458 }
4459 }
4460
4461 impl std::convert::From<i32> for IncompatibilityMode {
4462 fn from(value: i32) -> Self {
4463 match value {
4464 0 => Self::Unspecified,
4465 1 => Self::NotPerformedBySameVehicle,
4466 2 => Self::NotInSameVehicleSimultaneously,
4467 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4468 wkt::internal::UnknownEnumValue::Integer(value),
4469 )),
4470 }
4471 }
4472 }
4473
4474 impl std::convert::From<&str> for IncompatibilityMode {
4475 fn from(value: &str) -> Self {
4476 use std::string::ToString;
4477 match value {
4478 "INCOMPATIBILITY_MODE_UNSPECIFIED" => Self::Unspecified,
4479 "NOT_PERFORMED_BY_SAME_VEHICLE" => Self::NotPerformedBySameVehicle,
4480 "NOT_IN_SAME_VEHICLE_SIMULTANEOUSLY" => Self::NotInSameVehicleSimultaneously,
4481 _ => Self::UnknownValue(incompatibility_mode::UnknownValue(
4482 wkt::internal::UnknownEnumValue::String(value.to_string()),
4483 )),
4484 }
4485 }
4486 }
4487
4488 impl serde::ser::Serialize for IncompatibilityMode {
4489 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4490 where
4491 S: serde::Serializer,
4492 {
4493 match self {
4494 Self::Unspecified => serializer.serialize_i32(0),
4495 Self::NotPerformedBySameVehicle => serializer.serialize_i32(1),
4496 Self::NotInSameVehicleSimultaneously => serializer.serialize_i32(2),
4497 Self::UnknownValue(u) => u.0.serialize(serializer),
4498 }
4499 }
4500 }
4501
4502 impl<'de> serde::de::Deserialize<'de> for IncompatibilityMode {
4503 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4504 where
4505 D: serde::Deserializer<'de>,
4506 {
4507 deserializer.deserialize_any(wkt::internal::EnumVisitor::<IncompatibilityMode>::new(
4508 ".google.cloud.optimization.v1.ShipmentTypeIncompatibility.IncompatibilityMode",
4509 ))
4510 }
4511 }
4512}
4513
4514/// Specifies requirements between shipments based on their shipment_type.
4515/// The specifics of the requirement are defined by the requirement mode.
4516#[derive(Clone, Default, PartialEq)]
4517#[non_exhaustive]
4518pub struct ShipmentTypeRequirement {
4519 /// List of alternative shipment types required by the
4520 /// `dependent_shipment_types`.
4521 pub required_shipment_type_alternatives: std::vec::Vec<std::string::String>,
4522
4523 /// All shipments with a type in the `dependent_shipment_types` field require
4524 /// at least one shipment of type `required_shipment_type_alternatives` to be
4525 /// visited on the same route.
4526 ///
4527 /// NOTE: Chains of requirements such that a `shipment_type` depends on itself
4528 /// are not allowed.
4529 pub dependent_shipment_types: std::vec::Vec<std::string::String>,
4530
4531 /// Mode applied to the requirement.
4532 pub requirement_mode: crate::model::shipment_type_requirement::RequirementMode,
4533
4534 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4535}
4536
4537impl ShipmentTypeRequirement {
4538 pub fn new() -> Self {
4539 std::default::Default::default()
4540 }
4541
4542 /// Sets the value of [required_shipment_type_alternatives][crate::model::ShipmentTypeRequirement::required_shipment_type_alternatives].
4543 ///
4544 /// # Example
4545 /// ```ignore,no_run
4546 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4547 /// let x = ShipmentTypeRequirement::new().set_required_shipment_type_alternatives(["a", "b", "c"]);
4548 /// ```
4549 pub fn set_required_shipment_type_alternatives<T, V>(mut self, v: T) -> Self
4550 where
4551 T: std::iter::IntoIterator<Item = V>,
4552 V: std::convert::Into<std::string::String>,
4553 {
4554 use std::iter::Iterator;
4555 self.required_shipment_type_alternatives = v.into_iter().map(|i| i.into()).collect();
4556 self
4557 }
4558
4559 /// Sets the value of [dependent_shipment_types][crate::model::ShipmentTypeRequirement::dependent_shipment_types].
4560 ///
4561 /// # Example
4562 /// ```ignore,no_run
4563 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4564 /// let x = ShipmentTypeRequirement::new().set_dependent_shipment_types(["a", "b", "c"]);
4565 /// ```
4566 pub fn set_dependent_shipment_types<T, V>(mut self, v: T) -> Self
4567 where
4568 T: std::iter::IntoIterator<Item = V>,
4569 V: std::convert::Into<std::string::String>,
4570 {
4571 use std::iter::Iterator;
4572 self.dependent_shipment_types = v.into_iter().map(|i| i.into()).collect();
4573 self
4574 }
4575
4576 /// Sets the value of [requirement_mode][crate::model::ShipmentTypeRequirement::requirement_mode].
4577 ///
4578 /// # Example
4579 /// ```ignore,no_run
4580 /// # use google_cloud_optimization_v1::model::ShipmentTypeRequirement;
4581 /// use google_cloud_optimization_v1::model::shipment_type_requirement::RequirementMode;
4582 /// let x0 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::PerformedBySameVehicle);
4583 /// let x1 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtPickupTime);
4584 /// let x2 = ShipmentTypeRequirement::new().set_requirement_mode(RequirementMode::InSameVehicleAtDeliveryTime);
4585 /// ```
4586 pub fn set_requirement_mode<
4587 T: std::convert::Into<crate::model::shipment_type_requirement::RequirementMode>,
4588 >(
4589 mut self,
4590 v: T,
4591 ) -> Self {
4592 self.requirement_mode = v.into();
4593 self
4594 }
4595}
4596
4597impl wkt::message::Message for ShipmentTypeRequirement {
4598 fn typename() -> &'static str {
4599 "type.googleapis.com/google.cloud.optimization.v1.ShipmentTypeRequirement"
4600 }
4601}
4602
4603/// Defines additional types related to [ShipmentTypeRequirement].
4604pub mod shipment_type_requirement {
4605 #[allow(unused_imports)]
4606 use super::*;
4607
4608 /// Modes defining the appearance of dependent shipments on a route.
4609 ///
4610 /// # Working with unknown values
4611 ///
4612 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4613 /// additional enum variants at any time. Adding new variants is not considered
4614 /// a breaking change. Applications should write their code in anticipation of:
4615 ///
4616 /// - New values appearing in future releases of the client library, **and**
4617 /// - New values received dynamically, without application changes.
4618 ///
4619 /// Please consult the [Working with enums] section in the user guide for some
4620 /// guidelines.
4621 ///
4622 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4623 #[derive(Clone, Debug, PartialEq)]
4624 #[non_exhaustive]
4625 pub enum RequirementMode {
4626 /// Unspecified requirement mode. This value should never be used.
4627 Unspecified,
4628 /// In this mode, all "dependent" shipments must share the same vehicle as at
4629 /// least one of their "required" shipments.
4630 PerformedBySameVehicle,
4631 /// With the `IN_SAME_VEHICLE_AT_PICKUP_TIME` mode, all "dependent"
4632 /// shipments need to have at least one "required" shipment on their vehicle
4633 /// at the time of their pickup.
4634 ///
4635 /// A "dependent" shipment pickup must therefore have either:
4636 ///
4637 /// * A delivery-only "required" shipment delivered on the route after, or
4638 /// * A "required" shipment picked up on the route before it, and if the
4639 /// "required" shipment has a delivery, this delivery must be performed
4640 /// after the "dependent" shipment's pickup.
4641 InSameVehicleAtPickupTime,
4642 /// Same as before, except the "dependent" shipments need to have a
4643 /// "required" shipment on their vehicle at the time of their *delivery*.
4644 InSameVehicleAtDeliveryTime,
4645 /// If set, the enum was initialized with an unknown value.
4646 ///
4647 /// Applications can examine the value using [RequirementMode::value] or
4648 /// [RequirementMode::name].
4649 UnknownValue(requirement_mode::UnknownValue),
4650 }
4651
4652 #[doc(hidden)]
4653 pub mod requirement_mode {
4654 #[allow(unused_imports)]
4655 use super::*;
4656 #[derive(Clone, Debug, PartialEq)]
4657 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4658 }
4659
4660 impl RequirementMode {
4661 /// Gets the enum value.
4662 ///
4663 /// Returns `None` if the enum contains an unknown value deserialized from
4664 /// the string representation of enums.
4665 pub fn value(&self) -> std::option::Option<i32> {
4666 match self {
4667 Self::Unspecified => std::option::Option::Some(0),
4668 Self::PerformedBySameVehicle => std::option::Option::Some(1),
4669 Self::InSameVehicleAtPickupTime => std::option::Option::Some(2),
4670 Self::InSameVehicleAtDeliveryTime => std::option::Option::Some(3),
4671 Self::UnknownValue(u) => u.0.value(),
4672 }
4673 }
4674
4675 /// Gets the enum value as a string.
4676 ///
4677 /// Returns `None` if the enum contains an unknown value deserialized from
4678 /// the integer representation of enums.
4679 pub fn name(&self) -> std::option::Option<&str> {
4680 match self {
4681 Self::Unspecified => std::option::Option::Some("REQUIREMENT_MODE_UNSPECIFIED"),
4682 Self::PerformedBySameVehicle => {
4683 std::option::Option::Some("PERFORMED_BY_SAME_VEHICLE")
4684 }
4685 Self::InSameVehicleAtPickupTime => {
4686 std::option::Option::Some("IN_SAME_VEHICLE_AT_PICKUP_TIME")
4687 }
4688 Self::InSameVehicleAtDeliveryTime => {
4689 std::option::Option::Some("IN_SAME_VEHICLE_AT_DELIVERY_TIME")
4690 }
4691 Self::UnknownValue(u) => u.0.name(),
4692 }
4693 }
4694 }
4695
4696 impl std::default::Default for RequirementMode {
4697 fn default() -> Self {
4698 use std::convert::From;
4699 Self::from(0)
4700 }
4701 }
4702
4703 impl std::fmt::Display for RequirementMode {
4704 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4705 wkt::internal::display_enum(f, self.name(), self.value())
4706 }
4707 }
4708
4709 impl std::convert::From<i32> for RequirementMode {
4710 fn from(value: i32) -> Self {
4711 match value {
4712 0 => Self::Unspecified,
4713 1 => Self::PerformedBySameVehicle,
4714 2 => Self::InSameVehicleAtPickupTime,
4715 3 => Self::InSameVehicleAtDeliveryTime,
4716 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4717 wkt::internal::UnknownEnumValue::Integer(value),
4718 )),
4719 }
4720 }
4721 }
4722
4723 impl std::convert::From<&str> for RequirementMode {
4724 fn from(value: &str) -> Self {
4725 use std::string::ToString;
4726 match value {
4727 "REQUIREMENT_MODE_UNSPECIFIED" => Self::Unspecified,
4728 "PERFORMED_BY_SAME_VEHICLE" => Self::PerformedBySameVehicle,
4729 "IN_SAME_VEHICLE_AT_PICKUP_TIME" => Self::InSameVehicleAtPickupTime,
4730 "IN_SAME_VEHICLE_AT_DELIVERY_TIME" => Self::InSameVehicleAtDeliveryTime,
4731 _ => Self::UnknownValue(requirement_mode::UnknownValue(
4732 wkt::internal::UnknownEnumValue::String(value.to_string()),
4733 )),
4734 }
4735 }
4736 }
4737
4738 impl serde::ser::Serialize for RequirementMode {
4739 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4740 where
4741 S: serde::Serializer,
4742 {
4743 match self {
4744 Self::Unspecified => serializer.serialize_i32(0),
4745 Self::PerformedBySameVehicle => serializer.serialize_i32(1),
4746 Self::InSameVehicleAtPickupTime => serializer.serialize_i32(2),
4747 Self::InSameVehicleAtDeliveryTime => serializer.serialize_i32(3),
4748 Self::UnknownValue(u) => u.0.serialize(serializer),
4749 }
4750 }
4751 }
4752
4753 impl<'de> serde::de::Deserialize<'de> for RequirementMode {
4754 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4755 where
4756 D: serde::Deserializer<'de>,
4757 {
4758 deserializer.deserialize_any(wkt::internal::EnumVisitor::<RequirementMode>::new(
4759 ".google.cloud.optimization.v1.ShipmentTypeRequirement.RequirementMode",
4760 ))
4761 }
4762 }
4763}
4764
4765/// Encapsulates a set of optional conditions to satisfy when calculating
4766/// vehicle routes. This is similar to `RouteModifiers` in the Google Maps
4767/// Platform API; see:
4768/// <https://developers.google.com/maps/documentation/routes/reference/rest/v2/RouteModifiers>.
4769#[derive(Clone, Default, PartialEq)]
4770#[non_exhaustive]
4771pub struct RouteModifiers {
4772 /// Specifies whether to avoid toll roads where reasonable. Preference will be
4773 /// given to routes not containing toll roads. Applies only to motorized travel
4774 /// modes.
4775 pub avoid_tolls: bool,
4776
4777 /// Specifies whether to avoid highways where reasonable. Preference will be
4778 /// given to routes not containing highways. Applies only to motorized travel
4779 /// modes.
4780 pub avoid_highways: bool,
4781
4782 /// Specifies whether to avoid ferries where reasonable. Preference will be
4783 /// given to routes not containing travel by ferries. Applies only to motorized
4784 /// travel modes.
4785 pub avoid_ferries: bool,
4786
4787 /// Optional. Specifies whether to avoid navigating indoors where reasonable.
4788 /// Preference will be given to routes not containing indoor navigation.
4789 /// Applies only to the `WALKING` travel mode.
4790 pub avoid_indoor: bool,
4791
4792 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4793}
4794
4795impl RouteModifiers {
4796 pub fn new() -> Self {
4797 std::default::Default::default()
4798 }
4799
4800 /// Sets the value of [avoid_tolls][crate::model::RouteModifiers::avoid_tolls].
4801 ///
4802 /// # Example
4803 /// ```ignore,no_run
4804 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4805 /// let x = RouteModifiers::new().set_avoid_tolls(true);
4806 /// ```
4807 pub fn set_avoid_tolls<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4808 self.avoid_tolls = v.into();
4809 self
4810 }
4811
4812 /// Sets the value of [avoid_highways][crate::model::RouteModifiers::avoid_highways].
4813 ///
4814 /// # Example
4815 /// ```ignore,no_run
4816 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4817 /// let x = RouteModifiers::new().set_avoid_highways(true);
4818 /// ```
4819 pub fn set_avoid_highways<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4820 self.avoid_highways = v.into();
4821 self
4822 }
4823
4824 /// Sets the value of [avoid_ferries][crate::model::RouteModifiers::avoid_ferries].
4825 ///
4826 /// # Example
4827 /// ```ignore,no_run
4828 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4829 /// let x = RouteModifiers::new().set_avoid_ferries(true);
4830 /// ```
4831 pub fn set_avoid_ferries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4832 self.avoid_ferries = v.into();
4833 self
4834 }
4835
4836 /// Sets the value of [avoid_indoor][crate::model::RouteModifiers::avoid_indoor].
4837 ///
4838 /// # Example
4839 /// ```ignore,no_run
4840 /// # use google_cloud_optimization_v1::model::RouteModifiers;
4841 /// let x = RouteModifiers::new().set_avoid_indoor(true);
4842 /// ```
4843 pub fn set_avoid_indoor<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4844 self.avoid_indoor = v.into();
4845 self
4846 }
4847}
4848
4849impl wkt::message::Message for RouteModifiers {
4850 fn typename() -> &'static str {
4851 "type.googleapis.com/google.cloud.optimization.v1.RouteModifiers"
4852 }
4853}
4854
4855/// Models a vehicle in a shipment problem. Solving a shipment problem will
4856/// build a route starting from `start_location` and ending at `end_location`
4857/// for this vehicle. A route is a sequence of visits (see `ShipmentRoute`).
4858#[derive(Clone, Default, PartialEq)]
4859#[non_exhaustive]
4860pub struct Vehicle {
4861 /// The travel mode which affects the roads usable by the vehicle and its
4862 /// speed. See also `travel_duration_multiple`.
4863 pub travel_mode: crate::model::vehicle::TravelMode,
4864
4865 /// Optional. A set of conditions to satisfy that affect the way routes are
4866 /// calculated for the given vehicle.
4867 pub route_modifiers: std::option::Option<crate::model::RouteModifiers>,
4868
4869 /// Geographic location where the vehicle starts before picking up any
4870 /// shipments. If not specified, the vehicle starts at its first pickup.
4871 /// If the shipment model has duration and distance matrices, `start_location`
4872 /// must not be specified.
4873 pub start_location: std::option::Option<google_cloud_type::model::LatLng>,
4874
4875 /// Waypoint representing a geographic location where the vehicle starts before
4876 /// picking up any shipments. If neither `start_waypoint` nor `start_location`
4877 /// is specified, the vehicle starts at its first pickup.
4878 /// If the shipment model has duration and distance matrices, `start_waypoint`
4879 /// must not be specified.
4880 pub start_waypoint: std::option::Option<crate::model::Waypoint>,
4881
4882 /// Geographic location where the vehicle ends after it has completed its last
4883 /// `VisitRequest`. If not specified the vehicle's `ShipmentRoute` ends
4884 /// immediately when it completes its last `VisitRequest`.
4885 /// If the shipment model has duration and distance matrices, `end_location`
4886 /// must not be specified.
4887 pub end_location: std::option::Option<google_cloud_type::model::LatLng>,
4888
4889 /// Waypoint representing a geographic location where the vehicle ends after
4890 /// it has completed its last `VisitRequest`. If neither `end_waypoint` nor
4891 /// `end_location` is specified, the vehicle's `ShipmentRoute` ends immediately
4892 /// when it completes its last `VisitRequest`.
4893 /// If the shipment model has duration and distance matrices, `end_waypoint`
4894 /// must not be specified.
4895 pub end_waypoint: std::option::Option<crate::model::Waypoint>,
4896
4897 /// Specifies tags attached to the start of the vehicle's route.
4898 ///
4899 /// Empty or duplicate strings are not allowed.
4900 pub start_tags: std::vec::Vec<std::string::String>,
4901
4902 /// Specifies tags attached to the end of the vehicle's route.
4903 ///
4904 /// Empty or duplicate strings are not allowed.
4905 pub end_tags: std::vec::Vec<std::string::String>,
4906
4907 /// Time windows during which the vehicle may depart its start location.
4908 /// They must be within the global time limits (see
4909 /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4910 /// fields). If unspecified, there is no limitation besides those global time
4911 /// limits.
4912 ///
4913 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4914 /// time window can overlap with or be adjacent to another, and they must be in
4915 /// chronological order.
4916 ///
4917 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4918 /// there is a single time window.
4919 ///
4920 /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4921 pub start_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4922
4923 /// Time windows during which the vehicle may arrive at its end location.
4924 /// They must be within the global time limits (see
4925 /// [ShipmentModel.global_*][google.cloud.optimization.v1.ShipmentModel.global_start_time]
4926 /// fields). If unspecified, there is no limitation besides those global time
4927 /// limits.
4928 ///
4929 /// Time windows belonging to the same repeated field must be disjoint, i.e. no
4930 /// time window can overlap with or be adjacent to another, and they must be in
4931 /// chronological order.
4932 ///
4933 /// `cost_per_hour_after_soft_end_time` and `soft_end_time` can only be set if
4934 /// there is a single time window.
4935 ///
4936 /// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
4937 pub end_time_windows: std::vec::Vec<crate::model::TimeWindow>,
4938
4939 /// Specifies a multiplicative factor that can be used to increase or decrease
4940 /// travel times of this vehicle. For example, setting this to 2.0 means
4941 /// that this vehicle is slower and has travel times that are twice what they
4942 /// are for standard vehicles. This multiple does not affect visit durations.
4943 /// It does affect cost if `cost_per_hour` or `cost_per_traveled_hour` are
4944 /// specified. This must be in the range [0.001, 1000.0]. If unset, the vehicle
4945 /// is standard, and this multiple is considered 1.0.
4946 ///
4947 /// WARNING: Travel times will be rounded to the nearest second after this
4948 /// multiple is applied but before performing any numerical operations, thus,
4949 /// a small multiple may result in a loss of precision.
4950 ///
4951 /// See also `extra_visit_duration_for_visit_type` below.
4952 pub travel_duration_multiple: std::option::Option<f64>,
4953
4954 /// Unloading policy enforced on the vehicle.
4955 pub unloading_policy: crate::model::vehicle::UnloadingPolicy,
4956
4957 /// Capacities of the vehicle (weight, volume, # of pallets for example).
4958 /// The keys in the map are the identifiers of the type of load, consistent
4959 /// with the keys of the
4960 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
4961 /// field. If a given key is absent from this map, the corresponding capacity
4962 /// is considered to be limitless.
4963 ///
4964 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
4965 pub load_limits:
4966 std::collections::HashMap<std::string::String, crate::model::vehicle::LoadLimit>,
4967
4968 /// Vehicle costs: all costs add up and must be in the same unit as
4969 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
4970 ///
4971 /// Cost per hour of the vehicle route. This cost is applied to the total time
4972 /// taken by the route, and includes travel time, waiting time, and visit time.
4973 /// Using `cost_per_hour` instead of just `cost_per_traveled_hour` may result
4974 /// in additional latency.
4975 ///
4976 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
4977 pub cost_per_hour: f64,
4978
4979 /// Cost per traveled hour of the vehicle route. This cost is applied only to
4980 /// travel time taken by the route (i.e., that reported in
4981 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]),
4982 /// and excludes waiting time and visit time.
4983 ///
4984 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
4985 pub cost_per_traveled_hour: f64,
4986
4987 /// Cost per kilometer of the vehicle route. This cost is applied to the
4988 /// distance reported in the
4989 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
4990 /// and does not apply to any distance implicitly traveled from the
4991 /// `arrival_location` to the `departure_location` of a single `VisitRequest`.
4992 ///
4993 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
4994 pub cost_per_kilometer: f64,
4995
4996 /// Fixed cost applied if this vehicle is used to handle a shipment.
4997 pub fixed_cost: f64,
4998
4999 /// This field only applies to vehicles when their route does not serve any
5000 /// shipments. It indicates if the vehicle should be considered as used or not
5001 /// in this case.
5002 ///
5003 /// If true, the vehicle goes from its start to its end location even if it
5004 /// doesn't serve any shipments, and time and distance costs resulting from its
5005 /// start --> end travel are taken into account.
5006 ///
5007 /// Otherwise, it doesn't travel from its start to its end location, and no
5008 /// `break_rule` or delay (from `TransitionAttributes`) are scheduled for this
5009 /// vehicle. In this case, the vehicle's `ShipmentRoute` doesn't contain any
5010 /// information except for the vehicle index and label.
5011 pub used_if_route_is_empty: bool,
5012
5013 /// Limit applied to the total duration of the vehicle's route. In a given
5014 /// `OptimizeToursResponse`, the route duration of a vehicle is the
5015 /// difference between its `vehicle_end_time` and `vehicle_start_time`.
5016 pub route_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5017
5018 /// Limit applied to the travel duration of the vehicle's route. In a given
5019 /// `OptimizeToursResponse`, the route travel duration is the sum of all its
5020 /// [transitions.travel_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration].
5021 ///
5022 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_duration]: crate::model::shipment_route::Transition::travel_duration
5023 pub travel_duration_limit: std::option::Option<crate::model::vehicle::DurationLimit>,
5024
5025 /// Limit applied to the total distance of the vehicle's route. In a given
5026 /// `OptimizeToursResponse`, the route distance is the sum of all its
5027 /// [transitions.travel_distance_meters][google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters].
5028 ///
5029 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.travel_distance_meters]: crate::model::shipment_route::Transition::travel_distance_meters
5030 pub route_distance_limit: std::option::Option<crate::model::DistanceLimit>,
5031
5032 /// Specifies a map from visit_types strings to durations. The duration is time
5033 /// in addition to
5034 /// [VisitRequest.duration][google.cloud.optimization.v1.Shipment.VisitRequest.duration]
5035 /// to be taken at visits with the specified `visit_types`. This extra visit
5036 /// duration adds cost if `cost_per_hour` is specified. Keys (i.e.
5037 /// `visit_types`) cannot be empty strings.
5038 ///
5039 /// If a visit request has multiple types, a duration will be added for each
5040 /// type in the map.
5041 ///
5042 /// [google.cloud.optimization.v1.Shipment.VisitRequest.duration]: crate::model::shipment::VisitRequest::duration
5043 pub extra_visit_duration_for_visit_type:
5044 std::collections::HashMap<std::string::String, wkt::Duration>,
5045
5046 /// Describes the break schedule to be enforced on this vehicle.
5047 /// If empty, no breaks will be scheduled for this vehicle.
5048 pub break_rule: std::option::Option<crate::model::BreakRule>,
5049
5050 /// Specifies a label for this vehicle. This label is reported in the response
5051 /// as the `vehicle_label` of the corresponding
5052 /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
5053 ///
5054 /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
5055 pub label: std::string::String,
5056
5057 /// If true, `used_if_route_is_empty` must be false, and this vehicle will
5058 /// remain unused.
5059 ///
5060 /// If a shipment is performed by an ignored vehicle in
5061 /// `injected_first_solution_routes`, it is skipped in the first solution but
5062 /// is free to be performed in the response.
5063 ///
5064 /// If a shipment is performed by an ignored vehicle in
5065 /// `injected_solution_constraint` and any related pickup/delivery is
5066 /// constrained to remain on the vehicle (i.e., not relaxed to level
5067 /// `RELAX_ALL_AFTER_THRESHOLD`), it is skipped in the response.
5068 /// If a shipment has a non-empty `allowed_vehicle_indices` field and all of
5069 /// the allowed vehicles are ignored, it is skipped in the response.
5070 pub ignore: bool,
5071
5072 /// Deprecated: No longer used.
5073 /// Indices in the `break_rule` field in the source
5074 /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel]. They
5075 /// correspond to break rules enforced on the vehicle.
5076 ///
5077 /// As of 2018/03, at most one rule index per vehicle can be specified.
5078 ///
5079 /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
5080 #[deprecated]
5081 pub break_rule_indices: std::vec::Vec<i32>,
5082
5083 /// Deprecated: Use
5084 /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits]
5085 /// instead.
5086 ///
5087 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5088 #[deprecated]
5089 pub capacities: std::vec::Vec<crate::model::CapacityQuantity>,
5090
5091 /// Deprecated: Use
5092 /// [Vehicle.LoadLimit.start_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]
5093 /// instead.
5094 ///
5095 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.start_load_interval]: crate::model::vehicle::LoadLimit::start_load_interval
5096 #[deprecated]
5097 pub start_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5098
5099 /// Deprecated: Use
5100 /// [Vehicle.LoadLimit.end_load_interval][google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]
5101 /// instead.
5102 ///
5103 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.end_load_interval]: crate::model::vehicle::LoadLimit::end_load_interval
5104 #[deprecated]
5105 pub end_load_intervals: std::vec::Vec<crate::model::CapacityQuantityInterval>,
5106
5107 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5108}
5109
5110impl Vehicle {
5111 pub fn new() -> Self {
5112 std::default::Default::default()
5113 }
5114
5115 /// Sets the value of [travel_mode][crate::model::Vehicle::travel_mode].
5116 ///
5117 /// # Example
5118 /// ```ignore,no_run
5119 /// # use google_cloud_optimization_v1::model::Vehicle;
5120 /// use google_cloud_optimization_v1::model::vehicle::TravelMode;
5121 /// let x0 = Vehicle::new().set_travel_mode(TravelMode::Driving);
5122 /// let x1 = Vehicle::new().set_travel_mode(TravelMode::Walking);
5123 /// ```
5124 pub fn set_travel_mode<T: std::convert::Into<crate::model::vehicle::TravelMode>>(
5125 mut self,
5126 v: T,
5127 ) -> Self {
5128 self.travel_mode = v.into();
5129 self
5130 }
5131
5132 /// Sets the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5133 ///
5134 /// # Example
5135 /// ```ignore,no_run
5136 /// # use google_cloud_optimization_v1::model::Vehicle;
5137 /// use google_cloud_optimization_v1::model::RouteModifiers;
5138 /// let x = Vehicle::new().set_route_modifiers(RouteModifiers::default()/* use setters */);
5139 /// ```
5140 pub fn set_route_modifiers<T>(mut self, v: T) -> Self
5141 where
5142 T: std::convert::Into<crate::model::RouteModifiers>,
5143 {
5144 self.route_modifiers = std::option::Option::Some(v.into());
5145 self
5146 }
5147
5148 /// Sets or clears the value of [route_modifiers][crate::model::Vehicle::route_modifiers].
5149 ///
5150 /// # Example
5151 /// ```ignore,no_run
5152 /// # use google_cloud_optimization_v1::model::Vehicle;
5153 /// use google_cloud_optimization_v1::model::RouteModifiers;
5154 /// let x = Vehicle::new().set_or_clear_route_modifiers(Some(RouteModifiers::default()/* use setters */));
5155 /// let x = Vehicle::new().set_or_clear_route_modifiers(None::<RouteModifiers>);
5156 /// ```
5157 pub fn set_or_clear_route_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
5158 where
5159 T: std::convert::Into<crate::model::RouteModifiers>,
5160 {
5161 self.route_modifiers = v.map(|x| x.into());
5162 self
5163 }
5164
5165 /// Sets the value of [start_location][crate::model::Vehicle::start_location].
5166 ///
5167 /// # Example
5168 /// ```ignore,no_run
5169 /// # use google_cloud_optimization_v1::model::Vehicle;
5170 /// use google_cloud_type::model::LatLng;
5171 /// let x = Vehicle::new().set_start_location(LatLng::default()/* use setters */);
5172 /// ```
5173 pub fn set_start_location<T>(mut self, v: T) -> Self
5174 where
5175 T: std::convert::Into<google_cloud_type::model::LatLng>,
5176 {
5177 self.start_location = std::option::Option::Some(v.into());
5178 self
5179 }
5180
5181 /// Sets or clears the value of [start_location][crate::model::Vehicle::start_location].
5182 ///
5183 /// # Example
5184 /// ```ignore,no_run
5185 /// # use google_cloud_optimization_v1::model::Vehicle;
5186 /// use google_cloud_type::model::LatLng;
5187 /// let x = Vehicle::new().set_or_clear_start_location(Some(LatLng::default()/* use setters */));
5188 /// let x = Vehicle::new().set_or_clear_start_location(None::<LatLng>);
5189 /// ```
5190 pub fn set_or_clear_start_location<T>(mut self, v: std::option::Option<T>) -> Self
5191 where
5192 T: std::convert::Into<google_cloud_type::model::LatLng>,
5193 {
5194 self.start_location = v.map(|x| x.into());
5195 self
5196 }
5197
5198 /// Sets the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5199 ///
5200 /// # Example
5201 /// ```ignore,no_run
5202 /// # use google_cloud_optimization_v1::model::Vehicle;
5203 /// use google_cloud_optimization_v1::model::Waypoint;
5204 /// let x = Vehicle::new().set_start_waypoint(Waypoint::default()/* use setters */);
5205 /// ```
5206 pub fn set_start_waypoint<T>(mut self, v: T) -> Self
5207 where
5208 T: std::convert::Into<crate::model::Waypoint>,
5209 {
5210 self.start_waypoint = std::option::Option::Some(v.into());
5211 self
5212 }
5213
5214 /// Sets or clears the value of [start_waypoint][crate::model::Vehicle::start_waypoint].
5215 ///
5216 /// # Example
5217 /// ```ignore,no_run
5218 /// # use google_cloud_optimization_v1::model::Vehicle;
5219 /// use google_cloud_optimization_v1::model::Waypoint;
5220 /// let x = Vehicle::new().set_or_clear_start_waypoint(Some(Waypoint::default()/* use setters */));
5221 /// let x = Vehicle::new().set_or_clear_start_waypoint(None::<Waypoint>);
5222 /// ```
5223 pub fn set_or_clear_start_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5224 where
5225 T: std::convert::Into<crate::model::Waypoint>,
5226 {
5227 self.start_waypoint = v.map(|x| x.into());
5228 self
5229 }
5230
5231 /// Sets the value of [end_location][crate::model::Vehicle::end_location].
5232 ///
5233 /// # Example
5234 /// ```ignore,no_run
5235 /// # use google_cloud_optimization_v1::model::Vehicle;
5236 /// use google_cloud_type::model::LatLng;
5237 /// let x = Vehicle::new().set_end_location(LatLng::default()/* use setters */);
5238 /// ```
5239 pub fn set_end_location<T>(mut self, v: T) -> Self
5240 where
5241 T: std::convert::Into<google_cloud_type::model::LatLng>,
5242 {
5243 self.end_location = std::option::Option::Some(v.into());
5244 self
5245 }
5246
5247 /// Sets or clears the value of [end_location][crate::model::Vehicle::end_location].
5248 ///
5249 /// # Example
5250 /// ```ignore,no_run
5251 /// # use google_cloud_optimization_v1::model::Vehicle;
5252 /// use google_cloud_type::model::LatLng;
5253 /// let x = Vehicle::new().set_or_clear_end_location(Some(LatLng::default()/* use setters */));
5254 /// let x = Vehicle::new().set_or_clear_end_location(None::<LatLng>);
5255 /// ```
5256 pub fn set_or_clear_end_location<T>(mut self, v: std::option::Option<T>) -> Self
5257 where
5258 T: std::convert::Into<google_cloud_type::model::LatLng>,
5259 {
5260 self.end_location = v.map(|x| x.into());
5261 self
5262 }
5263
5264 /// Sets the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5265 ///
5266 /// # Example
5267 /// ```ignore,no_run
5268 /// # use google_cloud_optimization_v1::model::Vehicle;
5269 /// use google_cloud_optimization_v1::model::Waypoint;
5270 /// let x = Vehicle::new().set_end_waypoint(Waypoint::default()/* use setters */);
5271 /// ```
5272 pub fn set_end_waypoint<T>(mut self, v: T) -> Self
5273 where
5274 T: std::convert::Into<crate::model::Waypoint>,
5275 {
5276 self.end_waypoint = std::option::Option::Some(v.into());
5277 self
5278 }
5279
5280 /// Sets or clears the value of [end_waypoint][crate::model::Vehicle::end_waypoint].
5281 ///
5282 /// # Example
5283 /// ```ignore,no_run
5284 /// # use google_cloud_optimization_v1::model::Vehicle;
5285 /// use google_cloud_optimization_v1::model::Waypoint;
5286 /// let x = Vehicle::new().set_or_clear_end_waypoint(Some(Waypoint::default()/* use setters */));
5287 /// let x = Vehicle::new().set_or_clear_end_waypoint(None::<Waypoint>);
5288 /// ```
5289 pub fn set_or_clear_end_waypoint<T>(mut self, v: std::option::Option<T>) -> Self
5290 where
5291 T: std::convert::Into<crate::model::Waypoint>,
5292 {
5293 self.end_waypoint = v.map(|x| x.into());
5294 self
5295 }
5296
5297 /// Sets the value of [start_tags][crate::model::Vehicle::start_tags].
5298 ///
5299 /// # Example
5300 /// ```ignore,no_run
5301 /// # use google_cloud_optimization_v1::model::Vehicle;
5302 /// let x = Vehicle::new().set_start_tags(["a", "b", "c"]);
5303 /// ```
5304 pub fn set_start_tags<T, V>(mut self, v: T) -> Self
5305 where
5306 T: std::iter::IntoIterator<Item = V>,
5307 V: std::convert::Into<std::string::String>,
5308 {
5309 use std::iter::Iterator;
5310 self.start_tags = v.into_iter().map(|i| i.into()).collect();
5311 self
5312 }
5313
5314 /// Sets the value of [end_tags][crate::model::Vehicle::end_tags].
5315 ///
5316 /// # Example
5317 /// ```ignore,no_run
5318 /// # use google_cloud_optimization_v1::model::Vehicle;
5319 /// let x = Vehicle::new().set_end_tags(["a", "b", "c"]);
5320 /// ```
5321 pub fn set_end_tags<T, V>(mut self, v: T) -> Self
5322 where
5323 T: std::iter::IntoIterator<Item = V>,
5324 V: std::convert::Into<std::string::String>,
5325 {
5326 use std::iter::Iterator;
5327 self.end_tags = v.into_iter().map(|i| i.into()).collect();
5328 self
5329 }
5330
5331 /// Sets the value of [start_time_windows][crate::model::Vehicle::start_time_windows].
5332 ///
5333 /// # Example
5334 /// ```ignore,no_run
5335 /// # use google_cloud_optimization_v1::model::Vehicle;
5336 /// use google_cloud_optimization_v1::model::TimeWindow;
5337 /// let x = Vehicle::new()
5338 /// .set_start_time_windows([
5339 /// TimeWindow::default()/* use setters */,
5340 /// TimeWindow::default()/* use (different) setters */,
5341 /// ]);
5342 /// ```
5343 pub fn set_start_time_windows<T, V>(mut self, v: T) -> Self
5344 where
5345 T: std::iter::IntoIterator<Item = V>,
5346 V: std::convert::Into<crate::model::TimeWindow>,
5347 {
5348 use std::iter::Iterator;
5349 self.start_time_windows = v.into_iter().map(|i| i.into()).collect();
5350 self
5351 }
5352
5353 /// Sets the value of [end_time_windows][crate::model::Vehicle::end_time_windows].
5354 ///
5355 /// # Example
5356 /// ```ignore,no_run
5357 /// # use google_cloud_optimization_v1::model::Vehicle;
5358 /// use google_cloud_optimization_v1::model::TimeWindow;
5359 /// let x = Vehicle::new()
5360 /// .set_end_time_windows([
5361 /// TimeWindow::default()/* use setters */,
5362 /// TimeWindow::default()/* use (different) setters */,
5363 /// ]);
5364 /// ```
5365 pub fn set_end_time_windows<T, V>(mut self, v: T) -> Self
5366 where
5367 T: std::iter::IntoIterator<Item = V>,
5368 V: std::convert::Into<crate::model::TimeWindow>,
5369 {
5370 use std::iter::Iterator;
5371 self.end_time_windows = v.into_iter().map(|i| i.into()).collect();
5372 self
5373 }
5374
5375 /// Sets the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5376 ///
5377 /// # Example
5378 /// ```ignore,no_run
5379 /// # use google_cloud_optimization_v1::model::Vehicle;
5380 /// let x = Vehicle::new().set_travel_duration_multiple(42.0);
5381 /// ```
5382 pub fn set_travel_duration_multiple<T>(mut self, v: T) -> Self
5383 where
5384 T: std::convert::Into<f64>,
5385 {
5386 self.travel_duration_multiple = std::option::Option::Some(v.into());
5387 self
5388 }
5389
5390 /// Sets or clears the value of [travel_duration_multiple][crate::model::Vehicle::travel_duration_multiple].
5391 ///
5392 /// # Example
5393 /// ```ignore,no_run
5394 /// # use google_cloud_optimization_v1::model::Vehicle;
5395 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(Some(42.0));
5396 /// let x = Vehicle::new().set_or_clear_travel_duration_multiple(None::<f32>);
5397 /// ```
5398 pub fn set_or_clear_travel_duration_multiple<T>(mut self, v: std::option::Option<T>) -> Self
5399 where
5400 T: std::convert::Into<f64>,
5401 {
5402 self.travel_duration_multiple = v.map(|x| x.into());
5403 self
5404 }
5405
5406 /// Sets the value of [unloading_policy][crate::model::Vehicle::unloading_policy].
5407 ///
5408 /// # Example
5409 /// ```ignore,no_run
5410 /// # use google_cloud_optimization_v1::model::Vehicle;
5411 /// use google_cloud_optimization_v1::model::vehicle::UnloadingPolicy;
5412 /// let x0 = Vehicle::new().set_unloading_policy(UnloadingPolicy::LastInFirstOut);
5413 /// let x1 = Vehicle::new().set_unloading_policy(UnloadingPolicy::FirstInFirstOut);
5414 /// ```
5415 pub fn set_unloading_policy<T: std::convert::Into<crate::model::vehicle::UnloadingPolicy>>(
5416 mut self,
5417 v: T,
5418 ) -> Self {
5419 self.unloading_policy = v.into();
5420 self
5421 }
5422
5423 /// Sets the value of [load_limits][crate::model::Vehicle::load_limits].
5424 ///
5425 /// # Example
5426 /// ```ignore,no_run
5427 /// # use google_cloud_optimization_v1::model::Vehicle;
5428 /// use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5429 /// let x = Vehicle::new().set_load_limits([
5430 /// ("key0", LoadLimit::default()/* use setters */),
5431 /// ("key1", LoadLimit::default()/* use (different) setters */),
5432 /// ]);
5433 /// ```
5434 pub fn set_load_limits<T, K, V>(mut self, v: T) -> Self
5435 where
5436 T: std::iter::IntoIterator<Item = (K, V)>,
5437 K: std::convert::Into<std::string::String>,
5438 V: std::convert::Into<crate::model::vehicle::LoadLimit>,
5439 {
5440 use std::iter::Iterator;
5441 self.load_limits = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5442 self
5443 }
5444
5445 /// Sets the value of [cost_per_hour][crate::model::Vehicle::cost_per_hour].
5446 ///
5447 /// # Example
5448 /// ```ignore,no_run
5449 /// # use google_cloud_optimization_v1::model::Vehicle;
5450 /// let x = Vehicle::new().set_cost_per_hour(42.0);
5451 /// ```
5452 pub fn set_cost_per_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5453 self.cost_per_hour = v.into();
5454 self
5455 }
5456
5457 /// Sets the value of [cost_per_traveled_hour][crate::model::Vehicle::cost_per_traveled_hour].
5458 ///
5459 /// # Example
5460 /// ```ignore,no_run
5461 /// # use google_cloud_optimization_v1::model::Vehicle;
5462 /// let x = Vehicle::new().set_cost_per_traveled_hour(42.0);
5463 /// ```
5464 pub fn set_cost_per_traveled_hour<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5465 self.cost_per_traveled_hour = v.into();
5466 self
5467 }
5468
5469 /// Sets the value of [cost_per_kilometer][crate::model::Vehicle::cost_per_kilometer].
5470 ///
5471 /// # Example
5472 /// ```ignore,no_run
5473 /// # use google_cloud_optimization_v1::model::Vehicle;
5474 /// let x = Vehicle::new().set_cost_per_kilometer(42.0);
5475 /// ```
5476 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5477 self.cost_per_kilometer = v.into();
5478 self
5479 }
5480
5481 /// Sets the value of [fixed_cost][crate::model::Vehicle::fixed_cost].
5482 ///
5483 /// # Example
5484 /// ```ignore,no_run
5485 /// # use google_cloud_optimization_v1::model::Vehicle;
5486 /// let x = Vehicle::new().set_fixed_cost(42.0);
5487 /// ```
5488 pub fn set_fixed_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
5489 self.fixed_cost = v.into();
5490 self
5491 }
5492
5493 /// Sets the value of [used_if_route_is_empty][crate::model::Vehicle::used_if_route_is_empty].
5494 ///
5495 /// # Example
5496 /// ```ignore,no_run
5497 /// # use google_cloud_optimization_v1::model::Vehicle;
5498 /// let x = Vehicle::new().set_used_if_route_is_empty(true);
5499 /// ```
5500 pub fn set_used_if_route_is_empty<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5501 self.used_if_route_is_empty = v.into();
5502 self
5503 }
5504
5505 /// Sets the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5506 ///
5507 /// # Example
5508 /// ```ignore,no_run
5509 /// # use google_cloud_optimization_v1::model::Vehicle;
5510 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5511 /// let x = Vehicle::new().set_route_duration_limit(DurationLimit::default()/* use setters */);
5512 /// ```
5513 pub fn set_route_duration_limit<T>(mut self, v: T) -> Self
5514 where
5515 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5516 {
5517 self.route_duration_limit = std::option::Option::Some(v.into());
5518 self
5519 }
5520
5521 /// Sets or clears the value of [route_duration_limit][crate::model::Vehicle::route_duration_limit].
5522 ///
5523 /// # Example
5524 /// ```ignore,no_run
5525 /// # use google_cloud_optimization_v1::model::Vehicle;
5526 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5527 /// let x = Vehicle::new().set_or_clear_route_duration_limit(Some(DurationLimit::default()/* use setters */));
5528 /// let x = Vehicle::new().set_or_clear_route_duration_limit(None::<DurationLimit>);
5529 /// ```
5530 pub fn set_or_clear_route_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5531 where
5532 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5533 {
5534 self.route_duration_limit = v.map(|x| x.into());
5535 self
5536 }
5537
5538 /// Sets the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5539 ///
5540 /// # Example
5541 /// ```ignore,no_run
5542 /// # use google_cloud_optimization_v1::model::Vehicle;
5543 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5544 /// let x = Vehicle::new().set_travel_duration_limit(DurationLimit::default()/* use setters */);
5545 /// ```
5546 pub fn set_travel_duration_limit<T>(mut self, v: T) -> Self
5547 where
5548 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5549 {
5550 self.travel_duration_limit = std::option::Option::Some(v.into());
5551 self
5552 }
5553
5554 /// Sets or clears the value of [travel_duration_limit][crate::model::Vehicle::travel_duration_limit].
5555 ///
5556 /// # Example
5557 /// ```ignore,no_run
5558 /// # use google_cloud_optimization_v1::model::Vehicle;
5559 /// use google_cloud_optimization_v1::model::vehicle::DurationLimit;
5560 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(Some(DurationLimit::default()/* use setters */));
5561 /// let x = Vehicle::new().set_or_clear_travel_duration_limit(None::<DurationLimit>);
5562 /// ```
5563 pub fn set_or_clear_travel_duration_limit<T>(mut self, v: std::option::Option<T>) -> Self
5564 where
5565 T: std::convert::Into<crate::model::vehicle::DurationLimit>,
5566 {
5567 self.travel_duration_limit = v.map(|x| x.into());
5568 self
5569 }
5570
5571 /// Sets the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5572 ///
5573 /// # Example
5574 /// ```ignore,no_run
5575 /// # use google_cloud_optimization_v1::model::Vehicle;
5576 /// use google_cloud_optimization_v1::model::DistanceLimit;
5577 /// let x = Vehicle::new().set_route_distance_limit(DistanceLimit::default()/* use setters */);
5578 /// ```
5579 pub fn set_route_distance_limit<T>(mut self, v: T) -> Self
5580 where
5581 T: std::convert::Into<crate::model::DistanceLimit>,
5582 {
5583 self.route_distance_limit = std::option::Option::Some(v.into());
5584 self
5585 }
5586
5587 /// Sets or clears the value of [route_distance_limit][crate::model::Vehicle::route_distance_limit].
5588 ///
5589 /// # Example
5590 /// ```ignore,no_run
5591 /// # use google_cloud_optimization_v1::model::Vehicle;
5592 /// use google_cloud_optimization_v1::model::DistanceLimit;
5593 /// let x = Vehicle::new().set_or_clear_route_distance_limit(Some(DistanceLimit::default()/* use setters */));
5594 /// let x = Vehicle::new().set_or_clear_route_distance_limit(None::<DistanceLimit>);
5595 /// ```
5596 pub fn set_or_clear_route_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
5597 where
5598 T: std::convert::Into<crate::model::DistanceLimit>,
5599 {
5600 self.route_distance_limit = v.map(|x| x.into());
5601 self
5602 }
5603
5604 /// Sets the value of [extra_visit_duration_for_visit_type][crate::model::Vehicle::extra_visit_duration_for_visit_type].
5605 ///
5606 /// # Example
5607 /// ```ignore,no_run
5608 /// # use google_cloud_optimization_v1::model::Vehicle;
5609 /// use wkt::Duration;
5610 /// let x = Vehicle::new().set_extra_visit_duration_for_visit_type([
5611 /// ("key0", Duration::default()/* use setters */),
5612 /// ("key1", Duration::default()/* use (different) setters */),
5613 /// ]);
5614 /// ```
5615 pub fn set_extra_visit_duration_for_visit_type<T, K, V>(mut self, v: T) -> Self
5616 where
5617 T: std::iter::IntoIterator<Item = (K, V)>,
5618 K: std::convert::Into<std::string::String>,
5619 V: std::convert::Into<wkt::Duration>,
5620 {
5621 use std::iter::Iterator;
5622 self.extra_visit_duration_for_visit_type =
5623 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5624 self
5625 }
5626
5627 /// Sets the value of [break_rule][crate::model::Vehicle::break_rule].
5628 ///
5629 /// # Example
5630 /// ```ignore,no_run
5631 /// # use google_cloud_optimization_v1::model::Vehicle;
5632 /// use google_cloud_optimization_v1::model::BreakRule;
5633 /// let x = Vehicle::new().set_break_rule(BreakRule::default()/* use setters */);
5634 /// ```
5635 pub fn set_break_rule<T>(mut self, v: T) -> Self
5636 where
5637 T: std::convert::Into<crate::model::BreakRule>,
5638 {
5639 self.break_rule = std::option::Option::Some(v.into());
5640 self
5641 }
5642
5643 /// Sets or clears the value of [break_rule][crate::model::Vehicle::break_rule].
5644 ///
5645 /// # Example
5646 /// ```ignore,no_run
5647 /// # use google_cloud_optimization_v1::model::Vehicle;
5648 /// use google_cloud_optimization_v1::model::BreakRule;
5649 /// let x = Vehicle::new().set_or_clear_break_rule(Some(BreakRule::default()/* use setters */));
5650 /// let x = Vehicle::new().set_or_clear_break_rule(None::<BreakRule>);
5651 /// ```
5652 pub fn set_or_clear_break_rule<T>(mut self, v: std::option::Option<T>) -> Self
5653 where
5654 T: std::convert::Into<crate::model::BreakRule>,
5655 {
5656 self.break_rule = v.map(|x| x.into());
5657 self
5658 }
5659
5660 /// Sets the value of [label][crate::model::Vehicle::label].
5661 ///
5662 /// # Example
5663 /// ```ignore,no_run
5664 /// # use google_cloud_optimization_v1::model::Vehicle;
5665 /// let x = Vehicle::new().set_label("example");
5666 /// ```
5667 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5668 self.label = v.into();
5669 self
5670 }
5671
5672 /// Sets the value of [ignore][crate::model::Vehicle::ignore].
5673 ///
5674 /// # Example
5675 /// ```ignore,no_run
5676 /// # use google_cloud_optimization_v1::model::Vehicle;
5677 /// let x = Vehicle::new().set_ignore(true);
5678 /// ```
5679 pub fn set_ignore<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5680 self.ignore = v.into();
5681 self
5682 }
5683
5684 /// Sets the value of [break_rule_indices][crate::model::Vehicle::break_rule_indices].
5685 ///
5686 /// # Example
5687 /// ```ignore,no_run
5688 /// # use google_cloud_optimization_v1::model::Vehicle;
5689 /// let x = Vehicle::new().set_break_rule_indices([1, 2, 3]);
5690 /// ```
5691 #[deprecated]
5692 pub fn set_break_rule_indices<T, V>(mut self, v: T) -> Self
5693 where
5694 T: std::iter::IntoIterator<Item = V>,
5695 V: std::convert::Into<i32>,
5696 {
5697 use std::iter::Iterator;
5698 self.break_rule_indices = v.into_iter().map(|i| i.into()).collect();
5699 self
5700 }
5701
5702 /// Sets the value of [capacities][crate::model::Vehicle::capacities].
5703 ///
5704 /// # Example
5705 /// ```ignore,no_run
5706 /// # use google_cloud_optimization_v1::model::Vehicle;
5707 /// use google_cloud_optimization_v1::model::CapacityQuantity;
5708 /// let x = Vehicle::new()
5709 /// .set_capacities([
5710 /// CapacityQuantity::default()/* use setters */,
5711 /// CapacityQuantity::default()/* use (different) setters */,
5712 /// ]);
5713 /// ```
5714 #[deprecated]
5715 pub fn set_capacities<T, V>(mut self, v: T) -> Self
5716 where
5717 T: std::iter::IntoIterator<Item = V>,
5718 V: std::convert::Into<crate::model::CapacityQuantity>,
5719 {
5720 use std::iter::Iterator;
5721 self.capacities = v.into_iter().map(|i| i.into()).collect();
5722 self
5723 }
5724
5725 /// Sets the value of [start_load_intervals][crate::model::Vehicle::start_load_intervals].
5726 ///
5727 /// # Example
5728 /// ```ignore,no_run
5729 /// # use google_cloud_optimization_v1::model::Vehicle;
5730 /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5731 /// let x = Vehicle::new()
5732 /// .set_start_load_intervals([
5733 /// CapacityQuantityInterval::default()/* use setters */,
5734 /// CapacityQuantityInterval::default()/* use (different) setters */,
5735 /// ]);
5736 /// ```
5737 #[deprecated]
5738 pub fn set_start_load_intervals<T, V>(mut self, v: T) -> Self
5739 where
5740 T: std::iter::IntoIterator<Item = V>,
5741 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5742 {
5743 use std::iter::Iterator;
5744 self.start_load_intervals = v.into_iter().map(|i| i.into()).collect();
5745 self
5746 }
5747
5748 /// Sets the value of [end_load_intervals][crate::model::Vehicle::end_load_intervals].
5749 ///
5750 /// # Example
5751 /// ```ignore,no_run
5752 /// # use google_cloud_optimization_v1::model::Vehicle;
5753 /// use google_cloud_optimization_v1::model::CapacityQuantityInterval;
5754 /// let x = Vehicle::new()
5755 /// .set_end_load_intervals([
5756 /// CapacityQuantityInterval::default()/* use setters */,
5757 /// CapacityQuantityInterval::default()/* use (different) setters */,
5758 /// ]);
5759 /// ```
5760 #[deprecated]
5761 pub fn set_end_load_intervals<T, V>(mut self, v: T) -> Self
5762 where
5763 T: std::iter::IntoIterator<Item = V>,
5764 V: std::convert::Into<crate::model::CapacityQuantityInterval>,
5765 {
5766 use std::iter::Iterator;
5767 self.end_load_intervals = v.into_iter().map(|i| i.into()).collect();
5768 self
5769 }
5770}
5771
5772impl wkt::message::Message for Vehicle {
5773 fn typename() -> &'static str {
5774 "type.googleapis.com/google.cloud.optimization.v1.Vehicle"
5775 }
5776}
5777
5778/// Defines additional types related to [Vehicle].
5779pub mod vehicle {
5780 #[allow(unused_imports)]
5781 use super::*;
5782
5783 /// Defines a load limit applying to a vehicle, e.g. "this truck may only
5784 /// carry up to 3500 kg". See
5785 /// [load_limits][google.cloud.optimization.v1.Vehicle.load_limits].
5786 ///
5787 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
5788 #[derive(Clone, Default, PartialEq)]
5789 #[non_exhaustive]
5790 pub struct LoadLimit {
5791 /// The maximum acceptable amount of load.
5792 pub max_load: std::option::Option<i64>,
5793
5794 /// A soft limit of the load. See
5795 /// [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max].
5796 ///
5797 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5798 pub soft_max_load: i64,
5799
5800 /// If the load ever exceeds
5801 /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]
5802 /// along this vehicle's route, the following cost penalty applies (only once
5803 /// per vehicle): (load -
5804 /// [soft_max_load][google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load])
5805 ///
5806 /// * [cost_per_unit_above_soft_max][google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]. All costs
5807 /// add up and must be in the same unit as
5808 /// [Shipment.penalty_cost][google.cloud.optimization.v1.Shipment.penalty_cost].
5809 ///
5810 /// [google.cloud.optimization.v1.Shipment.penalty_cost]: crate::model::Shipment::penalty_cost
5811 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.cost_per_unit_above_soft_max]: crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max
5812 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.soft_max_load]: crate::model::vehicle::LoadLimit::soft_max_load
5813 pub cost_per_unit_above_soft_max: f64,
5814
5815 /// The acceptable load interval of the vehicle at the start of the route.
5816 pub start_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5817
5818 /// The acceptable load interval of the vehicle at the end of the route.
5819 pub end_load_interval: std::option::Option<crate::model::vehicle::load_limit::Interval>,
5820
5821 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5822 }
5823
5824 impl LoadLimit {
5825 pub fn new() -> Self {
5826 std::default::Default::default()
5827 }
5828
5829 /// Sets the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5830 ///
5831 /// # Example
5832 /// ```ignore,no_run
5833 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5834 /// let x = LoadLimit::new().set_max_load(42);
5835 /// ```
5836 pub fn set_max_load<T>(mut self, v: T) -> Self
5837 where
5838 T: std::convert::Into<i64>,
5839 {
5840 self.max_load = std::option::Option::Some(v.into());
5841 self
5842 }
5843
5844 /// Sets or clears the value of [max_load][crate::model::vehicle::LoadLimit::max_load].
5845 ///
5846 /// # Example
5847 /// ```ignore,no_run
5848 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5849 /// let x = LoadLimit::new().set_or_clear_max_load(Some(42));
5850 /// let x = LoadLimit::new().set_or_clear_max_load(None::<i32>);
5851 /// ```
5852 pub fn set_or_clear_max_load<T>(mut self, v: std::option::Option<T>) -> Self
5853 where
5854 T: std::convert::Into<i64>,
5855 {
5856 self.max_load = v.map(|x| x.into());
5857 self
5858 }
5859
5860 /// Sets the value of [soft_max_load][crate::model::vehicle::LoadLimit::soft_max_load].
5861 ///
5862 /// # Example
5863 /// ```ignore,no_run
5864 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5865 /// let x = LoadLimit::new().set_soft_max_load(42);
5866 /// ```
5867 pub fn set_soft_max_load<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5868 self.soft_max_load = v.into();
5869 self
5870 }
5871
5872 /// Sets the value of [cost_per_unit_above_soft_max][crate::model::vehicle::LoadLimit::cost_per_unit_above_soft_max].
5873 ///
5874 /// # Example
5875 /// ```ignore,no_run
5876 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5877 /// let x = LoadLimit::new().set_cost_per_unit_above_soft_max(42.0);
5878 /// ```
5879 pub fn set_cost_per_unit_above_soft_max<T: std::convert::Into<f64>>(
5880 mut self,
5881 v: T,
5882 ) -> Self {
5883 self.cost_per_unit_above_soft_max = v.into();
5884 self
5885 }
5886
5887 /// Sets the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5888 ///
5889 /// # Example
5890 /// ```ignore,no_run
5891 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5892 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5893 /// let x = LoadLimit::new().set_start_load_interval(Interval::default()/* use setters */);
5894 /// ```
5895 pub fn set_start_load_interval<T>(mut self, v: T) -> Self
5896 where
5897 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5898 {
5899 self.start_load_interval = std::option::Option::Some(v.into());
5900 self
5901 }
5902
5903 /// Sets or clears the value of [start_load_interval][crate::model::vehicle::LoadLimit::start_load_interval].
5904 ///
5905 /// # Example
5906 /// ```ignore,no_run
5907 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5908 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5909 /// let x = LoadLimit::new().set_or_clear_start_load_interval(Some(Interval::default()/* use setters */));
5910 /// let x = LoadLimit::new().set_or_clear_start_load_interval(None::<Interval>);
5911 /// ```
5912 pub fn set_or_clear_start_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5913 where
5914 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5915 {
5916 self.start_load_interval = v.map(|x| x.into());
5917 self
5918 }
5919
5920 /// Sets the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5921 ///
5922 /// # Example
5923 /// ```ignore,no_run
5924 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5925 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5926 /// let x = LoadLimit::new().set_end_load_interval(Interval::default()/* use setters */);
5927 /// ```
5928 pub fn set_end_load_interval<T>(mut self, v: T) -> Self
5929 where
5930 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5931 {
5932 self.end_load_interval = std::option::Option::Some(v.into());
5933 self
5934 }
5935
5936 /// Sets or clears the value of [end_load_interval][crate::model::vehicle::LoadLimit::end_load_interval].
5937 ///
5938 /// # Example
5939 /// ```ignore,no_run
5940 /// # use google_cloud_optimization_v1::model::vehicle::LoadLimit;
5941 /// use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
5942 /// let x = LoadLimit::new().set_or_clear_end_load_interval(Some(Interval::default()/* use setters */));
5943 /// let x = LoadLimit::new().set_or_clear_end_load_interval(None::<Interval>);
5944 /// ```
5945 pub fn set_or_clear_end_load_interval<T>(mut self, v: std::option::Option<T>) -> Self
5946 where
5947 T: std::convert::Into<crate::model::vehicle::load_limit::Interval>,
5948 {
5949 self.end_load_interval = v.map(|x| x.into());
5950 self
5951 }
5952 }
5953
5954 impl wkt::message::Message for LoadLimit {
5955 fn typename() -> &'static str {
5956 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit"
5957 }
5958 }
5959
5960 /// Defines additional types related to [LoadLimit].
5961 pub mod load_limit {
5962 #[allow(unused_imports)]
5963 use super::*;
5964
5965 /// Interval of acceptable load amounts.
5966 #[derive(Clone, Default, PartialEq)]
5967 #[non_exhaustive]
5968 pub struct Interval {
5969 /// A minimum acceptable load. Must be ≥ 0.
5970 /// If they're both specified,
5971 /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
5972 /// be ≤
5973 /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
5974 ///
5975 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
5976 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
5977 pub min: i64,
5978
5979 /// A maximum acceptable load. Must be ≥ 0. If unspecified, the maximum
5980 /// load is unrestricted by this message.
5981 /// If they're both specified,
5982 /// [min][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min] must
5983 /// be ≤
5984 /// [max][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max].
5985 ///
5986 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.max]: crate::model::vehicle::load_limit::Interval::max
5987 /// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval.min]: crate::model::vehicle::load_limit::Interval::min
5988 pub max: std::option::Option<i64>,
5989
5990 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5991 }
5992
5993 impl Interval {
5994 pub fn new() -> Self {
5995 std::default::Default::default()
5996 }
5997
5998 /// Sets the value of [min][crate::model::vehicle::load_limit::Interval::min].
5999 ///
6000 /// # Example
6001 /// ```ignore,no_run
6002 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6003 /// let x = Interval::new().set_min(42);
6004 /// ```
6005 pub fn set_min<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6006 self.min = v.into();
6007 self
6008 }
6009
6010 /// Sets the value of [max][crate::model::vehicle::load_limit::Interval::max].
6011 ///
6012 /// # Example
6013 /// ```ignore,no_run
6014 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6015 /// let x = Interval::new().set_max(42);
6016 /// ```
6017 pub fn set_max<T>(mut self, v: T) -> Self
6018 where
6019 T: std::convert::Into<i64>,
6020 {
6021 self.max = std::option::Option::Some(v.into());
6022 self
6023 }
6024
6025 /// Sets or clears the value of [max][crate::model::vehicle::load_limit::Interval::max].
6026 ///
6027 /// # Example
6028 /// ```ignore,no_run
6029 /// # use google_cloud_optimization_v1::model::vehicle::load_limit::Interval;
6030 /// let x = Interval::new().set_or_clear_max(Some(42));
6031 /// let x = Interval::new().set_or_clear_max(None::<i32>);
6032 /// ```
6033 pub fn set_or_clear_max<T>(mut self, v: std::option::Option<T>) -> Self
6034 where
6035 T: std::convert::Into<i64>,
6036 {
6037 self.max = v.map(|x| x.into());
6038 self
6039 }
6040 }
6041
6042 impl wkt::message::Message for Interval {
6043 fn typename() -> &'static str {
6044 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.LoadLimit.Interval"
6045 }
6046 }
6047 }
6048
6049 /// A limit defining a maximum duration of the route of a vehicle. It can be
6050 /// either hard or soft.
6051 ///
6052 /// When a soft limit field is defined, both the soft max threshold and its
6053 /// associated cost must be defined together.
6054 #[derive(Clone, Default, PartialEq)]
6055 #[non_exhaustive]
6056 pub struct DurationLimit {
6057 /// A hard limit constraining the duration to be at most max_duration.
6058 pub max_duration: std::option::Option<wkt::Duration>,
6059
6060 /// A soft limit not enforcing a maximum duration limit, but when violated
6061 /// makes the route incur a cost. This cost adds up to other costs defined in
6062 /// the model, with the same unit.
6063 ///
6064 /// If defined, `soft_max_duration` must be nonnegative. If max_duration is
6065 /// also defined, `soft_max_duration` must be less than max_duration.
6066 pub soft_max_duration: std::option::Option<wkt::Duration>,
6067
6068 /// Cost per hour incurred if the `soft_max_duration` threshold is violated.
6069 /// The additional cost is 0 if the duration is under the threshold,
6070 /// otherwise the cost depends on the duration as follows:
6071 ///
6072 /// ```norust
6073 /// cost_per_hour_after_soft_max * (duration - soft_max_duration)
6074 /// ```
6075 ///
6076 /// The cost must be nonnegative.
6077 pub cost_per_hour_after_soft_max: std::option::Option<f64>,
6078
6079 /// A soft limit not enforcing a maximum duration limit, but when violated
6080 /// makes the route incur a cost, quadratic in the duration. This cost adds
6081 /// up to other costs defined in the model, with the same unit.
6082 ///
6083 /// If defined, `quadratic_soft_max_duration` must be nonnegative. If
6084 /// `max_duration` is also defined, `quadratic_soft_max_duration` must be
6085 /// less than `max_duration`, and the difference must be no larger than one
6086 /// day:
6087 ///
6088 /// `max_duration - quadratic_soft_max_duration <= 86400 seconds`
6089 pub quadratic_soft_max_duration: std::option::Option<wkt::Duration>,
6090
6091 /// Cost per square hour incurred if the
6092 /// `quadratic_soft_max_duration` threshold is violated.
6093 ///
6094 /// The additional cost is 0 if the duration is under the threshold,
6095 /// otherwise the cost depends on the duration as follows:
6096 ///
6097 /// ```norust
6098 /// cost_per_square_hour_after_quadratic_soft_max *
6099 /// (duration - quadratic_soft_max_duration)^2
6100 /// ```
6101 ///
6102 /// The cost must be nonnegative.
6103 pub cost_per_square_hour_after_quadratic_soft_max: std::option::Option<f64>,
6104
6105 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6106 }
6107
6108 impl DurationLimit {
6109 pub fn new() -> Self {
6110 std::default::Default::default()
6111 }
6112
6113 /// Sets the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6114 ///
6115 /// # Example
6116 /// ```ignore,no_run
6117 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6118 /// use wkt::Duration;
6119 /// let x = DurationLimit::new().set_max_duration(Duration::default()/* use setters */);
6120 /// ```
6121 pub fn set_max_duration<T>(mut self, v: T) -> Self
6122 where
6123 T: std::convert::Into<wkt::Duration>,
6124 {
6125 self.max_duration = std::option::Option::Some(v.into());
6126 self
6127 }
6128
6129 /// Sets or clears the value of [max_duration][crate::model::vehicle::DurationLimit::max_duration].
6130 ///
6131 /// # Example
6132 /// ```ignore,no_run
6133 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6134 /// use wkt::Duration;
6135 /// let x = DurationLimit::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
6136 /// let x = DurationLimit::new().set_or_clear_max_duration(None::<Duration>);
6137 /// ```
6138 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6139 where
6140 T: std::convert::Into<wkt::Duration>,
6141 {
6142 self.max_duration = v.map(|x| x.into());
6143 self
6144 }
6145
6146 /// Sets the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6147 ///
6148 /// # Example
6149 /// ```ignore,no_run
6150 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6151 /// use wkt::Duration;
6152 /// let x = DurationLimit::new().set_soft_max_duration(Duration::default()/* use setters */);
6153 /// ```
6154 pub fn set_soft_max_duration<T>(mut self, v: T) -> Self
6155 where
6156 T: std::convert::Into<wkt::Duration>,
6157 {
6158 self.soft_max_duration = std::option::Option::Some(v.into());
6159 self
6160 }
6161
6162 /// Sets or clears the value of [soft_max_duration][crate::model::vehicle::DurationLimit::soft_max_duration].
6163 ///
6164 /// # Example
6165 /// ```ignore,no_run
6166 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6167 /// use wkt::Duration;
6168 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(Some(Duration::default()/* use setters */));
6169 /// let x = DurationLimit::new().set_or_clear_soft_max_duration(None::<Duration>);
6170 /// ```
6171 pub fn set_or_clear_soft_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6172 where
6173 T: std::convert::Into<wkt::Duration>,
6174 {
6175 self.soft_max_duration = v.map(|x| x.into());
6176 self
6177 }
6178
6179 /// Sets the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6180 ///
6181 /// # Example
6182 /// ```ignore,no_run
6183 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6184 /// let x = DurationLimit::new().set_cost_per_hour_after_soft_max(42.0);
6185 /// ```
6186 pub fn set_cost_per_hour_after_soft_max<T>(mut self, v: T) -> Self
6187 where
6188 T: std::convert::Into<f64>,
6189 {
6190 self.cost_per_hour_after_soft_max = std::option::Option::Some(v.into());
6191 self
6192 }
6193
6194 /// Sets or clears the value of [cost_per_hour_after_soft_max][crate::model::vehicle::DurationLimit::cost_per_hour_after_soft_max].
6195 ///
6196 /// # Example
6197 /// ```ignore,no_run
6198 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6199 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(Some(42.0));
6200 /// let x = DurationLimit::new().set_or_clear_cost_per_hour_after_soft_max(None::<f32>);
6201 /// ```
6202 pub fn set_or_clear_cost_per_hour_after_soft_max<T>(
6203 mut self,
6204 v: std::option::Option<T>,
6205 ) -> Self
6206 where
6207 T: std::convert::Into<f64>,
6208 {
6209 self.cost_per_hour_after_soft_max = v.map(|x| x.into());
6210 self
6211 }
6212
6213 /// Sets the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6214 ///
6215 /// # Example
6216 /// ```ignore,no_run
6217 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6218 /// use wkt::Duration;
6219 /// let x = DurationLimit::new().set_quadratic_soft_max_duration(Duration::default()/* use setters */);
6220 /// ```
6221 pub fn set_quadratic_soft_max_duration<T>(mut self, v: T) -> Self
6222 where
6223 T: std::convert::Into<wkt::Duration>,
6224 {
6225 self.quadratic_soft_max_duration = std::option::Option::Some(v.into());
6226 self
6227 }
6228
6229 /// Sets or clears the value of [quadratic_soft_max_duration][crate::model::vehicle::DurationLimit::quadratic_soft_max_duration].
6230 ///
6231 /// # Example
6232 /// ```ignore,no_run
6233 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6234 /// use wkt::Duration;
6235 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(Some(Duration::default()/* use setters */));
6236 /// let x = DurationLimit::new().set_or_clear_quadratic_soft_max_duration(None::<Duration>);
6237 /// ```
6238 pub fn set_or_clear_quadratic_soft_max_duration<T>(
6239 mut self,
6240 v: std::option::Option<T>,
6241 ) -> Self
6242 where
6243 T: std::convert::Into<wkt::Duration>,
6244 {
6245 self.quadratic_soft_max_duration = v.map(|x| x.into());
6246 self
6247 }
6248
6249 /// Sets the value of [cost_per_square_hour_after_quadratic_soft_max][crate::model::vehicle::DurationLimit::cost_per_square_hour_after_quadratic_soft_max].
6250 ///
6251 /// # Example
6252 /// ```ignore,no_run
6253 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6254 /// let x = DurationLimit::new().set_cost_per_square_hour_after_quadratic_soft_max(42.0);
6255 /// ```
6256 pub fn set_cost_per_square_hour_after_quadratic_soft_max<T>(mut self, v: T) -> Self
6257 where
6258 T: std::convert::Into<f64>,
6259 {
6260 self.cost_per_square_hour_after_quadratic_soft_max =
6261 std::option::Option::Some(v.into());
6262 self
6263 }
6264
6265 /// 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].
6266 ///
6267 /// # Example
6268 /// ```ignore,no_run
6269 /// # use google_cloud_optimization_v1::model::vehicle::DurationLimit;
6270 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(Some(42.0));
6271 /// let x = DurationLimit::new().set_or_clear_cost_per_square_hour_after_quadratic_soft_max(None::<f32>);
6272 /// ```
6273 pub fn set_or_clear_cost_per_square_hour_after_quadratic_soft_max<T>(
6274 mut self,
6275 v: std::option::Option<T>,
6276 ) -> Self
6277 where
6278 T: std::convert::Into<f64>,
6279 {
6280 self.cost_per_square_hour_after_quadratic_soft_max = v.map(|x| x.into());
6281 self
6282 }
6283 }
6284
6285 impl wkt::message::Message for DurationLimit {
6286 fn typename() -> &'static str {
6287 "type.googleapis.com/google.cloud.optimization.v1.Vehicle.DurationLimit"
6288 }
6289 }
6290
6291 /// Travel modes which can be used by vehicles.
6292 ///
6293 /// These should be a subset of the Google Maps Platform Routes Preferred API
6294 /// travel modes, see:
6295 /// <https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode>.
6296 ///
6297 /// # Working with unknown values
6298 ///
6299 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6300 /// additional enum variants at any time. Adding new variants is not considered
6301 /// a breaking change. Applications should write their code in anticipation of:
6302 ///
6303 /// - New values appearing in future releases of the client library, **and**
6304 /// - New values received dynamically, without application changes.
6305 ///
6306 /// Please consult the [Working with enums] section in the user guide for some
6307 /// guidelines.
6308 ///
6309 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6310 #[derive(Clone, Debug, PartialEq)]
6311 #[non_exhaustive]
6312 pub enum TravelMode {
6313 /// Unspecified travel mode, equivalent to `DRIVING`.
6314 Unspecified,
6315 /// Travel mode corresponding to driving directions (car, ...).
6316 Driving,
6317 /// Travel mode corresponding to walking directions.
6318 Walking,
6319 /// If set, the enum was initialized with an unknown value.
6320 ///
6321 /// Applications can examine the value using [TravelMode::value] or
6322 /// [TravelMode::name].
6323 UnknownValue(travel_mode::UnknownValue),
6324 }
6325
6326 #[doc(hidden)]
6327 pub mod travel_mode {
6328 #[allow(unused_imports)]
6329 use super::*;
6330 #[derive(Clone, Debug, PartialEq)]
6331 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6332 }
6333
6334 impl TravelMode {
6335 /// Gets the enum value.
6336 ///
6337 /// Returns `None` if the enum contains an unknown value deserialized from
6338 /// the string representation of enums.
6339 pub fn value(&self) -> std::option::Option<i32> {
6340 match self {
6341 Self::Unspecified => std::option::Option::Some(0),
6342 Self::Driving => std::option::Option::Some(1),
6343 Self::Walking => std::option::Option::Some(2),
6344 Self::UnknownValue(u) => u.0.value(),
6345 }
6346 }
6347
6348 /// Gets the enum value as a string.
6349 ///
6350 /// Returns `None` if the enum contains an unknown value deserialized from
6351 /// the integer representation of enums.
6352 pub fn name(&self) -> std::option::Option<&str> {
6353 match self {
6354 Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
6355 Self::Driving => std::option::Option::Some("DRIVING"),
6356 Self::Walking => std::option::Option::Some("WALKING"),
6357 Self::UnknownValue(u) => u.0.name(),
6358 }
6359 }
6360 }
6361
6362 impl std::default::Default for TravelMode {
6363 fn default() -> Self {
6364 use std::convert::From;
6365 Self::from(0)
6366 }
6367 }
6368
6369 impl std::fmt::Display for TravelMode {
6370 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6371 wkt::internal::display_enum(f, self.name(), self.value())
6372 }
6373 }
6374
6375 impl std::convert::From<i32> for TravelMode {
6376 fn from(value: i32) -> Self {
6377 match value {
6378 0 => Self::Unspecified,
6379 1 => Self::Driving,
6380 2 => Self::Walking,
6381 _ => Self::UnknownValue(travel_mode::UnknownValue(
6382 wkt::internal::UnknownEnumValue::Integer(value),
6383 )),
6384 }
6385 }
6386 }
6387
6388 impl std::convert::From<&str> for TravelMode {
6389 fn from(value: &str) -> Self {
6390 use std::string::ToString;
6391 match value {
6392 "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
6393 "DRIVING" => Self::Driving,
6394 "WALKING" => Self::Walking,
6395 _ => Self::UnknownValue(travel_mode::UnknownValue(
6396 wkt::internal::UnknownEnumValue::String(value.to_string()),
6397 )),
6398 }
6399 }
6400 }
6401
6402 impl serde::ser::Serialize for TravelMode {
6403 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6404 where
6405 S: serde::Serializer,
6406 {
6407 match self {
6408 Self::Unspecified => serializer.serialize_i32(0),
6409 Self::Driving => serializer.serialize_i32(1),
6410 Self::Walking => serializer.serialize_i32(2),
6411 Self::UnknownValue(u) => u.0.serialize(serializer),
6412 }
6413 }
6414 }
6415
6416 impl<'de> serde::de::Deserialize<'de> for TravelMode {
6417 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6418 where
6419 D: serde::Deserializer<'de>,
6420 {
6421 deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
6422 ".google.cloud.optimization.v1.Vehicle.TravelMode",
6423 ))
6424 }
6425 }
6426
6427 /// Policy on how a vehicle can be unloaded. Applies only to shipments having
6428 /// both a pickup and a delivery.
6429 ///
6430 /// Other shipments are free to occur anywhere on the route independent of
6431 /// `unloading_policy`.
6432 ///
6433 /// # Working with unknown values
6434 ///
6435 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6436 /// additional enum variants at any time. Adding new variants is not considered
6437 /// a breaking change. Applications should write their code in anticipation of:
6438 ///
6439 /// - New values appearing in future releases of the client library, **and**
6440 /// - New values received dynamically, without application changes.
6441 ///
6442 /// Please consult the [Working with enums] section in the user guide for some
6443 /// guidelines.
6444 ///
6445 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6446 #[derive(Clone, Debug, PartialEq)]
6447 #[non_exhaustive]
6448 pub enum UnloadingPolicy {
6449 /// Unspecified unloading policy; deliveries must just occur after their
6450 /// corresponding pickups.
6451 Unspecified,
6452 /// Deliveries must occur in reverse order of pickups
6453 LastInFirstOut,
6454 /// Deliveries must occur in the same order as pickups
6455 FirstInFirstOut,
6456 /// If set, the enum was initialized with an unknown value.
6457 ///
6458 /// Applications can examine the value using [UnloadingPolicy::value] or
6459 /// [UnloadingPolicy::name].
6460 UnknownValue(unloading_policy::UnknownValue),
6461 }
6462
6463 #[doc(hidden)]
6464 pub mod unloading_policy {
6465 #[allow(unused_imports)]
6466 use super::*;
6467 #[derive(Clone, Debug, PartialEq)]
6468 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6469 }
6470
6471 impl UnloadingPolicy {
6472 /// Gets the enum value.
6473 ///
6474 /// Returns `None` if the enum contains an unknown value deserialized from
6475 /// the string representation of enums.
6476 pub fn value(&self) -> std::option::Option<i32> {
6477 match self {
6478 Self::Unspecified => std::option::Option::Some(0),
6479 Self::LastInFirstOut => std::option::Option::Some(1),
6480 Self::FirstInFirstOut => std::option::Option::Some(2),
6481 Self::UnknownValue(u) => u.0.value(),
6482 }
6483 }
6484
6485 /// Gets the enum value as a string.
6486 ///
6487 /// Returns `None` if the enum contains an unknown value deserialized from
6488 /// the integer representation of enums.
6489 pub fn name(&self) -> std::option::Option<&str> {
6490 match self {
6491 Self::Unspecified => std::option::Option::Some("UNLOADING_POLICY_UNSPECIFIED"),
6492 Self::LastInFirstOut => std::option::Option::Some("LAST_IN_FIRST_OUT"),
6493 Self::FirstInFirstOut => std::option::Option::Some("FIRST_IN_FIRST_OUT"),
6494 Self::UnknownValue(u) => u.0.name(),
6495 }
6496 }
6497 }
6498
6499 impl std::default::Default for UnloadingPolicy {
6500 fn default() -> Self {
6501 use std::convert::From;
6502 Self::from(0)
6503 }
6504 }
6505
6506 impl std::fmt::Display for UnloadingPolicy {
6507 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6508 wkt::internal::display_enum(f, self.name(), self.value())
6509 }
6510 }
6511
6512 impl std::convert::From<i32> for UnloadingPolicy {
6513 fn from(value: i32) -> Self {
6514 match value {
6515 0 => Self::Unspecified,
6516 1 => Self::LastInFirstOut,
6517 2 => Self::FirstInFirstOut,
6518 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6519 wkt::internal::UnknownEnumValue::Integer(value),
6520 )),
6521 }
6522 }
6523 }
6524
6525 impl std::convert::From<&str> for UnloadingPolicy {
6526 fn from(value: &str) -> Self {
6527 use std::string::ToString;
6528 match value {
6529 "UNLOADING_POLICY_UNSPECIFIED" => Self::Unspecified,
6530 "LAST_IN_FIRST_OUT" => Self::LastInFirstOut,
6531 "FIRST_IN_FIRST_OUT" => Self::FirstInFirstOut,
6532 _ => Self::UnknownValue(unloading_policy::UnknownValue(
6533 wkt::internal::UnknownEnumValue::String(value.to_string()),
6534 )),
6535 }
6536 }
6537 }
6538
6539 impl serde::ser::Serialize for UnloadingPolicy {
6540 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6541 where
6542 S: serde::Serializer,
6543 {
6544 match self {
6545 Self::Unspecified => serializer.serialize_i32(0),
6546 Self::LastInFirstOut => serializer.serialize_i32(1),
6547 Self::FirstInFirstOut => serializer.serialize_i32(2),
6548 Self::UnknownValue(u) => u.0.serialize(serializer),
6549 }
6550 }
6551 }
6552
6553 impl<'de> serde::de::Deserialize<'de> for UnloadingPolicy {
6554 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6555 where
6556 D: serde::Deserializer<'de>,
6557 {
6558 deserializer.deserialize_any(wkt::internal::EnumVisitor::<UnloadingPolicy>::new(
6559 ".google.cloud.optimization.v1.Vehicle.UnloadingPolicy",
6560 ))
6561 }
6562 }
6563}
6564
6565/// Time windows constrain the time of an event, such as the arrival time at a
6566/// visit, or the start and end time of a vehicle.
6567///
6568/// Hard time window bounds, `start_time` and `end_time`, enforce the earliest
6569/// and latest time of the event, such that `start_time <= event_time <=
6570/// end_time`. The soft time window lower bound, `soft_start_time`, expresses a
6571/// preference for the event to happen at or after `soft_start_time` by incurring
6572/// a cost proportional to how long before soft_start_time the event occurs. The
6573/// soft time window upper bound, `soft_end_time`, expresses a preference for the
6574/// event to happen at or before `soft_end_time` by incurring a cost proportional
6575/// to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
6576/// `soft_start_time` and `soft_end_time` should be within the global time limits
6577/// (see
6578/// [ShipmentModel.global_start_time][google.cloud.optimization.v1.ShipmentModel.global_start_time]
6579/// and
6580/// [ShipmentModel.global_end_time][google.cloud.optimization.v1.ShipmentModel.global_end_time])
6581/// and should respect:
6582///
6583/// ```norust
6584/// 0 <= `start_time` <= `soft_start_time` <= `end_time` and
6585/// 0 <= `start_time` <= `soft_end_time` <= `end_time`.
6586/// ```
6587///
6588/// [google.cloud.optimization.v1.ShipmentModel.global_end_time]: crate::model::ShipmentModel::global_end_time
6589/// [google.cloud.optimization.v1.ShipmentModel.global_start_time]: crate::model::ShipmentModel::global_start_time
6590#[derive(Clone, Default, PartialEq)]
6591#[non_exhaustive]
6592pub struct TimeWindow {
6593 /// The hard time window start time. If unspecified it will be set to
6594 /// `ShipmentModel.global_start_time`.
6595 pub start_time: std::option::Option<wkt::Timestamp>,
6596
6597 /// The hard time window end time. If unspecified it will be set to
6598 /// `ShipmentModel.global_end_time`.
6599 pub end_time: std::option::Option<wkt::Timestamp>,
6600
6601 /// The soft start time of the time window.
6602 pub soft_start_time: std::option::Option<wkt::Timestamp>,
6603
6604 /// The soft end time of the time window.
6605 pub soft_end_time: std::option::Option<wkt::Timestamp>,
6606
6607 /// A cost per hour added to other costs in the model if the event occurs
6608 /// before soft_start_time, computed as:
6609 ///
6610 /// ```norust
6611 /// max(0, soft_start_time - t.seconds)
6612 /// * cost_per_hour_before_soft_start_time / 3600,
6613 /// t being the time of the event.
6614 /// ```
6615 ///
6616 /// This cost must be positive, and the field can only be set if
6617 /// soft_start_time has been set.
6618 pub cost_per_hour_before_soft_start_time: std::option::Option<f64>,
6619
6620 /// A cost per hour added to other costs in the model if the event occurs after
6621 /// `soft_end_time`, computed as:
6622 ///
6623 /// ```norust
6624 /// max(0, t.seconds - soft_end_time.seconds)
6625 /// * cost_per_hour_after_soft_end_time / 3600,
6626 /// t being the time of the event.
6627 /// ```
6628 ///
6629 /// This cost must be positive, and the field can only be set if
6630 /// `soft_end_time` has been set.
6631 pub cost_per_hour_after_soft_end_time: std::option::Option<f64>,
6632
6633 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6634}
6635
6636impl TimeWindow {
6637 pub fn new() -> Self {
6638 std::default::Default::default()
6639 }
6640
6641 /// Sets the value of [start_time][crate::model::TimeWindow::start_time].
6642 ///
6643 /// # Example
6644 /// ```ignore,no_run
6645 /// # use google_cloud_optimization_v1::model::TimeWindow;
6646 /// use wkt::Timestamp;
6647 /// let x = TimeWindow::new().set_start_time(Timestamp::default()/* use setters */);
6648 /// ```
6649 pub fn set_start_time<T>(mut self, v: T) -> Self
6650 where
6651 T: std::convert::Into<wkt::Timestamp>,
6652 {
6653 self.start_time = std::option::Option::Some(v.into());
6654 self
6655 }
6656
6657 /// Sets or clears the value of [start_time][crate::model::TimeWindow::start_time].
6658 ///
6659 /// # Example
6660 /// ```ignore,no_run
6661 /// # use google_cloud_optimization_v1::model::TimeWindow;
6662 /// use wkt::Timestamp;
6663 /// let x = TimeWindow::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
6664 /// let x = TimeWindow::new().set_or_clear_start_time(None::<Timestamp>);
6665 /// ```
6666 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6667 where
6668 T: std::convert::Into<wkt::Timestamp>,
6669 {
6670 self.start_time = v.map(|x| x.into());
6671 self
6672 }
6673
6674 /// Sets the value of [end_time][crate::model::TimeWindow::end_time].
6675 ///
6676 /// # Example
6677 /// ```ignore,no_run
6678 /// # use google_cloud_optimization_v1::model::TimeWindow;
6679 /// use wkt::Timestamp;
6680 /// let x = TimeWindow::new().set_end_time(Timestamp::default()/* use setters */);
6681 /// ```
6682 pub fn set_end_time<T>(mut self, v: T) -> Self
6683 where
6684 T: std::convert::Into<wkt::Timestamp>,
6685 {
6686 self.end_time = std::option::Option::Some(v.into());
6687 self
6688 }
6689
6690 /// Sets or clears the value of [end_time][crate::model::TimeWindow::end_time].
6691 ///
6692 /// # Example
6693 /// ```ignore,no_run
6694 /// # use google_cloud_optimization_v1::model::TimeWindow;
6695 /// use wkt::Timestamp;
6696 /// let x = TimeWindow::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
6697 /// let x = TimeWindow::new().set_or_clear_end_time(None::<Timestamp>);
6698 /// ```
6699 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6700 where
6701 T: std::convert::Into<wkt::Timestamp>,
6702 {
6703 self.end_time = v.map(|x| x.into());
6704 self
6705 }
6706
6707 /// Sets the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6708 ///
6709 /// # Example
6710 /// ```ignore,no_run
6711 /// # use google_cloud_optimization_v1::model::TimeWindow;
6712 /// use wkt::Timestamp;
6713 /// let x = TimeWindow::new().set_soft_start_time(Timestamp::default()/* use setters */);
6714 /// ```
6715 pub fn set_soft_start_time<T>(mut self, v: T) -> Self
6716 where
6717 T: std::convert::Into<wkt::Timestamp>,
6718 {
6719 self.soft_start_time = std::option::Option::Some(v.into());
6720 self
6721 }
6722
6723 /// Sets or clears the value of [soft_start_time][crate::model::TimeWindow::soft_start_time].
6724 ///
6725 /// # Example
6726 /// ```ignore,no_run
6727 /// # use google_cloud_optimization_v1::model::TimeWindow;
6728 /// use wkt::Timestamp;
6729 /// let x = TimeWindow::new().set_or_clear_soft_start_time(Some(Timestamp::default()/* use setters */));
6730 /// let x = TimeWindow::new().set_or_clear_soft_start_time(None::<Timestamp>);
6731 /// ```
6732 pub fn set_or_clear_soft_start_time<T>(mut self, v: std::option::Option<T>) -> Self
6733 where
6734 T: std::convert::Into<wkt::Timestamp>,
6735 {
6736 self.soft_start_time = v.map(|x| x.into());
6737 self
6738 }
6739
6740 /// Sets the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6741 ///
6742 /// # Example
6743 /// ```ignore,no_run
6744 /// # use google_cloud_optimization_v1::model::TimeWindow;
6745 /// use wkt::Timestamp;
6746 /// let x = TimeWindow::new().set_soft_end_time(Timestamp::default()/* use setters */);
6747 /// ```
6748 pub fn set_soft_end_time<T>(mut self, v: T) -> Self
6749 where
6750 T: std::convert::Into<wkt::Timestamp>,
6751 {
6752 self.soft_end_time = std::option::Option::Some(v.into());
6753 self
6754 }
6755
6756 /// Sets or clears the value of [soft_end_time][crate::model::TimeWindow::soft_end_time].
6757 ///
6758 /// # Example
6759 /// ```ignore,no_run
6760 /// # use google_cloud_optimization_v1::model::TimeWindow;
6761 /// use wkt::Timestamp;
6762 /// let x = TimeWindow::new().set_or_clear_soft_end_time(Some(Timestamp::default()/* use setters */));
6763 /// let x = TimeWindow::new().set_or_clear_soft_end_time(None::<Timestamp>);
6764 /// ```
6765 pub fn set_or_clear_soft_end_time<T>(mut self, v: std::option::Option<T>) -> Self
6766 where
6767 T: std::convert::Into<wkt::Timestamp>,
6768 {
6769 self.soft_end_time = v.map(|x| x.into());
6770 self
6771 }
6772
6773 /// Sets the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6774 ///
6775 /// # Example
6776 /// ```ignore,no_run
6777 /// # use google_cloud_optimization_v1::model::TimeWindow;
6778 /// let x = TimeWindow::new().set_cost_per_hour_before_soft_start_time(42.0);
6779 /// ```
6780 pub fn set_cost_per_hour_before_soft_start_time<T>(mut self, v: T) -> Self
6781 where
6782 T: std::convert::Into<f64>,
6783 {
6784 self.cost_per_hour_before_soft_start_time = std::option::Option::Some(v.into());
6785 self
6786 }
6787
6788 /// Sets or clears the value of [cost_per_hour_before_soft_start_time][crate::model::TimeWindow::cost_per_hour_before_soft_start_time].
6789 ///
6790 /// # Example
6791 /// ```ignore,no_run
6792 /// # use google_cloud_optimization_v1::model::TimeWindow;
6793 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(Some(42.0));
6794 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_before_soft_start_time(None::<f32>);
6795 /// ```
6796 pub fn set_or_clear_cost_per_hour_before_soft_start_time<T>(
6797 mut self,
6798 v: std::option::Option<T>,
6799 ) -> Self
6800 where
6801 T: std::convert::Into<f64>,
6802 {
6803 self.cost_per_hour_before_soft_start_time = v.map(|x| x.into());
6804 self
6805 }
6806
6807 /// Sets the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6808 ///
6809 /// # Example
6810 /// ```ignore,no_run
6811 /// # use google_cloud_optimization_v1::model::TimeWindow;
6812 /// let x = TimeWindow::new().set_cost_per_hour_after_soft_end_time(42.0);
6813 /// ```
6814 pub fn set_cost_per_hour_after_soft_end_time<T>(mut self, v: T) -> Self
6815 where
6816 T: std::convert::Into<f64>,
6817 {
6818 self.cost_per_hour_after_soft_end_time = std::option::Option::Some(v.into());
6819 self
6820 }
6821
6822 /// Sets or clears the value of [cost_per_hour_after_soft_end_time][crate::model::TimeWindow::cost_per_hour_after_soft_end_time].
6823 ///
6824 /// # Example
6825 /// ```ignore,no_run
6826 /// # use google_cloud_optimization_v1::model::TimeWindow;
6827 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(Some(42.0));
6828 /// let x = TimeWindow::new().set_or_clear_cost_per_hour_after_soft_end_time(None::<f32>);
6829 /// ```
6830 pub fn set_or_clear_cost_per_hour_after_soft_end_time<T>(
6831 mut self,
6832 v: std::option::Option<T>,
6833 ) -> Self
6834 where
6835 T: std::convert::Into<f64>,
6836 {
6837 self.cost_per_hour_after_soft_end_time = v.map(|x| x.into());
6838 self
6839 }
6840}
6841
6842impl wkt::message::Message for TimeWindow {
6843 fn typename() -> &'static str {
6844 "type.googleapis.com/google.cloud.optimization.v1.TimeWindow"
6845 }
6846}
6847
6848/// Deprecated: Use
6849/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6850/// instead.
6851///
6852/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6853#[derive(Clone, Default, PartialEq)]
6854#[non_exhaustive]
6855#[deprecated]
6856pub struct CapacityQuantity {
6857 pub r#type: std::string::String,
6858
6859 pub value: i64,
6860
6861 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6862}
6863
6864impl CapacityQuantity {
6865 pub fn new() -> Self {
6866 std::default::Default::default()
6867 }
6868
6869 /// Sets the value of [r#type][crate::model::CapacityQuantity::type].
6870 ///
6871 /// # Example
6872 /// ```ignore,no_run
6873 /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6874 /// let x = CapacityQuantity::new().set_type("example");
6875 /// ```
6876 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6877 self.r#type = v.into();
6878 self
6879 }
6880
6881 /// Sets the value of [value][crate::model::CapacityQuantity::value].
6882 ///
6883 /// # Example
6884 /// ```ignore,no_run
6885 /// # use google_cloud_optimization_v1::model::CapacityQuantity;
6886 /// let x = CapacityQuantity::new().set_value(42);
6887 /// ```
6888 pub fn set_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6889 self.value = v.into();
6890 self
6891 }
6892}
6893
6894impl wkt::message::Message for CapacityQuantity {
6895 fn typename() -> &'static str {
6896 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantity"
6897 }
6898}
6899
6900/// Deprecated: Use
6901/// [Vehicle.LoadLimit.Interval][google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]
6902/// instead.
6903///
6904/// [google.cloud.optimization.v1.Vehicle.LoadLimit.Interval]: crate::model::vehicle::load_limit::Interval
6905#[derive(Clone, Default, PartialEq)]
6906#[non_exhaustive]
6907#[deprecated]
6908pub struct CapacityQuantityInterval {
6909 pub r#type: std::string::String,
6910
6911 pub min_value: std::option::Option<i64>,
6912
6913 pub max_value: std::option::Option<i64>,
6914
6915 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6916}
6917
6918impl CapacityQuantityInterval {
6919 pub fn new() -> Self {
6920 std::default::Default::default()
6921 }
6922
6923 /// Sets the value of [r#type][crate::model::CapacityQuantityInterval::type].
6924 ///
6925 /// # Example
6926 /// ```ignore,no_run
6927 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6928 /// let x = CapacityQuantityInterval::new().set_type("example");
6929 /// ```
6930 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6931 self.r#type = v.into();
6932 self
6933 }
6934
6935 /// Sets the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6936 ///
6937 /// # Example
6938 /// ```ignore,no_run
6939 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6940 /// let x = CapacityQuantityInterval::new().set_min_value(42);
6941 /// ```
6942 pub fn set_min_value<T>(mut self, v: T) -> Self
6943 where
6944 T: std::convert::Into<i64>,
6945 {
6946 self.min_value = std::option::Option::Some(v.into());
6947 self
6948 }
6949
6950 /// Sets or clears the value of [min_value][crate::model::CapacityQuantityInterval::min_value].
6951 ///
6952 /// # Example
6953 /// ```ignore,no_run
6954 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6955 /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(Some(42));
6956 /// let x = CapacityQuantityInterval::new().set_or_clear_min_value(None::<i32>);
6957 /// ```
6958 pub fn set_or_clear_min_value<T>(mut self, v: std::option::Option<T>) -> Self
6959 where
6960 T: std::convert::Into<i64>,
6961 {
6962 self.min_value = v.map(|x| x.into());
6963 self
6964 }
6965
6966 /// Sets the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
6967 ///
6968 /// # Example
6969 /// ```ignore,no_run
6970 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6971 /// let x = CapacityQuantityInterval::new().set_max_value(42);
6972 /// ```
6973 pub fn set_max_value<T>(mut self, v: T) -> Self
6974 where
6975 T: std::convert::Into<i64>,
6976 {
6977 self.max_value = std::option::Option::Some(v.into());
6978 self
6979 }
6980
6981 /// Sets or clears the value of [max_value][crate::model::CapacityQuantityInterval::max_value].
6982 ///
6983 /// # Example
6984 /// ```ignore,no_run
6985 /// # use google_cloud_optimization_v1::model::CapacityQuantityInterval;
6986 /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(Some(42));
6987 /// let x = CapacityQuantityInterval::new().set_or_clear_max_value(None::<i32>);
6988 /// ```
6989 pub fn set_or_clear_max_value<T>(mut self, v: std::option::Option<T>) -> Self
6990 where
6991 T: std::convert::Into<i64>,
6992 {
6993 self.max_value = v.map(|x| x.into());
6994 self
6995 }
6996}
6997
6998impl wkt::message::Message for CapacityQuantityInterval {
6999 fn typename() -> &'static str {
7000 "type.googleapis.com/google.cloud.optimization.v1.CapacityQuantityInterval"
7001 }
7002}
7003
7004/// A limit defining a maximum distance which can be traveled. It can be either
7005/// hard or soft.
7006///
7007/// If a soft limit is defined, both `soft_max_meters` and
7008/// `cost_per_kilometer_above_soft_max` must be defined and be nonnegative.
7009#[derive(Clone, Default, PartialEq)]
7010#[non_exhaustive]
7011pub struct DistanceLimit {
7012 /// A hard limit constraining the distance to be at most max_meters. The limit
7013 /// must be nonnegative.
7014 pub max_meters: std::option::Option<i64>,
7015
7016 /// A soft limit not enforcing a maximum distance limit, but when violated
7017 /// results in a cost which adds up to other costs defined in the model,
7018 /// with the same unit.
7019 ///
7020 /// If defined soft_max_meters must be less than max_meters and must be
7021 /// nonnegative.
7022 pub soft_max_meters: std::option::Option<i64>,
7023
7024 /// Cost per kilometer incurred, increasing up to `soft_max_meters`, with
7025 /// formula:
7026 ///
7027 /// ```norust
7028 /// min(distance_meters, soft_max_meters) / 1000.0 *
7029 /// cost_per_kilometer_below_soft_max.
7030 /// ```
7031 ///
7032 /// This cost is not supported in `route_distance_limit`.
7033 pub cost_per_kilometer_below_soft_max: std::option::Option<f64>,
7034
7035 /// Cost per kilometer incurred if distance is above `soft_max_meters` limit.
7036 /// The additional cost is 0 if the distance is under the limit, otherwise the
7037 /// formula used to compute the cost is the following:
7038 ///
7039 /// ```norust
7040 /// (distance_meters - soft_max_meters) / 1000.0 *
7041 /// cost_per_kilometer_above_soft_max.
7042 /// ```
7043 ///
7044 /// The cost must be nonnegative.
7045 pub cost_per_kilometer_above_soft_max: std::option::Option<f64>,
7046
7047 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7048}
7049
7050impl DistanceLimit {
7051 pub fn new() -> Self {
7052 std::default::Default::default()
7053 }
7054
7055 /// Sets the value of [max_meters][crate::model::DistanceLimit::max_meters].
7056 ///
7057 /// # Example
7058 /// ```ignore,no_run
7059 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7060 /// let x = DistanceLimit::new().set_max_meters(42);
7061 /// ```
7062 pub fn set_max_meters<T>(mut self, v: T) -> Self
7063 where
7064 T: std::convert::Into<i64>,
7065 {
7066 self.max_meters = std::option::Option::Some(v.into());
7067 self
7068 }
7069
7070 /// Sets or clears the value of [max_meters][crate::model::DistanceLimit::max_meters].
7071 ///
7072 /// # Example
7073 /// ```ignore,no_run
7074 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7075 /// let x = DistanceLimit::new().set_or_clear_max_meters(Some(42));
7076 /// let x = DistanceLimit::new().set_or_clear_max_meters(None::<i32>);
7077 /// ```
7078 pub fn set_or_clear_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7079 where
7080 T: std::convert::Into<i64>,
7081 {
7082 self.max_meters = v.map(|x| x.into());
7083 self
7084 }
7085
7086 /// Sets the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7087 ///
7088 /// # Example
7089 /// ```ignore,no_run
7090 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7091 /// let x = DistanceLimit::new().set_soft_max_meters(42);
7092 /// ```
7093 pub fn set_soft_max_meters<T>(mut self, v: T) -> Self
7094 where
7095 T: std::convert::Into<i64>,
7096 {
7097 self.soft_max_meters = std::option::Option::Some(v.into());
7098 self
7099 }
7100
7101 /// Sets or clears the value of [soft_max_meters][crate::model::DistanceLimit::soft_max_meters].
7102 ///
7103 /// # Example
7104 /// ```ignore,no_run
7105 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7106 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(Some(42));
7107 /// let x = DistanceLimit::new().set_or_clear_soft_max_meters(None::<i32>);
7108 /// ```
7109 pub fn set_or_clear_soft_max_meters<T>(mut self, v: std::option::Option<T>) -> Self
7110 where
7111 T: std::convert::Into<i64>,
7112 {
7113 self.soft_max_meters = v.map(|x| x.into());
7114 self
7115 }
7116
7117 /// Sets the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7118 ///
7119 /// # Example
7120 /// ```ignore,no_run
7121 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7122 /// let x = DistanceLimit::new().set_cost_per_kilometer_below_soft_max(42.0);
7123 /// ```
7124 pub fn set_cost_per_kilometer_below_soft_max<T>(mut self, v: T) -> Self
7125 where
7126 T: std::convert::Into<f64>,
7127 {
7128 self.cost_per_kilometer_below_soft_max = std::option::Option::Some(v.into());
7129 self
7130 }
7131
7132 /// Sets or clears the value of [cost_per_kilometer_below_soft_max][crate::model::DistanceLimit::cost_per_kilometer_below_soft_max].
7133 ///
7134 /// # Example
7135 /// ```ignore,no_run
7136 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7137 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(Some(42.0));
7138 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_below_soft_max(None::<f32>);
7139 /// ```
7140 pub fn set_or_clear_cost_per_kilometer_below_soft_max<T>(
7141 mut self,
7142 v: std::option::Option<T>,
7143 ) -> Self
7144 where
7145 T: std::convert::Into<f64>,
7146 {
7147 self.cost_per_kilometer_below_soft_max = v.map(|x| x.into());
7148 self
7149 }
7150
7151 /// Sets the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7152 ///
7153 /// # Example
7154 /// ```ignore,no_run
7155 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7156 /// let x = DistanceLimit::new().set_cost_per_kilometer_above_soft_max(42.0);
7157 /// ```
7158 pub fn set_cost_per_kilometer_above_soft_max<T>(mut self, v: T) -> Self
7159 where
7160 T: std::convert::Into<f64>,
7161 {
7162 self.cost_per_kilometer_above_soft_max = std::option::Option::Some(v.into());
7163 self
7164 }
7165
7166 /// Sets or clears the value of [cost_per_kilometer_above_soft_max][crate::model::DistanceLimit::cost_per_kilometer_above_soft_max].
7167 ///
7168 /// # Example
7169 /// ```ignore,no_run
7170 /// # use google_cloud_optimization_v1::model::DistanceLimit;
7171 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(Some(42.0));
7172 /// let x = DistanceLimit::new().set_or_clear_cost_per_kilometer_above_soft_max(None::<f32>);
7173 /// ```
7174 pub fn set_or_clear_cost_per_kilometer_above_soft_max<T>(
7175 mut self,
7176 v: std::option::Option<T>,
7177 ) -> Self
7178 where
7179 T: std::convert::Into<f64>,
7180 {
7181 self.cost_per_kilometer_above_soft_max = v.map(|x| x.into());
7182 self
7183 }
7184}
7185
7186impl wkt::message::Message for DistanceLimit {
7187 fn typename() -> &'static str {
7188 "type.googleapis.com/google.cloud.optimization.v1.DistanceLimit"
7189 }
7190}
7191
7192/// Specifies attributes of transitions between two consecutive visits on a
7193/// route. Several `TransitionAttributes` may apply to the same transition: in
7194/// that case, all extra costs add up and the strictest constraint or limit
7195/// applies (following natural "AND" semantics).
7196#[derive(Clone, Default, PartialEq)]
7197#[non_exhaustive]
7198pub struct TransitionAttributes {
7199 /// Tags defining the set of (src->dst) transitions these attributes apply to.
7200 ///
7201 /// A source visit or vehicle start matches iff its
7202 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7203 /// or [Vehicle.start_tags][google.cloud.optimization.v1.Vehicle.start_tags]
7204 /// either contains `src_tag` or does not contain `excluded_src_tag` (depending
7205 /// on which of these two fields is non-empty).
7206 ///
7207 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7208 /// [google.cloud.optimization.v1.Vehicle.start_tags]: crate::model::Vehicle::start_tags
7209 pub src_tag: std::string::String,
7210
7211 /// See `src_tag`. Exactly one of `src_tag` and `excluded_src_tag` must be
7212 /// non-empty.
7213 pub excluded_src_tag: std::string::String,
7214
7215 /// A destination visit or vehicle end matches iff its
7216 /// [VisitRequest.tags][google.cloud.optimization.v1.Shipment.VisitRequest.tags]
7217 /// or [Vehicle.end_tags][google.cloud.optimization.v1.Vehicle.end_tags] either
7218 /// contains `dst_tag` or does not contain `excluded_dst_tag` (depending on
7219 /// which of these two fields is non-empty).
7220 ///
7221 /// [google.cloud.optimization.v1.Shipment.VisitRequest.tags]: crate::model::shipment::VisitRequest::tags
7222 /// [google.cloud.optimization.v1.Vehicle.end_tags]: crate::model::Vehicle::end_tags
7223 pub dst_tag: std::string::String,
7224
7225 /// See `dst_tag`. Exactly one of `dst_tag` and `excluded_dst_tag` must be
7226 /// non-empty.
7227 pub excluded_dst_tag: std::string::String,
7228
7229 /// Specifies a cost for performing this transition. This is in the same unit
7230 /// as all other costs in the model and must not be negative. It is applied on
7231 /// top of all other existing costs.
7232 pub cost: f64,
7233
7234 /// Specifies a cost per kilometer applied to the distance traveled while
7235 /// performing this transition. It adds up to any
7236 /// [Vehicle.cost_per_kilometer][google.cloud.optimization.v1.Vehicle.cost_per_kilometer]
7237 /// specified on vehicles.
7238 ///
7239 /// [google.cloud.optimization.v1.Vehicle.cost_per_kilometer]: crate::model::Vehicle::cost_per_kilometer
7240 pub cost_per_kilometer: f64,
7241
7242 /// Specifies a limit on the distance traveled while performing this
7243 /// transition.
7244 ///
7245 /// As of 2021/06, only soft limits are supported.
7246 pub distance_limit: std::option::Option<crate::model::DistanceLimit>,
7247
7248 /// Specifies a delay incurred when performing this transition.
7249 ///
7250 /// This delay always occurs *after* finishing the source visit and *before*
7251 /// starting the destination visit.
7252 pub delay: std::option::Option<wkt::Duration>,
7253
7254 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7255}
7256
7257impl TransitionAttributes {
7258 pub fn new() -> Self {
7259 std::default::Default::default()
7260 }
7261
7262 /// Sets the value of [src_tag][crate::model::TransitionAttributes::src_tag].
7263 ///
7264 /// # Example
7265 /// ```ignore,no_run
7266 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7267 /// let x = TransitionAttributes::new().set_src_tag("example");
7268 /// ```
7269 pub fn set_src_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7270 self.src_tag = v.into();
7271 self
7272 }
7273
7274 /// Sets the value of [excluded_src_tag][crate::model::TransitionAttributes::excluded_src_tag].
7275 ///
7276 /// # Example
7277 /// ```ignore,no_run
7278 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7279 /// let x = TransitionAttributes::new().set_excluded_src_tag("example");
7280 /// ```
7281 pub fn set_excluded_src_tag<T: std::convert::Into<std::string::String>>(
7282 mut self,
7283 v: T,
7284 ) -> Self {
7285 self.excluded_src_tag = v.into();
7286 self
7287 }
7288
7289 /// Sets the value of [dst_tag][crate::model::TransitionAttributes::dst_tag].
7290 ///
7291 /// # Example
7292 /// ```ignore,no_run
7293 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7294 /// let x = TransitionAttributes::new().set_dst_tag("example");
7295 /// ```
7296 pub fn set_dst_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7297 self.dst_tag = v.into();
7298 self
7299 }
7300
7301 /// Sets the value of [excluded_dst_tag][crate::model::TransitionAttributes::excluded_dst_tag].
7302 ///
7303 /// # Example
7304 /// ```ignore,no_run
7305 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7306 /// let x = TransitionAttributes::new().set_excluded_dst_tag("example");
7307 /// ```
7308 pub fn set_excluded_dst_tag<T: std::convert::Into<std::string::String>>(
7309 mut self,
7310 v: T,
7311 ) -> Self {
7312 self.excluded_dst_tag = v.into();
7313 self
7314 }
7315
7316 /// Sets the value of [cost][crate::model::TransitionAttributes::cost].
7317 ///
7318 /// # Example
7319 /// ```ignore,no_run
7320 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7321 /// let x = TransitionAttributes::new().set_cost(42.0);
7322 /// ```
7323 pub fn set_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7324 self.cost = v.into();
7325 self
7326 }
7327
7328 /// Sets the value of [cost_per_kilometer][crate::model::TransitionAttributes::cost_per_kilometer].
7329 ///
7330 /// # Example
7331 /// ```ignore,no_run
7332 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7333 /// let x = TransitionAttributes::new().set_cost_per_kilometer(42.0);
7334 /// ```
7335 pub fn set_cost_per_kilometer<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
7336 self.cost_per_kilometer = v.into();
7337 self
7338 }
7339
7340 /// Sets the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7341 ///
7342 /// # Example
7343 /// ```ignore,no_run
7344 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7345 /// use google_cloud_optimization_v1::model::DistanceLimit;
7346 /// let x = TransitionAttributes::new().set_distance_limit(DistanceLimit::default()/* use setters */);
7347 /// ```
7348 pub fn set_distance_limit<T>(mut self, v: T) -> Self
7349 where
7350 T: std::convert::Into<crate::model::DistanceLimit>,
7351 {
7352 self.distance_limit = std::option::Option::Some(v.into());
7353 self
7354 }
7355
7356 /// Sets or clears the value of [distance_limit][crate::model::TransitionAttributes::distance_limit].
7357 ///
7358 /// # Example
7359 /// ```ignore,no_run
7360 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7361 /// use google_cloud_optimization_v1::model::DistanceLimit;
7362 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(Some(DistanceLimit::default()/* use setters */));
7363 /// let x = TransitionAttributes::new().set_or_clear_distance_limit(None::<DistanceLimit>);
7364 /// ```
7365 pub fn set_or_clear_distance_limit<T>(mut self, v: std::option::Option<T>) -> Self
7366 where
7367 T: std::convert::Into<crate::model::DistanceLimit>,
7368 {
7369 self.distance_limit = v.map(|x| x.into());
7370 self
7371 }
7372
7373 /// Sets the value of [delay][crate::model::TransitionAttributes::delay].
7374 ///
7375 /// # Example
7376 /// ```ignore,no_run
7377 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7378 /// use wkt::Duration;
7379 /// let x = TransitionAttributes::new().set_delay(Duration::default()/* use setters */);
7380 /// ```
7381 pub fn set_delay<T>(mut self, v: T) -> Self
7382 where
7383 T: std::convert::Into<wkt::Duration>,
7384 {
7385 self.delay = std::option::Option::Some(v.into());
7386 self
7387 }
7388
7389 /// Sets or clears the value of [delay][crate::model::TransitionAttributes::delay].
7390 ///
7391 /// # Example
7392 /// ```ignore,no_run
7393 /// # use google_cloud_optimization_v1::model::TransitionAttributes;
7394 /// use wkt::Duration;
7395 /// let x = TransitionAttributes::new().set_or_clear_delay(Some(Duration::default()/* use setters */));
7396 /// let x = TransitionAttributes::new().set_or_clear_delay(None::<Duration>);
7397 /// ```
7398 pub fn set_or_clear_delay<T>(mut self, v: std::option::Option<T>) -> Self
7399 where
7400 T: std::convert::Into<wkt::Duration>,
7401 {
7402 self.delay = v.map(|x| x.into());
7403 self
7404 }
7405}
7406
7407impl wkt::message::Message for TransitionAttributes {
7408 fn typename() -> &'static str {
7409 "type.googleapis.com/google.cloud.optimization.v1.TransitionAttributes"
7410 }
7411}
7412
7413/// Encapsulates a waypoint. Waypoints mark arrival and departure locations of
7414/// VisitRequests, and start and end locations of Vehicles.
7415#[derive(Clone, Default, PartialEq)]
7416#[non_exhaustive]
7417pub struct Waypoint {
7418 /// Indicates that the location of this waypoint is meant to have a preference
7419 /// for the vehicle to stop at a particular side of road. When you set this
7420 /// value, the route will pass through the location so that the vehicle can
7421 /// stop at the side of road that the location is biased towards from the
7422 /// center of the road. This option works only for the 'DRIVING' travel mode,
7423 /// and when the 'location_type' is set to 'location'.
7424 pub side_of_road: bool,
7425
7426 /// Different ways to represent a location.
7427 pub location_type: std::option::Option<crate::model::waypoint::LocationType>,
7428
7429 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7430}
7431
7432impl Waypoint {
7433 pub fn new() -> Self {
7434 std::default::Default::default()
7435 }
7436
7437 /// Sets the value of [side_of_road][crate::model::Waypoint::side_of_road].
7438 ///
7439 /// # Example
7440 /// ```ignore,no_run
7441 /// # use google_cloud_optimization_v1::model::Waypoint;
7442 /// let x = Waypoint::new().set_side_of_road(true);
7443 /// ```
7444 pub fn set_side_of_road<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7445 self.side_of_road = v.into();
7446 self
7447 }
7448
7449 /// Sets the value of [location_type][crate::model::Waypoint::location_type].
7450 ///
7451 /// Note that all the setters affecting `location_type` are mutually
7452 /// exclusive.
7453 ///
7454 /// # Example
7455 /// ```ignore,no_run
7456 /// # use google_cloud_optimization_v1::model::Waypoint;
7457 /// use google_cloud_optimization_v1::model::waypoint::LocationType;
7458 /// let x = Waypoint::new().set_location_type(Some(LocationType::PlaceId("example".to_string())));
7459 /// ```
7460 pub fn set_location_type<
7461 T: std::convert::Into<std::option::Option<crate::model::waypoint::LocationType>>,
7462 >(
7463 mut self,
7464 v: T,
7465 ) -> Self {
7466 self.location_type = v.into();
7467 self
7468 }
7469
7470 /// The value of [location_type][crate::model::Waypoint::location_type]
7471 /// if it holds a `Location`, `None` if the field is not set or
7472 /// holds a different branch.
7473 pub fn location(&self) -> std::option::Option<&std::boxed::Box<crate::model::Location>> {
7474 #[allow(unreachable_patterns)]
7475 self.location_type.as_ref().and_then(|v| match v {
7476 crate::model::waypoint::LocationType::Location(v) => std::option::Option::Some(v),
7477 _ => std::option::Option::None,
7478 })
7479 }
7480
7481 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7482 /// to hold a `Location`.
7483 ///
7484 /// Note that all the setters affecting `location_type` are
7485 /// mutually exclusive.
7486 ///
7487 /// # Example
7488 /// ```ignore,no_run
7489 /// # use google_cloud_optimization_v1::model::Waypoint;
7490 /// use google_cloud_optimization_v1::model::Location;
7491 /// let x = Waypoint::new().set_location(Location::default()/* use setters */);
7492 /// assert!(x.location().is_some());
7493 /// assert!(x.place_id().is_none());
7494 /// ```
7495 pub fn set_location<T: std::convert::Into<std::boxed::Box<crate::model::Location>>>(
7496 mut self,
7497 v: T,
7498 ) -> Self {
7499 self.location_type =
7500 std::option::Option::Some(crate::model::waypoint::LocationType::Location(v.into()));
7501 self
7502 }
7503
7504 /// The value of [location_type][crate::model::Waypoint::location_type]
7505 /// if it holds a `PlaceId`, `None` if the field is not set or
7506 /// holds a different branch.
7507 pub fn place_id(&self) -> std::option::Option<&std::string::String> {
7508 #[allow(unreachable_patterns)]
7509 self.location_type.as_ref().and_then(|v| match v {
7510 crate::model::waypoint::LocationType::PlaceId(v) => std::option::Option::Some(v),
7511 _ => std::option::Option::None,
7512 })
7513 }
7514
7515 /// Sets the value of [location_type][crate::model::Waypoint::location_type]
7516 /// to hold a `PlaceId`.
7517 ///
7518 /// Note that all the setters affecting `location_type` are
7519 /// mutually exclusive.
7520 ///
7521 /// # Example
7522 /// ```ignore,no_run
7523 /// # use google_cloud_optimization_v1::model::Waypoint;
7524 /// let x = Waypoint::new().set_place_id("example");
7525 /// assert!(x.place_id().is_some());
7526 /// assert!(x.location().is_none());
7527 /// ```
7528 pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7529 self.location_type =
7530 std::option::Option::Some(crate::model::waypoint::LocationType::PlaceId(v.into()));
7531 self
7532 }
7533}
7534
7535impl wkt::message::Message for Waypoint {
7536 fn typename() -> &'static str {
7537 "type.googleapis.com/google.cloud.optimization.v1.Waypoint"
7538 }
7539}
7540
7541/// Defines additional types related to [Waypoint].
7542pub mod waypoint {
7543 #[allow(unused_imports)]
7544 use super::*;
7545
7546 /// Different ways to represent a location.
7547 #[derive(Clone, Debug, PartialEq)]
7548 #[non_exhaustive]
7549 pub enum LocationType {
7550 /// A point specified using geographic coordinates, including an optional
7551 /// heading.
7552 Location(std::boxed::Box<crate::model::Location>),
7553 /// The POI Place ID associated with the waypoint.
7554 PlaceId(std::string::String),
7555 }
7556}
7557
7558/// Encapsulates a location (a geographic point, and an optional heading).
7559#[derive(Clone, Default, PartialEq)]
7560#[non_exhaustive]
7561pub struct Location {
7562 /// The waypoint's geographic coordinates.
7563 pub lat_lng: std::option::Option<google_cloud_type::model::LatLng>,
7564
7565 /// The compass heading associated with the direction of the flow of traffic.
7566 /// This value is used to specify the side of the road to use for pickup and
7567 /// drop-off. Heading values can be from 0 to 360, where 0 specifies a heading
7568 /// of due North, 90 specifies a heading of due East, etc.
7569 pub heading: std::option::Option<i32>,
7570
7571 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7572}
7573
7574impl Location {
7575 pub fn new() -> Self {
7576 std::default::Default::default()
7577 }
7578
7579 /// Sets the value of [lat_lng][crate::model::Location::lat_lng].
7580 ///
7581 /// # Example
7582 /// ```ignore,no_run
7583 /// # use google_cloud_optimization_v1::model::Location;
7584 /// use google_cloud_type::model::LatLng;
7585 /// let x = Location::new().set_lat_lng(LatLng::default()/* use setters */);
7586 /// ```
7587 pub fn set_lat_lng<T>(mut self, v: T) -> Self
7588 where
7589 T: std::convert::Into<google_cloud_type::model::LatLng>,
7590 {
7591 self.lat_lng = std::option::Option::Some(v.into());
7592 self
7593 }
7594
7595 /// Sets or clears the value of [lat_lng][crate::model::Location::lat_lng].
7596 ///
7597 /// # Example
7598 /// ```ignore,no_run
7599 /// # use google_cloud_optimization_v1::model::Location;
7600 /// use google_cloud_type::model::LatLng;
7601 /// let x = Location::new().set_or_clear_lat_lng(Some(LatLng::default()/* use setters */));
7602 /// let x = Location::new().set_or_clear_lat_lng(None::<LatLng>);
7603 /// ```
7604 pub fn set_or_clear_lat_lng<T>(mut self, v: std::option::Option<T>) -> Self
7605 where
7606 T: std::convert::Into<google_cloud_type::model::LatLng>,
7607 {
7608 self.lat_lng = v.map(|x| x.into());
7609 self
7610 }
7611
7612 /// Sets the value of [heading][crate::model::Location::heading].
7613 ///
7614 /// # Example
7615 /// ```ignore,no_run
7616 /// # use google_cloud_optimization_v1::model::Location;
7617 /// let x = Location::new().set_heading(42);
7618 /// ```
7619 pub fn set_heading<T>(mut self, v: T) -> Self
7620 where
7621 T: std::convert::Into<i32>,
7622 {
7623 self.heading = std::option::Option::Some(v.into());
7624 self
7625 }
7626
7627 /// Sets or clears the value of [heading][crate::model::Location::heading].
7628 ///
7629 /// # Example
7630 /// ```ignore,no_run
7631 /// # use google_cloud_optimization_v1::model::Location;
7632 /// let x = Location::new().set_or_clear_heading(Some(42));
7633 /// let x = Location::new().set_or_clear_heading(None::<i32>);
7634 /// ```
7635 pub fn set_or_clear_heading<T>(mut self, v: std::option::Option<T>) -> Self
7636 where
7637 T: std::convert::Into<i32>,
7638 {
7639 self.heading = v.map(|x| x.into());
7640 self
7641 }
7642}
7643
7644impl wkt::message::Message for Location {
7645 fn typename() -> &'static str {
7646 "type.googleapis.com/google.cloud.optimization.v1.Location"
7647 }
7648}
7649
7650/// Rules to generate time breaks for a vehicle (e.g. lunch breaks). A break
7651/// is a contiguous period of time during which the vehicle remains idle at its
7652/// current position and cannot perform any visit. A break may occur:
7653///
7654/// * during the travel between two visits (which includes the time right
7655/// before or right after a visit, but not in the middle of a visit), in
7656/// which case it extends the corresponding transit time between the visits,
7657/// * or before the vehicle start (the vehicle may not start in the middle of
7658/// a break), in which case it does not affect the vehicle start time.
7659/// * or after the vehicle end (ditto, with the vehicle end time).
7660#[derive(Clone, Default, PartialEq)]
7661#[non_exhaustive]
7662pub struct BreakRule {
7663 /// Sequence of breaks. See the `BreakRequest` message.
7664 pub break_requests: std::vec::Vec<crate::model::break_rule::BreakRequest>,
7665
7666 /// Several `FrequencyConstraint` may apply. They must all be satisfied by
7667 /// the `BreakRequest`s of this `BreakRule`. See `FrequencyConstraint`.
7668 pub frequency_constraints: std::vec::Vec<crate::model::break_rule::FrequencyConstraint>,
7669
7670 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7671}
7672
7673impl BreakRule {
7674 pub fn new() -> Self {
7675 std::default::Default::default()
7676 }
7677
7678 /// Sets the value of [break_requests][crate::model::BreakRule::break_requests].
7679 ///
7680 /// # Example
7681 /// ```ignore,no_run
7682 /// # use google_cloud_optimization_v1::model::BreakRule;
7683 /// use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7684 /// let x = BreakRule::new()
7685 /// .set_break_requests([
7686 /// BreakRequest::default()/* use setters */,
7687 /// BreakRequest::default()/* use (different) setters */,
7688 /// ]);
7689 /// ```
7690 pub fn set_break_requests<T, V>(mut self, v: T) -> Self
7691 where
7692 T: std::iter::IntoIterator<Item = V>,
7693 V: std::convert::Into<crate::model::break_rule::BreakRequest>,
7694 {
7695 use std::iter::Iterator;
7696 self.break_requests = v.into_iter().map(|i| i.into()).collect();
7697 self
7698 }
7699
7700 /// Sets the value of [frequency_constraints][crate::model::BreakRule::frequency_constraints].
7701 ///
7702 /// # Example
7703 /// ```ignore,no_run
7704 /// # use google_cloud_optimization_v1::model::BreakRule;
7705 /// use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7706 /// let x = BreakRule::new()
7707 /// .set_frequency_constraints([
7708 /// FrequencyConstraint::default()/* use setters */,
7709 /// FrequencyConstraint::default()/* use (different) setters */,
7710 /// ]);
7711 /// ```
7712 pub fn set_frequency_constraints<T, V>(mut self, v: T) -> Self
7713 where
7714 T: std::iter::IntoIterator<Item = V>,
7715 V: std::convert::Into<crate::model::break_rule::FrequencyConstraint>,
7716 {
7717 use std::iter::Iterator;
7718 self.frequency_constraints = v.into_iter().map(|i| i.into()).collect();
7719 self
7720 }
7721}
7722
7723impl wkt::message::Message for BreakRule {
7724 fn typename() -> &'static str {
7725 "type.googleapis.com/google.cloud.optimization.v1.BreakRule"
7726 }
7727}
7728
7729/// Defines additional types related to [BreakRule].
7730pub mod break_rule {
7731 #[allow(unused_imports)]
7732 use super::*;
7733
7734 /// The sequence of breaks (i.e. their number and order) that apply to each
7735 /// vehicle must be known beforehand. The repeated `BreakRequest`s define
7736 /// that sequence, in the order in which they must occur. Their time windows
7737 /// (`earliest_start_time` / `latest_start_time`) may overlap, but they must
7738 /// be compatible with the order (this is checked).
7739 #[derive(Clone, Default, PartialEq)]
7740 #[non_exhaustive]
7741 pub struct BreakRequest {
7742 /// Required. Lower bound (inclusive) on the start of the break.
7743 pub earliest_start_time: std::option::Option<wkt::Timestamp>,
7744
7745 /// Required. Upper bound (inclusive) on the start of the break.
7746 pub latest_start_time: std::option::Option<wkt::Timestamp>,
7747
7748 /// Required. Minimum duration of the break. Must be positive.
7749 pub min_duration: std::option::Option<wkt::Duration>,
7750
7751 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7752 }
7753
7754 impl BreakRequest {
7755 pub fn new() -> Self {
7756 std::default::Default::default()
7757 }
7758
7759 /// Sets the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7760 ///
7761 /// # Example
7762 /// ```ignore,no_run
7763 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7764 /// use wkt::Timestamp;
7765 /// let x = BreakRequest::new().set_earliest_start_time(Timestamp::default()/* use setters */);
7766 /// ```
7767 pub fn set_earliest_start_time<T>(mut self, v: T) -> Self
7768 where
7769 T: std::convert::Into<wkt::Timestamp>,
7770 {
7771 self.earliest_start_time = std::option::Option::Some(v.into());
7772 self
7773 }
7774
7775 /// Sets or clears the value of [earliest_start_time][crate::model::break_rule::BreakRequest::earliest_start_time].
7776 ///
7777 /// # Example
7778 /// ```ignore,no_run
7779 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7780 /// use wkt::Timestamp;
7781 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(Some(Timestamp::default()/* use setters */));
7782 /// let x = BreakRequest::new().set_or_clear_earliest_start_time(None::<Timestamp>);
7783 /// ```
7784 pub fn set_or_clear_earliest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7785 where
7786 T: std::convert::Into<wkt::Timestamp>,
7787 {
7788 self.earliest_start_time = v.map(|x| x.into());
7789 self
7790 }
7791
7792 /// Sets the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7793 ///
7794 /// # Example
7795 /// ```ignore,no_run
7796 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7797 /// use wkt::Timestamp;
7798 /// let x = BreakRequest::new().set_latest_start_time(Timestamp::default()/* use setters */);
7799 /// ```
7800 pub fn set_latest_start_time<T>(mut self, v: T) -> Self
7801 where
7802 T: std::convert::Into<wkt::Timestamp>,
7803 {
7804 self.latest_start_time = std::option::Option::Some(v.into());
7805 self
7806 }
7807
7808 /// Sets or clears the value of [latest_start_time][crate::model::break_rule::BreakRequest::latest_start_time].
7809 ///
7810 /// # Example
7811 /// ```ignore,no_run
7812 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7813 /// use wkt::Timestamp;
7814 /// let x = BreakRequest::new().set_or_clear_latest_start_time(Some(Timestamp::default()/* use setters */));
7815 /// let x = BreakRequest::new().set_or_clear_latest_start_time(None::<Timestamp>);
7816 /// ```
7817 pub fn set_or_clear_latest_start_time<T>(mut self, v: std::option::Option<T>) -> Self
7818 where
7819 T: std::convert::Into<wkt::Timestamp>,
7820 {
7821 self.latest_start_time = v.map(|x| x.into());
7822 self
7823 }
7824
7825 /// Sets the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7826 ///
7827 /// # Example
7828 /// ```ignore,no_run
7829 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7830 /// use wkt::Duration;
7831 /// let x = BreakRequest::new().set_min_duration(Duration::default()/* use setters */);
7832 /// ```
7833 pub fn set_min_duration<T>(mut self, v: T) -> Self
7834 where
7835 T: std::convert::Into<wkt::Duration>,
7836 {
7837 self.min_duration = std::option::Option::Some(v.into());
7838 self
7839 }
7840
7841 /// Sets or clears the value of [min_duration][crate::model::break_rule::BreakRequest::min_duration].
7842 ///
7843 /// # Example
7844 /// ```ignore,no_run
7845 /// # use google_cloud_optimization_v1::model::break_rule::BreakRequest;
7846 /// use wkt::Duration;
7847 /// let x = BreakRequest::new().set_or_clear_min_duration(Some(Duration::default()/* use setters */));
7848 /// let x = BreakRequest::new().set_or_clear_min_duration(None::<Duration>);
7849 /// ```
7850 pub fn set_or_clear_min_duration<T>(mut self, v: std::option::Option<T>) -> Self
7851 where
7852 T: std::convert::Into<wkt::Duration>,
7853 {
7854 self.min_duration = v.map(|x| x.into());
7855 self
7856 }
7857 }
7858
7859 impl wkt::message::Message for BreakRequest {
7860 fn typename() -> &'static str {
7861 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.BreakRequest"
7862 }
7863 }
7864
7865 /// One may further constrain the frequency and duration of the breaks
7866 /// specified above, by enforcing a minimum break frequency, such as
7867 /// "There must be a break of at least 1 hour every 12 hours". Assuming that
7868 /// this can be interpreted as "Within any sliding time window of 12h, there
7869 /// must be at least one break of at least one hour", that example would
7870 /// translate to the following `FrequencyConstraint`:
7871 ///
7872 /// ```norust
7873 /// {
7874 /// min_break_duration { seconds: 3600 } # 1 hour.
7875 /// max_inter_break_duration { seconds: 39600 } # 11 hours (12 - 1 = 11).
7876 /// }
7877 /// ```
7878 ///
7879 /// The timing and duration of the breaks in the solution will respect all
7880 /// such constraints, in addition to the time windows and minimum durations
7881 /// already specified in the `BreakRequest`.
7882 ///
7883 /// A `FrequencyConstraint` may in practice apply to non-consecutive breaks.
7884 /// For example, the following schedule honors the "1h every 12h" example:
7885 ///
7886 /// ```norust
7887 /// 04:00 vehicle start
7888 /// .. performing travel and visits ..
7889 /// 09:00 1 hour break
7890 /// 10:00 end of the break
7891 /// .. performing travel and visits ..
7892 /// 12:00 20-min lunch break
7893 /// 12:20 end of the break
7894 /// .. performing travel and visits ..
7895 /// 21:00 1 hour break
7896 /// 22:00 end of the break
7897 /// .. performing travel and visits ..
7898 /// 23:59 vehicle end
7899 /// ```
7900 #[derive(Clone, Default, PartialEq)]
7901 #[non_exhaustive]
7902 pub struct FrequencyConstraint {
7903 /// Required. Minimum break duration for this constraint. Nonnegative.
7904 /// See description of `FrequencyConstraint`.
7905 pub min_break_duration: std::option::Option<wkt::Duration>,
7906
7907 /// Required. Maximum allowed span of any interval of time in the route that
7908 /// does not include at least partially a break of `duration >=
7909 /// min_break_duration`. Must be positive.
7910 pub max_inter_break_duration: std::option::Option<wkt::Duration>,
7911
7912 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7913 }
7914
7915 impl FrequencyConstraint {
7916 pub fn new() -> Self {
7917 std::default::Default::default()
7918 }
7919
7920 /// Sets the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7921 ///
7922 /// # Example
7923 /// ```ignore,no_run
7924 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7925 /// use wkt::Duration;
7926 /// let x = FrequencyConstraint::new().set_min_break_duration(Duration::default()/* use setters */);
7927 /// ```
7928 pub fn set_min_break_duration<T>(mut self, v: T) -> Self
7929 where
7930 T: std::convert::Into<wkt::Duration>,
7931 {
7932 self.min_break_duration = std::option::Option::Some(v.into());
7933 self
7934 }
7935
7936 /// Sets or clears the value of [min_break_duration][crate::model::break_rule::FrequencyConstraint::min_break_duration].
7937 ///
7938 /// # Example
7939 /// ```ignore,no_run
7940 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7941 /// use wkt::Duration;
7942 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(Some(Duration::default()/* use setters */));
7943 /// let x = FrequencyConstraint::new().set_or_clear_min_break_duration(None::<Duration>);
7944 /// ```
7945 pub fn set_or_clear_min_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7946 where
7947 T: std::convert::Into<wkt::Duration>,
7948 {
7949 self.min_break_duration = v.map(|x| x.into());
7950 self
7951 }
7952
7953 /// Sets the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7954 ///
7955 /// # Example
7956 /// ```ignore,no_run
7957 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7958 /// use wkt::Duration;
7959 /// let x = FrequencyConstraint::new().set_max_inter_break_duration(Duration::default()/* use setters */);
7960 /// ```
7961 pub fn set_max_inter_break_duration<T>(mut self, v: T) -> Self
7962 where
7963 T: std::convert::Into<wkt::Duration>,
7964 {
7965 self.max_inter_break_duration = std::option::Option::Some(v.into());
7966 self
7967 }
7968
7969 /// Sets or clears the value of [max_inter_break_duration][crate::model::break_rule::FrequencyConstraint::max_inter_break_duration].
7970 ///
7971 /// # Example
7972 /// ```ignore,no_run
7973 /// # use google_cloud_optimization_v1::model::break_rule::FrequencyConstraint;
7974 /// use wkt::Duration;
7975 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(Some(Duration::default()/* use setters */));
7976 /// let x = FrequencyConstraint::new().set_or_clear_max_inter_break_duration(None::<Duration>);
7977 /// ```
7978 pub fn set_or_clear_max_inter_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
7979 where
7980 T: std::convert::Into<wkt::Duration>,
7981 {
7982 self.max_inter_break_duration = v.map(|x| x.into());
7983 self
7984 }
7985 }
7986
7987 impl wkt::message::Message for FrequencyConstraint {
7988 fn typename() -> &'static str {
7989 "type.googleapis.com/google.cloud.optimization.v1.BreakRule.FrequencyConstraint"
7990 }
7991 }
7992}
7993
7994/// A vehicle's route can be decomposed, along the time axis, like this (we
7995/// assume there are n visits):
7996///
7997/// ```norust
7998/// | | | | | T[2], | | |
7999/// | Transition | Visit #0 | | | V[2], | | |
8000/// | #0 | aka | T[1] | V[1] | ... | V[n-1] | T[n] |
8001/// | aka T[0] | V[0] | | | V[n-2],| | |
8002/// | | | | | T[n-1] | | |
8003/// ^ ^ ^ ^ ^ ^ ^ ^
8004/// vehicle V[0].start V[0].end V[1]. V[1]. V[n]. V[n]. vehicle
8005/// start (arrival) (departure) start end start end end
8006/// ```
8007///
8008/// Note that we make a difference between:
8009///
8010/// * "punctual events", such as the vehicle start and end and each visit's start
8011/// and end (aka arrival and departure). They happen at a given second.
8012/// * "time intervals", such as the visits themselves, and the transition between
8013/// visits. Though time intervals can sometimes have zero duration, i.e. start
8014/// and end at the same second, they often have a positive duration.
8015///
8016/// Invariants:
8017///
8018/// * If there are n visits, there are n+1 transitions.
8019/// * A visit is always surrounded by a transition before it (same index) and a
8020/// transition after it (index + 1).
8021/// * The vehicle start is always followed by transition #0.
8022/// * The vehicle end is always preceded by transition #n.
8023///
8024/// Zooming in, here is what happens during a `Transition` and a `Visit`:
8025///
8026/// ```norust
8027/// ---+-------------------------------------+-----------------------------+-->
8028/// | TRANSITION[i] | VISIT[i] |
8029/// | | |
8030/// | * TRAVEL: the vehicle moves from | PERFORM the visit: |
8031/// | VISIT[i-1].departure_location to | |
8032/// | VISIT[i].arrival_location, which | * Spend some time: |
8033/// | takes a given travel duration | the "visit duration". |
8034/// | and distance | |
8035/// | | * Load or unload |
8036/// | * BREAKS: the driver may have | some quantities from the |
8037/// | breaks (e.g. lunch break). | vehicle: the "demand". |
8038/// | | |
8039/// | * WAIT: the driver/vehicle does | |
8040/// | nothing. This can happen for | |
8041/// | many reasons, for example when | |
8042/// | the vehicle reaches the next | |
8043/// | event's destination before the | |
8044/// | start of its time window | |
8045/// | | |
8046/// | * DELAY: *right before* the next | |
8047/// | arrival. E.g. the vehicle and/or | |
8048/// | driver spends time unloading. | |
8049/// | | |
8050/// ---+-------------------------------------+-----------------------------+-->
8051/// ^ ^ ^
8052/// V[i-1].end V[i].start V[i].end
8053/// ```
8054///
8055/// Lastly, here is how the TRAVEL, BREAKS, DELAY and WAIT can be arranged
8056/// during a transition.
8057///
8058/// * They don't overlap.
8059/// * The DELAY is unique and *must* be a contiguous period of time right
8060/// before the next visit (or vehicle end). Thus, it suffice to know the
8061/// delay duration to know its start and end time.
8062/// * The BREAKS are contiguous, non-overlapping periods of time. The
8063/// response specifies the start time and duration of each break.
8064/// * TRAVEL and WAIT are "preemptable": they can be interrupted several times
8065/// during this transition. Clients can assume that travel happens "as soon as
8066/// possible" and that "wait" fills the remaining time.
8067///
8068/// A (complex) example:
8069///
8070/// ```norust
8071/// TRANSITION[i]
8072/// --++-----+-----------------------------------------------------------++-->
8073/// || | | | | | | ||
8074/// || T | B | T | | B | | D ||
8075/// || r | r | r | W | r | W | e ||
8076/// || a | e | a | a | e | a | l ||
8077/// || v | a | v | i | a | i | a ||
8078/// || e | k | e | t | k | t | y ||
8079/// || l | | l | | | | ||
8080/// || | | | | | | ||
8081/// --++-----------------------------------------------------------------++-->
8082/// ```
8083#[derive(Clone, Default, PartialEq)]
8084#[non_exhaustive]
8085pub struct ShipmentRoute {
8086 /// Vehicle performing the route, identified by its index in the source
8087 /// `ShipmentModel`.
8088 pub vehicle_index: i32,
8089
8090 /// Label of the vehicle performing this route, equal to
8091 /// `ShipmentModel.vehicles(vehicle_index).label`, if specified.
8092 pub vehicle_label: std::string::String,
8093
8094 /// Time at which the vehicle starts its route.
8095 pub vehicle_start_time: std::option::Option<wkt::Timestamp>,
8096
8097 /// Time at which the vehicle finishes its route.
8098 pub vehicle_end_time: std::option::Option<wkt::Timestamp>,
8099
8100 /// Ordered sequence of visits representing a route.
8101 /// visits[i] is the i-th visit in the route.
8102 /// If this field is empty, the vehicle is considered as unused.
8103 pub visits: std::vec::Vec<crate::model::shipment_route::Visit>,
8104
8105 /// Ordered list of transitions for the route.
8106 pub transitions: std::vec::Vec<crate::model::shipment_route::Transition>,
8107
8108 /// When
8109 /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
8110 /// is set to true, this field indicates that inconsistencies in route timings
8111 /// are predicted using traffic-based travel duration estimates. There may be
8112 /// insufficient time to complete traffic-adjusted travel, delays, and breaks
8113 /// between visits, before the first visit, or after the last visit, while
8114 /// still satisfying the visit and vehicle time windows. For example,
8115 ///
8116 /// ```norust
8117 /// start_time(previous_visit) + duration(previous_visit) +
8118 /// travel_duration(previous_visit, next_visit) > start_time(next_visit)
8119 /// ```
8120 ///
8121 /// Arrival at next_visit will likely happen later than its current
8122 /// time window due the increased estimate of travel time
8123 /// `travel_duration(previous_visit, next_visit)` due to traffic. Also, a break
8124 /// may be forced to overlap with a visit due to an increase in travel time
8125 /// estimates and visit or break time window restrictions.
8126 ///
8127 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
8128 pub has_traffic_infeasibilities: bool,
8129
8130 /// The encoded polyline representation of the route.
8131 /// This field is only populated if
8132 /// [OptimizeToursRequest.populate_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]
8133 /// is set to true.
8134 ///
8135 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_polylines]: crate::model::OptimizeToursRequest::populate_polylines
8136 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
8137
8138 /// Breaks scheduled for the vehicle performing this route.
8139 /// The `breaks` sequence represents time intervals, each starting at the
8140 /// corresponding `start_time` and lasting `duration` seconds.
8141 pub breaks: std::vec::Vec<crate::model::shipment_route::Break>,
8142
8143 /// Duration, distance and load metrics for this route. The fields of
8144 /// [AggregatedMetrics][google.cloud.optimization.v1.AggregatedMetrics] are
8145 /// summed over all
8146 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8147 /// or
8148 /// [ShipmentRoute.visits][google.cloud.optimization.v1.ShipmentRoute.visits],
8149 /// depending on the context.
8150 ///
8151 /// [google.cloud.optimization.v1.AggregatedMetrics]: crate::model::AggregatedMetrics
8152 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8153 /// [google.cloud.optimization.v1.ShipmentRoute.visits]: crate::model::ShipmentRoute::visits
8154 pub metrics: std::option::Option<crate::model::AggregatedMetrics>,
8155
8156 /// Cost of the route, broken down by cost-related request fields.
8157 /// The keys are proto paths, relative to the input OptimizeToursRequest, e.g.
8158 /// "model.shipments.pickups.cost", and the values are the total cost
8159 /// generated by the corresponding cost field, aggregated over the whole route.
8160 /// In other words, costs["model.shipments.pickups.cost"] is the sum of all
8161 /// pickup costs over the route. All costs defined in the model are reported in
8162 /// detail here with the exception of costs related to TransitionAttributes
8163 /// that are only reported in an aggregated way as of 2022/01.
8164 pub route_costs: std::collections::HashMap<std::string::String, f64>,
8165
8166 /// Total cost of the route. The sum of all costs in the cost map.
8167 pub route_total_cost: f64,
8168
8169 /// Deprecated: Use
8170 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8171 /// instead. Vehicle loads upon arrival at its end location, for each type
8172 /// specified in
8173 /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8174 /// `start_load_intervals`, `end_load_intervals` or demands. Exception: we omit
8175 /// loads for quantity types unconstrained by intervals and that don't have any
8176 /// non-zero demand on the route.
8177 ///
8178 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8179 /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8180 #[deprecated]
8181 pub end_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8182
8183 /// Deprecated: Use
8184 /// [ShipmentRoute.transitions][google.cloud.optimization.v1.ShipmentRoute.transitions]
8185 /// instead. Ordered list of travel steps for the route.
8186 ///
8187 /// [google.cloud.optimization.v1.ShipmentRoute.transitions]: crate::model::ShipmentRoute::transitions
8188 #[deprecated]
8189 pub travel_steps: std::vec::Vec<crate::model::shipment_route::TravelStep>,
8190
8191 /// Deprecated: No longer used.
8192 /// This field will only be populated at the
8193 /// [ShipmentRoute.Visit][google.cloud.optimization.v1.ShipmentRoute.Visit]
8194 /// level.
8195 ///
8196 /// This field is the extra detour time due to the shipments visited on the
8197 /// route.
8198 ///
8199 /// It is equal to `vehicle_end_time` - `vehicle_start_time` - travel duration
8200 /// from the vehicle's start_location to its `end_location`.
8201 ///
8202 /// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
8203 #[deprecated]
8204 pub vehicle_detour: std::option::Option<wkt::Duration>,
8205
8206 /// Deprecated: Delay occurring before the vehicle end. See
8207 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8208 ///
8209 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8210 #[deprecated]
8211 pub delay_before_vehicle_end: std::option::Option<crate::model::shipment_route::Delay>,
8212
8213 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8214}
8215
8216impl ShipmentRoute {
8217 pub fn new() -> Self {
8218 std::default::Default::default()
8219 }
8220
8221 /// Sets the value of [vehicle_index][crate::model::ShipmentRoute::vehicle_index].
8222 ///
8223 /// # Example
8224 /// ```ignore,no_run
8225 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8226 /// let x = ShipmentRoute::new().set_vehicle_index(42);
8227 /// ```
8228 pub fn set_vehicle_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8229 self.vehicle_index = v.into();
8230 self
8231 }
8232
8233 /// Sets the value of [vehicle_label][crate::model::ShipmentRoute::vehicle_label].
8234 ///
8235 /// # Example
8236 /// ```ignore,no_run
8237 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8238 /// let x = ShipmentRoute::new().set_vehicle_label("example");
8239 /// ```
8240 pub fn set_vehicle_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8241 self.vehicle_label = v.into();
8242 self
8243 }
8244
8245 /// Sets the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8246 ///
8247 /// # Example
8248 /// ```ignore,no_run
8249 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8250 /// use wkt::Timestamp;
8251 /// let x = ShipmentRoute::new().set_vehicle_start_time(Timestamp::default()/* use setters */);
8252 /// ```
8253 pub fn set_vehicle_start_time<T>(mut self, v: T) -> Self
8254 where
8255 T: std::convert::Into<wkt::Timestamp>,
8256 {
8257 self.vehicle_start_time = std::option::Option::Some(v.into());
8258 self
8259 }
8260
8261 /// Sets or clears the value of [vehicle_start_time][crate::model::ShipmentRoute::vehicle_start_time].
8262 ///
8263 /// # Example
8264 /// ```ignore,no_run
8265 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8266 /// use wkt::Timestamp;
8267 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(Some(Timestamp::default()/* use setters */));
8268 /// let x = ShipmentRoute::new().set_or_clear_vehicle_start_time(None::<Timestamp>);
8269 /// ```
8270 pub fn set_or_clear_vehicle_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8271 where
8272 T: std::convert::Into<wkt::Timestamp>,
8273 {
8274 self.vehicle_start_time = v.map(|x| x.into());
8275 self
8276 }
8277
8278 /// Sets the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8279 ///
8280 /// # Example
8281 /// ```ignore,no_run
8282 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8283 /// use wkt::Timestamp;
8284 /// let x = ShipmentRoute::new().set_vehicle_end_time(Timestamp::default()/* use setters */);
8285 /// ```
8286 pub fn set_vehicle_end_time<T>(mut self, v: T) -> Self
8287 where
8288 T: std::convert::Into<wkt::Timestamp>,
8289 {
8290 self.vehicle_end_time = std::option::Option::Some(v.into());
8291 self
8292 }
8293
8294 /// Sets or clears the value of [vehicle_end_time][crate::model::ShipmentRoute::vehicle_end_time].
8295 ///
8296 /// # Example
8297 /// ```ignore,no_run
8298 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8299 /// use wkt::Timestamp;
8300 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(Some(Timestamp::default()/* use setters */));
8301 /// let x = ShipmentRoute::new().set_or_clear_vehicle_end_time(None::<Timestamp>);
8302 /// ```
8303 pub fn set_or_clear_vehicle_end_time<T>(mut self, v: std::option::Option<T>) -> Self
8304 where
8305 T: std::convert::Into<wkt::Timestamp>,
8306 {
8307 self.vehicle_end_time = v.map(|x| x.into());
8308 self
8309 }
8310
8311 /// Sets the value of [visits][crate::model::ShipmentRoute::visits].
8312 ///
8313 /// # Example
8314 /// ```ignore,no_run
8315 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8316 /// use google_cloud_optimization_v1::model::shipment_route::Visit;
8317 /// let x = ShipmentRoute::new()
8318 /// .set_visits([
8319 /// Visit::default()/* use setters */,
8320 /// Visit::default()/* use (different) setters */,
8321 /// ]);
8322 /// ```
8323 pub fn set_visits<T, V>(mut self, v: T) -> Self
8324 where
8325 T: std::iter::IntoIterator<Item = V>,
8326 V: std::convert::Into<crate::model::shipment_route::Visit>,
8327 {
8328 use std::iter::Iterator;
8329 self.visits = v.into_iter().map(|i| i.into()).collect();
8330 self
8331 }
8332
8333 /// Sets the value of [transitions][crate::model::ShipmentRoute::transitions].
8334 ///
8335 /// # Example
8336 /// ```ignore,no_run
8337 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8338 /// use google_cloud_optimization_v1::model::shipment_route::Transition;
8339 /// let x = ShipmentRoute::new()
8340 /// .set_transitions([
8341 /// Transition::default()/* use setters */,
8342 /// Transition::default()/* use (different) setters */,
8343 /// ]);
8344 /// ```
8345 pub fn set_transitions<T, V>(mut self, v: T) -> Self
8346 where
8347 T: std::iter::IntoIterator<Item = V>,
8348 V: std::convert::Into<crate::model::shipment_route::Transition>,
8349 {
8350 use std::iter::Iterator;
8351 self.transitions = v.into_iter().map(|i| i.into()).collect();
8352 self
8353 }
8354
8355 /// Sets the value of [has_traffic_infeasibilities][crate::model::ShipmentRoute::has_traffic_infeasibilities].
8356 ///
8357 /// # Example
8358 /// ```ignore,no_run
8359 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8360 /// let x = ShipmentRoute::new().set_has_traffic_infeasibilities(true);
8361 /// ```
8362 pub fn set_has_traffic_infeasibilities<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8363 self.has_traffic_infeasibilities = v.into();
8364 self
8365 }
8366
8367 /// Sets the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8368 ///
8369 /// # Example
8370 /// ```ignore,no_run
8371 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8372 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8373 /// let x = ShipmentRoute::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
8374 /// ```
8375 pub fn set_route_polyline<T>(mut self, v: T) -> Self
8376 where
8377 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8378 {
8379 self.route_polyline = std::option::Option::Some(v.into());
8380 self
8381 }
8382
8383 /// Sets or clears the value of [route_polyline][crate::model::ShipmentRoute::route_polyline].
8384 ///
8385 /// # Example
8386 /// ```ignore,no_run
8387 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8388 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
8389 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
8390 /// let x = ShipmentRoute::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
8391 /// ```
8392 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
8393 where
8394 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
8395 {
8396 self.route_polyline = v.map(|x| x.into());
8397 self
8398 }
8399
8400 /// Sets the value of [breaks][crate::model::ShipmentRoute::breaks].
8401 ///
8402 /// # Example
8403 /// ```ignore,no_run
8404 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8405 /// use google_cloud_optimization_v1::model::shipment_route::Break;
8406 /// let x = ShipmentRoute::new()
8407 /// .set_breaks([
8408 /// Break::default()/* use setters */,
8409 /// Break::default()/* use (different) setters */,
8410 /// ]);
8411 /// ```
8412 pub fn set_breaks<T, V>(mut self, v: T) -> Self
8413 where
8414 T: std::iter::IntoIterator<Item = V>,
8415 V: std::convert::Into<crate::model::shipment_route::Break>,
8416 {
8417 use std::iter::Iterator;
8418 self.breaks = v.into_iter().map(|i| i.into()).collect();
8419 self
8420 }
8421
8422 /// Sets the value of [metrics][crate::model::ShipmentRoute::metrics].
8423 ///
8424 /// # Example
8425 /// ```ignore,no_run
8426 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8427 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8428 /// let x = ShipmentRoute::new().set_metrics(AggregatedMetrics::default()/* use setters */);
8429 /// ```
8430 pub fn set_metrics<T>(mut self, v: T) -> Self
8431 where
8432 T: std::convert::Into<crate::model::AggregatedMetrics>,
8433 {
8434 self.metrics = std::option::Option::Some(v.into());
8435 self
8436 }
8437
8438 /// Sets or clears the value of [metrics][crate::model::ShipmentRoute::metrics].
8439 ///
8440 /// # Example
8441 /// ```ignore,no_run
8442 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8443 /// use google_cloud_optimization_v1::model::AggregatedMetrics;
8444 /// let x = ShipmentRoute::new().set_or_clear_metrics(Some(AggregatedMetrics::default()/* use setters */));
8445 /// let x = ShipmentRoute::new().set_or_clear_metrics(None::<AggregatedMetrics>);
8446 /// ```
8447 pub fn set_or_clear_metrics<T>(mut self, v: std::option::Option<T>) -> Self
8448 where
8449 T: std::convert::Into<crate::model::AggregatedMetrics>,
8450 {
8451 self.metrics = v.map(|x| x.into());
8452 self
8453 }
8454
8455 /// Sets the value of [route_costs][crate::model::ShipmentRoute::route_costs].
8456 ///
8457 /// # Example
8458 /// ```ignore,no_run
8459 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8460 /// let x = ShipmentRoute::new().set_route_costs([
8461 /// ("key0", 123.5),
8462 /// ("key1", 456.5),
8463 /// ]);
8464 /// ```
8465 pub fn set_route_costs<T, K, V>(mut self, v: T) -> Self
8466 where
8467 T: std::iter::IntoIterator<Item = (K, V)>,
8468 K: std::convert::Into<std::string::String>,
8469 V: std::convert::Into<f64>,
8470 {
8471 use std::iter::Iterator;
8472 self.route_costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8473 self
8474 }
8475
8476 /// Sets the value of [route_total_cost][crate::model::ShipmentRoute::route_total_cost].
8477 ///
8478 /// # Example
8479 /// ```ignore,no_run
8480 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8481 /// let x = ShipmentRoute::new().set_route_total_cost(42.0);
8482 /// ```
8483 pub fn set_route_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
8484 self.route_total_cost = v.into();
8485 self
8486 }
8487
8488 /// Sets the value of [end_loads][crate::model::ShipmentRoute::end_loads].
8489 ///
8490 /// # Example
8491 /// ```ignore,no_run
8492 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8493 /// use google_cloud_optimization_v1::model::CapacityQuantity;
8494 /// let x = ShipmentRoute::new()
8495 /// .set_end_loads([
8496 /// CapacityQuantity::default()/* use setters */,
8497 /// CapacityQuantity::default()/* use (different) setters */,
8498 /// ]);
8499 /// ```
8500 #[deprecated]
8501 pub fn set_end_loads<T, V>(mut self, v: T) -> Self
8502 where
8503 T: std::iter::IntoIterator<Item = V>,
8504 V: std::convert::Into<crate::model::CapacityQuantity>,
8505 {
8506 use std::iter::Iterator;
8507 self.end_loads = v.into_iter().map(|i| i.into()).collect();
8508 self
8509 }
8510
8511 /// Sets the value of [travel_steps][crate::model::ShipmentRoute::travel_steps].
8512 ///
8513 /// # Example
8514 /// ```ignore,no_run
8515 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8516 /// use google_cloud_optimization_v1::model::shipment_route::TravelStep;
8517 /// let x = ShipmentRoute::new()
8518 /// .set_travel_steps([
8519 /// TravelStep::default()/* use setters */,
8520 /// TravelStep::default()/* use (different) setters */,
8521 /// ]);
8522 /// ```
8523 #[deprecated]
8524 pub fn set_travel_steps<T, V>(mut self, v: T) -> Self
8525 where
8526 T: std::iter::IntoIterator<Item = V>,
8527 V: std::convert::Into<crate::model::shipment_route::TravelStep>,
8528 {
8529 use std::iter::Iterator;
8530 self.travel_steps = v.into_iter().map(|i| i.into()).collect();
8531 self
8532 }
8533
8534 /// Sets the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8535 ///
8536 /// # Example
8537 /// ```ignore,no_run
8538 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8539 /// use wkt::Duration;
8540 /// let x = ShipmentRoute::new().set_vehicle_detour(Duration::default()/* use setters */);
8541 /// ```
8542 #[deprecated]
8543 pub fn set_vehicle_detour<T>(mut self, v: T) -> Self
8544 where
8545 T: std::convert::Into<wkt::Duration>,
8546 {
8547 self.vehicle_detour = std::option::Option::Some(v.into());
8548 self
8549 }
8550
8551 /// Sets or clears the value of [vehicle_detour][crate::model::ShipmentRoute::vehicle_detour].
8552 ///
8553 /// # Example
8554 /// ```ignore,no_run
8555 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8556 /// use wkt::Duration;
8557 /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(Some(Duration::default()/* use setters */));
8558 /// let x = ShipmentRoute::new().set_or_clear_vehicle_detour(None::<Duration>);
8559 /// ```
8560 #[deprecated]
8561 pub fn set_or_clear_vehicle_detour<T>(mut self, v: std::option::Option<T>) -> Self
8562 where
8563 T: std::convert::Into<wkt::Duration>,
8564 {
8565 self.vehicle_detour = v.map(|x| x.into());
8566 self
8567 }
8568
8569 /// Sets the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8570 ///
8571 /// # Example
8572 /// ```ignore,no_run
8573 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8574 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8575 /// let x = ShipmentRoute::new().set_delay_before_vehicle_end(Delay::default()/* use setters */);
8576 /// ```
8577 #[deprecated]
8578 pub fn set_delay_before_vehicle_end<T>(mut self, v: T) -> Self
8579 where
8580 T: std::convert::Into<crate::model::shipment_route::Delay>,
8581 {
8582 self.delay_before_vehicle_end = std::option::Option::Some(v.into());
8583 self
8584 }
8585
8586 /// Sets or clears the value of [delay_before_vehicle_end][crate::model::ShipmentRoute::delay_before_vehicle_end].
8587 ///
8588 /// # Example
8589 /// ```ignore,no_run
8590 /// # use google_cloud_optimization_v1::model::ShipmentRoute;
8591 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8592 /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(Some(Delay::default()/* use setters */));
8593 /// let x = ShipmentRoute::new().set_or_clear_delay_before_vehicle_end(None::<Delay>);
8594 /// ```
8595 #[deprecated]
8596 pub fn set_or_clear_delay_before_vehicle_end<T>(mut self, v: std::option::Option<T>) -> Self
8597 where
8598 T: std::convert::Into<crate::model::shipment_route::Delay>,
8599 {
8600 self.delay_before_vehicle_end = v.map(|x| x.into());
8601 self
8602 }
8603}
8604
8605impl wkt::message::Message for ShipmentRoute {
8606 fn typename() -> &'static str {
8607 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute"
8608 }
8609}
8610
8611/// Defines additional types related to [ShipmentRoute].
8612pub mod shipment_route {
8613 #[allow(unused_imports)]
8614 use super::*;
8615
8616 /// Deprecated: Use
8617 /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8618 /// instead. Time interval spent on the route resulting from a
8619 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
8620 ///
8621 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8622 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
8623 #[derive(Clone, Default, PartialEq)]
8624 #[non_exhaustive]
8625 #[deprecated]
8626 pub struct Delay {
8627 /// Start of the delay.
8628 pub start_time: std::option::Option<wkt::Timestamp>,
8629
8630 /// Duration of the delay.
8631 pub duration: std::option::Option<wkt::Duration>,
8632
8633 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8634 }
8635
8636 impl Delay {
8637 pub fn new() -> Self {
8638 std::default::Default::default()
8639 }
8640
8641 /// Sets the value of [start_time][crate::model::shipment_route::Delay::start_time].
8642 ///
8643 /// # Example
8644 /// ```ignore,no_run
8645 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8646 /// use wkt::Timestamp;
8647 /// let x = Delay::new().set_start_time(Timestamp::default()/* use setters */);
8648 /// ```
8649 pub fn set_start_time<T>(mut self, v: T) -> Self
8650 where
8651 T: std::convert::Into<wkt::Timestamp>,
8652 {
8653 self.start_time = std::option::Option::Some(v.into());
8654 self
8655 }
8656
8657 /// Sets or clears the value of [start_time][crate::model::shipment_route::Delay::start_time].
8658 ///
8659 /// # Example
8660 /// ```ignore,no_run
8661 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8662 /// use wkt::Timestamp;
8663 /// let x = Delay::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8664 /// let x = Delay::new().set_or_clear_start_time(None::<Timestamp>);
8665 /// ```
8666 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8667 where
8668 T: std::convert::Into<wkt::Timestamp>,
8669 {
8670 self.start_time = v.map(|x| x.into());
8671 self
8672 }
8673
8674 /// Sets the value of [duration][crate::model::shipment_route::Delay::duration].
8675 ///
8676 /// # Example
8677 /// ```ignore,no_run
8678 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8679 /// use wkt::Duration;
8680 /// let x = Delay::new().set_duration(Duration::default()/* use setters */);
8681 /// ```
8682 pub fn set_duration<T>(mut self, v: T) -> Self
8683 where
8684 T: std::convert::Into<wkt::Duration>,
8685 {
8686 self.duration = std::option::Option::Some(v.into());
8687 self
8688 }
8689
8690 /// Sets or clears the value of [duration][crate::model::shipment_route::Delay::duration].
8691 ///
8692 /// # Example
8693 /// ```ignore,no_run
8694 /// # use google_cloud_optimization_v1::model::shipment_route::Delay;
8695 /// use wkt::Duration;
8696 /// let x = Delay::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
8697 /// let x = Delay::new().set_or_clear_duration(None::<Duration>);
8698 /// ```
8699 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
8700 where
8701 T: std::convert::Into<wkt::Duration>,
8702 {
8703 self.duration = v.map(|x| x.into());
8704 self
8705 }
8706 }
8707
8708 impl wkt::message::Message for Delay {
8709 fn typename() -> &'static str {
8710 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Delay"
8711 }
8712 }
8713
8714 /// A visit performed during a route. This visit corresponds to a pickup or a
8715 /// delivery of a `Shipment`.
8716 #[derive(Clone, Default, PartialEq)]
8717 #[non_exhaustive]
8718 pub struct Visit {
8719 /// Index of the `shipments` field in the source
8720 /// [ShipmentModel][google.cloud.optimization.v1.ShipmentModel].
8721 ///
8722 /// [google.cloud.optimization.v1.ShipmentModel]: crate::model::ShipmentModel
8723 pub shipment_index: i32,
8724
8725 /// If true the visit corresponds to a pickup of a `Shipment`. Otherwise, it
8726 /// corresponds to a delivery.
8727 pub is_pickup: bool,
8728
8729 /// Index of `VisitRequest` in either the pickup or delivery field of the
8730 /// `Shipment` (see `is_pickup`).
8731 pub visit_request_index: i32,
8732
8733 /// Time at which the visit starts. Note that the vehicle may arrive earlier
8734 /// than this at the visit location. Times are consistent with the
8735 /// `ShipmentModel`.
8736 pub start_time: std::option::Option<wkt::Timestamp>,
8737
8738 /// Total visit load demand as the sum of the shipment and the visit request
8739 /// `load_demands`. The values are negative if the visit is a delivery.
8740 /// Demands are reported for the same types as the
8741 /// [Transition.loads][google.cloud.optimization.v1.ShipmentRoute.Transition]
8742 /// (see this field).
8743 ///
8744 /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
8745 pub load_demands:
8746 std::collections::HashMap<std::string::String, crate::model::shipment::Load>,
8747
8748 /// Extra detour time due to the shipments visited on the route before the
8749 /// visit and to the potential waiting time induced by time windows.
8750 /// If the visit is a delivery, the detour is computed from the corresponding
8751 /// pickup visit and is equal to:
8752 ///
8753 /// ```norust
8754 /// start_time(delivery) - start_time(pickup)
8755 /// - (duration(pickup) + travel duration from the pickup location
8756 /// to the delivery location).
8757 /// ```
8758 ///
8759 /// Otherwise, it is computed from the vehicle `start_location` and is equal
8760 /// to:
8761 ///
8762 /// ```norust
8763 /// start_time - vehicle_start_time - travel duration from
8764 /// the vehicle's `start_location` to the visit.
8765 /// ```
8766 pub detour: std::option::Option<wkt::Duration>,
8767
8768 /// Copy of the corresponding `Shipment.label`, if specified in the
8769 /// `Shipment`.
8770 pub shipment_label: std::string::String,
8771
8772 /// Copy of the corresponding
8773 /// [VisitRequest.label][google.cloud.optimization.v1.Shipment.VisitRequest.label],
8774 /// if specified in the `VisitRequest`.
8775 ///
8776 /// [google.cloud.optimization.v1.Shipment.VisitRequest.label]: crate::model::shipment::VisitRequest::label
8777 pub visit_label: std::string::String,
8778
8779 /// Deprecated: Use
8780 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
8781 /// instead. Vehicle loads upon arrival at the visit location, for each type
8782 /// specified in
8783 /// [Vehicle.capacities][google.cloud.optimization.v1.Vehicle.capacities],
8784 /// `start_load_intervals`, `end_load_intervals` or `demands`.
8785 ///
8786 /// Exception: we omit loads for quantity types unconstrained by intervals
8787 /// and that don't have any non-zero demand on the route.
8788 ///
8789 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
8790 /// [google.cloud.optimization.v1.Vehicle.capacities]: crate::model::Vehicle::capacities
8791 #[deprecated]
8792 pub arrival_loads: std::vec::Vec<crate::model::CapacityQuantity>,
8793
8794 /// Deprecated: Use
8795 /// [ShipmentRoute.Transition.delay_duration][google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]
8796 /// instead. Delay occurring before the visit starts.
8797 ///
8798 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.delay_duration]: crate::model::shipment_route::Transition::delay_duration
8799 #[deprecated]
8800 pub delay_before_start: std::option::Option<crate::model::shipment_route::Delay>,
8801
8802 /// Deprecated: Use
8803 /// [Visit.load_demands][google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]
8804 /// instead.
8805 ///
8806 /// [google.cloud.optimization.v1.ShipmentRoute.Visit.load_demands]: crate::model::shipment_route::Visit::load_demands
8807 #[deprecated]
8808 pub demands: std::vec::Vec<crate::model::CapacityQuantity>,
8809
8810 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8811 }
8812
8813 impl Visit {
8814 pub fn new() -> Self {
8815 std::default::Default::default()
8816 }
8817
8818 /// Sets the value of [shipment_index][crate::model::shipment_route::Visit::shipment_index].
8819 ///
8820 /// # Example
8821 /// ```ignore,no_run
8822 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8823 /// let x = Visit::new().set_shipment_index(42);
8824 /// ```
8825 pub fn set_shipment_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8826 self.shipment_index = v.into();
8827 self
8828 }
8829
8830 /// Sets the value of [is_pickup][crate::model::shipment_route::Visit::is_pickup].
8831 ///
8832 /// # Example
8833 /// ```ignore,no_run
8834 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8835 /// let x = Visit::new().set_is_pickup(true);
8836 /// ```
8837 pub fn set_is_pickup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8838 self.is_pickup = v.into();
8839 self
8840 }
8841
8842 /// Sets the value of [visit_request_index][crate::model::shipment_route::Visit::visit_request_index].
8843 ///
8844 /// # Example
8845 /// ```ignore,no_run
8846 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8847 /// let x = Visit::new().set_visit_request_index(42);
8848 /// ```
8849 pub fn set_visit_request_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8850 self.visit_request_index = v.into();
8851 self
8852 }
8853
8854 /// Sets the value of [start_time][crate::model::shipment_route::Visit::start_time].
8855 ///
8856 /// # Example
8857 /// ```ignore,no_run
8858 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8859 /// use wkt::Timestamp;
8860 /// let x = Visit::new().set_start_time(Timestamp::default()/* use setters */);
8861 /// ```
8862 pub fn set_start_time<T>(mut self, v: T) -> Self
8863 where
8864 T: std::convert::Into<wkt::Timestamp>,
8865 {
8866 self.start_time = std::option::Option::Some(v.into());
8867 self
8868 }
8869
8870 /// Sets or clears the value of [start_time][crate::model::shipment_route::Visit::start_time].
8871 ///
8872 /// # Example
8873 /// ```ignore,no_run
8874 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8875 /// use wkt::Timestamp;
8876 /// let x = Visit::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
8877 /// let x = Visit::new().set_or_clear_start_time(None::<Timestamp>);
8878 /// ```
8879 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
8880 where
8881 T: std::convert::Into<wkt::Timestamp>,
8882 {
8883 self.start_time = v.map(|x| x.into());
8884 self
8885 }
8886
8887 /// Sets the value of [load_demands][crate::model::shipment_route::Visit::load_demands].
8888 ///
8889 /// # Example
8890 /// ```ignore,no_run
8891 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8892 /// use google_cloud_optimization_v1::model::shipment::Load;
8893 /// let x = Visit::new().set_load_demands([
8894 /// ("key0", Load::default()/* use setters */),
8895 /// ("key1", Load::default()/* use (different) setters */),
8896 /// ]);
8897 /// ```
8898 pub fn set_load_demands<T, K, V>(mut self, v: T) -> Self
8899 where
8900 T: std::iter::IntoIterator<Item = (K, V)>,
8901 K: std::convert::Into<std::string::String>,
8902 V: std::convert::Into<crate::model::shipment::Load>,
8903 {
8904 use std::iter::Iterator;
8905 self.load_demands = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8906 self
8907 }
8908
8909 /// Sets the value of [detour][crate::model::shipment_route::Visit::detour].
8910 ///
8911 /// # Example
8912 /// ```ignore,no_run
8913 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8914 /// use wkt::Duration;
8915 /// let x = Visit::new().set_detour(Duration::default()/* use setters */);
8916 /// ```
8917 pub fn set_detour<T>(mut self, v: T) -> Self
8918 where
8919 T: std::convert::Into<wkt::Duration>,
8920 {
8921 self.detour = std::option::Option::Some(v.into());
8922 self
8923 }
8924
8925 /// Sets or clears the value of [detour][crate::model::shipment_route::Visit::detour].
8926 ///
8927 /// # Example
8928 /// ```ignore,no_run
8929 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8930 /// use wkt::Duration;
8931 /// let x = Visit::new().set_or_clear_detour(Some(Duration::default()/* use setters */));
8932 /// let x = Visit::new().set_or_clear_detour(None::<Duration>);
8933 /// ```
8934 pub fn set_or_clear_detour<T>(mut self, v: std::option::Option<T>) -> Self
8935 where
8936 T: std::convert::Into<wkt::Duration>,
8937 {
8938 self.detour = v.map(|x| x.into());
8939 self
8940 }
8941
8942 /// Sets the value of [shipment_label][crate::model::shipment_route::Visit::shipment_label].
8943 ///
8944 /// # Example
8945 /// ```ignore,no_run
8946 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8947 /// let x = Visit::new().set_shipment_label("example");
8948 /// ```
8949 pub fn set_shipment_label<T: std::convert::Into<std::string::String>>(
8950 mut self,
8951 v: T,
8952 ) -> Self {
8953 self.shipment_label = v.into();
8954 self
8955 }
8956
8957 /// Sets the value of [visit_label][crate::model::shipment_route::Visit::visit_label].
8958 ///
8959 /// # Example
8960 /// ```ignore,no_run
8961 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8962 /// let x = Visit::new().set_visit_label("example");
8963 /// ```
8964 pub fn set_visit_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8965 self.visit_label = v.into();
8966 self
8967 }
8968
8969 /// Sets the value of [arrival_loads][crate::model::shipment_route::Visit::arrival_loads].
8970 ///
8971 /// # Example
8972 /// ```ignore,no_run
8973 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8974 /// use google_cloud_optimization_v1::model::CapacityQuantity;
8975 /// let x = Visit::new()
8976 /// .set_arrival_loads([
8977 /// CapacityQuantity::default()/* use setters */,
8978 /// CapacityQuantity::default()/* use (different) setters */,
8979 /// ]);
8980 /// ```
8981 #[deprecated]
8982 pub fn set_arrival_loads<T, V>(mut self, v: T) -> Self
8983 where
8984 T: std::iter::IntoIterator<Item = V>,
8985 V: std::convert::Into<crate::model::CapacityQuantity>,
8986 {
8987 use std::iter::Iterator;
8988 self.arrival_loads = v.into_iter().map(|i| i.into()).collect();
8989 self
8990 }
8991
8992 /// Sets the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
8993 ///
8994 /// # Example
8995 /// ```ignore,no_run
8996 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
8997 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
8998 /// let x = Visit::new().set_delay_before_start(Delay::default()/* use setters */);
8999 /// ```
9000 #[deprecated]
9001 pub fn set_delay_before_start<T>(mut self, v: T) -> Self
9002 where
9003 T: std::convert::Into<crate::model::shipment_route::Delay>,
9004 {
9005 self.delay_before_start = std::option::Option::Some(v.into());
9006 self
9007 }
9008
9009 /// Sets or clears the value of [delay_before_start][crate::model::shipment_route::Visit::delay_before_start].
9010 ///
9011 /// # Example
9012 /// ```ignore,no_run
9013 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9014 /// use google_cloud_optimization_v1::model::shipment_route::Delay;
9015 /// let x = Visit::new().set_or_clear_delay_before_start(Some(Delay::default()/* use setters */));
9016 /// let x = Visit::new().set_or_clear_delay_before_start(None::<Delay>);
9017 /// ```
9018 #[deprecated]
9019 pub fn set_or_clear_delay_before_start<T>(mut self, v: std::option::Option<T>) -> Self
9020 where
9021 T: std::convert::Into<crate::model::shipment_route::Delay>,
9022 {
9023 self.delay_before_start = v.map(|x| x.into());
9024 self
9025 }
9026
9027 /// Sets the value of [demands][crate::model::shipment_route::Visit::demands].
9028 ///
9029 /// # Example
9030 /// ```ignore,no_run
9031 /// # use google_cloud_optimization_v1::model::shipment_route::Visit;
9032 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9033 /// let x = Visit::new()
9034 /// .set_demands([
9035 /// CapacityQuantity::default()/* use setters */,
9036 /// CapacityQuantity::default()/* use (different) setters */,
9037 /// ]);
9038 /// ```
9039 #[deprecated]
9040 pub fn set_demands<T, V>(mut self, v: T) -> Self
9041 where
9042 T: std::iter::IntoIterator<Item = V>,
9043 V: std::convert::Into<crate::model::CapacityQuantity>,
9044 {
9045 use std::iter::Iterator;
9046 self.demands = v.into_iter().map(|i| i.into()).collect();
9047 self
9048 }
9049 }
9050
9051 impl wkt::message::Message for Visit {
9052 fn typename() -> &'static str {
9053 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Visit"
9054 }
9055 }
9056
9057 /// Transition between two events on the route. See the description of
9058 /// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute].
9059 ///
9060 /// If the vehicle does not have a `start_location` and/or `end_location`, the
9061 /// corresponding travel metrics are 0.
9062 ///
9063 /// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
9064 #[derive(Clone, Default, PartialEq)]
9065 #[non_exhaustive]
9066 pub struct Transition {
9067 /// Travel duration during this transition.
9068 pub travel_duration: std::option::Option<wkt::Duration>,
9069
9070 /// Distance traveled during the transition.
9071 pub travel_distance_meters: f64,
9072
9073 /// When traffic is requested via
9074 /// [OptimizeToursRequest.consider_road_traffic]
9075 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9076 /// and the traffic info couldn't be retrieved for a `Transition`, this
9077 /// boolean is set to true. This may be temporary (rare hiccup in the
9078 /// realtime traffic servers) or permanent (no data for this location).
9079 pub traffic_info_unavailable: bool,
9080
9081 /// Sum of the delay durations applied to this transition. If any, the delay
9082 /// starts exactly `delay_duration` seconds before the next event (visit or
9083 /// vehicle end). See
9084 /// [TransitionAttributes.delay][google.cloud.optimization.v1.TransitionAttributes.delay].
9085 ///
9086 /// [google.cloud.optimization.v1.TransitionAttributes.delay]: crate::model::TransitionAttributes::delay
9087 pub delay_duration: std::option::Option<wkt::Duration>,
9088
9089 /// Sum of the duration of the breaks occurring during this transition, if
9090 /// any. Details about each break's start time and duration are stored in
9091 /// [ShipmentRoute.breaks][google.cloud.optimization.v1.ShipmentRoute.breaks].
9092 ///
9093 /// [google.cloud.optimization.v1.ShipmentRoute.breaks]: crate::model::ShipmentRoute::breaks
9094 pub break_duration: std::option::Option<wkt::Duration>,
9095
9096 /// Time spent waiting during this transition. Wait duration corresponds to
9097 /// idle time and does not include break time. Also note that this wait time
9098 /// may be split into several non-contiguous intervals.
9099 pub wait_duration: std::option::Option<wkt::Duration>,
9100
9101 /// Total duration of the transition, provided for convenience. It is equal
9102 /// to:
9103 ///
9104 /// * next visit `start_time` (or `vehicle_end_time` if this is the last
9105 /// transition) - this transition's `start_time`;
9106 /// * if `ShipmentRoute.has_traffic_infeasibilities` is false, the following
9107 /// additionally holds: `total_duration = travel_duration + delay_duration
9108 ///
9109 /// + break_duration + wait_duration`.
9110 pub total_duration: std::option::Option<wkt::Duration>,
9111
9112 /// Start time of this transition.
9113 pub start_time: std::option::Option<wkt::Timestamp>,
9114
9115 /// The encoded polyline representation of the route followed during the
9116 /// transition.
9117 /// This field is only populated if [populate_transition_polylines]
9118 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_transition_polylines]
9119 /// is set to true.
9120 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9121
9122 /// Vehicle loads during this transition, for each type that either appears
9123 /// in this vehicle's
9124 /// [Vehicle.load_limits][google.cloud.optimization.v1.Vehicle.load_limits],
9125 /// or that have non-zero
9126 /// [Shipment.load_demands][google.cloud.optimization.v1.Shipment.load_demands]
9127 /// on some shipment performed on this route.
9128 ///
9129 /// The loads during the first transition are the starting loads of the
9130 /// vehicle route. Then, after each visit, the visit's `load_demands` are
9131 /// either added or subtracted to get the next transition's loads, depending
9132 /// on whether the visit was a pickup or a delivery.
9133 ///
9134 /// [google.cloud.optimization.v1.Shipment.load_demands]: crate::model::Shipment::load_demands
9135 /// [google.cloud.optimization.v1.Vehicle.load_limits]: crate::model::Vehicle::load_limits
9136 pub vehicle_loads: std::collections::HashMap<
9137 std::string::String,
9138 crate::model::shipment_route::VehicleLoad,
9139 >,
9140
9141 /// Deprecated: Use
9142 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
9143 /// instead.
9144 ///
9145 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9146 #[deprecated]
9147 pub loads: std::vec::Vec<crate::model::CapacityQuantity>,
9148
9149 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9150 }
9151
9152 impl Transition {
9153 pub fn new() -> Self {
9154 std::default::Default::default()
9155 }
9156
9157 /// Sets the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9158 ///
9159 /// # Example
9160 /// ```ignore,no_run
9161 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9162 /// use wkt::Duration;
9163 /// let x = Transition::new().set_travel_duration(Duration::default()/* use setters */);
9164 /// ```
9165 pub fn set_travel_duration<T>(mut self, v: T) -> Self
9166 where
9167 T: std::convert::Into<wkt::Duration>,
9168 {
9169 self.travel_duration = std::option::Option::Some(v.into());
9170 self
9171 }
9172
9173 /// Sets or clears the value of [travel_duration][crate::model::shipment_route::Transition::travel_duration].
9174 ///
9175 /// # Example
9176 /// ```ignore,no_run
9177 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9178 /// use wkt::Duration;
9179 /// let x = Transition::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
9180 /// let x = Transition::new().set_or_clear_travel_duration(None::<Duration>);
9181 /// ```
9182 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
9183 where
9184 T: std::convert::Into<wkt::Duration>,
9185 {
9186 self.travel_duration = v.map(|x| x.into());
9187 self
9188 }
9189
9190 /// Sets the value of [travel_distance_meters][crate::model::shipment_route::Transition::travel_distance_meters].
9191 ///
9192 /// # Example
9193 /// ```ignore,no_run
9194 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9195 /// let x = Transition::new().set_travel_distance_meters(42.0);
9196 /// ```
9197 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9198 self.travel_distance_meters = v.into();
9199 self
9200 }
9201
9202 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::Transition::traffic_info_unavailable].
9203 ///
9204 /// # Example
9205 /// ```ignore,no_run
9206 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9207 /// let x = Transition::new().set_traffic_info_unavailable(true);
9208 /// ```
9209 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9210 self.traffic_info_unavailable = v.into();
9211 self
9212 }
9213
9214 /// Sets the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9215 ///
9216 /// # Example
9217 /// ```ignore,no_run
9218 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9219 /// use wkt::Duration;
9220 /// let x = Transition::new().set_delay_duration(Duration::default()/* use setters */);
9221 /// ```
9222 pub fn set_delay_duration<T>(mut self, v: T) -> Self
9223 where
9224 T: std::convert::Into<wkt::Duration>,
9225 {
9226 self.delay_duration = std::option::Option::Some(v.into());
9227 self
9228 }
9229
9230 /// Sets or clears the value of [delay_duration][crate::model::shipment_route::Transition::delay_duration].
9231 ///
9232 /// # Example
9233 /// ```ignore,no_run
9234 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9235 /// use wkt::Duration;
9236 /// let x = Transition::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
9237 /// let x = Transition::new().set_or_clear_delay_duration(None::<Duration>);
9238 /// ```
9239 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
9240 where
9241 T: std::convert::Into<wkt::Duration>,
9242 {
9243 self.delay_duration = v.map(|x| x.into());
9244 self
9245 }
9246
9247 /// Sets the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9248 ///
9249 /// # Example
9250 /// ```ignore,no_run
9251 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9252 /// use wkt::Duration;
9253 /// let x = Transition::new().set_break_duration(Duration::default()/* use setters */);
9254 /// ```
9255 pub fn set_break_duration<T>(mut self, v: T) -> Self
9256 where
9257 T: std::convert::Into<wkt::Duration>,
9258 {
9259 self.break_duration = std::option::Option::Some(v.into());
9260 self
9261 }
9262
9263 /// Sets or clears the value of [break_duration][crate::model::shipment_route::Transition::break_duration].
9264 ///
9265 /// # Example
9266 /// ```ignore,no_run
9267 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9268 /// use wkt::Duration;
9269 /// let x = Transition::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
9270 /// let x = Transition::new().set_or_clear_break_duration(None::<Duration>);
9271 /// ```
9272 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
9273 where
9274 T: std::convert::Into<wkt::Duration>,
9275 {
9276 self.break_duration = v.map(|x| x.into());
9277 self
9278 }
9279
9280 /// Sets the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9281 ///
9282 /// # Example
9283 /// ```ignore,no_run
9284 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9285 /// use wkt::Duration;
9286 /// let x = Transition::new().set_wait_duration(Duration::default()/* use setters */);
9287 /// ```
9288 pub fn set_wait_duration<T>(mut self, v: T) -> Self
9289 where
9290 T: std::convert::Into<wkt::Duration>,
9291 {
9292 self.wait_duration = std::option::Option::Some(v.into());
9293 self
9294 }
9295
9296 /// Sets or clears the value of [wait_duration][crate::model::shipment_route::Transition::wait_duration].
9297 ///
9298 /// # Example
9299 /// ```ignore,no_run
9300 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9301 /// use wkt::Duration;
9302 /// let x = Transition::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
9303 /// let x = Transition::new().set_or_clear_wait_duration(None::<Duration>);
9304 /// ```
9305 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
9306 where
9307 T: std::convert::Into<wkt::Duration>,
9308 {
9309 self.wait_duration = v.map(|x| x.into());
9310 self
9311 }
9312
9313 /// Sets the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9314 ///
9315 /// # Example
9316 /// ```ignore,no_run
9317 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9318 /// use wkt::Duration;
9319 /// let x = Transition::new().set_total_duration(Duration::default()/* use setters */);
9320 /// ```
9321 pub fn set_total_duration<T>(mut self, v: T) -> Self
9322 where
9323 T: std::convert::Into<wkt::Duration>,
9324 {
9325 self.total_duration = std::option::Option::Some(v.into());
9326 self
9327 }
9328
9329 /// Sets or clears the value of [total_duration][crate::model::shipment_route::Transition::total_duration].
9330 ///
9331 /// # Example
9332 /// ```ignore,no_run
9333 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9334 /// use wkt::Duration;
9335 /// let x = Transition::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
9336 /// let x = Transition::new().set_or_clear_total_duration(None::<Duration>);
9337 /// ```
9338 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
9339 where
9340 T: std::convert::Into<wkt::Duration>,
9341 {
9342 self.total_duration = v.map(|x| x.into());
9343 self
9344 }
9345
9346 /// Sets the value of [start_time][crate::model::shipment_route::Transition::start_time].
9347 ///
9348 /// # Example
9349 /// ```ignore,no_run
9350 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9351 /// use wkt::Timestamp;
9352 /// let x = Transition::new().set_start_time(Timestamp::default()/* use setters */);
9353 /// ```
9354 pub fn set_start_time<T>(mut self, v: T) -> Self
9355 where
9356 T: std::convert::Into<wkt::Timestamp>,
9357 {
9358 self.start_time = std::option::Option::Some(v.into());
9359 self
9360 }
9361
9362 /// Sets or clears the value of [start_time][crate::model::shipment_route::Transition::start_time].
9363 ///
9364 /// # Example
9365 /// ```ignore,no_run
9366 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9367 /// use wkt::Timestamp;
9368 /// let x = Transition::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9369 /// let x = Transition::new().set_or_clear_start_time(None::<Timestamp>);
9370 /// ```
9371 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9372 where
9373 T: std::convert::Into<wkt::Timestamp>,
9374 {
9375 self.start_time = v.map(|x| x.into());
9376 self
9377 }
9378
9379 /// Sets the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9380 ///
9381 /// # Example
9382 /// ```ignore,no_run
9383 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9384 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9385 /// let x = Transition::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9386 /// ```
9387 pub fn set_route_polyline<T>(mut self, v: T) -> Self
9388 where
9389 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9390 {
9391 self.route_polyline = std::option::Option::Some(v.into());
9392 self
9393 }
9394
9395 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::Transition::route_polyline].
9396 ///
9397 /// # Example
9398 /// ```ignore,no_run
9399 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9400 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9401 /// let x = Transition::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9402 /// let x = Transition::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9403 /// ```
9404 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9405 where
9406 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9407 {
9408 self.route_polyline = v.map(|x| x.into());
9409 self
9410 }
9411
9412 /// Sets the value of [vehicle_loads][crate::model::shipment_route::Transition::vehicle_loads].
9413 ///
9414 /// # Example
9415 /// ```ignore,no_run
9416 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9417 /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9418 /// let x = Transition::new().set_vehicle_loads([
9419 /// ("key0", VehicleLoad::default()/* use setters */),
9420 /// ("key1", VehicleLoad::default()/* use (different) setters */),
9421 /// ]);
9422 /// ```
9423 pub fn set_vehicle_loads<T, K, V>(mut self, v: T) -> Self
9424 where
9425 T: std::iter::IntoIterator<Item = (K, V)>,
9426 K: std::convert::Into<std::string::String>,
9427 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
9428 {
9429 use std::iter::Iterator;
9430 self.vehicle_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
9431 self
9432 }
9433
9434 /// Sets the value of [loads][crate::model::shipment_route::Transition::loads].
9435 ///
9436 /// # Example
9437 /// ```ignore,no_run
9438 /// # use google_cloud_optimization_v1::model::shipment_route::Transition;
9439 /// use google_cloud_optimization_v1::model::CapacityQuantity;
9440 /// let x = Transition::new()
9441 /// .set_loads([
9442 /// CapacityQuantity::default()/* use setters */,
9443 /// CapacityQuantity::default()/* use (different) setters */,
9444 /// ]);
9445 /// ```
9446 #[deprecated]
9447 pub fn set_loads<T, V>(mut self, v: T) -> Self
9448 where
9449 T: std::iter::IntoIterator<Item = V>,
9450 V: std::convert::Into<crate::model::CapacityQuantity>,
9451 {
9452 use std::iter::Iterator;
9453 self.loads = v.into_iter().map(|i| i.into()).collect();
9454 self
9455 }
9456 }
9457
9458 impl wkt::message::Message for Transition {
9459 fn typename() -> &'static str {
9460 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Transition"
9461 }
9462 }
9463
9464 /// Reports the actual load of the vehicle at some point along the route,
9465 /// for a given type (see
9466 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]).
9467 ///
9468 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9469 #[derive(Clone, Default, PartialEq)]
9470 #[non_exhaustive]
9471 pub struct VehicleLoad {
9472 /// The amount of load on the vehicle, for the given type. The unit of load
9473 /// is usually indicated by the type. See
9474 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads].
9475 ///
9476 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
9477 pub amount: i64,
9478
9479 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9480 }
9481
9482 impl VehicleLoad {
9483 pub fn new() -> Self {
9484 std::default::Default::default()
9485 }
9486
9487 /// Sets the value of [amount][crate::model::shipment_route::VehicleLoad::amount].
9488 ///
9489 /// # Example
9490 /// ```ignore,no_run
9491 /// # use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
9492 /// let x = VehicleLoad::new().set_amount(42);
9493 /// ```
9494 pub fn set_amount<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
9495 self.amount = v.into();
9496 self
9497 }
9498 }
9499
9500 impl wkt::message::Message for VehicleLoad {
9501 fn typename() -> &'static str {
9502 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.VehicleLoad"
9503 }
9504 }
9505
9506 /// The encoded representation of a polyline. More information on polyline
9507 /// encoding can be found here:
9508 /// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
9509 /// <https://developers.google.com/maps/documentation/javascript/reference/geometry#encoding>.
9510 #[derive(Clone, Default, PartialEq)]
9511 #[non_exhaustive]
9512 pub struct EncodedPolyline {
9513 /// String representing encoded points of the polyline.
9514 pub points: std::string::String,
9515
9516 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9517 }
9518
9519 impl EncodedPolyline {
9520 pub fn new() -> Self {
9521 std::default::Default::default()
9522 }
9523
9524 /// Sets the value of [points][crate::model::shipment_route::EncodedPolyline::points].
9525 ///
9526 /// # Example
9527 /// ```ignore,no_run
9528 /// # use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9529 /// let x = EncodedPolyline::new().set_points("example");
9530 /// ```
9531 pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9532 self.points = v.into();
9533 self
9534 }
9535 }
9536
9537 impl wkt::message::Message for EncodedPolyline {
9538 fn typename() -> &'static str {
9539 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.EncodedPolyline"
9540 }
9541 }
9542
9543 /// Data representing the execution of a break.
9544 #[derive(Clone, Default, PartialEq)]
9545 #[non_exhaustive]
9546 pub struct Break {
9547 /// Start time of a break.
9548 pub start_time: std::option::Option<wkt::Timestamp>,
9549
9550 /// Duration of a break.
9551 pub duration: std::option::Option<wkt::Duration>,
9552
9553 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9554 }
9555
9556 impl Break {
9557 pub fn new() -> Self {
9558 std::default::Default::default()
9559 }
9560
9561 /// Sets the value of [start_time][crate::model::shipment_route::Break::start_time].
9562 ///
9563 /// # Example
9564 /// ```ignore,no_run
9565 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9566 /// use wkt::Timestamp;
9567 /// let x = Break::new().set_start_time(Timestamp::default()/* use setters */);
9568 /// ```
9569 pub fn set_start_time<T>(mut self, v: T) -> Self
9570 where
9571 T: std::convert::Into<wkt::Timestamp>,
9572 {
9573 self.start_time = std::option::Option::Some(v.into());
9574 self
9575 }
9576
9577 /// Sets or clears the value of [start_time][crate::model::shipment_route::Break::start_time].
9578 ///
9579 /// # Example
9580 /// ```ignore,no_run
9581 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9582 /// use wkt::Timestamp;
9583 /// let x = Break::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
9584 /// let x = Break::new().set_or_clear_start_time(None::<Timestamp>);
9585 /// ```
9586 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
9587 where
9588 T: std::convert::Into<wkt::Timestamp>,
9589 {
9590 self.start_time = v.map(|x| x.into());
9591 self
9592 }
9593
9594 /// Sets the value of [duration][crate::model::shipment_route::Break::duration].
9595 ///
9596 /// # Example
9597 /// ```ignore,no_run
9598 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9599 /// use wkt::Duration;
9600 /// let x = Break::new().set_duration(Duration::default()/* use setters */);
9601 /// ```
9602 pub fn set_duration<T>(mut self, v: T) -> Self
9603 where
9604 T: std::convert::Into<wkt::Duration>,
9605 {
9606 self.duration = std::option::Option::Some(v.into());
9607 self
9608 }
9609
9610 /// Sets or clears the value of [duration][crate::model::shipment_route::Break::duration].
9611 ///
9612 /// # Example
9613 /// ```ignore,no_run
9614 /// # use google_cloud_optimization_v1::model::shipment_route::Break;
9615 /// use wkt::Duration;
9616 /// let x = Break::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9617 /// let x = Break::new().set_or_clear_duration(None::<Duration>);
9618 /// ```
9619 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9620 where
9621 T: std::convert::Into<wkt::Duration>,
9622 {
9623 self.duration = v.map(|x| x.into());
9624 self
9625 }
9626 }
9627
9628 impl wkt::message::Message for Break {
9629 fn typename() -> &'static str {
9630 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.Break"
9631 }
9632 }
9633
9634 /// Deprecated: Use
9635 /// [ShipmentRoute.Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
9636 /// instead. Travel between each visit along the route: from the vehicle's
9637 /// `start_location` to the first visit's `arrival_location`, then from the
9638 /// first visit's `departure_location` to the second visit's
9639 /// `arrival_location`, and so on until the vehicle's `end_location`. This
9640 /// accounts only for the actual travel between visits, not counting the
9641 /// waiting time, the time spent performing a visit, nor the distance covered
9642 /// during a visit.
9643 ///
9644 /// Invariant: `travel_steps_size() == visits_size() + 1`.
9645 ///
9646 /// If the vehicle does not have a start_ and/or end_location, the
9647 /// corresponding travel metrics are 0 and/or empty.
9648 ///
9649 /// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
9650 #[derive(Clone, Default, PartialEq)]
9651 #[non_exhaustive]
9652 #[deprecated]
9653 pub struct TravelStep {
9654 /// Duration of the travel step.
9655 pub duration: std::option::Option<wkt::Duration>,
9656
9657 /// Distance traveled during the step.
9658 pub distance_meters: f64,
9659
9660 /// When traffic is requested via
9661 /// [OptimizeToursRequest.consider_road_traffic][google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic],
9662 /// and the traffic info couldn't be retrieved for a TravelStep, this boolean
9663 /// is set to true. This may be temporary (rare hiccup in the realtime
9664 /// traffic servers) or permanent (no data for this location).
9665 ///
9666 /// [google.cloud.optimization.v1.OptimizeToursRequest.consider_road_traffic]: crate::model::OptimizeToursRequest::consider_road_traffic
9667 pub traffic_info_unavailable: bool,
9668
9669 /// The encoded polyline representation of the route followed during the
9670 /// step.
9671 ///
9672 /// This field is only populated if
9673 /// [OptimizeToursRequest.populate_travel_step_polylines][google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]
9674 /// is set to true.
9675 ///
9676 /// [google.cloud.optimization.v1.OptimizeToursRequest.populate_travel_step_polylines]: crate::model::OptimizeToursRequest::populate_travel_step_polylines
9677 pub route_polyline: std::option::Option<crate::model::shipment_route::EncodedPolyline>,
9678
9679 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9680 }
9681
9682 impl TravelStep {
9683 pub fn new() -> Self {
9684 std::default::Default::default()
9685 }
9686
9687 /// Sets the value of [duration][crate::model::shipment_route::TravelStep::duration].
9688 ///
9689 /// # Example
9690 /// ```ignore,no_run
9691 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9692 /// use wkt::Duration;
9693 /// let x = TravelStep::new().set_duration(Duration::default()/* use setters */);
9694 /// ```
9695 pub fn set_duration<T>(mut self, v: T) -> Self
9696 where
9697 T: std::convert::Into<wkt::Duration>,
9698 {
9699 self.duration = std::option::Option::Some(v.into());
9700 self
9701 }
9702
9703 /// Sets or clears the value of [duration][crate::model::shipment_route::TravelStep::duration].
9704 ///
9705 /// # Example
9706 /// ```ignore,no_run
9707 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9708 /// use wkt::Duration;
9709 /// let x = TravelStep::new().set_or_clear_duration(Some(Duration::default()/* use setters */));
9710 /// let x = TravelStep::new().set_or_clear_duration(None::<Duration>);
9711 /// ```
9712 pub fn set_or_clear_duration<T>(mut self, v: std::option::Option<T>) -> Self
9713 where
9714 T: std::convert::Into<wkt::Duration>,
9715 {
9716 self.duration = v.map(|x| x.into());
9717 self
9718 }
9719
9720 /// Sets the value of [distance_meters][crate::model::shipment_route::TravelStep::distance_meters].
9721 ///
9722 /// # Example
9723 /// ```ignore,no_run
9724 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9725 /// let x = TravelStep::new().set_distance_meters(42.0);
9726 /// ```
9727 pub fn set_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
9728 self.distance_meters = v.into();
9729 self
9730 }
9731
9732 /// Sets the value of [traffic_info_unavailable][crate::model::shipment_route::TravelStep::traffic_info_unavailable].
9733 ///
9734 /// # Example
9735 /// ```ignore,no_run
9736 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9737 /// let x = TravelStep::new().set_traffic_info_unavailable(true);
9738 /// ```
9739 pub fn set_traffic_info_unavailable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9740 self.traffic_info_unavailable = v.into();
9741 self
9742 }
9743
9744 /// Sets the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9745 ///
9746 /// # Example
9747 /// ```ignore,no_run
9748 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9749 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9750 /// let x = TravelStep::new().set_route_polyline(EncodedPolyline::default()/* use setters */);
9751 /// ```
9752 pub fn set_route_polyline<T>(mut self, v: T) -> Self
9753 where
9754 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9755 {
9756 self.route_polyline = std::option::Option::Some(v.into());
9757 self
9758 }
9759
9760 /// Sets or clears the value of [route_polyline][crate::model::shipment_route::TravelStep::route_polyline].
9761 ///
9762 /// # Example
9763 /// ```ignore,no_run
9764 /// # use google_cloud_optimization_v1::model::shipment_route::TravelStep;
9765 /// use google_cloud_optimization_v1::model::shipment_route::EncodedPolyline;
9766 /// let x = TravelStep::new().set_or_clear_route_polyline(Some(EncodedPolyline::default()/* use setters */));
9767 /// let x = TravelStep::new().set_or_clear_route_polyline(None::<EncodedPolyline>);
9768 /// ```
9769 pub fn set_or_clear_route_polyline<T>(mut self, v: std::option::Option<T>) -> Self
9770 where
9771 T: std::convert::Into<crate::model::shipment_route::EncodedPolyline>,
9772 {
9773 self.route_polyline = v.map(|x| x.into());
9774 self
9775 }
9776 }
9777
9778 impl wkt::message::Message for TravelStep {
9779 fn typename() -> &'static str {
9780 "type.googleapis.com/google.cloud.optimization.v1.ShipmentRoute.TravelStep"
9781 }
9782 }
9783}
9784
9785/// Specifies details of unperformed shipments in a solution. For trivial cases
9786/// and/or if we are able to identify the cause for skipping, we report the
9787/// reason here.
9788#[derive(Clone, Default, PartialEq)]
9789#[non_exhaustive]
9790pub struct SkippedShipment {
9791 /// The index corresponds to the index of the shipment in the source
9792 /// `ShipmentModel`.
9793 pub index: i32,
9794
9795 /// Copy of the corresponding
9796 /// [Shipment.label][google.cloud.optimization.v1.Shipment.label], if specified
9797 /// in the `Shipment`.
9798 ///
9799 /// [google.cloud.optimization.v1.Shipment.label]: crate::model::Shipment::label
9800 pub label: std::string::String,
9801
9802 /// A list of reasons that explain why the shipment was skipped. See comment
9803 /// above `Reason`.
9804 pub reasons: std::vec::Vec<crate::model::skipped_shipment::Reason>,
9805
9806 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9807}
9808
9809impl SkippedShipment {
9810 pub fn new() -> Self {
9811 std::default::Default::default()
9812 }
9813
9814 /// Sets the value of [index][crate::model::SkippedShipment::index].
9815 ///
9816 /// # Example
9817 /// ```ignore,no_run
9818 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9819 /// let x = SkippedShipment::new().set_index(42);
9820 /// ```
9821 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9822 self.index = v.into();
9823 self
9824 }
9825
9826 /// Sets the value of [label][crate::model::SkippedShipment::label].
9827 ///
9828 /// # Example
9829 /// ```ignore,no_run
9830 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9831 /// let x = SkippedShipment::new().set_label("example");
9832 /// ```
9833 pub fn set_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9834 self.label = v.into();
9835 self
9836 }
9837
9838 /// Sets the value of [reasons][crate::model::SkippedShipment::reasons].
9839 ///
9840 /// # Example
9841 /// ```ignore,no_run
9842 /// # use google_cloud_optimization_v1::model::SkippedShipment;
9843 /// use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9844 /// let x = SkippedShipment::new()
9845 /// .set_reasons([
9846 /// Reason::default()/* use setters */,
9847 /// Reason::default()/* use (different) setters */,
9848 /// ]);
9849 /// ```
9850 pub fn set_reasons<T, V>(mut self, v: T) -> Self
9851 where
9852 T: std::iter::IntoIterator<Item = V>,
9853 V: std::convert::Into<crate::model::skipped_shipment::Reason>,
9854 {
9855 use std::iter::Iterator;
9856 self.reasons = v.into_iter().map(|i| i.into()).collect();
9857 self
9858 }
9859}
9860
9861impl wkt::message::Message for SkippedShipment {
9862 fn typename() -> &'static str {
9863 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment"
9864 }
9865}
9866
9867/// Defines additional types related to [SkippedShipment].
9868pub mod skipped_shipment {
9869 #[allow(unused_imports)]
9870 use super::*;
9871
9872 /// If we can explain why the shipment was skipped, reasons will be listed
9873 /// here. If the reason is not the same for all vehicles, `reason` will have
9874 /// more than 1 element. A skipped shipment cannot have duplicate reasons,
9875 /// i.e. where all fields are the same except for `example_vehicle_index`.
9876 /// Example:
9877 ///
9878 /// ```norust
9879 /// reasons {
9880 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9881 /// example_vehicle_index: 1
9882 /// example_exceeded_capacity_type: "Apples"
9883 /// }
9884 /// reasons {
9885 /// code: DEMAND_EXCEEDS_VEHICLE_CAPACITY
9886 /// example_vehicle_index: 3
9887 /// example_exceeded_capacity_type: "Pears"
9888 /// }
9889 /// reasons {
9890 /// code: CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT
9891 /// example_vehicle_index: 1
9892 /// }
9893 /// ```
9894 ///
9895 /// The skipped shipment is incompatible with all vehicles. The reasons may
9896 /// be different for all vehicles but at least one vehicle's "Apples"
9897 /// capacity would be exceeded (including vehicle 1), at least one vehicle's
9898 /// "Pears" capacity would be exceeded (including vehicle 3) and at least one
9899 /// vehicle's distance limit would be exceeded (including vehicle 1).
9900 #[derive(Clone, Default, PartialEq)]
9901 #[non_exhaustive]
9902 pub struct Reason {
9903 /// Refer to the comments of Code.
9904 pub code: crate::model::skipped_shipment::reason::Code,
9905
9906 /// If the reason is related to a shipment-vehicle incompatibility, this
9907 /// field provides the index of one relevant vehicle.
9908 pub example_vehicle_index: std::option::Option<i32>,
9909
9910 /// If the reason code is `DEMAND_EXCEEDS_VEHICLE_CAPACITY`, documents one
9911 /// capacity type that is exceeded.
9912 pub example_exceeded_capacity_type: std::string::String,
9913
9914 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9915 }
9916
9917 impl Reason {
9918 pub fn new() -> Self {
9919 std::default::Default::default()
9920 }
9921
9922 /// Sets the value of [code][crate::model::skipped_shipment::Reason::code].
9923 ///
9924 /// # Example
9925 /// ```ignore,no_run
9926 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9927 /// use google_cloud_optimization_v1::model::skipped_shipment::reason::Code;
9928 /// let x0 = Reason::new().set_code(Code::NoVehicle);
9929 /// let x1 = Reason::new().set_code(Code::DemandExceedsVehicleCapacity);
9930 /// let x2 = Reason::new().set_code(Code::CannotBePerformedWithinVehicleDistanceLimit);
9931 /// ```
9932 pub fn set_code<T: std::convert::Into<crate::model::skipped_shipment::reason::Code>>(
9933 mut self,
9934 v: T,
9935 ) -> Self {
9936 self.code = v.into();
9937 self
9938 }
9939
9940 /// Sets the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9941 ///
9942 /// # Example
9943 /// ```ignore,no_run
9944 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9945 /// let x = Reason::new().set_example_vehicle_index(42);
9946 /// ```
9947 pub fn set_example_vehicle_index<T>(mut self, v: T) -> Self
9948 where
9949 T: std::convert::Into<i32>,
9950 {
9951 self.example_vehicle_index = std::option::Option::Some(v.into());
9952 self
9953 }
9954
9955 /// Sets or clears the value of [example_vehicle_index][crate::model::skipped_shipment::Reason::example_vehicle_index].
9956 ///
9957 /// # Example
9958 /// ```ignore,no_run
9959 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9960 /// let x = Reason::new().set_or_clear_example_vehicle_index(Some(42));
9961 /// let x = Reason::new().set_or_clear_example_vehicle_index(None::<i32>);
9962 /// ```
9963 pub fn set_or_clear_example_vehicle_index<T>(mut self, v: std::option::Option<T>) -> Self
9964 where
9965 T: std::convert::Into<i32>,
9966 {
9967 self.example_vehicle_index = v.map(|x| x.into());
9968 self
9969 }
9970
9971 /// Sets the value of [example_exceeded_capacity_type][crate::model::skipped_shipment::Reason::example_exceeded_capacity_type].
9972 ///
9973 /// # Example
9974 /// ```ignore,no_run
9975 /// # use google_cloud_optimization_v1::model::skipped_shipment::Reason;
9976 /// let x = Reason::new().set_example_exceeded_capacity_type("example");
9977 /// ```
9978 pub fn set_example_exceeded_capacity_type<T: std::convert::Into<std::string::String>>(
9979 mut self,
9980 v: T,
9981 ) -> Self {
9982 self.example_exceeded_capacity_type = v.into();
9983 self
9984 }
9985 }
9986
9987 impl wkt::message::Message for Reason {
9988 fn typename() -> &'static str {
9989 "type.googleapis.com/google.cloud.optimization.v1.SkippedShipment.Reason"
9990 }
9991 }
9992
9993 /// Defines additional types related to [Reason].
9994 pub mod reason {
9995 #[allow(unused_imports)]
9996 use super::*;
9997
9998 /// Code identifying the reason type. The order here is meaningless. In
9999 /// particular, it gives no indication of whether a given reason will
10000 /// appear before another in the solution, if both apply.
10001 ///
10002 /// # Working with unknown values
10003 ///
10004 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10005 /// additional enum variants at any time. Adding new variants is not considered
10006 /// a breaking change. Applications should write their code in anticipation of:
10007 ///
10008 /// - New values appearing in future releases of the client library, **and**
10009 /// - New values received dynamically, without application changes.
10010 ///
10011 /// Please consult the [Working with enums] section in the user guide for some
10012 /// guidelines.
10013 ///
10014 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10015 #[derive(Clone, Debug, PartialEq)]
10016 #[non_exhaustive]
10017 pub enum Code {
10018 /// This should never be used. If we are unable to understand why a
10019 /// shipment was skipped, we simply return an empty set of reasons.
10020 Unspecified,
10021 /// There is no vehicle in the model making all shipments infeasible.
10022 NoVehicle,
10023 /// The demand of the shipment exceeds a vehicle's capacity for some
10024 /// capacity types, one of which is `example_exceeded_capacity_type`.
10025 DemandExceedsVehicleCapacity,
10026 /// The minimum distance necessary to perform this shipment, i.e. from
10027 /// the vehicle's `start_location` to the shipment's pickup and/or delivery
10028 /// locations and to the vehicle's end location exceeds the vehicle's
10029 /// `route_distance_limit`.
10030 ///
10031 /// Note that for this computation we use the geodesic distances.
10032 CannotBePerformedWithinVehicleDistanceLimit,
10033 /// The minimum time necessary to perform this shipment, including travel
10034 /// time, wait time and service time exceeds the vehicle's
10035 /// `route_duration_limit`.
10036 ///
10037 /// Note: travel time is computed in the best-case scenario, namely as
10038 /// geodesic distance x 36 m/s (roughly 130 km/hour).
10039 CannotBePerformedWithinVehicleDurationLimit,
10040 /// Same as above but we only compare minimum travel time and the
10041 /// vehicle's `travel_duration_limit`.
10042 CannotBePerformedWithinVehicleTravelDurationLimit,
10043 /// The vehicle cannot perform this shipment in the best-case scenario
10044 /// (see `CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT` for time
10045 /// computation) if it starts at its earliest start time: the total time
10046 /// would make the vehicle end after its latest end time.
10047 CannotBePerformedWithinVehicleTimeWindows,
10048 /// The `allowed_vehicle_indices` field of the shipment is not empty and
10049 /// this vehicle does not belong to it.
10050 VehicleNotAllowed,
10051 /// If set, the enum was initialized with an unknown value.
10052 ///
10053 /// Applications can examine the value using [Code::value] or
10054 /// [Code::name].
10055 UnknownValue(code::UnknownValue),
10056 }
10057
10058 #[doc(hidden)]
10059 pub mod code {
10060 #[allow(unused_imports)]
10061 use super::*;
10062 #[derive(Clone, Debug, PartialEq)]
10063 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10064 }
10065
10066 impl Code {
10067 /// Gets the enum value.
10068 ///
10069 /// Returns `None` if the enum contains an unknown value deserialized from
10070 /// the string representation of enums.
10071 pub fn value(&self) -> std::option::Option<i32> {
10072 match self {
10073 Self::Unspecified => std::option::Option::Some(0),
10074 Self::NoVehicle => std::option::Option::Some(1),
10075 Self::DemandExceedsVehicleCapacity => std::option::Option::Some(2),
10076 Self::CannotBePerformedWithinVehicleDistanceLimit => {
10077 std::option::Option::Some(3)
10078 }
10079 Self::CannotBePerformedWithinVehicleDurationLimit => {
10080 std::option::Option::Some(4)
10081 }
10082 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10083 std::option::Option::Some(5)
10084 }
10085 Self::CannotBePerformedWithinVehicleTimeWindows => std::option::Option::Some(6),
10086 Self::VehicleNotAllowed => std::option::Option::Some(7),
10087 Self::UnknownValue(u) => u.0.value(),
10088 }
10089 }
10090
10091 /// Gets the enum value as a string.
10092 ///
10093 /// Returns `None` if the enum contains an unknown value deserialized from
10094 /// the integer representation of enums.
10095 pub fn name(&self) -> std::option::Option<&str> {
10096 match self {
10097 Self::Unspecified => std::option::Option::Some("CODE_UNSPECIFIED"),
10098 Self::NoVehicle => std::option::Option::Some("NO_VEHICLE"),
10099 Self::DemandExceedsVehicleCapacity => {
10100 std::option::Option::Some("DEMAND_EXCEEDS_VEHICLE_CAPACITY")
10101 }
10102 Self::CannotBePerformedWithinVehicleDistanceLimit => std::option::Option::Some(
10103 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT",
10104 ),
10105 Self::CannotBePerformedWithinVehicleDurationLimit => std::option::Option::Some(
10106 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT",
10107 ),
10108 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10109 std::option::Option::Some(
10110 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT",
10111 )
10112 }
10113 Self::CannotBePerformedWithinVehicleTimeWindows => {
10114 std::option::Option::Some("CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS")
10115 }
10116 Self::VehicleNotAllowed => std::option::Option::Some("VEHICLE_NOT_ALLOWED"),
10117 Self::UnknownValue(u) => u.0.name(),
10118 }
10119 }
10120 }
10121
10122 impl std::default::Default for Code {
10123 fn default() -> Self {
10124 use std::convert::From;
10125 Self::from(0)
10126 }
10127 }
10128
10129 impl std::fmt::Display for Code {
10130 fn fmt(
10131 &self,
10132 f: &mut std::fmt::Formatter<'_>,
10133 ) -> std::result::Result<(), std::fmt::Error> {
10134 wkt::internal::display_enum(f, self.name(), self.value())
10135 }
10136 }
10137
10138 impl std::convert::From<i32> for Code {
10139 fn from(value: i32) -> Self {
10140 match value {
10141 0 => Self::Unspecified,
10142 1 => Self::NoVehicle,
10143 2 => Self::DemandExceedsVehicleCapacity,
10144 3 => Self::CannotBePerformedWithinVehicleDistanceLimit,
10145 4 => Self::CannotBePerformedWithinVehicleDurationLimit,
10146 5 => Self::CannotBePerformedWithinVehicleTravelDurationLimit,
10147 6 => Self::CannotBePerformedWithinVehicleTimeWindows,
10148 7 => Self::VehicleNotAllowed,
10149 _ => Self::UnknownValue(code::UnknownValue(
10150 wkt::internal::UnknownEnumValue::Integer(value),
10151 )),
10152 }
10153 }
10154 }
10155
10156 impl std::convert::From<&str> for Code {
10157 fn from(value: &str) -> Self {
10158 use std::string::ToString;
10159 match value {
10160 "CODE_UNSPECIFIED" => Self::Unspecified,
10161 "NO_VEHICLE" => Self::NoVehicle,
10162 "DEMAND_EXCEEDS_VEHICLE_CAPACITY" => Self::DemandExceedsVehicleCapacity,
10163 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DISTANCE_LIMIT" => {
10164 Self::CannotBePerformedWithinVehicleDistanceLimit
10165 }
10166 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_DURATION_LIMIT" => {
10167 Self::CannotBePerformedWithinVehicleDurationLimit
10168 }
10169 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TRAVEL_DURATION_LIMIT" => {
10170 Self::CannotBePerformedWithinVehicleTravelDurationLimit
10171 }
10172 "CANNOT_BE_PERFORMED_WITHIN_VEHICLE_TIME_WINDOWS" => {
10173 Self::CannotBePerformedWithinVehicleTimeWindows
10174 }
10175 "VEHICLE_NOT_ALLOWED" => Self::VehicleNotAllowed,
10176 _ => Self::UnknownValue(code::UnknownValue(
10177 wkt::internal::UnknownEnumValue::String(value.to_string()),
10178 )),
10179 }
10180 }
10181 }
10182
10183 impl serde::ser::Serialize for Code {
10184 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10185 where
10186 S: serde::Serializer,
10187 {
10188 match self {
10189 Self::Unspecified => serializer.serialize_i32(0),
10190 Self::NoVehicle => serializer.serialize_i32(1),
10191 Self::DemandExceedsVehicleCapacity => serializer.serialize_i32(2),
10192 Self::CannotBePerformedWithinVehicleDistanceLimit => {
10193 serializer.serialize_i32(3)
10194 }
10195 Self::CannotBePerformedWithinVehicleDurationLimit => {
10196 serializer.serialize_i32(4)
10197 }
10198 Self::CannotBePerformedWithinVehicleTravelDurationLimit => {
10199 serializer.serialize_i32(5)
10200 }
10201 Self::CannotBePerformedWithinVehicleTimeWindows => serializer.serialize_i32(6),
10202 Self::VehicleNotAllowed => serializer.serialize_i32(7),
10203 Self::UnknownValue(u) => u.0.serialize(serializer),
10204 }
10205 }
10206 }
10207
10208 impl<'de> serde::de::Deserialize<'de> for Code {
10209 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10210 where
10211 D: serde::Deserializer<'de>,
10212 {
10213 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
10214 ".google.cloud.optimization.v1.SkippedShipment.Reason.Code",
10215 ))
10216 }
10217 }
10218 }
10219}
10220
10221/// Aggregated metrics for
10222/// [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute] (resp. for
10223/// [OptimizeToursResponse][google.cloud.optimization.v1.OptimizeToursResponse]
10224/// over all [Transition][google.cloud.optimization.v1.ShipmentRoute.Transition]
10225/// and/or [Visit][google.cloud.optimization.v1.ShipmentRoute.Visit] (resp. over
10226/// all [ShipmentRoute][google.cloud.optimization.v1.ShipmentRoute]) elements.
10227///
10228/// [google.cloud.optimization.v1.OptimizeToursResponse]: crate::model::OptimizeToursResponse
10229/// [google.cloud.optimization.v1.ShipmentRoute]: crate::model::ShipmentRoute
10230/// [google.cloud.optimization.v1.ShipmentRoute.Transition]: crate::model::shipment_route::Transition
10231/// [google.cloud.optimization.v1.ShipmentRoute.Visit]: crate::model::shipment_route::Visit
10232#[derive(Clone, Default, PartialEq)]
10233#[non_exhaustive]
10234pub struct AggregatedMetrics {
10235 /// Number of shipments performed. Note that a pickup and delivery pair only
10236 /// counts once.
10237 pub performed_shipment_count: i32,
10238
10239 /// Total travel duration for a route or a solution.
10240 pub travel_duration: std::option::Option<wkt::Duration>,
10241
10242 /// Total wait duration for a route or a solution.
10243 pub wait_duration: std::option::Option<wkt::Duration>,
10244
10245 /// Total delay duration for a route or a solution.
10246 pub delay_duration: std::option::Option<wkt::Duration>,
10247
10248 /// Total break duration for a route or a solution.
10249 pub break_duration: std::option::Option<wkt::Duration>,
10250
10251 /// Total visit duration for a route or a solution.
10252 pub visit_duration: std::option::Option<wkt::Duration>,
10253
10254 /// The total duration should be equal to the sum of all durations above.
10255 /// For routes, it also corresponds to:
10256 /// [ShipmentRoute.vehicle_end_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]
10257 /// `-`
10258 /// [ShipmentRoute.vehicle_start_time][google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]
10259 ///
10260 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_end_time]: crate::model::ShipmentRoute::vehicle_end_time
10261 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_start_time]: crate::model::ShipmentRoute::vehicle_start_time
10262 pub total_duration: std::option::Option<wkt::Duration>,
10263
10264 /// Total travel distance for a route or a solution.
10265 pub travel_distance_meters: f64,
10266
10267 /// Maximum load achieved over the entire route (resp. solution), for each of
10268 /// the quantities on this route (resp. solution), computed as the maximum over
10269 /// all
10270 /// [Transition.vehicle_loads][google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]
10271 /// (resp.
10272 /// [ShipmentRoute.metrics.max_loads][google.cloud.optimization.v1.AggregatedMetrics.max_loads].
10273 ///
10274 /// [google.cloud.optimization.v1.AggregatedMetrics.max_loads]: crate::model::AggregatedMetrics::max_loads
10275 /// [google.cloud.optimization.v1.ShipmentRoute.Transition.vehicle_loads]: crate::model::shipment_route::Transition::vehicle_loads
10276 pub max_loads:
10277 std::collections::HashMap<std::string::String, crate::model::shipment_route::VehicleLoad>,
10278
10279 /// Deprecated: Use
10280 /// [ShipmentRoute.route_costs][google.cloud.optimization.v1.ShipmentRoute.route_costs]
10281 /// and
10282 /// [OptimizeToursResponse.Metrics.costs][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]
10283 /// instead.
10284 ///
10285 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.costs]: crate::model::optimize_tours_response::Metrics::costs
10286 /// [google.cloud.optimization.v1.ShipmentRoute.route_costs]: crate::model::ShipmentRoute::route_costs
10287 #[deprecated]
10288 pub costs: std::collections::HashMap<std::string::String, f64>,
10289
10290 /// Deprecated: Use
10291 /// [ShipmentRoute.route_total_cost][google.cloud.optimization.v1.ShipmentRoute.route_total_cost]
10292 /// and
10293 /// [OptimizeToursResponse.Metrics.total_cost][google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]
10294 /// instead.
10295 ///
10296 /// [google.cloud.optimization.v1.OptimizeToursResponse.Metrics.total_cost]: crate::model::optimize_tours_response::Metrics::total_cost
10297 /// [google.cloud.optimization.v1.ShipmentRoute.route_total_cost]: crate::model::ShipmentRoute::route_total_cost
10298 #[deprecated]
10299 pub total_cost: f64,
10300
10301 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10302}
10303
10304impl AggregatedMetrics {
10305 pub fn new() -> Self {
10306 std::default::Default::default()
10307 }
10308
10309 /// Sets the value of [performed_shipment_count][crate::model::AggregatedMetrics::performed_shipment_count].
10310 ///
10311 /// # Example
10312 /// ```ignore,no_run
10313 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10314 /// let x = AggregatedMetrics::new().set_performed_shipment_count(42);
10315 /// ```
10316 pub fn set_performed_shipment_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10317 self.performed_shipment_count = v.into();
10318 self
10319 }
10320
10321 /// Sets the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10322 ///
10323 /// # Example
10324 /// ```ignore,no_run
10325 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10326 /// use wkt::Duration;
10327 /// let x = AggregatedMetrics::new().set_travel_duration(Duration::default()/* use setters */);
10328 /// ```
10329 pub fn set_travel_duration<T>(mut self, v: T) -> Self
10330 where
10331 T: std::convert::Into<wkt::Duration>,
10332 {
10333 self.travel_duration = std::option::Option::Some(v.into());
10334 self
10335 }
10336
10337 /// Sets or clears the value of [travel_duration][crate::model::AggregatedMetrics::travel_duration].
10338 ///
10339 /// # Example
10340 /// ```ignore,no_run
10341 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10342 /// use wkt::Duration;
10343 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(Some(Duration::default()/* use setters */));
10344 /// let x = AggregatedMetrics::new().set_or_clear_travel_duration(None::<Duration>);
10345 /// ```
10346 pub fn set_or_clear_travel_duration<T>(mut self, v: std::option::Option<T>) -> Self
10347 where
10348 T: std::convert::Into<wkt::Duration>,
10349 {
10350 self.travel_duration = v.map(|x| x.into());
10351 self
10352 }
10353
10354 /// Sets the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10355 ///
10356 /// # Example
10357 /// ```ignore,no_run
10358 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10359 /// use wkt::Duration;
10360 /// let x = AggregatedMetrics::new().set_wait_duration(Duration::default()/* use setters */);
10361 /// ```
10362 pub fn set_wait_duration<T>(mut self, v: T) -> Self
10363 where
10364 T: std::convert::Into<wkt::Duration>,
10365 {
10366 self.wait_duration = std::option::Option::Some(v.into());
10367 self
10368 }
10369
10370 /// Sets or clears the value of [wait_duration][crate::model::AggregatedMetrics::wait_duration].
10371 ///
10372 /// # Example
10373 /// ```ignore,no_run
10374 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10375 /// use wkt::Duration;
10376 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(Some(Duration::default()/* use setters */));
10377 /// let x = AggregatedMetrics::new().set_or_clear_wait_duration(None::<Duration>);
10378 /// ```
10379 pub fn set_or_clear_wait_duration<T>(mut self, v: std::option::Option<T>) -> Self
10380 where
10381 T: std::convert::Into<wkt::Duration>,
10382 {
10383 self.wait_duration = v.map(|x| x.into());
10384 self
10385 }
10386
10387 /// Sets the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10388 ///
10389 /// # Example
10390 /// ```ignore,no_run
10391 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10392 /// use wkt::Duration;
10393 /// let x = AggregatedMetrics::new().set_delay_duration(Duration::default()/* use setters */);
10394 /// ```
10395 pub fn set_delay_duration<T>(mut self, v: T) -> Self
10396 where
10397 T: std::convert::Into<wkt::Duration>,
10398 {
10399 self.delay_duration = std::option::Option::Some(v.into());
10400 self
10401 }
10402
10403 /// Sets or clears the value of [delay_duration][crate::model::AggregatedMetrics::delay_duration].
10404 ///
10405 /// # Example
10406 /// ```ignore,no_run
10407 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10408 /// use wkt::Duration;
10409 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(Some(Duration::default()/* use setters */));
10410 /// let x = AggregatedMetrics::new().set_or_clear_delay_duration(None::<Duration>);
10411 /// ```
10412 pub fn set_or_clear_delay_duration<T>(mut self, v: std::option::Option<T>) -> Self
10413 where
10414 T: std::convert::Into<wkt::Duration>,
10415 {
10416 self.delay_duration = v.map(|x| x.into());
10417 self
10418 }
10419
10420 /// Sets the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10421 ///
10422 /// # Example
10423 /// ```ignore,no_run
10424 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10425 /// use wkt::Duration;
10426 /// let x = AggregatedMetrics::new().set_break_duration(Duration::default()/* use setters */);
10427 /// ```
10428 pub fn set_break_duration<T>(mut self, v: T) -> Self
10429 where
10430 T: std::convert::Into<wkt::Duration>,
10431 {
10432 self.break_duration = std::option::Option::Some(v.into());
10433 self
10434 }
10435
10436 /// Sets or clears the value of [break_duration][crate::model::AggregatedMetrics::break_duration].
10437 ///
10438 /// # Example
10439 /// ```ignore,no_run
10440 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10441 /// use wkt::Duration;
10442 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(Some(Duration::default()/* use setters */));
10443 /// let x = AggregatedMetrics::new().set_or_clear_break_duration(None::<Duration>);
10444 /// ```
10445 pub fn set_or_clear_break_duration<T>(mut self, v: std::option::Option<T>) -> Self
10446 where
10447 T: std::convert::Into<wkt::Duration>,
10448 {
10449 self.break_duration = v.map(|x| x.into());
10450 self
10451 }
10452
10453 /// Sets the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10454 ///
10455 /// # Example
10456 /// ```ignore,no_run
10457 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10458 /// use wkt::Duration;
10459 /// let x = AggregatedMetrics::new().set_visit_duration(Duration::default()/* use setters */);
10460 /// ```
10461 pub fn set_visit_duration<T>(mut self, v: T) -> Self
10462 where
10463 T: std::convert::Into<wkt::Duration>,
10464 {
10465 self.visit_duration = std::option::Option::Some(v.into());
10466 self
10467 }
10468
10469 /// Sets or clears the value of [visit_duration][crate::model::AggregatedMetrics::visit_duration].
10470 ///
10471 /// # Example
10472 /// ```ignore,no_run
10473 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10474 /// use wkt::Duration;
10475 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(Some(Duration::default()/* use setters */));
10476 /// let x = AggregatedMetrics::new().set_or_clear_visit_duration(None::<Duration>);
10477 /// ```
10478 pub fn set_or_clear_visit_duration<T>(mut self, v: std::option::Option<T>) -> Self
10479 where
10480 T: std::convert::Into<wkt::Duration>,
10481 {
10482 self.visit_duration = v.map(|x| x.into());
10483 self
10484 }
10485
10486 /// Sets the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10487 ///
10488 /// # Example
10489 /// ```ignore,no_run
10490 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10491 /// use wkt::Duration;
10492 /// let x = AggregatedMetrics::new().set_total_duration(Duration::default()/* use setters */);
10493 /// ```
10494 pub fn set_total_duration<T>(mut self, v: T) -> Self
10495 where
10496 T: std::convert::Into<wkt::Duration>,
10497 {
10498 self.total_duration = std::option::Option::Some(v.into());
10499 self
10500 }
10501
10502 /// Sets or clears the value of [total_duration][crate::model::AggregatedMetrics::total_duration].
10503 ///
10504 /// # Example
10505 /// ```ignore,no_run
10506 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10507 /// use wkt::Duration;
10508 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(Some(Duration::default()/* use setters */));
10509 /// let x = AggregatedMetrics::new().set_or_clear_total_duration(None::<Duration>);
10510 /// ```
10511 pub fn set_or_clear_total_duration<T>(mut self, v: std::option::Option<T>) -> Self
10512 where
10513 T: std::convert::Into<wkt::Duration>,
10514 {
10515 self.total_duration = v.map(|x| x.into());
10516 self
10517 }
10518
10519 /// Sets the value of [travel_distance_meters][crate::model::AggregatedMetrics::travel_distance_meters].
10520 ///
10521 /// # Example
10522 /// ```ignore,no_run
10523 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10524 /// let x = AggregatedMetrics::new().set_travel_distance_meters(42.0);
10525 /// ```
10526 pub fn set_travel_distance_meters<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10527 self.travel_distance_meters = v.into();
10528 self
10529 }
10530
10531 /// Sets the value of [max_loads][crate::model::AggregatedMetrics::max_loads].
10532 ///
10533 /// # Example
10534 /// ```ignore,no_run
10535 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10536 /// use google_cloud_optimization_v1::model::shipment_route::VehicleLoad;
10537 /// let x = AggregatedMetrics::new().set_max_loads([
10538 /// ("key0", VehicleLoad::default()/* use setters */),
10539 /// ("key1", VehicleLoad::default()/* use (different) setters */),
10540 /// ]);
10541 /// ```
10542 pub fn set_max_loads<T, K, V>(mut self, v: T) -> Self
10543 where
10544 T: std::iter::IntoIterator<Item = (K, V)>,
10545 K: std::convert::Into<std::string::String>,
10546 V: std::convert::Into<crate::model::shipment_route::VehicleLoad>,
10547 {
10548 use std::iter::Iterator;
10549 self.max_loads = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10550 self
10551 }
10552
10553 /// Sets the value of [costs][crate::model::AggregatedMetrics::costs].
10554 ///
10555 /// # Example
10556 /// ```ignore,no_run
10557 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10558 /// let x = AggregatedMetrics::new().set_costs([
10559 /// ("key0", 123.5),
10560 /// ("key1", 456.5),
10561 /// ]);
10562 /// ```
10563 #[deprecated]
10564 pub fn set_costs<T, K, V>(mut self, v: T) -> Self
10565 where
10566 T: std::iter::IntoIterator<Item = (K, V)>,
10567 K: std::convert::Into<std::string::String>,
10568 V: std::convert::Into<f64>,
10569 {
10570 use std::iter::Iterator;
10571 self.costs = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10572 self
10573 }
10574
10575 /// Sets the value of [total_cost][crate::model::AggregatedMetrics::total_cost].
10576 ///
10577 /// # Example
10578 /// ```ignore,no_run
10579 /// # use google_cloud_optimization_v1::model::AggregatedMetrics;
10580 /// let x = AggregatedMetrics::new().set_total_cost(42.0);
10581 /// ```
10582 #[deprecated]
10583 pub fn set_total_cost<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
10584 self.total_cost = v.into();
10585 self
10586 }
10587}
10588
10589impl wkt::message::Message for AggregatedMetrics {
10590 fn typename() -> &'static str {
10591 "type.googleapis.com/google.cloud.optimization.v1.AggregatedMetrics"
10592 }
10593}
10594
10595/// Solution injected in the request including information about which visits
10596/// must be constrained and how they must be constrained.
10597#[derive(Clone, Default, PartialEq)]
10598#[non_exhaustive]
10599pub struct InjectedSolutionConstraint {
10600 /// Routes of the solution to inject. Some routes may be omitted from the
10601 /// original solution. The routes and skipped shipments must satisfy the basic
10602 /// validity assumptions listed for `injected_first_solution_routes`.
10603 pub routes: std::vec::Vec<crate::model::ShipmentRoute>,
10604
10605 /// Skipped shipments of the solution to inject. Some may be omitted from the
10606 /// original solution. See the `routes` field.
10607 pub skipped_shipments: std::vec::Vec<crate::model::SkippedShipment>,
10608
10609 /// For zero or more groups of vehicles, specifies when and how much to relax
10610 /// constraints. If this field is empty, all non-empty vehicle routes are
10611 /// fully constrained.
10612 pub constraint_relaxations:
10613 std::vec::Vec<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10614
10615 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10616}
10617
10618impl InjectedSolutionConstraint {
10619 pub fn new() -> Self {
10620 std::default::Default::default()
10621 }
10622
10623 /// Sets the value of [routes][crate::model::InjectedSolutionConstraint::routes].
10624 ///
10625 /// # Example
10626 /// ```ignore,no_run
10627 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10628 /// use google_cloud_optimization_v1::model::ShipmentRoute;
10629 /// let x = InjectedSolutionConstraint::new()
10630 /// .set_routes([
10631 /// ShipmentRoute::default()/* use setters */,
10632 /// ShipmentRoute::default()/* use (different) setters */,
10633 /// ]);
10634 /// ```
10635 pub fn set_routes<T, V>(mut self, v: T) -> Self
10636 where
10637 T: std::iter::IntoIterator<Item = V>,
10638 V: std::convert::Into<crate::model::ShipmentRoute>,
10639 {
10640 use std::iter::Iterator;
10641 self.routes = v.into_iter().map(|i| i.into()).collect();
10642 self
10643 }
10644
10645 /// Sets the value of [skipped_shipments][crate::model::InjectedSolutionConstraint::skipped_shipments].
10646 ///
10647 /// # Example
10648 /// ```ignore,no_run
10649 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10650 /// use google_cloud_optimization_v1::model::SkippedShipment;
10651 /// let x = InjectedSolutionConstraint::new()
10652 /// .set_skipped_shipments([
10653 /// SkippedShipment::default()/* use setters */,
10654 /// SkippedShipment::default()/* use (different) setters */,
10655 /// ]);
10656 /// ```
10657 pub fn set_skipped_shipments<T, V>(mut self, v: T) -> Self
10658 where
10659 T: std::iter::IntoIterator<Item = V>,
10660 V: std::convert::Into<crate::model::SkippedShipment>,
10661 {
10662 use std::iter::Iterator;
10663 self.skipped_shipments = v.into_iter().map(|i| i.into()).collect();
10664 self
10665 }
10666
10667 /// Sets the value of [constraint_relaxations][crate::model::InjectedSolutionConstraint::constraint_relaxations].
10668 ///
10669 /// # Example
10670 /// ```ignore,no_run
10671 /// # use google_cloud_optimization_v1::model::InjectedSolutionConstraint;
10672 /// use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10673 /// let x = InjectedSolutionConstraint::new()
10674 /// .set_constraint_relaxations([
10675 /// ConstraintRelaxation::default()/* use setters */,
10676 /// ConstraintRelaxation::default()/* use (different) setters */,
10677 /// ]);
10678 /// ```
10679 pub fn set_constraint_relaxations<T, V>(mut self, v: T) -> Self
10680 where
10681 T: std::iter::IntoIterator<Item = V>,
10682 V: std::convert::Into<crate::model::injected_solution_constraint::ConstraintRelaxation>,
10683 {
10684 use std::iter::Iterator;
10685 self.constraint_relaxations = v.into_iter().map(|i| i.into()).collect();
10686 self
10687 }
10688}
10689
10690impl wkt::message::Message for InjectedSolutionConstraint {
10691 fn typename() -> &'static str {
10692 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint"
10693 }
10694}
10695
10696/// Defines additional types related to [InjectedSolutionConstraint].
10697pub mod injected_solution_constraint {
10698 #[allow(unused_imports)]
10699 use super::*;
10700
10701 /// For a group of vehicles, specifies at what threshold(s) constraints on
10702 /// visits will be relaxed and to which level. Shipments listed in
10703 /// the `skipped_shipment` field are constrained to be skipped; i.e., they
10704 /// cannot be performed.
10705 #[derive(Clone, Default, PartialEq)]
10706 #[non_exhaustive]
10707 pub struct ConstraintRelaxation {
10708 /// All the visit constraint relaxations that will apply to visits on
10709 /// routes with vehicles in `vehicle_indices`.
10710 pub relaxations: std::vec::Vec<
10711 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10712 >,
10713
10714 /// Specifies the vehicle indices to which the visit constraint
10715 /// `relaxations` apply. If empty, this is considered the default and the
10716 /// `relaxations` apply to all vehicles that are not specified in other
10717 /// `constraint_relaxations`. There can be at most one default, i.e., at
10718 /// most one constraint relaxation field is allowed empty
10719 /// `vehicle_indices`. A vehicle index can only be listed once, even within
10720 /// several `constraint_relaxations`.
10721 ///
10722 /// A vehicle index is mapped the same as
10723 /// [ShipmentRoute.vehicle_index][google.cloud.optimization.v1.ShipmentRoute.vehicle_index],
10724 /// if `interpret_injected_solutions_using_labels` is true (see `fields`
10725 /// comment).
10726 ///
10727 /// [google.cloud.optimization.v1.ShipmentRoute.vehicle_index]: crate::model::ShipmentRoute::vehicle_index
10728 pub vehicle_indices: std::vec::Vec<i32>,
10729
10730 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10731 }
10732
10733 impl ConstraintRelaxation {
10734 pub fn new() -> Self {
10735 std::default::Default::default()
10736 }
10737
10738 /// Sets the value of [relaxations][crate::model::injected_solution_constraint::ConstraintRelaxation::relaxations].
10739 ///
10740 /// # Example
10741 /// ```ignore,no_run
10742 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10743 /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10744 /// let x = ConstraintRelaxation::new()
10745 /// .set_relaxations([
10746 /// Relaxation::default()/* use setters */,
10747 /// Relaxation::default()/* use (different) setters */,
10748 /// ]);
10749 /// ```
10750 pub fn set_relaxations<T, V>(mut self, v: T) -> Self
10751 where
10752 T: std::iter::IntoIterator<Item = V>,
10753 V: std::convert::Into<
10754 crate::model::injected_solution_constraint::constraint_relaxation::Relaxation,
10755 >,
10756 {
10757 use std::iter::Iterator;
10758 self.relaxations = v.into_iter().map(|i| i.into()).collect();
10759 self
10760 }
10761
10762 /// Sets the value of [vehicle_indices][crate::model::injected_solution_constraint::ConstraintRelaxation::vehicle_indices].
10763 ///
10764 /// # Example
10765 /// ```ignore,no_run
10766 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::ConstraintRelaxation;
10767 /// let x = ConstraintRelaxation::new().set_vehicle_indices([1, 2, 3]);
10768 /// ```
10769 pub fn set_vehicle_indices<T, V>(mut self, v: T) -> Self
10770 where
10771 T: std::iter::IntoIterator<Item = V>,
10772 V: std::convert::Into<i32>,
10773 {
10774 use std::iter::Iterator;
10775 self.vehicle_indices = v.into_iter().map(|i| i.into()).collect();
10776 self
10777 }
10778 }
10779
10780 impl wkt::message::Message for ConstraintRelaxation {
10781 fn typename() -> &'static str {
10782 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation"
10783 }
10784 }
10785
10786 /// Defines additional types related to [ConstraintRelaxation].
10787 pub mod constraint_relaxation {
10788 #[allow(unused_imports)]
10789 use super::*;
10790
10791 /// If `relaxations` is empty, the start time and sequence of all visits
10792 /// on `routes` are fully constrained and no new visits may be inserted or
10793 /// added to those routes. Also, a vehicle's start and end time in
10794 /// `routes` is fully constrained, unless the vehicle is empty (i.e., has no
10795 /// visits and has `used_if_route_is_empty` set to false in the model).
10796 ///
10797 /// `relaxations(i).level` specifies the constraint relaxation level applied
10798 /// to a visit #j that satisfies:
10799 ///
10800 /// * `route.visits(j).start_time >= relaxations(i).threshold_time` AND
10801 /// * `j + 1 >= relaxations(i).threshold_visit_count`
10802 ///
10803 /// Similarly, the vehicle start is relaxed to `relaxations(i).level` if it
10804 /// satisfies:
10805 ///
10806 /// * `vehicle_start_time >= relaxations(i).threshold_time` AND
10807 /// * `relaxations(i).threshold_visit_count == 0`
10808 /// and the vehicle end is relaxed to `relaxations(i).level` if it satisfies:
10809 /// * `vehicle_end_time >= relaxations(i).threshold_time` AND
10810 /// * `route.visits_size() + 1 >= relaxations(i).threshold_visit_count`
10811 ///
10812 /// To apply a relaxation level if a visit meets the `threshold_visit_count`
10813 /// OR the `threshold_time` add two `relaxations` with the same `level`:
10814 /// one with only `threshold_visit_count` set and the other with only
10815 /// `threshold_time` set. If a visit satisfies the conditions of multiple
10816 /// `relaxations`, the most relaxed level applies. As a result, from the
10817 /// vehicle start through the route visits in order to the vehicle end, the
10818 /// relaxation level becomes more relaxed: i.e., the relaxation level is
10819 /// non-decreasing as the route progresses.
10820 ///
10821 /// The timing and sequence of route visits that do not satisfy the
10822 /// threshold conditions of any `relaxations` are fully constrained
10823 /// and no visits may be inserted into these sequences. Also, if a
10824 /// vehicle start or end does not satisfy the conditions of any
10825 /// relaxation the time is fixed, unless the vehicle is empty.
10826 #[derive(Clone, Default, PartialEq)]
10827 #[non_exhaustive]
10828 pub struct Relaxation {
10829
10830 /// The constraint relaxation level that applies when the conditions
10831 /// at or after `threshold_time` AND at least `threshold_visit_count` are
10832 /// satisfied.
10833 pub level: crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level,
10834
10835 /// The time at or after which the relaxation `level` may be applied.
10836 pub threshold_time: std::option::Option<wkt::Timestamp>,
10837
10838 /// The number of visits at or after which the relaxation `level` may be
10839 /// applied. If `threshold_visit_count` is 0 (or unset), the `level` may be
10840 /// applied directly at the vehicle start.
10841 ///
10842 /// If it is `route.visits_size() + 1`, the `level` may only be applied to
10843 /// the vehicle end. If it is more than `route.visits_size() + 1`,
10844 /// `level` is not applied at all for that route.
10845 pub threshold_visit_count: i32,
10846
10847 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10848 }
10849
10850 impl Relaxation {
10851 pub fn new() -> Self {
10852 std::default::Default::default()
10853 }
10854
10855 /// Sets the value of [level][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::level].
10856 ///
10857 /// # Example
10858 /// ```ignore,no_run
10859 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10860 /// use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::relaxation::Level;
10861 /// let x0 = Relaxation::new().set_level(Level::RelaxVisitTimesAfterThreshold);
10862 /// let x1 = Relaxation::new().set_level(Level::RelaxVisitTimesAndSequenceAfterThreshold);
10863 /// let x2 = Relaxation::new().set_level(Level::RelaxAllAfterThreshold);
10864 /// ```
10865 pub fn set_level<T: std::convert::Into<crate::model::injected_solution_constraint::constraint_relaxation::relaxation::Level>>(mut self, v: T) -> Self{
10866 self.level = v.into();
10867 self
10868 }
10869
10870 /// Sets the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10871 ///
10872 /// # Example
10873 /// ```ignore,no_run
10874 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10875 /// use wkt::Timestamp;
10876 /// let x = Relaxation::new().set_threshold_time(Timestamp::default()/* use setters */);
10877 /// ```
10878 pub fn set_threshold_time<T>(mut self, v: T) -> Self
10879 where
10880 T: std::convert::Into<wkt::Timestamp>,
10881 {
10882 self.threshold_time = std::option::Option::Some(v.into());
10883 self
10884 }
10885
10886 /// Sets or clears the value of [threshold_time][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_time].
10887 ///
10888 /// # Example
10889 /// ```ignore,no_run
10890 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10891 /// use wkt::Timestamp;
10892 /// let x = Relaxation::new().set_or_clear_threshold_time(Some(Timestamp::default()/* use setters */));
10893 /// let x = Relaxation::new().set_or_clear_threshold_time(None::<Timestamp>);
10894 /// ```
10895 pub fn set_or_clear_threshold_time<T>(mut self, v: std::option::Option<T>) -> Self
10896 where
10897 T: std::convert::Into<wkt::Timestamp>,
10898 {
10899 self.threshold_time = v.map(|x| x.into());
10900 self
10901 }
10902
10903 /// Sets the value of [threshold_visit_count][crate::model::injected_solution_constraint::constraint_relaxation::Relaxation::threshold_visit_count].
10904 ///
10905 /// # Example
10906 /// ```ignore,no_run
10907 /// # use google_cloud_optimization_v1::model::injected_solution_constraint::constraint_relaxation::Relaxation;
10908 /// let x = Relaxation::new().set_threshold_visit_count(42);
10909 /// ```
10910 pub fn set_threshold_visit_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10911 self.threshold_visit_count = v.into();
10912 self
10913 }
10914 }
10915
10916 impl wkt::message::Message for Relaxation {
10917 fn typename() -> &'static str {
10918 "type.googleapis.com/google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation"
10919 }
10920 }
10921
10922 /// Defines additional types related to [Relaxation].
10923 pub mod relaxation {
10924 #[allow(unused_imports)]
10925 use super::*;
10926
10927 /// Expresses the different constraint relaxation levels, which are
10928 /// applied for a visit and those that follow when it satisfies the
10929 /// threshold conditions.
10930 ///
10931 /// The enumeration below is in order of increasing relaxation.
10932 ///
10933 /// # Working with unknown values
10934 ///
10935 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10936 /// additional enum variants at any time. Adding new variants is not considered
10937 /// a breaking change. Applications should write their code in anticipation of:
10938 ///
10939 /// - New values appearing in future releases of the client library, **and**
10940 /// - New values received dynamically, without application changes.
10941 ///
10942 /// Please consult the [Working with enums] section in the user guide for some
10943 /// guidelines.
10944 ///
10945 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10946 #[derive(Clone, Debug, PartialEq)]
10947 #[non_exhaustive]
10948 pub enum Level {
10949 /// Implicit default relaxation level: no constraints are relaxed,
10950 /// i.e., all visits are fully constrained.
10951 ///
10952 /// This value must not be explicitly used in `level`.
10953 Unspecified,
10954 /// Visit start times and vehicle start/end times will be relaxed, but
10955 /// each visit remains bound to the same vehicle and the visit sequence
10956 /// must be observed: no visit can be inserted between them or before
10957 /// them.
10958 RelaxVisitTimesAfterThreshold,
10959 /// Same as `RELAX_VISIT_TIMES_AFTER_THRESHOLD`, but the visit sequence
10960 /// is also relaxed: visits can only be performed by this vehicle, but
10961 /// can potentially become unperformed.
10962 RelaxVisitTimesAndSequenceAfterThreshold,
10963 /// Same as `RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD`, but the
10964 /// vehicle is also relaxed: visits are completely free at or after the
10965 /// threshold time and can potentially become unperformed.
10966 RelaxAllAfterThreshold,
10967 /// If set, the enum was initialized with an unknown value.
10968 ///
10969 /// Applications can examine the value using [Level::value] or
10970 /// [Level::name].
10971 UnknownValue(level::UnknownValue),
10972 }
10973
10974 #[doc(hidden)]
10975 pub mod level {
10976 #[allow(unused_imports)]
10977 use super::*;
10978 #[derive(Clone, Debug, PartialEq)]
10979 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10980 }
10981
10982 impl Level {
10983 /// Gets the enum value.
10984 ///
10985 /// Returns `None` if the enum contains an unknown value deserialized from
10986 /// the string representation of enums.
10987 pub fn value(&self) -> std::option::Option<i32> {
10988 match self {
10989 Self::Unspecified => std::option::Option::Some(0),
10990 Self::RelaxVisitTimesAfterThreshold => std::option::Option::Some(1),
10991 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
10992 std::option::Option::Some(2)
10993 }
10994 Self::RelaxAllAfterThreshold => std::option::Option::Some(3),
10995 Self::UnknownValue(u) => u.0.value(),
10996 }
10997 }
10998
10999 /// Gets the enum value as a string.
11000 ///
11001 /// Returns `None` if the enum contains an unknown value deserialized from
11002 /// the integer representation of enums.
11003 pub fn name(&self) -> std::option::Option<&str> {
11004 match self {
11005 Self::Unspecified => std::option::Option::Some("LEVEL_UNSPECIFIED"),
11006 Self::RelaxVisitTimesAfterThreshold => {
11007 std::option::Option::Some("RELAX_VISIT_TIMES_AFTER_THRESHOLD")
11008 }
11009 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11010 std::option::Option::Some(
11011 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD",
11012 )
11013 }
11014 Self::RelaxAllAfterThreshold => {
11015 std::option::Option::Some("RELAX_ALL_AFTER_THRESHOLD")
11016 }
11017 Self::UnknownValue(u) => u.0.name(),
11018 }
11019 }
11020 }
11021
11022 impl std::default::Default for Level {
11023 fn default() -> Self {
11024 use std::convert::From;
11025 Self::from(0)
11026 }
11027 }
11028
11029 impl std::fmt::Display for Level {
11030 fn fmt(
11031 &self,
11032 f: &mut std::fmt::Formatter<'_>,
11033 ) -> std::result::Result<(), std::fmt::Error> {
11034 wkt::internal::display_enum(f, self.name(), self.value())
11035 }
11036 }
11037
11038 impl std::convert::From<i32> for Level {
11039 fn from(value: i32) -> Self {
11040 match value {
11041 0 => Self::Unspecified,
11042 1 => Self::RelaxVisitTimesAfterThreshold,
11043 2 => Self::RelaxVisitTimesAndSequenceAfterThreshold,
11044 3 => Self::RelaxAllAfterThreshold,
11045 _ => Self::UnknownValue(level::UnknownValue(
11046 wkt::internal::UnknownEnumValue::Integer(value),
11047 )),
11048 }
11049 }
11050 }
11051
11052 impl std::convert::From<&str> for Level {
11053 fn from(value: &str) -> Self {
11054 use std::string::ToString;
11055 match value {
11056 "LEVEL_UNSPECIFIED" => Self::Unspecified,
11057 "RELAX_VISIT_TIMES_AFTER_THRESHOLD" => Self::RelaxVisitTimesAfterThreshold,
11058 "RELAX_VISIT_TIMES_AND_SEQUENCE_AFTER_THRESHOLD" => {
11059 Self::RelaxVisitTimesAndSequenceAfterThreshold
11060 }
11061 "RELAX_ALL_AFTER_THRESHOLD" => Self::RelaxAllAfterThreshold,
11062 _ => Self::UnknownValue(level::UnknownValue(
11063 wkt::internal::UnknownEnumValue::String(value.to_string()),
11064 )),
11065 }
11066 }
11067 }
11068
11069 impl serde::ser::Serialize for Level {
11070 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11071 where
11072 S: serde::Serializer,
11073 {
11074 match self {
11075 Self::Unspecified => serializer.serialize_i32(0),
11076 Self::RelaxVisitTimesAfterThreshold => serializer.serialize_i32(1),
11077 Self::RelaxVisitTimesAndSequenceAfterThreshold => {
11078 serializer.serialize_i32(2)
11079 }
11080 Self::RelaxAllAfterThreshold => serializer.serialize_i32(3),
11081 Self::UnknownValue(u) => u.0.serialize(serializer),
11082 }
11083 }
11084 }
11085
11086 impl<'de> serde::de::Deserialize<'de> for Level {
11087 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11088 where
11089 D: serde::Deserializer<'de>,
11090 {
11091 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Level>::new(
11092 ".google.cloud.optimization.v1.InjectedSolutionConstraint.ConstraintRelaxation.Relaxation.Level"))
11093 }
11094 }
11095 }
11096 }
11097}
11098
11099/// Describes an error encountered when validating an `OptimizeToursRequest`.
11100#[derive(Clone, Default, PartialEq)]
11101#[non_exhaustive]
11102pub struct OptimizeToursValidationError {
11103 /// A validation error is defined by the pair (`code`, `display_name`) which
11104 /// are always present.
11105 ///
11106 /// Other fields (below) provide more context about the error.
11107 ///
11108 /// *MULTIPLE ERRORS*:
11109 /// When there are multiple errors, the validation process tries to output
11110 /// several of them. Much like a compiler, this is an imperfect process. Some
11111 /// validation errors will be "fatal", meaning that they stop the entire
11112 /// validation process. This is the case for `display_name="UNSPECIFIED"`
11113 /// errors, among others. Some may cause the validation process to skip other
11114 /// errors.
11115 ///
11116 /// *STABILITY*:
11117 /// `code` and `display_name` should be very stable. But new codes and
11118 /// display names may appear over time, which may cause a given (invalid)
11119 /// request to yield a different (`code`, `display_name`) pair because the new
11120 /// error hid the old one (see "MULTIPLE ERRORS").
11121 ///
11122 /// *REFERENCE*: A list of all (code, name) pairs:
11123 ///
11124 /// * UNSPECIFIED = 0;
11125 ///
11126 /// * VALIDATION_TIMEOUT_ERROR = 10; Validation couldn't be completed within
11127 /// the deadline.
11128 ///
11129 /// * REQUEST_OPTIONS_ERROR = 12;
11130 ///
11131 /// * REQUEST_OPTIONS_INVALID_SOLVING_MODE = 1201;
11132 /// * REQUEST_OPTIONS_INVALID_MAX_VALIDATION_ERRORS = 1203;
11133 /// * REQUEST_OPTIONS_INVALID_GEODESIC_METERS_PER_SECOND = 1204;
11134 /// * REQUEST_OPTIONS_GEODESIC_METERS_PER_SECOND_TOO_SMALL = 1205;
11135 /// * REQUEST_OPTIONS_MISSING_GEODESIC_METERS_PER_SECOND = 1206;
11136 /// * REQUEST_OPTIONS_POPULATE_PATHFINDER_TRIPS_AND_GEODESIC_DISTANCE
11137 /// = 1207;
11138 /// * REQUEST_OPTIONS_COST_MODEL_OPTIONS_AND_GEODESIC_DISTANCE = 1208;
11139 /// * REQUEST_OPTIONS_TRAVEL_MODE_INCOMPATIBLE_WITH_TRAFFIC = 1211;
11140 /// * REQUEST_OPTIONS_MULTIPLE_TRAFFIC_FLAVORS = 1212;
11141 /// * REQUEST_OPTIONS_INVALID_TRAFFIC_FLAVOR = 1213;
11142 /// * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITHOUT_GLOBAL_START_TIME = 1214;
11143 /// * REQUEST_OPTIONS_TRAFFIC_ENABLED_WITH_PRECEDENCES = 1215;
11144 /// * REQUEST_OPTIONS_TRAFFIC_PREFILL_MODE_INVALID = 1216;
11145 /// * REQUEST_OPTIONS_TRAFFIC_PREFILL_ENABLED_WITHOUT_TRAFFIC = 1217;
11146 /// * INJECTED_SOLUTION_ERROR = 20;
11147 ///
11148 /// * INJECTED_SOLUTION_MISSING_LABEL = 2000;
11149 /// * INJECTED_SOLUTION_DUPLICATE_LABEL = 2001;
11150 /// * INJECTED_SOLUTION_AMBIGUOUS_INDEX = 2002;
11151 /// * INJECTED_SOLUTION_INFEASIBLE_AFTER_GETTING_TRAVEL_TIMES = 2003;
11152 /// * INJECTED_SOLUTION_TRANSITION_INCONSISTENT_WITH_ACTUAL_TRAVEL = 2004;
11153 /// * INJECTED_SOLUTION_CONCURRENT_SOLUTION_TYPES = 2005;
11154 /// * INJECTED_SOLUTION_MORE_THAN_ONE_PER_TYPE = 2006;
11155 /// * INJECTED_SOLUTION_REFRESH_WITHOUT_POPULATE = 2008;
11156 /// * INJECTED_SOLUTION_CONSTRAINED_ROUTE_PORTION_INFEASIBLE = 2010;
11157 /// * SHIPMENT_MODEL_ERROR = 22;
11158 ///
11159 /// * SHIPMENT_MODEL_TOO_LARGE = 2200;
11160 /// * SHIPMENT_MODEL_TOO_MANY_CAPACITY_TYPES = 2201;
11161 /// * SHIPMENT_MODEL_GLOBAL_START_TIME_NEGATIVE_OR_NAN = 2202;
11162 /// * SHIPMENT_MODEL_GLOBAL_END_TIME_TOO_LARGE_OR_NAN = 2203;
11163 /// * SHIPMENT_MODEL_GLOBAL_START_TIME_AFTER_GLOBAL_END_TIME = 2204;
11164 /// * SHIPMENT_MODEL_GLOBAL_DURATION_TOO_LONG = 2205;
11165 /// * SHIPMENT_MODEL_MAX_ACTIVE_VEHICLES_NOT_POSITIVE = 2206;
11166 /// * SHIPMENT_MODEL_DURATION_MATRIX_TOO_LARGE = 2207;
11167 /// * INDEX_ERROR = 24;
11168 ///
11169 /// * TAG_ERROR = 26;
11170 ///
11171 /// * TIME_WINDOW_ERROR = 28;
11172 ///
11173 /// * TIME_WINDOW_INVALID_START_TIME = 2800;
11174 /// * TIME_WINDOW_INVALID_END_TIME = 2801;
11175 /// * TIME_WINDOW_INVALID_SOFT_START_TIME = 2802;
11176 /// * TIME_WINDOW_INVALID_SOFT_END_TIME = 2803;
11177 /// * TIME_WINDOW_OUTSIDE_GLOBAL_TIME_WINDOW = 2804;
11178 /// * TIME_WINDOW_START_TIME_AFTER_END_TIME = 2805;
11179 /// * TIME_WINDOW_INVALID_COST_PER_HOUR_BEFORE_SOFT_START_TIME = 2806;
11180 /// * TIME_WINDOW_INVALID_COST_PER_HOUR_AFTER_SOFT_END_TIME = 2807;
11181 /// * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_WITHOUT_SOFT_START_TIME
11182 /// = 2808;
11183 /// * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_WITHOUT_SOFT_END_TIME = 2809;
11184 /// * TIME_WINDOW_SOFT_START_TIME_WITHOUT_COST_BEFORE_SOFT_START_TIME
11185 /// = 2810;
11186 /// * TIME_WINDOW_SOFT_END_TIME_WITHOUT_COST_AFTER_SOFT_END_TIME = 2811;
11187 /// * TIME_WINDOW_OVERLAPPING_ADJACENT_OR_EARLIER_THAN_PREVIOUS = 2812;
11188 /// * TIME_WINDOW_START_TIME_AFTER_SOFT_START_TIME = 2813;
11189 /// * TIME_WINDOW_SOFT_START_TIME_AFTER_END_TIME = 2814;
11190 /// * TIME_WINDOW_START_TIME_AFTER_SOFT_END_TIME = 2815;
11191 /// * TIME_WINDOW_SOFT_END_TIME_AFTER_END_TIME = 2816;
11192 /// * TIME_WINDOW_COST_BEFORE_SOFT_START_TIME_SET_AND_MULTIPLE_WINDOWS
11193 /// = 2817;
11194 /// * TIME_WINDOW_COST_AFTER_SOFT_END_TIME_SET_AND_MULTIPLE_WINDOWS = 2818;
11195 /// * TRANSITION_ATTRIBUTES_ERROR = 30;
11196 /// * TRANSITION_ATTRIBUTES_INVALID_COST = 3000;
11197 /// * TRANSITION_ATTRIBUTES_INVALID_COST_PER_KILOMETER = 3001;
11198 /// * TRANSITION_ATTRIBUTES_DUPLICATE_TAG_PAIR = 3002;
11199 /// * TRANSITION_ATTRIBUTES_DISTANCE_LIMIT_MAX_METERS_UNSUPPORTED = 3003;
11200 /// * TRANSITION_ATTRIBUTES_UNSPECIFIED_SOURCE_TAGS = 3004;
11201 /// * TRANSITION_ATTRIBUTES_CONFLICTING_SOURCE_TAGS_FIELDS = 3005;
11202 /// * TRANSITION_ATTRIBUTES_UNSPECIFIED_DESTINATION_TAGS = 3006;
11203 /// * TRANSITION_ATTRIBUTES_CONFLICTING_DESTINATION_TAGS_FIELDS = 3007;
11204 /// * TRANSITION_ATTRIBUTES_DELAY_DURATION_NEGATIVE_OR_NAN = 3008;
11205 /// * TRANSITION_ATTRIBUTES_DELAY_DURATION_EXCEEDS_GLOBAL_DURATION = 3009;
11206 /// * AMOUNT_ERROR = 31;
11207 ///
11208 /// * AMOUNT_NEGATIVE_VALUE = 3100;
11209 /// * LOAD_LIMIT_ERROR = 33;
11210 ///
11211 /// * LOAD_LIMIT_INVALID_COST_ABOVE_SOFT_MAX = 3303;
11212 /// * LOAD_LIMIT_SOFT_MAX_WITHOUT_COST_ABOVE_SOFT_MAX = 3304;
11213 /// * LOAD_LIMIT_COST_ABOVE_SOFT_MAX_WITHOUT_SOFT_MAX = 3305;
11214 /// * LOAD_LIMIT_NEGATIVE_SOFT_MAX = 3306;
11215 /// * LOAD_LIMIT_MIXED_DEMAND_TYPE = 3307;
11216 /// * LOAD_LIMIT_MAX_LOAD_NEGATIVE_VALUE = 3308;
11217 /// * LOAD_LIMIT_SOFT_MAX_ABOVE_MAX = 3309;
11218 /// * INTERVAL_ERROR = 34;
11219 ///
11220 /// * INTERVAL_MIN_EXCEEDS_MAX = 3401;
11221 /// * INTERVAL_NEGATIVE_MIN = 3402;
11222 /// * INTERVAL_NEGATIVE_MAX = 3403;
11223 /// * INTERVAL_MIN_EXCEEDS_CAPACITY = 3404;
11224 /// * INTERVAL_MAX_EXCEEDS_CAPACITY = 3405;
11225 /// * DISTANCE_LIMIT_ERROR = 36;
11226 ///
11227 /// * DISTANCE_LIMIT_INVALID_COST_AFTER_SOFT_MAX = 3601;
11228 /// * DISTANCE_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3602;
11229 /// * DISTANCE_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3603;
11230 /// * DISTANCE_LIMIT_NEGATIVE_MAX = 3604;
11231 /// * DISTANCE_LIMIT_NEGATIVE_SOFT_MAX = 3605;
11232 /// * DISTANCE_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3606;
11233 /// * DURATION_LIMIT_ERROR = 38;
11234 ///
11235 /// * DURATION_LIMIT_MAX_DURATION_NEGATIVE_OR_NAN = 3800;
11236 /// * DURATION_LIMIT_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3801;
11237 /// * DURATION_LIMIT_INVALID_COST_PER_HOUR_AFTER_SOFT_MAX = 3802;
11238 /// * DURATION_LIMIT_SOFT_MAX_WITHOUT_COST_AFTER_SOFT_MAX = 3803;
11239 /// * DURATION_LIMIT_COST_AFTER_SOFT_MAX_WITHOUT_SOFT_MAX = 3804;
11240 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_NEGATIVE_OR_NAN = 3805;
11241 /// * DURATION_LIMIT_INVALID_COST_AFTER_QUADRATIC_SOFT_MAX = 3806;
11242 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_COST_PER_SQUARE_HOUR
11243 /// = 3807;
11244 /// * DURATION_LIMIT_COST_PER_SQUARE_HOUR_WITHOUT_QUADRATIC_SOFT_MAX
11245 /// = 3808;
11246 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_WITHOUT_MAX = 3809;
11247 /// * DURATION_LIMIT_SOFT_MAX_LARGER_THAN_MAX = 3810;
11248 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_LARGER_THAN_MAX = 3811;
11249 /// * DURATION_LIMIT_DIFF_BETWEEN_MAX_AND_QUADRATIC_SOFT_MAX_TOO_LARGE
11250 /// = 3812;
11251 /// * DURATION_LIMIT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3813;
11252 /// * DURATION_LIMIT_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION = 3814;
11253 /// * DURATION_LIMIT_QUADRATIC_SOFT_MAX_DURATION_EXCEEDS_GLOBAL_DURATION
11254 /// = 3815;
11255 /// * SHIPMENT_ERROR = 40;
11256 ///
11257 /// * SHIPMENT_PD_LIMIT_WITHOUT_PICKUP_AND_DELIVERY = 4014;
11258 /// * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_NEGATIVE_OR_NAN = 4000;
11259 /// * SHIPMENT_PD_ABSOLUTE_DETOUR_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION
11260 /// = 4001;
11261 /// * SHIPMENT_PD_RELATIVE_DETOUR_LIMIT_INVALID = 4015;
11262 /// * SHIPMENT_PD_DETOUR_LIMIT_AND_EXTRA_VISIT_DURATION = 4016;
11263 /// * SHIPMENT_PD_TIME_LIMIT_DURATION_NEGATIVE_OR_NAN = 4002;
11264 /// * SHIPMENT_PD_TIME_LIMIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4003;
11265 /// * SHIPMENT_EMPTY_SHIPMENT_TYPE = 4004;
11266 /// * SHIPMENT_NO_PICKUP_NO_DELIVERY = 4005;
11267 /// * SHIPMENT_INVALID_PENALTY_COST = 4006;
11268 /// * SHIPMENT_ALLOWED_VEHICLE_INDEX_OUT_OF_BOUNDS = 4007;
11269 /// * SHIPMENT_DUPLICATE_ALLOWED_VEHICLE_INDEX = 4008;
11270 /// * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITHOUT_INDEX = 4009;
11271 /// * SHIPMENT_INCONSISTENT_COST_FOR_VEHICLE_SIZE_WITH_INDEX = 4010;
11272 /// * SHIPMENT_INVALID_COST_FOR_VEHICLE = 4011;
11273 /// * SHIPMENT_COST_FOR_VEHICLE_INDEX_OUT_OF_BOUNDS = 4012;
11274 /// * SHIPMENT_DUPLICATE_COST_FOR_VEHICLE_INDEX = 4013;
11275 /// * VEHICLE_ERROR = 42;
11276 ///
11277 /// * VEHICLE_EMPTY_REQUIRED_OPERATOR_TYPE = 4200;
11278 /// * VEHICLE_DUPLICATE_REQUIRED_OPERATOR_TYPE = 4201;
11279 /// * VEHICLE_NO_OPERATOR_WITH_REQUIRED_OPERATOR_TYPE = 4202;
11280 /// * VEHICLE_EMPTY_START_TAG = 4203;
11281 /// * VEHICLE_DUPLICATE_START_TAG = 4204;
11282 /// * VEHICLE_EMPTY_END_TAG = 4205;
11283 /// * VEHICLE_DUPLICATE_END_TAG = 4206;
11284 /// * VEHICLE_EXTRA_VISIT_DURATION_NEGATIVE_OR_NAN = 4207;
11285 /// * VEHICLE_EXTRA_VISIT_DURATION_EXCEEDS_GLOBAL_DURATION = 4208;
11286 /// * VEHICLE_EXTRA_VISIT_DURATION_EMPTY_KEY = 4209;
11287 /// * VEHICLE_FIRST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4210;
11288 /// * VEHICLE_FIRST_SHIPMENT_IGNORED = 4211;
11289 /// * VEHICLE_FIRST_SHIPMENT_NOT_BOUND = 4212;
11290 /// * VEHICLE_LAST_SHIPMENT_INDEX_OUT_OF_BOUNDS = 4213;
11291 /// * VEHICLE_LAST_SHIPMENT_IGNORED = 4214;
11292 /// * VEHICLE_LAST_SHIPMENT_NOT_BOUND = 4215;
11293 /// * VEHICLE_IGNORED_WITH_USED_IF_ROUTE_IS_EMPTY = 4216;
11294 /// * VEHICLE_INVALID_COST_PER_KILOMETER = 4217;
11295 /// * VEHICLE_INVALID_COST_PER_HOUR = 4218;
11296 /// * VEHICLE_INVALID_COST_PER_TRAVELED_HOUR = 4219;
11297 /// * VEHICLE_INVALID_FIXED_COST = 4220;
11298 /// * VEHICLE_INVALID_TRAVEL_DURATION_MULTIPLE = 4221;
11299 /// * VEHICLE_TRAVEL_DURATION_MULTIPLE_WITH_SHIPMENT_PD_DETOUR_LIMITS
11300 /// = 4223;
11301 /// * VEHICLE_MATRIX_INDEX_WITH_SHIPMENT_PD_DETOUR_LIMITS = 4224;
11302 /// * VEHICLE_MINIMUM_DURATION_LONGER_THAN_DURATION_LIMIT = 4222;
11303 /// * VISIT_REQUEST_ERROR = 44;
11304 ///
11305 /// * VISIT_REQUEST_EMPTY_TAG = 4400;
11306 /// * VISIT_REQUEST_DUPLICATE_TAG = 4401;
11307 /// * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404;
11308 /// * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405;
11309 /// * PRECEDENCE_ERROR = 46;
11310 ///
11311 /// * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600;
11312 /// * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601;
11313 /// * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602;
11314 /// * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603;
11315 /// * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604;
11316 /// * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605;
11317 /// * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606;
11318 /// * BREAK_ERROR = 48;
11319 ///
11320 /// * BREAK_RULE_EMPTY = 4800;
11321 /// * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801;
11322 /// * BREAK_REQUEST_UNSPECIFIED_EARLIEST_START_TIME = 4802;
11323 /// * BREAK_REQUEST_UNSPECIFIED_LATEST_START_TIME = 4803;
11324 /// * BREAK_REQUEST_DURATION_NEGATIVE_OR_NAN = 4804; = 4804;
11325 /// * BREAK_REQUEST_LATEST_START_TIME_BEFORE_EARLIEST_START_TIME = 4805;
11326 /// * BREAK_REQUEST_EARLIEST_START_TIME_BEFORE_GLOBAL_START_TIME = 4806;
11327 /// * BREAK_REQUEST_LATEST_END_TIME_AFTER_GLOBAL_END_TIME = 4807;
11328 /// * BREAK_REQUEST_NON_SCHEDULABLE = 4808;
11329 /// * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_NEGATIVE_OR_NAN = 4809;
11330 /// * BREAK_FREQUENCY_MIN_BREAK_DURATION_NEGATIVE_OR_NAN = 4810;
11331 /// * BREAK_FREQUENCY_MIN_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION = 4811;
11332 /// * BREAK_FREQUENCY_MAX_INTER_BREAK_DURATION_EXCEEDS_GLOBAL_DURATION
11333 /// = 4812;
11334 /// * BREAK_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4813;
11335 /// * BREAK_FREQUENCY_MISSING_MAX_INTER_BREAK_DURATION = 4814;
11336 /// * BREAK_FREQUENCY_MISSING_MIN_BREAK_DURATION = 4815;
11337 /// * SHIPMENT_TYPE_INCOMPATIBILITY_ERROR = 50;
11338 ///
11339 /// * SHIPMENT_TYPE_INCOMPATIBILITY_EMPTY_TYPE = 5001;
11340 /// * SHIPMENT_TYPE_INCOMPATIBILITY_LESS_THAN_TWO_TYPES = 5002;
11341 /// * SHIPMENT_TYPE_INCOMPATIBILITY_DUPLICATE_TYPE = 5003;
11342 /// * SHIPMENT_TYPE_INCOMPATIBILITY_INVALID_INCOMPATIBILITY_MODE = 5004;
11343 /// * SHIPMENT_TYPE_INCOMPATIBILITY_TOO_MANY_INCOMPATIBILITIES = 5005;
11344 /// * SHIPMENT_TYPE_REQUIREMENT_ERROR = 52;
11345 ///
11346 /// * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE = 52001;
11347 /// * SHIPMENT_TYPE_REQUIREMENT_NO_DEPENDENT_TYPE = 52002;
11348 /// * SHIPMENT_TYPE_REQUIREMENT_INVALID_REQUIREMENT_MODE = 52003;
11349 /// * SHIPMENT_TYPE_REQUIREMENT_TOO_MANY_REQUIREMENTS = 52004;
11350 /// * SHIPMENT_TYPE_REQUIREMENT_EMPTY_REQUIRED_TYPE = 52005;
11351 /// * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_REQUIRED_TYPE = 52006;
11352 /// * SHIPMENT_TYPE_REQUIREMENT_NO_REQUIRED_TYPE_FOUND = 52007;
11353 /// * SHIPMENT_TYPE_REQUIREMENT_EMPTY_DEPENDENT_TYPE = 52008;
11354 /// * SHIPMENT_TYPE_REQUIREMENT_DUPLICATE_DEPENDENT_TYPE = 52009;
11355 /// * SHIPMENT_TYPE_REQUIREMENT_SELF_DEPENDENT_TYPE = 52010;
11356 /// * SHIPMENT_TYPE_REQUIREMENT_GRAPH_HAS_CYCLES = 52011;
11357 /// * VEHICLE_OPERATOR_ERROR = 54;
11358 ///
11359 /// * VEHICLE_OPERATOR_EMPTY_TYPE = 5400;
11360 /// * VEHICLE_OPERATOR_MULTIPLE_START_TIME_WINDOWS = 5401;
11361 /// * VEHICLE_OPERATOR_SOFT_START_TIME_WINDOW = 5402;
11362 /// * VEHICLE_OPERATOR_MULTIPLE_END_TIME_WINDOWS = 5403;
11363 /// * VEHICLE_OPERATOR_SOFT_END_TIME_WINDOW = 5404;
11364 /// * DURATION_SECONDS_MATRIX_ERROR = 56;
11365 ///
11366 /// * DURATION_SECONDS_MATRIX_DURATION_NEGATIVE_OR_NAN = 5600;
11367 /// * DURATION_SECONDS_MATRIX_DURATION_EXCEEDS_GLOBAL_DURATION = 5601;
11368 pub code: i32,
11369
11370 /// The error display name.
11371 pub display_name: std::string::String,
11372
11373 /// An error context may involve 0, 1 (most of the time) or more fields. For
11374 /// example, referring to vehicle #4 and shipment #2's first pickup can be
11375 /// done as follows:
11376 ///
11377 /// ```norust
11378 /// fields { name: "vehicles" index: 4}
11379 /// fields { name: "shipments" index: 2 sub_field {name: "pickups" index: 0} }
11380 /// ```
11381 ///
11382 /// Note, however, that the cardinality of `fields` should not change for a
11383 /// given error code.
11384 pub fields: std::vec::Vec<crate::model::optimize_tours_validation_error::FieldReference>,
11385
11386 /// Human-readable string describing the error. There is a 1:1 mapping
11387 /// between `code` and `error_message` (when code != "UNSPECIFIED").
11388 ///
11389 /// *STABILITY*: Not stable: the error message associated to a given `code` may
11390 /// change (hopefully to clarify it) over time. Please rely on the
11391 /// `display_name` and `code` instead.
11392 pub error_message: std::string::String,
11393
11394 /// May contain the value(s) of the field(s). This is not always available. You
11395 /// should absolutely not rely on it and use it only for manual model
11396 /// debugging.
11397 pub offending_values: std::string::String,
11398
11399 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11400}
11401
11402impl OptimizeToursValidationError {
11403 pub fn new() -> Self {
11404 std::default::Default::default()
11405 }
11406
11407 /// Sets the value of [code][crate::model::OptimizeToursValidationError::code].
11408 ///
11409 /// # Example
11410 /// ```ignore,no_run
11411 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11412 /// let x = OptimizeToursValidationError::new().set_code(42);
11413 /// ```
11414 pub fn set_code<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11415 self.code = v.into();
11416 self
11417 }
11418
11419 /// Sets the value of [display_name][crate::model::OptimizeToursValidationError::display_name].
11420 ///
11421 /// # Example
11422 /// ```ignore,no_run
11423 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11424 /// let x = OptimizeToursValidationError::new().set_display_name("example");
11425 /// ```
11426 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11427 self.display_name = v.into();
11428 self
11429 }
11430
11431 /// Sets the value of [fields][crate::model::OptimizeToursValidationError::fields].
11432 ///
11433 /// # Example
11434 /// ```ignore,no_run
11435 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11436 /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11437 /// let x = OptimizeToursValidationError::new()
11438 /// .set_fields([
11439 /// FieldReference::default()/* use setters */,
11440 /// FieldReference::default()/* use (different) setters */,
11441 /// ]);
11442 /// ```
11443 pub fn set_fields<T, V>(mut self, v: T) -> Self
11444 where
11445 T: std::iter::IntoIterator<Item = V>,
11446 V: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11447 {
11448 use std::iter::Iterator;
11449 self.fields = v.into_iter().map(|i| i.into()).collect();
11450 self
11451 }
11452
11453 /// Sets the value of [error_message][crate::model::OptimizeToursValidationError::error_message].
11454 ///
11455 /// # Example
11456 /// ```ignore,no_run
11457 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11458 /// let x = OptimizeToursValidationError::new().set_error_message("example");
11459 /// ```
11460 pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11461 self.error_message = v.into();
11462 self
11463 }
11464
11465 /// Sets the value of [offending_values][crate::model::OptimizeToursValidationError::offending_values].
11466 ///
11467 /// # Example
11468 /// ```ignore,no_run
11469 /// # use google_cloud_optimization_v1::model::OptimizeToursValidationError;
11470 /// let x = OptimizeToursValidationError::new().set_offending_values("example");
11471 /// ```
11472 pub fn set_offending_values<T: std::convert::Into<std::string::String>>(
11473 mut self,
11474 v: T,
11475 ) -> Self {
11476 self.offending_values = v.into();
11477 self
11478 }
11479}
11480
11481impl wkt::message::Message for OptimizeToursValidationError {
11482 fn typename() -> &'static str {
11483 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError"
11484 }
11485}
11486
11487/// Defines additional types related to [OptimizeToursValidationError].
11488pub mod optimize_tours_validation_error {
11489 #[allow(unused_imports)]
11490 use super::*;
11491
11492 /// Specifies a context for the validation error. A `FieldReference` always
11493 /// refers to a given field in this file and follows the same hierarchical
11494 /// structure. For example, we may specify element #2 of `start_time_windows`
11495 /// of vehicle #5 using:
11496 ///
11497 /// ```norust
11498 /// name: "vehicles" index: 5 sub_field { name: "end_time_windows" index: 2 }
11499 /// ```
11500 ///
11501 /// We however omit top-level entities such as `OptimizeToursRequest` or
11502 /// `ShipmentModel` to avoid crowding the message.
11503 #[derive(Clone, Default, PartialEq)]
11504 #[non_exhaustive]
11505 pub struct FieldReference {
11506 /// Name of the field, e.g., "vehicles".
11507 pub name: std::string::String,
11508
11509 /// Recursively nested sub-field, if needed.
11510 pub sub_field: std::option::Option<
11511 std::boxed::Box<crate::model::optimize_tours_validation_error::FieldReference>,
11512 >,
11513
11514 pub index_or_key: std::option::Option<
11515 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11516 >,
11517
11518 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
11519 }
11520
11521 impl FieldReference {
11522 pub fn new() -> Self {
11523 std::default::Default::default()
11524 }
11525
11526 /// Sets the value of [name][crate::model::optimize_tours_validation_error::FieldReference::name].
11527 ///
11528 /// # Example
11529 /// ```ignore,no_run
11530 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11531 /// let x = FieldReference::new().set_name("example");
11532 /// ```
11533 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11534 self.name = v.into();
11535 self
11536 }
11537
11538 /// Sets the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11539 ///
11540 /// # Example
11541 /// ```ignore,no_run
11542 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11543 /// let x = FieldReference::new().set_sub_field(FieldReference::default()/* use setters */);
11544 /// ```
11545 pub fn set_sub_field<T>(mut self, v: T) -> Self
11546 where
11547 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11548 {
11549 self.sub_field = std::option::Option::Some(std::boxed::Box::new(v.into()));
11550 self
11551 }
11552
11553 /// Sets or clears the value of [sub_field][crate::model::optimize_tours_validation_error::FieldReference::sub_field].
11554 ///
11555 /// # Example
11556 /// ```ignore,no_run
11557 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11558 /// let x = FieldReference::new().set_or_clear_sub_field(Some(FieldReference::default()/* use setters */));
11559 /// let x = FieldReference::new().set_or_clear_sub_field(None::<FieldReference>);
11560 /// ```
11561 pub fn set_or_clear_sub_field<T>(mut self, v: std::option::Option<T>) -> Self
11562 where
11563 T: std::convert::Into<crate::model::optimize_tours_validation_error::FieldReference>,
11564 {
11565 self.sub_field = v.map(|x| std::boxed::Box::new(x.into()));
11566 self
11567 }
11568
11569 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key].
11570 ///
11571 /// Note that all the setters affecting `index_or_key` are mutually
11572 /// exclusive.
11573 ///
11574 /// # Example
11575 /// ```ignore,no_run
11576 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11577 /// use google_cloud_optimization_v1::model::optimize_tours_validation_error::field_reference::IndexOrKey;
11578 /// let x = FieldReference::new().set_index_or_key(Some(IndexOrKey::Index(42)));
11579 /// ```
11580 pub fn set_index_or_key<
11581 T: std::convert::Into<
11582 std::option::Option<
11583 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey,
11584 >,
11585 >,
11586 >(
11587 mut self,
11588 v: T,
11589 ) -> Self {
11590 self.index_or_key = v.into();
11591 self
11592 }
11593
11594 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11595 /// if it holds a `Index`, `None` if the field is not set or
11596 /// holds a different branch.
11597 pub fn index(&self) -> std::option::Option<&i32> {
11598 #[allow(unreachable_patterns)]
11599 self.index_or_key.as_ref().and_then(|v| match v {
11600 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(v) => std::option::Option::Some(v),
11601 _ => std::option::Option::None,
11602 })
11603 }
11604
11605 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11606 /// to hold a `Index`.
11607 ///
11608 /// Note that all the setters affecting `index_or_key` are
11609 /// mutually exclusive.
11610 ///
11611 /// # Example
11612 /// ```ignore,no_run
11613 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11614 /// let x = FieldReference::new().set_index(42);
11615 /// assert!(x.index().is_some());
11616 /// assert!(x.key().is_none());
11617 /// ```
11618 pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
11619 self.index_or_key = std::option::Option::Some(
11620 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Index(
11621 v.into(),
11622 ),
11623 );
11624 self
11625 }
11626
11627 /// The value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11628 /// if it holds a `Key`, `None` if the field is not set or
11629 /// holds a different branch.
11630 pub fn key(&self) -> std::option::Option<&std::string::String> {
11631 #[allow(unreachable_patterns)]
11632 self.index_or_key.as_ref().and_then(|v| match v {
11633 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11634 v,
11635 ) => std::option::Option::Some(v),
11636 _ => std::option::Option::None,
11637 })
11638 }
11639
11640 /// Sets the value of [index_or_key][crate::model::optimize_tours_validation_error::FieldReference::index_or_key]
11641 /// to hold a `Key`.
11642 ///
11643 /// Note that all the setters affecting `index_or_key` are
11644 /// mutually exclusive.
11645 ///
11646 /// # Example
11647 /// ```ignore,no_run
11648 /// # use google_cloud_optimization_v1::model::optimize_tours_validation_error::FieldReference;
11649 /// let x = FieldReference::new().set_key("example");
11650 /// assert!(x.key().is_some());
11651 /// assert!(x.index().is_none());
11652 /// ```
11653 pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
11654 self.index_or_key = std::option::Option::Some(
11655 crate::model::optimize_tours_validation_error::field_reference::IndexOrKey::Key(
11656 v.into(),
11657 ),
11658 );
11659 self
11660 }
11661 }
11662
11663 impl wkt::message::Message for FieldReference {
11664 fn typename() -> &'static str {
11665 "type.googleapis.com/google.cloud.optimization.v1.OptimizeToursValidationError.FieldReference"
11666 }
11667 }
11668
11669 /// Defines additional types related to [FieldReference].
11670 pub mod field_reference {
11671 #[allow(unused_imports)]
11672 use super::*;
11673
11674 #[derive(Clone, Debug, PartialEq)]
11675 #[non_exhaustive]
11676 pub enum IndexOrKey {
11677 /// Index of the field if repeated.
11678 Index(i32),
11679 /// Key if the field is a map.
11680 Key(std::string::String),
11681 }
11682 }
11683}
11684
11685/// Data formats for input and output files.
11686///
11687/// # Working with unknown values
11688///
11689/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11690/// additional enum variants at any time. Adding new variants is not considered
11691/// a breaking change. Applications should write their code in anticipation of:
11692///
11693/// - New values appearing in future releases of the client library, **and**
11694/// - New values received dynamically, without application changes.
11695///
11696/// Please consult the [Working with enums] section in the user guide for some
11697/// guidelines.
11698///
11699/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11700#[derive(Clone, Debug, PartialEq)]
11701#[non_exhaustive]
11702pub enum DataFormat {
11703 /// Default value.
11704 Unspecified,
11705 /// Input data in json format.
11706 Json,
11707 /// Input data in string format.
11708 String,
11709 /// If set, the enum was initialized with an unknown value.
11710 ///
11711 /// Applications can examine the value using [DataFormat::value] or
11712 /// [DataFormat::name].
11713 UnknownValue(data_format::UnknownValue),
11714}
11715
11716#[doc(hidden)]
11717pub mod data_format {
11718 #[allow(unused_imports)]
11719 use super::*;
11720 #[derive(Clone, Debug, PartialEq)]
11721 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11722}
11723
11724impl DataFormat {
11725 /// Gets the enum value.
11726 ///
11727 /// Returns `None` if the enum contains an unknown value deserialized from
11728 /// the string representation of enums.
11729 pub fn value(&self) -> std::option::Option<i32> {
11730 match self {
11731 Self::Unspecified => std::option::Option::Some(0),
11732 Self::Json => std::option::Option::Some(1),
11733 Self::String => std::option::Option::Some(2),
11734 Self::UnknownValue(u) => u.0.value(),
11735 }
11736 }
11737
11738 /// Gets the enum value as a string.
11739 ///
11740 /// Returns `None` if the enum contains an unknown value deserialized from
11741 /// the integer representation of enums.
11742 pub fn name(&self) -> std::option::Option<&str> {
11743 match self {
11744 Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
11745 Self::Json => std::option::Option::Some("JSON"),
11746 Self::String => std::option::Option::Some("STRING"),
11747 Self::UnknownValue(u) => u.0.name(),
11748 }
11749 }
11750}
11751
11752impl std::default::Default for DataFormat {
11753 fn default() -> Self {
11754 use std::convert::From;
11755 Self::from(0)
11756 }
11757}
11758
11759impl std::fmt::Display for DataFormat {
11760 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11761 wkt::internal::display_enum(f, self.name(), self.value())
11762 }
11763}
11764
11765impl std::convert::From<i32> for DataFormat {
11766 fn from(value: i32) -> Self {
11767 match value {
11768 0 => Self::Unspecified,
11769 1 => Self::Json,
11770 2 => Self::String,
11771 _ => Self::UnknownValue(data_format::UnknownValue(
11772 wkt::internal::UnknownEnumValue::Integer(value),
11773 )),
11774 }
11775 }
11776}
11777
11778impl std::convert::From<&str> for DataFormat {
11779 fn from(value: &str) -> Self {
11780 use std::string::ToString;
11781 match value {
11782 "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
11783 "JSON" => Self::Json,
11784 "STRING" => Self::String,
11785 _ => Self::UnknownValue(data_format::UnknownValue(
11786 wkt::internal::UnknownEnumValue::String(value.to_string()),
11787 )),
11788 }
11789 }
11790}
11791
11792impl serde::ser::Serialize for DataFormat {
11793 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11794 where
11795 S: serde::Serializer,
11796 {
11797 match self {
11798 Self::Unspecified => serializer.serialize_i32(0),
11799 Self::Json => serializer.serialize_i32(1),
11800 Self::String => serializer.serialize_i32(2),
11801 Self::UnknownValue(u) => u.0.serialize(serializer),
11802 }
11803 }
11804}
11805
11806impl<'de> serde::de::Deserialize<'de> for DataFormat {
11807 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11808 where
11809 D: serde::Deserializer<'de>,
11810 {
11811 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
11812 ".google.cloud.optimization.v1.DataFormat",
11813 ))
11814 }
11815}