google_cloud_type/model.rs
1// Copyright 2024 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::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21#![no_implicit_prelude]
22extern crate bytes;
23extern crate serde;
24extern crate serde_json;
25extern crate serde_with;
26extern crate std;
27extern crate wkt;
28
29mod debug;
30mod deserialize;
31mod serialize;
32
33/// Represents a color in the RGBA color space. This representation is designed
34/// for simplicity of conversion to and from color representations in various
35/// languages over compactness. For example, the fields of this representation
36/// can be trivially provided to the constructor of `java.awt.Color` in Java; it
37/// can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha`
38/// method in iOS; and, with just a little work, it can be easily formatted into
39/// a CSS `rgba()` string in JavaScript.
40///
41/// This reference page doesn't have information about the absolute color
42/// space that should be used to interpret the RGB value—for example, sRGB,
43/// Adobe RGB,
44/// DCI-P3, and BT.2020. By default, applications should assume the sRGB color
45/// space.
46///
47/// When color equality needs to be decided, implementations, unless documented
48/// otherwise, treat two colors as equal if all their red, green, blue, and alpha
49/// values each differ by at most `1e-5`.
50///
51/// Example (Java):
52///
53/// ```norust
54/// import com.google.type.Color;
55///
56/// // ...
57/// public static java.awt.Color fromProto(Color protocolor) {
58/// float alpha = protocolor.hasAlpha()
59/// ? protocolor.getAlpha().getValue()
60/// : 1.0;
61///
62/// return new java.awt.Color(
63/// protocolor.getRed(),
64/// protocolor.getGreen(),
65/// protocolor.getBlue(),
66/// alpha);
67/// }
68///
69/// public static Color toProto(java.awt.Color color) {
70/// float red = (float) color.getRed();
71/// float green = (float) color.getGreen();
72/// float blue = (float) color.getBlue();
73/// float denominator = 255.0;
74/// Color.Builder resultBuilder =
75/// Color
76/// .newBuilder()
77/// .setRed(red / denominator)
78/// .setGreen(green / denominator)
79/// .setBlue(blue / denominator);
80/// int alpha = color.getAlpha();
81/// if (alpha != 255) {
82/// result.setAlpha(
83/// FloatValue
84/// .newBuilder()
85/// .setValue(((float) alpha) / denominator)
86/// .build());
87/// }
88/// return resultBuilder.build();
89/// }
90/// // ...
91/// ```
92///
93/// Example (iOS / Obj-C):
94///
95/// ```norust
96/// // ...
97/// static UIColor* fromProto(Color* protocolor) {
98/// float red = [protocolor red];
99/// float green = [protocolor green];
100/// float blue = [protocolor blue];
101/// FloatValue* alpha_wrapper = [protocolor alpha];
102/// float alpha = 1.0;
103/// if (alpha_wrapper != nil) {
104/// alpha = [alpha_wrapper value];
105/// }
106/// return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
107/// }
108///
109/// static Color* toProto(UIColor* color) {
110/// CGFloat red, green, blue, alpha;
111/// if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
112/// return nil;
113/// }
114/// Color* result = [[Color alloc] init];
115/// [result setRed:red];
116/// [result setGreen:green];
117/// [result setBlue:blue];
118/// if (alpha <= 0.9999) {
119/// [result setAlpha:floatWrapperWithValue(alpha)];
120/// }
121/// [result autorelease];
122/// return result;
123/// }
124/// // ...
125/// ```
126///
127/// Example (JavaScript):
128///
129/// ```norust
130/// // ...
131///
132/// var protoToCssColor = function(rgb_color) {
133/// var redFrac = rgb_color.red || 0.0;
134/// var greenFrac = rgb_color.green || 0.0;
135/// var blueFrac = rgb_color.blue || 0.0;
136/// var red = Math.floor(redFrac * 255);
137/// var green = Math.floor(greenFrac * 255);
138/// var blue = Math.floor(blueFrac * 255);
139///
140/// if (!('alpha' in rgb_color)) {
141/// return rgbToCssColor(red, green, blue);
142/// }
143///
144/// var alphaFrac = rgb_color.alpha.value || 0.0;
145/// var rgbParams = [red, green, blue].join(',');
146/// return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
147/// };
148///
149/// var rgbToCssColor = function(red, green, blue) {
150/// var rgbNumber = new Number((red << 16) | (green << 8) | blue);
151/// var hexString = rgbNumber.toString(16);
152/// var missingZeros = 6 - hexString.length;
153/// var resultBuilder = ['#'];
154/// for (var i = 0; i < missingZeros; i++) {
155/// resultBuilder.push('0');
156/// }
157/// resultBuilder.push(hexString);
158/// return resultBuilder.join('');
159/// };
160///
161/// // ...
162/// ```
163#[derive(Clone, Default, PartialEq)]
164#[non_exhaustive]
165pub struct Color {
166 /// The amount of red in the color as a value in the interval [0, 1].
167 pub red: f32,
168
169 /// The amount of green in the color as a value in the interval [0, 1].
170 pub green: f32,
171
172 /// The amount of blue in the color as a value in the interval [0, 1].
173 pub blue: f32,
174
175 /// The fraction of this color that should be applied to the pixel. That is,
176 /// the final pixel color is defined by the equation:
177 ///
178 /// `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)`
179 ///
180 /// This means that a value of 1.0 corresponds to a solid color, whereas
181 /// a value of 0.0 corresponds to a completely transparent color. This
182 /// uses a wrapper message rather than a simple float scalar so that it is
183 /// possible to distinguish between a default value and the value being unset.
184 /// If omitted, this color object is rendered as a solid color
185 /// (as if the alpha value had been explicitly given a value of 1.0).
186 pub alpha: std::option::Option<wkt::FloatValue>,
187
188 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
189}
190
191impl Color {
192 /// Creates a new default instance.
193 pub fn new() -> Self {
194 std::default::Default::default()
195 }
196
197 /// Sets the value of [red][crate::model::Color::red].
198 ///
199 /// # Example
200 /// ```ignore,no_run
201 /// # use google_cloud_type::model::Color;
202 /// let x = Color::new().set_red(42.0);
203 /// ```
204 pub fn set_red<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
205 self.red = v.into();
206 self
207 }
208
209 /// Sets the value of [green][crate::model::Color::green].
210 ///
211 /// # Example
212 /// ```ignore,no_run
213 /// # use google_cloud_type::model::Color;
214 /// let x = Color::new().set_green(42.0);
215 /// ```
216 pub fn set_green<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
217 self.green = v.into();
218 self
219 }
220
221 /// Sets the value of [blue][crate::model::Color::blue].
222 ///
223 /// # Example
224 /// ```ignore,no_run
225 /// # use google_cloud_type::model::Color;
226 /// let x = Color::new().set_blue(42.0);
227 /// ```
228 pub fn set_blue<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
229 self.blue = v.into();
230 self
231 }
232
233 /// Sets the value of [alpha][crate::model::Color::alpha].
234 ///
235 /// # Example
236 /// ```ignore,no_run
237 /// # use google_cloud_type::model::Color;
238 /// use wkt::FloatValue;
239 /// let x = Color::new().set_alpha(FloatValue::default()/* use setters */);
240 /// ```
241 pub fn set_alpha<T>(mut self, v: T) -> Self
242 where
243 T: std::convert::Into<wkt::FloatValue>,
244 {
245 self.alpha = std::option::Option::Some(v.into());
246 self
247 }
248
249 /// Sets or clears the value of [alpha][crate::model::Color::alpha].
250 ///
251 /// # Example
252 /// ```ignore,no_run
253 /// # use google_cloud_type::model::Color;
254 /// use wkt::FloatValue;
255 /// let x = Color::new().set_or_clear_alpha(Some(FloatValue::default()/* use setters */));
256 /// let x = Color::new().set_or_clear_alpha(None::<FloatValue>);
257 /// ```
258 pub fn set_or_clear_alpha<T>(mut self, v: std::option::Option<T>) -> Self
259 where
260 T: std::convert::Into<wkt::FloatValue>,
261 {
262 self.alpha = v.map(|x| x.into());
263 self
264 }
265}
266
267impl wkt::message::Message for Color {
268 fn typename() -> &'static str {
269 "type.googleapis.com/google.type.Color"
270 }
271}
272
273/// Represents a whole or partial calendar date, such as a birthday. The time of
274/// day and time zone are either specified elsewhere or are insignificant. The
275/// date is relative to the Gregorian Calendar. This can represent one of the
276/// following:
277///
278/// * A full date, with non-zero year, month, and day values.
279/// * A month and day, with a zero year (for example, an anniversary).
280/// * A year on its own, with a zero month and a zero day.
281/// * A year and month, with a zero day (for example, a credit card expiration
282/// date).
283///
284/// Related types:
285///
286/// * [google.type.TimeOfDay][google.type.TimeOfDay]
287/// * [google.type.DateTime][google.type.DateTime]
288/// * [google.protobuf.Timestamp][google.protobuf.Timestamp]
289///
290/// [google.protobuf.Timestamp]: wkt::Timestamp
291/// [google.type.DateTime]: crate::model::DateTime
292/// [google.type.TimeOfDay]: crate::model::TimeOfDay
293#[derive(Clone, Default, PartialEq)]
294#[non_exhaustive]
295pub struct Date {
296 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without
297 /// a year.
298 pub year: i32,
299
300 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a
301 /// month and day.
302 pub month: i32,
303
304 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0
305 /// to specify a year by itself or a year and month where the day isn't
306 /// significant.
307 pub day: i32,
308
309 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
310}
311
312impl Date {
313 /// Creates a new default instance.
314 pub fn new() -> Self {
315 std::default::Default::default()
316 }
317
318 /// Sets the value of [year][crate::model::Date::year].
319 ///
320 /// # Example
321 /// ```ignore,no_run
322 /// # use google_cloud_type::model::Date;
323 /// let x = Date::new().set_year(42);
324 /// ```
325 pub fn set_year<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
326 self.year = v.into();
327 self
328 }
329
330 /// Sets the value of [month][crate::model::Date::month].
331 ///
332 /// # Example
333 /// ```ignore,no_run
334 /// # use google_cloud_type::model::Date;
335 /// let x = Date::new().set_month(42);
336 /// ```
337 pub fn set_month<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
338 self.month = v.into();
339 self
340 }
341
342 /// Sets the value of [day][crate::model::Date::day].
343 ///
344 /// # Example
345 /// ```ignore,no_run
346 /// # use google_cloud_type::model::Date;
347 /// let x = Date::new().set_day(42);
348 /// ```
349 pub fn set_day<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
350 self.day = v.into();
351 self
352 }
353}
354
355impl wkt::message::Message for Date {
356 fn typename() -> &'static str {
357 "type.googleapis.com/google.type.Date"
358 }
359}
360
361/// Represents civil time (or occasionally physical time).
362///
363/// This type can represent a civil time in one of a few possible ways:
364///
365/// * When utc_offset is set and time_zone is unset: a civil time on a calendar
366/// day with a particular offset from UTC.
367/// * When time_zone is set and utc_offset is unset: a civil time on a calendar
368/// day in a particular time zone.
369/// * When neither time_zone nor utc_offset is set: a civil time on a calendar
370/// day in local time.
371///
372/// The date is relative to the Proleptic Gregorian Calendar.
373///
374/// If year, month, or day are 0, the DateTime is considered not to have a
375/// specific year, month, or day respectively.
376///
377/// This type may also be used to represent a physical time if all the date and
378/// time fields are set and either case of the `time_offset` oneof is set.
379/// Consider using `Timestamp` message for physical time instead. If your use
380/// case also would like to store the user's timezone, that can be done in
381/// another field.
382///
383/// This type is more flexible than some applications may want. Make sure to
384/// document and validate your application's limitations.
385#[derive(Clone, Default, PartialEq)]
386#[non_exhaustive]
387pub struct DateTime {
388 /// Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a
389 /// datetime without a year.
390 pub year: i32,
391
392 /// Optional. Month of year. Must be from 1 to 12, or 0 if specifying a
393 /// datetime without a month.
394 pub month: i32,
395
396 /// Optional. Day of month. Must be from 1 to 31 and valid for the year and
397 /// month, or 0 if specifying a datetime without a day.
398 pub day: i32,
399
400 /// Optional. Hours of day in 24 hour format. Should be from 0 to 23, defaults
401 /// to 0 (midnight). An API may choose to allow the value "24:00:00" for
402 /// scenarios like business closing time.
403 pub hours: i32,
404
405 /// Optional. Minutes of hour of day. Must be from 0 to 59, defaults to 0.
406 pub minutes: i32,
407
408 /// Optional. Seconds of minutes of the time. Must normally be from 0 to 59,
409 /// defaults to 0. An API may allow the value 60 if it allows leap-seconds.
410 pub seconds: i32,
411
412 /// Optional. Fractions of seconds in nanoseconds. Must be from 0 to
413 /// 999,999,999, defaults to 0.
414 pub nanos: i32,
415
416 /// Optional. Specifies either the UTC offset or the time zone of the DateTime.
417 /// Choose carefully between them, considering that time zone data may change
418 /// in the future (for example, a country modifies their DST start/end dates,
419 /// and future DateTimes in the affected range had already been stored).
420 /// If omitted, the DateTime is considered to be in local time.
421 pub time_offset: std::option::Option<crate::model::date_time::TimeOffset>,
422
423 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
424}
425
426impl DateTime {
427 /// Creates a new default instance.
428 pub fn new() -> Self {
429 std::default::Default::default()
430 }
431
432 /// Sets the value of [year][crate::model::DateTime::year].
433 ///
434 /// # Example
435 /// ```ignore,no_run
436 /// # use google_cloud_type::model::DateTime;
437 /// let x = DateTime::new().set_year(42);
438 /// ```
439 pub fn set_year<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
440 self.year = v.into();
441 self
442 }
443
444 /// Sets the value of [month][crate::model::DateTime::month].
445 ///
446 /// # Example
447 /// ```ignore,no_run
448 /// # use google_cloud_type::model::DateTime;
449 /// let x = DateTime::new().set_month(42);
450 /// ```
451 pub fn set_month<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
452 self.month = v.into();
453 self
454 }
455
456 /// Sets the value of [day][crate::model::DateTime::day].
457 ///
458 /// # Example
459 /// ```ignore,no_run
460 /// # use google_cloud_type::model::DateTime;
461 /// let x = DateTime::new().set_day(42);
462 /// ```
463 pub fn set_day<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
464 self.day = v.into();
465 self
466 }
467
468 /// Sets the value of [hours][crate::model::DateTime::hours].
469 ///
470 /// # Example
471 /// ```ignore,no_run
472 /// # use google_cloud_type::model::DateTime;
473 /// let x = DateTime::new().set_hours(42);
474 /// ```
475 pub fn set_hours<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
476 self.hours = v.into();
477 self
478 }
479
480 /// Sets the value of [minutes][crate::model::DateTime::minutes].
481 ///
482 /// # Example
483 /// ```ignore,no_run
484 /// # use google_cloud_type::model::DateTime;
485 /// let x = DateTime::new().set_minutes(42);
486 /// ```
487 pub fn set_minutes<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
488 self.minutes = v.into();
489 self
490 }
491
492 /// Sets the value of [seconds][crate::model::DateTime::seconds].
493 ///
494 /// # Example
495 /// ```ignore,no_run
496 /// # use google_cloud_type::model::DateTime;
497 /// let x = DateTime::new().set_seconds(42);
498 /// ```
499 pub fn set_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
500 self.seconds = v.into();
501 self
502 }
503
504 /// Sets the value of [nanos][crate::model::DateTime::nanos].
505 ///
506 /// # Example
507 /// ```ignore,no_run
508 /// # use google_cloud_type::model::DateTime;
509 /// let x = DateTime::new().set_nanos(42);
510 /// ```
511 pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
512 self.nanos = v.into();
513 self
514 }
515
516 /// Sets the value of [time_offset][crate::model::DateTime::time_offset].
517 ///
518 /// Note that all the setters affecting `time_offset` are mutually
519 /// exclusive.
520 ///
521 /// # Example
522 /// ```ignore,no_run
523 /// # use google_cloud_type::model::DateTime;
524 /// use wkt::Duration;
525 /// let x = DateTime::new().set_time_offset(Some(
526 /// google_cloud_type::model::date_time::TimeOffset::UtcOffset(Duration::default().into())));
527 /// ```
528 pub fn set_time_offset<
529 T: std::convert::Into<std::option::Option<crate::model::date_time::TimeOffset>>,
530 >(
531 mut self,
532 v: T,
533 ) -> Self {
534 self.time_offset = v.into();
535 self
536 }
537
538 /// The value of [time_offset][crate::model::DateTime::time_offset]
539 /// if it holds a `UtcOffset`, `None` if the field is not set or
540 /// holds a different branch.
541 pub fn utc_offset(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
542 #[allow(unreachable_patterns)]
543 self.time_offset.as_ref().and_then(|v| match v {
544 crate::model::date_time::TimeOffset::UtcOffset(v) => std::option::Option::Some(v),
545 _ => std::option::Option::None,
546 })
547 }
548
549 /// Sets the value of [time_offset][crate::model::DateTime::time_offset]
550 /// to hold a `UtcOffset`.
551 ///
552 /// Note that all the setters affecting `time_offset` are
553 /// mutually exclusive.
554 ///
555 /// # Example
556 /// ```ignore,no_run
557 /// # use google_cloud_type::model::DateTime;
558 /// use wkt::Duration;
559 /// let x = DateTime::new().set_utc_offset(Duration::default()/* use setters */);
560 /// assert!(x.utc_offset().is_some());
561 /// assert!(x.time_zone().is_none());
562 /// ```
563 pub fn set_utc_offset<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
564 mut self,
565 v: T,
566 ) -> Self {
567 self.time_offset =
568 std::option::Option::Some(crate::model::date_time::TimeOffset::UtcOffset(v.into()));
569 self
570 }
571
572 /// The value of [time_offset][crate::model::DateTime::time_offset]
573 /// if it holds a `TimeZone`, `None` if the field is not set or
574 /// holds a different branch.
575 pub fn time_zone(&self) -> std::option::Option<&std::boxed::Box<crate::model::TimeZone>> {
576 #[allow(unreachable_patterns)]
577 self.time_offset.as_ref().and_then(|v| match v {
578 crate::model::date_time::TimeOffset::TimeZone(v) => std::option::Option::Some(v),
579 _ => std::option::Option::None,
580 })
581 }
582
583 /// Sets the value of [time_offset][crate::model::DateTime::time_offset]
584 /// to hold a `TimeZone`.
585 ///
586 /// Note that all the setters affecting `time_offset` are
587 /// mutually exclusive.
588 ///
589 /// # Example
590 /// ```ignore,no_run
591 /// # use google_cloud_type::model::DateTime;
592 /// use google_cloud_type::model::TimeZone;
593 /// let x = DateTime::new().set_time_zone(TimeZone::default()/* use setters */);
594 /// assert!(x.time_zone().is_some());
595 /// assert!(x.utc_offset().is_none());
596 /// ```
597 pub fn set_time_zone<T: std::convert::Into<std::boxed::Box<crate::model::TimeZone>>>(
598 mut self,
599 v: T,
600 ) -> Self {
601 self.time_offset =
602 std::option::Option::Some(crate::model::date_time::TimeOffset::TimeZone(v.into()));
603 self
604 }
605}
606
607impl wkt::message::Message for DateTime {
608 fn typename() -> &'static str {
609 "type.googleapis.com/google.type.DateTime"
610 }
611}
612
613/// Defines additional types related to [DateTime].
614pub mod date_time {
615 #[allow(unused_imports)]
616 use super::*;
617
618 /// Optional. Specifies either the UTC offset or the time zone of the DateTime.
619 /// Choose carefully between them, considering that time zone data may change
620 /// in the future (for example, a country modifies their DST start/end dates,
621 /// and future DateTimes in the affected range had already been stored).
622 /// If omitted, the DateTime is considered to be in local time.
623 #[derive(Clone, Debug, PartialEq)]
624 #[non_exhaustive]
625 pub enum TimeOffset {
626 /// UTC offset. Must be whole seconds, between -18 hours and +18 hours.
627 /// For example, a UTC offset of -4:00 would be represented as
628 /// { seconds: -14400 }.
629 UtcOffset(std::boxed::Box<wkt::Duration>),
630 /// Time zone.
631 TimeZone(std::boxed::Box<crate::model::TimeZone>),
632 }
633}
634
635/// Represents a time zone from the
636/// [IANA Time Zone Database](https://www.iana.org/time-zones).
637#[derive(Clone, Default, PartialEq)]
638#[non_exhaustive]
639pub struct TimeZone {
640 /// IANA Time Zone Database time zone. For example "America/New_York".
641 pub id: std::string::String,
642
643 /// Optional. IANA Time Zone Database version number. For example "2019a".
644 pub version: std::string::String,
645
646 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
647}
648
649impl TimeZone {
650 /// Creates a new default instance.
651 pub fn new() -> Self {
652 std::default::Default::default()
653 }
654
655 /// Sets the value of [id][crate::model::TimeZone::id].
656 ///
657 /// # Example
658 /// ```ignore,no_run
659 /// # use google_cloud_type::model::TimeZone;
660 /// let x = TimeZone::new().set_id("example");
661 /// ```
662 pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
663 self.id = v.into();
664 self
665 }
666
667 /// Sets the value of [version][crate::model::TimeZone::version].
668 ///
669 /// # Example
670 /// ```ignore,no_run
671 /// # use google_cloud_type::model::TimeZone;
672 /// let x = TimeZone::new().set_version("example");
673 /// ```
674 pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
675 self.version = v.into();
676 self
677 }
678}
679
680impl wkt::message::Message for TimeZone {
681 fn typename() -> &'static str {
682 "type.googleapis.com/google.type.TimeZone"
683 }
684}
685
686/// A representation of a decimal value, such as 2.5. Clients may convert values
687/// into language-native decimal formats, such as Java's
688/// [BigDecimal](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html)
689/// or Python's
690/// [decimal.Decimal](https://docs.python.org/3/library/decimal.html).
691#[derive(Clone, Default, PartialEq)]
692#[non_exhaustive]
693pub struct Decimal {
694 /// The decimal value, as a string.
695 ///
696 /// The string representation consists of an optional sign, `+` (`U+002B`)
697 /// or `-` (`U+002D`), followed by a sequence of zero or more decimal digits
698 /// ("the integer"), optionally followed by a fraction, optionally followed
699 /// by an exponent. An empty string **should** be interpreted as `0`.
700 ///
701 /// The fraction consists of a decimal point followed by zero or more decimal
702 /// digits. The string must contain at least one digit in either the integer
703 /// or the fraction. The number formed by the sign, the integer and the
704 /// fraction is referred to as the significand.
705 ///
706 /// The exponent consists of the character `e` (`U+0065`) or `E` (`U+0045`)
707 /// followed by one or more decimal digits.
708 ///
709 /// Services **should** normalize decimal values before storing them by:
710 ///
711 /// - Removing an explicitly-provided `+` sign (`+2.5` -> `2.5`).
712 /// - Replacing a zero-length integer value with `0` (`.5` -> `0.5`).
713 /// - Coercing the exponent character to upper-case, with explicit sign
714 /// (`2.5e8` -> `2.5E+8`).
715 /// - Removing an explicitly-provided zero exponent (`2.5E0` -> `2.5`).
716 ///
717 /// Services **may** perform additional normalization based on its own needs
718 /// and the internal decimal implementation selected, such as shifting the
719 /// decimal point and exponent value together (example: `2.5E-1` <-> `0.25`).
720 /// Additionally, services **may** preserve trailing zeroes in the fraction
721 /// to indicate increased precision, but are not required to do so.
722 ///
723 /// Note that only the `.` character is supported to divide the integer
724 /// and the fraction; `,` **should not** be supported regardless of locale.
725 /// Additionally, thousand separators **should not** be supported. If a
726 /// service does support them, values **must** be normalized.
727 ///
728 /// The ENBF grammar is:
729 ///
730 /// ```norust
731 /// DecimalString =
732 /// '' | [Sign] Significand [Exponent];
733 ///
734 /// Sign = '+' | '-';
735 ///
736 /// Significand =
737 /// Digits ['.'] [Digits] | [Digits] '.' Digits;
738 ///
739 /// Exponent = ('e' | 'E') [Sign] Digits;
740 ///
741 /// Digits = { '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' };
742 /// ```
743 ///
744 /// Services **should** clearly document the range of supported values, the
745 /// maximum supported precision (total number of digits), and, if applicable,
746 /// the scale (number of digits after the decimal point), as well as how it
747 /// behaves when receiving out-of-bounds values.
748 ///
749 /// Services **may** choose to accept values passed as input even when the
750 /// value has a higher precision or scale than the service supports, and
751 /// **should** round the value to fit the supported scale. Alternatively, the
752 /// service **may** error with `400 Bad Request` (`INVALID_ARGUMENT` in gRPC)
753 /// if precision would be lost.
754 ///
755 /// Services **should** error with `400 Bad Request` (`INVALID_ARGUMENT` in
756 /// gRPC) if the service receives a value outside of the supported range.
757 pub value: std::string::String,
758
759 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
760}
761
762impl Decimal {
763 /// Creates a new default instance.
764 pub fn new() -> Self {
765 std::default::Default::default()
766 }
767
768 /// Sets the value of [value][crate::model::Decimal::value].
769 ///
770 /// # Example
771 /// ```ignore,no_run
772 /// # use google_cloud_type::model::Decimal;
773 /// let x = Decimal::new().set_value("example");
774 /// ```
775 pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
776 self.value = v.into();
777 self
778 }
779}
780
781impl wkt::message::Message for Decimal {
782 fn typename() -> &'static str {
783 "type.googleapis.com/google.type.Decimal"
784 }
785}
786
787/// Represents a textual expression in the Common Expression Language (CEL)
788/// syntax. CEL is a C-like expression language. The syntax and semantics of CEL
789/// are documented at <https://github.com/google/cel-spec>.
790///
791/// Example (Comparison):
792///
793/// ```norust
794/// title: "Summary size limit"
795/// description: "Determines if a summary is less than 100 chars"
796/// expression: "document.summary.size() < 100"
797/// ```
798///
799/// Example (Equality):
800///
801/// ```norust
802/// title: "Requestor is owner"
803/// description: "Determines if requestor is the document owner"
804/// expression: "document.owner == request.auth.claims.email"
805/// ```
806///
807/// Example (Logic):
808///
809/// ```norust
810/// title: "Public documents"
811/// description: "Determine whether the document should be publicly visible"
812/// expression: "document.type != 'private' && document.type != 'internal'"
813/// ```
814///
815/// Example (Data Manipulation):
816///
817/// ```norust
818/// title: "Notification string"
819/// description: "Create a notification string with a timestamp."
820/// expression: "'New message received at ' + string(document.create_time)"
821/// ```
822///
823/// The exact variables and functions that may be referenced within an expression
824/// are determined by the service that evaluates it. See the service
825/// documentation for additional information.
826#[derive(Clone, Default, PartialEq)]
827#[non_exhaustive]
828pub struct Expr {
829 /// Textual representation of an expression in Common Expression Language
830 /// syntax.
831 pub expression: std::string::String,
832
833 /// Optional. Title for the expression, i.e. a short string describing
834 /// its purpose. This can be used e.g. in UIs which allow to enter the
835 /// expression.
836 pub title: std::string::String,
837
838 /// Optional. Description of the expression. This is a longer text which
839 /// describes the expression, e.g. when hovered over it in a UI.
840 pub description: std::string::String,
841
842 /// Optional. String indicating the location of the expression for error
843 /// reporting, e.g. a file name and a position in the file.
844 pub location: std::string::String,
845
846 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
847}
848
849impl Expr {
850 /// Creates a new default instance.
851 pub fn new() -> Self {
852 std::default::Default::default()
853 }
854
855 /// Sets the value of [expression][crate::model::Expr::expression].
856 ///
857 /// # Example
858 /// ```ignore,no_run
859 /// # use google_cloud_type::model::Expr;
860 /// let x = Expr::new().set_expression("example");
861 /// ```
862 pub fn set_expression<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
863 self.expression = v.into();
864 self
865 }
866
867 /// Sets the value of [title][crate::model::Expr::title].
868 ///
869 /// # Example
870 /// ```ignore,no_run
871 /// # use google_cloud_type::model::Expr;
872 /// let x = Expr::new().set_title("example");
873 /// ```
874 pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
875 self.title = v.into();
876 self
877 }
878
879 /// Sets the value of [description][crate::model::Expr::description].
880 ///
881 /// # Example
882 /// ```ignore,no_run
883 /// # use google_cloud_type::model::Expr;
884 /// let x = Expr::new().set_description("example");
885 /// ```
886 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
887 self.description = v.into();
888 self
889 }
890
891 /// Sets the value of [location][crate::model::Expr::location].
892 ///
893 /// # Example
894 /// ```ignore,no_run
895 /// # use google_cloud_type::model::Expr;
896 /// let x = Expr::new().set_location("example");
897 /// ```
898 pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
899 self.location = v.into();
900 self
901 }
902}
903
904impl wkt::message::Message for Expr {
905 fn typename() -> &'static str {
906 "type.googleapis.com/google.type.Expr"
907 }
908}
909
910/// Represents a fraction in terms of a numerator divided by a denominator.
911#[derive(Clone, Default, PartialEq)]
912#[non_exhaustive]
913pub struct Fraction {
914 /// The numerator in the fraction, e.g. 2 in 2/3.
915 pub numerator: i64,
916
917 /// The value by which the numerator is divided, e.g. 3 in 2/3. Must be
918 /// positive.
919 pub denominator: i64,
920
921 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
922}
923
924impl Fraction {
925 /// Creates a new default instance.
926 pub fn new() -> Self {
927 std::default::Default::default()
928 }
929
930 /// Sets the value of [numerator][crate::model::Fraction::numerator].
931 ///
932 /// # Example
933 /// ```ignore,no_run
934 /// # use google_cloud_type::model::Fraction;
935 /// let x = Fraction::new().set_numerator(42);
936 /// ```
937 pub fn set_numerator<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
938 self.numerator = v.into();
939 self
940 }
941
942 /// Sets the value of [denominator][crate::model::Fraction::denominator].
943 ///
944 /// # Example
945 /// ```ignore,no_run
946 /// # use google_cloud_type::model::Fraction;
947 /// let x = Fraction::new().set_denominator(42);
948 /// ```
949 pub fn set_denominator<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
950 self.denominator = v.into();
951 self
952 }
953}
954
955impl wkt::message::Message for Fraction {
956 fn typename() -> &'static str {
957 "type.googleapis.com/google.type.Fraction"
958 }
959}
960
961/// Represents a time interval, encoded as a Timestamp start (inclusive) and a
962/// Timestamp end (exclusive).
963///
964/// The start must be less than or equal to the end.
965/// When the start equals the end, the interval is empty (matches no time).
966/// When both start and end are unspecified, the interval matches any time.
967#[derive(Clone, Default, PartialEq)]
968#[non_exhaustive]
969pub struct Interval {
970 /// Optional. Inclusive start of the interval.
971 ///
972 /// If specified, a Timestamp matching this interval will have to be the same
973 /// or after the start.
974 pub start_time: std::option::Option<wkt::Timestamp>,
975
976 /// Optional. Exclusive end of the interval.
977 ///
978 /// If specified, a Timestamp matching this interval will have to be before the
979 /// end.
980 pub end_time: std::option::Option<wkt::Timestamp>,
981
982 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
983}
984
985impl Interval {
986 /// Creates a new default instance.
987 pub fn new() -> Self {
988 std::default::Default::default()
989 }
990
991 /// Sets the value of [start_time][crate::model::Interval::start_time].
992 ///
993 /// # Example
994 /// ```ignore,no_run
995 /// # use google_cloud_type::model::Interval;
996 /// use wkt::Timestamp;
997 /// let x = Interval::new().set_start_time(Timestamp::default()/* use setters */);
998 /// ```
999 pub fn set_start_time<T>(mut self, v: T) -> Self
1000 where
1001 T: std::convert::Into<wkt::Timestamp>,
1002 {
1003 self.start_time = std::option::Option::Some(v.into());
1004 self
1005 }
1006
1007 /// Sets or clears the value of [start_time][crate::model::Interval::start_time].
1008 ///
1009 /// # Example
1010 /// ```ignore,no_run
1011 /// # use google_cloud_type::model::Interval;
1012 /// use wkt::Timestamp;
1013 /// let x = Interval::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
1014 /// let x = Interval::new().set_or_clear_start_time(None::<Timestamp>);
1015 /// ```
1016 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
1017 where
1018 T: std::convert::Into<wkt::Timestamp>,
1019 {
1020 self.start_time = v.map(|x| x.into());
1021 self
1022 }
1023
1024 /// Sets the value of [end_time][crate::model::Interval::end_time].
1025 ///
1026 /// # Example
1027 /// ```ignore,no_run
1028 /// # use google_cloud_type::model::Interval;
1029 /// use wkt::Timestamp;
1030 /// let x = Interval::new().set_end_time(Timestamp::default()/* use setters */);
1031 /// ```
1032 pub fn set_end_time<T>(mut self, v: T) -> Self
1033 where
1034 T: std::convert::Into<wkt::Timestamp>,
1035 {
1036 self.end_time = std::option::Option::Some(v.into());
1037 self
1038 }
1039
1040 /// Sets or clears the value of [end_time][crate::model::Interval::end_time].
1041 ///
1042 /// # Example
1043 /// ```ignore,no_run
1044 /// # use google_cloud_type::model::Interval;
1045 /// use wkt::Timestamp;
1046 /// let x = Interval::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
1047 /// let x = Interval::new().set_or_clear_end_time(None::<Timestamp>);
1048 /// ```
1049 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
1050 where
1051 T: std::convert::Into<wkt::Timestamp>,
1052 {
1053 self.end_time = v.map(|x| x.into());
1054 self
1055 }
1056}
1057
1058impl wkt::message::Message for Interval {
1059 fn typename() -> &'static str {
1060 "type.googleapis.com/google.type.Interval"
1061 }
1062}
1063
1064/// An object that represents a latitude/longitude pair. This is expressed as a
1065/// pair of doubles to represent degrees latitude and degrees longitude. Unless
1066/// specified otherwise, this object must conform to the
1067/// <a href="https://en.wikipedia.org/wiki/World_Geodetic_System#1984_version">
1068/// WGS84 standard</a>. Values must be within normalized ranges.
1069#[derive(Clone, Default, PartialEq)]
1070#[non_exhaustive]
1071pub struct LatLng {
1072 /// The latitude in degrees. It must be in the range [-90.0, +90.0].
1073 pub latitude: f64,
1074
1075 /// The longitude in degrees. It must be in the range [-180.0, +180.0].
1076 pub longitude: f64,
1077
1078 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1079}
1080
1081impl LatLng {
1082 /// Creates a new default instance.
1083 pub fn new() -> Self {
1084 std::default::Default::default()
1085 }
1086
1087 /// Sets the value of [latitude][crate::model::LatLng::latitude].
1088 ///
1089 /// # Example
1090 /// ```ignore,no_run
1091 /// # use google_cloud_type::model::LatLng;
1092 /// let x = LatLng::new().set_latitude(42.0);
1093 /// ```
1094 pub fn set_latitude<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1095 self.latitude = v.into();
1096 self
1097 }
1098
1099 /// Sets the value of [longitude][crate::model::LatLng::longitude].
1100 ///
1101 /// # Example
1102 /// ```ignore,no_run
1103 /// # use google_cloud_type::model::LatLng;
1104 /// let x = LatLng::new().set_longitude(42.0);
1105 /// ```
1106 pub fn set_longitude<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1107 self.longitude = v.into();
1108 self
1109 }
1110}
1111
1112impl wkt::message::Message for LatLng {
1113 fn typename() -> &'static str {
1114 "type.googleapis.com/google.type.LatLng"
1115 }
1116}
1117
1118/// Localized variant of a text in a particular language.
1119#[derive(Clone, Default, PartialEq)]
1120#[non_exhaustive]
1121pub struct LocalizedText {
1122 /// Localized string in the language corresponding to
1123 /// [language_code][google.type.LocalizedText.language_code] below.
1124 ///
1125 /// [google.type.LocalizedText.language_code]: crate::model::LocalizedText::language_code
1126 pub text: std::string::String,
1127
1128 /// The text's BCP-47 language code, such as "en-US" or "sr-Latn".
1129 ///
1130 /// For more information, see
1131 /// <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>.
1132 pub language_code: std::string::String,
1133
1134 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1135}
1136
1137impl LocalizedText {
1138 /// Creates a new default instance.
1139 pub fn new() -> Self {
1140 std::default::Default::default()
1141 }
1142
1143 /// Sets the value of [text][crate::model::LocalizedText::text].
1144 ///
1145 /// # Example
1146 /// ```ignore,no_run
1147 /// # use google_cloud_type::model::LocalizedText;
1148 /// let x = LocalizedText::new().set_text("example");
1149 /// ```
1150 pub fn set_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1151 self.text = v.into();
1152 self
1153 }
1154
1155 /// Sets the value of [language_code][crate::model::LocalizedText::language_code].
1156 ///
1157 /// # Example
1158 /// ```ignore,no_run
1159 /// # use google_cloud_type::model::LocalizedText;
1160 /// let x = LocalizedText::new().set_language_code("example");
1161 /// ```
1162 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1163 self.language_code = v.into();
1164 self
1165 }
1166}
1167
1168impl wkt::message::Message for LocalizedText {
1169 fn typename() -> &'static str {
1170 "type.googleapis.com/google.type.LocalizedText"
1171 }
1172}
1173
1174/// Represents an amount of money with its currency type.
1175#[derive(Clone, Default, PartialEq)]
1176#[non_exhaustive]
1177pub struct Money {
1178 /// The three-letter currency code defined in ISO 4217.
1179 pub currency_code: std::string::String,
1180
1181 /// The whole units of the amount.
1182 /// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
1183 pub units: i64,
1184
1185 /// Number of nano (10^-9) units of the amount.
1186 /// The value must be between -999,999,999 and +999,999,999 inclusive.
1187 /// If `units` is positive, `nanos` must be positive or zero.
1188 /// If `units` is zero, `nanos` can be positive, zero, or negative.
1189 /// If `units` is negative, `nanos` must be negative or zero.
1190 /// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
1191 pub nanos: i32,
1192
1193 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1194}
1195
1196impl Money {
1197 /// Creates a new default instance.
1198 pub fn new() -> Self {
1199 std::default::Default::default()
1200 }
1201
1202 /// Sets the value of [currency_code][crate::model::Money::currency_code].
1203 ///
1204 /// # Example
1205 /// ```ignore,no_run
1206 /// # use google_cloud_type::model::Money;
1207 /// let x = Money::new().set_currency_code("example");
1208 /// ```
1209 pub fn set_currency_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1210 self.currency_code = v.into();
1211 self
1212 }
1213
1214 /// Sets the value of [units][crate::model::Money::units].
1215 ///
1216 /// # Example
1217 /// ```ignore,no_run
1218 /// # use google_cloud_type::model::Money;
1219 /// let x = Money::new().set_units(42);
1220 /// ```
1221 pub fn set_units<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1222 self.units = v.into();
1223 self
1224 }
1225
1226 /// Sets the value of [nanos][crate::model::Money::nanos].
1227 ///
1228 /// # Example
1229 /// ```ignore,no_run
1230 /// # use google_cloud_type::model::Money;
1231 /// let x = Money::new().set_nanos(42);
1232 /// ```
1233 pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1234 self.nanos = v.into();
1235 self
1236 }
1237}
1238
1239impl wkt::message::Message for Money {
1240 fn typename() -> &'static str {
1241 "type.googleapis.com/google.type.Money"
1242 }
1243}
1244
1245/// An object representing a phone number, suitable as an API wire format.
1246///
1247/// This representation:
1248///
1249/// - should not be used for locale-specific formatting of a phone number, such
1250/// as "+1 (650) 253-0000 ext. 123"
1251///
1252/// - is not designed for efficient storage
1253///
1254/// - may not be suitable for dialing - specialized libraries (see references)
1255/// should be used to parse the number for that purpose
1256///
1257///
1258/// To do something meaningful with this number, such as format it for various
1259/// use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first.
1260///
1261/// For instance, in Java this would be:
1262///
1263/// ```norust
1264/// com.google.type.PhoneNumber wireProto =
1265/// com.google.type.PhoneNumber.newBuilder().build();
1266/// com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber =
1267/// PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ");
1268/// if (!wireProto.getExtension().isEmpty()) {
1269/// phoneNumber.setExtension(wireProto.getExtension());
1270/// }
1271/// ```
1272///
1273/// Reference(s):
1274///
1275/// - <https://github.com/google/libphonenumber>
1276#[derive(Clone, Default, PartialEq)]
1277#[non_exhaustive]
1278pub struct PhoneNumber {
1279 /// The phone number's extension. The extension is not standardized in ITU
1280 /// recommendations, except for being defined as a series of numbers with a
1281 /// maximum length of 40 digits. Other than digits, some other dialing
1282 /// characters such as ',' (indicating a wait) or '#' may be stored here.
1283 ///
1284 /// Note that no regions currently use extensions with short codes, so this
1285 /// field is normally only set in conjunction with an E.164 number. It is held
1286 /// separately from the E.164 number to allow for short code extensions in the
1287 /// future.
1288 pub extension: std::string::String,
1289
1290 /// Required. Either a regular number, or a short code. New fields may be
1291 /// added to the oneof below in the future, so clients should ignore phone
1292 /// numbers for which none of the fields they coded against are set.
1293 pub kind: std::option::Option<crate::model::phone_number::Kind>,
1294
1295 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1296}
1297
1298impl PhoneNumber {
1299 /// Creates a new default instance.
1300 pub fn new() -> Self {
1301 std::default::Default::default()
1302 }
1303
1304 /// Sets the value of [extension][crate::model::PhoneNumber::extension].
1305 ///
1306 /// # Example
1307 /// ```ignore,no_run
1308 /// # use google_cloud_type::model::PhoneNumber;
1309 /// let x = PhoneNumber::new().set_extension("example");
1310 /// ```
1311 pub fn set_extension<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1312 self.extension = v.into();
1313 self
1314 }
1315
1316 /// Sets the value of [kind][crate::model::PhoneNumber::kind].
1317 ///
1318 /// Note that all the setters affecting `kind` are mutually
1319 /// exclusive.
1320 ///
1321 /// # Example
1322 /// ```ignore,no_run
1323 /// # use google_cloud_type::model::PhoneNumber;
1324 /// use google_cloud_type::model::phone_number::Kind;
1325 /// let x = PhoneNumber::new().set_kind(Some(Kind::E164Number("example".to_string())));
1326 /// ```
1327 pub fn set_kind<
1328 T: std::convert::Into<std::option::Option<crate::model::phone_number::Kind>>,
1329 >(
1330 mut self,
1331 v: T,
1332 ) -> Self {
1333 self.kind = v.into();
1334 self
1335 }
1336
1337 /// The value of [kind][crate::model::PhoneNumber::kind]
1338 /// if it holds a `E164Number`, `None` if the field is not set or
1339 /// holds a different branch.
1340 pub fn e164_number(&self) -> std::option::Option<&std::string::String> {
1341 #[allow(unreachable_patterns)]
1342 self.kind.as_ref().and_then(|v| match v {
1343 crate::model::phone_number::Kind::E164Number(v) => std::option::Option::Some(v),
1344 _ => std::option::Option::None,
1345 })
1346 }
1347
1348 /// Sets the value of [kind][crate::model::PhoneNumber::kind]
1349 /// to hold a `E164Number`.
1350 ///
1351 /// Note that all the setters affecting `kind` are
1352 /// mutually exclusive.
1353 ///
1354 /// # Example
1355 /// ```ignore,no_run
1356 /// # use google_cloud_type::model::PhoneNumber;
1357 /// let x = PhoneNumber::new().set_e164_number("example");
1358 /// assert!(x.e164_number().is_some());
1359 /// assert!(x.short_code().is_none());
1360 /// ```
1361 pub fn set_e164_number<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1362 self.kind =
1363 std::option::Option::Some(crate::model::phone_number::Kind::E164Number(v.into()));
1364 self
1365 }
1366
1367 /// The value of [kind][crate::model::PhoneNumber::kind]
1368 /// if it holds a `ShortCode`, `None` if the field is not set or
1369 /// holds a different branch.
1370 pub fn short_code(
1371 &self,
1372 ) -> std::option::Option<&std::boxed::Box<crate::model::phone_number::ShortCode>> {
1373 #[allow(unreachable_patterns)]
1374 self.kind.as_ref().and_then(|v| match v {
1375 crate::model::phone_number::Kind::ShortCode(v) => std::option::Option::Some(v),
1376 _ => std::option::Option::None,
1377 })
1378 }
1379
1380 /// Sets the value of [kind][crate::model::PhoneNumber::kind]
1381 /// to hold a `ShortCode`.
1382 ///
1383 /// Note that all the setters affecting `kind` are
1384 /// mutually exclusive.
1385 ///
1386 /// # Example
1387 /// ```ignore,no_run
1388 /// # use google_cloud_type::model::PhoneNumber;
1389 /// use google_cloud_type::model::phone_number::ShortCode;
1390 /// let x = PhoneNumber::new().set_short_code(ShortCode::default()/* use setters */);
1391 /// assert!(x.short_code().is_some());
1392 /// assert!(x.e164_number().is_none());
1393 /// ```
1394 pub fn set_short_code<
1395 T: std::convert::Into<std::boxed::Box<crate::model::phone_number::ShortCode>>,
1396 >(
1397 mut self,
1398 v: T,
1399 ) -> Self {
1400 self.kind =
1401 std::option::Option::Some(crate::model::phone_number::Kind::ShortCode(v.into()));
1402 self
1403 }
1404}
1405
1406impl wkt::message::Message for PhoneNumber {
1407 fn typename() -> &'static str {
1408 "type.googleapis.com/google.type.PhoneNumber"
1409 }
1410}
1411
1412/// Defines additional types related to [PhoneNumber].
1413pub mod phone_number {
1414 #[allow(unused_imports)]
1415 use super::*;
1416
1417 /// An object representing a short code, which is a phone number that is
1418 /// typically much shorter than regular phone numbers and can be used to
1419 /// address messages in MMS and SMS systems, as well as for abbreviated dialing
1420 /// (For example "Text 611 to see how many minutes you have remaining on your
1421 /// plan.").
1422 ///
1423 /// Short codes are restricted to a region and are not internationally
1424 /// dialable, which means the same short code can exist in different regions,
1425 /// with different usage and pricing, even if those regions share the same
1426 /// country calling code (For example: US and CA).
1427 #[derive(Clone, Default, PartialEq)]
1428 #[non_exhaustive]
1429 pub struct ShortCode {
1430 /// Required. The BCP-47 region code of the location where calls to this
1431 /// short code can be made, such as "US" and "BB".
1432 ///
1433 /// Reference(s):
1434 ///
1435 /// - <http://www.unicode.org/reports/tr35/#unicode_region_subtag>
1436 pub region_code: std::string::String,
1437
1438 /// Required. The short code digits, without a leading plus ('+') or country
1439 /// calling code. For example "611".
1440 pub number: std::string::String,
1441
1442 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1443 }
1444
1445 impl ShortCode {
1446 /// Creates a new default instance.
1447 pub fn new() -> Self {
1448 std::default::Default::default()
1449 }
1450
1451 /// Sets the value of [region_code][crate::model::phone_number::ShortCode::region_code].
1452 ///
1453 /// # Example
1454 /// ```ignore,no_run
1455 /// # use google_cloud_type::model::phone_number::ShortCode;
1456 /// let x = ShortCode::new().set_region_code("example");
1457 /// ```
1458 pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1459 self.region_code = v.into();
1460 self
1461 }
1462
1463 /// Sets the value of [number][crate::model::phone_number::ShortCode::number].
1464 ///
1465 /// # Example
1466 /// ```ignore,no_run
1467 /// # use google_cloud_type::model::phone_number::ShortCode;
1468 /// let x = ShortCode::new().set_number("example");
1469 /// ```
1470 pub fn set_number<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1471 self.number = v.into();
1472 self
1473 }
1474 }
1475
1476 impl wkt::message::Message for ShortCode {
1477 fn typename() -> &'static str {
1478 "type.googleapis.com/google.type.PhoneNumber.ShortCode"
1479 }
1480 }
1481
1482 /// Required. Either a regular number, or a short code. New fields may be
1483 /// added to the oneof below in the future, so clients should ignore phone
1484 /// numbers for which none of the fields they coded against are set.
1485 #[derive(Clone, Debug, PartialEq)]
1486 #[non_exhaustive]
1487 pub enum Kind {
1488 /// The phone number, represented as a leading plus sign ('+'), followed by a
1489 /// phone number that uses a relaxed ITU E.164 format consisting of the
1490 /// country calling code (1 to 3 digits) and the subscriber number, with no
1491 /// additional spaces or formatting. For example:
1492 ///
1493 /// - correct: "+15552220123"
1494 ///
1495 /// - incorrect: "+1 (555) 222-01234 x123"
1496 ///
1497 ///
1498 /// The ITU E.164 format limits the latter to 12 digits, but in practice not
1499 /// all countries respect that, so we relax that restriction here.
1500 /// National-only numbers are not allowed.
1501 ///
1502 /// References:
1503 ///
1504 /// - <https://www.itu.int/rec/T-REC-E.164-201011-I>
1505 ///
1506 /// - <https://en.wikipedia.org/wiki/E.164>.
1507 ///
1508 /// - <https://en.wikipedia.org/wiki/List_of_country_calling_codes>
1509 ///
1510 E164Number(std::string::String),
1511 /// A short code.
1512 ///
1513 /// Reference(s):
1514 ///
1515 /// - <https://wikipedia.org/wiki/Short_code>
1516 ShortCode(std::boxed::Box<crate::model::phone_number::ShortCode>),
1517 }
1518}
1519
1520/// Represents a postal address, such as for postal delivery or payments
1521/// addresses. With a postal address, a postal service can deliver items to a
1522/// premise, P.O. box, or similar. A postal address is not intended to model
1523/// geographical locations like roads, towns, or mountains.
1524///
1525/// In typical usage, an address would be created by user input or from importing
1526/// existing data, depending on the type of process.
1527///
1528/// Advice on address input or editing:
1529///
1530/// - Use an internationalization-ready address widget such as
1531/// <https://github.com/google/libaddressinput>.
1532/// - Users should not be presented with UI elements for input or editing of
1533/// fields outside countries where that field is used.
1534///
1535/// For more guidance on how to use this schema, see:
1536/// <https://support.google.com/business/answer/6397478>.
1537#[derive(Clone, Default, PartialEq)]
1538#[non_exhaustive]
1539pub struct PostalAddress {
1540 /// The schema revision of the `PostalAddress`. This must be set to 0, which is
1541 /// the latest revision.
1542 ///
1543 /// All new revisions **must** be backward compatible with old revisions.
1544 pub revision: i32,
1545
1546 /// Required. CLDR region code of the country/region of the address. This
1547 /// is never inferred and it is up to the user to ensure the value is
1548 /// correct. See <https://cldr.unicode.org/> and
1549 /// <https://www.unicode.org/cldr/charts/30/supplemental/territory_information.html>
1550 /// for details. Example: "CH" for Switzerland.
1551 pub region_code: std::string::String,
1552
1553 /// Optional. BCP-47 language code of the contents of this address (if
1554 /// known). This is often the UI language of the input form or is expected
1555 /// to match one of the languages used in the address' country/region, or their
1556 /// transliterated equivalents.
1557 /// This can affect formatting in certain countries, but is not critical
1558 /// to the correctness of the data and will never affect any validation or
1559 /// other non-formatting related operations.
1560 ///
1561 /// If this value is not known, it should be omitted (rather than specifying a
1562 /// possibly incorrect default).
1563 ///
1564 /// Examples: "zh-Hant", "ja", "ja-Latn", "en".
1565 pub language_code: std::string::String,
1566
1567 /// Optional. Postal code of the address. Not all countries use or require
1568 /// postal codes to be present, but where they are used, they may trigger
1569 /// additional validation with other parts of the address (for example,
1570 /// state or zip code validation in the United States).
1571 pub postal_code: std::string::String,
1572
1573 /// Optional. Additional, country-specific, sorting code. This is not used
1574 /// in most regions. Where it is used, the value is either a string like
1575 /// "CEDEX", optionally followed by a number (for example, "CEDEX 7"), or just
1576 /// a number alone, representing the "sector code" (Jamaica), "delivery area
1577 /// indicator" (Malawi) or "post office indicator" (Côte d'Ivoire).
1578 pub sorting_code: std::string::String,
1579
1580 /// Optional. Highest administrative subdivision which is used for postal
1581 /// addresses of a country or region.
1582 /// For example, this can be a state, a province, an oblast, or a prefecture.
1583 /// For Spain, this is the province and not the autonomous
1584 /// community (for example, "Barcelona" and not "Catalonia").
1585 /// Many countries don't use an administrative area in postal addresses. For
1586 /// example, in Switzerland, this should be left unpopulated.
1587 pub administrative_area: std::string::String,
1588
1589 /// Optional. Generally refers to the city or town portion of the address.
1590 /// Examples: US city, IT comune, UK post town.
1591 /// In regions of the world where localities are not well defined or do not fit
1592 /// into this structure well, leave `locality` empty and use `address_lines`.
1593 pub locality: std::string::String,
1594
1595 /// Optional. Sublocality of the address.
1596 /// For example, this can be a neighborhood, borough, or district.
1597 pub sublocality: std::string::String,
1598
1599 /// Unstructured address lines describing the lower levels of an address.
1600 ///
1601 /// Because values in `address_lines` do not have type information and may
1602 /// sometimes contain multiple values in a single field (for example,
1603 /// "Austin, TX"), it is important that the line order is clear. The order of
1604 /// address lines should be "envelope order" for the country or region of the
1605 /// address. In places where this can vary (for example, Japan),
1606 /// `address_language` is used to make it explicit (for example, "ja" for
1607 /// large-to-small ordering and "ja-Latn" or "en" for small-to-large). In this
1608 /// way, the most specific line of an address can be selected based on the
1609 /// language.
1610 ///
1611 /// The minimum permitted structural representation of an address consists
1612 /// of a `region_code` with all remaining information placed in the
1613 /// `address_lines`. It would be possible to format such an address very
1614 /// approximately without geocoding, but no semantic reasoning could be
1615 /// made about any of the address components until it was at least
1616 /// partially resolved.
1617 ///
1618 /// Creating an address only containing a `region_code` and `address_lines` and
1619 /// then geocoding is the recommended way to handle completely unstructured
1620 /// addresses (as opposed to guessing which parts of the address should be
1621 /// localities or administrative areas).
1622 pub address_lines: std::vec::Vec<std::string::String>,
1623
1624 /// Optional. The recipient at the address.
1625 /// This field may, under certain circumstances, contain multiline information.
1626 /// For example, it might contain "care of" information.
1627 pub recipients: std::vec::Vec<std::string::String>,
1628
1629 /// Optional. The name of the organization at the address.
1630 pub organization: std::string::String,
1631
1632 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1633}
1634
1635impl PostalAddress {
1636 /// Creates a new default instance.
1637 pub fn new() -> Self {
1638 std::default::Default::default()
1639 }
1640
1641 /// Sets the value of [revision][crate::model::PostalAddress::revision].
1642 ///
1643 /// # Example
1644 /// ```ignore,no_run
1645 /// # use google_cloud_type::model::PostalAddress;
1646 /// let x = PostalAddress::new().set_revision(42);
1647 /// ```
1648 pub fn set_revision<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1649 self.revision = v.into();
1650 self
1651 }
1652
1653 /// Sets the value of [region_code][crate::model::PostalAddress::region_code].
1654 ///
1655 /// # Example
1656 /// ```ignore,no_run
1657 /// # use google_cloud_type::model::PostalAddress;
1658 /// let x = PostalAddress::new().set_region_code("example");
1659 /// ```
1660 pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1661 self.region_code = v.into();
1662 self
1663 }
1664
1665 /// Sets the value of [language_code][crate::model::PostalAddress::language_code].
1666 ///
1667 /// # Example
1668 /// ```ignore,no_run
1669 /// # use google_cloud_type::model::PostalAddress;
1670 /// let x = PostalAddress::new().set_language_code("example");
1671 /// ```
1672 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1673 self.language_code = v.into();
1674 self
1675 }
1676
1677 /// Sets the value of [postal_code][crate::model::PostalAddress::postal_code].
1678 ///
1679 /// # Example
1680 /// ```ignore,no_run
1681 /// # use google_cloud_type::model::PostalAddress;
1682 /// let x = PostalAddress::new().set_postal_code("example");
1683 /// ```
1684 pub fn set_postal_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1685 self.postal_code = v.into();
1686 self
1687 }
1688
1689 /// Sets the value of [sorting_code][crate::model::PostalAddress::sorting_code].
1690 ///
1691 /// # Example
1692 /// ```ignore,no_run
1693 /// # use google_cloud_type::model::PostalAddress;
1694 /// let x = PostalAddress::new().set_sorting_code("example");
1695 /// ```
1696 pub fn set_sorting_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1697 self.sorting_code = v.into();
1698 self
1699 }
1700
1701 /// Sets the value of [administrative_area][crate::model::PostalAddress::administrative_area].
1702 ///
1703 /// # Example
1704 /// ```ignore,no_run
1705 /// # use google_cloud_type::model::PostalAddress;
1706 /// let x = PostalAddress::new().set_administrative_area("example");
1707 /// ```
1708 pub fn set_administrative_area<T: std::convert::Into<std::string::String>>(
1709 mut self,
1710 v: T,
1711 ) -> Self {
1712 self.administrative_area = v.into();
1713 self
1714 }
1715
1716 /// Sets the value of [locality][crate::model::PostalAddress::locality].
1717 ///
1718 /// # Example
1719 /// ```ignore,no_run
1720 /// # use google_cloud_type::model::PostalAddress;
1721 /// let x = PostalAddress::new().set_locality("example");
1722 /// ```
1723 pub fn set_locality<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1724 self.locality = v.into();
1725 self
1726 }
1727
1728 /// Sets the value of [sublocality][crate::model::PostalAddress::sublocality].
1729 ///
1730 /// # Example
1731 /// ```ignore,no_run
1732 /// # use google_cloud_type::model::PostalAddress;
1733 /// let x = PostalAddress::new().set_sublocality("example");
1734 /// ```
1735 pub fn set_sublocality<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1736 self.sublocality = v.into();
1737 self
1738 }
1739
1740 /// Sets the value of [address_lines][crate::model::PostalAddress::address_lines].
1741 ///
1742 /// # Example
1743 /// ```ignore,no_run
1744 /// # use google_cloud_type::model::PostalAddress;
1745 /// let x = PostalAddress::new().set_address_lines(["a", "b", "c"]);
1746 /// ```
1747 pub fn set_address_lines<T, V>(mut self, v: T) -> Self
1748 where
1749 T: std::iter::IntoIterator<Item = V>,
1750 V: std::convert::Into<std::string::String>,
1751 {
1752 use std::iter::Iterator;
1753 self.address_lines = v.into_iter().map(|i| i.into()).collect();
1754 self
1755 }
1756
1757 /// Sets the value of [recipients][crate::model::PostalAddress::recipients].
1758 ///
1759 /// # Example
1760 /// ```ignore,no_run
1761 /// # use google_cloud_type::model::PostalAddress;
1762 /// let x = PostalAddress::new().set_recipients(["a", "b", "c"]);
1763 /// ```
1764 pub fn set_recipients<T, V>(mut self, v: T) -> Self
1765 where
1766 T: std::iter::IntoIterator<Item = V>,
1767 V: std::convert::Into<std::string::String>,
1768 {
1769 use std::iter::Iterator;
1770 self.recipients = v.into_iter().map(|i| i.into()).collect();
1771 self
1772 }
1773
1774 /// Sets the value of [organization][crate::model::PostalAddress::organization].
1775 ///
1776 /// # Example
1777 /// ```ignore,no_run
1778 /// # use google_cloud_type::model::PostalAddress;
1779 /// let x = PostalAddress::new().set_organization("example");
1780 /// ```
1781 pub fn set_organization<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1782 self.organization = v.into();
1783 self
1784 }
1785}
1786
1787impl wkt::message::Message for PostalAddress {
1788 fn typename() -> &'static str {
1789 "type.googleapis.com/google.type.PostalAddress"
1790 }
1791}
1792
1793/// A quaternion, represented by four 64-bit floating point values.
1794///
1795/// A quaternion is defined as the quotient of two directed lines in a
1796/// three-dimensional space or equivalently as the quotient of two Euclidean
1797/// vectors (<https://en.wikipedia.org/wiki/Quaternion>).
1798///
1799/// Quaternions are often used in calculations involving three-dimensional
1800/// rotations (<https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation>),
1801/// as they provide greater mathematical robustness by avoiding the gimbal lock
1802/// problems that can be encountered when using Euler angles
1803/// (<https://en.wikipedia.org/wiki/Gimbal_lock>).
1804///
1805/// Quaternions are generally represented in this form:
1806///
1807/// ```norust
1808/// w + xi + yj + zk
1809/// ```
1810///
1811/// where x, y, z, and w are real numbers, and i, j, and k are three imaginary
1812/// numbers.
1813///
1814/// The naming choice `(x, y, z, w)` comes from the desire to avoid confusion for
1815/// those interested in the geometric properties of the quaternion in the 3D
1816/// Cartesian space. Other texts often use alternative names or subscripts, such
1817/// as `(a, b, c, d)`, `(1, i, j, k)`, or `(0, 1, 2, 3)`, which are perhaps
1818/// better suited for mathematical interpretations.
1819///
1820/// To avoid any confusion, as well as to maintain compatibility with a large
1821/// number of software libraries, the quaternions represented using the protocol
1822/// buffer below *must* follow the Hamilton convention, which defines `ij = k`
1823/// (i.e. a right-handed algebra), and therefore:
1824///
1825/// ```norust
1826/// i^2 = j^2 = k^2 = ijk = −1
1827/// ij = −ji = k
1828/// jk = −kj = i
1829/// ki = −ik = j
1830/// ```
1831///
1832/// Please DO NOT use this to represent quaternions that follow the JPL
1833/// convention, or any of the other quaternion flavors out there.
1834///
1835/// Definitions:
1836///
1837/// - Quaternion norm (or magnitude): `sqrt(x^2 + y^2 + z^2 + w^2)`.
1838/// - Unit (or normalized) quaternion: a quaternion whose norm is 1.
1839/// - Pure quaternion: a quaternion whose scalar component (`w`) is 0.
1840/// - Rotation quaternion: a unit quaternion used to represent rotation.
1841/// - Orientation quaternion: a unit quaternion used to represent orientation.
1842///
1843/// A quaternion can be normalized by dividing it by its norm. The resulting
1844/// quaternion maintains the same direction, but has a norm of 1, i.e. it moves
1845/// on the unit sphere. This is generally necessary for rotation and orientation
1846/// quaternions, to avoid rounding errors:
1847/// <https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions>
1848///
1849/// Note that `(x, y, z, w)` and `(-x, -y, -z, -w)` represent the same rotation,
1850/// but normalization would be even more useful, e.g. for comparison purposes, if
1851/// it would produce a unique representation. It is thus recommended that `w` be
1852/// kept positive, which can be achieved by changing all the signs when `w` is
1853/// negative.
1854#[derive(Clone, Default, PartialEq)]
1855#[non_exhaustive]
1856pub struct Quaternion {
1857 /// The x component.
1858 pub x: f64,
1859
1860 /// The y component.
1861 pub y: f64,
1862
1863 /// The z component.
1864 pub z: f64,
1865
1866 /// The scalar component.
1867 pub w: f64,
1868
1869 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1870}
1871
1872impl Quaternion {
1873 /// Creates a new default instance.
1874 pub fn new() -> Self {
1875 std::default::Default::default()
1876 }
1877
1878 /// Sets the value of [x][crate::model::Quaternion::x].
1879 ///
1880 /// # Example
1881 /// ```ignore,no_run
1882 /// # use google_cloud_type::model::Quaternion;
1883 /// let x = Quaternion::new().set_x(42.0);
1884 /// ```
1885 pub fn set_x<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1886 self.x = v.into();
1887 self
1888 }
1889
1890 /// Sets the value of [y][crate::model::Quaternion::y].
1891 ///
1892 /// # Example
1893 /// ```ignore,no_run
1894 /// # use google_cloud_type::model::Quaternion;
1895 /// let x = Quaternion::new().set_y(42.0);
1896 /// ```
1897 pub fn set_y<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1898 self.y = v.into();
1899 self
1900 }
1901
1902 /// Sets the value of [z][crate::model::Quaternion::z].
1903 ///
1904 /// # Example
1905 /// ```ignore,no_run
1906 /// # use google_cloud_type::model::Quaternion;
1907 /// let x = Quaternion::new().set_z(42.0);
1908 /// ```
1909 pub fn set_z<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1910 self.z = v.into();
1911 self
1912 }
1913
1914 /// Sets the value of [w][crate::model::Quaternion::w].
1915 ///
1916 /// # Example
1917 /// ```ignore,no_run
1918 /// # use google_cloud_type::model::Quaternion;
1919 /// let x = Quaternion::new().set_w(42.0);
1920 /// ```
1921 pub fn set_w<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1922 self.w = v.into();
1923 self
1924 }
1925}
1926
1927impl wkt::message::Message for Quaternion {
1928 fn typename() -> &'static str {
1929 "type.googleapis.com/google.type.Quaternion"
1930 }
1931}
1932
1933/// Represents a time of day. The date and time zone are either not significant
1934/// or are specified elsewhere. An API may choose to allow leap seconds. Related
1935/// types are [google.type.Date][google.type.Date] and
1936/// `google.protobuf.Timestamp`.
1937///
1938/// [google.type.Date]: crate::model::Date
1939#[derive(Clone, Default, PartialEq)]
1940#[non_exhaustive]
1941pub struct TimeOfDay {
1942 /// Hours of a day in 24 hour format. Must be greater than or equal to 0 and
1943 /// typically must be less than or equal to 23. An API may choose to allow the
1944 /// value "24:00:00" for scenarios like business closing time.
1945 pub hours: i32,
1946
1947 /// Minutes of an hour. Must be greater than or equal to 0 and less than or
1948 /// equal to 59.
1949 pub minutes: i32,
1950
1951 /// Seconds of a minute. Must be greater than or equal to 0 and typically must
1952 /// be less than or equal to 59. An API may allow the value 60 if it allows
1953 /// leap-seconds.
1954 pub seconds: i32,
1955
1956 /// Fractions of seconds, in nanoseconds. Must be greater than or equal to 0
1957 /// and less than or equal to 999,999,999.
1958 pub nanos: i32,
1959
1960 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1961}
1962
1963impl TimeOfDay {
1964 /// Creates a new default instance.
1965 pub fn new() -> Self {
1966 std::default::Default::default()
1967 }
1968
1969 /// Sets the value of [hours][crate::model::TimeOfDay::hours].
1970 ///
1971 /// # Example
1972 /// ```ignore,no_run
1973 /// # use google_cloud_type::model::TimeOfDay;
1974 /// let x = TimeOfDay::new().set_hours(42);
1975 /// ```
1976 pub fn set_hours<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1977 self.hours = v.into();
1978 self
1979 }
1980
1981 /// Sets the value of [minutes][crate::model::TimeOfDay::minutes].
1982 ///
1983 /// # Example
1984 /// ```ignore,no_run
1985 /// # use google_cloud_type::model::TimeOfDay;
1986 /// let x = TimeOfDay::new().set_minutes(42);
1987 /// ```
1988 pub fn set_minutes<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1989 self.minutes = v.into();
1990 self
1991 }
1992
1993 /// Sets the value of [seconds][crate::model::TimeOfDay::seconds].
1994 ///
1995 /// # Example
1996 /// ```ignore,no_run
1997 /// # use google_cloud_type::model::TimeOfDay;
1998 /// let x = TimeOfDay::new().set_seconds(42);
1999 /// ```
2000 pub fn set_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2001 self.seconds = v.into();
2002 self
2003 }
2004
2005 /// Sets the value of [nanos][crate::model::TimeOfDay::nanos].
2006 ///
2007 /// # Example
2008 /// ```ignore,no_run
2009 /// # use google_cloud_type::model::TimeOfDay;
2010 /// let x = TimeOfDay::new().set_nanos(42);
2011 /// ```
2012 pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2013 self.nanos = v.into();
2014 self
2015 }
2016}
2017
2018impl wkt::message::Message for TimeOfDay {
2019 fn typename() -> &'static str {
2020 "type.googleapis.com/google.type.TimeOfDay"
2021 }
2022}
2023
2024/// A `CalendarPeriod` represents the abstract concept of a time period that has
2025/// a canonical start. Grammatically, "the start of the current
2026/// `CalendarPeriod`." All calendar times begin at midnight UTC.
2027///
2028/// # Working with unknown values
2029///
2030/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2031/// additional enum variants at any time. Adding new variants is not considered
2032/// a breaking change. Applications should write their code in anticipation of:
2033///
2034/// - New values appearing in future releases of the client library, **and**
2035/// - New values received dynamically, without application changes.
2036///
2037/// Please consult the [Working with enums] section in the user guide for some
2038/// guidelines.
2039///
2040/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2041#[derive(Clone, Debug, PartialEq)]
2042#[non_exhaustive]
2043pub enum CalendarPeriod {
2044 /// Undefined period, raises an error.
2045 Unspecified,
2046 /// A day.
2047 Day,
2048 /// A week. Weeks begin on Monday, following
2049 /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
2050 Week,
2051 /// A fortnight. The first calendar fortnight of the year begins at the start
2052 /// of week 1 according to
2053 /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
2054 Fortnight,
2055 /// A month.
2056 Month,
2057 /// A quarter. Quarters start on dates 1-Jan, 1-Apr, 1-Jul, and 1-Oct of each
2058 /// year.
2059 Quarter,
2060 /// A half-year. Half-years start on dates 1-Jan and 1-Jul.
2061 Half,
2062 /// A year.
2063 Year,
2064 /// If set, the enum was initialized with an unknown value.
2065 ///
2066 /// Applications can examine the value using [CalendarPeriod::value] or
2067 /// [CalendarPeriod::name].
2068 UnknownValue(calendar_period::UnknownValue),
2069}
2070
2071#[doc(hidden)]
2072pub mod calendar_period {
2073 #[allow(unused_imports)]
2074 use super::*;
2075 #[derive(Clone, Debug, PartialEq)]
2076 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2077}
2078
2079impl CalendarPeriod {
2080 /// Gets the enum value.
2081 ///
2082 /// Returns `None` if the enum contains an unknown value deserialized from
2083 /// the string representation of enums.
2084 pub fn value(&self) -> std::option::Option<i32> {
2085 match self {
2086 Self::Unspecified => std::option::Option::Some(0),
2087 Self::Day => std::option::Option::Some(1),
2088 Self::Week => std::option::Option::Some(2),
2089 Self::Fortnight => std::option::Option::Some(3),
2090 Self::Month => std::option::Option::Some(4),
2091 Self::Quarter => std::option::Option::Some(5),
2092 Self::Half => std::option::Option::Some(6),
2093 Self::Year => std::option::Option::Some(7),
2094 Self::UnknownValue(u) => u.0.value(),
2095 }
2096 }
2097
2098 /// Gets the enum value as a string.
2099 ///
2100 /// Returns `None` if the enum contains an unknown value deserialized from
2101 /// the integer representation of enums.
2102 pub fn name(&self) -> std::option::Option<&str> {
2103 match self {
2104 Self::Unspecified => std::option::Option::Some("CALENDAR_PERIOD_UNSPECIFIED"),
2105 Self::Day => std::option::Option::Some("DAY"),
2106 Self::Week => std::option::Option::Some("WEEK"),
2107 Self::Fortnight => std::option::Option::Some("FORTNIGHT"),
2108 Self::Month => std::option::Option::Some("MONTH"),
2109 Self::Quarter => std::option::Option::Some("QUARTER"),
2110 Self::Half => std::option::Option::Some("HALF"),
2111 Self::Year => std::option::Option::Some("YEAR"),
2112 Self::UnknownValue(u) => u.0.name(),
2113 }
2114 }
2115}
2116
2117impl std::default::Default for CalendarPeriod {
2118 fn default() -> Self {
2119 use std::convert::From;
2120 Self::from(0)
2121 }
2122}
2123
2124impl std::fmt::Display for CalendarPeriod {
2125 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2126 wkt::internal::display_enum(f, self.name(), self.value())
2127 }
2128}
2129
2130impl std::convert::From<i32> for CalendarPeriod {
2131 fn from(value: i32) -> Self {
2132 match value {
2133 0 => Self::Unspecified,
2134 1 => Self::Day,
2135 2 => Self::Week,
2136 3 => Self::Fortnight,
2137 4 => Self::Month,
2138 5 => Self::Quarter,
2139 6 => Self::Half,
2140 7 => Self::Year,
2141 _ => Self::UnknownValue(calendar_period::UnknownValue(
2142 wkt::internal::UnknownEnumValue::Integer(value),
2143 )),
2144 }
2145 }
2146}
2147
2148impl std::convert::From<&str> for CalendarPeriod {
2149 fn from(value: &str) -> Self {
2150 use std::string::ToString;
2151 match value {
2152 "CALENDAR_PERIOD_UNSPECIFIED" => Self::Unspecified,
2153 "DAY" => Self::Day,
2154 "WEEK" => Self::Week,
2155 "FORTNIGHT" => Self::Fortnight,
2156 "MONTH" => Self::Month,
2157 "QUARTER" => Self::Quarter,
2158 "HALF" => Self::Half,
2159 "YEAR" => Self::Year,
2160 _ => Self::UnknownValue(calendar_period::UnknownValue(
2161 wkt::internal::UnknownEnumValue::String(value.to_string()),
2162 )),
2163 }
2164 }
2165}
2166
2167impl serde::ser::Serialize for CalendarPeriod {
2168 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2169 where
2170 S: serde::Serializer,
2171 {
2172 match self {
2173 Self::Unspecified => serializer.serialize_i32(0),
2174 Self::Day => serializer.serialize_i32(1),
2175 Self::Week => serializer.serialize_i32(2),
2176 Self::Fortnight => serializer.serialize_i32(3),
2177 Self::Month => serializer.serialize_i32(4),
2178 Self::Quarter => serializer.serialize_i32(5),
2179 Self::Half => serializer.serialize_i32(6),
2180 Self::Year => serializer.serialize_i32(7),
2181 Self::UnknownValue(u) => u.0.serialize(serializer),
2182 }
2183 }
2184}
2185
2186impl<'de> serde::de::Deserialize<'de> for CalendarPeriod {
2187 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2188 where
2189 D: serde::Deserializer<'de>,
2190 {
2191 deserializer.deserialize_any(wkt::internal::EnumVisitor::<CalendarPeriod>::new(
2192 ".google.type.CalendarPeriod",
2193 ))
2194 }
2195}
2196
2197/// Represents a day of the week.
2198///
2199/// # Working with unknown values
2200///
2201/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2202/// additional enum variants at any time. Adding new variants is not considered
2203/// a breaking change. Applications should write their code in anticipation of:
2204///
2205/// - New values appearing in future releases of the client library, **and**
2206/// - New values received dynamically, without application changes.
2207///
2208/// Please consult the [Working with enums] section in the user guide for some
2209/// guidelines.
2210///
2211/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2212#[derive(Clone, Debug, PartialEq)]
2213#[non_exhaustive]
2214pub enum DayOfWeek {
2215 /// The day of the week is unspecified.
2216 Unspecified,
2217 /// Monday
2218 Monday,
2219 /// Tuesday
2220 Tuesday,
2221 /// Wednesday
2222 Wednesday,
2223 /// Thursday
2224 Thursday,
2225 /// Friday
2226 Friday,
2227 /// Saturday
2228 Saturday,
2229 /// Sunday
2230 Sunday,
2231 /// If set, the enum was initialized with an unknown value.
2232 ///
2233 /// Applications can examine the value using [DayOfWeek::value] or
2234 /// [DayOfWeek::name].
2235 UnknownValue(day_of_week::UnknownValue),
2236}
2237
2238#[doc(hidden)]
2239pub mod day_of_week {
2240 #[allow(unused_imports)]
2241 use super::*;
2242 #[derive(Clone, Debug, PartialEq)]
2243 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2244}
2245
2246impl DayOfWeek {
2247 /// Gets the enum value.
2248 ///
2249 /// Returns `None` if the enum contains an unknown value deserialized from
2250 /// the string representation of enums.
2251 pub fn value(&self) -> std::option::Option<i32> {
2252 match self {
2253 Self::Unspecified => std::option::Option::Some(0),
2254 Self::Monday => std::option::Option::Some(1),
2255 Self::Tuesday => std::option::Option::Some(2),
2256 Self::Wednesday => std::option::Option::Some(3),
2257 Self::Thursday => std::option::Option::Some(4),
2258 Self::Friday => std::option::Option::Some(5),
2259 Self::Saturday => std::option::Option::Some(6),
2260 Self::Sunday => std::option::Option::Some(7),
2261 Self::UnknownValue(u) => u.0.value(),
2262 }
2263 }
2264
2265 /// Gets the enum value as a string.
2266 ///
2267 /// Returns `None` if the enum contains an unknown value deserialized from
2268 /// the integer representation of enums.
2269 pub fn name(&self) -> std::option::Option<&str> {
2270 match self {
2271 Self::Unspecified => std::option::Option::Some("DAY_OF_WEEK_UNSPECIFIED"),
2272 Self::Monday => std::option::Option::Some("MONDAY"),
2273 Self::Tuesday => std::option::Option::Some("TUESDAY"),
2274 Self::Wednesday => std::option::Option::Some("WEDNESDAY"),
2275 Self::Thursday => std::option::Option::Some("THURSDAY"),
2276 Self::Friday => std::option::Option::Some("FRIDAY"),
2277 Self::Saturday => std::option::Option::Some("SATURDAY"),
2278 Self::Sunday => std::option::Option::Some("SUNDAY"),
2279 Self::UnknownValue(u) => u.0.name(),
2280 }
2281 }
2282}
2283
2284impl std::default::Default for DayOfWeek {
2285 fn default() -> Self {
2286 use std::convert::From;
2287 Self::from(0)
2288 }
2289}
2290
2291impl std::fmt::Display for DayOfWeek {
2292 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2293 wkt::internal::display_enum(f, self.name(), self.value())
2294 }
2295}
2296
2297impl std::convert::From<i32> for DayOfWeek {
2298 fn from(value: i32) -> Self {
2299 match value {
2300 0 => Self::Unspecified,
2301 1 => Self::Monday,
2302 2 => Self::Tuesday,
2303 3 => Self::Wednesday,
2304 4 => Self::Thursday,
2305 5 => Self::Friday,
2306 6 => Self::Saturday,
2307 7 => Self::Sunday,
2308 _ => Self::UnknownValue(day_of_week::UnknownValue(
2309 wkt::internal::UnknownEnumValue::Integer(value),
2310 )),
2311 }
2312 }
2313}
2314
2315impl std::convert::From<&str> for DayOfWeek {
2316 fn from(value: &str) -> Self {
2317 use std::string::ToString;
2318 match value {
2319 "DAY_OF_WEEK_UNSPECIFIED" => Self::Unspecified,
2320 "MONDAY" => Self::Monday,
2321 "TUESDAY" => Self::Tuesday,
2322 "WEDNESDAY" => Self::Wednesday,
2323 "THURSDAY" => Self::Thursday,
2324 "FRIDAY" => Self::Friday,
2325 "SATURDAY" => Self::Saturday,
2326 "SUNDAY" => Self::Sunday,
2327 _ => Self::UnknownValue(day_of_week::UnknownValue(
2328 wkt::internal::UnknownEnumValue::String(value.to_string()),
2329 )),
2330 }
2331 }
2332}
2333
2334impl serde::ser::Serialize for DayOfWeek {
2335 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2336 where
2337 S: serde::Serializer,
2338 {
2339 match self {
2340 Self::Unspecified => serializer.serialize_i32(0),
2341 Self::Monday => serializer.serialize_i32(1),
2342 Self::Tuesday => serializer.serialize_i32(2),
2343 Self::Wednesday => serializer.serialize_i32(3),
2344 Self::Thursday => serializer.serialize_i32(4),
2345 Self::Friday => serializer.serialize_i32(5),
2346 Self::Saturday => serializer.serialize_i32(6),
2347 Self::Sunday => serializer.serialize_i32(7),
2348 Self::UnknownValue(u) => u.0.serialize(serializer),
2349 }
2350 }
2351}
2352
2353impl<'de> serde::de::Deserialize<'de> for DayOfWeek {
2354 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2355 where
2356 D: serde::Deserializer<'de>,
2357 {
2358 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DayOfWeek>::new(
2359 ".google.type.DayOfWeek",
2360 ))
2361 }
2362}
2363
2364/// Represents a month in the Gregorian calendar.
2365///
2366/// # Working with unknown values
2367///
2368/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2369/// additional enum variants at any time. Adding new variants is not considered
2370/// a breaking change. Applications should write their code in anticipation of:
2371///
2372/// - New values appearing in future releases of the client library, **and**
2373/// - New values received dynamically, without application changes.
2374///
2375/// Please consult the [Working with enums] section in the user guide for some
2376/// guidelines.
2377///
2378/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2379#[derive(Clone, Debug, PartialEq)]
2380#[non_exhaustive]
2381pub enum Month {
2382 /// The unspecified month.
2383 Unspecified,
2384 /// The month of January.
2385 January,
2386 /// The month of February.
2387 February,
2388 /// The month of March.
2389 March,
2390 /// The month of April.
2391 April,
2392 /// The month of May.
2393 May,
2394 /// The month of June.
2395 June,
2396 /// The month of July.
2397 July,
2398 /// The month of August.
2399 August,
2400 /// The month of September.
2401 September,
2402 /// The month of October.
2403 October,
2404 /// The month of November.
2405 November,
2406 /// The month of December.
2407 December,
2408 /// If set, the enum was initialized with an unknown value.
2409 ///
2410 /// Applications can examine the value using [Month::value] or
2411 /// [Month::name].
2412 UnknownValue(month::UnknownValue),
2413}
2414
2415#[doc(hidden)]
2416pub mod month {
2417 #[allow(unused_imports)]
2418 use super::*;
2419 #[derive(Clone, Debug, PartialEq)]
2420 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2421}
2422
2423impl Month {
2424 /// Gets the enum value.
2425 ///
2426 /// Returns `None` if the enum contains an unknown value deserialized from
2427 /// the string representation of enums.
2428 pub fn value(&self) -> std::option::Option<i32> {
2429 match self {
2430 Self::Unspecified => std::option::Option::Some(0),
2431 Self::January => std::option::Option::Some(1),
2432 Self::February => std::option::Option::Some(2),
2433 Self::March => std::option::Option::Some(3),
2434 Self::April => std::option::Option::Some(4),
2435 Self::May => std::option::Option::Some(5),
2436 Self::June => std::option::Option::Some(6),
2437 Self::July => std::option::Option::Some(7),
2438 Self::August => std::option::Option::Some(8),
2439 Self::September => std::option::Option::Some(9),
2440 Self::October => std::option::Option::Some(10),
2441 Self::November => std::option::Option::Some(11),
2442 Self::December => std::option::Option::Some(12),
2443 Self::UnknownValue(u) => u.0.value(),
2444 }
2445 }
2446
2447 /// Gets the enum value as a string.
2448 ///
2449 /// Returns `None` if the enum contains an unknown value deserialized from
2450 /// the integer representation of enums.
2451 pub fn name(&self) -> std::option::Option<&str> {
2452 match self {
2453 Self::Unspecified => std::option::Option::Some("MONTH_UNSPECIFIED"),
2454 Self::January => std::option::Option::Some("JANUARY"),
2455 Self::February => std::option::Option::Some("FEBRUARY"),
2456 Self::March => std::option::Option::Some("MARCH"),
2457 Self::April => std::option::Option::Some("APRIL"),
2458 Self::May => std::option::Option::Some("MAY"),
2459 Self::June => std::option::Option::Some("JUNE"),
2460 Self::July => std::option::Option::Some("JULY"),
2461 Self::August => std::option::Option::Some("AUGUST"),
2462 Self::September => std::option::Option::Some("SEPTEMBER"),
2463 Self::October => std::option::Option::Some("OCTOBER"),
2464 Self::November => std::option::Option::Some("NOVEMBER"),
2465 Self::December => std::option::Option::Some("DECEMBER"),
2466 Self::UnknownValue(u) => u.0.name(),
2467 }
2468 }
2469}
2470
2471impl std::default::Default for Month {
2472 fn default() -> Self {
2473 use std::convert::From;
2474 Self::from(0)
2475 }
2476}
2477
2478impl std::fmt::Display for Month {
2479 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2480 wkt::internal::display_enum(f, self.name(), self.value())
2481 }
2482}
2483
2484impl std::convert::From<i32> for Month {
2485 fn from(value: i32) -> Self {
2486 match value {
2487 0 => Self::Unspecified,
2488 1 => Self::January,
2489 2 => Self::February,
2490 3 => Self::March,
2491 4 => Self::April,
2492 5 => Self::May,
2493 6 => Self::June,
2494 7 => Self::July,
2495 8 => Self::August,
2496 9 => Self::September,
2497 10 => Self::October,
2498 11 => Self::November,
2499 12 => Self::December,
2500 _ => Self::UnknownValue(month::UnknownValue(
2501 wkt::internal::UnknownEnumValue::Integer(value),
2502 )),
2503 }
2504 }
2505}
2506
2507impl std::convert::From<&str> for Month {
2508 fn from(value: &str) -> Self {
2509 use std::string::ToString;
2510 match value {
2511 "MONTH_UNSPECIFIED" => Self::Unspecified,
2512 "JANUARY" => Self::January,
2513 "FEBRUARY" => Self::February,
2514 "MARCH" => Self::March,
2515 "APRIL" => Self::April,
2516 "MAY" => Self::May,
2517 "JUNE" => Self::June,
2518 "JULY" => Self::July,
2519 "AUGUST" => Self::August,
2520 "SEPTEMBER" => Self::September,
2521 "OCTOBER" => Self::October,
2522 "NOVEMBER" => Self::November,
2523 "DECEMBER" => Self::December,
2524 _ => Self::UnknownValue(month::UnknownValue(
2525 wkt::internal::UnknownEnumValue::String(value.to_string()),
2526 )),
2527 }
2528 }
2529}
2530
2531impl serde::ser::Serialize for Month {
2532 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2533 where
2534 S: serde::Serializer,
2535 {
2536 match self {
2537 Self::Unspecified => serializer.serialize_i32(0),
2538 Self::January => serializer.serialize_i32(1),
2539 Self::February => serializer.serialize_i32(2),
2540 Self::March => serializer.serialize_i32(3),
2541 Self::April => serializer.serialize_i32(4),
2542 Self::May => serializer.serialize_i32(5),
2543 Self::June => serializer.serialize_i32(6),
2544 Self::July => serializer.serialize_i32(7),
2545 Self::August => serializer.serialize_i32(8),
2546 Self::September => serializer.serialize_i32(9),
2547 Self::October => serializer.serialize_i32(10),
2548 Self::November => serializer.serialize_i32(11),
2549 Self::December => serializer.serialize_i32(12),
2550 Self::UnknownValue(u) => u.0.serialize(serializer),
2551 }
2552 }
2553}
2554
2555impl<'de> serde::de::Deserialize<'de> for Month {
2556 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2557 where
2558 D: serde::Deserializer<'de>,
2559 {
2560 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Month>::new(
2561 ".google.type.Month",
2562 ))
2563 }
2564}