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#[derive(Clone, Debug, Default, PartialEq)]
158#[non_exhaustive]
159pub struct Color {
160    /// The amount of red in the color as a value in the interval [0, 1].
161    pub red: f32,
162
163    /// The amount of green in the color as a value in the interval [0, 1].
164    pub green: f32,
165
166    /// The amount of blue in the color as a value in the interval [0, 1].
167    pub blue: f32,
168
169    /// The fraction of this color that should be applied to the pixel. That is,
170    /// the final pixel color is defined by the equation:
171    ///
172    /// `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)`
173    ///
174    /// This means that a value of 1.0 corresponds to a solid color, whereas
175    /// a value of 0.0 corresponds to a completely transparent color. This
176    /// uses a wrapper message rather than a simple float scalar so that it is
177    /// possible to distinguish between a default value and the value being unset.
178    /// If omitted, this color object is rendered as a solid color
179    /// (as if the alpha value had been explicitly given a value of 1.0).
180    pub alpha: std::option::Option<wkt::FloatValue>,
181
182    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
183}
184
185impl Color {
186    pub fn new() -> Self {
187        std::default::Default::default()
188    }
189
190    /// Sets the value of [red][crate::model::Color::red].
191    pub fn set_red<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
192        self.red = v.into();
193        self
194    }
195
196    /// Sets the value of [green][crate::model::Color::green].
197    pub fn set_green<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
198        self.green = v.into();
199        self
200    }
201
202    /// Sets the value of [blue][crate::model::Color::blue].
203    pub fn set_blue<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
204        self.blue = v.into();
205        self
206    }
207
208    /// Sets the value of [alpha][crate::model::Color::alpha].
209    pub fn set_alpha<T>(mut self, v: T) -> Self
210    where
211        T: std::convert::Into<wkt::FloatValue>,
212    {
213        self.alpha = std::option::Option::Some(v.into());
214        self
215    }
216
217    /// Sets or clears the value of [alpha][crate::model::Color::alpha].
218    pub fn set_or_clear_alpha<T>(mut self, v: std::option::Option<T>) -> Self
219    where
220        T: std::convert::Into<wkt::FloatValue>,
221    {
222        self.alpha = v.map(|x| x.into());
223        self
224    }
225}
226
227impl wkt::message::Message for Color {
228    fn typename() -> &'static str {
229        "type.googleapis.com/google.type.Color"
230    }
231}
232
233#[doc(hidden)]
234impl<'de> serde::de::Deserialize<'de> for Color {
235    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
236    where
237        D: serde::Deserializer<'de>,
238    {
239        #[allow(non_camel_case_types)]
240        #[doc(hidden)]
241        #[derive(PartialEq, Eq, Hash)]
242        enum __FieldTag {
243            __red,
244            __green,
245            __blue,
246            __alpha,
247            Unknown(std::string::String),
248        }
249        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
250            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
251            where
252                D: serde::Deserializer<'de>,
253            {
254                struct Visitor;
255                impl<'de> serde::de::Visitor<'de> for Visitor {
256                    type Value = __FieldTag;
257                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
258                        formatter.write_str("a field name for Color")
259                    }
260                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
261                    where
262                        E: serde::de::Error,
263                    {
264                        use std::result::Result::Ok;
265                        use std::string::ToString;
266                        match value {
267                            "red" => Ok(__FieldTag::__red),
268                            "green" => Ok(__FieldTag::__green),
269                            "blue" => Ok(__FieldTag::__blue),
270                            "alpha" => Ok(__FieldTag::__alpha),
271                            _ => Ok(__FieldTag::Unknown(value.to_string())),
272                        }
273                    }
274                }
275                deserializer.deserialize_identifier(Visitor)
276            }
277        }
278        struct Visitor;
279        impl<'de> serde::de::Visitor<'de> for Visitor {
280            type Value = Color;
281            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
282                formatter.write_str("struct Color")
283            }
284            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
285            where
286                A: serde::de::MapAccess<'de>,
287            {
288                #[allow(unused_imports)]
289                use serde::de::Error;
290                use std::option::Option::Some;
291                let mut fields = std::collections::HashSet::new();
292                let mut result = Self::Value::new();
293                while let Some(tag) = map.next_key::<__FieldTag>()? {
294                    #[allow(clippy::match_single_binding)]
295                    match tag {
296                        __FieldTag::__red => {
297                            if !fields.insert(__FieldTag::__red) {
298                                return std::result::Result::Err(A::Error::duplicate_field(
299                                    "multiple values for red",
300                                ));
301                            }
302                            struct __With(std::option::Option<f32>);
303                            impl<'de> serde::de::Deserialize<'de> for __With {
304                                fn deserialize<D>(
305                                    deserializer: D,
306                                ) -> std::result::Result<Self, D::Error>
307                                where
308                                    D: serde::de::Deserializer<'de>,
309                                {
310                                    serde_with::As::< std::option::Option<wkt::internal::F32> >::deserialize(deserializer).map(__With)
311                                }
312                            }
313                            result.red = map.next_value::<__With>()?.0.unwrap_or_default();
314                        }
315                        __FieldTag::__green => {
316                            if !fields.insert(__FieldTag::__green) {
317                                return std::result::Result::Err(A::Error::duplicate_field(
318                                    "multiple values for green",
319                                ));
320                            }
321                            struct __With(std::option::Option<f32>);
322                            impl<'de> serde::de::Deserialize<'de> for __With {
323                                fn deserialize<D>(
324                                    deserializer: D,
325                                ) -> std::result::Result<Self, D::Error>
326                                where
327                                    D: serde::de::Deserializer<'de>,
328                                {
329                                    serde_with::As::< std::option::Option<wkt::internal::F32> >::deserialize(deserializer).map(__With)
330                                }
331                            }
332                            result.green = map.next_value::<__With>()?.0.unwrap_or_default();
333                        }
334                        __FieldTag::__blue => {
335                            if !fields.insert(__FieldTag::__blue) {
336                                return std::result::Result::Err(A::Error::duplicate_field(
337                                    "multiple values for blue",
338                                ));
339                            }
340                            struct __With(std::option::Option<f32>);
341                            impl<'de> serde::de::Deserialize<'de> for __With {
342                                fn deserialize<D>(
343                                    deserializer: D,
344                                ) -> std::result::Result<Self, D::Error>
345                                where
346                                    D: serde::de::Deserializer<'de>,
347                                {
348                                    serde_with::As::< std::option::Option<wkt::internal::F32> >::deserialize(deserializer).map(__With)
349                                }
350                            }
351                            result.blue = map.next_value::<__With>()?.0.unwrap_or_default();
352                        }
353                        __FieldTag::__alpha => {
354                            if !fields.insert(__FieldTag::__alpha) {
355                                return std::result::Result::Err(A::Error::duplicate_field(
356                                    "multiple values for alpha",
357                                ));
358                            }
359                            struct __With(std::option::Option<wkt::FloatValue>);
360                            impl<'de> serde::de::Deserialize<'de> for __With {
361                                fn deserialize<D>(
362                                    deserializer: D,
363                                ) -> std::result::Result<Self, D::Error>
364                                where
365                                    D: serde::de::Deserializer<'de>,
366                                {
367                                    serde_with::As::< std::option::Option<wkt::internal::F32> >::deserialize(deserializer).map(__With)
368                                }
369                            }
370                            result.alpha = map.next_value::<__With>()?.0;
371                        }
372                        __FieldTag::Unknown(key) => {
373                            let value = map.next_value::<serde_json::Value>()?;
374                            result._unknown_fields.insert(key, value);
375                        }
376                    }
377                }
378                std::result::Result::Ok(result)
379            }
380        }
381        deserializer.deserialize_any(Visitor)
382    }
383}
384
385#[doc(hidden)]
386impl serde::ser::Serialize for Color {
387    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
388    where
389        S: serde::ser::Serializer,
390    {
391        use serde::ser::SerializeMap;
392        #[allow(unused_imports)]
393        use std::option::Option::Some;
394        let mut state = serializer.serialize_map(std::option::Option::None)?;
395        if !wkt::internal::is_default(&self.red) {
396            struct __With<'a>(&'a f32);
397            impl<'a> serde::ser::Serialize for __With<'a> {
398                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
399                where
400                    S: serde::ser::Serializer,
401                {
402                    serde_with::As::<wkt::internal::F32>::serialize(self.0, serializer)
403                }
404            }
405            state.serialize_entry("red", &__With(&self.red))?;
406        }
407        if !wkt::internal::is_default(&self.green) {
408            struct __With<'a>(&'a f32);
409            impl<'a> serde::ser::Serialize for __With<'a> {
410                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
411                where
412                    S: serde::ser::Serializer,
413                {
414                    serde_with::As::<wkt::internal::F32>::serialize(self.0, serializer)
415                }
416            }
417            state.serialize_entry("green", &__With(&self.green))?;
418        }
419        if !wkt::internal::is_default(&self.blue) {
420            struct __With<'a>(&'a f32);
421            impl<'a> serde::ser::Serialize for __With<'a> {
422                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
423                where
424                    S: serde::ser::Serializer,
425                {
426                    serde_with::As::<wkt::internal::F32>::serialize(self.0, serializer)
427                }
428            }
429            state.serialize_entry("blue", &__With(&self.blue))?;
430        }
431        if self.alpha.is_some() {
432            struct __With<'a>(&'a std::option::Option<wkt::FloatValue>);
433            impl<'a> serde::ser::Serialize for __With<'a> {
434                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
435                where
436                    S: serde::ser::Serializer,
437                {
438                    serde_with::As::<std::option::Option<wkt::internal::F32>>::serialize(
439                        self.0, serializer,
440                    )
441                }
442            }
443            state.serialize_entry("alpha", &__With(&self.alpha))?;
444        }
445        if !self._unknown_fields.is_empty() {
446            for (key, value) in self._unknown_fields.iter() {
447                state.serialize_entry(key, &value)?;
448            }
449        }
450        state.end()
451    }
452}
453
454/// Represents a whole or partial calendar date, such as a birthday. The time of
455/// day and time zone are either specified elsewhere or are insignificant. The
456/// date is relative to the Gregorian Calendar. This can represent one of the
457/// following:
458///
459/// * A full date, with non-zero year, month, and day values
460/// * A month and day value, with a zero year, such as an anniversary
461/// * A year on its own, with zero month and day values
462/// * A year and month value, with a zero day, such as a credit card expiration
463///   date
464///
465/// Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and
466/// `google.protobuf.Timestamp`.
467///
468/// [google.type.TimeOfDay]: crate::model::TimeOfDay
469#[derive(Clone, Debug, Default, PartialEq)]
470#[non_exhaustive]
471pub struct Date {
472    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without
473    /// a year.
474    pub year: i32,
475
476    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a
477    /// month and day.
478    pub month: i32,
479
480    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0
481    /// to specify a year by itself or a year and month where the day isn't
482    /// significant.
483    pub day: i32,
484
485    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
486}
487
488impl Date {
489    pub fn new() -> Self {
490        std::default::Default::default()
491    }
492
493    /// Sets the value of [year][crate::model::Date::year].
494    pub fn set_year<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
495        self.year = v.into();
496        self
497    }
498
499    /// Sets the value of [month][crate::model::Date::month].
500    pub fn set_month<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
501        self.month = v.into();
502        self
503    }
504
505    /// Sets the value of [day][crate::model::Date::day].
506    pub fn set_day<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
507        self.day = v.into();
508        self
509    }
510}
511
512impl wkt::message::Message for Date {
513    fn typename() -> &'static str {
514        "type.googleapis.com/google.type.Date"
515    }
516}
517
518#[doc(hidden)]
519impl<'de> serde::de::Deserialize<'de> for Date {
520    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
521    where
522        D: serde::Deserializer<'de>,
523    {
524        #[allow(non_camel_case_types)]
525        #[doc(hidden)]
526        #[derive(PartialEq, Eq, Hash)]
527        enum __FieldTag {
528            __year,
529            __month,
530            __day,
531            Unknown(std::string::String),
532        }
533        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
534            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
535            where
536                D: serde::Deserializer<'de>,
537            {
538                struct Visitor;
539                impl<'de> serde::de::Visitor<'de> for Visitor {
540                    type Value = __FieldTag;
541                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
542                        formatter.write_str("a field name for Date")
543                    }
544                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
545                    where
546                        E: serde::de::Error,
547                    {
548                        use std::result::Result::Ok;
549                        use std::string::ToString;
550                        match value {
551                            "year" => Ok(__FieldTag::__year),
552                            "month" => Ok(__FieldTag::__month),
553                            "day" => Ok(__FieldTag::__day),
554                            _ => Ok(__FieldTag::Unknown(value.to_string())),
555                        }
556                    }
557                }
558                deserializer.deserialize_identifier(Visitor)
559            }
560        }
561        struct Visitor;
562        impl<'de> serde::de::Visitor<'de> for Visitor {
563            type Value = Date;
564            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
565                formatter.write_str("struct Date")
566            }
567            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
568            where
569                A: serde::de::MapAccess<'de>,
570            {
571                #[allow(unused_imports)]
572                use serde::de::Error;
573                use std::option::Option::Some;
574                let mut fields = std::collections::HashSet::new();
575                let mut result = Self::Value::new();
576                while let Some(tag) = map.next_key::<__FieldTag>()? {
577                    #[allow(clippy::match_single_binding)]
578                    match tag {
579                        __FieldTag::__year => {
580                            if !fields.insert(__FieldTag::__year) {
581                                return std::result::Result::Err(A::Error::duplicate_field(
582                                    "multiple values for year",
583                                ));
584                            }
585                            struct __With(std::option::Option<i32>);
586                            impl<'de> serde::de::Deserialize<'de> for __With {
587                                fn deserialize<D>(
588                                    deserializer: D,
589                                ) -> std::result::Result<Self, D::Error>
590                                where
591                                    D: serde::de::Deserializer<'de>,
592                                {
593                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
594                                }
595                            }
596                            result.year = map.next_value::<__With>()?.0.unwrap_or_default();
597                        }
598                        __FieldTag::__month => {
599                            if !fields.insert(__FieldTag::__month) {
600                                return std::result::Result::Err(A::Error::duplicate_field(
601                                    "multiple values for month",
602                                ));
603                            }
604                            struct __With(std::option::Option<i32>);
605                            impl<'de> serde::de::Deserialize<'de> for __With {
606                                fn deserialize<D>(
607                                    deserializer: D,
608                                ) -> std::result::Result<Self, D::Error>
609                                where
610                                    D: serde::de::Deserializer<'de>,
611                                {
612                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
613                                }
614                            }
615                            result.month = map.next_value::<__With>()?.0.unwrap_or_default();
616                        }
617                        __FieldTag::__day => {
618                            if !fields.insert(__FieldTag::__day) {
619                                return std::result::Result::Err(A::Error::duplicate_field(
620                                    "multiple values for day",
621                                ));
622                            }
623                            struct __With(std::option::Option<i32>);
624                            impl<'de> serde::de::Deserialize<'de> for __With {
625                                fn deserialize<D>(
626                                    deserializer: D,
627                                ) -> std::result::Result<Self, D::Error>
628                                where
629                                    D: serde::de::Deserializer<'de>,
630                                {
631                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
632                                }
633                            }
634                            result.day = map.next_value::<__With>()?.0.unwrap_or_default();
635                        }
636                        __FieldTag::Unknown(key) => {
637                            let value = map.next_value::<serde_json::Value>()?;
638                            result._unknown_fields.insert(key, value);
639                        }
640                    }
641                }
642                std::result::Result::Ok(result)
643            }
644        }
645        deserializer.deserialize_any(Visitor)
646    }
647}
648
649#[doc(hidden)]
650impl serde::ser::Serialize for Date {
651    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
652    where
653        S: serde::ser::Serializer,
654    {
655        use serde::ser::SerializeMap;
656        #[allow(unused_imports)]
657        use std::option::Option::Some;
658        let mut state = serializer.serialize_map(std::option::Option::None)?;
659        if !wkt::internal::is_default(&self.year) {
660            struct __With<'a>(&'a i32);
661            impl<'a> serde::ser::Serialize for __With<'a> {
662                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
663                where
664                    S: serde::ser::Serializer,
665                {
666                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
667                }
668            }
669            state.serialize_entry("year", &__With(&self.year))?;
670        }
671        if !wkt::internal::is_default(&self.month) {
672            struct __With<'a>(&'a i32);
673            impl<'a> serde::ser::Serialize for __With<'a> {
674                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
675                where
676                    S: serde::ser::Serializer,
677                {
678                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
679                }
680            }
681            state.serialize_entry("month", &__With(&self.month))?;
682        }
683        if !wkt::internal::is_default(&self.day) {
684            struct __With<'a>(&'a i32);
685            impl<'a> serde::ser::Serialize for __With<'a> {
686                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
687                where
688                    S: serde::ser::Serializer,
689                {
690                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
691                }
692            }
693            state.serialize_entry("day", &__With(&self.day))?;
694        }
695        if !self._unknown_fields.is_empty() {
696            for (key, value) in self._unknown_fields.iter() {
697                state.serialize_entry(key, &value)?;
698            }
699        }
700        state.end()
701    }
702}
703
704/// Represents civil time (or occasionally physical time).
705///
706/// This type can represent a civil time in one of a few possible ways:
707///
708/// * When utc_offset is set and time_zone is unset: a civil time on a calendar
709///   day with a particular offset from UTC.
710/// * When time_zone is set and utc_offset is unset: a civil time on a calendar
711///   day in a particular time zone.
712/// * When neither time_zone nor utc_offset is set: a civil time on a calendar
713///   day in local time.
714///
715/// The date is relative to the Proleptic Gregorian Calendar.
716///
717/// If year is 0, the DateTime is considered not to have a specific year. month
718/// and day must have valid, non-zero values.
719///
720/// This type may also be used to represent a physical time if all the date and
721/// time fields are set and either case of the `time_offset` oneof is set.
722/// Consider using `Timestamp` message for physical time instead. If your use
723/// case also would like to store the user's timezone, that can be done in
724/// another field.
725///
726/// This type is more flexible than some applications may want. Make sure to
727/// document and validate your application's limitations.
728#[derive(Clone, Debug, Default, PartialEq)]
729#[non_exhaustive]
730pub struct DateTime {
731    /// Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a
732    /// datetime without a year.
733    pub year: i32,
734
735    /// Required. Month of year. Must be from 1 to 12.
736    pub month: i32,
737
738    /// Required. Day of month. Must be from 1 to 31 and valid for the year and
739    /// month.
740    pub day: i32,
741
742    /// Required. Hours of day in 24 hour format. Should be from 0 to 23. An API
743    /// may choose to allow the value "24:00:00" for scenarios like business
744    /// closing time.
745    pub hours: i32,
746
747    /// Required. Minutes of hour of day. Must be from 0 to 59.
748    pub minutes: i32,
749
750    /// Required. Seconds of minutes of the time. Must normally be from 0 to 59. An
751    /// API may allow the value 60 if it allows leap-seconds.
752    pub seconds: i32,
753
754    /// Required. Fractions of seconds in nanoseconds. Must be from 0 to
755    /// 999,999,999.
756    pub nanos: i32,
757
758    /// Optional. Specifies either the UTC offset or the time zone of the DateTime.
759    /// Choose carefully between them, considering that time zone data may change
760    /// in the future (for example, a country modifies their DST start/end dates,
761    /// and future DateTimes in the affected range had already been stored).
762    /// If omitted, the DateTime is considered to be in local time.
763    pub time_offset: std::option::Option<crate::model::date_time::TimeOffset>,
764
765    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
766}
767
768impl DateTime {
769    pub fn new() -> Self {
770        std::default::Default::default()
771    }
772
773    /// Sets the value of [year][crate::model::DateTime::year].
774    pub fn set_year<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
775        self.year = v.into();
776        self
777    }
778
779    /// Sets the value of [month][crate::model::DateTime::month].
780    pub fn set_month<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
781        self.month = v.into();
782        self
783    }
784
785    /// Sets the value of [day][crate::model::DateTime::day].
786    pub fn set_day<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
787        self.day = v.into();
788        self
789    }
790
791    /// Sets the value of [hours][crate::model::DateTime::hours].
792    pub fn set_hours<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
793        self.hours = v.into();
794        self
795    }
796
797    /// Sets the value of [minutes][crate::model::DateTime::minutes].
798    pub fn set_minutes<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
799        self.minutes = v.into();
800        self
801    }
802
803    /// Sets the value of [seconds][crate::model::DateTime::seconds].
804    pub fn set_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
805        self.seconds = v.into();
806        self
807    }
808
809    /// Sets the value of [nanos][crate::model::DateTime::nanos].
810    pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
811        self.nanos = v.into();
812        self
813    }
814
815    /// Sets the value of [time_offset][crate::model::DateTime::time_offset].
816    ///
817    /// Note that all the setters affecting `time_offset` are mutually
818    /// exclusive.
819    pub fn set_time_offset<
820        T: std::convert::Into<std::option::Option<crate::model::date_time::TimeOffset>>,
821    >(
822        mut self,
823        v: T,
824    ) -> Self {
825        self.time_offset = v.into();
826        self
827    }
828
829    /// The value of [time_offset][crate::model::DateTime::time_offset]
830    /// if it holds a `UtcOffset`, `None` if the field is not set or
831    /// holds a different branch.
832    pub fn utc_offset(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
833        #[allow(unreachable_patterns)]
834        self.time_offset.as_ref().and_then(|v| match v {
835            crate::model::date_time::TimeOffset::UtcOffset(v) => std::option::Option::Some(v),
836            _ => std::option::Option::None,
837        })
838    }
839
840    /// Sets the value of [time_offset][crate::model::DateTime::time_offset]
841    /// to hold a `UtcOffset`.
842    ///
843    /// Note that all the setters affecting `time_offset` are
844    /// mutually exclusive.
845    pub fn set_utc_offset<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
846        mut self,
847        v: T,
848    ) -> Self {
849        self.time_offset =
850            std::option::Option::Some(crate::model::date_time::TimeOffset::UtcOffset(v.into()));
851        self
852    }
853
854    /// The value of [time_offset][crate::model::DateTime::time_offset]
855    /// if it holds a `TimeZone`, `None` if the field is not set or
856    /// holds a different branch.
857    pub fn time_zone(&self) -> std::option::Option<&std::boxed::Box<crate::model::TimeZone>> {
858        #[allow(unreachable_patterns)]
859        self.time_offset.as_ref().and_then(|v| match v {
860            crate::model::date_time::TimeOffset::TimeZone(v) => std::option::Option::Some(v),
861            _ => std::option::Option::None,
862        })
863    }
864
865    /// Sets the value of [time_offset][crate::model::DateTime::time_offset]
866    /// to hold a `TimeZone`.
867    ///
868    /// Note that all the setters affecting `time_offset` are
869    /// mutually exclusive.
870    pub fn set_time_zone<T: std::convert::Into<std::boxed::Box<crate::model::TimeZone>>>(
871        mut self,
872        v: T,
873    ) -> Self {
874        self.time_offset =
875            std::option::Option::Some(crate::model::date_time::TimeOffset::TimeZone(v.into()));
876        self
877    }
878}
879
880impl wkt::message::Message for DateTime {
881    fn typename() -> &'static str {
882        "type.googleapis.com/google.type.DateTime"
883    }
884}
885
886#[doc(hidden)]
887impl<'de> serde::de::Deserialize<'de> for DateTime {
888    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
889    where
890        D: serde::Deserializer<'de>,
891    {
892        #[allow(non_camel_case_types)]
893        #[doc(hidden)]
894        #[derive(PartialEq, Eq, Hash)]
895        enum __FieldTag {
896            __year,
897            __month,
898            __day,
899            __hours,
900            __minutes,
901            __seconds,
902            __nanos,
903            __utc_offset,
904            __time_zone,
905            Unknown(std::string::String),
906        }
907        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
908            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
909            where
910                D: serde::Deserializer<'de>,
911            {
912                struct Visitor;
913                impl<'de> serde::de::Visitor<'de> for Visitor {
914                    type Value = __FieldTag;
915                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
916                        formatter.write_str("a field name for DateTime")
917                    }
918                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
919                    where
920                        E: serde::de::Error,
921                    {
922                        use std::result::Result::Ok;
923                        use std::string::ToString;
924                        match value {
925                            "year" => Ok(__FieldTag::__year),
926                            "month" => Ok(__FieldTag::__month),
927                            "day" => Ok(__FieldTag::__day),
928                            "hours" => Ok(__FieldTag::__hours),
929                            "minutes" => Ok(__FieldTag::__minutes),
930                            "seconds" => Ok(__FieldTag::__seconds),
931                            "nanos" => Ok(__FieldTag::__nanos),
932                            "utcOffset" => Ok(__FieldTag::__utc_offset),
933                            "utc_offset" => Ok(__FieldTag::__utc_offset),
934                            "timeZone" => Ok(__FieldTag::__time_zone),
935                            "time_zone" => Ok(__FieldTag::__time_zone),
936                            _ => Ok(__FieldTag::Unknown(value.to_string())),
937                        }
938                    }
939                }
940                deserializer.deserialize_identifier(Visitor)
941            }
942        }
943        struct Visitor;
944        impl<'de> serde::de::Visitor<'de> for Visitor {
945            type Value = DateTime;
946            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
947                formatter.write_str("struct DateTime")
948            }
949            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
950            where
951                A: serde::de::MapAccess<'de>,
952            {
953                #[allow(unused_imports)]
954                use serde::de::Error;
955                use std::option::Option::Some;
956                let mut fields = std::collections::HashSet::new();
957                let mut result = Self::Value::new();
958                while let Some(tag) = map.next_key::<__FieldTag>()? {
959                    #[allow(clippy::match_single_binding)]
960                    match tag {
961                        __FieldTag::__year => {
962                            if !fields.insert(__FieldTag::__year) {
963                                return std::result::Result::Err(A::Error::duplicate_field(
964                                    "multiple values for year",
965                                ));
966                            }
967                            struct __With(std::option::Option<i32>);
968                            impl<'de> serde::de::Deserialize<'de> for __With {
969                                fn deserialize<D>(
970                                    deserializer: D,
971                                ) -> std::result::Result<Self, D::Error>
972                                where
973                                    D: serde::de::Deserializer<'de>,
974                                {
975                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
976                                }
977                            }
978                            result.year = map.next_value::<__With>()?.0.unwrap_or_default();
979                        }
980                        __FieldTag::__month => {
981                            if !fields.insert(__FieldTag::__month) {
982                                return std::result::Result::Err(A::Error::duplicate_field(
983                                    "multiple values for month",
984                                ));
985                            }
986                            struct __With(std::option::Option<i32>);
987                            impl<'de> serde::de::Deserialize<'de> for __With {
988                                fn deserialize<D>(
989                                    deserializer: D,
990                                ) -> std::result::Result<Self, D::Error>
991                                where
992                                    D: serde::de::Deserializer<'de>,
993                                {
994                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
995                                }
996                            }
997                            result.month = map.next_value::<__With>()?.0.unwrap_or_default();
998                        }
999                        __FieldTag::__day => {
1000                            if !fields.insert(__FieldTag::__day) {
1001                                return std::result::Result::Err(A::Error::duplicate_field(
1002                                    "multiple values for day",
1003                                ));
1004                            }
1005                            struct __With(std::option::Option<i32>);
1006                            impl<'de> serde::de::Deserialize<'de> for __With {
1007                                fn deserialize<D>(
1008                                    deserializer: D,
1009                                ) -> std::result::Result<Self, D::Error>
1010                                where
1011                                    D: serde::de::Deserializer<'de>,
1012                                {
1013                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1014                                }
1015                            }
1016                            result.day = map.next_value::<__With>()?.0.unwrap_or_default();
1017                        }
1018                        __FieldTag::__hours => {
1019                            if !fields.insert(__FieldTag::__hours) {
1020                                return std::result::Result::Err(A::Error::duplicate_field(
1021                                    "multiple values for hours",
1022                                ));
1023                            }
1024                            struct __With(std::option::Option<i32>);
1025                            impl<'de> serde::de::Deserialize<'de> for __With {
1026                                fn deserialize<D>(
1027                                    deserializer: D,
1028                                ) -> std::result::Result<Self, D::Error>
1029                                where
1030                                    D: serde::de::Deserializer<'de>,
1031                                {
1032                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1033                                }
1034                            }
1035                            result.hours = map.next_value::<__With>()?.0.unwrap_or_default();
1036                        }
1037                        __FieldTag::__minutes => {
1038                            if !fields.insert(__FieldTag::__minutes) {
1039                                return std::result::Result::Err(A::Error::duplicate_field(
1040                                    "multiple values for minutes",
1041                                ));
1042                            }
1043                            struct __With(std::option::Option<i32>);
1044                            impl<'de> serde::de::Deserialize<'de> for __With {
1045                                fn deserialize<D>(
1046                                    deserializer: D,
1047                                ) -> std::result::Result<Self, D::Error>
1048                                where
1049                                    D: serde::de::Deserializer<'de>,
1050                                {
1051                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1052                                }
1053                            }
1054                            result.minutes = map.next_value::<__With>()?.0.unwrap_or_default();
1055                        }
1056                        __FieldTag::__seconds => {
1057                            if !fields.insert(__FieldTag::__seconds) {
1058                                return std::result::Result::Err(A::Error::duplicate_field(
1059                                    "multiple values for seconds",
1060                                ));
1061                            }
1062                            struct __With(std::option::Option<i32>);
1063                            impl<'de> serde::de::Deserialize<'de> for __With {
1064                                fn deserialize<D>(
1065                                    deserializer: D,
1066                                ) -> std::result::Result<Self, D::Error>
1067                                where
1068                                    D: serde::de::Deserializer<'de>,
1069                                {
1070                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1071                                }
1072                            }
1073                            result.seconds = map.next_value::<__With>()?.0.unwrap_or_default();
1074                        }
1075                        __FieldTag::__nanos => {
1076                            if !fields.insert(__FieldTag::__nanos) {
1077                                return std::result::Result::Err(A::Error::duplicate_field(
1078                                    "multiple values for nanos",
1079                                ));
1080                            }
1081                            struct __With(std::option::Option<i32>);
1082                            impl<'de> serde::de::Deserialize<'de> for __With {
1083                                fn deserialize<D>(
1084                                    deserializer: D,
1085                                ) -> std::result::Result<Self, D::Error>
1086                                where
1087                                    D: serde::de::Deserializer<'de>,
1088                                {
1089                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1090                                }
1091                            }
1092                            result.nanos = map.next_value::<__With>()?.0.unwrap_or_default();
1093                        }
1094                        __FieldTag::__utc_offset => {
1095                            if !fields.insert(__FieldTag::__utc_offset) {
1096                                return std::result::Result::Err(A::Error::duplicate_field(
1097                                    "multiple values for utc_offset",
1098                                ));
1099                            }
1100                            if result.time_offset.is_some() {
1101                                return std::result::Result::Err(A::Error::duplicate_field(
1102                                    "multiple values for `time_offset`, a oneof with full ID .google.type.DateTime.utc_offset, latest field was utcOffset",
1103                                ));
1104                            }
1105                            result.time_offset = std::option::Option::Some(
1106                                crate::model::date_time::TimeOffset::UtcOffset(
1107                                    map.next_value::<std::option::Option<std::boxed::Box<wkt::Duration>>>()?.unwrap_or_default()
1108                                ),
1109                            );
1110                        }
1111                        __FieldTag::__time_zone => {
1112                            if !fields.insert(__FieldTag::__time_zone) {
1113                                return std::result::Result::Err(A::Error::duplicate_field(
1114                                    "multiple values for time_zone",
1115                                ));
1116                            }
1117                            if result.time_offset.is_some() {
1118                                return std::result::Result::Err(A::Error::duplicate_field(
1119                                    "multiple values for `time_offset`, a oneof with full ID .google.type.DateTime.time_zone, latest field was timeZone",
1120                                ));
1121                            }
1122                            result.time_offset = std::option::Option::Some(
1123                                crate::model::date_time::TimeOffset::TimeZone(
1124                                    map.next_value::<std::option::Option<
1125                                        std::boxed::Box<crate::model::TimeZone>,
1126                                    >>()?
1127                                    .unwrap_or_default(),
1128                                ),
1129                            );
1130                        }
1131                        __FieldTag::Unknown(key) => {
1132                            let value = map.next_value::<serde_json::Value>()?;
1133                            result._unknown_fields.insert(key, value);
1134                        }
1135                    }
1136                }
1137                std::result::Result::Ok(result)
1138            }
1139        }
1140        deserializer.deserialize_any(Visitor)
1141    }
1142}
1143
1144#[doc(hidden)]
1145impl serde::ser::Serialize for DateTime {
1146    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1147    where
1148        S: serde::ser::Serializer,
1149    {
1150        use serde::ser::SerializeMap;
1151        #[allow(unused_imports)]
1152        use std::option::Option::Some;
1153        let mut state = serializer.serialize_map(std::option::Option::None)?;
1154        if !wkt::internal::is_default(&self.year) {
1155            struct __With<'a>(&'a i32);
1156            impl<'a> serde::ser::Serialize for __With<'a> {
1157                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1158                where
1159                    S: serde::ser::Serializer,
1160                {
1161                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1162                }
1163            }
1164            state.serialize_entry("year", &__With(&self.year))?;
1165        }
1166        if !wkt::internal::is_default(&self.month) {
1167            struct __With<'a>(&'a i32);
1168            impl<'a> serde::ser::Serialize for __With<'a> {
1169                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1170                where
1171                    S: serde::ser::Serializer,
1172                {
1173                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1174                }
1175            }
1176            state.serialize_entry("month", &__With(&self.month))?;
1177        }
1178        if !wkt::internal::is_default(&self.day) {
1179            struct __With<'a>(&'a i32);
1180            impl<'a> serde::ser::Serialize for __With<'a> {
1181                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1182                where
1183                    S: serde::ser::Serializer,
1184                {
1185                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1186                }
1187            }
1188            state.serialize_entry("day", &__With(&self.day))?;
1189        }
1190        if !wkt::internal::is_default(&self.hours) {
1191            struct __With<'a>(&'a i32);
1192            impl<'a> serde::ser::Serialize for __With<'a> {
1193                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1194                where
1195                    S: serde::ser::Serializer,
1196                {
1197                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1198                }
1199            }
1200            state.serialize_entry("hours", &__With(&self.hours))?;
1201        }
1202        if !wkt::internal::is_default(&self.minutes) {
1203            struct __With<'a>(&'a i32);
1204            impl<'a> serde::ser::Serialize for __With<'a> {
1205                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1206                where
1207                    S: serde::ser::Serializer,
1208                {
1209                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1210                }
1211            }
1212            state.serialize_entry("minutes", &__With(&self.minutes))?;
1213        }
1214        if !wkt::internal::is_default(&self.seconds) {
1215            struct __With<'a>(&'a i32);
1216            impl<'a> serde::ser::Serialize for __With<'a> {
1217                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1218                where
1219                    S: serde::ser::Serializer,
1220                {
1221                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1222                }
1223            }
1224            state.serialize_entry("seconds", &__With(&self.seconds))?;
1225        }
1226        if !wkt::internal::is_default(&self.nanos) {
1227            struct __With<'a>(&'a i32);
1228            impl<'a> serde::ser::Serialize for __With<'a> {
1229                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1230                where
1231                    S: serde::ser::Serializer,
1232                {
1233                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1234                }
1235            }
1236            state.serialize_entry("nanos", &__With(&self.nanos))?;
1237        }
1238        if let Some(value) = self.utc_offset() {
1239            state.serialize_entry("utcOffset", value)?;
1240        }
1241        if let Some(value) = self.time_zone() {
1242            state.serialize_entry("timeZone", value)?;
1243        }
1244        if !self._unknown_fields.is_empty() {
1245            for (key, value) in self._unknown_fields.iter() {
1246                state.serialize_entry(key, &value)?;
1247            }
1248        }
1249        state.end()
1250    }
1251}
1252
1253/// Defines additional types related to [DateTime].
1254pub mod date_time {
1255    #[allow(unused_imports)]
1256    use super::*;
1257
1258    /// Optional. Specifies either the UTC offset or the time zone of the DateTime.
1259    /// Choose carefully between them, considering that time zone data may change
1260    /// in the future (for example, a country modifies their DST start/end dates,
1261    /// and future DateTimes in the affected range had already been stored).
1262    /// If omitted, the DateTime is considered to be in local time.
1263    #[derive(Clone, Debug, PartialEq)]
1264    #[non_exhaustive]
1265    pub enum TimeOffset {
1266        /// UTC offset. Must be whole seconds, between -18 hours and +18 hours.
1267        /// For example, a UTC offset of -4:00 would be represented as
1268        /// { seconds: -14400 }.
1269        UtcOffset(std::boxed::Box<wkt::Duration>),
1270        /// Time zone.
1271        TimeZone(std::boxed::Box<crate::model::TimeZone>),
1272    }
1273}
1274
1275/// Represents a time zone from the
1276/// [IANA Time Zone Database](https://www.iana.org/time-zones).
1277#[derive(Clone, Debug, Default, PartialEq)]
1278#[non_exhaustive]
1279pub struct TimeZone {
1280    /// IANA Time Zone Database time zone, e.g. "America/New_York".
1281    pub id: std::string::String,
1282
1283    /// Optional. IANA Time Zone Database version number, e.g. "2019a".
1284    pub version: std::string::String,
1285
1286    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1287}
1288
1289impl TimeZone {
1290    pub fn new() -> Self {
1291        std::default::Default::default()
1292    }
1293
1294    /// Sets the value of [id][crate::model::TimeZone::id].
1295    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1296        self.id = v.into();
1297        self
1298    }
1299
1300    /// Sets the value of [version][crate::model::TimeZone::version].
1301    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1302        self.version = v.into();
1303        self
1304    }
1305}
1306
1307impl wkt::message::Message for TimeZone {
1308    fn typename() -> &'static str {
1309        "type.googleapis.com/google.type.TimeZone"
1310    }
1311}
1312
1313#[doc(hidden)]
1314impl<'de> serde::de::Deserialize<'de> for TimeZone {
1315    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1316    where
1317        D: serde::Deserializer<'de>,
1318    {
1319        #[allow(non_camel_case_types)]
1320        #[doc(hidden)]
1321        #[derive(PartialEq, Eq, Hash)]
1322        enum __FieldTag {
1323            __id,
1324            __version,
1325            Unknown(std::string::String),
1326        }
1327        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1328            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1329            where
1330                D: serde::Deserializer<'de>,
1331            {
1332                struct Visitor;
1333                impl<'de> serde::de::Visitor<'de> for Visitor {
1334                    type Value = __FieldTag;
1335                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1336                        formatter.write_str("a field name for TimeZone")
1337                    }
1338                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1339                    where
1340                        E: serde::de::Error,
1341                    {
1342                        use std::result::Result::Ok;
1343                        use std::string::ToString;
1344                        match value {
1345                            "id" => Ok(__FieldTag::__id),
1346                            "version" => Ok(__FieldTag::__version),
1347                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1348                        }
1349                    }
1350                }
1351                deserializer.deserialize_identifier(Visitor)
1352            }
1353        }
1354        struct Visitor;
1355        impl<'de> serde::de::Visitor<'de> for Visitor {
1356            type Value = TimeZone;
1357            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1358                formatter.write_str("struct TimeZone")
1359            }
1360            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1361            where
1362                A: serde::de::MapAccess<'de>,
1363            {
1364                #[allow(unused_imports)]
1365                use serde::de::Error;
1366                use std::option::Option::Some;
1367                let mut fields = std::collections::HashSet::new();
1368                let mut result = Self::Value::new();
1369                while let Some(tag) = map.next_key::<__FieldTag>()? {
1370                    #[allow(clippy::match_single_binding)]
1371                    match tag {
1372                        __FieldTag::__id => {
1373                            if !fields.insert(__FieldTag::__id) {
1374                                return std::result::Result::Err(A::Error::duplicate_field(
1375                                    "multiple values for id",
1376                                ));
1377                            }
1378                            result.id = map
1379                                .next_value::<std::option::Option<std::string::String>>()?
1380                                .unwrap_or_default();
1381                        }
1382                        __FieldTag::__version => {
1383                            if !fields.insert(__FieldTag::__version) {
1384                                return std::result::Result::Err(A::Error::duplicate_field(
1385                                    "multiple values for version",
1386                                ));
1387                            }
1388                            result.version = map
1389                                .next_value::<std::option::Option<std::string::String>>()?
1390                                .unwrap_or_default();
1391                        }
1392                        __FieldTag::Unknown(key) => {
1393                            let value = map.next_value::<serde_json::Value>()?;
1394                            result._unknown_fields.insert(key, value);
1395                        }
1396                    }
1397                }
1398                std::result::Result::Ok(result)
1399            }
1400        }
1401        deserializer.deserialize_any(Visitor)
1402    }
1403}
1404
1405#[doc(hidden)]
1406impl serde::ser::Serialize for TimeZone {
1407    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1408    where
1409        S: serde::ser::Serializer,
1410    {
1411        use serde::ser::SerializeMap;
1412        #[allow(unused_imports)]
1413        use std::option::Option::Some;
1414        let mut state = serializer.serialize_map(std::option::Option::None)?;
1415        if !self.id.is_empty() {
1416            state.serialize_entry("id", &self.id)?;
1417        }
1418        if !self.version.is_empty() {
1419            state.serialize_entry("version", &self.version)?;
1420        }
1421        if !self._unknown_fields.is_empty() {
1422            for (key, value) in self._unknown_fields.iter() {
1423                state.serialize_entry(key, &value)?;
1424            }
1425        }
1426        state.end()
1427    }
1428}
1429
1430/// A representation of a decimal value, such as 2.5. Clients may convert values
1431/// into language-native decimal formats, such as Java's [BigDecimal][] or
1432/// Python's [decimal.Decimal][].
1433///
1434/// [BigDecimal]:
1435///  https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html
1436/// [decimal.Decimal]:
1437///  https://docs.python.org/3/library/decimal.html
1438#[derive(Clone, Debug, Default, PartialEq)]
1439#[non_exhaustive]
1440pub struct Decimal {
1441    /// The decimal value, as a string.
1442    ///
1443    /// The string representation consists of an optional sign, `+` (`U+002B`)
1444    /// or `-` (`U+002D`), followed by a sequence of zero or more decimal digits
1445    /// ("the integer"), optionally followed by a fraction, optionally followed
1446    /// by an exponent.
1447    ///
1448    /// The fraction consists of a decimal point followed by zero or more decimal
1449    /// digits. The string must contain at least one digit in either the integer
1450    /// or the fraction. The number formed by the sign, the integer and the
1451    /// fraction is referred to as the significand.
1452    ///
1453    /// The exponent consists of the character `e` (`U+0065`) or `E` (`U+0045`)
1454    /// followed by one or more decimal digits.
1455    ///
1456    /// Services **should** normalize decimal values before storing them by:
1457    ///
1458    /// - Removing an explicitly-provided `+` sign (`+2.5` -> `2.5`).
1459    /// - Replacing a zero-length integer value with `0` (`.5` -> `0.5`).
1460    /// - Coercing the exponent character to lower-case (`2.5E8` -> `2.5e8`).
1461    /// - Removing an explicitly-provided zero exponent (`2.5e0` -> `2.5`).
1462    ///
1463    /// Services **may** perform additional normalization based on its own needs
1464    /// and the internal decimal implementation selected, such as shifting the
1465    /// decimal point and exponent value together (example: `2.5e-1` <-> `0.25`).
1466    /// Additionally, services **may** preserve trailing zeroes in the fraction
1467    /// to indicate increased precision, but are not required to do so.
1468    ///
1469    /// Note that only the `.` character is supported to divide the integer
1470    /// and the fraction; `,` **should not** be supported regardless of locale.
1471    /// Additionally, thousand separators **should not** be supported. If a
1472    /// service does support them, values **must** be normalized.
1473    ///
1474    /// The ENBF grammar is:
1475    ///
1476    /// ```norust
1477    /// DecimalString =
1478    ///   [Sign] Significand [Exponent];
1479    ///
1480    /// Sign = '+' | '-';
1481    ///
1482    /// Significand =
1483    ///   Digits ['.'] [Digits] | [Digits] '.' Digits;
1484    ///
1485    /// Exponent = ('e' | 'E') [Sign] Digits;
1486    ///
1487    /// Digits = { '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' };
1488    /// ```
1489    ///
1490    /// Services **should** clearly document the range of supported values, the
1491    /// maximum supported precision (total number of digits), and, if applicable,
1492    /// the scale (number of digits after the decimal point), as well as how it
1493    /// behaves when receiving out-of-bounds values.
1494    ///
1495    /// Services **may** choose to accept values passed as input even when the
1496    /// value has a higher precision or scale than the service supports, and
1497    /// **should** round the value to fit the supported scale. Alternatively, the
1498    /// service **may** error with `400 Bad Request` (`INVALID_ARGUMENT` in gRPC)
1499    /// if precision would be lost.
1500    ///
1501    /// Services **should** error with `400 Bad Request` (`INVALID_ARGUMENT` in
1502    /// gRPC) if the service receives a value outside of the supported range.
1503    pub value: std::string::String,
1504
1505    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1506}
1507
1508impl Decimal {
1509    pub fn new() -> Self {
1510        std::default::Default::default()
1511    }
1512
1513    /// Sets the value of [value][crate::model::Decimal::value].
1514    pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1515        self.value = v.into();
1516        self
1517    }
1518}
1519
1520impl wkt::message::Message for Decimal {
1521    fn typename() -> &'static str {
1522        "type.googleapis.com/google.type.Decimal"
1523    }
1524}
1525
1526#[doc(hidden)]
1527impl<'de> serde::de::Deserialize<'de> for Decimal {
1528    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1529    where
1530        D: serde::Deserializer<'de>,
1531    {
1532        #[allow(non_camel_case_types)]
1533        #[doc(hidden)]
1534        #[derive(PartialEq, Eq, Hash)]
1535        enum __FieldTag {
1536            __value,
1537            Unknown(std::string::String),
1538        }
1539        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1540            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1541            where
1542                D: serde::Deserializer<'de>,
1543            {
1544                struct Visitor;
1545                impl<'de> serde::de::Visitor<'de> for Visitor {
1546                    type Value = __FieldTag;
1547                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1548                        formatter.write_str("a field name for Decimal")
1549                    }
1550                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1551                    where
1552                        E: serde::de::Error,
1553                    {
1554                        use std::result::Result::Ok;
1555                        use std::string::ToString;
1556                        match value {
1557                            "value" => Ok(__FieldTag::__value),
1558                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1559                        }
1560                    }
1561                }
1562                deserializer.deserialize_identifier(Visitor)
1563            }
1564        }
1565        struct Visitor;
1566        impl<'de> serde::de::Visitor<'de> for Visitor {
1567            type Value = Decimal;
1568            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1569                formatter.write_str("struct Decimal")
1570            }
1571            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1572            where
1573                A: serde::de::MapAccess<'de>,
1574            {
1575                #[allow(unused_imports)]
1576                use serde::de::Error;
1577                use std::option::Option::Some;
1578                let mut fields = std::collections::HashSet::new();
1579                let mut result = Self::Value::new();
1580                while let Some(tag) = map.next_key::<__FieldTag>()? {
1581                    #[allow(clippy::match_single_binding)]
1582                    match tag {
1583                        __FieldTag::__value => {
1584                            if !fields.insert(__FieldTag::__value) {
1585                                return std::result::Result::Err(A::Error::duplicate_field(
1586                                    "multiple values for value",
1587                                ));
1588                            }
1589                            result.value = map
1590                                .next_value::<std::option::Option<std::string::String>>()?
1591                                .unwrap_or_default();
1592                        }
1593                        __FieldTag::Unknown(key) => {
1594                            let value = map.next_value::<serde_json::Value>()?;
1595                            result._unknown_fields.insert(key, value);
1596                        }
1597                    }
1598                }
1599                std::result::Result::Ok(result)
1600            }
1601        }
1602        deserializer.deserialize_any(Visitor)
1603    }
1604}
1605
1606#[doc(hidden)]
1607impl serde::ser::Serialize for Decimal {
1608    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1609    where
1610        S: serde::ser::Serializer,
1611    {
1612        use serde::ser::SerializeMap;
1613        #[allow(unused_imports)]
1614        use std::option::Option::Some;
1615        let mut state = serializer.serialize_map(std::option::Option::None)?;
1616        if !self.value.is_empty() {
1617            state.serialize_entry("value", &self.value)?;
1618        }
1619        if !self._unknown_fields.is_empty() {
1620            for (key, value) in self._unknown_fields.iter() {
1621                state.serialize_entry(key, &value)?;
1622            }
1623        }
1624        state.end()
1625    }
1626}
1627
1628/// Represents a textual expression in the Common Expression Language (CEL)
1629/// syntax. CEL is a C-like expression language. The syntax and semantics of CEL
1630/// are documented at <https://github.com/google/cel-spec>.
1631///
1632/// Example (Comparison):
1633///
1634/// ```norust
1635/// title: "Summary size limit"
1636/// description: "Determines if a summary is less than 100 chars"
1637/// expression: "document.summary.size() < 100"
1638/// ```
1639///
1640/// Example (Equality):
1641///
1642/// ```norust
1643/// title: "Requestor is owner"
1644/// description: "Determines if requestor is the document owner"
1645/// expression: "document.owner == request.auth.claims.email"
1646/// ```
1647///
1648/// Example (Logic):
1649///
1650/// ```norust
1651/// title: "Public documents"
1652/// description: "Determine whether the document should be publicly visible"
1653/// expression: "document.type != 'private' && document.type != 'internal'"
1654/// ```
1655///
1656/// Example (Data Manipulation):
1657///
1658/// ```norust
1659/// title: "Notification string"
1660/// description: "Create a notification string with a timestamp."
1661/// expression: "'New message received at ' + string(document.create_time)"
1662/// ```
1663///
1664/// The exact variables and functions that may be referenced within an expression
1665/// are determined by the service that evaluates it. See the service
1666/// documentation for additional information.
1667#[derive(Clone, Debug, Default, PartialEq)]
1668#[non_exhaustive]
1669pub struct Expr {
1670    /// Textual representation of an expression in Common Expression Language
1671    /// syntax.
1672    pub expression: std::string::String,
1673
1674    /// Optional. Title for the expression, i.e. a short string describing
1675    /// its purpose. This can be used e.g. in UIs which allow to enter the
1676    /// expression.
1677    pub title: std::string::String,
1678
1679    /// Optional. Description of the expression. This is a longer text which
1680    /// describes the expression, e.g. when hovered over it in a UI.
1681    pub description: std::string::String,
1682
1683    /// Optional. String indicating the location of the expression for error
1684    /// reporting, e.g. a file name and a position in the file.
1685    pub location: std::string::String,
1686
1687    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1688}
1689
1690impl Expr {
1691    pub fn new() -> Self {
1692        std::default::Default::default()
1693    }
1694
1695    /// Sets the value of [expression][crate::model::Expr::expression].
1696    pub fn set_expression<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1697        self.expression = v.into();
1698        self
1699    }
1700
1701    /// Sets the value of [title][crate::model::Expr::title].
1702    pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1703        self.title = v.into();
1704        self
1705    }
1706
1707    /// Sets the value of [description][crate::model::Expr::description].
1708    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1709        self.description = v.into();
1710        self
1711    }
1712
1713    /// Sets the value of [location][crate::model::Expr::location].
1714    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1715        self.location = v.into();
1716        self
1717    }
1718}
1719
1720impl wkt::message::Message for Expr {
1721    fn typename() -> &'static str {
1722        "type.googleapis.com/google.type.Expr"
1723    }
1724}
1725
1726#[doc(hidden)]
1727impl<'de> serde::de::Deserialize<'de> for Expr {
1728    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1729    where
1730        D: serde::Deserializer<'de>,
1731    {
1732        #[allow(non_camel_case_types)]
1733        #[doc(hidden)]
1734        #[derive(PartialEq, Eq, Hash)]
1735        enum __FieldTag {
1736            __expression,
1737            __title,
1738            __description,
1739            __location,
1740            Unknown(std::string::String),
1741        }
1742        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1743            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1744            where
1745                D: serde::Deserializer<'de>,
1746            {
1747                struct Visitor;
1748                impl<'de> serde::de::Visitor<'de> for Visitor {
1749                    type Value = __FieldTag;
1750                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1751                        formatter.write_str("a field name for Expr")
1752                    }
1753                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1754                    where
1755                        E: serde::de::Error,
1756                    {
1757                        use std::result::Result::Ok;
1758                        use std::string::ToString;
1759                        match value {
1760                            "expression" => Ok(__FieldTag::__expression),
1761                            "title" => Ok(__FieldTag::__title),
1762                            "description" => Ok(__FieldTag::__description),
1763                            "location" => Ok(__FieldTag::__location),
1764                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1765                        }
1766                    }
1767                }
1768                deserializer.deserialize_identifier(Visitor)
1769            }
1770        }
1771        struct Visitor;
1772        impl<'de> serde::de::Visitor<'de> for Visitor {
1773            type Value = Expr;
1774            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1775                formatter.write_str("struct Expr")
1776            }
1777            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1778            where
1779                A: serde::de::MapAccess<'de>,
1780            {
1781                #[allow(unused_imports)]
1782                use serde::de::Error;
1783                use std::option::Option::Some;
1784                let mut fields = std::collections::HashSet::new();
1785                let mut result = Self::Value::new();
1786                while let Some(tag) = map.next_key::<__FieldTag>()? {
1787                    #[allow(clippy::match_single_binding)]
1788                    match tag {
1789                        __FieldTag::__expression => {
1790                            if !fields.insert(__FieldTag::__expression) {
1791                                return std::result::Result::Err(A::Error::duplicate_field(
1792                                    "multiple values for expression",
1793                                ));
1794                            }
1795                            result.expression = map
1796                                .next_value::<std::option::Option<std::string::String>>()?
1797                                .unwrap_or_default();
1798                        }
1799                        __FieldTag::__title => {
1800                            if !fields.insert(__FieldTag::__title) {
1801                                return std::result::Result::Err(A::Error::duplicate_field(
1802                                    "multiple values for title",
1803                                ));
1804                            }
1805                            result.title = map
1806                                .next_value::<std::option::Option<std::string::String>>()?
1807                                .unwrap_or_default();
1808                        }
1809                        __FieldTag::__description => {
1810                            if !fields.insert(__FieldTag::__description) {
1811                                return std::result::Result::Err(A::Error::duplicate_field(
1812                                    "multiple values for description",
1813                                ));
1814                            }
1815                            result.description = map
1816                                .next_value::<std::option::Option<std::string::String>>()?
1817                                .unwrap_or_default();
1818                        }
1819                        __FieldTag::__location => {
1820                            if !fields.insert(__FieldTag::__location) {
1821                                return std::result::Result::Err(A::Error::duplicate_field(
1822                                    "multiple values for location",
1823                                ));
1824                            }
1825                            result.location = map
1826                                .next_value::<std::option::Option<std::string::String>>()?
1827                                .unwrap_or_default();
1828                        }
1829                        __FieldTag::Unknown(key) => {
1830                            let value = map.next_value::<serde_json::Value>()?;
1831                            result._unknown_fields.insert(key, value);
1832                        }
1833                    }
1834                }
1835                std::result::Result::Ok(result)
1836            }
1837        }
1838        deserializer.deserialize_any(Visitor)
1839    }
1840}
1841
1842#[doc(hidden)]
1843impl serde::ser::Serialize for Expr {
1844    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1845    where
1846        S: serde::ser::Serializer,
1847    {
1848        use serde::ser::SerializeMap;
1849        #[allow(unused_imports)]
1850        use std::option::Option::Some;
1851        let mut state = serializer.serialize_map(std::option::Option::None)?;
1852        if !self.expression.is_empty() {
1853            state.serialize_entry("expression", &self.expression)?;
1854        }
1855        if !self.title.is_empty() {
1856            state.serialize_entry("title", &self.title)?;
1857        }
1858        if !self.description.is_empty() {
1859            state.serialize_entry("description", &self.description)?;
1860        }
1861        if !self.location.is_empty() {
1862            state.serialize_entry("location", &self.location)?;
1863        }
1864        if !self._unknown_fields.is_empty() {
1865            for (key, value) in self._unknown_fields.iter() {
1866                state.serialize_entry(key, &value)?;
1867            }
1868        }
1869        state.end()
1870    }
1871}
1872
1873/// Represents a fraction in terms of a numerator divided by a denominator.
1874#[derive(Clone, Debug, Default, PartialEq)]
1875#[non_exhaustive]
1876pub struct Fraction {
1877    /// The numerator in the fraction, e.g. 2 in 2/3.
1878    pub numerator: i64,
1879
1880    /// The value by which the numerator is divided, e.g. 3 in 2/3. Must be
1881    /// positive.
1882    pub denominator: i64,
1883
1884    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1885}
1886
1887impl Fraction {
1888    pub fn new() -> Self {
1889        std::default::Default::default()
1890    }
1891
1892    /// Sets the value of [numerator][crate::model::Fraction::numerator].
1893    pub fn set_numerator<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1894        self.numerator = v.into();
1895        self
1896    }
1897
1898    /// Sets the value of [denominator][crate::model::Fraction::denominator].
1899    pub fn set_denominator<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1900        self.denominator = v.into();
1901        self
1902    }
1903}
1904
1905impl wkt::message::Message for Fraction {
1906    fn typename() -> &'static str {
1907        "type.googleapis.com/google.type.Fraction"
1908    }
1909}
1910
1911#[doc(hidden)]
1912impl<'de> serde::de::Deserialize<'de> for Fraction {
1913    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1914    where
1915        D: serde::Deserializer<'de>,
1916    {
1917        #[allow(non_camel_case_types)]
1918        #[doc(hidden)]
1919        #[derive(PartialEq, Eq, Hash)]
1920        enum __FieldTag {
1921            __numerator,
1922            __denominator,
1923            Unknown(std::string::String),
1924        }
1925        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1926            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1927            where
1928                D: serde::Deserializer<'de>,
1929            {
1930                struct Visitor;
1931                impl<'de> serde::de::Visitor<'de> for Visitor {
1932                    type Value = __FieldTag;
1933                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1934                        formatter.write_str("a field name for Fraction")
1935                    }
1936                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1937                    where
1938                        E: serde::de::Error,
1939                    {
1940                        use std::result::Result::Ok;
1941                        use std::string::ToString;
1942                        match value {
1943                            "numerator" => Ok(__FieldTag::__numerator),
1944                            "denominator" => Ok(__FieldTag::__denominator),
1945                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1946                        }
1947                    }
1948                }
1949                deserializer.deserialize_identifier(Visitor)
1950            }
1951        }
1952        struct Visitor;
1953        impl<'de> serde::de::Visitor<'de> for Visitor {
1954            type Value = Fraction;
1955            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1956                formatter.write_str("struct Fraction")
1957            }
1958            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1959            where
1960                A: serde::de::MapAccess<'de>,
1961            {
1962                #[allow(unused_imports)]
1963                use serde::de::Error;
1964                use std::option::Option::Some;
1965                let mut fields = std::collections::HashSet::new();
1966                let mut result = Self::Value::new();
1967                while let Some(tag) = map.next_key::<__FieldTag>()? {
1968                    #[allow(clippy::match_single_binding)]
1969                    match tag {
1970                        __FieldTag::__numerator => {
1971                            if !fields.insert(__FieldTag::__numerator) {
1972                                return std::result::Result::Err(A::Error::duplicate_field(
1973                                    "multiple values for numerator",
1974                                ));
1975                            }
1976                            struct __With(std::option::Option<i64>);
1977                            impl<'de> serde::de::Deserialize<'de> for __With {
1978                                fn deserialize<D>(
1979                                    deserializer: D,
1980                                ) -> std::result::Result<Self, D::Error>
1981                                where
1982                                    D: serde::de::Deserializer<'de>,
1983                                {
1984                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
1985                                }
1986                            }
1987                            result.numerator = map.next_value::<__With>()?.0.unwrap_or_default();
1988                        }
1989                        __FieldTag::__denominator => {
1990                            if !fields.insert(__FieldTag::__denominator) {
1991                                return std::result::Result::Err(A::Error::duplicate_field(
1992                                    "multiple values for denominator",
1993                                ));
1994                            }
1995                            struct __With(std::option::Option<i64>);
1996                            impl<'de> serde::de::Deserialize<'de> for __With {
1997                                fn deserialize<D>(
1998                                    deserializer: D,
1999                                ) -> std::result::Result<Self, D::Error>
2000                                where
2001                                    D: serde::de::Deserializer<'de>,
2002                                {
2003                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
2004                                }
2005                            }
2006                            result.denominator = map.next_value::<__With>()?.0.unwrap_or_default();
2007                        }
2008                        __FieldTag::Unknown(key) => {
2009                            let value = map.next_value::<serde_json::Value>()?;
2010                            result._unknown_fields.insert(key, value);
2011                        }
2012                    }
2013                }
2014                std::result::Result::Ok(result)
2015            }
2016        }
2017        deserializer.deserialize_any(Visitor)
2018    }
2019}
2020
2021#[doc(hidden)]
2022impl serde::ser::Serialize for Fraction {
2023    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2024    where
2025        S: serde::ser::Serializer,
2026    {
2027        use serde::ser::SerializeMap;
2028        #[allow(unused_imports)]
2029        use std::option::Option::Some;
2030        let mut state = serializer.serialize_map(std::option::Option::None)?;
2031        if !wkt::internal::is_default(&self.numerator) {
2032            struct __With<'a>(&'a i64);
2033            impl<'a> serde::ser::Serialize for __With<'a> {
2034                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2035                where
2036                    S: serde::ser::Serializer,
2037                {
2038                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2039                }
2040            }
2041            state.serialize_entry("numerator", &__With(&self.numerator))?;
2042        }
2043        if !wkt::internal::is_default(&self.denominator) {
2044            struct __With<'a>(&'a i64);
2045            impl<'a> serde::ser::Serialize for __With<'a> {
2046                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2047                where
2048                    S: serde::ser::Serializer,
2049                {
2050                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2051                }
2052            }
2053            state.serialize_entry("denominator", &__With(&self.denominator))?;
2054        }
2055        if !self._unknown_fields.is_empty() {
2056            for (key, value) in self._unknown_fields.iter() {
2057                state.serialize_entry(key, &value)?;
2058            }
2059        }
2060        state.end()
2061    }
2062}
2063
2064/// Represents a time interval, encoded as a Timestamp start (inclusive) and a
2065/// Timestamp end (exclusive).
2066///
2067/// The start must be less than or equal to the end.
2068/// When the start equals the end, the interval is empty (matches no time).
2069/// When both start and end are unspecified, the interval matches any time.
2070#[derive(Clone, Debug, Default, PartialEq)]
2071#[non_exhaustive]
2072pub struct Interval {
2073    /// Optional. Inclusive start of the interval.
2074    ///
2075    /// If specified, a Timestamp matching this interval will have to be the same
2076    /// or after the start.
2077    pub start_time: std::option::Option<wkt::Timestamp>,
2078
2079    /// Optional. Exclusive end of the interval.
2080    ///
2081    /// If specified, a Timestamp matching this interval will have to be before the
2082    /// end.
2083    pub end_time: std::option::Option<wkt::Timestamp>,
2084
2085    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2086}
2087
2088impl Interval {
2089    pub fn new() -> Self {
2090        std::default::Default::default()
2091    }
2092
2093    /// Sets the value of [start_time][crate::model::Interval::start_time].
2094    pub fn set_start_time<T>(mut self, v: T) -> Self
2095    where
2096        T: std::convert::Into<wkt::Timestamp>,
2097    {
2098        self.start_time = std::option::Option::Some(v.into());
2099        self
2100    }
2101
2102    /// Sets or clears the value of [start_time][crate::model::Interval::start_time].
2103    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
2104    where
2105        T: std::convert::Into<wkt::Timestamp>,
2106    {
2107        self.start_time = v.map(|x| x.into());
2108        self
2109    }
2110
2111    /// Sets the value of [end_time][crate::model::Interval::end_time].
2112    pub fn set_end_time<T>(mut self, v: T) -> Self
2113    where
2114        T: std::convert::Into<wkt::Timestamp>,
2115    {
2116        self.end_time = std::option::Option::Some(v.into());
2117        self
2118    }
2119
2120    /// Sets or clears the value of [end_time][crate::model::Interval::end_time].
2121    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
2122    where
2123        T: std::convert::Into<wkt::Timestamp>,
2124    {
2125        self.end_time = v.map(|x| x.into());
2126        self
2127    }
2128}
2129
2130impl wkt::message::Message for Interval {
2131    fn typename() -> &'static str {
2132        "type.googleapis.com/google.type.Interval"
2133    }
2134}
2135
2136#[doc(hidden)]
2137impl<'de> serde::de::Deserialize<'de> for Interval {
2138    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2139    where
2140        D: serde::Deserializer<'de>,
2141    {
2142        #[allow(non_camel_case_types)]
2143        #[doc(hidden)]
2144        #[derive(PartialEq, Eq, Hash)]
2145        enum __FieldTag {
2146            __start_time,
2147            __end_time,
2148            Unknown(std::string::String),
2149        }
2150        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2151            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2152            where
2153                D: serde::Deserializer<'de>,
2154            {
2155                struct Visitor;
2156                impl<'de> serde::de::Visitor<'de> for Visitor {
2157                    type Value = __FieldTag;
2158                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2159                        formatter.write_str("a field name for Interval")
2160                    }
2161                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2162                    where
2163                        E: serde::de::Error,
2164                    {
2165                        use std::result::Result::Ok;
2166                        use std::string::ToString;
2167                        match value {
2168                            "startTime" => Ok(__FieldTag::__start_time),
2169                            "start_time" => Ok(__FieldTag::__start_time),
2170                            "endTime" => Ok(__FieldTag::__end_time),
2171                            "end_time" => Ok(__FieldTag::__end_time),
2172                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2173                        }
2174                    }
2175                }
2176                deserializer.deserialize_identifier(Visitor)
2177            }
2178        }
2179        struct Visitor;
2180        impl<'de> serde::de::Visitor<'de> for Visitor {
2181            type Value = Interval;
2182            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2183                formatter.write_str("struct Interval")
2184            }
2185            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2186            where
2187                A: serde::de::MapAccess<'de>,
2188            {
2189                #[allow(unused_imports)]
2190                use serde::de::Error;
2191                use std::option::Option::Some;
2192                let mut fields = std::collections::HashSet::new();
2193                let mut result = Self::Value::new();
2194                while let Some(tag) = map.next_key::<__FieldTag>()? {
2195                    #[allow(clippy::match_single_binding)]
2196                    match tag {
2197                        __FieldTag::__start_time => {
2198                            if !fields.insert(__FieldTag::__start_time) {
2199                                return std::result::Result::Err(A::Error::duplicate_field(
2200                                    "multiple values for start_time",
2201                                ));
2202                            }
2203                            result.start_time =
2204                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2205                        }
2206                        __FieldTag::__end_time => {
2207                            if !fields.insert(__FieldTag::__end_time) {
2208                                return std::result::Result::Err(A::Error::duplicate_field(
2209                                    "multiple values for end_time",
2210                                ));
2211                            }
2212                            result.end_time =
2213                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2214                        }
2215                        __FieldTag::Unknown(key) => {
2216                            let value = map.next_value::<serde_json::Value>()?;
2217                            result._unknown_fields.insert(key, value);
2218                        }
2219                    }
2220                }
2221                std::result::Result::Ok(result)
2222            }
2223        }
2224        deserializer.deserialize_any(Visitor)
2225    }
2226}
2227
2228#[doc(hidden)]
2229impl serde::ser::Serialize for Interval {
2230    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2231    where
2232        S: serde::ser::Serializer,
2233    {
2234        use serde::ser::SerializeMap;
2235        #[allow(unused_imports)]
2236        use std::option::Option::Some;
2237        let mut state = serializer.serialize_map(std::option::Option::None)?;
2238        if self.start_time.is_some() {
2239            state.serialize_entry("startTime", &self.start_time)?;
2240        }
2241        if self.end_time.is_some() {
2242            state.serialize_entry("endTime", &self.end_time)?;
2243        }
2244        if !self._unknown_fields.is_empty() {
2245            for (key, value) in self._unknown_fields.iter() {
2246                state.serialize_entry(key, &value)?;
2247            }
2248        }
2249        state.end()
2250    }
2251}
2252
2253/// An object that represents a latitude/longitude pair. This is expressed as a
2254/// pair of doubles to represent degrees latitude and degrees longitude. Unless
2255/// specified otherwise, this must conform to the
2256/// <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
2257/// standard</a>. Values must be within normalized ranges.
2258#[derive(Clone, Debug, Default, PartialEq)]
2259#[non_exhaustive]
2260pub struct LatLng {
2261    /// The latitude in degrees. It must be in the range [-90.0, +90.0].
2262    pub latitude: f64,
2263
2264    /// The longitude in degrees. It must be in the range [-180.0, +180.0].
2265    pub longitude: f64,
2266
2267    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2268}
2269
2270impl LatLng {
2271    pub fn new() -> Self {
2272        std::default::Default::default()
2273    }
2274
2275    /// Sets the value of [latitude][crate::model::LatLng::latitude].
2276    pub fn set_latitude<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2277        self.latitude = v.into();
2278        self
2279    }
2280
2281    /// Sets the value of [longitude][crate::model::LatLng::longitude].
2282    pub fn set_longitude<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2283        self.longitude = v.into();
2284        self
2285    }
2286}
2287
2288impl wkt::message::Message for LatLng {
2289    fn typename() -> &'static str {
2290        "type.googleapis.com/google.type.LatLng"
2291    }
2292}
2293
2294#[doc(hidden)]
2295impl<'de> serde::de::Deserialize<'de> for LatLng {
2296    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2297    where
2298        D: serde::Deserializer<'de>,
2299    {
2300        #[allow(non_camel_case_types)]
2301        #[doc(hidden)]
2302        #[derive(PartialEq, Eq, Hash)]
2303        enum __FieldTag {
2304            __latitude,
2305            __longitude,
2306            Unknown(std::string::String),
2307        }
2308        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2309            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2310            where
2311                D: serde::Deserializer<'de>,
2312            {
2313                struct Visitor;
2314                impl<'de> serde::de::Visitor<'de> for Visitor {
2315                    type Value = __FieldTag;
2316                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2317                        formatter.write_str("a field name for LatLng")
2318                    }
2319                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2320                    where
2321                        E: serde::de::Error,
2322                    {
2323                        use std::result::Result::Ok;
2324                        use std::string::ToString;
2325                        match value {
2326                            "latitude" => Ok(__FieldTag::__latitude),
2327                            "longitude" => Ok(__FieldTag::__longitude),
2328                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2329                        }
2330                    }
2331                }
2332                deserializer.deserialize_identifier(Visitor)
2333            }
2334        }
2335        struct Visitor;
2336        impl<'de> serde::de::Visitor<'de> for Visitor {
2337            type Value = LatLng;
2338            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2339                formatter.write_str("struct LatLng")
2340            }
2341            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2342            where
2343                A: serde::de::MapAccess<'de>,
2344            {
2345                #[allow(unused_imports)]
2346                use serde::de::Error;
2347                use std::option::Option::Some;
2348                let mut fields = std::collections::HashSet::new();
2349                let mut result = Self::Value::new();
2350                while let Some(tag) = map.next_key::<__FieldTag>()? {
2351                    #[allow(clippy::match_single_binding)]
2352                    match tag {
2353                        __FieldTag::__latitude => {
2354                            if !fields.insert(__FieldTag::__latitude) {
2355                                return std::result::Result::Err(A::Error::duplicate_field(
2356                                    "multiple values for latitude",
2357                                ));
2358                            }
2359                            struct __With(std::option::Option<f64>);
2360                            impl<'de> serde::de::Deserialize<'de> for __With {
2361                                fn deserialize<D>(
2362                                    deserializer: D,
2363                                ) -> std::result::Result<Self, D::Error>
2364                                where
2365                                    D: serde::de::Deserializer<'de>,
2366                                {
2367                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
2368                                }
2369                            }
2370                            result.latitude = map.next_value::<__With>()?.0.unwrap_or_default();
2371                        }
2372                        __FieldTag::__longitude => {
2373                            if !fields.insert(__FieldTag::__longitude) {
2374                                return std::result::Result::Err(A::Error::duplicate_field(
2375                                    "multiple values for longitude",
2376                                ));
2377                            }
2378                            struct __With(std::option::Option<f64>);
2379                            impl<'de> serde::de::Deserialize<'de> for __With {
2380                                fn deserialize<D>(
2381                                    deserializer: D,
2382                                ) -> std::result::Result<Self, D::Error>
2383                                where
2384                                    D: serde::de::Deserializer<'de>,
2385                                {
2386                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
2387                                }
2388                            }
2389                            result.longitude = map.next_value::<__With>()?.0.unwrap_or_default();
2390                        }
2391                        __FieldTag::Unknown(key) => {
2392                            let value = map.next_value::<serde_json::Value>()?;
2393                            result._unknown_fields.insert(key, value);
2394                        }
2395                    }
2396                }
2397                std::result::Result::Ok(result)
2398            }
2399        }
2400        deserializer.deserialize_any(Visitor)
2401    }
2402}
2403
2404#[doc(hidden)]
2405impl serde::ser::Serialize for LatLng {
2406    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2407    where
2408        S: serde::ser::Serializer,
2409    {
2410        use serde::ser::SerializeMap;
2411        #[allow(unused_imports)]
2412        use std::option::Option::Some;
2413        let mut state = serializer.serialize_map(std::option::Option::None)?;
2414        if !wkt::internal::is_default(&self.latitude) {
2415            struct __With<'a>(&'a f64);
2416            impl<'a> serde::ser::Serialize for __With<'a> {
2417                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2418                where
2419                    S: serde::ser::Serializer,
2420                {
2421                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2422                }
2423            }
2424            state.serialize_entry("latitude", &__With(&self.latitude))?;
2425        }
2426        if !wkt::internal::is_default(&self.longitude) {
2427            struct __With<'a>(&'a f64);
2428            impl<'a> serde::ser::Serialize for __With<'a> {
2429                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2430                where
2431                    S: serde::ser::Serializer,
2432                {
2433                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
2434                }
2435            }
2436            state.serialize_entry("longitude", &__With(&self.longitude))?;
2437        }
2438        if !self._unknown_fields.is_empty() {
2439            for (key, value) in self._unknown_fields.iter() {
2440                state.serialize_entry(key, &value)?;
2441            }
2442        }
2443        state.end()
2444    }
2445}
2446
2447/// Localized variant of a text in a particular language.
2448#[derive(Clone, Debug, Default, PartialEq)]
2449#[non_exhaustive]
2450pub struct LocalizedText {
2451    /// Localized string in the language corresponding to `language_code' below.
2452    pub text: std::string::String,
2453
2454    /// The text's BCP-47 language code, such as "en-US" or "sr-Latn".
2455    ///
2456    /// For more information, see
2457    /// <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>.
2458    pub language_code: std::string::String,
2459
2460    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2461}
2462
2463impl LocalizedText {
2464    pub fn new() -> Self {
2465        std::default::Default::default()
2466    }
2467
2468    /// Sets the value of [text][crate::model::LocalizedText::text].
2469    pub fn set_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2470        self.text = v.into();
2471        self
2472    }
2473
2474    /// Sets the value of [language_code][crate::model::LocalizedText::language_code].
2475    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2476        self.language_code = v.into();
2477        self
2478    }
2479}
2480
2481impl wkt::message::Message for LocalizedText {
2482    fn typename() -> &'static str {
2483        "type.googleapis.com/google.type.LocalizedText"
2484    }
2485}
2486
2487#[doc(hidden)]
2488impl<'de> serde::de::Deserialize<'de> for LocalizedText {
2489    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2490    where
2491        D: serde::Deserializer<'de>,
2492    {
2493        #[allow(non_camel_case_types)]
2494        #[doc(hidden)]
2495        #[derive(PartialEq, Eq, Hash)]
2496        enum __FieldTag {
2497            __text,
2498            __language_code,
2499            Unknown(std::string::String),
2500        }
2501        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2502            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2503            where
2504                D: serde::Deserializer<'de>,
2505            {
2506                struct Visitor;
2507                impl<'de> serde::de::Visitor<'de> for Visitor {
2508                    type Value = __FieldTag;
2509                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2510                        formatter.write_str("a field name for LocalizedText")
2511                    }
2512                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2513                    where
2514                        E: serde::de::Error,
2515                    {
2516                        use std::result::Result::Ok;
2517                        use std::string::ToString;
2518                        match value {
2519                            "text" => Ok(__FieldTag::__text),
2520                            "languageCode" => Ok(__FieldTag::__language_code),
2521                            "language_code" => Ok(__FieldTag::__language_code),
2522                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2523                        }
2524                    }
2525                }
2526                deserializer.deserialize_identifier(Visitor)
2527            }
2528        }
2529        struct Visitor;
2530        impl<'de> serde::de::Visitor<'de> for Visitor {
2531            type Value = LocalizedText;
2532            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2533                formatter.write_str("struct LocalizedText")
2534            }
2535            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2536            where
2537                A: serde::de::MapAccess<'de>,
2538            {
2539                #[allow(unused_imports)]
2540                use serde::de::Error;
2541                use std::option::Option::Some;
2542                let mut fields = std::collections::HashSet::new();
2543                let mut result = Self::Value::new();
2544                while let Some(tag) = map.next_key::<__FieldTag>()? {
2545                    #[allow(clippy::match_single_binding)]
2546                    match tag {
2547                        __FieldTag::__text => {
2548                            if !fields.insert(__FieldTag::__text) {
2549                                return std::result::Result::Err(A::Error::duplicate_field(
2550                                    "multiple values for text",
2551                                ));
2552                            }
2553                            result.text = map
2554                                .next_value::<std::option::Option<std::string::String>>()?
2555                                .unwrap_or_default();
2556                        }
2557                        __FieldTag::__language_code => {
2558                            if !fields.insert(__FieldTag::__language_code) {
2559                                return std::result::Result::Err(A::Error::duplicate_field(
2560                                    "multiple values for language_code",
2561                                ));
2562                            }
2563                            result.language_code = map
2564                                .next_value::<std::option::Option<std::string::String>>()?
2565                                .unwrap_or_default();
2566                        }
2567                        __FieldTag::Unknown(key) => {
2568                            let value = map.next_value::<serde_json::Value>()?;
2569                            result._unknown_fields.insert(key, value);
2570                        }
2571                    }
2572                }
2573                std::result::Result::Ok(result)
2574            }
2575        }
2576        deserializer.deserialize_any(Visitor)
2577    }
2578}
2579
2580#[doc(hidden)]
2581impl serde::ser::Serialize for LocalizedText {
2582    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2583    where
2584        S: serde::ser::Serializer,
2585    {
2586        use serde::ser::SerializeMap;
2587        #[allow(unused_imports)]
2588        use std::option::Option::Some;
2589        let mut state = serializer.serialize_map(std::option::Option::None)?;
2590        if !self.text.is_empty() {
2591            state.serialize_entry("text", &self.text)?;
2592        }
2593        if !self.language_code.is_empty() {
2594            state.serialize_entry("languageCode", &self.language_code)?;
2595        }
2596        if !self._unknown_fields.is_empty() {
2597            for (key, value) in self._unknown_fields.iter() {
2598                state.serialize_entry(key, &value)?;
2599            }
2600        }
2601        state.end()
2602    }
2603}
2604
2605/// Represents an amount of money with its currency type.
2606#[derive(Clone, Debug, Default, PartialEq)]
2607#[non_exhaustive]
2608pub struct Money {
2609    /// The three-letter currency code defined in ISO 4217.
2610    pub currency_code: std::string::String,
2611
2612    /// The whole units of the amount.
2613    /// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
2614    pub units: i64,
2615
2616    /// Number of nano (10^-9) units of the amount.
2617    /// The value must be between -999,999,999 and +999,999,999 inclusive.
2618    /// If `units` is positive, `nanos` must be positive or zero.
2619    /// If `units` is zero, `nanos` can be positive, zero, or negative.
2620    /// If `units` is negative, `nanos` must be negative or zero.
2621    /// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
2622    pub nanos: i32,
2623
2624    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2625}
2626
2627impl Money {
2628    pub fn new() -> Self {
2629        std::default::Default::default()
2630    }
2631
2632    /// Sets the value of [currency_code][crate::model::Money::currency_code].
2633    pub fn set_currency_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2634        self.currency_code = v.into();
2635        self
2636    }
2637
2638    /// Sets the value of [units][crate::model::Money::units].
2639    pub fn set_units<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2640        self.units = v.into();
2641        self
2642    }
2643
2644    /// Sets the value of [nanos][crate::model::Money::nanos].
2645    pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2646        self.nanos = v.into();
2647        self
2648    }
2649}
2650
2651impl wkt::message::Message for Money {
2652    fn typename() -> &'static str {
2653        "type.googleapis.com/google.type.Money"
2654    }
2655}
2656
2657#[doc(hidden)]
2658impl<'de> serde::de::Deserialize<'de> for Money {
2659    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2660    where
2661        D: serde::Deserializer<'de>,
2662    {
2663        #[allow(non_camel_case_types)]
2664        #[doc(hidden)]
2665        #[derive(PartialEq, Eq, Hash)]
2666        enum __FieldTag {
2667            __currency_code,
2668            __units,
2669            __nanos,
2670            Unknown(std::string::String),
2671        }
2672        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2673            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2674            where
2675                D: serde::Deserializer<'de>,
2676            {
2677                struct Visitor;
2678                impl<'de> serde::de::Visitor<'de> for Visitor {
2679                    type Value = __FieldTag;
2680                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2681                        formatter.write_str("a field name for Money")
2682                    }
2683                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2684                    where
2685                        E: serde::de::Error,
2686                    {
2687                        use std::result::Result::Ok;
2688                        use std::string::ToString;
2689                        match value {
2690                            "currencyCode" => Ok(__FieldTag::__currency_code),
2691                            "currency_code" => Ok(__FieldTag::__currency_code),
2692                            "units" => Ok(__FieldTag::__units),
2693                            "nanos" => Ok(__FieldTag::__nanos),
2694                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2695                        }
2696                    }
2697                }
2698                deserializer.deserialize_identifier(Visitor)
2699            }
2700        }
2701        struct Visitor;
2702        impl<'de> serde::de::Visitor<'de> for Visitor {
2703            type Value = Money;
2704            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2705                formatter.write_str("struct Money")
2706            }
2707            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2708            where
2709                A: serde::de::MapAccess<'de>,
2710            {
2711                #[allow(unused_imports)]
2712                use serde::de::Error;
2713                use std::option::Option::Some;
2714                let mut fields = std::collections::HashSet::new();
2715                let mut result = Self::Value::new();
2716                while let Some(tag) = map.next_key::<__FieldTag>()? {
2717                    #[allow(clippy::match_single_binding)]
2718                    match tag {
2719                        __FieldTag::__currency_code => {
2720                            if !fields.insert(__FieldTag::__currency_code) {
2721                                return std::result::Result::Err(A::Error::duplicate_field(
2722                                    "multiple values for currency_code",
2723                                ));
2724                            }
2725                            result.currency_code = map
2726                                .next_value::<std::option::Option<std::string::String>>()?
2727                                .unwrap_or_default();
2728                        }
2729                        __FieldTag::__units => {
2730                            if !fields.insert(__FieldTag::__units) {
2731                                return std::result::Result::Err(A::Error::duplicate_field(
2732                                    "multiple values for units",
2733                                ));
2734                            }
2735                            struct __With(std::option::Option<i64>);
2736                            impl<'de> serde::de::Deserialize<'de> for __With {
2737                                fn deserialize<D>(
2738                                    deserializer: D,
2739                                ) -> std::result::Result<Self, D::Error>
2740                                where
2741                                    D: serde::de::Deserializer<'de>,
2742                                {
2743                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
2744                                }
2745                            }
2746                            result.units = map.next_value::<__With>()?.0.unwrap_or_default();
2747                        }
2748                        __FieldTag::__nanos => {
2749                            if !fields.insert(__FieldTag::__nanos) {
2750                                return std::result::Result::Err(A::Error::duplicate_field(
2751                                    "multiple values for nanos",
2752                                ));
2753                            }
2754                            struct __With(std::option::Option<i32>);
2755                            impl<'de> serde::de::Deserialize<'de> for __With {
2756                                fn deserialize<D>(
2757                                    deserializer: D,
2758                                ) -> std::result::Result<Self, D::Error>
2759                                where
2760                                    D: serde::de::Deserializer<'de>,
2761                                {
2762                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2763                                }
2764                            }
2765                            result.nanos = map.next_value::<__With>()?.0.unwrap_or_default();
2766                        }
2767                        __FieldTag::Unknown(key) => {
2768                            let value = map.next_value::<serde_json::Value>()?;
2769                            result._unknown_fields.insert(key, value);
2770                        }
2771                    }
2772                }
2773                std::result::Result::Ok(result)
2774            }
2775        }
2776        deserializer.deserialize_any(Visitor)
2777    }
2778}
2779
2780#[doc(hidden)]
2781impl serde::ser::Serialize for Money {
2782    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2783    where
2784        S: serde::ser::Serializer,
2785    {
2786        use serde::ser::SerializeMap;
2787        #[allow(unused_imports)]
2788        use std::option::Option::Some;
2789        let mut state = serializer.serialize_map(std::option::Option::None)?;
2790        if !self.currency_code.is_empty() {
2791            state.serialize_entry("currencyCode", &self.currency_code)?;
2792        }
2793        if !wkt::internal::is_default(&self.units) {
2794            struct __With<'a>(&'a i64);
2795            impl<'a> serde::ser::Serialize for __With<'a> {
2796                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2797                where
2798                    S: serde::ser::Serializer,
2799                {
2800                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2801                }
2802            }
2803            state.serialize_entry("units", &__With(&self.units))?;
2804        }
2805        if !wkt::internal::is_default(&self.nanos) {
2806            struct __With<'a>(&'a i32);
2807            impl<'a> serde::ser::Serialize for __With<'a> {
2808                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2809                where
2810                    S: serde::ser::Serializer,
2811                {
2812                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
2813                }
2814            }
2815            state.serialize_entry("nanos", &__With(&self.nanos))?;
2816        }
2817        if !self._unknown_fields.is_empty() {
2818            for (key, value) in self._unknown_fields.iter() {
2819                state.serialize_entry(key, &value)?;
2820            }
2821        }
2822        state.end()
2823    }
2824}
2825
2826/// An object representing a phone number, suitable as an API wire format.
2827///
2828/// This representation:
2829///
2830/// - should not be used for locale-specific formatting of a phone number, such
2831///   as "+1 (650) 253-0000 ext. 123"
2832///
2833/// - is not designed for efficient storage
2834///
2835/// - may not be suitable for dialing - specialized libraries (see references)
2836///   should be used to parse the number for that purpose
2837///
2838///
2839/// To do something meaningful with this number, such as format it for various
2840/// use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first.
2841///
2842/// For instance, in Java this would be:
2843///
2844/// com.google.type.PhoneNumber wireProto =
2845/// com.google.type.PhoneNumber.newBuilder().build();
2846/// com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber =
2847/// PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ");
2848/// if (!wireProto.getExtension().isEmpty()) {
2849/// phoneNumber.setExtension(wireProto.getExtension());
2850/// }
2851///
2852/// Reference(s):
2853///
2854/// - <https://github.com/google/libphonenumber>
2855#[derive(Clone, Debug, Default, PartialEq)]
2856#[non_exhaustive]
2857pub struct PhoneNumber {
2858    /// The phone number's extension. The extension is not standardized in ITU
2859    /// recommendations, except for being defined as a series of numbers with a
2860    /// maximum length of 40 digits. Other than digits, some other dialing
2861    /// characters such as ',' (indicating a wait) or '#' may be stored here.
2862    ///
2863    /// Note that no regions currently use extensions with short codes, so this
2864    /// field is normally only set in conjunction with an E.164 number. It is held
2865    /// separately from the E.164 number to allow for short code extensions in the
2866    /// future.
2867    pub extension: std::string::String,
2868
2869    /// Required.  Either a regular number, or a short code.  New fields may be
2870    /// added to the oneof below in the future, so clients should ignore phone
2871    /// numbers for which none of the fields they coded against are set.
2872    pub kind: std::option::Option<crate::model::phone_number::Kind>,
2873
2874    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2875}
2876
2877impl PhoneNumber {
2878    pub fn new() -> Self {
2879        std::default::Default::default()
2880    }
2881
2882    /// Sets the value of [extension][crate::model::PhoneNumber::extension].
2883    pub fn set_extension<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2884        self.extension = v.into();
2885        self
2886    }
2887
2888    /// Sets the value of [kind][crate::model::PhoneNumber::kind].
2889    ///
2890    /// Note that all the setters affecting `kind` are mutually
2891    /// exclusive.
2892    pub fn set_kind<
2893        T: std::convert::Into<std::option::Option<crate::model::phone_number::Kind>>,
2894    >(
2895        mut self,
2896        v: T,
2897    ) -> Self {
2898        self.kind = v.into();
2899        self
2900    }
2901
2902    /// The value of [kind][crate::model::PhoneNumber::kind]
2903    /// if it holds a `E164Number`, `None` if the field is not set or
2904    /// holds a different branch.
2905    pub fn e164_number(&self) -> std::option::Option<&std::string::String> {
2906        #[allow(unreachable_patterns)]
2907        self.kind.as_ref().and_then(|v| match v {
2908            crate::model::phone_number::Kind::E164Number(v) => std::option::Option::Some(v),
2909            _ => std::option::Option::None,
2910        })
2911    }
2912
2913    /// Sets the value of [kind][crate::model::PhoneNumber::kind]
2914    /// to hold a `E164Number`.
2915    ///
2916    /// Note that all the setters affecting `kind` are
2917    /// mutually exclusive.
2918    pub fn set_e164_number<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2919        self.kind =
2920            std::option::Option::Some(crate::model::phone_number::Kind::E164Number(v.into()));
2921        self
2922    }
2923
2924    /// The value of [kind][crate::model::PhoneNumber::kind]
2925    /// if it holds a `ShortCode`, `None` if the field is not set or
2926    /// holds a different branch.
2927    pub fn short_code(
2928        &self,
2929    ) -> std::option::Option<&std::boxed::Box<crate::model::phone_number::ShortCode>> {
2930        #[allow(unreachable_patterns)]
2931        self.kind.as_ref().and_then(|v| match v {
2932            crate::model::phone_number::Kind::ShortCode(v) => std::option::Option::Some(v),
2933            _ => std::option::Option::None,
2934        })
2935    }
2936
2937    /// Sets the value of [kind][crate::model::PhoneNumber::kind]
2938    /// to hold a `ShortCode`.
2939    ///
2940    /// Note that all the setters affecting `kind` are
2941    /// mutually exclusive.
2942    pub fn set_short_code<
2943        T: std::convert::Into<std::boxed::Box<crate::model::phone_number::ShortCode>>,
2944    >(
2945        mut self,
2946        v: T,
2947    ) -> Self {
2948        self.kind =
2949            std::option::Option::Some(crate::model::phone_number::Kind::ShortCode(v.into()));
2950        self
2951    }
2952}
2953
2954impl wkt::message::Message for PhoneNumber {
2955    fn typename() -> &'static str {
2956        "type.googleapis.com/google.type.PhoneNumber"
2957    }
2958}
2959
2960#[doc(hidden)]
2961impl<'de> serde::de::Deserialize<'de> for PhoneNumber {
2962    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2963    where
2964        D: serde::Deserializer<'de>,
2965    {
2966        #[allow(non_camel_case_types)]
2967        #[doc(hidden)]
2968        #[derive(PartialEq, Eq, Hash)]
2969        enum __FieldTag {
2970            __e164_number,
2971            __short_code,
2972            __extension,
2973            Unknown(std::string::String),
2974        }
2975        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2976            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2977            where
2978                D: serde::Deserializer<'de>,
2979            {
2980                struct Visitor;
2981                impl<'de> serde::de::Visitor<'de> for Visitor {
2982                    type Value = __FieldTag;
2983                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2984                        formatter.write_str("a field name for PhoneNumber")
2985                    }
2986                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2987                    where
2988                        E: serde::de::Error,
2989                    {
2990                        use std::result::Result::Ok;
2991                        use std::string::ToString;
2992                        match value {
2993                            "e164Number" => Ok(__FieldTag::__e164_number),
2994                            "e164_number" => Ok(__FieldTag::__e164_number),
2995                            "shortCode" => Ok(__FieldTag::__short_code),
2996                            "short_code" => Ok(__FieldTag::__short_code),
2997                            "extension" => Ok(__FieldTag::__extension),
2998                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2999                        }
3000                    }
3001                }
3002                deserializer.deserialize_identifier(Visitor)
3003            }
3004        }
3005        struct Visitor;
3006        impl<'de> serde::de::Visitor<'de> for Visitor {
3007            type Value = PhoneNumber;
3008            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3009                formatter.write_str("struct PhoneNumber")
3010            }
3011            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3012            where
3013                A: serde::de::MapAccess<'de>,
3014            {
3015                #[allow(unused_imports)]
3016                use serde::de::Error;
3017                use std::option::Option::Some;
3018                let mut fields = std::collections::HashSet::new();
3019                let mut result = Self::Value::new();
3020                while let Some(tag) = map.next_key::<__FieldTag>()? {
3021                    #[allow(clippy::match_single_binding)]
3022                    match tag {
3023                        __FieldTag::__e164_number => {
3024                            if !fields.insert(__FieldTag::__e164_number) {
3025                                return std::result::Result::Err(A::Error::duplicate_field(
3026                                    "multiple values for e164_number",
3027                                ));
3028                            }
3029                            if result.kind.is_some() {
3030                                return std::result::Result::Err(A::Error::duplicate_field(
3031                                    "multiple values for `kind`, a oneof with full ID .google.type.PhoneNumber.e164_number, latest field was e164Number",
3032                                ));
3033                            }
3034                            result.kind = std::option::Option::Some(
3035                                crate::model::phone_number::Kind::E164Number(
3036                                    map.next_value::<std::option::Option<std::string::String>>()?
3037                                        .unwrap_or_default(),
3038                                ),
3039                            );
3040                        }
3041                        __FieldTag::__short_code => {
3042                            if !fields.insert(__FieldTag::__short_code) {
3043                                return std::result::Result::Err(A::Error::duplicate_field(
3044                                    "multiple values for short_code",
3045                                ));
3046                            }
3047                            if result.kind.is_some() {
3048                                return std::result::Result::Err(A::Error::duplicate_field(
3049                                    "multiple values for `kind`, a oneof with full ID .google.type.PhoneNumber.short_code, latest field was shortCode",
3050                                ));
3051                            }
3052                            result.kind = std::option::Option::Some(
3053                                crate::model::phone_number::Kind::ShortCode(
3054                                    map.next_value::<std::option::Option<
3055                                        std::boxed::Box<crate::model::phone_number::ShortCode>,
3056                                    >>()?
3057                                    .unwrap_or_default(),
3058                                ),
3059                            );
3060                        }
3061                        __FieldTag::__extension => {
3062                            if !fields.insert(__FieldTag::__extension) {
3063                                return std::result::Result::Err(A::Error::duplicate_field(
3064                                    "multiple values for extension",
3065                                ));
3066                            }
3067                            result.extension = map
3068                                .next_value::<std::option::Option<std::string::String>>()?
3069                                .unwrap_or_default();
3070                        }
3071                        __FieldTag::Unknown(key) => {
3072                            let value = map.next_value::<serde_json::Value>()?;
3073                            result._unknown_fields.insert(key, value);
3074                        }
3075                    }
3076                }
3077                std::result::Result::Ok(result)
3078            }
3079        }
3080        deserializer.deserialize_any(Visitor)
3081    }
3082}
3083
3084#[doc(hidden)]
3085impl serde::ser::Serialize for PhoneNumber {
3086    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3087    where
3088        S: serde::ser::Serializer,
3089    {
3090        use serde::ser::SerializeMap;
3091        #[allow(unused_imports)]
3092        use std::option::Option::Some;
3093        let mut state = serializer.serialize_map(std::option::Option::None)?;
3094        if let Some(value) = self.e164_number() {
3095            state.serialize_entry("e164Number", value)?;
3096        }
3097        if let Some(value) = self.short_code() {
3098            state.serialize_entry("shortCode", value)?;
3099        }
3100        if !self.extension.is_empty() {
3101            state.serialize_entry("extension", &self.extension)?;
3102        }
3103        if !self._unknown_fields.is_empty() {
3104            for (key, value) in self._unknown_fields.iter() {
3105                state.serialize_entry(key, &value)?;
3106            }
3107        }
3108        state.end()
3109    }
3110}
3111
3112/// Defines additional types related to [PhoneNumber].
3113pub mod phone_number {
3114    #[allow(unused_imports)]
3115    use super::*;
3116
3117    /// An object representing a short code, which is a phone number that is
3118    /// typically much shorter than regular phone numbers and can be used to
3119    /// address messages in MMS and SMS systems, as well as for abbreviated dialing
3120    /// (e.g. "Text 611 to see how many minutes you have remaining on your plan.").
3121    ///
3122    /// Short codes are restricted to a region and are not internationally
3123    /// dialable, which means the same short code can exist in different regions,
3124    /// with different usage and pricing, even if those regions share the same
3125    /// country calling code (e.g. US and CA).
3126    #[derive(Clone, Debug, Default, PartialEq)]
3127    #[non_exhaustive]
3128    pub struct ShortCode {
3129        /// Required. The BCP-47 region code of the location where calls to this
3130        /// short code can be made, such as "US" and "BB".
3131        ///
3132        /// Reference(s):
3133        ///
3134        /// - <http://www.unicode.org/reports/tr35/#unicode_region_subtag>
3135        pub region_code: std::string::String,
3136
3137        /// Required. The short code digits, without a leading plus ('+') or country
3138        /// calling code, e.g. "611".
3139        pub number: std::string::String,
3140
3141        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3142    }
3143
3144    impl ShortCode {
3145        pub fn new() -> Self {
3146            std::default::Default::default()
3147        }
3148
3149        /// Sets the value of [region_code][crate::model::phone_number::ShortCode::region_code].
3150        pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3151            self.region_code = v.into();
3152            self
3153        }
3154
3155        /// Sets the value of [number][crate::model::phone_number::ShortCode::number].
3156        pub fn set_number<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3157            self.number = v.into();
3158            self
3159        }
3160    }
3161
3162    impl wkt::message::Message for ShortCode {
3163        fn typename() -> &'static str {
3164            "type.googleapis.com/google.type.PhoneNumber.ShortCode"
3165        }
3166    }
3167
3168    #[doc(hidden)]
3169    impl<'de> serde::de::Deserialize<'de> for ShortCode {
3170        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3171        where
3172            D: serde::Deserializer<'de>,
3173        {
3174            #[allow(non_camel_case_types)]
3175            #[doc(hidden)]
3176            #[derive(PartialEq, Eq, Hash)]
3177            enum __FieldTag {
3178                __region_code,
3179                __number,
3180                Unknown(std::string::String),
3181            }
3182            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3183                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3184                where
3185                    D: serde::Deserializer<'de>,
3186                {
3187                    struct Visitor;
3188                    impl<'de> serde::de::Visitor<'de> for Visitor {
3189                        type Value = __FieldTag;
3190                        fn expecting(
3191                            &self,
3192                            formatter: &mut std::fmt::Formatter,
3193                        ) -> std::fmt::Result {
3194                            formatter.write_str("a field name for ShortCode")
3195                        }
3196                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3197                        where
3198                            E: serde::de::Error,
3199                        {
3200                            use std::result::Result::Ok;
3201                            use std::string::ToString;
3202                            match value {
3203                                "regionCode" => Ok(__FieldTag::__region_code),
3204                                "region_code" => Ok(__FieldTag::__region_code),
3205                                "number" => Ok(__FieldTag::__number),
3206                                _ => Ok(__FieldTag::Unknown(value.to_string())),
3207                            }
3208                        }
3209                    }
3210                    deserializer.deserialize_identifier(Visitor)
3211                }
3212            }
3213            struct Visitor;
3214            impl<'de> serde::de::Visitor<'de> for Visitor {
3215                type Value = ShortCode;
3216                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3217                    formatter.write_str("struct ShortCode")
3218                }
3219                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3220                where
3221                    A: serde::de::MapAccess<'de>,
3222                {
3223                    #[allow(unused_imports)]
3224                    use serde::de::Error;
3225                    use std::option::Option::Some;
3226                    let mut fields = std::collections::HashSet::new();
3227                    let mut result = Self::Value::new();
3228                    while let Some(tag) = map.next_key::<__FieldTag>()? {
3229                        #[allow(clippy::match_single_binding)]
3230                        match tag {
3231                            __FieldTag::__region_code => {
3232                                if !fields.insert(__FieldTag::__region_code) {
3233                                    return std::result::Result::Err(A::Error::duplicate_field(
3234                                        "multiple values for region_code",
3235                                    ));
3236                                }
3237                                result.region_code = map
3238                                    .next_value::<std::option::Option<std::string::String>>()?
3239                                    .unwrap_or_default();
3240                            }
3241                            __FieldTag::__number => {
3242                                if !fields.insert(__FieldTag::__number) {
3243                                    return std::result::Result::Err(A::Error::duplicate_field(
3244                                        "multiple values for number",
3245                                    ));
3246                                }
3247                                result.number = map
3248                                    .next_value::<std::option::Option<std::string::String>>()?
3249                                    .unwrap_or_default();
3250                            }
3251                            __FieldTag::Unknown(key) => {
3252                                let value = map.next_value::<serde_json::Value>()?;
3253                                result._unknown_fields.insert(key, value);
3254                            }
3255                        }
3256                    }
3257                    std::result::Result::Ok(result)
3258                }
3259            }
3260            deserializer.deserialize_any(Visitor)
3261        }
3262    }
3263
3264    #[doc(hidden)]
3265    impl serde::ser::Serialize for ShortCode {
3266        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3267        where
3268            S: serde::ser::Serializer,
3269        {
3270            use serde::ser::SerializeMap;
3271            #[allow(unused_imports)]
3272            use std::option::Option::Some;
3273            let mut state = serializer.serialize_map(std::option::Option::None)?;
3274            if !self.region_code.is_empty() {
3275                state.serialize_entry("regionCode", &self.region_code)?;
3276            }
3277            if !self.number.is_empty() {
3278                state.serialize_entry("number", &self.number)?;
3279            }
3280            if !self._unknown_fields.is_empty() {
3281                for (key, value) in self._unknown_fields.iter() {
3282                    state.serialize_entry(key, &value)?;
3283                }
3284            }
3285            state.end()
3286        }
3287    }
3288
3289    /// Required.  Either a regular number, or a short code.  New fields may be
3290    /// added to the oneof below in the future, so clients should ignore phone
3291    /// numbers for which none of the fields they coded against are set.
3292    #[derive(Clone, Debug, PartialEq)]
3293    #[non_exhaustive]
3294    pub enum Kind {
3295        /// The phone number, represented as a leading plus sign ('+'), followed by a
3296        /// phone number that uses a relaxed ITU E.164 format consisting of the
3297        /// country calling code (1 to 3 digits) and the subscriber number, with no
3298        /// additional spaces or formatting, e.g.:
3299        ///
3300        /// - correct: "+15552220123"
3301        /// - incorrect: "+1 (555) 222-01234 x123".
3302        ///
3303        /// The ITU E.164 format limits the latter to 12 digits, but in practice not
3304        /// all countries respect that, so we relax that restriction here.
3305        /// National-only numbers are not allowed.
3306        ///
3307        /// References:
3308        ///
3309        /// - <https://www.itu.int/rec/T-REC-E.164-201011-I>
3310        /// - <https://en.wikipedia.org/wiki/E.164>.
3311        /// - <https://en.wikipedia.org/wiki/List_of_country_calling_codes>
3312        E164Number(std::string::String),
3313        /// A short code.
3314        ///
3315        /// Reference(s):
3316        ///
3317        /// - <https://en.wikipedia.org/wiki/Short_code>
3318        ShortCode(std::boxed::Box<crate::model::phone_number::ShortCode>),
3319    }
3320}
3321
3322/// Represents a postal address, e.g. for postal delivery or payments addresses.
3323/// Given a postal address, a postal service can deliver items to a premise, P.O.
3324/// Box or similar.
3325/// It is not intended to model geographical locations (roads, towns,
3326/// mountains).
3327///
3328/// In typical usage an address would be created via user input or from importing
3329/// existing data, depending on the type of process.
3330///
3331/// Advice on address input / editing:
3332///
3333/// - Use an i18n-ready address widget such as
3334///   <https://github.com/google/libaddressinput>)
3335/// - Users should not be presented with UI elements for input or editing of
3336///   fields outside countries where that field is used.
3337///
3338/// For more guidance on how to use this schema, please see:
3339/// <https://support.google.com/business/answer/6397478>
3340#[derive(Clone, Debug, Default, PartialEq)]
3341#[non_exhaustive]
3342pub struct PostalAddress {
3343    /// The schema revision of the `PostalAddress`. This must be set to 0, which is
3344    /// the latest revision.
3345    ///
3346    /// All new revisions **must** be backward compatible with old revisions.
3347    pub revision: i32,
3348
3349    /// Required. CLDR region code of the country/region of the address. This
3350    /// is never inferred and it is up to the user to ensure the value is
3351    /// correct. See <http://cldr.unicode.org/> and
3352    /// <http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html>
3353    /// for details. Example: "CH" for Switzerland.
3354    pub region_code: std::string::String,
3355
3356    /// Optional. BCP-47 language code of the contents of this address (if
3357    /// known). This is often the UI language of the input form or is expected
3358    /// to match one of the languages used in the address' country/region, or their
3359    /// transliterated equivalents.
3360    /// This can affect formatting in certain countries, but is not critical
3361    /// to the correctness of the data and will never affect any validation or
3362    /// other non-formatting related operations.
3363    ///
3364    /// If this value is not known, it should be omitted (rather than specifying a
3365    /// possibly incorrect default).
3366    ///
3367    /// Examples: "zh-Hant", "ja", "ja-Latn", "en".
3368    pub language_code: std::string::String,
3369
3370    /// Optional. Postal code of the address. Not all countries use or require
3371    /// postal codes to be present, but where they are used, they may trigger
3372    /// additional validation with other parts of the address (e.g. state/zip
3373    /// validation in the U.S.A.).
3374    pub postal_code: std::string::String,
3375
3376    /// Optional. Additional, country-specific, sorting code. This is not used
3377    /// in most regions. Where it is used, the value is either a string like
3378    /// "CEDEX", optionally followed by a number (e.g. "CEDEX 7"), or just a number
3379    /// alone, representing the "sector code" (Jamaica), "delivery area indicator"
3380    /// (Malawi) or "post office indicator" (e.g. Côte d'Ivoire).
3381    pub sorting_code: std::string::String,
3382
3383    /// Optional. Highest administrative subdivision which is used for postal
3384    /// addresses of a country or region.
3385    /// For example, this can be a state, a province, an oblast, or a prefecture.
3386    /// Specifically, for Spain this is the province and not the autonomous
3387    /// community (e.g. "Barcelona" and not "Catalonia").
3388    /// Many countries don't use an administrative area in postal addresses. E.g.
3389    /// in Switzerland this should be left unpopulated.
3390    pub administrative_area: std::string::String,
3391
3392    /// Optional. Generally refers to the city/town portion of the address.
3393    /// Examples: US city, IT comune, UK post town.
3394    /// In regions of the world where localities are not well defined or do not fit
3395    /// into this structure well, leave locality empty and use address_lines.
3396    pub locality: std::string::String,
3397
3398    /// Optional. Sublocality of the address.
3399    /// For example, this can be neighborhoods, boroughs, districts.
3400    pub sublocality: std::string::String,
3401
3402    /// Unstructured address lines describing the lower levels of an address.
3403    ///
3404    /// Because values in address_lines do not have type information and may
3405    /// sometimes contain multiple values in a single field (e.g.
3406    /// "Austin, TX"), it is important that the line order is clear. The order of
3407    /// address lines should be "envelope order" for the country/region of the
3408    /// address. In places where this can vary (e.g. Japan), address_language is
3409    /// used to make it explicit (e.g. "ja" for large-to-small ordering and
3410    /// "ja-Latn" or "en" for small-to-large). This way, the most specific line of
3411    /// an address can be selected based on the language.
3412    ///
3413    /// The minimum permitted structural representation of an address consists
3414    /// of a region_code with all remaining information placed in the
3415    /// address_lines. It would be possible to format such an address very
3416    /// approximately without geocoding, but no semantic reasoning could be
3417    /// made about any of the address components until it was at least
3418    /// partially resolved.
3419    ///
3420    /// Creating an address only containing a region_code and address_lines, and
3421    /// then geocoding is the recommended way to handle completely unstructured
3422    /// addresses (as opposed to guessing which parts of the address should be
3423    /// localities or administrative areas).
3424    pub address_lines: std::vec::Vec<std::string::String>,
3425
3426    /// Optional. The recipient at the address.
3427    /// This field may, under certain circumstances, contain multiline information.
3428    /// For example, it might contain "care of" information.
3429    pub recipients: std::vec::Vec<std::string::String>,
3430
3431    /// Optional. The name of the organization at the address.
3432    pub organization: std::string::String,
3433
3434    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3435}
3436
3437impl PostalAddress {
3438    pub fn new() -> Self {
3439        std::default::Default::default()
3440    }
3441
3442    /// Sets the value of [revision][crate::model::PostalAddress::revision].
3443    pub fn set_revision<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3444        self.revision = v.into();
3445        self
3446    }
3447
3448    /// Sets the value of [region_code][crate::model::PostalAddress::region_code].
3449    pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3450        self.region_code = v.into();
3451        self
3452    }
3453
3454    /// Sets the value of [language_code][crate::model::PostalAddress::language_code].
3455    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3456        self.language_code = v.into();
3457        self
3458    }
3459
3460    /// Sets the value of [postal_code][crate::model::PostalAddress::postal_code].
3461    pub fn set_postal_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3462        self.postal_code = v.into();
3463        self
3464    }
3465
3466    /// Sets the value of [sorting_code][crate::model::PostalAddress::sorting_code].
3467    pub fn set_sorting_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3468        self.sorting_code = v.into();
3469        self
3470    }
3471
3472    /// Sets the value of [administrative_area][crate::model::PostalAddress::administrative_area].
3473    pub fn set_administrative_area<T: std::convert::Into<std::string::String>>(
3474        mut self,
3475        v: T,
3476    ) -> Self {
3477        self.administrative_area = v.into();
3478        self
3479    }
3480
3481    /// Sets the value of [locality][crate::model::PostalAddress::locality].
3482    pub fn set_locality<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3483        self.locality = v.into();
3484        self
3485    }
3486
3487    /// Sets the value of [sublocality][crate::model::PostalAddress::sublocality].
3488    pub fn set_sublocality<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3489        self.sublocality = v.into();
3490        self
3491    }
3492
3493    /// Sets the value of [address_lines][crate::model::PostalAddress::address_lines].
3494    pub fn set_address_lines<T, V>(mut self, v: T) -> Self
3495    where
3496        T: std::iter::IntoIterator<Item = V>,
3497        V: std::convert::Into<std::string::String>,
3498    {
3499        use std::iter::Iterator;
3500        self.address_lines = v.into_iter().map(|i| i.into()).collect();
3501        self
3502    }
3503
3504    /// Sets the value of [recipients][crate::model::PostalAddress::recipients].
3505    pub fn set_recipients<T, V>(mut self, v: T) -> Self
3506    where
3507        T: std::iter::IntoIterator<Item = V>,
3508        V: std::convert::Into<std::string::String>,
3509    {
3510        use std::iter::Iterator;
3511        self.recipients = v.into_iter().map(|i| i.into()).collect();
3512        self
3513    }
3514
3515    /// Sets the value of [organization][crate::model::PostalAddress::organization].
3516    pub fn set_organization<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3517        self.organization = v.into();
3518        self
3519    }
3520}
3521
3522impl wkt::message::Message for PostalAddress {
3523    fn typename() -> &'static str {
3524        "type.googleapis.com/google.type.PostalAddress"
3525    }
3526}
3527
3528#[doc(hidden)]
3529impl<'de> serde::de::Deserialize<'de> for PostalAddress {
3530    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3531    where
3532        D: serde::Deserializer<'de>,
3533    {
3534        #[allow(non_camel_case_types)]
3535        #[doc(hidden)]
3536        #[derive(PartialEq, Eq, Hash)]
3537        enum __FieldTag {
3538            __revision,
3539            __region_code,
3540            __language_code,
3541            __postal_code,
3542            __sorting_code,
3543            __administrative_area,
3544            __locality,
3545            __sublocality,
3546            __address_lines,
3547            __recipients,
3548            __organization,
3549            Unknown(std::string::String),
3550        }
3551        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3552            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3553            where
3554                D: serde::Deserializer<'de>,
3555            {
3556                struct Visitor;
3557                impl<'de> serde::de::Visitor<'de> for Visitor {
3558                    type Value = __FieldTag;
3559                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3560                        formatter.write_str("a field name for PostalAddress")
3561                    }
3562                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3563                    where
3564                        E: serde::de::Error,
3565                    {
3566                        use std::result::Result::Ok;
3567                        use std::string::ToString;
3568                        match value {
3569                            "revision" => Ok(__FieldTag::__revision),
3570                            "regionCode" => Ok(__FieldTag::__region_code),
3571                            "region_code" => Ok(__FieldTag::__region_code),
3572                            "languageCode" => Ok(__FieldTag::__language_code),
3573                            "language_code" => Ok(__FieldTag::__language_code),
3574                            "postalCode" => Ok(__FieldTag::__postal_code),
3575                            "postal_code" => Ok(__FieldTag::__postal_code),
3576                            "sortingCode" => Ok(__FieldTag::__sorting_code),
3577                            "sorting_code" => Ok(__FieldTag::__sorting_code),
3578                            "administrativeArea" => Ok(__FieldTag::__administrative_area),
3579                            "administrative_area" => Ok(__FieldTag::__administrative_area),
3580                            "locality" => Ok(__FieldTag::__locality),
3581                            "sublocality" => Ok(__FieldTag::__sublocality),
3582                            "addressLines" => Ok(__FieldTag::__address_lines),
3583                            "address_lines" => Ok(__FieldTag::__address_lines),
3584                            "recipients" => Ok(__FieldTag::__recipients),
3585                            "organization" => Ok(__FieldTag::__organization),
3586                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3587                        }
3588                    }
3589                }
3590                deserializer.deserialize_identifier(Visitor)
3591            }
3592        }
3593        struct Visitor;
3594        impl<'de> serde::de::Visitor<'de> for Visitor {
3595            type Value = PostalAddress;
3596            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3597                formatter.write_str("struct PostalAddress")
3598            }
3599            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3600            where
3601                A: serde::de::MapAccess<'de>,
3602            {
3603                #[allow(unused_imports)]
3604                use serde::de::Error;
3605                use std::option::Option::Some;
3606                let mut fields = std::collections::HashSet::new();
3607                let mut result = Self::Value::new();
3608                while let Some(tag) = map.next_key::<__FieldTag>()? {
3609                    #[allow(clippy::match_single_binding)]
3610                    match tag {
3611                        __FieldTag::__revision => {
3612                            if !fields.insert(__FieldTag::__revision) {
3613                                return std::result::Result::Err(A::Error::duplicate_field(
3614                                    "multiple values for revision",
3615                                ));
3616                            }
3617                            struct __With(std::option::Option<i32>);
3618                            impl<'de> serde::de::Deserialize<'de> for __With {
3619                                fn deserialize<D>(
3620                                    deserializer: D,
3621                                ) -> std::result::Result<Self, D::Error>
3622                                where
3623                                    D: serde::de::Deserializer<'de>,
3624                                {
3625                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
3626                                }
3627                            }
3628                            result.revision = map.next_value::<__With>()?.0.unwrap_or_default();
3629                        }
3630                        __FieldTag::__region_code => {
3631                            if !fields.insert(__FieldTag::__region_code) {
3632                                return std::result::Result::Err(A::Error::duplicate_field(
3633                                    "multiple values for region_code",
3634                                ));
3635                            }
3636                            result.region_code = map
3637                                .next_value::<std::option::Option<std::string::String>>()?
3638                                .unwrap_or_default();
3639                        }
3640                        __FieldTag::__language_code => {
3641                            if !fields.insert(__FieldTag::__language_code) {
3642                                return std::result::Result::Err(A::Error::duplicate_field(
3643                                    "multiple values for language_code",
3644                                ));
3645                            }
3646                            result.language_code = map
3647                                .next_value::<std::option::Option<std::string::String>>()?
3648                                .unwrap_or_default();
3649                        }
3650                        __FieldTag::__postal_code => {
3651                            if !fields.insert(__FieldTag::__postal_code) {
3652                                return std::result::Result::Err(A::Error::duplicate_field(
3653                                    "multiple values for postal_code",
3654                                ));
3655                            }
3656                            result.postal_code = map
3657                                .next_value::<std::option::Option<std::string::String>>()?
3658                                .unwrap_or_default();
3659                        }
3660                        __FieldTag::__sorting_code => {
3661                            if !fields.insert(__FieldTag::__sorting_code) {
3662                                return std::result::Result::Err(A::Error::duplicate_field(
3663                                    "multiple values for sorting_code",
3664                                ));
3665                            }
3666                            result.sorting_code = map
3667                                .next_value::<std::option::Option<std::string::String>>()?
3668                                .unwrap_or_default();
3669                        }
3670                        __FieldTag::__administrative_area => {
3671                            if !fields.insert(__FieldTag::__administrative_area) {
3672                                return std::result::Result::Err(A::Error::duplicate_field(
3673                                    "multiple values for administrative_area",
3674                                ));
3675                            }
3676                            result.administrative_area = map
3677                                .next_value::<std::option::Option<std::string::String>>()?
3678                                .unwrap_or_default();
3679                        }
3680                        __FieldTag::__locality => {
3681                            if !fields.insert(__FieldTag::__locality) {
3682                                return std::result::Result::Err(A::Error::duplicate_field(
3683                                    "multiple values for locality",
3684                                ));
3685                            }
3686                            result.locality = map
3687                                .next_value::<std::option::Option<std::string::String>>()?
3688                                .unwrap_or_default();
3689                        }
3690                        __FieldTag::__sublocality => {
3691                            if !fields.insert(__FieldTag::__sublocality) {
3692                                return std::result::Result::Err(A::Error::duplicate_field(
3693                                    "multiple values for sublocality",
3694                                ));
3695                            }
3696                            result.sublocality = map
3697                                .next_value::<std::option::Option<std::string::String>>()?
3698                                .unwrap_or_default();
3699                        }
3700                        __FieldTag::__address_lines => {
3701                            if !fields.insert(__FieldTag::__address_lines) {
3702                                return std::result::Result::Err(A::Error::duplicate_field(
3703                                    "multiple values for address_lines",
3704                                ));
3705                            }
3706                            result.address_lines = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
3707                        }
3708                        __FieldTag::__recipients => {
3709                            if !fields.insert(__FieldTag::__recipients) {
3710                                return std::result::Result::Err(A::Error::duplicate_field(
3711                                    "multiple values for recipients",
3712                                ));
3713                            }
3714                            result.recipients = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
3715                        }
3716                        __FieldTag::__organization => {
3717                            if !fields.insert(__FieldTag::__organization) {
3718                                return std::result::Result::Err(A::Error::duplicate_field(
3719                                    "multiple values for organization",
3720                                ));
3721                            }
3722                            result.organization = map
3723                                .next_value::<std::option::Option<std::string::String>>()?
3724                                .unwrap_or_default();
3725                        }
3726                        __FieldTag::Unknown(key) => {
3727                            let value = map.next_value::<serde_json::Value>()?;
3728                            result._unknown_fields.insert(key, value);
3729                        }
3730                    }
3731                }
3732                std::result::Result::Ok(result)
3733            }
3734        }
3735        deserializer.deserialize_any(Visitor)
3736    }
3737}
3738
3739#[doc(hidden)]
3740impl serde::ser::Serialize for PostalAddress {
3741    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3742    where
3743        S: serde::ser::Serializer,
3744    {
3745        use serde::ser::SerializeMap;
3746        #[allow(unused_imports)]
3747        use std::option::Option::Some;
3748        let mut state = serializer.serialize_map(std::option::Option::None)?;
3749        if !wkt::internal::is_default(&self.revision) {
3750            struct __With<'a>(&'a i32);
3751            impl<'a> serde::ser::Serialize for __With<'a> {
3752                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3753                where
3754                    S: serde::ser::Serializer,
3755                {
3756                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3757                }
3758            }
3759            state.serialize_entry("revision", &__With(&self.revision))?;
3760        }
3761        if !self.region_code.is_empty() {
3762            state.serialize_entry("regionCode", &self.region_code)?;
3763        }
3764        if !self.language_code.is_empty() {
3765            state.serialize_entry("languageCode", &self.language_code)?;
3766        }
3767        if !self.postal_code.is_empty() {
3768            state.serialize_entry("postalCode", &self.postal_code)?;
3769        }
3770        if !self.sorting_code.is_empty() {
3771            state.serialize_entry("sortingCode", &self.sorting_code)?;
3772        }
3773        if !self.administrative_area.is_empty() {
3774            state.serialize_entry("administrativeArea", &self.administrative_area)?;
3775        }
3776        if !self.locality.is_empty() {
3777            state.serialize_entry("locality", &self.locality)?;
3778        }
3779        if !self.sublocality.is_empty() {
3780            state.serialize_entry("sublocality", &self.sublocality)?;
3781        }
3782        if !self.address_lines.is_empty() {
3783            state.serialize_entry("addressLines", &self.address_lines)?;
3784        }
3785        if !self.recipients.is_empty() {
3786            state.serialize_entry("recipients", &self.recipients)?;
3787        }
3788        if !self.organization.is_empty() {
3789            state.serialize_entry("organization", &self.organization)?;
3790        }
3791        if !self._unknown_fields.is_empty() {
3792            for (key, value) in self._unknown_fields.iter() {
3793                state.serialize_entry(key, &value)?;
3794            }
3795        }
3796        state.end()
3797    }
3798}
3799
3800/// A quaternion is defined as the quotient of two directed lines in a
3801/// three-dimensional space or equivalently as the quotient of two Euclidean
3802/// vectors (<https://en.wikipedia.org/wiki/Quaternion>).
3803///
3804/// Quaternions are often used in calculations involving three-dimensional
3805/// rotations (<https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation>),
3806/// as they provide greater mathematical robustness by avoiding the gimbal lock
3807/// problems that can be encountered when using Euler angles
3808/// (<https://en.wikipedia.org/wiki/Gimbal_lock>).
3809///
3810/// Quaternions are generally represented in this form:
3811///
3812/// ```norust
3813/// w + xi + yj + zk
3814/// ```
3815///
3816/// where x, y, z, and w are real numbers, and i, j, and k are three imaginary
3817/// numbers.
3818///
3819/// Our naming choice `(x, y, z, w)` comes from the desire to avoid confusion for
3820/// those interested in the geometric properties of the quaternion in the 3D
3821/// Cartesian space. Other texts often use alternative names or subscripts, such
3822/// as `(a, b, c, d)`, `(1, i, j, k)`, or `(0, 1, 2, 3)`, which are perhaps
3823/// better suited for mathematical interpretations.
3824///
3825/// To avoid any confusion, as well as to maintain compatibility with a large
3826/// number of software libraries, the quaternions represented using the protocol
3827/// buffer below *must* follow the Hamilton convention, which defines `ij = k`
3828/// (i.e. a right-handed algebra), and therefore:
3829///
3830/// ```norust
3831/// i^2 = j^2 = k^2 = ijk = −1
3832/// ij = −ji = k
3833/// jk = −kj = i
3834/// ki = −ik = j
3835/// ```
3836///
3837/// Please DO NOT use this to represent quaternions that follow the JPL
3838/// convention, or any of the other quaternion flavors out there.
3839///
3840/// Definitions:
3841///
3842/// - Quaternion norm (or magnitude): `sqrt(x^2 + y^2 + z^2 + w^2)`.
3843/// - Unit (or normalized) quaternion: a quaternion whose norm is 1.
3844/// - Pure quaternion: a quaternion whose scalar component (`w`) is 0.
3845/// - Rotation quaternion: a unit quaternion used to represent rotation.
3846/// - Orientation quaternion: a unit quaternion used to represent orientation.
3847///
3848/// A quaternion can be normalized by dividing it by its norm. The resulting
3849/// quaternion maintains the same direction, but has a norm of 1, i.e. it moves
3850/// on the unit sphere. This is generally necessary for rotation and orientation
3851/// quaternions, to avoid rounding errors:
3852/// <https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions>
3853///
3854/// Note that `(x, y, z, w)` and `(-x, -y, -z, -w)` represent the same rotation,
3855/// but normalization would be even more useful, e.g. for comparison purposes, if
3856/// it would produce a unique representation. It is thus recommended that `w` be
3857/// kept positive, which can be achieved by changing all the signs when `w` is
3858/// negative.
3859#[derive(Clone, Debug, Default, PartialEq)]
3860#[non_exhaustive]
3861pub struct Quaternion {
3862    /// The x component.
3863    pub x: f64,
3864
3865    /// The y component.
3866    pub y: f64,
3867
3868    /// The z component.
3869    pub z: f64,
3870
3871    /// The scalar component.
3872    pub w: f64,
3873
3874    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3875}
3876
3877impl Quaternion {
3878    pub fn new() -> Self {
3879        std::default::Default::default()
3880    }
3881
3882    /// Sets the value of [x][crate::model::Quaternion::x].
3883    pub fn set_x<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3884        self.x = v.into();
3885        self
3886    }
3887
3888    /// Sets the value of [y][crate::model::Quaternion::y].
3889    pub fn set_y<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3890        self.y = v.into();
3891        self
3892    }
3893
3894    /// Sets the value of [z][crate::model::Quaternion::z].
3895    pub fn set_z<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3896        self.z = v.into();
3897        self
3898    }
3899
3900    /// Sets the value of [w][crate::model::Quaternion::w].
3901    pub fn set_w<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3902        self.w = v.into();
3903        self
3904    }
3905}
3906
3907impl wkt::message::Message for Quaternion {
3908    fn typename() -> &'static str {
3909        "type.googleapis.com/google.type.Quaternion"
3910    }
3911}
3912
3913#[doc(hidden)]
3914impl<'de> serde::de::Deserialize<'de> for Quaternion {
3915    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3916    where
3917        D: serde::Deserializer<'de>,
3918    {
3919        #[allow(non_camel_case_types)]
3920        #[doc(hidden)]
3921        #[derive(PartialEq, Eq, Hash)]
3922        enum __FieldTag {
3923            __x,
3924            __y,
3925            __z,
3926            __w,
3927            Unknown(std::string::String),
3928        }
3929        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3930            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3931            where
3932                D: serde::Deserializer<'de>,
3933            {
3934                struct Visitor;
3935                impl<'de> serde::de::Visitor<'de> for Visitor {
3936                    type Value = __FieldTag;
3937                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3938                        formatter.write_str("a field name for Quaternion")
3939                    }
3940                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3941                    where
3942                        E: serde::de::Error,
3943                    {
3944                        use std::result::Result::Ok;
3945                        use std::string::ToString;
3946                        match value {
3947                            "x" => Ok(__FieldTag::__x),
3948                            "y" => Ok(__FieldTag::__y),
3949                            "z" => Ok(__FieldTag::__z),
3950                            "w" => Ok(__FieldTag::__w),
3951                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3952                        }
3953                    }
3954                }
3955                deserializer.deserialize_identifier(Visitor)
3956            }
3957        }
3958        struct Visitor;
3959        impl<'de> serde::de::Visitor<'de> for Visitor {
3960            type Value = Quaternion;
3961            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3962                formatter.write_str("struct Quaternion")
3963            }
3964            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3965            where
3966                A: serde::de::MapAccess<'de>,
3967            {
3968                #[allow(unused_imports)]
3969                use serde::de::Error;
3970                use std::option::Option::Some;
3971                let mut fields = std::collections::HashSet::new();
3972                let mut result = Self::Value::new();
3973                while let Some(tag) = map.next_key::<__FieldTag>()? {
3974                    #[allow(clippy::match_single_binding)]
3975                    match tag {
3976                        __FieldTag::__x => {
3977                            if !fields.insert(__FieldTag::__x) {
3978                                return std::result::Result::Err(A::Error::duplicate_field(
3979                                    "multiple values for x",
3980                                ));
3981                            }
3982                            struct __With(std::option::Option<f64>);
3983                            impl<'de> serde::de::Deserialize<'de> for __With {
3984                                fn deserialize<D>(
3985                                    deserializer: D,
3986                                ) -> std::result::Result<Self, D::Error>
3987                                where
3988                                    D: serde::de::Deserializer<'de>,
3989                                {
3990                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
3991                                }
3992                            }
3993                            result.x = map.next_value::<__With>()?.0.unwrap_or_default();
3994                        }
3995                        __FieldTag::__y => {
3996                            if !fields.insert(__FieldTag::__y) {
3997                                return std::result::Result::Err(A::Error::duplicate_field(
3998                                    "multiple values for y",
3999                                ));
4000                            }
4001                            struct __With(std::option::Option<f64>);
4002                            impl<'de> serde::de::Deserialize<'de> for __With {
4003                                fn deserialize<D>(
4004                                    deserializer: D,
4005                                ) -> std::result::Result<Self, D::Error>
4006                                where
4007                                    D: serde::de::Deserializer<'de>,
4008                                {
4009                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
4010                                }
4011                            }
4012                            result.y = map.next_value::<__With>()?.0.unwrap_or_default();
4013                        }
4014                        __FieldTag::__z => {
4015                            if !fields.insert(__FieldTag::__z) {
4016                                return std::result::Result::Err(A::Error::duplicate_field(
4017                                    "multiple values for z",
4018                                ));
4019                            }
4020                            struct __With(std::option::Option<f64>);
4021                            impl<'de> serde::de::Deserialize<'de> for __With {
4022                                fn deserialize<D>(
4023                                    deserializer: D,
4024                                ) -> std::result::Result<Self, D::Error>
4025                                where
4026                                    D: serde::de::Deserializer<'de>,
4027                                {
4028                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
4029                                }
4030                            }
4031                            result.z = map.next_value::<__With>()?.0.unwrap_or_default();
4032                        }
4033                        __FieldTag::__w => {
4034                            if !fields.insert(__FieldTag::__w) {
4035                                return std::result::Result::Err(A::Error::duplicate_field(
4036                                    "multiple values for w",
4037                                ));
4038                            }
4039                            struct __With(std::option::Option<f64>);
4040                            impl<'de> serde::de::Deserialize<'de> for __With {
4041                                fn deserialize<D>(
4042                                    deserializer: D,
4043                                ) -> std::result::Result<Self, D::Error>
4044                                where
4045                                    D: serde::de::Deserializer<'de>,
4046                                {
4047                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
4048                                }
4049                            }
4050                            result.w = map.next_value::<__With>()?.0.unwrap_or_default();
4051                        }
4052                        __FieldTag::Unknown(key) => {
4053                            let value = map.next_value::<serde_json::Value>()?;
4054                            result._unknown_fields.insert(key, value);
4055                        }
4056                    }
4057                }
4058                std::result::Result::Ok(result)
4059            }
4060        }
4061        deserializer.deserialize_any(Visitor)
4062    }
4063}
4064
4065#[doc(hidden)]
4066impl serde::ser::Serialize for Quaternion {
4067    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4068    where
4069        S: serde::ser::Serializer,
4070    {
4071        use serde::ser::SerializeMap;
4072        #[allow(unused_imports)]
4073        use std::option::Option::Some;
4074        let mut state = serializer.serialize_map(std::option::Option::None)?;
4075        if !wkt::internal::is_default(&self.x) {
4076            struct __With<'a>(&'a f64);
4077            impl<'a> serde::ser::Serialize for __With<'a> {
4078                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4079                where
4080                    S: serde::ser::Serializer,
4081                {
4082                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
4083                }
4084            }
4085            state.serialize_entry("x", &__With(&self.x))?;
4086        }
4087        if !wkt::internal::is_default(&self.y) {
4088            struct __With<'a>(&'a f64);
4089            impl<'a> serde::ser::Serialize for __With<'a> {
4090                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4091                where
4092                    S: serde::ser::Serializer,
4093                {
4094                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
4095                }
4096            }
4097            state.serialize_entry("y", &__With(&self.y))?;
4098        }
4099        if !wkt::internal::is_default(&self.z) {
4100            struct __With<'a>(&'a f64);
4101            impl<'a> serde::ser::Serialize for __With<'a> {
4102                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4103                where
4104                    S: serde::ser::Serializer,
4105                {
4106                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
4107                }
4108            }
4109            state.serialize_entry("z", &__With(&self.z))?;
4110        }
4111        if !wkt::internal::is_default(&self.w) {
4112            struct __With<'a>(&'a f64);
4113            impl<'a> serde::ser::Serialize for __With<'a> {
4114                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4115                where
4116                    S: serde::ser::Serializer,
4117                {
4118                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
4119                }
4120            }
4121            state.serialize_entry("w", &__With(&self.w))?;
4122        }
4123        if !self._unknown_fields.is_empty() {
4124            for (key, value) in self._unknown_fields.iter() {
4125                state.serialize_entry(key, &value)?;
4126            }
4127        }
4128        state.end()
4129    }
4130}
4131
4132/// Represents a time of day. The date and time zone are either not significant
4133/// or are specified elsewhere. An API may choose to allow leap seconds. Related
4134/// types are [google.type.Date][google.type.Date] and
4135/// `google.protobuf.Timestamp`.
4136///
4137/// [google.type.Date]: crate::model::Date
4138#[derive(Clone, Debug, Default, PartialEq)]
4139#[non_exhaustive]
4140pub struct TimeOfDay {
4141    /// Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
4142    /// to allow the value "24:00:00" for scenarios like business closing time.
4143    pub hours: i32,
4144
4145    /// Minutes of hour of day. Must be from 0 to 59.
4146    pub minutes: i32,
4147
4148    /// Seconds of minutes of the time. Must normally be from 0 to 59. An API may
4149    /// allow the value 60 if it allows leap-seconds.
4150    pub seconds: i32,
4151
4152    /// Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
4153    pub nanos: i32,
4154
4155    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4156}
4157
4158impl TimeOfDay {
4159    pub fn new() -> Self {
4160        std::default::Default::default()
4161    }
4162
4163    /// Sets the value of [hours][crate::model::TimeOfDay::hours].
4164    pub fn set_hours<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4165        self.hours = v.into();
4166        self
4167    }
4168
4169    /// Sets the value of [minutes][crate::model::TimeOfDay::minutes].
4170    pub fn set_minutes<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4171        self.minutes = v.into();
4172        self
4173    }
4174
4175    /// Sets the value of [seconds][crate::model::TimeOfDay::seconds].
4176    pub fn set_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4177        self.seconds = v.into();
4178        self
4179    }
4180
4181    /// Sets the value of [nanos][crate::model::TimeOfDay::nanos].
4182    pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4183        self.nanos = v.into();
4184        self
4185    }
4186}
4187
4188impl wkt::message::Message for TimeOfDay {
4189    fn typename() -> &'static str {
4190        "type.googleapis.com/google.type.TimeOfDay"
4191    }
4192}
4193
4194#[doc(hidden)]
4195impl<'de> serde::de::Deserialize<'de> for TimeOfDay {
4196    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4197    where
4198        D: serde::Deserializer<'de>,
4199    {
4200        #[allow(non_camel_case_types)]
4201        #[doc(hidden)]
4202        #[derive(PartialEq, Eq, Hash)]
4203        enum __FieldTag {
4204            __hours,
4205            __minutes,
4206            __seconds,
4207            __nanos,
4208            Unknown(std::string::String),
4209        }
4210        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4211            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4212            where
4213                D: serde::Deserializer<'de>,
4214            {
4215                struct Visitor;
4216                impl<'de> serde::de::Visitor<'de> for Visitor {
4217                    type Value = __FieldTag;
4218                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4219                        formatter.write_str("a field name for TimeOfDay")
4220                    }
4221                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4222                    where
4223                        E: serde::de::Error,
4224                    {
4225                        use std::result::Result::Ok;
4226                        use std::string::ToString;
4227                        match value {
4228                            "hours" => Ok(__FieldTag::__hours),
4229                            "minutes" => Ok(__FieldTag::__minutes),
4230                            "seconds" => Ok(__FieldTag::__seconds),
4231                            "nanos" => Ok(__FieldTag::__nanos),
4232                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4233                        }
4234                    }
4235                }
4236                deserializer.deserialize_identifier(Visitor)
4237            }
4238        }
4239        struct Visitor;
4240        impl<'de> serde::de::Visitor<'de> for Visitor {
4241            type Value = TimeOfDay;
4242            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4243                formatter.write_str("struct TimeOfDay")
4244            }
4245            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4246            where
4247                A: serde::de::MapAccess<'de>,
4248            {
4249                #[allow(unused_imports)]
4250                use serde::de::Error;
4251                use std::option::Option::Some;
4252                let mut fields = std::collections::HashSet::new();
4253                let mut result = Self::Value::new();
4254                while let Some(tag) = map.next_key::<__FieldTag>()? {
4255                    #[allow(clippy::match_single_binding)]
4256                    match tag {
4257                        __FieldTag::__hours => {
4258                            if !fields.insert(__FieldTag::__hours) {
4259                                return std::result::Result::Err(A::Error::duplicate_field(
4260                                    "multiple values for hours",
4261                                ));
4262                            }
4263                            struct __With(std::option::Option<i32>);
4264                            impl<'de> serde::de::Deserialize<'de> for __With {
4265                                fn deserialize<D>(
4266                                    deserializer: D,
4267                                ) -> std::result::Result<Self, D::Error>
4268                                where
4269                                    D: serde::de::Deserializer<'de>,
4270                                {
4271                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
4272                                }
4273                            }
4274                            result.hours = map.next_value::<__With>()?.0.unwrap_or_default();
4275                        }
4276                        __FieldTag::__minutes => {
4277                            if !fields.insert(__FieldTag::__minutes) {
4278                                return std::result::Result::Err(A::Error::duplicate_field(
4279                                    "multiple values for minutes",
4280                                ));
4281                            }
4282                            struct __With(std::option::Option<i32>);
4283                            impl<'de> serde::de::Deserialize<'de> for __With {
4284                                fn deserialize<D>(
4285                                    deserializer: D,
4286                                ) -> std::result::Result<Self, D::Error>
4287                                where
4288                                    D: serde::de::Deserializer<'de>,
4289                                {
4290                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
4291                                }
4292                            }
4293                            result.minutes = map.next_value::<__With>()?.0.unwrap_or_default();
4294                        }
4295                        __FieldTag::__seconds => {
4296                            if !fields.insert(__FieldTag::__seconds) {
4297                                return std::result::Result::Err(A::Error::duplicate_field(
4298                                    "multiple values for seconds",
4299                                ));
4300                            }
4301                            struct __With(std::option::Option<i32>);
4302                            impl<'de> serde::de::Deserialize<'de> for __With {
4303                                fn deserialize<D>(
4304                                    deserializer: D,
4305                                ) -> std::result::Result<Self, D::Error>
4306                                where
4307                                    D: serde::de::Deserializer<'de>,
4308                                {
4309                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
4310                                }
4311                            }
4312                            result.seconds = map.next_value::<__With>()?.0.unwrap_or_default();
4313                        }
4314                        __FieldTag::__nanos => {
4315                            if !fields.insert(__FieldTag::__nanos) {
4316                                return std::result::Result::Err(A::Error::duplicate_field(
4317                                    "multiple values for nanos",
4318                                ));
4319                            }
4320                            struct __With(std::option::Option<i32>);
4321                            impl<'de> serde::de::Deserialize<'de> for __With {
4322                                fn deserialize<D>(
4323                                    deserializer: D,
4324                                ) -> std::result::Result<Self, D::Error>
4325                                where
4326                                    D: serde::de::Deserializer<'de>,
4327                                {
4328                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
4329                                }
4330                            }
4331                            result.nanos = map.next_value::<__With>()?.0.unwrap_or_default();
4332                        }
4333                        __FieldTag::Unknown(key) => {
4334                            let value = map.next_value::<serde_json::Value>()?;
4335                            result._unknown_fields.insert(key, value);
4336                        }
4337                    }
4338                }
4339                std::result::Result::Ok(result)
4340            }
4341        }
4342        deserializer.deserialize_any(Visitor)
4343    }
4344}
4345
4346#[doc(hidden)]
4347impl serde::ser::Serialize for TimeOfDay {
4348    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4349    where
4350        S: serde::ser::Serializer,
4351    {
4352        use serde::ser::SerializeMap;
4353        #[allow(unused_imports)]
4354        use std::option::Option::Some;
4355        let mut state = serializer.serialize_map(std::option::Option::None)?;
4356        if !wkt::internal::is_default(&self.hours) {
4357            struct __With<'a>(&'a i32);
4358            impl<'a> serde::ser::Serialize for __With<'a> {
4359                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4360                where
4361                    S: serde::ser::Serializer,
4362                {
4363                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
4364                }
4365            }
4366            state.serialize_entry("hours", &__With(&self.hours))?;
4367        }
4368        if !wkt::internal::is_default(&self.minutes) {
4369            struct __With<'a>(&'a i32);
4370            impl<'a> serde::ser::Serialize for __With<'a> {
4371                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4372                where
4373                    S: serde::ser::Serializer,
4374                {
4375                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
4376                }
4377            }
4378            state.serialize_entry("minutes", &__With(&self.minutes))?;
4379        }
4380        if !wkt::internal::is_default(&self.seconds) {
4381            struct __With<'a>(&'a i32);
4382            impl<'a> serde::ser::Serialize for __With<'a> {
4383                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4384                where
4385                    S: serde::ser::Serializer,
4386                {
4387                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
4388                }
4389            }
4390            state.serialize_entry("seconds", &__With(&self.seconds))?;
4391        }
4392        if !wkt::internal::is_default(&self.nanos) {
4393            struct __With<'a>(&'a i32);
4394            impl<'a> serde::ser::Serialize for __With<'a> {
4395                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4396                where
4397                    S: serde::ser::Serializer,
4398                {
4399                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
4400                }
4401            }
4402            state.serialize_entry("nanos", &__With(&self.nanos))?;
4403        }
4404        if !self._unknown_fields.is_empty() {
4405            for (key, value) in self._unknown_fields.iter() {
4406                state.serialize_entry(key, &value)?;
4407            }
4408        }
4409        state.end()
4410    }
4411}
4412
4413/// A `CalendarPeriod` represents the abstract concept of a time period that has
4414/// a canonical start. Grammatically, "the start of the current
4415/// `CalendarPeriod`." All calendar times begin at midnight UTC.
4416///
4417/// # Working with unknown values
4418///
4419/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4420/// additional enum variants at any time. Adding new variants is not considered
4421/// a breaking change. Applications should write their code in anticipation of:
4422///
4423/// - New values appearing in future releases of the client library, **and**
4424/// - New values received dynamically, without application changes.
4425///
4426/// Please consult the [Working with enums] section in the user guide for some
4427/// guidelines.
4428///
4429/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4430#[derive(Clone, Debug, PartialEq)]
4431#[non_exhaustive]
4432pub enum CalendarPeriod {
4433    /// Undefined period, raises an error.
4434    Unspecified,
4435    /// A day.
4436    Day,
4437    /// A week. Weeks begin on Monday, following
4438    /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
4439    Week,
4440    /// A fortnight. The first calendar fortnight of the year begins at the start
4441    /// of week 1 according to
4442    /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
4443    Fortnight,
4444    /// A month.
4445    Month,
4446    /// A quarter. Quarters start on dates 1-Jan, 1-Apr, 1-Jul, and 1-Oct of each
4447    /// year.
4448    Quarter,
4449    /// A half-year. Half-years start on dates 1-Jan and 1-Jul.
4450    Half,
4451    /// A year.
4452    Year,
4453    /// If set, the enum was initialized with an unknown value.
4454    ///
4455    /// Applications can examine the value using [CalendarPeriod::value] or
4456    /// [CalendarPeriod::name].
4457    UnknownValue(calendar_period::UnknownValue),
4458}
4459
4460#[doc(hidden)]
4461pub mod calendar_period {
4462    #[allow(unused_imports)]
4463    use super::*;
4464    #[derive(Clone, Debug, PartialEq)]
4465    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4466}
4467
4468impl CalendarPeriod {
4469    /// Gets the enum value.
4470    ///
4471    /// Returns `None` if the enum contains an unknown value deserialized from
4472    /// the string representation of enums.
4473    pub fn value(&self) -> std::option::Option<i32> {
4474        match self {
4475            Self::Unspecified => std::option::Option::Some(0),
4476            Self::Day => std::option::Option::Some(1),
4477            Self::Week => std::option::Option::Some(2),
4478            Self::Fortnight => std::option::Option::Some(3),
4479            Self::Month => std::option::Option::Some(4),
4480            Self::Quarter => std::option::Option::Some(5),
4481            Self::Half => std::option::Option::Some(6),
4482            Self::Year => std::option::Option::Some(7),
4483            Self::UnknownValue(u) => u.0.value(),
4484        }
4485    }
4486
4487    /// Gets the enum value as a string.
4488    ///
4489    /// Returns `None` if the enum contains an unknown value deserialized from
4490    /// the integer representation of enums.
4491    pub fn name(&self) -> std::option::Option<&str> {
4492        match self {
4493            Self::Unspecified => std::option::Option::Some("CALENDAR_PERIOD_UNSPECIFIED"),
4494            Self::Day => std::option::Option::Some("DAY"),
4495            Self::Week => std::option::Option::Some("WEEK"),
4496            Self::Fortnight => std::option::Option::Some("FORTNIGHT"),
4497            Self::Month => std::option::Option::Some("MONTH"),
4498            Self::Quarter => std::option::Option::Some("QUARTER"),
4499            Self::Half => std::option::Option::Some("HALF"),
4500            Self::Year => std::option::Option::Some("YEAR"),
4501            Self::UnknownValue(u) => u.0.name(),
4502        }
4503    }
4504}
4505
4506impl std::default::Default for CalendarPeriod {
4507    fn default() -> Self {
4508        use std::convert::From;
4509        Self::from(0)
4510    }
4511}
4512
4513impl std::fmt::Display for CalendarPeriod {
4514    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4515        wkt::internal::display_enum(f, self.name(), self.value())
4516    }
4517}
4518
4519impl std::convert::From<i32> for CalendarPeriod {
4520    fn from(value: i32) -> Self {
4521        match value {
4522            0 => Self::Unspecified,
4523            1 => Self::Day,
4524            2 => Self::Week,
4525            3 => Self::Fortnight,
4526            4 => Self::Month,
4527            5 => Self::Quarter,
4528            6 => Self::Half,
4529            7 => Self::Year,
4530            _ => Self::UnknownValue(calendar_period::UnknownValue(
4531                wkt::internal::UnknownEnumValue::Integer(value),
4532            )),
4533        }
4534    }
4535}
4536
4537impl std::convert::From<&str> for CalendarPeriod {
4538    fn from(value: &str) -> Self {
4539        use std::string::ToString;
4540        match value {
4541            "CALENDAR_PERIOD_UNSPECIFIED" => Self::Unspecified,
4542            "DAY" => Self::Day,
4543            "WEEK" => Self::Week,
4544            "FORTNIGHT" => Self::Fortnight,
4545            "MONTH" => Self::Month,
4546            "QUARTER" => Self::Quarter,
4547            "HALF" => Self::Half,
4548            "YEAR" => Self::Year,
4549            _ => Self::UnknownValue(calendar_period::UnknownValue(
4550                wkt::internal::UnknownEnumValue::String(value.to_string()),
4551            )),
4552        }
4553    }
4554}
4555
4556impl serde::ser::Serialize for CalendarPeriod {
4557    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4558    where
4559        S: serde::Serializer,
4560    {
4561        match self {
4562            Self::Unspecified => serializer.serialize_i32(0),
4563            Self::Day => serializer.serialize_i32(1),
4564            Self::Week => serializer.serialize_i32(2),
4565            Self::Fortnight => serializer.serialize_i32(3),
4566            Self::Month => serializer.serialize_i32(4),
4567            Self::Quarter => serializer.serialize_i32(5),
4568            Self::Half => serializer.serialize_i32(6),
4569            Self::Year => serializer.serialize_i32(7),
4570            Self::UnknownValue(u) => u.0.serialize(serializer),
4571        }
4572    }
4573}
4574
4575impl<'de> serde::de::Deserialize<'de> for CalendarPeriod {
4576    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4577    where
4578        D: serde::Deserializer<'de>,
4579    {
4580        deserializer.deserialize_any(wkt::internal::EnumVisitor::<CalendarPeriod>::new(
4581            ".google.type.CalendarPeriod",
4582        ))
4583    }
4584}
4585
4586/// Represents a day of the week.
4587///
4588/// # Working with unknown values
4589///
4590/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4591/// additional enum variants at any time. Adding new variants is not considered
4592/// a breaking change. Applications should write their code in anticipation of:
4593///
4594/// - New values appearing in future releases of the client library, **and**
4595/// - New values received dynamically, without application changes.
4596///
4597/// Please consult the [Working with enums] section in the user guide for some
4598/// guidelines.
4599///
4600/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4601#[derive(Clone, Debug, PartialEq)]
4602#[non_exhaustive]
4603pub enum DayOfWeek {
4604    /// The day of the week is unspecified.
4605    Unspecified,
4606    /// Monday
4607    Monday,
4608    /// Tuesday
4609    Tuesday,
4610    /// Wednesday
4611    Wednesday,
4612    /// Thursday
4613    Thursday,
4614    /// Friday
4615    Friday,
4616    /// Saturday
4617    Saturday,
4618    /// Sunday
4619    Sunday,
4620    /// If set, the enum was initialized with an unknown value.
4621    ///
4622    /// Applications can examine the value using [DayOfWeek::value] or
4623    /// [DayOfWeek::name].
4624    UnknownValue(day_of_week::UnknownValue),
4625}
4626
4627#[doc(hidden)]
4628pub mod day_of_week {
4629    #[allow(unused_imports)]
4630    use super::*;
4631    #[derive(Clone, Debug, PartialEq)]
4632    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4633}
4634
4635impl DayOfWeek {
4636    /// Gets the enum value.
4637    ///
4638    /// Returns `None` if the enum contains an unknown value deserialized from
4639    /// the string representation of enums.
4640    pub fn value(&self) -> std::option::Option<i32> {
4641        match self {
4642            Self::Unspecified => std::option::Option::Some(0),
4643            Self::Monday => std::option::Option::Some(1),
4644            Self::Tuesday => std::option::Option::Some(2),
4645            Self::Wednesday => std::option::Option::Some(3),
4646            Self::Thursday => std::option::Option::Some(4),
4647            Self::Friday => std::option::Option::Some(5),
4648            Self::Saturday => std::option::Option::Some(6),
4649            Self::Sunday => std::option::Option::Some(7),
4650            Self::UnknownValue(u) => u.0.value(),
4651        }
4652    }
4653
4654    /// Gets the enum value as a string.
4655    ///
4656    /// Returns `None` if the enum contains an unknown value deserialized from
4657    /// the integer representation of enums.
4658    pub fn name(&self) -> std::option::Option<&str> {
4659        match self {
4660            Self::Unspecified => std::option::Option::Some("DAY_OF_WEEK_UNSPECIFIED"),
4661            Self::Monday => std::option::Option::Some("MONDAY"),
4662            Self::Tuesday => std::option::Option::Some("TUESDAY"),
4663            Self::Wednesday => std::option::Option::Some("WEDNESDAY"),
4664            Self::Thursday => std::option::Option::Some("THURSDAY"),
4665            Self::Friday => std::option::Option::Some("FRIDAY"),
4666            Self::Saturday => std::option::Option::Some("SATURDAY"),
4667            Self::Sunday => std::option::Option::Some("SUNDAY"),
4668            Self::UnknownValue(u) => u.0.name(),
4669        }
4670    }
4671}
4672
4673impl std::default::Default for DayOfWeek {
4674    fn default() -> Self {
4675        use std::convert::From;
4676        Self::from(0)
4677    }
4678}
4679
4680impl std::fmt::Display for DayOfWeek {
4681    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4682        wkt::internal::display_enum(f, self.name(), self.value())
4683    }
4684}
4685
4686impl std::convert::From<i32> for DayOfWeek {
4687    fn from(value: i32) -> Self {
4688        match value {
4689            0 => Self::Unspecified,
4690            1 => Self::Monday,
4691            2 => Self::Tuesday,
4692            3 => Self::Wednesday,
4693            4 => Self::Thursday,
4694            5 => Self::Friday,
4695            6 => Self::Saturday,
4696            7 => Self::Sunday,
4697            _ => Self::UnknownValue(day_of_week::UnknownValue(
4698                wkt::internal::UnknownEnumValue::Integer(value),
4699            )),
4700        }
4701    }
4702}
4703
4704impl std::convert::From<&str> for DayOfWeek {
4705    fn from(value: &str) -> Self {
4706        use std::string::ToString;
4707        match value {
4708            "DAY_OF_WEEK_UNSPECIFIED" => Self::Unspecified,
4709            "MONDAY" => Self::Monday,
4710            "TUESDAY" => Self::Tuesday,
4711            "WEDNESDAY" => Self::Wednesday,
4712            "THURSDAY" => Self::Thursday,
4713            "FRIDAY" => Self::Friday,
4714            "SATURDAY" => Self::Saturday,
4715            "SUNDAY" => Self::Sunday,
4716            _ => Self::UnknownValue(day_of_week::UnknownValue(
4717                wkt::internal::UnknownEnumValue::String(value.to_string()),
4718            )),
4719        }
4720    }
4721}
4722
4723impl serde::ser::Serialize for DayOfWeek {
4724    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4725    where
4726        S: serde::Serializer,
4727    {
4728        match self {
4729            Self::Unspecified => serializer.serialize_i32(0),
4730            Self::Monday => serializer.serialize_i32(1),
4731            Self::Tuesday => serializer.serialize_i32(2),
4732            Self::Wednesday => serializer.serialize_i32(3),
4733            Self::Thursday => serializer.serialize_i32(4),
4734            Self::Friday => serializer.serialize_i32(5),
4735            Self::Saturday => serializer.serialize_i32(6),
4736            Self::Sunday => serializer.serialize_i32(7),
4737            Self::UnknownValue(u) => u.0.serialize(serializer),
4738        }
4739    }
4740}
4741
4742impl<'de> serde::de::Deserialize<'de> for DayOfWeek {
4743    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4744    where
4745        D: serde::Deserializer<'de>,
4746    {
4747        deserializer.deserialize_any(wkt::internal::EnumVisitor::<DayOfWeek>::new(
4748            ".google.type.DayOfWeek",
4749        ))
4750    }
4751}
4752
4753/// Represents a month in the Gregorian calendar.
4754///
4755/// # Working with unknown values
4756///
4757/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4758/// additional enum variants at any time. Adding new variants is not considered
4759/// a breaking change. Applications should write their code in anticipation of:
4760///
4761/// - New values appearing in future releases of the client library, **and**
4762/// - New values received dynamically, without application changes.
4763///
4764/// Please consult the [Working with enums] section in the user guide for some
4765/// guidelines.
4766///
4767/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4768#[derive(Clone, Debug, PartialEq)]
4769#[non_exhaustive]
4770pub enum Month {
4771    /// The unspecified month.
4772    Unspecified,
4773    /// The month of January.
4774    January,
4775    /// The month of February.
4776    February,
4777    /// The month of March.
4778    March,
4779    /// The month of April.
4780    April,
4781    /// The month of May.
4782    May,
4783    /// The month of June.
4784    June,
4785    /// The month of July.
4786    July,
4787    /// The month of August.
4788    August,
4789    /// The month of September.
4790    September,
4791    /// The month of October.
4792    October,
4793    /// The month of November.
4794    November,
4795    /// The month of December.
4796    December,
4797    /// If set, the enum was initialized with an unknown value.
4798    ///
4799    /// Applications can examine the value using [Month::value] or
4800    /// [Month::name].
4801    UnknownValue(month::UnknownValue),
4802}
4803
4804#[doc(hidden)]
4805pub mod month {
4806    #[allow(unused_imports)]
4807    use super::*;
4808    #[derive(Clone, Debug, PartialEq)]
4809    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4810}
4811
4812impl Month {
4813    /// Gets the enum value.
4814    ///
4815    /// Returns `None` if the enum contains an unknown value deserialized from
4816    /// the string representation of enums.
4817    pub fn value(&self) -> std::option::Option<i32> {
4818        match self {
4819            Self::Unspecified => std::option::Option::Some(0),
4820            Self::January => std::option::Option::Some(1),
4821            Self::February => std::option::Option::Some(2),
4822            Self::March => std::option::Option::Some(3),
4823            Self::April => std::option::Option::Some(4),
4824            Self::May => std::option::Option::Some(5),
4825            Self::June => std::option::Option::Some(6),
4826            Self::July => std::option::Option::Some(7),
4827            Self::August => std::option::Option::Some(8),
4828            Self::September => std::option::Option::Some(9),
4829            Self::October => std::option::Option::Some(10),
4830            Self::November => std::option::Option::Some(11),
4831            Self::December => std::option::Option::Some(12),
4832            Self::UnknownValue(u) => u.0.value(),
4833        }
4834    }
4835
4836    /// Gets the enum value as a string.
4837    ///
4838    /// Returns `None` if the enum contains an unknown value deserialized from
4839    /// the integer representation of enums.
4840    pub fn name(&self) -> std::option::Option<&str> {
4841        match self {
4842            Self::Unspecified => std::option::Option::Some("MONTH_UNSPECIFIED"),
4843            Self::January => std::option::Option::Some("JANUARY"),
4844            Self::February => std::option::Option::Some("FEBRUARY"),
4845            Self::March => std::option::Option::Some("MARCH"),
4846            Self::April => std::option::Option::Some("APRIL"),
4847            Self::May => std::option::Option::Some("MAY"),
4848            Self::June => std::option::Option::Some("JUNE"),
4849            Self::July => std::option::Option::Some("JULY"),
4850            Self::August => std::option::Option::Some("AUGUST"),
4851            Self::September => std::option::Option::Some("SEPTEMBER"),
4852            Self::October => std::option::Option::Some("OCTOBER"),
4853            Self::November => std::option::Option::Some("NOVEMBER"),
4854            Self::December => std::option::Option::Some("DECEMBER"),
4855            Self::UnknownValue(u) => u.0.name(),
4856        }
4857    }
4858}
4859
4860impl std::default::Default for Month {
4861    fn default() -> Self {
4862        use std::convert::From;
4863        Self::from(0)
4864    }
4865}
4866
4867impl std::fmt::Display for Month {
4868    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4869        wkt::internal::display_enum(f, self.name(), self.value())
4870    }
4871}
4872
4873impl std::convert::From<i32> for Month {
4874    fn from(value: i32) -> Self {
4875        match value {
4876            0 => Self::Unspecified,
4877            1 => Self::January,
4878            2 => Self::February,
4879            3 => Self::March,
4880            4 => Self::April,
4881            5 => Self::May,
4882            6 => Self::June,
4883            7 => Self::July,
4884            8 => Self::August,
4885            9 => Self::September,
4886            10 => Self::October,
4887            11 => Self::November,
4888            12 => Self::December,
4889            _ => Self::UnknownValue(month::UnknownValue(
4890                wkt::internal::UnknownEnumValue::Integer(value),
4891            )),
4892        }
4893    }
4894}
4895
4896impl std::convert::From<&str> for Month {
4897    fn from(value: &str) -> Self {
4898        use std::string::ToString;
4899        match value {
4900            "MONTH_UNSPECIFIED" => Self::Unspecified,
4901            "JANUARY" => Self::January,
4902            "FEBRUARY" => Self::February,
4903            "MARCH" => Self::March,
4904            "APRIL" => Self::April,
4905            "MAY" => Self::May,
4906            "JUNE" => Self::June,
4907            "JULY" => Self::July,
4908            "AUGUST" => Self::August,
4909            "SEPTEMBER" => Self::September,
4910            "OCTOBER" => Self::October,
4911            "NOVEMBER" => Self::November,
4912            "DECEMBER" => Self::December,
4913            _ => Self::UnknownValue(month::UnknownValue(
4914                wkt::internal::UnknownEnumValue::String(value.to_string()),
4915            )),
4916        }
4917    }
4918}
4919
4920impl serde::ser::Serialize for Month {
4921    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4922    where
4923        S: serde::Serializer,
4924    {
4925        match self {
4926            Self::Unspecified => serializer.serialize_i32(0),
4927            Self::January => serializer.serialize_i32(1),
4928            Self::February => serializer.serialize_i32(2),
4929            Self::March => serializer.serialize_i32(3),
4930            Self::April => serializer.serialize_i32(4),
4931            Self::May => serializer.serialize_i32(5),
4932            Self::June => serializer.serialize_i32(6),
4933            Self::July => serializer.serialize_i32(7),
4934            Self::August => serializer.serialize_i32(8),
4935            Self::September => serializer.serialize_i32(9),
4936            Self::October => serializer.serialize_i32(10),
4937            Self::November => serializer.serialize_i32(11),
4938            Self::December => serializer.serialize_i32(12),
4939            Self::UnknownValue(u) => u.0.serialize(serializer),
4940        }
4941    }
4942}
4943
4944impl<'de> serde::de::Deserialize<'de> for Month {
4945    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4946    where
4947        D: serde::Deserializer<'de>,
4948    {
4949        deserializer.deserialize_any(wkt::internal::EnumVisitor::<Month>::new(
4950            ".google.type.Month",
4951        ))
4952    }
4953}