google_cloud_wkt/generated/
mod.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::invalid_html_tags)]
18#![allow(rustdoc::redundant_explicit_links)]
19use crate as wkt;
20
21/// Api is a light-weight descriptor for an API Interface.
22///
23/// Interfaces are also described as "protocol buffer services" in some contexts,
24/// such as by the "service" keyword in a .proto file, but they are different
25/// from API Services, which represent a concrete implementation of an interface
26/// as opposed to simply a description of methods and bindings. They are also
27/// sometimes simply referred to as "APIs" in other contexts, such as the name of
28/// this message itself. See <https://cloud.google.com/apis/design/glossary> for
29/// detailed terminology.
30#[serde_with::serde_as]
31#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
32#[serde(default, rename_all = "camelCase")]
33#[non_exhaustive]
34pub struct Api {
35    /// The fully qualified name of this interface, including package name
36    /// followed by the interface's simple name.
37    #[serde(skip_serializing_if = "std::string::String::is_empty")]
38    pub name: std::string::String,
39
40    /// The methods of this interface, in unspecified order.
41    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
42    pub methods: std::vec::Vec<crate::Method>,
43
44    /// Any metadata attached to the interface.
45    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
46    pub options: std::vec::Vec<crate::Option>,
47
48    /// A version string for this interface. If specified, must have the form
49    /// `major-version.minor-version`, as in `1.10`. If the minor version is
50    /// omitted, it defaults to zero. If the entire version field is empty, the
51    /// major version is derived from the package name, as outlined below. If the
52    /// field is not empty, the version in the package name will be verified to be
53    /// consistent with what is provided here.
54    ///
55    /// The versioning schema uses [semantic
56    /// versioning](http://semver.org) where the major version number
57    /// indicates a breaking change and the minor version an additive,
58    /// non-breaking change. Both version numbers are signals to users
59    /// what to expect from different versions, and should be carefully
60    /// chosen based on the product plan.
61    ///
62    /// The major version is also reflected in the package name of the
63    /// interface, which must end in `v<major-version>`, as in
64    /// `google.feature.v1`. For major versions 0 and 1, the suffix can
65    /// be omitted. Zero major versions must only be used for
66    /// experimental, non-GA interfaces.
67    #[serde(skip_serializing_if = "std::string::String::is_empty")]
68    pub version: std::string::String,
69
70    /// Source context for the protocol buffer service represented by this
71    /// message.
72    #[serde(skip_serializing_if = "std::option::Option::is_none")]
73    pub source_context: std::option::Option<crate::SourceContext>,
74
75    /// Included interfaces. See [Mixin][].
76    ///
77    /// [Mixin]: crate::Mixin
78    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
79    pub mixins: std::vec::Vec<crate::Mixin>,
80
81    /// The source syntax of the service.
82    pub syntax: crate::Syntax,
83}
84
85impl Api {
86    pub fn new() -> Self {
87        std::default::Default::default()
88    }
89
90    /// Sets the value of [name][crate::Api::name].
91    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
92        self.name = v.into();
93        self
94    }
95
96    /// Sets the value of [version][crate::Api::version].
97    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
98        self.version = v.into();
99        self
100    }
101
102    /// Sets the value of [source_context][crate::Api::source_context].
103    pub fn set_source_context<T: std::convert::Into<std::option::Option<crate::SourceContext>>>(
104        mut self,
105        v: T,
106    ) -> Self {
107        self.source_context = v.into();
108        self
109    }
110
111    /// Sets the value of [syntax][crate::Api::syntax].
112    pub fn set_syntax<T: std::convert::Into<crate::Syntax>>(mut self, v: T) -> Self {
113        self.syntax = v.into();
114        self
115    }
116
117    /// Sets the value of [methods][crate::Api::methods].
118    pub fn set_methods<T, V>(mut self, v: T) -> Self
119    where
120        T: std::iter::IntoIterator<Item = V>,
121        V: std::convert::Into<crate::Method>,
122    {
123        use std::iter::Iterator;
124        self.methods = v.into_iter().map(|i| i.into()).collect();
125        self
126    }
127
128    /// Sets the value of [options][crate::Api::options].
129    pub fn set_options<T, V>(mut self, v: T) -> Self
130    where
131        T: std::iter::IntoIterator<Item = V>,
132        V: std::convert::Into<crate::Option>,
133    {
134        use std::iter::Iterator;
135        self.options = v.into_iter().map(|i| i.into()).collect();
136        self
137    }
138
139    /// Sets the value of [mixins][crate::Api::mixins].
140    pub fn set_mixins<T, V>(mut self, v: T) -> Self
141    where
142        T: std::iter::IntoIterator<Item = V>,
143        V: std::convert::Into<crate::Mixin>,
144    {
145        use std::iter::Iterator;
146        self.mixins = v.into_iter().map(|i| i.into()).collect();
147        self
148    }
149}
150
151impl wkt::message::Message for Api {
152    fn typename() -> &'static str {
153        "type.googleapis.com/google.protobuf.Api"
154    }
155}
156
157/// Method represents a method of an API interface.
158#[serde_with::serde_as]
159#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
160#[serde(default, rename_all = "camelCase")]
161#[non_exhaustive]
162pub struct Method {
163    /// The simple name of this method.
164    #[serde(skip_serializing_if = "std::string::String::is_empty")]
165    pub name: std::string::String,
166
167    /// A URL of the input message type.
168    #[serde(skip_serializing_if = "std::string::String::is_empty")]
169    pub request_type_url: std::string::String,
170
171    /// If true, the request is streamed.
172    pub request_streaming: bool,
173
174    /// The URL of the output message type.
175    #[serde(skip_serializing_if = "std::string::String::is_empty")]
176    pub response_type_url: std::string::String,
177
178    /// If true, the response is streamed.
179    pub response_streaming: bool,
180
181    /// Any metadata attached to the method.
182    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
183    pub options: std::vec::Vec<crate::Option>,
184
185    /// The source syntax of this method.
186    pub syntax: crate::Syntax,
187}
188
189impl Method {
190    pub fn new() -> Self {
191        std::default::Default::default()
192    }
193
194    /// Sets the value of [name][crate::Method::name].
195    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
196        self.name = v.into();
197        self
198    }
199
200    /// Sets the value of [request_type_url][crate::Method::request_type_url].
201    pub fn set_request_type_url<T: std::convert::Into<std::string::String>>(
202        mut self,
203        v: T,
204    ) -> Self {
205        self.request_type_url = v.into();
206        self
207    }
208
209    /// Sets the value of [request_streaming][crate::Method::request_streaming].
210    pub fn set_request_streaming<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
211        self.request_streaming = v.into();
212        self
213    }
214
215    /// Sets the value of [response_type_url][crate::Method::response_type_url].
216    pub fn set_response_type_url<T: std::convert::Into<std::string::String>>(
217        mut self,
218        v: T,
219    ) -> Self {
220        self.response_type_url = v.into();
221        self
222    }
223
224    /// Sets the value of [response_streaming][crate::Method::response_streaming].
225    pub fn set_response_streaming<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
226        self.response_streaming = v.into();
227        self
228    }
229
230    /// Sets the value of [syntax][crate::Method::syntax].
231    pub fn set_syntax<T: std::convert::Into<crate::Syntax>>(mut self, v: T) -> Self {
232        self.syntax = v.into();
233        self
234    }
235
236    /// Sets the value of [options][crate::Method::options].
237    pub fn set_options<T, V>(mut self, v: T) -> Self
238    where
239        T: std::iter::IntoIterator<Item = V>,
240        V: std::convert::Into<crate::Option>,
241    {
242        use std::iter::Iterator;
243        self.options = v.into_iter().map(|i| i.into()).collect();
244        self
245    }
246}
247
248impl wkt::message::Message for Method {
249    fn typename() -> &'static str {
250        "type.googleapis.com/google.protobuf.Method"
251    }
252}
253
254/// Declares an API Interface to be included in this interface. The including
255/// interface must redeclare all the methods from the included interface, but
256/// documentation and options are inherited as follows:
257///
258/// - If after comment and whitespace stripping, the documentation
259///   string of the redeclared method is empty, it will be inherited
260///   from the original method.
261///
262/// - Each annotation belonging to the service config (http,
263///   visibility) which is not set in the redeclared method will be
264///   inherited.
265///
266/// - If an http annotation is inherited, the path pattern will be
267///   modified as follows. Any version prefix will be replaced by the
268///   version of the including interface plus the [root][] path if
269///   specified.
270///
271///
272/// Example of a simple mixin:
273///
274/// ```norust
275/// package google.acl.v1;
276/// service AccessControl {
277///   // Get the underlying ACL object.
278///   rpc GetAcl(GetAclRequest) returns (Acl) {
279///     option (google.api.http).get = "/v1/{resource=**}:getAcl";
280///   }
281/// }
282///
283/// package google.storage.v2;
284/// service Storage {
285///   rpc GetAcl(GetAclRequest) returns (Acl);
286///
287///   // Get a data record.
288///   rpc GetData(GetDataRequest) returns (Data) {
289///     option (google.api.http).get = "/v2/{resource=**}";
290///   }
291/// }
292/// ```
293///
294/// Example of a mixin configuration:
295///
296/// ```norust
297/// apis:
298/// - name: google.storage.v2.Storage
299///   mixins:
300///   - name: google.acl.v1.AccessControl
301/// ```
302///
303/// The mixin construct implies that all methods in `AccessControl` are
304/// also declared with same name and request/response types in
305/// `Storage`. A documentation generator or annotation processor will
306/// see the effective `Storage.GetAcl` method after inheriting
307/// documentation and annotations as follows:
308///
309/// ```norust
310/// service Storage {
311///   // Get the underlying ACL object.
312///   rpc GetAcl(GetAclRequest) returns (Acl) {
313///     option (google.api.http).get = "/v2/{resource=**}:getAcl";
314///   }
315///   ...
316/// }
317/// ```
318///
319/// Note how the version in the path pattern changed from `v1` to `v2`.
320///
321/// If the `root` field in the mixin is specified, it should be a
322/// relative path under which inherited HTTP paths are placed. Example:
323///
324/// ```norust
325/// apis:
326/// - name: google.storage.v2.Storage
327///   mixins:
328///   - name: google.acl.v1.AccessControl
329///     root: acls
330/// ```
331///
332/// This implies the following inherited HTTP annotation:
333///
334/// ```norust
335/// service Storage {
336///   // Get the underlying ACL object.
337///   rpc GetAcl(GetAclRequest) returns (Acl) {
338///     option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
339///   }
340///   ...
341/// }
342/// ```
343///
344/// [root]: wkt::Mixin::root
345#[serde_with::serde_as]
346#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
347#[serde(default, rename_all = "camelCase")]
348#[non_exhaustive]
349pub struct Mixin {
350    /// The fully qualified name of the interface which is included.
351    #[serde(skip_serializing_if = "std::string::String::is_empty")]
352    pub name: std::string::String,
353
354    /// If non-empty specifies a path under which inherited HTTP paths
355    /// are rooted.
356    #[serde(skip_serializing_if = "std::string::String::is_empty")]
357    pub root: std::string::String,
358}
359
360impl Mixin {
361    pub fn new() -> Self {
362        std::default::Default::default()
363    }
364
365    /// Sets the value of [name][crate::Mixin::name].
366    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
367        self.name = v.into();
368        self
369    }
370
371    /// Sets the value of [root][crate::Mixin::root].
372    pub fn set_root<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
373        self.root = v.into();
374        self
375    }
376}
377
378impl wkt::message::Message for Mixin {
379    fn typename() -> &'static str {
380        "type.googleapis.com/google.protobuf.Mixin"
381    }
382}
383
384/// `SourceContext` represents information about the source of a
385/// protobuf element, like the file in which it is defined.
386#[serde_with::serde_as]
387#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
388#[serde(default, rename_all = "camelCase")]
389#[non_exhaustive]
390pub struct SourceContext {
391    /// The path-qualified name of the .proto file that contained the associated
392    /// protobuf element.  For example: `"google/protobuf/source_context.proto"`.
393    #[serde(skip_serializing_if = "std::string::String::is_empty")]
394    pub file_name: std::string::String,
395}
396
397impl SourceContext {
398    pub fn new() -> Self {
399        std::default::Default::default()
400    }
401
402    /// Sets the value of [file_name][crate::SourceContext::file_name].
403    pub fn set_file_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
404        self.file_name = v.into();
405        self
406    }
407}
408
409impl wkt::message::Message for SourceContext {
410    fn typename() -> &'static str {
411        "type.googleapis.com/google.protobuf.SourceContext"
412    }
413}
414
415/// A protocol buffer message type.
416#[serde_with::serde_as]
417#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
418#[serde(default, rename_all = "camelCase")]
419#[non_exhaustive]
420pub struct Type {
421    /// The fully qualified message name.
422    #[serde(skip_serializing_if = "std::string::String::is_empty")]
423    pub name: std::string::String,
424
425    /// The list of fields.
426    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
427    pub fields: std::vec::Vec<crate::Field>,
428
429    /// The list of types appearing in `oneof` definitions in this type.
430    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
431    pub oneofs: std::vec::Vec<std::string::String>,
432
433    /// The protocol buffer options.
434    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
435    pub options: std::vec::Vec<crate::Option>,
436
437    /// The source context.
438    #[serde(skip_serializing_if = "std::option::Option::is_none")]
439    pub source_context: std::option::Option<crate::SourceContext>,
440
441    /// The source syntax.
442    pub syntax: crate::Syntax,
443
444    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
445    #[serde(skip_serializing_if = "std::string::String::is_empty")]
446    pub edition: std::string::String,
447}
448
449impl Type {
450    pub fn new() -> Self {
451        std::default::Default::default()
452    }
453
454    /// Sets the value of [name][crate::Type::name].
455    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
456        self.name = v.into();
457        self
458    }
459
460    /// Sets the value of [source_context][crate::Type::source_context].
461    pub fn set_source_context<T: std::convert::Into<std::option::Option<crate::SourceContext>>>(
462        mut self,
463        v: T,
464    ) -> Self {
465        self.source_context = v.into();
466        self
467    }
468
469    /// Sets the value of [syntax][crate::Type::syntax].
470    pub fn set_syntax<T: std::convert::Into<crate::Syntax>>(mut self, v: T) -> Self {
471        self.syntax = v.into();
472        self
473    }
474
475    /// Sets the value of [edition][crate::Type::edition].
476    pub fn set_edition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
477        self.edition = v.into();
478        self
479    }
480
481    /// Sets the value of [fields][crate::Type::fields].
482    pub fn set_fields<T, V>(mut self, v: T) -> Self
483    where
484        T: std::iter::IntoIterator<Item = V>,
485        V: std::convert::Into<crate::Field>,
486    {
487        use std::iter::Iterator;
488        self.fields = v.into_iter().map(|i| i.into()).collect();
489        self
490    }
491
492    /// Sets the value of [oneofs][crate::Type::oneofs].
493    pub fn set_oneofs<T, V>(mut self, v: T) -> Self
494    where
495        T: std::iter::IntoIterator<Item = V>,
496        V: std::convert::Into<std::string::String>,
497    {
498        use std::iter::Iterator;
499        self.oneofs = v.into_iter().map(|i| i.into()).collect();
500        self
501    }
502
503    /// Sets the value of [options][crate::Type::options].
504    pub fn set_options<T, V>(mut self, v: T) -> Self
505    where
506        T: std::iter::IntoIterator<Item = V>,
507        V: std::convert::Into<crate::Option>,
508    {
509        use std::iter::Iterator;
510        self.options = v.into_iter().map(|i| i.into()).collect();
511        self
512    }
513}
514
515impl wkt::message::Message for Type {
516    fn typename() -> &'static str {
517        "type.googleapis.com/google.protobuf.Type"
518    }
519}
520
521/// A single field of a message type.
522#[serde_with::serde_as]
523#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
524#[serde(default, rename_all = "camelCase")]
525#[non_exhaustive]
526pub struct Field {
527    /// The field type.
528    pub kind: crate::field::Kind,
529
530    /// The field cardinality.
531    pub cardinality: crate::field::Cardinality,
532
533    /// The field number.
534    pub number: i32,
535
536    /// The field name.
537    #[serde(skip_serializing_if = "std::string::String::is_empty")]
538    pub name: std::string::String,
539
540    /// The field type URL, without the scheme, for message or enumeration
541    /// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
542    #[serde(skip_serializing_if = "std::string::String::is_empty")]
543    pub type_url: std::string::String,
544
545    /// The index of the field type in `Type.oneofs`, for message or enumeration
546    /// types. The first type has index 1; zero means the type is not in the list.
547    pub oneof_index: i32,
548
549    /// Whether to use alternative packed wire representation.
550    pub packed: bool,
551
552    /// The protocol buffer options.
553    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
554    pub options: std::vec::Vec<crate::Option>,
555
556    /// The field JSON name.
557    #[serde(skip_serializing_if = "std::string::String::is_empty")]
558    pub json_name: std::string::String,
559
560    /// The string value of the default value of this field. Proto2 syntax only.
561    #[serde(skip_serializing_if = "std::string::String::is_empty")]
562    pub default_value: std::string::String,
563}
564
565impl Field {
566    pub fn new() -> Self {
567        std::default::Default::default()
568    }
569
570    /// Sets the value of [kind][crate::Field::kind].
571    pub fn set_kind<T: std::convert::Into<crate::field::Kind>>(mut self, v: T) -> Self {
572        self.kind = v.into();
573        self
574    }
575
576    /// Sets the value of [cardinality][crate::Field::cardinality].
577    pub fn set_cardinality<T: std::convert::Into<crate::field::Cardinality>>(
578        mut self,
579        v: T,
580    ) -> Self {
581        self.cardinality = v.into();
582        self
583    }
584
585    /// Sets the value of [number][crate::Field::number].
586    pub fn set_number<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
587        self.number = v.into();
588        self
589    }
590
591    /// Sets the value of [name][crate::Field::name].
592    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
593        self.name = v.into();
594        self
595    }
596
597    /// Sets the value of [type_url][crate::Field::type_url].
598    pub fn set_type_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
599        self.type_url = v.into();
600        self
601    }
602
603    /// Sets the value of [oneof_index][crate::Field::oneof_index].
604    pub fn set_oneof_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
605        self.oneof_index = v.into();
606        self
607    }
608
609    /// Sets the value of [packed][crate::Field::packed].
610    pub fn set_packed<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
611        self.packed = v.into();
612        self
613    }
614
615    /// Sets the value of [json_name][crate::Field::json_name].
616    pub fn set_json_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
617        self.json_name = v.into();
618        self
619    }
620
621    /// Sets the value of [default_value][crate::Field::default_value].
622    pub fn set_default_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
623        self.default_value = v.into();
624        self
625    }
626
627    /// Sets the value of [options][crate::Field::options].
628    pub fn set_options<T, V>(mut self, v: T) -> Self
629    where
630        T: std::iter::IntoIterator<Item = V>,
631        V: std::convert::Into<crate::Option>,
632    {
633        use std::iter::Iterator;
634        self.options = v.into_iter().map(|i| i.into()).collect();
635        self
636    }
637}
638
639impl wkt::message::Message for Field {
640    fn typename() -> &'static str {
641        "type.googleapis.com/google.protobuf.Field"
642    }
643}
644
645/// Defines additional types related to Field
646pub mod field {
647    #[allow(unused_imports)]
648    use super::*;
649
650    /// Basic field types.
651    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
652    pub struct Kind(std::borrow::Cow<'static, str>);
653
654    impl Kind {
655        /// Creates a new Kind instance.
656        pub const fn new(v: &'static str) -> Self {
657            Self(std::borrow::Cow::Borrowed(v))
658        }
659
660        /// Gets the enum value.
661        pub fn value(&self) -> &str {
662            &self.0
663        }
664    }
665
666    /// Useful constants to work with [Kind](Kind)
667    pub mod kind {
668        use super::Kind;
669
670        /// Field type unknown.
671        pub const TYPE_UNKNOWN: Kind = Kind::new("TYPE_UNKNOWN");
672
673        /// Field type double.
674        pub const TYPE_DOUBLE: Kind = Kind::new("TYPE_DOUBLE");
675
676        /// Field type float.
677        pub const TYPE_FLOAT: Kind = Kind::new("TYPE_FLOAT");
678
679        /// Field type int64.
680        pub const TYPE_INT64: Kind = Kind::new("TYPE_INT64");
681
682        /// Field type uint64.
683        pub const TYPE_UINT64: Kind = Kind::new("TYPE_UINT64");
684
685        /// Field type int32.
686        pub const TYPE_INT32: Kind = Kind::new("TYPE_INT32");
687
688        /// Field type fixed64.
689        pub const TYPE_FIXED64: Kind = Kind::new("TYPE_FIXED64");
690
691        /// Field type fixed32.
692        pub const TYPE_FIXED32: Kind = Kind::new("TYPE_FIXED32");
693
694        /// Field type bool.
695        pub const TYPE_BOOL: Kind = Kind::new("TYPE_BOOL");
696
697        /// Field type string.
698        pub const TYPE_STRING: Kind = Kind::new("TYPE_STRING");
699
700        /// Field type group. Proto2 syntax only, and deprecated.
701        pub const TYPE_GROUP: Kind = Kind::new("TYPE_GROUP");
702
703        /// Field type message.
704        pub const TYPE_MESSAGE: Kind = Kind::new("TYPE_MESSAGE");
705
706        /// Field type bytes.
707        pub const TYPE_BYTES: Kind = Kind::new("TYPE_BYTES");
708
709        /// Field type uint32.
710        pub const TYPE_UINT32: Kind = Kind::new("TYPE_UINT32");
711
712        /// Field type enum.
713        pub const TYPE_ENUM: Kind = Kind::new("TYPE_ENUM");
714
715        /// Field type sfixed32.
716        pub const TYPE_SFIXED32: Kind = Kind::new("TYPE_SFIXED32");
717
718        /// Field type sfixed64.
719        pub const TYPE_SFIXED64: Kind = Kind::new("TYPE_SFIXED64");
720
721        /// Field type sint32.
722        pub const TYPE_SINT32: Kind = Kind::new("TYPE_SINT32");
723
724        /// Field type sint64.
725        pub const TYPE_SINT64: Kind = Kind::new("TYPE_SINT64");
726    }
727
728    impl std::convert::From<std::string::String> for Kind {
729        fn from(value: std::string::String) -> Self {
730            Self(std::borrow::Cow::Owned(value))
731        }
732    }
733
734    /// Whether a field is optional, required, or repeated.
735    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
736    pub struct Cardinality(std::borrow::Cow<'static, str>);
737
738    impl Cardinality {
739        /// Creates a new Cardinality instance.
740        pub const fn new(v: &'static str) -> Self {
741            Self(std::borrow::Cow::Borrowed(v))
742        }
743
744        /// Gets the enum value.
745        pub fn value(&self) -> &str {
746            &self.0
747        }
748    }
749
750    /// Useful constants to work with [Cardinality](Cardinality)
751    pub mod cardinality {
752        use super::Cardinality;
753
754        /// For fields with unknown cardinality.
755        pub const CARDINALITY_UNKNOWN: Cardinality = Cardinality::new("CARDINALITY_UNKNOWN");
756
757        /// For optional fields.
758        pub const CARDINALITY_OPTIONAL: Cardinality = Cardinality::new("CARDINALITY_OPTIONAL");
759
760        /// For required fields. Proto2 syntax only.
761        pub const CARDINALITY_REQUIRED: Cardinality = Cardinality::new("CARDINALITY_REQUIRED");
762
763        /// For repeated fields.
764        pub const CARDINALITY_REPEATED: Cardinality = Cardinality::new("CARDINALITY_REPEATED");
765    }
766
767    impl std::convert::From<std::string::String> for Cardinality {
768        fn from(value: std::string::String) -> Self {
769            Self(std::borrow::Cow::Owned(value))
770        }
771    }
772}
773
774/// Enum type definition.
775#[serde_with::serde_as]
776#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
777#[serde(default, rename_all = "camelCase")]
778#[non_exhaustive]
779pub struct Enum {
780    /// Enum type name.
781    #[serde(skip_serializing_if = "std::string::String::is_empty")]
782    pub name: std::string::String,
783
784    /// Enum value definitions.
785    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
786    pub enumvalue: std::vec::Vec<crate::EnumValue>,
787
788    /// Protocol buffer options.
789    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
790    pub options: std::vec::Vec<crate::Option>,
791
792    /// The source context.
793    #[serde(skip_serializing_if = "std::option::Option::is_none")]
794    pub source_context: std::option::Option<crate::SourceContext>,
795
796    /// The source syntax.
797    pub syntax: crate::Syntax,
798
799    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
800    #[serde(skip_serializing_if = "std::string::String::is_empty")]
801    pub edition: std::string::String,
802}
803
804impl Enum {
805    pub fn new() -> Self {
806        std::default::Default::default()
807    }
808
809    /// Sets the value of [name][crate::Enum::name].
810    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
811        self.name = v.into();
812        self
813    }
814
815    /// Sets the value of [source_context][crate::Enum::source_context].
816    pub fn set_source_context<T: std::convert::Into<std::option::Option<crate::SourceContext>>>(
817        mut self,
818        v: T,
819    ) -> Self {
820        self.source_context = v.into();
821        self
822    }
823
824    /// Sets the value of [syntax][crate::Enum::syntax].
825    pub fn set_syntax<T: std::convert::Into<crate::Syntax>>(mut self, v: T) -> Self {
826        self.syntax = v.into();
827        self
828    }
829
830    /// Sets the value of [edition][crate::Enum::edition].
831    pub fn set_edition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
832        self.edition = v.into();
833        self
834    }
835
836    /// Sets the value of [enumvalue][crate::Enum::enumvalue].
837    pub fn set_enumvalue<T, V>(mut self, v: T) -> Self
838    where
839        T: std::iter::IntoIterator<Item = V>,
840        V: std::convert::Into<crate::EnumValue>,
841    {
842        use std::iter::Iterator;
843        self.enumvalue = v.into_iter().map(|i| i.into()).collect();
844        self
845    }
846
847    /// Sets the value of [options][crate::Enum::options].
848    pub fn set_options<T, V>(mut self, v: T) -> Self
849    where
850        T: std::iter::IntoIterator<Item = V>,
851        V: std::convert::Into<crate::Option>,
852    {
853        use std::iter::Iterator;
854        self.options = v.into_iter().map(|i| i.into()).collect();
855        self
856    }
857}
858
859impl wkt::message::Message for Enum {
860    fn typename() -> &'static str {
861        "type.googleapis.com/google.protobuf.Enum"
862    }
863}
864
865/// Enum value definition.
866#[serde_with::serde_as]
867#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
868#[serde(default, rename_all = "camelCase")]
869#[non_exhaustive]
870pub struct EnumValue {
871    /// Enum value name.
872    #[serde(skip_serializing_if = "std::string::String::is_empty")]
873    pub name: std::string::String,
874
875    /// Enum value number.
876    pub number: i32,
877
878    /// Protocol buffer options.
879    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
880    pub options: std::vec::Vec<crate::Option>,
881}
882
883impl EnumValue {
884    pub fn new() -> Self {
885        std::default::Default::default()
886    }
887
888    /// Sets the value of [name][crate::EnumValue::name].
889    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
890        self.name = v.into();
891        self
892    }
893
894    /// Sets the value of [number][crate::EnumValue::number].
895    pub fn set_number<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
896        self.number = v.into();
897        self
898    }
899
900    /// Sets the value of [options][crate::EnumValue::options].
901    pub fn set_options<T, V>(mut self, v: T) -> Self
902    where
903        T: std::iter::IntoIterator<Item = V>,
904        V: std::convert::Into<crate::Option>,
905    {
906        use std::iter::Iterator;
907        self.options = v.into_iter().map(|i| i.into()).collect();
908        self
909    }
910}
911
912impl wkt::message::Message for EnumValue {
913    fn typename() -> &'static str {
914        "type.googleapis.com/google.protobuf.EnumValue"
915    }
916}
917
918/// A protocol buffer option, which can be attached to a message, field,
919/// enumeration, etc.
920#[serde_with::serde_as]
921#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
922#[serde(default, rename_all = "camelCase")]
923#[non_exhaustive]
924pub struct Option {
925    /// The option's name. For protobuf built-in options (options defined in
926    /// descriptor.proto), this is the short name. For example, `"map_entry"`.
927    /// For custom options, it should be the fully-qualified name. For example,
928    /// `"google.api.http"`.
929    #[serde(skip_serializing_if = "std::string::String::is_empty")]
930    pub name: std::string::String,
931
932    /// The option's value packed in an Any message. If the value is a primitive,
933    /// the corresponding wrapper type defined in google/protobuf/wrappers.proto
934    /// should be used. If the value is an enum, it should be stored as an int32
935    /// value using the google.protobuf.Int32Value type.
936    #[serde(skip_serializing_if = "std::option::Option::is_none")]
937    pub value: std::option::Option<crate::Any>,
938}
939
940impl Option {
941    pub fn new() -> Self {
942        std::default::Default::default()
943    }
944
945    /// Sets the value of [name][crate::Option::name].
946    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
947        self.name = v.into();
948        self
949    }
950
951    /// Sets the value of [value][crate::Option::value].
952    pub fn set_value<T: std::convert::Into<std::option::Option<crate::Any>>>(
953        mut self,
954        v: T,
955    ) -> Self {
956        self.value = v.into();
957        self
958    }
959}
960
961impl wkt::message::Message for Option {
962    fn typename() -> &'static str {
963        "type.googleapis.com/google.protobuf.Option"
964    }
965}
966
967/// The syntax in which a protocol buffer element is defined.
968#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
969pub struct Syntax(std::borrow::Cow<'static, str>);
970
971impl Syntax {
972    /// Creates a new Syntax instance.
973    pub const fn new(v: &'static str) -> Self {
974        Self(std::borrow::Cow::Borrowed(v))
975    }
976
977    /// Gets the enum value.
978    pub fn value(&self) -> &str {
979        &self.0
980    }
981}
982
983/// Useful constants to work with [Syntax](Syntax)
984pub mod syntax {
985    use super::Syntax;
986
987    /// Syntax `proto2`.
988    pub const SYNTAX_PROTO2: Syntax = Syntax::new("SYNTAX_PROTO2");
989
990    /// Syntax `proto3`.
991    pub const SYNTAX_PROTO3: Syntax = Syntax::new("SYNTAX_PROTO3");
992
993    /// Syntax `editions`.
994    pub const SYNTAX_EDITIONS: Syntax = Syntax::new("SYNTAX_EDITIONS");
995}
996
997impl std::convert::From<std::string::String> for Syntax {
998    fn from(value: std::string::String) -> Self {
999        Self(std::borrow::Cow::Owned(value))
1000    }
1001}