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