protobuf/well_known_types/
any.rs

1// This file is generated by rust-protobuf 2.27.1. Do not edit
2// @generated
3
4// https://github.com/rust-lang/rust-clippy/issues/702
5#![allow(unknown_lints)]
6#![allow(clippy::all)]
7
8#![allow(unused_attributes)]
9#![cfg_attr(rustfmt, rustfmt::skip)]
10
11#![allow(box_pointers)]
12#![allow(dead_code)]
13#![allow(missing_docs)]
14#![allow(non_camel_case_types)]
15#![allow(non_snake_case)]
16#![allow(non_upper_case_globals)]
17#![allow(trivial_casts)]
18#![allow(unused_imports)]
19#![allow(unused_results)]
20//! Generated file from `google/protobuf/any.proto`
21
22#[derive(PartialEq,Clone,Default)]
23#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
24pub struct Any {
25    // message fields
26    pub type_url: ::std::string::String,
27    pub value: ::std::vec::Vec<u8>,
28    // special fields
29    #[cfg_attr(feature = "with-serde", serde(skip))]
30    pub unknown_fields: crate::UnknownFields,
31    #[cfg_attr(feature = "with-serde", serde(skip))]
32    pub cached_size: crate::CachedSize,
33}
34
35impl<'a> ::std::default::Default for &'a Any {
36    fn default() -> &'a Any {
37        <Any as crate::Message>::default_instance()
38    }
39}
40
41impl Any {
42    pub fn new() -> Any {
43        ::std::default::Default::default()
44    }
45
46    // string type_url = 1;
47
48
49    pub fn get_type_url(&self) -> &str {
50        &self.type_url
51    }
52    pub fn clear_type_url(&mut self) {
53        self.type_url.clear();
54    }
55
56    // Param is passed by value, moved
57    pub fn set_type_url(&mut self, v: ::std::string::String) {
58        self.type_url = v;
59    }
60
61    // Mutable pointer to the field.
62    // If field is not initialized, it is initialized with default value first.
63    pub fn mut_type_url(&mut self) -> &mut ::std::string::String {
64        &mut self.type_url
65    }
66
67    // Take field
68    pub fn take_type_url(&mut self) -> ::std::string::String {
69        ::std::mem::replace(&mut self.type_url, ::std::string::String::new())
70    }
71
72    // bytes value = 2;
73
74
75    pub fn get_value(&self) -> &[u8] {
76        &self.value
77    }
78    pub fn clear_value(&mut self) {
79        self.value.clear();
80    }
81
82    // Param is passed by value, moved
83    pub fn set_value(&mut self, v: ::std::vec::Vec<u8>) {
84        self.value = v;
85    }
86
87    // Mutable pointer to the field.
88    // If field is not initialized, it is initialized with default value first.
89    pub fn mut_value(&mut self) -> &mut ::std::vec::Vec<u8> {
90        &mut self.value
91    }
92
93    // Take field
94    pub fn take_value(&mut self) -> ::std::vec::Vec<u8> {
95        ::std::mem::replace(&mut self.value, ::std::vec::Vec::new())
96    }
97}
98
99impl crate::Message for Any {
100    fn is_initialized(&self) -> bool {
101        true
102    }
103
104    fn merge_from(&mut self, is: &mut crate::CodedInputStream<'_>) -> crate::ProtobufResult<()> {
105        while !is.eof()? {
106            let (field_number, wire_type) = is.read_tag_unpack()?;
107            match field_number {
108                1 => {
109                    crate::rt::read_singular_proto3_string_into(wire_type, is, &mut self.type_url)?;
110                },
111                2 => {
112                    crate::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.value)?;
113                },
114                _ => {
115                    crate::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
116                },
117            };
118        }
119        ::std::result::Result::Ok(())
120    }
121
122    // Compute sizes of nested messages
123    #[allow(unused_variables)]
124    fn compute_size(&self) -> u32 {
125        let mut my_size = 0;
126        if !self.type_url.is_empty() {
127            my_size += crate::rt::string_size(1, &self.type_url);
128        }
129        if !self.value.is_empty() {
130            my_size += crate::rt::bytes_size(2, &self.value);
131        }
132        my_size += crate::rt::unknown_fields_size(self.get_unknown_fields());
133        self.cached_size.set(my_size);
134        my_size
135    }
136
137    fn write_to_with_cached_sizes(&self, os: &mut crate::CodedOutputStream<'_>) -> crate::ProtobufResult<()> {
138        if !self.type_url.is_empty() {
139            os.write_string(1, &self.type_url)?;
140        }
141        if !self.value.is_empty() {
142            os.write_bytes(2, &self.value)?;
143        }
144        os.write_unknown_fields(self.get_unknown_fields())?;
145        ::std::result::Result::Ok(())
146    }
147
148    fn get_cached_size(&self) -> u32 {
149        self.cached_size.get()
150    }
151
152    fn get_unknown_fields(&self) -> &crate::UnknownFields {
153        &self.unknown_fields
154    }
155
156    fn mut_unknown_fields(&mut self) -> &mut crate::UnknownFields {
157        &mut self.unknown_fields
158    }
159
160    fn as_any(&self) -> &dyn (::std::any::Any) {
161        self as &dyn (::std::any::Any)
162    }
163    fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
164        self as &mut dyn (::std::any::Any)
165    }
166    fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
167        self
168    }
169
170    fn descriptor(&self) -> &'static crate::reflect::MessageDescriptor {
171        Self::descriptor_static()
172    }
173
174    fn new() -> Any {
175        Any::new()
176    }
177
178    fn descriptor_static() -> &'static crate::reflect::MessageDescriptor {
179        static descriptor: crate::rt::LazyV2<crate::reflect::MessageDescriptor> = crate::rt::LazyV2::INIT;
180        descriptor.get(|| {
181            let mut fields = ::std::vec::Vec::new();
182            fields.push(crate::reflect::accessor::make_simple_field_accessor::<_, crate::types::ProtobufTypeString>(
183                "type_url",
184                |m: &Any| { &m.type_url },
185                |m: &mut Any| { &mut m.type_url },
186            ));
187            fields.push(crate::reflect::accessor::make_simple_field_accessor::<_, crate::types::ProtobufTypeBytes>(
188                "value",
189                |m: &Any| { &m.value },
190                |m: &mut Any| { &mut m.value },
191            ));
192            crate::reflect::MessageDescriptor::new_pb_name::<Any>(
193                "Any",
194                fields,
195                file_descriptor_proto()
196            )
197        })
198    }
199
200    fn default_instance() -> &'static Any {
201        static instance: crate::rt::LazyV2<Any> = crate::rt::LazyV2::INIT;
202        instance.get(Any::new)
203    }
204}
205
206impl crate::Clear for Any {
207    fn clear(&mut self) {
208        self.type_url.clear();
209        self.value.clear();
210        self.unknown_fields.clear();
211    }
212}
213
214impl ::std::fmt::Debug for Any {
215    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
216        crate::text_format::fmt(self, f)
217    }
218}
219
220impl crate::reflect::ProtobufValue for Any {
221    fn as_ref(&self) -> crate::reflect::ReflectValueRef {
222        crate::reflect::ReflectValueRef::Message(self)
223    }
224}
225
226static file_descriptor_proto_data: &'static [u8] = b"\
227    \n\x19google/protobuf/any.proto\x12\x0fgoogle.protobuf\"6\n\x03Any\x12\
228    \x19\n\x08type_url\x18\x01\x20\x01(\tR\x07typeUrl\x12\x14\n\x05value\x18\
229    \x02\x20\x01(\x0cR\x05valueBv\n\x13com.google.protobufB\x08AnyProtoP\x01\
230    Z,google.golang.org/protobuf/types/known/anypb\xa2\x02\x03GPB\xaa\x02\
231    \x1eGoogle.Protobuf.WellKnownTypesJ\xf9*\n\x07\x12\x05\x1e\0\x9d\x01\x01\
232    \n\xcc\x0c\n\x01\x0c\x12\x03\x1e\0\x122\xc1\x0c\x20Protocol\x20Buffers\
233    \x20-\x20Google's\x20data\x20interchange\x20format\n\x20Copyright\x20200\
234    8\x20Google\x20Inc.\x20\x20All\x20rights\x20reserved.\n\x20https://devel\
235    opers.google.com/protocol-buffers/\n\n\x20Redistribution\x20and\x20use\
236    \x20in\x20source\x20and\x20binary\x20forms,\x20with\x20or\x20without\n\
237    \x20modification,\x20are\x20permitted\x20provided\x20that\x20the\x20foll\
238    owing\x20conditions\x20are\n\x20met:\n\n\x20\x20\x20\x20\x20*\x20Redistr\
239    ibutions\x20of\x20source\x20code\x20must\x20retain\x20the\x20above\x20co\
240    pyright\n\x20notice,\x20this\x20list\x20of\x20conditions\x20and\x20the\
241    \x20following\x20disclaimer.\n\x20\x20\x20\x20\x20*\x20Redistributions\
242    \x20in\x20binary\x20form\x20must\x20reproduce\x20the\x20above\n\x20copyr\
243    ight\x20notice,\x20this\x20list\x20of\x20conditions\x20and\x20the\x20fol\
244    lowing\x20disclaimer\n\x20in\x20the\x20documentation\x20and/or\x20other\
245    \x20materials\x20provided\x20with\x20the\n\x20distribution.\n\x20\x20\
246    \x20\x20\x20*\x20Neither\x20the\x20name\x20of\x20Google\x20Inc.\x20nor\
247    \x20the\x20names\x20of\x20its\n\x20contributors\x20may\x20be\x20used\x20\
248    to\x20endorse\x20or\x20promote\x20products\x20derived\x20from\n\x20this\
249    \x20software\x20without\x20specific\x20prior\x20written\x20permission.\n\
250    \n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDED\x20BY\x20THE\x20COPYRIGHT\x20HO\
251    LDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\x20AND\x20ANY\x20EXPRESS\
252    \x20OR\x20IMPLIED\x20WARRANTIES,\x20INCLUDING,\x20BUT\x20NOT\n\x20LIMITE\
253    D\x20TO,\x20THE\x20IMPLIED\x20WARRANTIES\x20OF\x20MERCHANTABILITY\x20AND\
254    \x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\x20PURPOSE\x20ARE\x20DISCLAIMED.\
255    \x20IN\x20NO\x20EVENT\x20SHALL\x20THE\x20COPYRIGHT\n\x20OWNER\x20OR\x20C\
256    ONTRIBUTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20DIRECT,\x20INDIRECT,\x20INC\
257    IDENTAL,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\
258    \x20(INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20PROCUREMENT\x20OF\
259    \x20SUBSTITUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\x20OF\x20USE,\n\x20DA\
260    TA,\x20OR\x20PROFITS;\x20OR\x20BUSINESS\x20INTERRUPTION)\x20HOWEVER\x20C\
261    AUSED\x20AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIABILITY,\x20WHETHER\x20\
262    IN\x20CONTRACT,\x20STRICT\x20LIABILITY,\x20OR\x20TORT\n\x20(INCLUDING\
263    \x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\x20ANY\x20WAY\x20OUT\
264    \x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\x20EVEN\x20IF\x20ADVIS\
265    ED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20SUCH\x20DAMAGE.\n\n\x08\n\x01\
266    \x02\x12\x03\x20\0\x18\n\x08\n\x01\x08\x12\x03\"\0;\n\t\n\x02\x08%\x12\
267    \x03\"\0;\n\x08\n\x01\x08\x12\x03#\0C\n\t\n\x02\x08\x0b\x12\x03#\0C\n\
268    \x08\n\x01\x08\x12\x03$\0,\n\t\n\x02\x08\x01\x12\x03$\0,\n\x08\n\x01\x08\
269    \x12\x03%\0)\n\t\n\x02\x08\x08\x12\x03%\0)\n\x08\n\x01\x08\x12\x03&\0\"\
270    \n\t\n\x02\x08\n\x12\x03&\0\"\n\x08\n\x01\x08\x12\x03'\0!\n\t\n\x02\x08$\
271    \x12\x03'\0!\n\xfd\x10\n\x02\x04\0\x12\x05|\0\x9d\x01\x01\x1a\xef\x10\
272    \x20`Any`\x20contains\x20an\x20arbitrary\x20serialized\x20protocol\x20bu\
273    ffer\x20message\x20along\x20with\x20a\n\x20URL\x20that\x20describes\x20t\
274    he\x20type\x20of\x20the\x20serialized\x20message.\n\n\x20Protobuf\x20lib\
275    rary\x20provides\x20support\x20to\x20pack/unpack\x20Any\x20values\x20in\
276    \x20the\x20form\n\x20of\x20utility\x20functions\x20or\x20additional\x20g\
277    enerated\x20methods\x20of\x20the\x20Any\x20type.\n\n\x20Example\x201:\
278    \x20Pack\x20and\x20unpack\x20a\x20message\x20in\x20C++.\n\n\x20\x20\x20\
279    \x20\x20Foo\x20foo\x20=\x20...;\n\x20\x20\x20\x20\x20Any\x20any;\n\x20\
280    \x20\x20\x20\x20any.PackFrom(foo);\n\x20\x20\x20\x20\x20...\n\x20\x20\
281    \x20\x20\x20if\x20(any.UnpackTo(&foo))\x20{\n\x20\x20\x20\x20\x20\x20\
282    \x20...\n\x20\x20\x20\x20\x20}\n\n\x20Example\x202:\x20Pack\x20and\x20un\
283    pack\x20a\x20message\x20in\x20Java.\n\n\x20\x20\x20\x20\x20Foo\x20foo\
284    \x20=\x20...;\n\x20\x20\x20\x20\x20Any\x20any\x20=\x20Any.pack(foo);\n\
285    \x20\x20\x20\x20\x20...\n\x20\x20\x20\x20\x20if\x20(any.is(Foo.class))\
286    \x20{\n\x20\x20\x20\x20\x20\x20\x20foo\x20=\x20any.unpack(Foo.class);\n\
287    \x20\x20\x20\x20\x20}\n\n\x20\x20Example\x203:\x20Pack\x20and\x20unpack\
288    \x20a\x20message\x20in\x20Python.\n\n\x20\x20\x20\x20\x20foo\x20=\x20Foo\
289    (...)\n\x20\x20\x20\x20\x20any\x20=\x20Any()\n\x20\x20\x20\x20\x20any.Pa\
290    ck(foo)\n\x20\x20\x20\x20\x20...\n\x20\x20\x20\x20\x20if\x20any.Is(Foo.D\
291    ESCRIPTOR):\n\x20\x20\x20\x20\x20\x20\x20any.Unpack(foo)\n\x20\x20\x20\
292    \x20\x20\x20\x20...\n\n\x20\x20Example\x204:\x20Pack\x20and\x20unpack\
293    \x20a\x20message\x20in\x20Go\n\n\x20\x20\x20\x20\x20\x20foo\x20:=\x20&pb\
294    .Foo{...}\n\x20\x20\x20\x20\x20\x20any,\x20err\x20:=\x20anypb.New(foo)\n\
295    \x20\x20\x20\x20\x20\x20if\x20err\x20!=\x20nil\x20{\n\x20\x20\x20\x20\
296    \x20\x20\x20\x20...\n\x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20\x20\
297    ...\n\x20\x20\x20\x20\x20\x20foo\x20:=\x20&pb.Foo{}\n\x20\x20\x20\x20\
298    \x20\x20if\x20err\x20:=\x20any.UnmarshalTo(foo);\x20err\x20!=\x20nil\x20\
299    {\n\x20\x20\x20\x20\x20\x20\x20\x20...\n\x20\x20\x20\x20\x20\x20}\n\n\
300    \x20The\x20pack\x20methods\x20provided\x20by\x20protobuf\x20library\x20w\
301    ill\x20by\x20default\x20use\n\x20'type.googleapis.com/full.type.name'\
302    \x20as\x20the\x20type\x20URL\x20and\x20the\x20unpack\n\x20methods\x20onl\
303    y\x20use\x20the\x20fully\x20qualified\x20type\x20name\x20after\x20the\
304    \x20last\x20'/'\n\x20in\x20the\x20type\x20URL,\x20for\x20example\x20\"fo\
305    o.bar.com/x/y.z\"\x20will\x20yield\x20type\n\x20name\x20\"y.z\".\n\n\n\
306    \x20JSON\n\x20====\n\x20The\x20JSON\x20representation\x20of\x20an\x20`An\
307    y`\x20value\x20uses\x20the\x20regular\n\x20representation\x20of\x20the\
308    \x20deserialized,\x20embedded\x20message,\x20with\x20an\n\x20additional\
309    \x20field\x20`@type`\x20which\x20contains\x20the\x20type\x20URL.\x20Exam\
310    ple:\n\n\x20\x20\x20\x20\x20package\x20google.profile;\n\x20\x20\x20\x20\
311    \x20message\x20Person\x20{\n\x20\x20\x20\x20\x20\x20\x20string\x20first_\
312    name\x20=\x201;\n\x20\x20\x20\x20\x20\x20\x20string\x20last_name\x20=\
313    \x202;\n\x20\x20\x20\x20\x20}\n\n\x20\x20\x20\x20\x20{\n\x20\x20\x20\x20\
314    \x20\x20\x20\"@type\":\x20\"type.googleapis.com/google.profile.Person\",\
315    \n\x20\x20\x20\x20\x20\x20\x20\"firstName\":\x20<string>,\n\x20\x20\x20\
316    \x20\x20\x20\x20\"lastName\":\x20<string>\n\x20\x20\x20\x20\x20}\n\n\x20\
317    If\x20the\x20embedded\x20message\x20type\x20is\x20well-known\x20and\x20h\
318    as\x20a\x20custom\x20JSON\n\x20representation,\x20that\x20representation\
319    \x20will\x20be\x20embedded\x20adding\x20a\x20field\n\x20`value`\x20which\
320    \x20holds\x20the\x20custom\x20JSON\x20in\x20addition\x20to\x20the\x20`@t\
321    ype`\n\x20field.\x20Example\x20(for\x20message\x20[google.protobuf.Durat\
322    ion][]):\n\n\x20\x20\x20\x20\x20{\n\x20\x20\x20\x20\x20\x20\x20\"@type\"\
323    :\x20\"type.googleapis.com/google.protobuf.Duration\",\n\x20\x20\x20\x20\
324    \x20\x20\x20\"value\":\x20\"1.212s\"\n\x20\x20\x20\x20\x20}\n\n\n\n\n\
325    \x03\x04\0\x01\x12\x03|\x08\x0b\n\xd7\n\n\x04\x04\0\x02\0\x12\x04\x99\
326    \x01\x02\x16\x1a\xc8\n\x20A\x20URL/resource\x20name\x20that\x20uniquely\
327    \x20identifies\x20the\x20type\x20of\x20the\x20serialized\n\x20protocol\
328    \x20buffer\x20message.\x20This\x20string\x20must\x20contain\x20at\x20lea\
329    st\n\x20one\x20\"/\"\x20character.\x20The\x20last\x20segment\x20of\x20th\
330    e\x20URL's\x20path\x20must\x20represent\n\x20the\x20fully\x20qualified\
331    \x20name\x20of\x20the\x20type\x20(as\x20in\n\x20`path/google.protobuf.Du\
332    ration`).\x20The\x20name\x20should\x20be\x20in\x20a\x20canonical\x20form\
333    \n\x20(e.g.,\x20leading\x20\".\"\x20is\x20not\x20accepted).\n\n\x20In\
334    \x20practice,\x20teams\x20usually\x20precompile\x20into\x20the\x20binary\
335    \x20all\x20types\x20that\x20they\n\x20expect\x20it\x20to\x20use\x20in\
336    \x20the\x20context\x20of\x20Any.\x20However,\x20for\x20URLs\x20which\x20\
337    use\x20the\n\x20scheme\x20`http`,\x20`https`,\x20or\x20no\x20scheme,\x20\
338    one\x20can\x20optionally\x20set\x20up\x20a\x20type\n\x20server\x20that\
339    \x20maps\x20type\x20URLs\x20to\x20message\x20definitions\x20as\x20follow\
340    s:\n\n\x20*\x20If\x20no\x20scheme\x20is\x20provided,\x20`https`\x20is\
341    \x20assumed.\n\x20*\x20An\x20HTTP\x20GET\x20on\x20the\x20URL\x20must\x20\
342    yield\x20a\x20[google.protobuf.Type][]\n\x20\x20\x20value\x20in\x20binar\
343    y\x20format,\x20or\x20produce\x20an\x20error.\n\x20*\x20Applications\x20\
344    are\x20allowed\x20to\x20cache\x20lookup\x20results\x20based\x20on\x20the\
345    \n\x20\x20\x20URL,\x20or\x20have\x20them\x20precompiled\x20into\x20a\x20\
346    binary\x20to\x20avoid\x20any\n\x20\x20\x20lookup.\x20Therefore,\x20binar\
347    y\x20compatibility\x20needs\x20to\x20be\x20preserved\n\x20\x20\x20on\x20\
348    changes\x20to\x20types.\x20(Use\x20versioned\x20type\x20names\x20to\x20m\
349    anage\n\x20\x20\x20breaking\x20changes.)\n\n\x20Note:\x20this\x20functio\
350    nality\x20is\x20not\x20currently\x20available\x20in\x20the\x20official\n\
351    \x20protobuf\x20release,\x20and\x20it\x20is\x20not\x20used\x20for\x20typ\
352    e\x20URLs\x20beginning\x20with\n\x20type.googleapis.com.\n\n\x20Schemes\
353    \x20other\x20than\x20`http`,\x20`https`\x20(or\x20the\x20empty\x20scheme\
354    )\x20might\x20be\n\x20used\x20with\x20implementation\x20specific\x20sema\
355    ntics.\n\n\n\r\n\x05\x04\0\x02\0\x05\x12\x04\x99\x01\x02\x08\n\r\n\x05\
356    \x04\0\x02\0\x01\x12\x04\x99\x01\t\x11\n\r\n\x05\x04\0\x02\0\x03\x12\x04\
357    \x99\x01\x14\x15\nW\n\x04\x04\0\x02\x01\x12\x04\x9c\x01\x02\x12\x1aI\x20\
358    Must\x20be\x20a\x20valid\x20serialized\x20protocol\x20buffer\x20of\x20th\
359    e\x20above\x20specified\x20type.\n\n\r\n\x05\x04\0\x02\x01\x05\x12\x04\
360    \x9c\x01\x02\x07\n\r\n\x05\x04\0\x02\x01\x01\x12\x04\x9c\x01\x08\r\n\r\n\
361    \x05\x04\0\x02\x01\x03\x12\x04\x9c\x01\x10\x11b\x06proto3\
362";
363
364static file_descriptor_proto_lazy: crate::rt::LazyV2<crate::descriptor::FileDescriptorProto> = crate::rt::LazyV2::INIT;
365
366fn parse_descriptor_proto() -> crate::descriptor::FileDescriptorProto {
367    crate::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
368}
369
370pub fn file_descriptor_proto() -> &'static crate::descriptor::FileDescriptorProto {
371    file_descriptor_proto_lazy.get(|| {
372        parse_descriptor_proto()
373    })
374}