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