Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: mojo/public/rust/tests/util/mojom_validation.rs

Issue 2220183003: Rust: Add validation to decode (Closed) Base URL: git@github.com:domokit/mojo.git@coder-testing
Patch Set: Update from upstream branches (fixed arrays, validation code, etc.) Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/rust/tests/util/mod.rs ('k') | mojo/public/rust/tests/validation.rs » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //! This file was auto-generated by the Rust bindings generator. 1 //! This file was auto-generated by the Rust bindings generator.
2 #![allow(bad_style)] 2 #![allow(bad_style)]
3 #![allow(unused_imports)] 3 #![allow(unused_imports)]
4 #![allow(unused_variables)] 4 #![allow(unused_variables)]
5 #![allow(dead_code)] 5 #![allow(dead_code)]
6 6
7 use mojo::bindings::decoding::Decoder; 7 use mojo::bindings::decoding;
8 use mojo::bindings::decoding::{Decoder, ValidationError};
8 use mojo::bindings::encoding; 9 use mojo::bindings::encoding;
9 use mojo::bindings::encoding::{Context, DataHeaderValue, DATA_HEADER_SIZE, Encod er}; 10 use mojo::bindings::encoding::{Context, DataHeaderValue, DATA_HEADER_SIZE, Encod er};
10 use mojo::bindings::message; 11 use mojo::bindings::message;
11 use mojo::bindings::message::MessageHeader; 12 use mojo::bindings::message::MessageHeader;
12 use mojo::bindings::mojom; 13 use mojo::bindings::mojom;
13 use mojo::bindings::mojom::{MojomEncodable, MojomPointer, MojomStruct, MojomUnio n, MojomMessage, 14 use mojo::bindings::mojom::{MojomEncodable, MojomPointer, MojomStruct, MojomUnio n, MojomMessage,
14 MojomInterface, MojomInterfaceSend, MojomInterfaceRe cv, 15 MojomInterface, MojomInterfaceSend, MojomInterfaceRe cv,
15 MojomMessageOption, UNION_SIZE}; 16 MojomMessageOption, UNION_SIZE};
16 17
17 use mojo::system; 18 use mojo::system;
(...skipping 23 matching lines...) Expand all
41 fn header_data(&self) -> DataHeaderValue { 42 fn header_data(&self) -> DataHeaderValue {
42 DataHeaderValue::Version(0) 43 DataHeaderValue::Version(0)
43 } 44 }
44 fn serialized_size(&self, _context: &Context) -> usize { 45 fn serialized_size(&self, _context: &Context) -> usize {
45 16 46 16
46 } 47 }
47 fn encode_value(self, encoder: &mut Encoder, context: Context) { 48 fn encode_value(self, encoder: &mut Encoder, context: Context) {
48 MojomEncodable::encode(self.i, encoder, context.clone()); 49 MojomEncodable::encode(self.i, encoder, context.clone());
49 50
50 } 51 }
51 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 52 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
52 // TODO(mknyszek): Validate bytes and version 53 let version = {
53 let (_bytes, version) = {
54 let mut state = decoder.get_mut(&context); 54 let mut state = decoder.get_mut(&context);
55 let bytes = state.decode::<u32>(); 55 match state.decode_struct_header(&StructAVersions) {
56 let version = state.decode::<u32>(); 56 Ok(header) => header.data(),
57 (bytes, version) 57 Err(err) => return Err(err),
58 }
58 }; 59 };
59 let i = <u64>::decode(decoder, context.clone()); 60 let i = match <u64>::decode(decoder, context.clone()) {
60 StructA { i: i } 61 Ok(value) => value,
62 Err(err) => return Err(err),
63 };
64 Ok(StructA { i: i })
61 } 65 }
62 } 66 }
63 67
64 impl MojomEncodable for StructA { 68 impl MojomEncodable for StructA {
65 impl_encodable_for_pointer!(); 69 impl_encodable_for_pointer!();
66 fn compute_size(&self, context: Context) -> usize { 70 fn compute_size(&self, context: Context) -> usize {
67 encoding::align_default(self.serialized_size(&context)) + 71 encoding::align_default(self.serialized_size(&context)) +
68 self.i.compute_size(context.clone()) 72 self.i.compute_size(context.clone())
69 } 73 }
70 } 74 }
(...skipping 15 matching lines...) Expand all
86 fn header_data(&self) -> DataHeaderValue { 90 fn header_data(&self) -> DataHeaderValue {
87 DataHeaderValue::Version(0) 91 DataHeaderValue::Version(0)
88 } 92 }
89 fn serialized_size(&self, _context: &Context) -> usize { 93 fn serialized_size(&self, _context: &Context) -> usize {
90 16 94 16
91 } 95 }
92 fn encode_value(self, encoder: &mut Encoder, context: Context) { 96 fn encode_value(self, encoder: &mut Encoder, context: Context) {
93 MojomEncodable::encode(self.struct_a, encoder, context.clone()); 97 MojomEncodable::encode(self.struct_a, encoder, context.clone());
94 98
95 } 99 }
96 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 100 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
97 // TODO(mknyszek): Validate bytes and version 101 let version = {
98 let (_bytes, version) = {
99 let mut state = decoder.get_mut(&context); 102 let mut state = decoder.get_mut(&context);
100 let bytes = state.decode::<u32>(); 103 match state.decode_struct_header(&StructBVersions) {
101 let version = state.decode::<u32>(); 104 Ok(header) => header.data(),
102 (bytes, version) 105 Err(err) => return Err(err),
106 }
103 }; 107 };
104 let struct_a = <StructA>::decode(decoder, context.clone()); 108 let struct_a = match <StructA>::decode(decoder, context.clone()) {
105 StructB { struct_a: struct_a } 109 Ok(value) => value,
110 Err(err) => return Err(err),
111 };
112 Ok(StructB { struct_a: struct_a })
106 } 113 }
107 } 114 }
108 115
109 impl MojomEncodable for StructB { 116 impl MojomEncodable for StructB {
110 impl_encodable_for_pointer!(); 117 impl_encodable_for_pointer!();
111 fn compute_size(&self, context: Context) -> usize { 118 fn compute_size(&self, context: Context) -> usize {
112 encoding::align_default(self.serialized_size(&context)) + 119 encoding::align_default(self.serialized_size(&context)) +
113 self.struct_a.compute_size(context.clone()) 120 self.struct_a.compute_size(context.clone())
114 } 121 }
115 } 122 }
(...skipping 15 matching lines...) Expand all
131 fn header_data(&self) -> DataHeaderValue { 138 fn header_data(&self) -> DataHeaderValue {
132 DataHeaderValue::Version(0) 139 DataHeaderValue::Version(0)
133 } 140 }
134 fn serialized_size(&self, _context: &Context) -> usize { 141 fn serialized_size(&self, _context: &Context) -> usize {
135 16 142 16
136 } 143 }
137 fn encode_value(self, encoder: &mut Encoder, context: Context) { 144 fn encode_value(self, encoder: &mut Encoder, context: Context) {
138 MojomEncodable::encode(self.data, encoder, context.clone()); 145 MojomEncodable::encode(self.data, encoder, context.clone());
139 146
140 } 147 }
141 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 148 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
142 // TODO(mknyszek): Validate bytes and version 149 let version = {
143 let (_bytes, version) = {
144 let mut state = decoder.get_mut(&context); 150 let mut state = decoder.get_mut(&context);
145 let bytes = state.decode::<u32>(); 151 match state.decode_struct_header(&StructCVersions) {
146 let version = state.decode::<u32>(); 152 Ok(header) => header.data(),
147 (bytes, version) 153 Err(err) => return Err(err),
154 }
148 }; 155 };
149 let data = <Vec<u8>>::decode(decoder, context.clone()); 156 let data = match <Vec<u8>>::decode(decoder, context.clone()) {
150 StructC { data: data } 157 Ok(value) => value,
158 Err(err) => return Err(err),
159 };
160 Ok(StructC { data: data })
151 } 161 }
152 } 162 }
153 163
154 impl MojomEncodable for StructC { 164 impl MojomEncodable for StructC {
155 impl_encodable_for_pointer!(); 165 impl_encodable_for_pointer!();
156 fn compute_size(&self, context: Context) -> usize { 166 fn compute_size(&self, context: Context) -> usize {
157 encoding::align_default(self.serialized_size(&context)) + 167 encoding::align_default(self.serialized_size(&context)) +
158 self.data.compute_size(context.clone()) 168 self.data.compute_size(context.clone())
159 } 169 }
160 } 170 }
(...skipping 15 matching lines...) Expand all
176 fn header_data(&self) -> DataHeaderValue { 186 fn header_data(&self) -> DataHeaderValue {
177 DataHeaderValue::Version(0) 187 DataHeaderValue::Version(0)
178 } 188 }
179 fn serialized_size(&self, _context: &Context) -> usize { 189 fn serialized_size(&self, _context: &Context) -> usize {
180 16 190 16
181 } 191 }
182 fn encode_value(self, encoder: &mut Encoder, context: Context) { 192 fn encode_value(self, encoder: &mut Encoder, context: Context) {
183 MojomEncodable::encode(self.message_pipes, encoder, context.clone()); 193 MojomEncodable::encode(self.message_pipes, encoder, context.clone());
184 194
185 } 195 }
186 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 196 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
187 // TODO(mknyszek): Validate bytes and version 197 let version = {
188 let (_bytes, version) = {
189 let mut state = decoder.get_mut(&context); 198 let mut state = decoder.get_mut(&context);
190 let bytes = state.decode::<u32>(); 199 match state.decode_struct_header(&StructDVersions) {
191 let version = state.decode::<u32>(); 200 Ok(header) => header.data(),
192 (bytes, version) 201 Err(err) => return Err(err),
202 }
193 }; 203 };
194 let message_pipes = 204 let message_pipes = match <Vec<message_pipe::MessageEndpoint>>::decode(d ecoder, context.clone()) {
195 <Vec<message_pipe::MessageEndpoint>>::decode(decoder, context.clone( )); 205 Ok(value) => value,
196 StructD { message_pipes: message_pipes } 206 Err(err) => return Err(err),
207 };
208 Ok(StructD { message_pipes: message_pipes })
197 } 209 }
198 } 210 }
199 211
200 impl MojomEncodable for StructD { 212 impl MojomEncodable for StructD {
201 impl_encodable_for_pointer!(); 213 impl_encodable_for_pointer!();
202 fn compute_size(&self, context: Context) -> usize { 214 fn compute_size(&self, context: Context) -> usize {
203 encoding::align_default(self.serialized_size(&context)) + 215 encoding::align_default(self.serialized_size(&context)) +
204 self.message_pipes.compute_size(context.clone()) 216 self.message_pipes.compute_size(context.clone())
205 } 217 }
206 } 218 }
(...skipping 17 matching lines...) Expand all
224 DataHeaderValue::Version(0) 236 DataHeaderValue::Version(0)
225 } 237 }
226 fn serialized_size(&self, _context: &Context) -> usize { 238 fn serialized_size(&self, _context: &Context) -> usize {
227 24 239 24
228 } 240 }
229 fn encode_value(self, encoder: &mut Encoder, context: Context) { 241 fn encode_value(self, encoder: &mut Encoder, context: Context) {
230 MojomEncodable::encode(self.struct_d, encoder, context.clone()); 242 MojomEncodable::encode(self.struct_d, encoder, context.clone());
231 MojomEncodable::encode(self.data_pipe_consumer, encoder, context.clone() ); 243 MojomEncodable::encode(self.data_pipe_consumer, encoder, context.clone() );
232 244
233 } 245 }
234 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 246 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
235 // TODO(mknyszek): Validate bytes and version 247 let version = {
236 let (_bytes, version) = {
237 let mut state = decoder.get_mut(&context); 248 let mut state = decoder.get_mut(&context);
238 let bytes = state.decode::<u32>(); 249 match state.decode_struct_header(&StructEVersions) {
239 let version = state.decode::<u32>(); 250 Ok(header) => header.data(),
240 (bytes, version) 251 Err(err) => return Err(err),
252 }
241 }; 253 };
242 let struct_d = <StructD>::decode(decoder, context.clone()); 254 let struct_d = match <StructD>::decode(decoder, context.clone()) {
255 Ok(value) => value,
256 Err(err) => return Err(err),
257 };
243 let data_pipe_consumer = 258 let data_pipe_consumer =
244 <system::data_pipe::Consumer<u8>>::decode(decoder, context.clone()); 259 match <system::data_pipe::Consumer<u8>>::decode(decoder, context.clo ne()) {
245 StructE { 260 Ok(value) => value,
261 Err(err) => return Err(err),
262 };
263 Ok(StructE {
246 struct_d: struct_d, 264 struct_d: struct_d,
247 data_pipe_consumer: data_pipe_consumer, 265 data_pipe_consumer: data_pipe_consumer,
248 } 266 })
249 } 267 }
250 } 268 }
251 269
252 impl MojomEncodable for StructE { 270 impl MojomEncodable for StructE {
253 impl_encodable_for_pointer!(); 271 impl_encodable_for_pointer!();
254 fn compute_size(&self, context: Context) -> usize { 272 fn compute_size(&self, context: Context) -> usize {
255 encoding::align_default(self.serialized_size(&context)) + 273 encoding::align_default(self.serialized_size(&context)) +
256 self.struct_d.compute_size(context.clone()) + 274 self.struct_d.compute_size(context.clone()) +
257 self.data_pipe_consumer.compute_size(context.clone()) 275 self.data_pipe_consumer.compute_size(context.clone())
258 } 276 }
(...skipping 16 matching lines...) Expand all
275 fn header_data(&self) -> DataHeaderValue { 293 fn header_data(&self) -> DataHeaderValue {
276 DataHeaderValue::Version(0) 294 DataHeaderValue::Version(0)
277 } 295 }
278 fn serialized_size(&self, _context: &Context) -> usize { 296 fn serialized_size(&self, _context: &Context) -> usize {
279 16 297 16
280 } 298 }
281 fn encode_value(self, encoder: &mut Encoder, context: Context) { 299 fn encode_value(self, encoder: &mut Encoder, context: Context) {
282 MojomEncodable::encode(self.fixed_size_array, encoder, context.clone()); 300 MojomEncodable::encode(self.fixed_size_array, encoder, context.clone());
283 301
284 } 302 }
285 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 303 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
286 // TODO(mknyszek): Validate bytes and version 304 let version = {
287 let (_bytes, version) = {
288 let mut state = decoder.get_mut(&context); 305 let mut state = decoder.get_mut(&context);
289 let bytes = state.decode::<u32>(); 306 match state.decode_struct_header(&StructFVersions) {
290 let version = state.decode::<u32>(); 307 Ok(header) => header.data(),
291 (bytes, version) 308 Err(err) => return Err(err),
309 }
292 }; 310 };
293 let fixed_size_array = <[u8; 3]>::decode(decoder, context.clone()); 311 let fixed_size_array = match <[u8; 3]>::decode(decoder, context.clone()) {
294 StructF { fixed_size_array: fixed_size_array } 312 Ok(value) => value,
313 Err(err) => return Err(err),
314 };
315 Ok(StructF { fixed_size_array: fixed_size_array })
295 } 316 }
296 } 317 }
297 318
298 impl MojomEncodable for StructF { 319 impl MojomEncodable for StructF {
299 impl_encodable_for_pointer!(); 320 impl_encodable_for_pointer!();
300 fn compute_size(&self, context: Context) -> usize { 321 fn compute_size(&self, context: Context) -> usize {
301 encoding::align_default(self.serialized_size(&context)) + 322 encoding::align_default(self.serialized_size(&context)) +
302 self.fixed_size_array.compute_size(context.clone()) 323 self.fixed_size_array.compute_size(context.clone())
303 } 324 }
304 } 325 }
(...skipping 21 matching lines...) Expand all
326 fn serialized_size(&self, _context: &Context) -> usize { 347 fn serialized_size(&self, _context: &Context) -> usize {
327 32 348 32
328 } 349 }
329 fn encode_value(self, encoder: &mut Encoder, context: Context) { 350 fn encode_value(self, encoder: &mut Encoder, context: Context) {
330 MojomEncodable::encode(self.i, encoder, context.clone()); 351 MojomEncodable::encode(self.i, encoder, context.clone());
331 MojomEncodable::encode(self.b, encoder, context.clone()); 352 MojomEncodable::encode(self.b, encoder, context.clone());
332 MojomEncodable::encode(self.struct_a, encoder, context.clone()); 353 MojomEncodable::encode(self.struct_a, encoder, context.clone());
333 MojomEncodable::encode(self.str, encoder, context.clone()); 354 MojomEncodable::encode(self.str, encoder, context.clone());
334 355
335 } 356 }
336 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 357 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
337 // TODO(mknyszek): Validate bytes and version 358 let version = {
338 let (_bytes, version) = {
339 let mut state = decoder.get_mut(&context); 359 let mut state = decoder.get_mut(&context);
340 let bytes = state.decode::<u32>(); 360 match state.decode_struct_header(&StructGVersions) {
341 let version = state.decode::<u32>(); 361 Ok(header) => header.data(),
342 (bytes, version) 362 Err(err) => return Err(err),
363 }
343 }; 364 };
344 let i = <i32>::decode(decoder, context.clone()); 365 let i = match <i32>::decode(decoder, context.clone()) {
366 Ok(value) => value,
367 Err(err) => return Err(err),
368 };
345 let b = if version >= 3 { 369 let b = if version >= 3 {
346 <bool>::decode(decoder, context.clone()) 370 match <bool>::decode(decoder, context.clone()) {
371 Ok(value) => value,
372 Err(err) => return Err(err),
373 }
347 } else { 374 } else {
348 Default::default() 375 Default::default()
349 }; 376 };
350 let struct_a = if version >= 1 { 377 let struct_a = if version >= 1 {
351 <Option<StructA>>::decode(decoder, context.clone()) 378 match <Option<StructA>>::decode(decoder, context.clone()) {
379 Ok(value) => value,
380 Err(err) => return Err(err),
381 }
352 } else { 382 } else {
353 Default::default() 383 Default::default()
354 }; 384 };
355 let str = if version >= 3 { 385 let str = if version >= 3 {
356 <Option<String>>::decode(decoder, context.clone()) 386 match <Option<String>>::decode(decoder, context.clone()) {
387 Ok(value) => value,
388 Err(err) => return Err(err),
389 }
357 } else { 390 } else {
358 Default::default() 391 Default::default()
359 }; 392 };
360 StructG { 393 Ok(StructG {
361 i: i, 394 i: i,
362 b: b, 395 b: b,
363 struct_a: struct_a, 396 struct_a: struct_a,
364 str: str, 397 str: str,
365 } 398 })
366 } 399 }
367 } 400 }
368 401
369 impl MojomEncodable for StructG { 402 impl MojomEncodable for StructG {
370 impl_encodable_for_pointer!(); 403 impl_encodable_for_pointer!();
371 fn compute_size(&self, context: Context) -> usize { 404 fn compute_size(&self, context: Context) -> usize {
372 encoding::align_default(self.serialized_size(&context)) + 405 encoding::align_default(self.serialized_size(&context)) +
373 self.i.compute_size(context.clone()) + self.b.compute_size(context.clone ()) + 406 self.i.compute_size(context.clone()) + self.b.compute_size(context.clone ()) +
374 self.struct_a.compute_size(context.clone()) + self.str.compute_size(cont ext.clone()) 407 self.struct_a.compute_size(context.clone()) + self.str.compute_size(cont ext.clone())
375 } 408 }
(...skipping 24 matching lines...) Expand all
400 48 433 48
401 } 434 }
402 fn encode_value(self, encoder: &mut Encoder, context: Context) { 435 fn encode_value(self, encoder: &mut Encoder, context: Context) {
403 MojomEncodable::encode(self.a, encoder, context.clone()); 436 MojomEncodable::encode(self.a, encoder, context.clone());
404 MojomEncodable::encode(self.b, encoder, context.clone()); 437 MojomEncodable::encode(self.b, encoder, context.clone());
405 MojomEncodable::encode(self.c, encoder, context.clone()); 438 MojomEncodable::encode(self.c, encoder, context.clone());
406 MojomEncodable::encode(self.d, encoder, context.clone()); 439 MojomEncodable::encode(self.d, encoder, context.clone());
407 MojomEncodable::encode(self.e, encoder, context.clone()); 440 MojomEncodable::encode(self.e, encoder, context.clone());
408 441
409 } 442 }
410 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 443 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
411 // TODO(mknyszek): Validate bytes and version 444 let version = {
412 let (_bytes, version) = {
413 let mut state = decoder.get_mut(&context); 445 let mut state = decoder.get_mut(&context);
414 let bytes = state.decode::<u32>(); 446 match state.decode_struct_header(&StructHVersions) {
415 let version = state.decode::<u32>(); 447 Ok(header) => header.data(),
416 (bytes, version) 448 Err(err) => return Err(err),
449 }
417 }; 450 };
418 let a = <bool>::decode(decoder, context.clone()); 451 let a = match <bool>::decode(decoder, context.clone()) {
419 let b = <u8>::decode(decoder, context.clone()); 452 Ok(value) => value,
420 let c = <Option<UnionA>>::decode(decoder, context.clone()); 453 Err(err) => return Err(err),
421 let d = <Option<Vec<UnionA>>>::decode(decoder, context.clone()); 454 };
422 let e = <Option<HashMap<u8, UnionA>>>::decode(decoder, context.clone()); 455 let b = match <u8>::decode(decoder, context.clone()) {
423 StructH { 456 Ok(value) => value,
457 Err(err) => return Err(err),
458 };
459 let c = match <Option<UnionA>>::decode(decoder, context.clone()) {
460 Ok(value) => value,
461 Err(err) => return Err(err),
462 };
463 let d = match <Option<Vec<UnionA>>>::decode(decoder, context.clone()) {
464 Ok(value) => value,
465 Err(err) => return Err(err),
466 };
467 let e = match <Option<HashMap<u8, UnionA>>>::decode(decoder, context.clo ne()) {
468 Ok(value) => value,
469 Err(err) => return Err(err),
470 };
471 Ok(StructH {
424 a: a, 472 a: a,
425 b: b, 473 b: b,
426 c: c, 474 c: c,
427 d: d, 475 d: d,
428 e: e, 476 e: e,
429 } 477 })
430 } 478 }
431 } 479 }
432 480
433 impl MojomEncodable for StructH { 481 impl MojomEncodable for StructH {
434 impl_encodable_for_pointer!(); 482 impl_encodable_for_pointer!();
435 fn compute_size(&self, context: Context) -> usize { 483 fn compute_size(&self, context: Context) -> usize {
436 encoding::align_default(self.serialized_size(&context)) + 484 encoding::align_default(self.serialized_size(&context)) +
437 self.a.compute_size(context.clone()) + self.b.compute_size(context.clone ()) + 485 self.a.compute_size(context.clone()) + self.b.compute_size(context.clone ()) +
438 self.c.compute_size(context.clone()) + self.d.compute_size(context.clone ()) + 486 self.c.compute_size(context.clone()) + self.d.compute_size(context.clone ()) +
439 self.e.compute_size(context.clone()) 487 self.e.compute_size(context.clone())
(...skipping 17 matching lines...) Expand all
457 fn header_data(&self) -> DataHeaderValue { 505 fn header_data(&self) -> DataHeaderValue {
458 DataHeaderValue::Version(0) 506 DataHeaderValue::Version(0)
459 } 507 }
460 fn serialized_size(&self, _context: &Context) -> usize { 508 fn serialized_size(&self, _context: &Context) -> usize {
461 16 509 16
462 } 510 }
463 fn encode_value(self, encoder: &mut Encoder, context: Context) { 511 fn encode_value(self, encoder: &mut Encoder, context: Context) {
464 MojomEncodable::encode(self.a, encoder, context.clone()); 512 MojomEncodable::encode(self.a, encoder, context.clone());
465 513
466 } 514 }
467 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 515 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
468 // TODO(mknyszek): Validate bytes and version 516 let version = {
469 let (_bytes, version) = {
470 let mut state = decoder.get_mut(&context); 517 let mut state = decoder.get_mut(&context);
471 let bytes = state.decode::<u32>(); 518 match state.decode_struct_header(&BasicStructVersions) {
472 let version = state.decode::<u32>(); 519 Ok(header) => header.data(),
473 (bytes, version) 520 Err(err) => return Err(err),
521 }
474 }; 522 };
475 let a = <i32>::decode(decoder, context.clone()); 523 let a = match <i32>::decode(decoder, context.clone()) {
476 BasicStruct { a: a } 524 Ok(value) => value,
525 Err(err) => return Err(err),
526 };
527 Ok(BasicStruct { a: a })
477 } 528 }
478 } 529 }
479 530
480 impl MojomEncodable for BasicStruct { 531 impl MojomEncodable for BasicStruct {
481 impl_encodable_for_pointer!(); 532 impl_encodable_for_pointer!();
482 fn compute_size(&self, context: Context) -> usize { 533 fn compute_size(&self, context: Context) -> usize {
483 encoding::align_default(self.serialized_size(&context)) + 534 encoding::align_default(self.serialized_size(&context)) +
484 self.a.compute_size(context.clone()) 535 self.a.compute_size(context.clone())
485 } 536 }
486 } 537 }
(...skipping 20 matching lines...) Expand all
507 } 558 }
508 559
509 impl MojomPointer for StructWithEnum { 560 impl MojomPointer for StructWithEnum {
510 fn header_data(&self) -> DataHeaderValue { 561 fn header_data(&self) -> DataHeaderValue {
511 DataHeaderValue::Version(0) 562 DataHeaderValue::Version(0)
512 } 563 }
513 fn serialized_size(&self, _context: &Context) -> usize { 564 fn serialized_size(&self, _context: &Context) -> usize {
514 8 565 8
515 } 566 }
516 fn encode_value(self, encoder: &mut Encoder, context: Context) {} 567 fn encode_value(self, encoder: &mut Encoder, context: Context) {}
517 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 568 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
518 // TODO(mknyszek): Validate bytes and version 569 let version = {
519 let (_bytes, version) = {
520 let mut state = decoder.get_mut(&context); 570 let mut state = decoder.get_mut(&context);
521 let bytes = state.decode::<u32>(); 571 match state.decode_struct_header(&StructWithEnumVersions) {
522 let version = state.decode::<u32>(); 572 Ok(header) => header.data(),
523 (bytes, version) 573 Err(err) => return Err(err),
574 }
524 }; 575 };
525 StructWithEnum {} 576 Ok(StructWithEnum {})
526 } 577 }
527 } 578 }
528 579
529 impl MojomEncodable for StructWithEnum { 580 impl MojomEncodable for StructWithEnum {
530 impl_encodable_for_pointer!(); 581 impl_encodable_for_pointer!();
531 fn compute_size(&self, context: Context) -> usize { 582 fn compute_size(&self, context: Context) -> usize {
532 encoding::align_default(self.serialized_size(&context)) 583 encoding::align_default(self.serialized_size(&context))
533 } 584 }
534 } 585 }
535 586
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 UnionA::d(val) => MojomEncodable::encode(val, encoder, context.clone ()), 645 UnionA::d(val) => MojomEncodable::encode(val, encoder, context.clone ()),
595 UnionA::e(val) => MojomEncodable::encode(val, encoder, context.clone ()), 646 UnionA::e(val) => MojomEncodable::encode(val, encoder, context.clone ()),
596 UnionA::f(val) => MojomEncodable::encode(val, encoder, context.clone ()), 647 UnionA::f(val) => MojomEncodable::encode(val, encoder, context.clone ()),
597 UnionA::g(val) => MojomEncodable::encode(val, encoder, context.clone ()), 648 UnionA::g(val) => MojomEncodable::encode(val, encoder, context.clone ()),
598 UnionA::h(val) => MojomEncodable::encode(val, encoder, context.clone ()), 649 UnionA::h(val) => MojomEncodable::encode(val, encoder, context.clone ()),
599 UnionA::i(val) => MojomEncodable::encode(val, encoder, context.clone ()), 650 UnionA::i(val) => MojomEncodable::encode(val, encoder, context.clone ()),
600 UnionA::j(val) => MojomEncodable::encode(val, encoder, context.clone ()), 651 UnionA::j(val) => MojomEncodable::encode(val, encoder, context.clone ()),
601 UnionA::_Unknown(val) => MojomEncodable::encode(val, encoder, contex t.clone()), 652 UnionA::_Unknown(val) => MojomEncodable::encode(val, encoder, contex t.clone()),
602 } 653 }
603 } 654 }
604 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 655 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
605 // TODO(mknyszek): Validate bytes and tag 656 let tag = {
606 let (_bytes, tag) = {
607 let mut state = decoder.get_mut(&context); 657 let mut state = decoder.get_mut(&context);
608 let bytes = state.decode::<u32>(); 658 let bytes = state.decode::<u32>();
609 let tag = state.decode::<u32>(); 659 if (bytes as usize) != UNION_SIZE {
610 (bytes, tag) 660 return Err(ValidationError::UnexpectedNullUnion);
661 }
662 state.decode::<u32>()
611 }; 663 };
612 match tag { 664 Ok(match tag {
613 UnionATag_a => UnionA::a(<u16>::decode(decoder, context.clone())), 665 UnionATag_a => {
614 UnionATag_b => UnionA::b(<u32>::decode(decoder, context.clone())), 666 UnionA::a({
615 UnionATag_c => UnionA::c(<Option<StructA>>::decode(decoder, context. clone())), 667 match <u16>::decode(decoder, context.clone()) {
616 UnionATag_d => UnionA::d(<Option<Vec<u8>>>::decode(decoder, context. clone())), 668 Ok(value) => value,
669 Err(err) => return Err(err),
670 }
671 })
672 }
673 UnionATag_b => {
674 UnionA::b({
675 match <u32>::decode(decoder, context.clone()) {
676 Ok(value) => value,
677 Err(err) => return Err(err),
678 }
679 })
680 }
681 UnionATag_c => {
682 UnionA::c({
683 match <Option<StructA>>::decode(decoder, context.clone()) {
684 Ok(value) => value,
685 Err(err) => return Err(err),
686 }
687 })
688 }
689 UnionATag_d => {
690 UnionA::d({
691 match <Option<Vec<u8>>>::decode(decoder, context.clone()) {
692 Ok(value) => value,
693 Err(err) => return Err(err),
694 }
695 })
696 }
617 UnionATag_e => { 697 UnionATag_e => {
618 UnionA::e(<Option<HashMap<String, u8>>>::decode(decoder, context .clone())) 698 UnionA::e({
699 match <Option<HashMap<String, u8>>>::decode(decoder, context .clone()) {
700 Ok(value) => value,
701 Err(err) => return Err(err),
702 }
703 })
619 } 704 }
620 UnionATag_f => UnionA::f(<Option<UnionB>>::decode(decoder, context.c lone())), 705 UnionATag_f => {
621 UnionATag_g => UnionA::g(<StructA>::decode(decoder, context.clone()) ), 706 UnionA::f({
622 UnionATag_h => UnionA::h(<Vec<u8>>::decode(decoder, context.clone()) ), 707 match <Option<UnionB>>::decode(decoder, context.clone()) {
623 UnionATag_i => UnionA::i(<HashMap<String, u8>>::decode(decoder, cont ext.clone())), 708 Ok(value) => value,
624 UnionATag_j => UnionA::j(<UnionB>::decode(decoder, context.clone())) , 709 Err(err) => return Err(err),
625 _ => UnionA::_Unknown(u64::decode(decoder, context.clone())), 710 }
626 } 711 })
712 }
713 UnionATag_g => {
714 UnionA::g({
715 match <StructA>::decode(decoder, context.clone()) {
716 Ok(value) => value,
717 Err(err) => return Err(err),
718 }
719 })
720 }
721 UnionATag_h => {
722 UnionA::h({
723 match <Vec<u8>>::decode(decoder, context.clone()) {
724 Ok(value) => value,
725 Err(err) => return Err(err),
726 }
727 })
728 }
729 UnionATag_i => {
730 UnionA::i({
731 match <HashMap<String, u8>>::decode(decoder, context.clone() ) {
732 Ok(value) => value,
733 Err(err) => return Err(err),
734 }
735 })
736 }
737 UnionATag_j => {
738 UnionA::j({
739 match <UnionB>::decode(decoder, context.clone()) {
740 Ok(value) => value,
741 Err(err) => return Err(err),
742 }
743 })
744 }
745 _ => UnionA::_Unknown(u64::decode(decoder, context.clone()).unwrap() ),
746 })
627 } 747 }
628 } 748 }
629 749
630 impl MojomEncodable for UnionA { 750 impl MojomEncodable for UnionA {
631 impl_encodable_for_union!(); 751 impl_encodable_for_union!();
632 fn compute_size(&self, context: Context) -> usize { 752 fn compute_size(&self, context: Context) -> usize {
633 UNION_SIZE + 753 UNION_SIZE +
634 match *self { 754 match *self {
635 UnionA::a(ref val) => val.compute_size(context.clone()), 755 UnionA::a(ref val) => val.compute_size(context.clone()),
636 UnionA::b(ref val) => val.compute_size(context.clone()), 756 UnionA::b(ref val) => val.compute_size(context.clone()),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 800 }
681 fn encode_value(self, encoder: &mut Encoder, context: Context) { 801 fn encode_value(self, encoder: &mut Encoder, context: Context) {
682 match self { 802 match self {
683 UnionB::a(val) => MojomEncodable::encode(val, encoder, context.clone ()), 803 UnionB::a(val) => MojomEncodable::encode(val, encoder, context.clone ()),
684 UnionB::b(val) => MojomEncodable::encode(val, encoder, context.clone ()), 804 UnionB::b(val) => MojomEncodable::encode(val, encoder, context.clone ()),
685 UnionB::c(val) => MojomEncodable::encode(val, encoder, context.clone ()), 805 UnionB::c(val) => MojomEncodable::encode(val, encoder, context.clone ()),
686 UnionB::d(val) => MojomEncodable::encode(val, encoder, context.clone ()), 806 UnionB::d(val) => MojomEncodable::encode(val, encoder, context.clone ()),
687 UnionB::_Unknown(val) => MojomEncodable::encode(val, encoder, contex t.clone()), 807 UnionB::_Unknown(val) => MojomEncodable::encode(val, encoder, contex t.clone()),
688 } 808 }
689 } 809 }
690 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 810 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
691 // TODO(mknyszek): Validate bytes and tag 811 let tag = {
692 let (_bytes, tag) = {
693 let mut state = decoder.get_mut(&context); 812 let mut state = decoder.get_mut(&context);
694 let bytes = state.decode::<u32>(); 813 let bytes = state.decode::<u32>();
695 let tag = state.decode::<u32>(); 814 if (bytes as usize) != UNION_SIZE {
696 (bytes, tag) 815 return Err(ValidationError::UnexpectedNullUnion);
816 }
817 state.decode::<u32>()
697 }; 818 };
698 match tag { 819 Ok(match tag {
699 UnionBTag_a => UnionB::a(<u16>::decode(decoder, context.clone())), 820 UnionBTag_a => {
700 UnionBTag_b => UnionB::b(<u32>::decode(decoder, context.clone())), 821 UnionB::a({
701 UnionBTag_c => UnionB::c(<u64>::decode(decoder, context.clone())), 822 match <u16>::decode(decoder, context.clone()) {
702 UnionBTag_d => UnionB::d(<u32>::decode(decoder, context.clone())), 823 Ok(value) => value,
703 _ => UnionB::_Unknown(u64::decode(decoder, context.clone())), 824 Err(err) => return Err(err),
704 } 825 }
826 })
827 }
828 UnionBTag_b => {
829 UnionB::b({
830 match <u32>::decode(decoder, context.clone()) {
831 Ok(value) => value,
832 Err(err) => return Err(err),
833 }
834 })
835 }
836 UnionBTag_c => {
837 UnionB::c({
838 match <u64>::decode(decoder, context.clone()) {
839 Ok(value) => value,
840 Err(err) => return Err(err),
841 }
842 })
843 }
844 UnionBTag_d => {
845 UnionB::d({
846 match <u32>::decode(decoder, context.clone()) {
847 Ok(value) => value,
848 Err(err) => return Err(err),
849 }
850 })
851 }
852 _ => UnionB::_Unknown(u64::decode(decoder, context.clone()).unwrap() ),
853 })
705 } 854 }
706 } 855 }
707 856
708 impl MojomEncodable for UnionB { 857 impl MojomEncodable for UnionB {
709 impl_encodable_for_union!(); 858 impl_encodable_for_union!();
710 fn compute_size(&self, context: Context) -> usize { 859 fn compute_size(&self, context: Context) -> usize {
711 UNION_SIZE + 860 UNION_SIZE +
712 match *self { 861 match *self {
713 UnionB::a(ref val) => val.compute_size(context.clone()), 862 UnionB::a(ref val) => val.compute_size(context.clone()),
714 UnionB::b(ref val) => val.compute_size(context.clone()), 863 UnionB::b(ref val) => val.compute_size(context.clone()),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 984
836 985
837 pub trait InterfaceARequest: MojomMessage {} 986 pub trait InterfaceARequest: MojomMessage {}
838 pub trait InterfaceAResponse: MojomMessage {} 987 pub trait InterfaceAResponse: MojomMessage {}
839 988
840 pub enum InterfaceARequestOption { 989 pub enum InterfaceARequestOption {
841 990
842 } 991 }
843 992
844 impl MojomMessageOption for InterfaceARequestOption { 993 impl MojomMessageOption for InterfaceARequestOption {
845 fn decode_payload(ordinal: u32, buffer: &[u8], handles: Vec<UntypedHandle>) -> Self { 994 fn decode_payload(header: MessageHeader,
846 match ordinal { 995 buffer: &[u8],
847 _ => panic!("Unknown message found: {}", ordinal), 996 handles: Vec<UntypedHandle>)
997 -> Result<Self, ValidationError> {
998 match header.name {
999 _ => Err(ValidationError::MessageHeaderUnknownMethod),
848 } 1000 }
849 } 1001 }
850 } 1002 }
851 1003
852 pub enum InterfaceAResponseOption { 1004 pub enum InterfaceAResponseOption {
853 1005
854 } 1006 }
855 1007
856 impl MojomMessageOption for InterfaceAResponseOption { 1008 impl MojomMessageOption for InterfaceAResponseOption {
857 fn decode_payload(ordinal: u32, buffer: &[u8], handles: Vec<UntypedHandle>) -> Self { 1009 fn decode_payload(header: MessageHeader,
858 match ordinal { 1010 buffer: &[u8],
859 _ => { 1011 handles: Vec<UntypedHandle>)
860 panic!("Unknown message found, or message has no response: {}", 1012 -> Result<Self, ValidationError> {
861 ordinal) 1013 if header.flags != message::MESSAGE_HEADER_IS_RESPONSE {
862 } 1014 return Err(ValidationError::MessageHeaderInvalidFlags);
1015 }
1016 match header.name {
1017 _ => Err(ValidationError::MessageHeaderUnknownMethod),
863 } 1018 }
864 } 1019 }
865 } 1020 }
866 1021
867 1022
868 // --- BoundsCheckTestInterface --- 1023 // --- BoundsCheckTestInterface ---
869 1024
870 pub mod BoundsCheckTestInterface { 1025 pub mod BoundsCheckTestInterface {
871 pub const SERVICE_NAME: &'static str = "this.is.the.service.name.for.BoundsC heckTestInterface"; 1026 pub const SERVICE_NAME: &'static str = "this.is.the.service.name.for.BoundsC heckTestInterface";
872 pub const VERSION: u32 = 0; 1027 pub const VERSION: u32 = 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 1121
967 pub trait BoundsCheckTestInterfaceRequest: MojomMessage {} 1122 pub trait BoundsCheckTestInterfaceRequest: MojomMessage {}
968 pub trait BoundsCheckTestInterfaceResponse: MojomMessage {} 1123 pub trait BoundsCheckTestInterfaceResponse: MojomMessage {}
969 1124
970 pub enum BoundsCheckTestInterfaceRequestOption { 1125 pub enum BoundsCheckTestInterfaceRequestOption {
971 BoundsCheckTestInterfaceMethod0(BoundsCheckTestInterfaceMethod0Request), 1126 BoundsCheckTestInterfaceMethod0(BoundsCheckTestInterfaceMethod0Request),
972 BoundsCheckTestInterfaceMethod1(BoundsCheckTestInterfaceMethod1Request), 1127 BoundsCheckTestInterfaceMethod1(BoundsCheckTestInterfaceMethod1Request),
973 } 1128 }
974 1129
975 impl MojomMessageOption for BoundsCheckTestInterfaceRequestOption { 1130 impl MojomMessageOption for BoundsCheckTestInterfaceRequestOption {
976 fn decode_payload(ordinal: u32, buffer: &[u8], handles: Vec<UntypedHandle>) -> Self { 1131 fn decode_payload(header: MessageHeader,
977 match ordinal { 1132 buffer: &[u8],
978 BoundsCheckTestInterfaceMethod0::ORDINAL => BoundsCheckTestInterface RequestOption::BoundsCheckTestInterfaceMethod0(BoundsCheckTestInterfaceMethod0Re quest::deserialize(buffer, handles)), 1133 handles: Vec<UntypedHandle>)
979 BoundsCheckTestInterfaceMethod1::ORDINAL => BoundsCheckTestInterface RequestOption::BoundsCheckTestInterfaceMethod1(BoundsCheckTestInterfaceMethod1Re quest::deserialize(buffer, handles)), 1134 -> Result<Self, ValidationError> {
980 _ => panic!("Unknown message found: {}", ordinal), 1135 match header.name {
1136 BoundsCheckTestInterfaceMethod0::ORDINAL => {
1137 if header.flags != message::MESSAGE_HEADER_EXPECT_RESPONSE {
1138 return Err(ValidationError::MessageHeaderInvalidFlags);
1139 }
1140 match BoundsCheckTestInterfaceMethod0Request::deserialize(buffer , handles) {
1141 Ok(value) => Ok(BoundsCheckTestInterfaceRequestOption::Bound sCheckTestInterfaceMethod0(value)),
1142 Err(err) => return Err(err),
1143 }
1144 }
1145 BoundsCheckTestInterfaceMethod1::ORDINAL => {
1146 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1147 return Err(ValidationError::MessageHeaderInvalidFlags);
1148 }
1149 match BoundsCheckTestInterfaceMethod1Request::deserialize(buffer , handles) {
1150 Ok(value) => Ok(BoundsCheckTestInterfaceRequestOption::Bound sCheckTestInterfaceMethod1(value)),
1151 Err(err) => return Err(err),
1152 }
1153 }
1154 _ => Err(ValidationError::MessageHeaderUnknownMethod),
981 } 1155 }
982 } 1156 }
983 } 1157 }
984 1158
985 pub enum BoundsCheckTestInterfaceResponseOption { 1159 pub enum BoundsCheckTestInterfaceResponseOption {
986 BoundsCheckTestInterfaceMethod0(BoundsCheckTestInterfaceMethod0Response), 1160 BoundsCheckTestInterfaceMethod0(BoundsCheckTestInterfaceMethod0Response),
987 } 1161 }
988 1162
989 impl MojomMessageOption for BoundsCheckTestInterfaceResponseOption { 1163 impl MojomMessageOption for BoundsCheckTestInterfaceResponseOption {
990 fn decode_payload(ordinal: u32, buffer: &[u8], handles: Vec<UntypedHandle>) -> Self { 1164 fn decode_payload(header: MessageHeader,
991 match ordinal { 1165 buffer: &[u8],
992 BoundsCheckTestInterfaceMethod0::ORDINAL => BoundsCheckTestInterface ResponseOption::BoundsCheckTestInterfaceMethod0(BoundsCheckTestInterfaceMethod0R esponse::deserialize(buffer, handles)), 1166 handles: Vec<UntypedHandle>)
993 _ => { 1167 -> Result<Self, ValidationError> {
994 panic!("Unknown message found, or message has no response: {}", 1168 if header.flags != message::MESSAGE_HEADER_IS_RESPONSE {
995 ordinal) 1169 return Err(ValidationError::MessageHeaderInvalidFlags);
1170 }
1171 match header.name {
1172 BoundsCheckTestInterfaceMethod0::ORDINAL => {
1173 match BoundsCheckTestInterfaceMethod0Response::deserialize(buffe r, handles) {
1174 Ok(value) => Ok(BoundsCheckTestInterfaceResponseOption::Boun dsCheckTestInterfaceMethod0(value)),
1175 Err(err) => return Err(err),
1176 }
996 } 1177 }
1178 _ => Err(ValidationError::MessageHeaderUnknownMethod),
997 } 1179 }
998 } 1180 }
999 } 1181 }
1000 1182
1001 /// Message: BoundsCheckTestInterfaceMethod0 1183 /// Message: BoundsCheckTestInterfaceMethod0
1002 pub mod BoundsCheckTestInterfaceMethod0 { 1184 pub mod BoundsCheckTestInterfaceMethod0 {
1003 pub const ORDINAL: u32 = 0; 1185 pub const ORDINAL: u32 = 0;
1004 pub const MIN_VERSION: u32 = 0; 1186 pub const MIN_VERSION: u32 = 0;
1005 } 1187 }
1006 // -- BoundsCheckTestInterfaceMethod0Request -- 1188 // -- BoundsCheckTestInterfaceMethod0Request --
(...skipping 12 matching lines...) Expand all
1019 fn header_data(&self) -> DataHeaderValue { 1201 fn header_data(&self) -> DataHeaderValue {
1020 DataHeaderValue::Version(0) 1202 DataHeaderValue::Version(0)
1021 } 1203 }
1022 fn serialized_size(&self, _context: &Context) -> usize { 1204 fn serialized_size(&self, _context: &Context) -> usize {
1023 16 1205 16
1024 } 1206 }
1025 fn encode_value(self, encoder: &mut Encoder, context: Context) { 1207 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1026 MojomEncodable::encode(self.param0, encoder, context.clone()); 1208 MojomEncodable::encode(self.param0, encoder, context.clone());
1027 1209
1028 } 1210 }
1029 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 1211 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1030 // TODO(mknyszek): Validate bytes and version 1212 let version = {
1031 let (_bytes, version) = {
1032 let mut state = decoder.get_mut(&context); 1213 let mut state = decoder.get_mut(&context);
1033 let bytes = state.decode::<u32>(); 1214 match state.decode_struct_header(&BoundsCheckTestInterfaceMethod0Req uestVersions) {
1034 let version = state.decode::<u32>(); 1215 Ok(header) => header.data(),
1035 (bytes, version) 1216 Err(err) => return Err(err),
1217 }
1036 }; 1218 };
1037 let param0 = <u8>::decode(decoder, context.clone()); 1219 let param0 = match <u8>::decode(decoder, context.clone()) {
1038 BoundsCheckTestInterfaceMethod0Request { param0: param0 } 1220 Ok(value) => value,
1221 Err(err) => return Err(err),
1222 };
1223 Ok(BoundsCheckTestInterfaceMethod0Request { param0: param0 })
1039 } 1224 }
1040 } 1225 }
1041 1226
1042 impl MojomEncodable for BoundsCheckTestInterfaceMethod0Request { 1227 impl MojomEncodable for BoundsCheckTestInterfaceMethod0Request {
1043 impl_encodable_for_pointer!(); 1228 impl_encodable_for_pointer!();
1044 fn compute_size(&self, context: Context) -> usize { 1229 fn compute_size(&self, context: Context) -> usize {
1045 encoding::align_default(self.serialized_size(&context)) + 1230 encoding::align_default(self.serialized_size(&context)) +
1046 self.param0.compute_size(context.clone()) 1231 self.param0.compute_size(context.clone())
1047 } 1232 }
1048 } 1233 }
(...skipping 25 matching lines...) Expand all
1074 fn header_data(&self) -> DataHeaderValue { 1259 fn header_data(&self) -> DataHeaderValue {
1075 DataHeaderValue::Version(0) 1260 DataHeaderValue::Version(0)
1076 } 1261 }
1077 fn serialized_size(&self, _context: &Context) -> usize { 1262 fn serialized_size(&self, _context: &Context) -> usize {
1078 16 1263 16
1079 } 1264 }
1080 fn encode_value(self, encoder: &mut Encoder, context: Context) { 1265 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1081 MojomEncodable::encode(self.param0, encoder, context.clone()); 1266 MojomEncodable::encode(self.param0, encoder, context.clone());
1082 1267
1083 } 1268 }
1084 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 1269 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1085 // TODO(mknyszek): Validate bytes and version 1270 let version = {
1086 let (_bytes, version) = {
1087 let mut state = decoder.get_mut(&context); 1271 let mut state = decoder.get_mut(&context);
1088 let bytes = state.decode::<u32>(); 1272 match state.decode_struct_header(&BoundsCheckTestInterfaceMethod0Res ponseVersions) {
1089 let version = state.decode::<u32>(); 1273 Ok(header) => header.data(),
1090 (bytes, version) 1274 Err(err) => return Err(err),
1275 }
1091 }; 1276 };
1092 let param0 = <u8>::decode(decoder, context.clone()); 1277 let param0 = match <u8>::decode(decoder, context.clone()) {
1093 BoundsCheckTestInterfaceMethod0Response { param0: param0 } 1278 Ok(value) => value,
1279 Err(err) => return Err(err),
1280 };
1281 Ok(BoundsCheckTestInterfaceMethod0Response { param0: param0 })
1094 } 1282 }
1095 } 1283 }
1096 1284
1097 impl MojomEncodable for BoundsCheckTestInterfaceMethod0Response { 1285 impl MojomEncodable for BoundsCheckTestInterfaceMethod0Response {
1098 impl_encodable_for_pointer!(); 1286 impl_encodable_for_pointer!();
1099 fn compute_size(&self, context: Context) -> usize { 1287 fn compute_size(&self, context: Context) -> usize {
1100 encoding::align_default(self.serialized_size(&context)) + 1288 encoding::align_default(self.serialized_size(&context)) +
1101 self.param0.compute_size(context.clone()) 1289 self.param0.compute_size(context.clone())
1102 } 1290 }
1103 } 1291 }
(...skipping 29 matching lines...) Expand all
1133 fn header_data(&self) -> DataHeaderValue { 1321 fn header_data(&self) -> DataHeaderValue {
1134 DataHeaderValue::Version(0) 1322 DataHeaderValue::Version(0)
1135 } 1323 }
1136 fn serialized_size(&self, _context: &Context) -> usize { 1324 fn serialized_size(&self, _context: &Context) -> usize {
1137 16 1325 16
1138 } 1326 }
1139 fn encode_value(self, encoder: &mut Encoder, context: Context) { 1327 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1140 MojomEncodable::encode(self.param0, encoder, context.clone()); 1328 MojomEncodable::encode(self.param0, encoder, context.clone());
1141 1329
1142 } 1330 }
1143 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 1331 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1144 // TODO(mknyszek): Validate bytes and version 1332 let version = {
1145 let (_bytes, version) = {
1146 let mut state = decoder.get_mut(&context); 1333 let mut state = decoder.get_mut(&context);
1147 let bytes = state.decode::<u32>(); 1334 match state.decode_struct_header(&BoundsCheckTestInterfaceMethod1Req uestVersions) {
1148 let version = state.decode::<u32>(); 1335 Ok(header) => header.data(),
1149 (bytes, version) 1336 Err(err) => return Err(err),
1337 }
1150 }; 1338 };
1151 let param0 = <u8>::decode(decoder, context.clone()); 1339 let param0 = match <u8>::decode(decoder, context.clone()) {
1152 BoundsCheckTestInterfaceMethod1Request { param0: param0 } 1340 Ok(value) => value,
1341 Err(err) => return Err(err),
1342 };
1343 Ok(BoundsCheckTestInterfaceMethod1Request { param0: param0 })
1153 } 1344 }
1154 } 1345 }
1155 1346
1156 impl MojomEncodable for BoundsCheckTestInterfaceMethod1Request { 1347 impl MojomEncodable for BoundsCheckTestInterfaceMethod1Request {
1157 impl_encodable_for_pointer!(); 1348 impl_encodable_for_pointer!();
1158 fn compute_size(&self, context: Context) -> usize { 1349 fn compute_size(&self, context: Context) -> usize {
1159 encoding::align_default(self.serialized_size(&context)) + 1350 encoding::align_default(self.serialized_size(&context)) +
1160 self.param0.compute_size(context.clone()) 1351 self.param0.compute_size(context.clone())
1161 } 1352 }
1162 } 1353 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 // Enums 1460 // Enums
1270 1461
1271 1462
1272 // Constants 1463 // Constants
1273 1464
1274 1465
1275 pub trait ConformanceTestInterfaceRequest: MojomMessage {} 1466 pub trait ConformanceTestInterfaceRequest: MojomMessage {}
1276 pub trait ConformanceTestInterfaceResponse: MojomMessage {} 1467 pub trait ConformanceTestInterfaceResponse: MojomMessage {}
1277 1468
1278 pub enum ConformanceTestInterfaceRequestOption { 1469 pub enum ConformanceTestInterfaceRequestOption {
1470 ConformanceTestInterfaceMethod2(ConformanceTestInterfaceMethod2Request),
1471 ConformanceTestInterfaceMethod3(ConformanceTestInterfaceMethod3Request),
1472 ConformanceTestInterfaceMethod4(ConformanceTestInterfaceMethod4Request),
1279 ConformanceTestInterfaceMethod5(ConformanceTestInterfaceMethod5Request), 1473 ConformanceTestInterfaceMethod5(ConformanceTestInterfaceMethod5Request),
1280 ConformanceTestInterfaceMethod11(ConformanceTestInterfaceMethod11Request), 1474 ConformanceTestInterfaceMethod10(ConformanceTestInterfaceMethod10Request),
1281 ConformanceTestInterfaceMethod14(ConformanceTestInterfaceMethod14Request),
1282 ConformanceTestInterfaceMethod2(ConformanceTestInterfaceMethod2Request),
1283 ConformanceTestInterfaceMethod4(ConformanceTestInterfaceMethod4Request),
1284 ConformanceTestInterfaceMethod6(ConformanceTestInterfaceMethod6Request), 1475 ConformanceTestInterfaceMethod6(ConformanceTestInterfaceMethod6Request),
1285 ConformanceTestInterfaceMethod7(ConformanceTestInterfaceMethod7Request), 1476 ConformanceTestInterfaceMethod7(ConformanceTestInterfaceMethod7Request),
1286 ConformanceTestInterfaceMethod10(ConformanceTestInterfaceMethod10Request), 1477 ConformanceTestInterfaceMethod8(ConformanceTestInterfaceMethod8Request),
1478 ConformanceTestInterfaceMethod9(ConformanceTestInterfaceMethod9Request),
1479 ConformanceTestInterfaceMethod11(ConformanceTestInterfaceMethod11Request),
1287 ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod12Request), 1480 ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod12Request),
1288 ConformanceTestInterfaceMethod15(ConformanceTestInterfaceMethod15Request), 1481 ConformanceTestInterfaceMethod14(ConformanceTestInterfaceMethod14Request),
1289 ConformanceTestInterfaceMethod0(ConformanceTestInterfaceMethod0Request), 1482 ConformanceTestInterfaceMethod0(ConformanceTestInterfaceMethod0Request),
1290 ConformanceTestInterfaceMethod1(ConformanceTestInterfaceMethod1Request), 1483 ConformanceTestInterfaceMethod1(ConformanceTestInterfaceMethod1Request),
1291 ConformanceTestInterfaceMethod3(ConformanceTestInterfaceMethod3Request),
1292 ConformanceTestInterfaceMethod8(ConformanceTestInterfaceMethod8Request),
1293 ConformanceTestInterfaceMethod9(ConformanceTestInterfaceMethod9Request),
1294 ConformanceTestInterfaceMethod13(ConformanceTestInterfaceMethod13Request), 1484 ConformanceTestInterfaceMethod13(ConformanceTestInterfaceMethod13Request),
1485 ConformanceTestInterfaceMethod15(ConformanceTestInterfaceMethod15Request),
1295 } 1486 }
1296 1487
1297 impl MojomMessageOption for ConformanceTestInterfaceRequestOption { 1488 impl MojomMessageOption for ConformanceTestInterfaceRequestOption {
1298 fn decode_payload(ordinal: u32, buffer: &[u8], handles: Vec<UntypedHandle>) -> Self { 1489 fn decode_payload(header: MessageHeader,
1299 match ordinal { 1490 buffer: &[u8],
1300 ConformanceTestInterfaceMethod5::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod5(ConformanceTestInterfaceMethod5Re quest::deserialize(buffer, handles)), 1491 handles: Vec<UntypedHandle>)
1301 ConformanceTestInterfaceMethod11::ORDINAL => ConformanceTestInterfac eRequestOption::ConformanceTestInterfaceMethod11(ConformanceTestInterfaceMethod1 1Request::deserialize(buffer, handles)), 1492 -> Result<Self, ValidationError> {
1302 ConformanceTestInterfaceMethod14::ORDINAL => ConformanceTestInterfac eRequestOption::ConformanceTestInterfaceMethod14(ConformanceTestInterfaceMethod1 4Request::deserialize(buffer, handles)), 1493 match header.name {
1303 ConformanceTestInterfaceMethod2::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod2(ConformanceTestInterfaceMethod2Re quest::deserialize(buffer, handles)), 1494 ConformanceTestInterfaceMethod2::ORDINAL => {
1304 ConformanceTestInterfaceMethod4::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod4(ConformanceTestInterfaceMethod4Re quest::deserialize(buffer, handles)), 1495 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1305 ConformanceTestInterfaceMethod6::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod6(ConformanceTestInterfaceMethod6Re quest::deserialize(buffer, handles)), 1496 return Err(ValidationError::MessageHeaderInvalidFlags);
1306 ConformanceTestInterfaceMethod7::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod7(ConformanceTestInterfaceMethod7Re quest::deserialize(buffer, handles)), 1497 }
1307 ConformanceTestInterfaceMethod10::ORDINAL => ConformanceTestInterfac eRequestOption::ConformanceTestInterfaceMethod10(ConformanceTestInterfaceMethod1 0Request::deserialize(buffer, handles)), 1498 match ConformanceTestInterfaceMethod2Request::deserialize(buffer , handles) {
1308 ConformanceTestInterfaceMethod12::ORDINAL => ConformanceTestInterfac eRequestOption::ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod1 2Request::deserialize(buffer, handles)), 1499 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod2(value)),
1309 ConformanceTestInterfaceMethod15::ORDINAL => ConformanceTestInterfac eRequestOption::ConformanceTestInterfaceMethod15(ConformanceTestInterfaceMethod1 5Request::deserialize(buffer, handles)), 1500 Err(err) => return Err(err),
1310 ConformanceTestInterfaceMethod0::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod0(ConformanceTestInterfaceMethod0Re quest::deserialize(buffer, handles)), 1501 }
1311 ConformanceTestInterfaceMethod1::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod1(ConformanceTestInterfaceMethod1Re quest::deserialize(buffer, handles)), 1502 }
1312 ConformanceTestInterfaceMethod3::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod3(ConformanceTestInterfaceMethod3Re quest::deserialize(buffer, handles)), 1503 ConformanceTestInterfaceMethod3::ORDINAL => {
1313 ConformanceTestInterfaceMethod8::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod8(ConformanceTestInterfaceMethod8Re quest::deserialize(buffer, handles)), 1504 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1314 ConformanceTestInterfaceMethod9::ORDINAL => ConformanceTestInterface RequestOption::ConformanceTestInterfaceMethod9(ConformanceTestInterfaceMethod9Re quest::deserialize(buffer, handles)), 1505 return Err(ValidationError::MessageHeaderInvalidFlags);
1315 ConformanceTestInterfaceMethod13::ORDINAL => ConformanceTestInterfac eRequestOption::ConformanceTestInterfaceMethod13(ConformanceTestInterfaceMethod1 3Request::deserialize(buffer, handles)), 1506 }
1316 _ => panic!("Unknown message found: {}", ordinal), 1507 match ConformanceTestInterfaceMethod3Request::deserialize(buffer , handles) {
1508 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod3(value)),
1509 Err(err) => return Err(err),
1510 }
1511 }
1512 ConformanceTestInterfaceMethod4::ORDINAL => {
1513 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1514 return Err(ValidationError::MessageHeaderInvalidFlags);
1515 }
1516 match ConformanceTestInterfaceMethod4Request::deserialize(buffer , handles) {
1517 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod4(value)),
1518 Err(err) => return Err(err),
1519 }
1520 }
1521 ConformanceTestInterfaceMethod5::ORDINAL => {
1522 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1523 return Err(ValidationError::MessageHeaderInvalidFlags);
1524 }
1525 match ConformanceTestInterfaceMethod5Request::deserialize(buffer , handles) {
1526 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod5(value)),
1527 Err(err) => return Err(err),
1528 }
1529 }
1530 ConformanceTestInterfaceMethod10::ORDINAL => {
1531 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1532 return Err(ValidationError::MessageHeaderInvalidFlags);
1533 }
1534 match ConformanceTestInterfaceMethod10Request::deserialize(buffe r, handles) {
1535 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod10(value)),
1536 Err(err) => return Err(err),
1537 }
1538 }
1539 ConformanceTestInterfaceMethod6::ORDINAL => {
1540 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1541 return Err(ValidationError::MessageHeaderInvalidFlags);
1542 }
1543 match ConformanceTestInterfaceMethod6Request::deserialize(buffer , handles) {
1544 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod6(value)),
1545 Err(err) => return Err(err),
1546 }
1547 }
1548 ConformanceTestInterfaceMethod7::ORDINAL => {
1549 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1550 return Err(ValidationError::MessageHeaderInvalidFlags);
1551 }
1552 match ConformanceTestInterfaceMethod7Request::deserialize(buffer , handles) {
1553 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod7(value)),
1554 Err(err) => return Err(err),
1555 }
1556 }
1557 ConformanceTestInterfaceMethod8::ORDINAL => {
1558 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1559 return Err(ValidationError::MessageHeaderInvalidFlags);
1560 }
1561 match ConformanceTestInterfaceMethod8Request::deserialize(buffer , handles) {
1562 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod8(value)),
1563 Err(err) => return Err(err),
1564 }
1565 }
1566 ConformanceTestInterfaceMethod9::ORDINAL => {
1567 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1568 return Err(ValidationError::MessageHeaderInvalidFlags);
1569 }
1570 match ConformanceTestInterfaceMethod9Request::deserialize(buffer , handles) {
1571 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod9(value)),
1572 Err(err) => return Err(err),
1573 }
1574 }
1575 ConformanceTestInterfaceMethod11::ORDINAL => {
1576 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1577 return Err(ValidationError::MessageHeaderInvalidFlags);
1578 }
1579 match ConformanceTestInterfaceMethod11Request::deserialize(buffe r, handles) {
1580 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod11(value)),
1581 Err(err) => return Err(err),
1582 }
1583 }
1584 ConformanceTestInterfaceMethod12::ORDINAL => {
1585 if header.flags != message::MESSAGE_HEADER_EXPECT_RESPONSE {
1586 return Err(ValidationError::MessageHeaderInvalidFlags);
1587 }
1588 match ConformanceTestInterfaceMethod12Request::deserialize(buffe r, handles) {
1589 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod12(value)),
1590 Err(err) => return Err(err),
1591 }
1592 }
1593 ConformanceTestInterfaceMethod14::ORDINAL => {
1594 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1595 return Err(ValidationError::MessageHeaderInvalidFlags);
1596 }
1597 match ConformanceTestInterfaceMethod14Request::deserialize(buffe r, handles) {
1598 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod14(value)),
1599 Err(err) => return Err(err),
1600 }
1601 }
1602 ConformanceTestInterfaceMethod0::ORDINAL => {
1603 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1604 return Err(ValidationError::MessageHeaderInvalidFlags);
1605 }
1606 match ConformanceTestInterfaceMethod0Request::deserialize(buffer , handles) {
1607 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod0(value)),
1608 Err(err) => return Err(err),
1609 }
1610 }
1611 ConformanceTestInterfaceMethod1::ORDINAL => {
1612 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1613 return Err(ValidationError::MessageHeaderInvalidFlags);
1614 }
1615 match ConformanceTestInterfaceMethod1Request::deserialize(buffer , handles) {
1616 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod1(value)),
1617 Err(err) => return Err(err),
1618 }
1619 }
1620 ConformanceTestInterfaceMethod13::ORDINAL => {
1621 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1622 return Err(ValidationError::MessageHeaderInvalidFlags);
1623 }
1624 match ConformanceTestInterfaceMethod13Request::deserialize(buffe r, handles) {
1625 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod13(value)),
1626 Err(err) => return Err(err),
1627 }
1628 }
1629 ConformanceTestInterfaceMethod15::ORDINAL => {
1630 if header.flags != message::MESSAGE_HEADER_NO_FLAG {
1631 return Err(ValidationError::MessageHeaderInvalidFlags);
1632 }
1633 match ConformanceTestInterfaceMethod15Request::deserialize(buffe r, handles) {
1634 Ok(value) => Ok(ConformanceTestInterfaceRequestOption::Confo rmanceTestInterfaceMethod15(value)),
1635 Err(err) => return Err(err),
1636 }
1637 }
1638 _ => Err(ValidationError::MessageHeaderUnknownMethod),
1317 } 1639 }
1318 } 1640 }
1319 } 1641 }
1320 1642
1321 pub enum ConformanceTestInterfaceResponseOption { 1643 pub enum ConformanceTestInterfaceResponseOption {
1322 ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod12Response), 1644 ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod12Response),
1323 } 1645 }
1324 1646
1325 impl MojomMessageOption for ConformanceTestInterfaceResponseOption { 1647 impl MojomMessageOption for ConformanceTestInterfaceResponseOption {
1326 fn decode_payload(ordinal: u32, buffer: &[u8], handles: Vec<UntypedHandle>) -> Self { 1648 fn decode_payload(header: MessageHeader,
1327 match ordinal { 1649 buffer: &[u8],
1328 ConformanceTestInterfaceMethod12::ORDINAL => ConformanceTestInterfac eResponseOption::ConformanceTestInterfaceMethod12(ConformanceTestInterfaceMethod 12Response::deserialize(buffer, handles)), 1650 handles: Vec<UntypedHandle>)
1329 _ => { 1651 -> Result<Self, ValidationError> {
1330 panic!("Unknown message found, or message has no response: {}", 1652 if header.flags != message::MESSAGE_HEADER_IS_RESPONSE {
1331 ordinal) 1653 return Err(ValidationError::MessageHeaderInvalidFlags);
1654 }
1655 match header.name {
1656 ConformanceTestInterfaceMethod12::ORDINAL => {
1657 match ConformanceTestInterfaceMethod12Response::deserialize(buff er, handles) {
1658 Ok(value) => Ok(ConformanceTestInterfaceResponseOption::Conf ormanceTestInterfaceMethod12(value)),
1659 Err(err) => return Err(err),
1660 }
1332 } 1661 }
1662 _ => Err(ValidationError::MessageHeaderUnknownMethod),
1333 } 1663 }
1334 } 1664 }
1335 } 1665 }
1336 1666
1337 /// Message: ConformanceTestInterfaceMethod5 1667 /// Message: ConformanceTestInterfaceMethod2
1338 pub mod ConformanceTestInterfaceMethod5 { 1668 pub mod ConformanceTestInterfaceMethod2 {
1339 pub const ORDINAL: u32 = 5; 1669 pub const ORDINAL: u32 = 2;
1340 pub const MIN_VERSION: u32 = 0; 1670 pub const MIN_VERSION: u32 = 0;
1341 } 1671 }
1342 // -- ConformanceTestInterfaceMethod5Request -- 1672 // -- ConformanceTestInterfaceMethod2Request --
1343 1673
1344 // Constants 1674 // Constants
1345 // Enums 1675 // Enums
1346 // Struct version information 1676 // Struct version information
1347 const ConformanceTestInterfaceMethod5RequestVersions: [(u32, u32); 1] = [(0, 24) ]; 1677 const ConformanceTestInterfaceMethod2RequestVersions: [(u32, u32); 1] = [(0, 24) ];
1348 1678
1349 // Struct definition 1679 // Struct definition
1350 pub struct ConformanceTestInterfaceMethod5Request { 1680 pub struct ConformanceTestInterfaceMethod2Request {
1351 pub param0: StructE, 1681 pub param0: StructB,
1352 pub param1: system::data_pipe::Producer<u8>, 1682 pub param1: StructA,
1353 } 1683 }
1354 1684
1355 impl MojomPointer for ConformanceTestInterfaceMethod5Request { 1685 impl MojomPointer for ConformanceTestInterfaceMethod2Request {
1356 fn header_data(&self) -> DataHeaderValue { 1686 fn header_data(&self) -> DataHeaderValue {
1357 DataHeaderValue::Version(0) 1687 DataHeaderValue::Version(0)
1358 } 1688 }
1359 fn serialized_size(&self, _context: &Context) -> usize { 1689 fn serialized_size(&self, _context: &Context) -> usize {
1360 24 1690 24
1361 } 1691 }
1362 fn encode_value(self, encoder: &mut Encoder, context: Context) { 1692 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1363 MojomEncodable::encode(self.param0, encoder, context.clone()); 1693 MojomEncodable::encode(self.param0, encoder, context.clone());
1364 MojomEncodable::encode(self.param1, encoder, context.clone()); 1694 MojomEncodable::encode(self.param1, encoder, context.clone());
1365 1695
1366 } 1696 }
1367 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 1697 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1368 // TODO(mknyszek): Validate bytes and version 1698 let version = {
1369 let (_bytes, version) = {
1370 let mut state = decoder.get_mut(&context); 1699 let mut state = decoder.get_mut(&context);
1371 let bytes = state.decode::<u32>(); 1700 match state.decode_struct_header(&ConformanceTestInterfaceMethod2Req uestVersions) {
1372 let version = state.decode::<u32>(); 1701 Ok(header) => header.data(),
1373 (bytes, version) 1702 Err(err) => return Err(err),
1703 }
1374 }; 1704 };
1375 let param0 = <StructE>::decode(decoder, context.clone()); 1705 let param0 = match <StructB>::decode(decoder, context.clone()) {
1376 let param1 = <system::data_pipe::Producer<u8>>::decode(decoder, context. clone()); 1706 Ok(value) => value,
1377 ConformanceTestInterfaceMethod5Request { 1707 Err(err) => return Err(err),
1708 };
1709 let param1 = match <StructA>::decode(decoder, context.clone()) {
1710 Ok(value) => value,
1711 Err(err) => return Err(err),
1712 };
1713 Ok(ConformanceTestInterfaceMethod2Request {
1378 param0: param0, 1714 param0: param0,
1379 param1: param1, 1715 param1: param1,
1380 } 1716 })
1381 } 1717 }
1382 } 1718 }
1383 1719
1384 impl MojomEncodable for ConformanceTestInterfaceMethod5Request { 1720 impl MojomEncodable for ConformanceTestInterfaceMethod2Request {
1385 impl_encodable_for_pointer!(); 1721 impl_encodable_for_pointer!();
1386 fn compute_size(&self, context: Context) -> usize { 1722 fn compute_size(&self, context: Context) -> usize {
1387 encoding::align_default(self.serialized_size(&context)) + 1723 encoding::align_default(self.serialized_size(&context)) +
1388 self.param0.compute_size(context.clone()) + 1724 self.param0.compute_size(context.clone()) +
1389 self.param1.compute_size(context.clone()) 1725 self.param1.compute_size(context.clone())
1390 } 1726 }
1391 } 1727 }
1392 1728
1393 impl MojomStruct for ConformanceTestInterfaceMethod5Request {} 1729 impl MojomStruct for ConformanceTestInterfaceMethod2Request {}
1394 impl MojomMessage for ConformanceTestInterfaceMethod5Request { 1730 impl MojomMessage for ConformanceTestInterfaceMethod2Request {
1395 fn create_header() -> MessageHeader { 1731 fn create_header() -> MessageHeader {
1396 MessageHeader::new(ConformanceTestInterface::VERSION, 1732 MessageHeader::new(ConformanceTestInterface::VERSION,
1397 ConformanceTestInterfaceMethod5::ORDINAL, 1733 ConformanceTestInterfaceMethod2::ORDINAL,
1398 message::MESSAGE_HEADER_NO_FLAG) 1734 message::MESSAGE_HEADER_NO_FLAG)
1399 1735
1400 } 1736 }
1401 } 1737 }
1402 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod5Request {} 1738 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod2Request {}
1403 1739
1404 /// Message: ConformanceTestInterfaceMethod11 1740 /// Message: ConformanceTestInterfaceMethod3
1405 pub mod ConformanceTestInterfaceMethod11 { 1741 pub mod ConformanceTestInterfaceMethod3 {
1406 pub const ORDINAL: u32 = 11; 1742 pub const ORDINAL: u32 = 3;
1407 pub const MIN_VERSION: u32 = 0; 1743 pub const MIN_VERSION: u32 = 0;
1408 } 1744 }
1409 // -- ConformanceTestInterfaceMethod11Request -- 1745 // -- ConformanceTestInterfaceMethod3Request --
1410 1746
1411 // Constants 1747 // Constants
1412 // Enums 1748 // Enums
1413 // Struct version information 1749 // Struct version information
1414 const ConformanceTestInterfaceMethod11RequestVersions: [(u32, u32); 1] = [(0, 16 )]; 1750 const ConformanceTestInterfaceMethod3RequestVersions: [(u32, u32); 1] = [(0, 16) ];
1415 1751
1416 // Struct definition 1752 // Struct definition
1417 pub struct ConformanceTestInterfaceMethod11Request { 1753 pub struct ConformanceTestInterfaceMethod3Request {
1418 pub param0: StructG, 1754 pub param0: Vec<bool>,
1419 } 1755 }
1420 1756
1421 impl MojomPointer for ConformanceTestInterfaceMethod11Request { 1757 impl MojomPointer for ConformanceTestInterfaceMethod3Request {
1422 fn header_data(&self) -> DataHeaderValue { 1758 fn header_data(&self) -> DataHeaderValue {
1423 DataHeaderValue::Version(0) 1759 DataHeaderValue::Version(0)
1424 } 1760 }
1425 fn serialized_size(&self, _context: &Context) -> usize { 1761 fn serialized_size(&self, _context: &Context) -> usize {
1426 16 1762 16
1427 } 1763 }
1428 fn encode_value(self, encoder: &mut Encoder, context: Context) { 1764 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1429 MojomEncodable::encode(self.param0, encoder, context.clone()); 1765 MojomEncodable::encode(self.param0, encoder, context.clone());
1430 1766
1431 } 1767 }
1432 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 1768 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1433 // TODO(mknyszek): Validate bytes and version 1769 let version = {
1434 let (_bytes, version) = {
1435 let mut state = decoder.get_mut(&context); 1770 let mut state = decoder.get_mut(&context);
1436 let bytes = state.decode::<u32>(); 1771 match state.decode_struct_header(&ConformanceTestInterfaceMethod3Req uestVersions) {
1437 let version = state.decode::<u32>(); 1772 Ok(header) => header.data(),
1438 (bytes, version) 1773 Err(err) => return Err(err),
1774 }
1439 }; 1775 };
1440 let param0 = <StructG>::decode(decoder, context.clone()); 1776 let param0 = match <Vec<bool>>::decode(decoder, context.clone()) {
1441 ConformanceTestInterfaceMethod11Request { param0: param0 } 1777 Ok(value) => value,
1778 Err(err) => return Err(err),
1779 };
1780 Ok(ConformanceTestInterfaceMethod3Request { param0: param0 })
1442 } 1781 }
1443 } 1782 }
1444 1783
1445 impl MojomEncodable for ConformanceTestInterfaceMethod11Request { 1784 impl MojomEncodable for ConformanceTestInterfaceMethod3Request {
1446 impl_encodable_for_pointer!(); 1785 impl_encodable_for_pointer!();
1447 fn compute_size(&self, context: Context) -> usize { 1786 fn compute_size(&self, context: Context) -> usize {
1448 encoding::align_default(self.serialized_size(&context)) + 1787 encoding::align_default(self.serialized_size(&context)) +
1449 self.param0.compute_size(context.clone()) 1788 self.param0.compute_size(context.clone())
1450 } 1789 }
1451 } 1790 }
1452 1791
1453 impl MojomStruct for ConformanceTestInterfaceMethod11Request {} 1792 impl MojomStruct for ConformanceTestInterfaceMethod3Request {}
1454 impl MojomMessage for ConformanceTestInterfaceMethod11Request { 1793 impl MojomMessage for ConformanceTestInterfaceMethod3Request {
1455 fn create_header() -> MessageHeader { 1794 fn create_header() -> MessageHeader {
1456 MessageHeader::new(ConformanceTestInterface::VERSION, 1795 MessageHeader::new(ConformanceTestInterface::VERSION,
1457 ConformanceTestInterfaceMethod11::ORDINAL, 1796 ConformanceTestInterfaceMethod3::ORDINAL,
1458 message::MESSAGE_HEADER_NO_FLAG) 1797 message::MESSAGE_HEADER_NO_FLAG)
1459 1798
1460 } 1799 }
1461 } 1800 }
1462 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod11Request {} 1801 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod3Request {}
1463 1802
1464 /// Message: ConformanceTestInterfaceMethod14 1803 /// Message: ConformanceTestInterfaceMethod4
1465 pub mod ConformanceTestInterfaceMethod14 { 1804 pub mod ConformanceTestInterfaceMethod4 {
1466 pub const ORDINAL: u32 = 14; 1805 pub const ORDINAL: u32 = 4;
1467 pub const MIN_VERSION: u32 = 0; 1806 pub const MIN_VERSION: u32 = 0;
1468 } 1807 }
1469 // -- ConformanceTestInterfaceMethod14Request -- 1808 // -- ConformanceTestInterfaceMethod4Request --
1470 1809
1471 // Constants 1810 // Constants
1472 // Enums 1811 // Enums
1473 // Struct version information 1812 // Struct version information
1474 const ConformanceTestInterfaceMethod14RequestVersions: [(u32, u32); 1] = [(0, 24 )]; 1813 const ConformanceTestInterfaceMethod4RequestVersions: [(u32, u32); 1] = [(0, 24) ];
1475 1814
1476 // Struct definition 1815 // Struct definition
1477 pub struct ConformanceTestInterfaceMethod14Request { 1816 pub struct ConformanceTestInterfaceMethod4Request {
1478 pub param0: UnionA, 1817 pub param0: StructC,
1818 pub param1: Vec<u8>,
1479 } 1819 }
1480 1820
1481 impl MojomPointer for ConformanceTestInterfaceMethod14Request { 1821 impl MojomPointer for ConformanceTestInterfaceMethod4Request {
1482 fn header_data(&self) -> DataHeaderValue { 1822 fn header_data(&self) -> DataHeaderValue {
1483 DataHeaderValue::Version(0) 1823 DataHeaderValue::Version(0)
1484 } 1824 }
1485 fn serialized_size(&self, _context: &Context) -> usize { 1825 fn serialized_size(&self, _context: &Context) -> usize {
1486 24 1826 24
1487 } 1827 }
1488 fn encode_value(self, encoder: &mut Encoder, context: Context) { 1828 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1489 MojomEncodable::encode(self.param0, encoder, context.clone()); 1829 MojomEncodable::encode(self.param0, encoder, context.clone());
1830 MojomEncodable::encode(self.param1, encoder, context.clone());
1490 1831
1491 } 1832 }
1492 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 1833 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1493 // TODO(mknyszek): Validate bytes and version 1834 let version = {
1494 let (_bytes, version) = {
1495 let mut state = decoder.get_mut(&context); 1835 let mut state = decoder.get_mut(&context);
1496 let bytes = state.decode::<u32>(); 1836 match state.decode_struct_header(&ConformanceTestInterfaceMethod4Req uestVersions) {
1497 let version = state.decode::<u32>(); 1837 Ok(header) => header.data(),
1498 (bytes, version) 1838 Err(err) => return Err(err),
1839 }
1499 }; 1840 };
1500 let param0 = <UnionA>::decode(decoder, context.clone()); 1841 let param0 = match <StructC>::decode(decoder, context.clone()) {
1501 ConformanceTestInterfaceMethod14Request { param0: param0 } 1842 Ok(value) => value,
1843 Err(err) => return Err(err),
1844 };
1845 let param1 = match <Vec<u8>>::decode(decoder, context.clone()) {
1846 Ok(value) => value,
1847 Err(err) => return Err(err),
1848 };
1849 Ok(ConformanceTestInterfaceMethod4Request {
1850 param0: param0,
1851 param1: param1,
1852 })
1502 } 1853 }
1503 } 1854 }
1504 1855
1505 impl MojomEncodable for ConformanceTestInterfaceMethod14Request { 1856 impl MojomEncodable for ConformanceTestInterfaceMethod4Request {
1506 impl_encodable_for_pointer!(); 1857 impl_encodable_for_pointer!();
1507 fn compute_size(&self, context: Context) -> usize { 1858 fn compute_size(&self, context: Context) -> usize {
1508 encoding::align_default(self.serialized_size(&context)) + 1859 encoding::align_default(self.serialized_size(&context)) +
1509 self.param0.compute_size(context.clone()) 1860 self.param0.compute_size(context.clone()) +
1861 self.param1.compute_size(context.clone())
1510 } 1862 }
1511 } 1863 }
1512 1864
1513 impl MojomStruct for ConformanceTestInterfaceMethod14Request {} 1865 impl MojomStruct for ConformanceTestInterfaceMethod4Request {}
1514 impl MojomMessage for ConformanceTestInterfaceMethod14Request { 1866 impl MojomMessage for ConformanceTestInterfaceMethod4Request {
1515 fn create_header() -> MessageHeader { 1867 fn create_header() -> MessageHeader {
1516 MessageHeader::new(ConformanceTestInterface::VERSION, 1868 MessageHeader::new(ConformanceTestInterface::VERSION,
1517 ConformanceTestInterfaceMethod14::ORDINAL, 1869 ConformanceTestInterfaceMethod4::ORDINAL,
1518 message::MESSAGE_HEADER_NO_FLAG) 1870 message::MESSAGE_HEADER_NO_FLAG)
1519 1871
1520 } 1872 }
1521 } 1873 }
1522 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod14Request {} 1874 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod4Request {}
1523 1875
1524 /// Message: ConformanceTestInterfaceMethod2 1876 /// Message: ConformanceTestInterfaceMethod5
1525 pub mod ConformanceTestInterfaceMethod2 { 1877 pub mod ConformanceTestInterfaceMethod5 {
1526 pub const ORDINAL: u32 = 2; 1878 pub const ORDINAL: u32 = 5;
1527 pub const MIN_VERSION: u32 = 0; 1879 pub const MIN_VERSION: u32 = 0;
1528 } 1880 }
1529 // -- ConformanceTestInterfaceMethod2Request -- 1881 // -- ConformanceTestInterfaceMethod5Request --
1530 1882
1531 // Constants 1883 // Constants
1532 // Enums 1884 // Enums
1533 // Struct version information 1885 // Struct version information
1534 const ConformanceTestInterfaceMethod2RequestVersions: [(u32, u32); 1] = [(0, 24) ]; 1886 const ConformanceTestInterfaceMethod5RequestVersions: [(u32, u32); 1] = [(0, 24) ];
1535 1887
1536 // Struct definition 1888 // Struct definition
1537 pub struct ConformanceTestInterfaceMethod2Request { 1889 pub struct ConformanceTestInterfaceMethod5Request {
1538 pub param0: StructB, 1890 pub param0: StructE,
1539 pub param1: StructA, 1891 pub param1: system::data_pipe::Producer<u8>,
1540 } 1892 }
1541 1893
1542 impl MojomPointer for ConformanceTestInterfaceMethod2Request { 1894 impl MojomPointer for ConformanceTestInterfaceMethod5Request {
1543 fn header_data(&self) -> DataHeaderValue { 1895 fn header_data(&self) -> DataHeaderValue {
1544 DataHeaderValue::Version(0) 1896 DataHeaderValue::Version(0)
1545 } 1897 }
1546 fn serialized_size(&self, _context: &Context) -> usize { 1898 fn serialized_size(&self, _context: &Context) -> usize {
1547 24 1899 24
1548 } 1900 }
1549 fn encode_value(self, encoder: &mut Encoder, context: Context) { 1901 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1550 MojomEncodable::encode(self.param0, encoder, context.clone()); 1902 MojomEncodable::encode(self.param0, encoder, context.clone());
1551 MojomEncodable::encode(self.param1, encoder, context.clone()); 1903 MojomEncodable::encode(self.param1, encoder, context.clone());
1552 1904
1553 } 1905 }
1554 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 1906 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1555 // TODO(mknyszek): Validate bytes and version 1907 let version = {
1556 let (_bytes, version) = {
1557 let mut state = decoder.get_mut(&context); 1908 let mut state = decoder.get_mut(&context);
1558 let bytes = state.decode::<u32>(); 1909 match state.decode_struct_header(&ConformanceTestInterfaceMethod5Req uestVersions) {
1559 let version = state.decode::<u32>(); 1910 Ok(header) => header.data(),
1560 (bytes, version) 1911 Err(err) => return Err(err),
1912 }
1561 }; 1913 };
1562 let param0 = <StructB>::decode(decoder, context.clone()); 1914 let param0 = match <StructE>::decode(decoder, context.clone()) {
1563 let param1 = <StructA>::decode(decoder, context.clone()); 1915 Ok(value) => value,
1564 ConformanceTestInterfaceMethod2Request { 1916 Err(err) => return Err(err),
1917 };
1918 let param1 =
1919 match <system::data_pipe::Producer<u8>>::decode(decoder, context.clo ne()) {
1920 Ok(value) => value,
1921 Err(err) => return Err(err),
1922 };
1923 Ok(ConformanceTestInterfaceMethod5Request {
1565 param0: param0, 1924 param0: param0,
1566 param1: param1, 1925 param1: param1,
1567 } 1926 })
1568 } 1927 }
1569 } 1928 }
1570 1929
1571 impl MojomEncodable for ConformanceTestInterfaceMethod2Request { 1930 impl MojomEncodable for ConformanceTestInterfaceMethod5Request {
1572 impl_encodable_for_pointer!(); 1931 impl_encodable_for_pointer!();
1573 fn compute_size(&self, context: Context) -> usize { 1932 fn compute_size(&self, context: Context) -> usize {
1574 encoding::align_default(self.serialized_size(&context)) + 1933 encoding::align_default(self.serialized_size(&context)) +
1575 self.param0.compute_size(context.clone()) + 1934 self.param0.compute_size(context.clone()) +
1576 self.param1.compute_size(context.clone()) 1935 self.param1.compute_size(context.clone())
1577 } 1936 }
1578 } 1937 }
1579 1938
1580 impl MojomStruct for ConformanceTestInterfaceMethod2Request {} 1939 impl MojomStruct for ConformanceTestInterfaceMethod5Request {}
1581 impl MojomMessage for ConformanceTestInterfaceMethod2Request { 1940 impl MojomMessage for ConformanceTestInterfaceMethod5Request {
1582 fn create_header() -> MessageHeader { 1941 fn create_header() -> MessageHeader {
1583 MessageHeader::new(ConformanceTestInterface::VERSION, 1942 MessageHeader::new(ConformanceTestInterface::VERSION,
1584 ConformanceTestInterfaceMethod2::ORDINAL, 1943 ConformanceTestInterfaceMethod5::ORDINAL,
1585 message::MESSAGE_HEADER_NO_FLAG) 1944 message::MESSAGE_HEADER_NO_FLAG)
1586 1945
1587 } 1946 }
1588 } 1947 }
1589 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod2Request {} 1948 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod5Request {}
1590 1949
1591 /// Message: ConformanceTestInterfaceMethod4 1950 /// Message: ConformanceTestInterfaceMethod10
1592 pub mod ConformanceTestInterfaceMethod4 { 1951 pub mod ConformanceTestInterfaceMethod10 {
1593 pub const ORDINAL: u32 = 4; 1952 pub const ORDINAL: u32 = 10;
1594 pub const MIN_VERSION: u32 = 0; 1953 pub const MIN_VERSION: u32 = 0;
1595 } 1954 }
1596 // -- ConformanceTestInterfaceMethod4Request -- 1955 // -- ConformanceTestInterfaceMethod10Request --
1597 1956
1598 // Constants 1957 // Constants
1599 // Enums 1958 // Enums
1600 // Struct version information 1959 // Struct version information
1601 const ConformanceTestInterfaceMethod4RequestVersions: [(u32, u32); 1] = [(0, 24) ]; 1960 const ConformanceTestInterfaceMethod10RequestVersions: [(u32, u32); 1] = [(0, 16 )];
1602 1961
1603 // Struct definition 1962 // Struct definition
1604 pub struct ConformanceTestInterfaceMethod4Request { 1963 pub struct ConformanceTestInterfaceMethod10Request {
1605 pub param0: StructC, 1964 pub param0: HashMap<String, u8>,
1606 pub param1: Vec<u8>,
1607 } 1965 }
1608 1966
1609 impl MojomPointer for ConformanceTestInterfaceMethod4Request { 1967 impl MojomPointer for ConformanceTestInterfaceMethod10Request {
1610 fn header_data(&self) -> DataHeaderValue { 1968 fn header_data(&self) -> DataHeaderValue {
1611 DataHeaderValue::Version(0) 1969 DataHeaderValue::Version(0)
1612 } 1970 }
1613 fn serialized_size(&self, _context: &Context) -> usize { 1971 fn serialized_size(&self, _context: &Context) -> usize {
1614 24 1972 16
1615 } 1973 }
1616 fn encode_value(self, encoder: &mut Encoder, context: Context) { 1974 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1617 MojomEncodable::encode(self.param0, encoder, context.clone()); 1975 MojomEncodable::encode(self.param0, encoder, context.clone());
1618 MojomEncodable::encode(self.param1, encoder, context.clone());
1619 1976
1620 } 1977 }
1621 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 1978 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1622 // TODO(mknyszek): Validate bytes and version 1979 let version = {
1623 let (_bytes, version) = {
1624 let mut state = decoder.get_mut(&context); 1980 let mut state = decoder.get_mut(&context);
1625 let bytes = state.decode::<u32>(); 1981 match state.decode_struct_header(&ConformanceTestInterfaceMethod10Re questVersions) {
1626 let version = state.decode::<u32>(); 1982 Ok(header) => header.data(),
1627 (bytes, version) 1983 Err(err) => return Err(err),
1984 }
1628 }; 1985 };
1629 let param0 = <StructC>::decode(decoder, context.clone()); 1986 let param0 = match <HashMap<String, u8>>::decode(decoder, context.clone( )) {
1630 let param1 = <Vec<u8>>::decode(decoder, context.clone()); 1987 Ok(value) => value,
1631 ConformanceTestInterfaceMethod4Request { 1988 Err(err) => return Err(err),
1632 param0: param0, 1989 };
1633 param1: param1, 1990 Ok(ConformanceTestInterfaceMethod10Request { param0: param0 })
1634 }
1635 } 1991 }
1636 } 1992 }
1637 1993
1638 impl MojomEncodable for ConformanceTestInterfaceMethod4Request { 1994 impl MojomEncodable for ConformanceTestInterfaceMethod10Request {
1639 impl_encodable_for_pointer!(); 1995 impl_encodable_for_pointer!();
1640 fn compute_size(&self, context: Context) -> usize { 1996 fn compute_size(&self, context: Context) -> usize {
1641 encoding::align_default(self.serialized_size(&context)) + 1997 encoding::align_default(self.serialized_size(&context)) +
1642 self.param0.compute_size(context.clone()) + 1998 self.param0.compute_size(context.clone())
1643 self.param1.compute_size(context.clone())
1644 } 1999 }
1645 } 2000 }
1646 2001
1647 impl MojomStruct for ConformanceTestInterfaceMethod4Request {} 2002 impl MojomStruct for ConformanceTestInterfaceMethod10Request {}
1648 impl MojomMessage for ConformanceTestInterfaceMethod4Request { 2003 impl MojomMessage for ConformanceTestInterfaceMethod10Request {
1649 fn create_header() -> MessageHeader { 2004 fn create_header() -> MessageHeader {
1650 MessageHeader::new(ConformanceTestInterface::VERSION, 2005 MessageHeader::new(ConformanceTestInterface::VERSION,
1651 ConformanceTestInterfaceMethod4::ORDINAL, 2006 ConformanceTestInterfaceMethod10::ORDINAL,
1652 message::MESSAGE_HEADER_NO_FLAG) 2007 message::MESSAGE_HEADER_NO_FLAG)
1653 2008
1654 } 2009 }
1655 } 2010 }
1656 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod4Request {} 2011 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod10Request {}
1657 2012
1658 /// Message: ConformanceTestInterfaceMethod6 2013 /// Message: ConformanceTestInterfaceMethod6
1659 pub mod ConformanceTestInterfaceMethod6 { 2014 pub mod ConformanceTestInterfaceMethod6 {
1660 pub const ORDINAL: u32 = 6; 2015 pub const ORDINAL: u32 = 6;
1661 pub const MIN_VERSION: u32 = 0; 2016 pub const MIN_VERSION: u32 = 0;
1662 } 2017 }
1663 // -- ConformanceTestInterfaceMethod6Request -- 2018 // -- ConformanceTestInterfaceMethod6Request --
1664 2019
1665 // Constants 2020 // Constants
1666 // Enums 2021 // Enums
1667 // Struct version information 2022 // Struct version information
1668 const ConformanceTestInterfaceMethod6RequestVersions: [(u32, u32); 1] = [(0, 16) ]; 2023 const ConformanceTestInterfaceMethod6RequestVersions: [(u32, u32); 1] = [(0, 16) ];
1669 2024
1670 // Struct definition 2025 // Struct definition
1671 pub struct ConformanceTestInterfaceMethod6Request { 2026 pub struct ConformanceTestInterfaceMethod6Request {
1672 pub param0: Vec<Vec<u8>>, 2027 pub param0: Vec<Vec<u8>>,
1673 } 2028 }
1674 2029
1675 impl MojomPointer for ConformanceTestInterfaceMethod6Request { 2030 impl MojomPointer for ConformanceTestInterfaceMethod6Request {
1676 fn header_data(&self) -> DataHeaderValue { 2031 fn header_data(&self) -> DataHeaderValue {
1677 DataHeaderValue::Version(0) 2032 DataHeaderValue::Version(0)
1678 } 2033 }
1679 fn serialized_size(&self, _context: &Context) -> usize { 2034 fn serialized_size(&self, _context: &Context) -> usize {
1680 16 2035 16
1681 } 2036 }
1682 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2037 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1683 MojomEncodable::encode(self.param0, encoder, context.clone()); 2038 MojomEncodable::encode(self.param0, encoder, context.clone());
1684 2039
1685 } 2040 }
1686 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2041 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1687 // TODO(mknyszek): Validate bytes and version 2042 let version = {
1688 let (_bytes, version) = {
1689 let mut state = decoder.get_mut(&context); 2043 let mut state = decoder.get_mut(&context);
1690 let bytes = state.decode::<u32>(); 2044 match state.decode_struct_header(&ConformanceTestInterfaceMethod6Req uestVersions) {
1691 let version = state.decode::<u32>(); 2045 Ok(header) => header.data(),
1692 (bytes, version) 2046 Err(err) => return Err(err),
2047 }
1693 }; 2048 };
1694 let param0 = <Vec<Vec<u8>>>::decode(decoder, context.clone()); 2049 let param0 = match <Vec<Vec<u8>>>::decode(decoder, context.clone()) {
1695 ConformanceTestInterfaceMethod6Request { param0: param0 } 2050 Ok(value) => value,
2051 Err(err) => return Err(err),
2052 };
2053 Ok(ConformanceTestInterfaceMethod6Request { param0: param0 })
1696 } 2054 }
1697 } 2055 }
1698 2056
1699 impl MojomEncodable for ConformanceTestInterfaceMethod6Request { 2057 impl MojomEncodable for ConformanceTestInterfaceMethod6Request {
1700 impl_encodable_for_pointer!(); 2058 impl_encodable_for_pointer!();
1701 fn compute_size(&self, context: Context) -> usize { 2059 fn compute_size(&self, context: Context) -> usize {
1702 encoding::align_default(self.serialized_size(&context)) + 2060 encoding::align_default(self.serialized_size(&context)) +
1703 self.param0.compute_size(context.clone()) 2061 self.param0.compute_size(context.clone())
1704 } 2062 }
1705 } 2063 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 DataHeaderValue::Version(0) 2096 DataHeaderValue::Version(0)
1739 } 2097 }
1740 fn serialized_size(&self, _context: &Context) -> usize { 2098 fn serialized_size(&self, _context: &Context) -> usize {
1741 24 2099 24
1742 } 2100 }
1743 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2101 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1744 MojomEncodable::encode(self.param0, encoder, context.clone()); 2102 MojomEncodable::encode(self.param0, encoder, context.clone());
1745 MojomEncodable::encode(self.param1, encoder, context.clone()); 2103 MojomEncodable::encode(self.param1, encoder, context.clone());
1746 2104
1747 } 2105 }
1748 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2106 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1749 // TODO(mknyszek): Validate bytes and version 2107 let version = {
1750 let (_bytes, version) = {
1751 let mut state = decoder.get_mut(&context); 2108 let mut state = decoder.get_mut(&context);
1752 let bytes = state.decode::<u32>(); 2109 match state.decode_struct_header(&ConformanceTestInterfaceMethod7Req uestVersions) {
1753 let version = state.decode::<u32>(); 2110 Ok(header) => header.data(),
1754 (bytes, version) 2111 Err(err) => return Err(err),
2112 }
1755 }; 2113 };
1756 let param0 = <StructF>::decode(decoder, context.clone()); 2114 let param0 = match <StructF>::decode(decoder, context.clone()) {
1757 let param1 = <[Option<[u8; 3]>; 2]>::decode(decoder, context.clone()); 2115 Ok(value) => value,
1758 ConformanceTestInterfaceMethod7Request { 2116 Err(err) => return Err(err),
2117 };
2118 let param1 = match <[Option<[u8; 3]>; 2]>::decode(decoder, context.clone ()) {
2119 Ok(value) => value,
2120 Err(err) => return Err(err),
2121 };
2122 Ok(ConformanceTestInterfaceMethod7Request {
1759 param0: param0, 2123 param0: param0,
1760 param1: param1, 2124 param1: param1,
1761 } 2125 })
1762 } 2126 }
1763 } 2127 }
1764 2128
1765 impl MojomEncodable for ConformanceTestInterfaceMethod7Request { 2129 impl MojomEncodable for ConformanceTestInterfaceMethod7Request {
1766 impl_encodable_for_pointer!(); 2130 impl_encodable_for_pointer!();
1767 fn compute_size(&self, context: Context) -> usize { 2131 fn compute_size(&self, context: Context) -> usize {
1768 encoding::align_default(self.serialized_size(&context)) + 2132 encoding::align_default(self.serialized_size(&context)) +
1769 self.param0.compute_size(context.clone()) + 2133 self.param0.compute_size(context.clone()) +
1770 self.param1.compute_size(context.clone()) 2134 self.param1.compute_size(context.clone())
1771 } 2135 }
1772 } 2136 }
1773 2137
1774 impl MojomStruct for ConformanceTestInterfaceMethod7Request {} 2138 impl MojomStruct for ConformanceTestInterfaceMethod7Request {}
1775 impl MojomMessage for ConformanceTestInterfaceMethod7Request { 2139 impl MojomMessage for ConformanceTestInterfaceMethod7Request {
1776 fn create_header() -> MessageHeader { 2140 fn create_header() -> MessageHeader {
1777 MessageHeader::new(ConformanceTestInterface::VERSION, 2141 MessageHeader::new(ConformanceTestInterface::VERSION,
1778 ConformanceTestInterfaceMethod7::ORDINAL, 2142 ConformanceTestInterfaceMethod7::ORDINAL,
1779 message::MESSAGE_HEADER_NO_FLAG) 2143 message::MESSAGE_HEADER_NO_FLAG)
1780 2144
1781 } 2145 }
1782 } 2146 }
1783 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod7Request {} 2147 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod7Request {}
1784 2148
1785 /// Message: ConformanceTestInterfaceMethod10 2149 /// Message: ConformanceTestInterfaceMethod8
1786 pub mod ConformanceTestInterfaceMethod10 { 2150 pub mod ConformanceTestInterfaceMethod8 {
1787 pub const ORDINAL: u32 = 10; 2151 pub const ORDINAL: u32 = 8;
1788 pub const MIN_VERSION: u32 = 0; 2152 pub const MIN_VERSION: u32 = 0;
1789 } 2153 }
1790 // -- ConformanceTestInterfaceMethod10Request -- 2154 // -- ConformanceTestInterfaceMethod8Request --
1791 2155
1792 // Constants 2156 // Constants
1793 // Enums 2157 // Enums
1794 // Struct version information 2158 // Struct version information
1795 const ConformanceTestInterfaceMethod10RequestVersions: [(u32, u32); 1] = [(0, 16 )]; 2159 const ConformanceTestInterfaceMethod8RequestVersions: [(u32, u32); 1] = [(0, 16) ];
1796 2160
1797 // Struct definition 2161 // Struct definition
1798 pub struct ConformanceTestInterfaceMethod10Request { 2162 pub struct ConformanceTestInterfaceMethod8Request {
1799 pub param0: HashMap<String, u8>, 2163 pub param0: Vec<Option<Vec<String>>>,
1800 } 2164 }
1801 2165
1802 impl MojomPointer for ConformanceTestInterfaceMethod10Request { 2166 impl MojomPointer for ConformanceTestInterfaceMethod8Request {
1803 fn header_data(&self) -> DataHeaderValue { 2167 fn header_data(&self) -> DataHeaderValue {
1804 DataHeaderValue::Version(0) 2168 DataHeaderValue::Version(0)
1805 } 2169 }
1806 fn serialized_size(&self, _context: &Context) -> usize { 2170 fn serialized_size(&self, _context: &Context) -> usize {
1807 16 2171 16
1808 } 2172 }
1809 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2173 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1810 MojomEncodable::encode(self.param0, encoder, context.clone()); 2174 MojomEncodable::encode(self.param0, encoder, context.clone());
1811 2175
1812 } 2176 }
1813 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2177 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1814 // TODO(mknyszek): Validate bytes and version 2178 let version = {
1815 let (_bytes, version) = {
1816 let mut state = decoder.get_mut(&context); 2179 let mut state = decoder.get_mut(&context);
1817 let bytes = state.decode::<u32>(); 2180 match state.decode_struct_header(&ConformanceTestInterfaceMethod8Req uestVersions) {
1818 let version = state.decode::<u32>(); 2181 Ok(header) => header.data(),
1819 (bytes, version) 2182 Err(err) => return Err(err),
2183 }
1820 }; 2184 };
1821 let param0 = <HashMap<String, u8>>::decode(decoder, context.clone()); 2185 let param0 = match <Vec<Option<Vec<String>>>>::decode(decoder, context.c lone()) {
1822 ConformanceTestInterfaceMethod10Request { param0: param0 } 2186 Ok(value) => value,
2187 Err(err) => return Err(err),
2188 };
2189 Ok(ConformanceTestInterfaceMethod8Request { param0: param0 })
1823 } 2190 }
1824 } 2191 }
1825 2192
1826 impl MojomEncodable for ConformanceTestInterfaceMethod10Request { 2193 impl MojomEncodable for ConformanceTestInterfaceMethod8Request {
1827 impl_encodable_for_pointer!(); 2194 impl_encodable_for_pointer!();
1828 fn compute_size(&self, context: Context) -> usize { 2195 fn compute_size(&self, context: Context) -> usize {
1829 encoding::align_default(self.serialized_size(&context)) + 2196 encoding::align_default(self.serialized_size(&context)) +
1830 self.param0.compute_size(context.clone()) 2197 self.param0.compute_size(context.clone())
1831 } 2198 }
1832 } 2199 }
1833 2200
1834 impl MojomStruct for ConformanceTestInterfaceMethod10Request {} 2201 impl MojomStruct for ConformanceTestInterfaceMethod8Request {}
1835 impl MojomMessage for ConformanceTestInterfaceMethod10Request { 2202 impl MojomMessage for ConformanceTestInterfaceMethod8Request {
1836 fn create_header() -> MessageHeader { 2203 fn create_header() -> MessageHeader {
1837 MessageHeader::new(ConformanceTestInterface::VERSION, 2204 MessageHeader::new(ConformanceTestInterface::VERSION,
1838 ConformanceTestInterfaceMethod10::ORDINAL, 2205 ConformanceTestInterfaceMethod8::ORDINAL,
1839 message::MESSAGE_HEADER_NO_FLAG) 2206 message::MESSAGE_HEADER_NO_FLAG)
1840 2207
1841 } 2208 }
1842 } 2209 }
1843 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod10Request {} 2210 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod8Request {}
1844 2211
1845 /// Message: ConformanceTestInterfaceMethod12 2212 /// Message: ConformanceTestInterfaceMethod9
1846 pub mod ConformanceTestInterfaceMethod12 { 2213 pub mod ConformanceTestInterfaceMethod9 {
1847 pub const ORDINAL: u32 = 12; 2214 pub const ORDINAL: u32 = 9;
1848 pub const MIN_VERSION: u32 = 0; 2215 pub const MIN_VERSION: u32 = 0;
1849 } 2216 }
1850 // -- ConformanceTestInterfaceMethod12Request -- 2217 // -- ConformanceTestInterfaceMethod9Request --
1851 2218
1852 // Constants 2219 // Constants
1853 // Enums 2220 // Enums
1854 // Struct version information 2221 // Struct version information
1855 const ConformanceTestInterfaceMethod12RequestVersions: [(u32, u32); 1] = [(0, 16 )]; 2222 const ConformanceTestInterfaceMethod9RequestVersions: [(u32, u32); 1] = [(0, 16) ];
1856 2223
1857 // Struct definition 2224 // Struct definition
1858 pub struct ConformanceTestInterfaceMethod12Request { 2225 pub struct ConformanceTestInterfaceMethod9Request {
1859 pub param0: f32, 2226 pub param0: Option<Vec<Vec<Option<system::UntypedHandle>>>>,
1860 } 2227 }
1861 2228
1862 impl MojomPointer for ConformanceTestInterfaceMethod12Request { 2229 impl MojomPointer for ConformanceTestInterfaceMethod9Request {
1863 fn header_data(&self) -> DataHeaderValue { 2230 fn header_data(&self) -> DataHeaderValue {
1864 DataHeaderValue::Version(0) 2231 DataHeaderValue::Version(0)
1865 } 2232 }
1866 fn serialized_size(&self, _context: &Context) -> usize { 2233 fn serialized_size(&self, _context: &Context) -> usize {
1867 16 2234 16
1868 } 2235 }
1869 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2236 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1870 MojomEncodable::encode(self.param0, encoder, context.clone()); 2237 MojomEncodable::encode(self.param0, encoder, context.clone());
1871 2238
1872 } 2239 }
1873 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2240 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1874 // TODO(mknyszek): Validate bytes and version 2241 let version = {
1875 let (_bytes, version) = {
1876 let mut state = decoder.get_mut(&context); 2242 let mut state = decoder.get_mut(&context);
1877 let bytes = state.decode::<u32>(); 2243 match state.decode_struct_header(&ConformanceTestInterfaceMethod9Req uestVersions) {
1878 let version = state.decode::<u32>(); 2244 Ok(header) => header.data(),
1879 (bytes, version) 2245 Err(err) => return Err(err),
2246 }
1880 }; 2247 };
1881 let param0 = <f32>::decode(decoder, context.clone()); 2248 let param0 = match <Option<Vec<Vec<Option<system::UntypedHandle>>>>>::de code(decoder, context.clone()) {
1882 ConformanceTestInterfaceMethod12Request { param0: param0 } 2249 Ok(value) => value,
2250 Err(err) => return Err(err),
2251 };
2252 Ok(ConformanceTestInterfaceMethod9Request { param0: param0 })
1883 } 2253 }
1884 } 2254 }
1885 2255
1886 impl MojomEncodable for ConformanceTestInterfaceMethod12Request { 2256 impl MojomEncodable for ConformanceTestInterfaceMethod9Request {
1887 impl_encodable_for_pointer!(); 2257 impl_encodable_for_pointer!();
1888 fn compute_size(&self, context: Context) -> usize { 2258 fn compute_size(&self, context: Context) -> usize {
1889 encoding::align_default(self.serialized_size(&context)) + 2259 encoding::align_default(self.serialized_size(&context)) +
1890 self.param0.compute_size(context.clone()) 2260 self.param0.compute_size(context.clone())
1891 } 2261 }
1892 } 2262 }
1893 2263
1894 impl MojomStruct for ConformanceTestInterfaceMethod12Request {} 2264 impl MojomStruct for ConformanceTestInterfaceMethod9Request {}
1895 impl MojomMessage for ConformanceTestInterfaceMethod12Request { 2265 impl MojomMessage for ConformanceTestInterfaceMethod9Request {
1896 fn create_header() -> MessageHeader { 2266 fn create_header() -> MessageHeader {
1897 MessageHeader::new(ConformanceTestInterface::VERSION, 2267 MessageHeader::new(ConformanceTestInterface::VERSION,
1898 ConformanceTestInterfaceMethod12::ORDINAL, 2268 ConformanceTestInterfaceMethod9::ORDINAL,
1899 message::MESSAGE_HEADER_EXPECT_RESPONSE) 2269 message::MESSAGE_HEADER_NO_FLAG)
1900 2270
1901 } 2271 }
1902 } 2272 }
1903 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod12Request {} 2273 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod9Request {}
1904 2274
1905 // -- ConformanceTestInterfaceMethod12Response -- 2275 /// Message: ConformanceTestInterfaceMethod11
2276 pub mod ConformanceTestInterfaceMethod11 {
2277 pub const ORDINAL: u32 = 11;
2278 pub const MIN_VERSION: u32 = 0;
2279 }
2280 // -- ConformanceTestInterfaceMethod11Request --
1906 2281
1907 // Constants 2282 // Constants
1908 // Enums 2283 // Enums
1909 // Struct version information 2284 // Struct version information
1910 const ConformanceTestInterfaceMethod12ResponseVersions: [(u32, u32); 1] = [(0, 1 6)]; 2285 const ConformanceTestInterfaceMethod11RequestVersions: [(u32, u32); 1] = [(0, 16 )];
1911 2286
1912 // Struct definition 2287 // Struct definition
1913 pub struct ConformanceTestInterfaceMethod12Response { 2288 pub struct ConformanceTestInterfaceMethod11Request {
1914 pub param0: f32, 2289 pub param0: StructG,
1915 } 2290 }
1916 2291
1917 impl MojomPointer for ConformanceTestInterfaceMethod12Response { 2292 impl MojomPointer for ConformanceTestInterfaceMethod11Request {
1918 fn header_data(&self) -> DataHeaderValue { 2293 fn header_data(&self) -> DataHeaderValue {
1919 DataHeaderValue::Version(0) 2294 DataHeaderValue::Version(0)
1920 } 2295 }
1921 fn serialized_size(&self, _context: &Context) -> usize { 2296 fn serialized_size(&self, _context: &Context) -> usize {
1922 16 2297 16
1923 } 2298 }
1924 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2299 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1925 MojomEncodable::encode(self.param0, encoder, context.clone()); 2300 MojomEncodable::encode(self.param0, encoder, context.clone());
1926 2301
1927 } 2302 }
1928 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2303 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1929 // TODO(mknyszek): Validate bytes and version 2304 let version = {
1930 let (_bytes, version) = {
1931 let mut state = decoder.get_mut(&context); 2305 let mut state = decoder.get_mut(&context);
1932 let bytes = state.decode::<u32>(); 2306 match state.decode_struct_header(&ConformanceTestInterfaceMethod11Re questVersions) {
1933 let version = state.decode::<u32>(); 2307 Ok(header) => header.data(),
1934 (bytes, version) 2308 Err(err) => return Err(err),
2309 }
1935 }; 2310 };
1936 let param0 = <f32>::decode(decoder, context.clone()); 2311 let param0 = match <StructG>::decode(decoder, context.clone()) {
1937 ConformanceTestInterfaceMethod12Response { param0: param0 } 2312 Ok(value) => value,
2313 Err(err) => return Err(err),
2314 };
2315 Ok(ConformanceTestInterfaceMethod11Request { param0: param0 })
1938 } 2316 }
1939 } 2317 }
1940 2318
1941 impl MojomEncodable for ConformanceTestInterfaceMethod12Response { 2319 impl MojomEncodable for ConformanceTestInterfaceMethod11Request {
1942 impl_encodable_for_pointer!(); 2320 impl_encodable_for_pointer!();
1943 fn compute_size(&self, context: Context) -> usize { 2321 fn compute_size(&self, context: Context) -> usize {
1944 encoding::align_default(self.serialized_size(&context)) + 2322 encoding::align_default(self.serialized_size(&context)) +
1945 self.param0.compute_size(context.clone()) 2323 self.param0.compute_size(context.clone())
1946 } 2324 }
1947 } 2325 }
1948 2326
1949 impl MojomStruct for ConformanceTestInterfaceMethod12Response {} 2327 impl MojomStruct for ConformanceTestInterfaceMethod11Request {}
1950 2328 impl MojomMessage for ConformanceTestInterfaceMethod11Request {
1951 impl MojomMessage for ConformanceTestInterfaceMethod12Response {
1952 fn create_header() -> MessageHeader { 2329 fn create_header() -> MessageHeader {
1953 MessageHeader::new(ConformanceTestInterface::VERSION, 2330 MessageHeader::new(ConformanceTestInterface::VERSION,
1954 ConformanceTestInterfaceMethod12::ORDINAL, 2331 ConformanceTestInterfaceMethod11::ORDINAL,
1955 message::MESSAGE_HEADER_IS_RESPONSE) 2332 message::MESSAGE_HEADER_NO_FLAG)
2333
1956 } 2334 }
1957 } 2335 }
1958 impl ConformanceTestInterfaceResponse for ConformanceTestInterfaceMethod12Reques t {} 2336 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod11Request {}
1959 /// Message: ConformanceTestInterfaceMethod15 2337
1960 pub mod ConformanceTestInterfaceMethod15 { 2338 /// Message: ConformanceTestInterfaceMethod12
1961 pub const ORDINAL: u32 = 15; 2339 pub mod ConformanceTestInterfaceMethod12 {
2340 pub const ORDINAL: u32 = 12;
1962 pub const MIN_VERSION: u32 = 0; 2341 pub const MIN_VERSION: u32 = 0;
1963 } 2342 }
1964 // -- ConformanceTestInterfaceMethod15Request -- 2343 // -- ConformanceTestInterfaceMethod12Request --
1965 2344
1966 // Constants 2345 // Constants
1967 // Enums 2346 // Enums
1968 // Struct version information 2347 // Struct version information
1969 const ConformanceTestInterfaceMethod15RequestVersions: [(u32, u32); 1] = [(0, 16 )]; 2348 const ConformanceTestInterfaceMethod12RequestVersions: [(u32, u32); 1] = [(0, 16 )];
1970 2349
1971 // Struct definition 2350 // Struct definition
1972 pub struct ConformanceTestInterfaceMethod15Request { 2351 pub struct ConformanceTestInterfaceMethod12Request {
1973 pub param0: StructH, 2352 pub param0: f32,
1974 } 2353 }
1975 2354
1976 impl MojomPointer for ConformanceTestInterfaceMethod15Request { 2355 impl MojomPointer for ConformanceTestInterfaceMethod12Request {
1977 fn header_data(&self) -> DataHeaderValue { 2356 fn header_data(&self) -> DataHeaderValue {
1978 DataHeaderValue::Version(0) 2357 DataHeaderValue::Version(0)
1979 } 2358 }
1980 fn serialized_size(&self, _context: &Context) -> usize { 2359 fn serialized_size(&self, _context: &Context) -> usize {
1981 16 2360 16
1982 } 2361 }
1983 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2362 fn encode_value(self, encoder: &mut Encoder, context: Context) {
1984 MojomEncodable::encode(self.param0, encoder, context.clone()); 2363 MojomEncodable::encode(self.param0, encoder, context.clone());
1985 2364
1986 } 2365 }
1987 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2366 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
1988 // TODO(mknyszek): Validate bytes and version 2367 let version = {
1989 let (_bytes, version) = {
1990 let mut state = decoder.get_mut(&context); 2368 let mut state = decoder.get_mut(&context);
1991 let bytes = state.decode::<u32>(); 2369 match state.decode_struct_header(&ConformanceTestInterfaceMethod12Re questVersions) {
1992 let version = state.decode::<u32>(); 2370 Ok(header) => header.data(),
1993 (bytes, version) 2371 Err(err) => return Err(err),
2372 }
1994 }; 2373 };
1995 let param0 = <StructH>::decode(decoder, context.clone()); 2374 let param0 = match <f32>::decode(decoder, context.clone()) {
1996 ConformanceTestInterfaceMethod15Request { param0: param0 } 2375 Ok(value) => value,
2376 Err(err) => return Err(err),
2377 };
2378 Ok(ConformanceTestInterfaceMethod12Request { param0: param0 })
1997 } 2379 }
1998 } 2380 }
1999 2381
2000 impl MojomEncodable for ConformanceTestInterfaceMethod15Request { 2382 impl MojomEncodable for ConformanceTestInterfaceMethod12Request {
2001 impl_encodable_for_pointer!(); 2383 impl_encodable_for_pointer!();
2002 fn compute_size(&self, context: Context) -> usize { 2384 fn compute_size(&self, context: Context) -> usize {
2003 encoding::align_default(self.serialized_size(&context)) + 2385 encoding::align_default(self.serialized_size(&context)) +
2004 self.param0.compute_size(context.clone()) 2386 self.param0.compute_size(context.clone())
2005 } 2387 }
2006 } 2388 }
2007 2389
2008 impl MojomStruct for ConformanceTestInterfaceMethod15Request {} 2390 impl MojomStruct for ConformanceTestInterfaceMethod12Request {}
2009 impl MojomMessage for ConformanceTestInterfaceMethod15Request { 2391 impl MojomMessage for ConformanceTestInterfaceMethod12Request {
2010 fn create_header() -> MessageHeader { 2392 fn create_header() -> MessageHeader {
2011 MessageHeader::new(ConformanceTestInterface::VERSION, 2393 MessageHeader::new(ConformanceTestInterface::VERSION,
2012 ConformanceTestInterfaceMethod15::ORDINAL, 2394 ConformanceTestInterfaceMethod12::ORDINAL,
2013 message::MESSAGE_HEADER_NO_FLAG) 2395 message::MESSAGE_HEADER_EXPECT_RESPONSE)
2014 2396
2015 } 2397 }
2016 } 2398 }
2017 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod15Request {} 2399 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod12Request {}
2018 2400
2019 /// Message: ConformanceTestInterfaceMethod0 2401 // -- ConformanceTestInterfaceMethod12Response --
2020 pub mod ConformanceTestInterfaceMethod0 {
2021 pub const ORDINAL: u32 = 0;
2022 pub const MIN_VERSION: u32 = 0;
2023 }
2024 // -- ConformanceTestInterfaceMethod0Request --
2025 2402
2026 // Constants 2403 // Constants
2027 // Enums 2404 // Enums
2028 // Struct version information 2405 // Struct version information
2029 const ConformanceTestInterfaceMethod0RequestVersions: [(u32, u32); 1] = [(0, 16) ]; 2406 const ConformanceTestInterfaceMethod12ResponseVersions: [(u32, u32); 1] = [(0, 1 6)];
2030 2407
2031 // Struct definition 2408 // Struct definition
2032 pub struct ConformanceTestInterfaceMethod0Request { 2409 pub struct ConformanceTestInterfaceMethod12Response {
2033 pub param0: f32, 2410 pub param0: f32,
2034 } 2411 }
2035 2412
2036 impl MojomPointer for ConformanceTestInterfaceMethod0Request { 2413 impl MojomPointer for ConformanceTestInterfaceMethod12Response {
2037 fn header_data(&self) -> DataHeaderValue { 2414 fn header_data(&self) -> DataHeaderValue {
2038 DataHeaderValue::Version(0) 2415 DataHeaderValue::Version(0)
2039 } 2416 }
2040 fn serialized_size(&self, _context: &Context) -> usize { 2417 fn serialized_size(&self, _context: &Context) -> usize {
2041 16 2418 16
2042 } 2419 }
2043 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2420 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2044 MojomEncodable::encode(self.param0, encoder, context.clone()); 2421 MojomEncodable::encode(self.param0, encoder, context.clone());
2045 2422
2046 } 2423 }
2047 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2424 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
2048 // TODO(mknyszek): Validate bytes and version 2425 let version = {
2049 let (_bytes, version) = {
2050 let mut state = decoder.get_mut(&context); 2426 let mut state = decoder.get_mut(&context);
2051 let bytes = state.decode::<u32>(); 2427 match state.decode_struct_header(&ConformanceTestInterfaceMethod12Re sponseVersions) {
2052 let version = state.decode::<u32>(); 2428 Ok(header) => header.data(),
2053 (bytes, version) 2429 Err(err) => return Err(err),
2430 }
2054 }; 2431 };
2055 let param0 = <f32>::decode(decoder, context.clone()); 2432 let param0 = match <f32>::decode(decoder, context.clone()) {
2056 ConformanceTestInterfaceMethod0Request { param0: param0 } 2433 Ok(value) => value,
2434 Err(err) => return Err(err),
2435 };
2436 Ok(ConformanceTestInterfaceMethod12Response { param0: param0 })
2057 } 2437 }
2058 } 2438 }
2059 2439
2060 impl MojomEncodable for ConformanceTestInterfaceMethod0Request { 2440 impl MojomEncodable for ConformanceTestInterfaceMethod12Response {
2061 impl_encodable_for_pointer!(); 2441 impl_encodable_for_pointer!();
2062 fn compute_size(&self, context: Context) -> usize { 2442 fn compute_size(&self, context: Context) -> usize {
2063 encoding::align_default(self.serialized_size(&context)) + 2443 encoding::align_default(self.serialized_size(&context)) +
2064 self.param0.compute_size(context.clone()) 2444 self.param0.compute_size(context.clone())
2065 } 2445 }
2066 } 2446 }
2067 2447
2068 impl MojomStruct for ConformanceTestInterfaceMethod0Request {} 2448 impl MojomStruct for ConformanceTestInterfaceMethod12Response {}
2069 impl MojomMessage for ConformanceTestInterfaceMethod0Request { 2449
2450 impl MojomMessage for ConformanceTestInterfaceMethod12Response {
2070 fn create_header() -> MessageHeader { 2451 fn create_header() -> MessageHeader {
2071 MessageHeader::new(ConformanceTestInterface::VERSION, 2452 MessageHeader::new(ConformanceTestInterface::VERSION,
2072 ConformanceTestInterfaceMethod0::ORDINAL, 2453 ConformanceTestInterfaceMethod12::ORDINAL,
2073 message::MESSAGE_HEADER_NO_FLAG) 2454 message::MESSAGE_HEADER_IS_RESPONSE)
2074
2075 } 2455 }
2076 } 2456 }
2077 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod0Request {} 2457 impl ConformanceTestInterfaceResponse for ConformanceTestInterfaceMethod12Reques t {}
2078 2458 /// Message: ConformanceTestInterfaceMethod14
2079 /// Message: ConformanceTestInterfaceMethod1 2459 pub mod ConformanceTestInterfaceMethod14 {
2080 pub mod ConformanceTestInterfaceMethod1 { 2460 pub const ORDINAL: u32 = 14;
2081 pub const ORDINAL: u32 = 1;
2082 pub const MIN_VERSION: u32 = 0; 2461 pub const MIN_VERSION: u32 = 0;
2083 } 2462 }
2084 // -- ConformanceTestInterfaceMethod1Request -- 2463 // -- ConformanceTestInterfaceMethod14Request --
2085 2464
2086 // Constants 2465 // Constants
2087 // Enums 2466 // Enums
2088 // Struct version information 2467 // Struct version information
2089 const ConformanceTestInterfaceMethod1RequestVersions: [(u32, u32); 1] = [(0, 16) ]; 2468 const ConformanceTestInterfaceMethod14RequestVersions: [(u32, u32); 1] = [(0, 24 )];
2090 2469
2091 // Struct definition 2470 // Struct definition
2092 pub struct ConformanceTestInterfaceMethod1Request { 2471 pub struct ConformanceTestInterfaceMethod14Request {
2093 pub param0: StructA, 2472 pub param0: UnionA,
2094 } 2473 }
2095 2474
2096 impl MojomPointer for ConformanceTestInterfaceMethod1Request { 2475 impl MojomPointer for ConformanceTestInterfaceMethod14Request {
2097 fn header_data(&self) -> DataHeaderValue { 2476 fn header_data(&self) -> DataHeaderValue {
2098 DataHeaderValue::Version(0) 2477 DataHeaderValue::Version(0)
2099 } 2478 }
2100 fn serialized_size(&self, _context: &Context) -> usize { 2479 fn serialized_size(&self, _context: &Context) -> usize {
2101 16 2480 24
2102 } 2481 }
2103 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2482 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2104 MojomEncodable::encode(self.param0, encoder, context.clone()); 2483 MojomEncodable::encode(self.param0, encoder, context.clone());
2105 2484
2106 } 2485 }
2107 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2486 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
2108 // TODO(mknyszek): Validate bytes and version 2487 let version = {
2109 let (_bytes, version) = {
2110 let mut state = decoder.get_mut(&context); 2488 let mut state = decoder.get_mut(&context);
2111 let bytes = state.decode::<u32>(); 2489 match state.decode_struct_header(&ConformanceTestInterfaceMethod14Re questVersions) {
2112 let version = state.decode::<u32>(); 2490 Ok(header) => header.data(),
2113 (bytes, version) 2491 Err(err) => return Err(err),
2492 }
2114 }; 2493 };
2115 let param0 = <StructA>::decode(decoder, context.clone()); 2494 let param0 = match <UnionA>::decode(decoder, context.clone()) {
2116 ConformanceTestInterfaceMethod1Request { param0: param0 } 2495 Ok(value) => value,
2496 Err(err) => return Err(err),
2497 };
2498 Ok(ConformanceTestInterfaceMethod14Request { param0: param0 })
2117 } 2499 }
2118 } 2500 }
2119 2501
2120 impl MojomEncodable for ConformanceTestInterfaceMethod1Request { 2502 impl MojomEncodable for ConformanceTestInterfaceMethod14Request {
2121 impl_encodable_for_pointer!(); 2503 impl_encodable_for_pointer!();
2122 fn compute_size(&self, context: Context) -> usize { 2504 fn compute_size(&self, context: Context) -> usize {
2123 encoding::align_default(self.serialized_size(&context)) + 2505 encoding::align_default(self.serialized_size(&context)) +
2124 self.param0.compute_size(context.clone()) 2506 self.param0.compute_size(context.clone())
2125 } 2507 }
2126 } 2508 }
2127 2509
2128 impl MojomStruct for ConformanceTestInterfaceMethod1Request {} 2510 impl MojomStruct for ConformanceTestInterfaceMethod14Request {}
2129 impl MojomMessage for ConformanceTestInterfaceMethod1Request { 2511 impl MojomMessage for ConformanceTestInterfaceMethod14Request {
2130 fn create_header() -> MessageHeader { 2512 fn create_header() -> MessageHeader {
2131 MessageHeader::new(ConformanceTestInterface::VERSION, 2513 MessageHeader::new(ConformanceTestInterface::VERSION,
2132 ConformanceTestInterfaceMethod1::ORDINAL, 2514 ConformanceTestInterfaceMethod14::ORDINAL,
2133 message::MESSAGE_HEADER_NO_FLAG) 2515 message::MESSAGE_HEADER_NO_FLAG)
2134 2516
2135 } 2517 }
2136 } 2518 }
2137 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod1Request {} 2519 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod14Request {}
2138 2520
2139 /// Message: ConformanceTestInterfaceMethod3 2521 /// Message: ConformanceTestInterfaceMethod0
2140 pub mod ConformanceTestInterfaceMethod3 { 2522 pub mod ConformanceTestInterfaceMethod0 {
2141 pub const ORDINAL: u32 = 3; 2523 pub const ORDINAL: u32 = 0;
2142 pub const MIN_VERSION: u32 = 0; 2524 pub const MIN_VERSION: u32 = 0;
2143 } 2525 }
2144 // -- ConformanceTestInterfaceMethod3Request -- 2526 // -- ConformanceTestInterfaceMethod0Request --
2145 2527
2146 // Constants 2528 // Constants
2147 // Enums 2529 // Enums
2148 // Struct version information 2530 // Struct version information
2149 const ConformanceTestInterfaceMethod3RequestVersions: [(u32, u32); 1] = [(0, 16) ]; 2531 const ConformanceTestInterfaceMethod0RequestVersions: [(u32, u32); 1] = [(0, 16) ];
2150 2532
2151 // Struct definition 2533 // Struct definition
2152 pub struct ConformanceTestInterfaceMethod3Request { 2534 pub struct ConformanceTestInterfaceMethod0Request {
2153 pub param0: Vec<bool>, 2535 pub param0: f32,
2154 } 2536 }
2155 2537
2156 impl MojomPointer for ConformanceTestInterfaceMethod3Request { 2538 impl MojomPointer for ConformanceTestInterfaceMethod0Request {
2157 fn header_data(&self) -> DataHeaderValue { 2539 fn header_data(&self) -> DataHeaderValue {
2158 DataHeaderValue::Version(0) 2540 DataHeaderValue::Version(0)
2159 } 2541 }
2160 fn serialized_size(&self, _context: &Context) -> usize { 2542 fn serialized_size(&self, _context: &Context) -> usize {
2161 16 2543 16
2162 } 2544 }
2163 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2545 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2164 MojomEncodable::encode(self.param0, encoder, context.clone()); 2546 MojomEncodable::encode(self.param0, encoder, context.clone());
2165 2547
2166 } 2548 }
2167 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2549 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
2168 // TODO(mknyszek): Validate bytes and version 2550 let version = {
2169 let (_bytes, version) = {
2170 let mut state = decoder.get_mut(&context); 2551 let mut state = decoder.get_mut(&context);
2171 let bytes = state.decode::<u32>(); 2552 match state.decode_struct_header(&ConformanceTestInterfaceMethod0Req uestVersions) {
2172 let version = state.decode::<u32>(); 2553 Ok(header) => header.data(),
2173 (bytes, version) 2554 Err(err) => return Err(err),
2555 }
2174 }; 2556 };
2175 let param0 = <Vec<bool>>::decode(decoder, context.clone()); 2557 let param0 = match <f32>::decode(decoder, context.clone()) {
2176 ConformanceTestInterfaceMethod3Request { param0: param0 } 2558 Ok(value) => value,
2559 Err(err) => return Err(err),
2560 };
2561 Ok(ConformanceTestInterfaceMethod0Request { param0: param0 })
2177 } 2562 }
2178 } 2563 }
2179 2564
2180 impl MojomEncodable for ConformanceTestInterfaceMethod3Request { 2565 impl MojomEncodable for ConformanceTestInterfaceMethod0Request {
2181 impl_encodable_for_pointer!(); 2566 impl_encodable_for_pointer!();
2182 fn compute_size(&self, context: Context) -> usize { 2567 fn compute_size(&self, context: Context) -> usize {
2183 encoding::align_default(self.serialized_size(&context)) + 2568 encoding::align_default(self.serialized_size(&context)) +
2184 self.param0.compute_size(context.clone()) 2569 self.param0.compute_size(context.clone())
2185 } 2570 }
2186 } 2571 }
2187 2572
2188 impl MojomStruct for ConformanceTestInterfaceMethod3Request {} 2573 impl MojomStruct for ConformanceTestInterfaceMethod0Request {}
2189 impl MojomMessage for ConformanceTestInterfaceMethod3Request { 2574 impl MojomMessage for ConformanceTestInterfaceMethod0Request {
2190 fn create_header() -> MessageHeader { 2575 fn create_header() -> MessageHeader {
2191 MessageHeader::new(ConformanceTestInterface::VERSION, 2576 MessageHeader::new(ConformanceTestInterface::VERSION,
2192 ConformanceTestInterfaceMethod3::ORDINAL, 2577 ConformanceTestInterfaceMethod0::ORDINAL,
2193 message::MESSAGE_HEADER_NO_FLAG) 2578 message::MESSAGE_HEADER_NO_FLAG)
2194 2579
2195 } 2580 }
2196 } 2581 }
2197 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod3Request {} 2582 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod0Request {}
2198 2583
2199 /// Message: ConformanceTestInterfaceMethod8 2584 /// Message: ConformanceTestInterfaceMethod1
2200 pub mod ConformanceTestInterfaceMethod8 { 2585 pub mod ConformanceTestInterfaceMethod1 {
2201 pub const ORDINAL: u32 = 8; 2586 pub const ORDINAL: u32 = 1;
2202 pub const MIN_VERSION: u32 = 0; 2587 pub const MIN_VERSION: u32 = 0;
2203 } 2588 }
2204 // -- ConformanceTestInterfaceMethod8Request -- 2589 // -- ConformanceTestInterfaceMethod1Request --
2205 2590
2206 // Constants 2591 // Constants
2207 // Enums 2592 // Enums
2208 // Struct version information 2593 // Struct version information
2209 const ConformanceTestInterfaceMethod8RequestVersions: [(u32, u32); 1] = [(0, 16) ]; 2594 const ConformanceTestInterfaceMethod1RequestVersions: [(u32, u32); 1] = [(0, 16) ];
2210 2595
2211 // Struct definition 2596 // Struct definition
2212 pub struct ConformanceTestInterfaceMethod8Request { 2597 pub struct ConformanceTestInterfaceMethod1Request {
2213 pub param0: Vec<Option<Vec<String>>>, 2598 pub param0: StructA,
2214 } 2599 }
2215 2600
2216 impl MojomPointer for ConformanceTestInterfaceMethod8Request { 2601 impl MojomPointer for ConformanceTestInterfaceMethod1Request {
2217 fn header_data(&self) -> DataHeaderValue { 2602 fn header_data(&self) -> DataHeaderValue {
2218 DataHeaderValue::Version(0) 2603 DataHeaderValue::Version(0)
2219 } 2604 }
2220 fn serialized_size(&self, _context: &Context) -> usize { 2605 fn serialized_size(&self, _context: &Context) -> usize {
2221 16 2606 16
2222 } 2607 }
2223 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2608 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2224 MojomEncodable::encode(self.param0, encoder, context.clone()); 2609 MojomEncodable::encode(self.param0, encoder, context.clone());
2225 2610
2226 } 2611 }
2227 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2612 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
2228 // TODO(mknyszek): Validate bytes and version 2613 let version = {
2229 let (_bytes, version) = {
2230 let mut state = decoder.get_mut(&context); 2614 let mut state = decoder.get_mut(&context);
2231 let bytes = state.decode::<u32>(); 2615 match state.decode_struct_header(&ConformanceTestInterfaceMethod1Req uestVersions) {
2232 let version = state.decode::<u32>(); 2616 Ok(header) => header.data(),
2233 (bytes, version) 2617 Err(err) => return Err(err),
2618 }
2234 }; 2619 };
2235 let param0 = <Vec<Option<Vec<String>>>>::decode(decoder, context.clone() ); 2620 let param0 = match <StructA>::decode(decoder, context.clone()) {
2236 ConformanceTestInterfaceMethod8Request { param0: param0 } 2621 Ok(value) => value,
2622 Err(err) => return Err(err),
2623 };
2624 Ok(ConformanceTestInterfaceMethod1Request { param0: param0 })
2237 } 2625 }
2238 } 2626 }
2239 2627
2240 impl MojomEncodable for ConformanceTestInterfaceMethod8Request { 2628 impl MojomEncodable for ConformanceTestInterfaceMethod1Request {
2241 impl_encodable_for_pointer!(); 2629 impl_encodable_for_pointer!();
2242 fn compute_size(&self, context: Context) -> usize { 2630 fn compute_size(&self, context: Context) -> usize {
2243 encoding::align_default(self.serialized_size(&context)) + 2631 encoding::align_default(self.serialized_size(&context)) +
2244 self.param0.compute_size(context.clone()) 2632 self.param0.compute_size(context.clone())
2245 } 2633 }
2246 } 2634 }
2247 2635
2248 impl MojomStruct for ConformanceTestInterfaceMethod8Request {} 2636 impl MojomStruct for ConformanceTestInterfaceMethod1Request {}
2249 impl MojomMessage for ConformanceTestInterfaceMethod8Request { 2637 impl MojomMessage for ConformanceTestInterfaceMethod1Request {
2250 fn create_header() -> MessageHeader { 2638 fn create_header() -> MessageHeader {
2251 MessageHeader::new(ConformanceTestInterface::VERSION, 2639 MessageHeader::new(ConformanceTestInterface::VERSION,
2252 ConformanceTestInterfaceMethod8::ORDINAL, 2640 ConformanceTestInterfaceMethod1::ORDINAL,
2253 message::MESSAGE_HEADER_NO_FLAG) 2641 message::MESSAGE_HEADER_NO_FLAG)
2254 2642
2255 } 2643 }
2256 } 2644 }
2257 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod8Request {} 2645 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod1Request {}
2258
2259 /// Message: ConformanceTestInterfaceMethod9
2260 pub mod ConformanceTestInterfaceMethod9 {
2261 pub const ORDINAL: u32 = 9;
2262 pub const MIN_VERSION: u32 = 0;
2263 }
2264 // -- ConformanceTestInterfaceMethod9Request --
2265
2266 // Constants
2267 // Enums
2268 // Struct version information
2269 const ConformanceTestInterfaceMethod9RequestVersions: [(u32, u32); 1] = [(0, 16) ];
2270
2271 // Struct definition
2272 pub struct ConformanceTestInterfaceMethod9Request {
2273 pub param0: Option<Vec<Vec<Option<system::UntypedHandle>>>>,
2274 }
2275
2276 impl MojomPointer for ConformanceTestInterfaceMethod9Request {
2277 fn header_data(&self) -> DataHeaderValue {
2278 DataHeaderValue::Version(0)
2279 }
2280 fn serialized_size(&self, _context: &Context) -> usize {
2281 16
2282 }
2283 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2284 MojomEncodable::encode(self.param0, encoder, context.clone());
2285
2286 }
2287 fn decode_value(decoder: &mut Decoder, context: Context) -> Self {
2288 // TODO(mknyszek): Validate bytes and version
2289 let (_bytes, version) = {
2290 let mut state = decoder.get_mut(&context);
2291 let bytes = state.decode::<u32>();
2292 let version = state.decode::<u32>();
2293 (bytes, version)
2294 };
2295 let param0 = <Option<Vec<Vec<Option<system::UntypedHandle>>>>>::decode(d ecoder, context.clone());
2296 ConformanceTestInterfaceMethod9Request { param0: param0 }
2297 }
2298 }
2299
2300 impl MojomEncodable for ConformanceTestInterfaceMethod9Request {
2301 impl_encodable_for_pointer!();
2302 fn compute_size(&self, context: Context) -> usize {
2303 encoding::align_default(self.serialized_size(&context)) +
2304 self.param0.compute_size(context.clone())
2305 }
2306 }
2307
2308 impl MojomStruct for ConformanceTestInterfaceMethod9Request {}
2309 impl MojomMessage for ConformanceTestInterfaceMethod9Request {
2310 fn create_header() -> MessageHeader {
2311 MessageHeader::new(ConformanceTestInterface::VERSION,
2312 ConformanceTestInterfaceMethod9::ORDINAL,
2313 message::MESSAGE_HEADER_NO_FLAG)
2314
2315 }
2316 }
2317 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod9Request {}
2318 2646
2319 /// Message: ConformanceTestInterfaceMethod13 2647 /// Message: ConformanceTestInterfaceMethod13
2320 pub mod ConformanceTestInterfaceMethod13 { 2648 pub mod ConformanceTestInterfaceMethod13 {
2321 pub const ORDINAL: u32 = 13; 2649 pub const ORDINAL: u32 = 13;
2322 pub const MIN_VERSION: u32 = 0; 2650 pub const MIN_VERSION: u32 = 0;
2323 } 2651 }
2324 // -- ConformanceTestInterfaceMethod13Request -- 2652 // -- ConformanceTestInterfaceMethod13Request --
2325 2653
2326 // Constants 2654 // Constants
2327 // Enums 2655 // Enums
(...skipping 13 matching lines...) Expand all
2341 } 2669 }
2342 fn serialized_size(&self, _context: &Context) -> usize { 2670 fn serialized_size(&self, _context: &Context) -> usize {
2343 32 2671 32
2344 } 2672 }
2345 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2673 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2346 MojomEncodable::encode(self.param0, encoder, context.clone()); 2674 MojomEncodable::encode(self.param0, encoder, context.clone());
2347 MojomEncodable::encode(self.param1, encoder, context.clone()); 2675 MojomEncodable::encode(self.param1, encoder, context.clone());
2348 MojomEncodable::encode(self.param2, encoder, context.clone()); 2676 MojomEncodable::encode(self.param2, encoder, context.clone());
2349 2677
2350 } 2678 }
2351 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2679 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
2352 // TODO(mknyszek): Validate bytes and version 2680 let version = {
2353 let (_bytes, version) = {
2354 let mut state = decoder.get_mut(&context); 2681 let mut state = decoder.get_mut(&context);
2355 let bytes = state.decode::<u32>(); 2682 match state.decode_struct_header(&ConformanceTestInterfaceMethod13Re questVersions) {
2356 let version = state.decode::<u32>(); 2683 Ok(header) => header.data(),
2357 (bytes, version) 2684 Err(err) => return Err(err),
2685 }
2358 }; 2686 };
2359 let param0 = <Option<InterfaceAClient>>::decode(decoder, context.clone() ); 2687 let param0 = match <Option<InterfaceAClient>>::decode(decoder, context.c lone()) {
2360 let param1 = <u32>::decode(decoder, context.clone()); 2688 Ok(value) => value,
2361 let param2 = <Option<InterfaceAClient>>::decode(decoder, context.clone() ); 2689 Err(err) => return Err(err),
2362 ConformanceTestInterfaceMethod13Request { 2690 };
2691 let param1 = match <u32>::decode(decoder, context.clone()) {
2692 Ok(value) => value,
2693 Err(err) => return Err(err),
2694 };
2695 let param2 = match <Option<InterfaceAClient>>::decode(decoder, context.c lone()) {
2696 Ok(value) => value,
2697 Err(err) => return Err(err),
2698 };
2699 Ok(ConformanceTestInterfaceMethod13Request {
2363 param0: param0, 2700 param0: param0,
2364 param1: param1, 2701 param1: param1,
2365 param2: param2, 2702 param2: param2,
2366 } 2703 })
2367 } 2704 }
2368 } 2705 }
2369 2706
2370 impl MojomEncodable for ConformanceTestInterfaceMethod13Request { 2707 impl MojomEncodable for ConformanceTestInterfaceMethod13Request {
2371 impl_encodable_for_pointer!(); 2708 impl_encodable_for_pointer!();
2372 fn compute_size(&self, context: Context) -> usize { 2709 fn compute_size(&self, context: Context) -> usize {
2373 encoding::align_default(self.serialized_size(&context)) + 2710 encoding::align_default(self.serialized_size(&context)) +
2374 self.param0.compute_size(context.clone()) + 2711 self.param0.compute_size(context.clone()) +
2375 self.param1.compute_size(context.clone()) + 2712 self.param1.compute_size(context.clone()) +
2376 self.param2.compute_size(context.clone()) 2713 self.param2.compute_size(context.clone())
2377 } 2714 }
2378 } 2715 }
2379 2716
2380 impl MojomStruct for ConformanceTestInterfaceMethod13Request {} 2717 impl MojomStruct for ConformanceTestInterfaceMethod13Request {}
2381 impl MojomMessage for ConformanceTestInterfaceMethod13Request { 2718 impl MojomMessage for ConformanceTestInterfaceMethod13Request {
2382 fn create_header() -> MessageHeader { 2719 fn create_header() -> MessageHeader {
2383 MessageHeader::new(ConformanceTestInterface::VERSION, 2720 MessageHeader::new(ConformanceTestInterface::VERSION,
2384 ConformanceTestInterfaceMethod13::ORDINAL, 2721 ConformanceTestInterfaceMethod13::ORDINAL,
2385 message::MESSAGE_HEADER_NO_FLAG) 2722 message::MESSAGE_HEADER_NO_FLAG)
2386 2723
2387 } 2724 }
2388 } 2725 }
2389 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod13Request {} 2726 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod13Request {}
2390 2727
2728 /// Message: ConformanceTestInterfaceMethod15
2729 pub mod ConformanceTestInterfaceMethod15 {
2730 pub const ORDINAL: u32 = 15;
2731 pub const MIN_VERSION: u32 = 0;
2732 }
2733 // -- ConformanceTestInterfaceMethod15Request --
2734
2735 // Constants
2736 // Enums
2737 // Struct version information
2738 const ConformanceTestInterfaceMethod15RequestVersions: [(u32, u32); 1] = [(0, 16 )];
2739
2740 // Struct definition
2741 pub struct ConformanceTestInterfaceMethod15Request {
2742 pub param0: StructH,
2743 }
2744
2745 impl MojomPointer for ConformanceTestInterfaceMethod15Request {
2746 fn header_data(&self) -> DataHeaderValue {
2747 DataHeaderValue::Version(0)
2748 }
2749 fn serialized_size(&self, _context: &Context) -> usize {
2750 16
2751 }
2752 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2753 MojomEncodable::encode(self.param0, encoder, context.clone());
2754
2755 }
2756 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
2757 let version = {
2758 let mut state = decoder.get_mut(&context);
2759 match state.decode_struct_header(&ConformanceTestInterfaceMethod15Re questVersions) {
2760 Ok(header) => header.data(),
2761 Err(err) => return Err(err),
2762 }
2763 };
2764 let param0 = match <StructH>::decode(decoder, context.clone()) {
2765 Ok(value) => value,
2766 Err(err) => return Err(err),
2767 };
2768 Ok(ConformanceTestInterfaceMethod15Request { param0: param0 })
2769 }
2770 }
2771
2772 impl MojomEncodable for ConformanceTestInterfaceMethod15Request {
2773 impl_encodable_for_pointer!();
2774 fn compute_size(&self, context: Context) -> usize {
2775 encoding::align_default(self.serialized_size(&context)) +
2776 self.param0.compute_size(context.clone())
2777 }
2778 }
2779
2780 impl MojomStruct for ConformanceTestInterfaceMethod15Request {}
2781 impl MojomMessage for ConformanceTestInterfaceMethod15Request {
2782 fn create_header() -> MessageHeader {
2783 MessageHeader::new(ConformanceTestInterface::VERSION,
2784 ConformanceTestInterfaceMethod15::ORDINAL,
2785 message::MESSAGE_HEADER_NO_FLAG)
2786
2787 }
2788 }
2789 impl ConformanceTestInterfaceRequest for ConformanceTestInterfaceMethod15Request {}
2790
2391 2791
2392 // --- IntegrationTestInterface --- 2792 // --- IntegrationTestInterface ---
2393 2793
2394 pub mod IntegrationTestInterface { 2794 pub mod IntegrationTestInterface {
2395 pub const SERVICE_NAME: &'static str = ""; 2795 pub const SERVICE_NAME: &'static str = "";
2396 pub const VERSION: u32 = 0; 2796 pub const VERSION: u32 = 0;
2397 } 2797 }
2398 2798
2399 pub struct IntegrationTestInterfaceClient { 2799 pub struct IntegrationTestInterfaceClient {
2400 pipe: message_pipe::MessageEndpoint, 2800 pipe: message_pipe::MessageEndpoint,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 2889
2490 2890
2491 pub trait IntegrationTestInterfaceRequest: MojomMessage {} 2891 pub trait IntegrationTestInterfaceRequest: MojomMessage {}
2492 pub trait IntegrationTestInterfaceResponse: MojomMessage {} 2892 pub trait IntegrationTestInterfaceResponse: MojomMessage {}
2493 2893
2494 pub enum IntegrationTestInterfaceRequestOption { 2894 pub enum IntegrationTestInterfaceRequestOption {
2495 IntegrationTestInterfaceMethod0(IntegrationTestInterfaceMethod0Request), 2895 IntegrationTestInterfaceMethod0(IntegrationTestInterfaceMethod0Request),
2496 } 2896 }
2497 2897
2498 impl MojomMessageOption for IntegrationTestInterfaceRequestOption { 2898 impl MojomMessageOption for IntegrationTestInterfaceRequestOption {
2499 fn decode_payload(ordinal: u32, buffer: &[u8], handles: Vec<UntypedHandle>) -> Self { 2899 fn decode_payload(header: MessageHeader,
2500 match ordinal { 2900 buffer: &[u8],
2501 IntegrationTestInterfaceMethod0::ORDINAL => IntegrationTestInterface RequestOption::IntegrationTestInterfaceMethod0(IntegrationTestInterfaceMethod0Re quest::deserialize(buffer, handles)), 2901 handles: Vec<UntypedHandle>)
2502 _ => panic!("Unknown message found: {}", ordinal), 2902 -> Result<Self, ValidationError> {
2903 match header.name {
2904 IntegrationTestInterfaceMethod0::ORDINAL => {
2905 if header.flags != message::MESSAGE_HEADER_EXPECT_RESPONSE {
2906 return Err(ValidationError::MessageHeaderInvalidFlags);
2907 }
2908 match IntegrationTestInterfaceMethod0Request::deserialize(buffer , handles) {
2909 Ok(value) => Ok(IntegrationTestInterfaceRequestOption::Integ rationTestInterfaceMethod0(value)),
2910 Err(err) => return Err(err),
2911 }
2912 }
2913 _ => Err(ValidationError::MessageHeaderUnknownMethod),
2503 } 2914 }
2504 } 2915 }
2505 } 2916 }
2506 2917
2507 pub enum IntegrationTestInterfaceResponseOption { 2918 pub enum IntegrationTestInterfaceResponseOption {
2508 IntegrationTestInterfaceMethod0(IntegrationTestInterfaceMethod0Response), 2919 IntegrationTestInterfaceMethod0(IntegrationTestInterfaceMethod0Response),
2509 } 2920 }
2510 2921
2511 impl MojomMessageOption for IntegrationTestInterfaceResponseOption { 2922 impl MojomMessageOption for IntegrationTestInterfaceResponseOption {
2512 fn decode_payload(ordinal: u32, buffer: &[u8], handles: Vec<UntypedHandle>) -> Self { 2923 fn decode_payload(header: MessageHeader,
2513 match ordinal { 2924 buffer: &[u8],
2514 IntegrationTestInterfaceMethod0::ORDINAL => IntegrationTestInterface ResponseOption::IntegrationTestInterfaceMethod0(IntegrationTestInterfaceMethod0R esponse::deserialize(buffer, handles)), 2925 handles: Vec<UntypedHandle>)
2515 _ => { 2926 -> Result<Self, ValidationError> {
2516 panic!("Unknown message found, or message has no response: {}", 2927 if header.flags != message::MESSAGE_HEADER_IS_RESPONSE {
2517 ordinal) 2928 return Err(ValidationError::MessageHeaderInvalidFlags);
2929 }
2930 match header.name {
2931 IntegrationTestInterfaceMethod0::ORDINAL => {
2932 match IntegrationTestInterfaceMethod0Response::deserialize(buffe r, handles) {
2933 Ok(value) => Ok(IntegrationTestInterfaceResponseOption::Inte grationTestInterfaceMethod0(value)),
2934 Err(err) => return Err(err),
2935 }
2518 } 2936 }
2937 _ => Err(ValidationError::MessageHeaderUnknownMethod),
2519 } 2938 }
2520 } 2939 }
2521 } 2940 }
2522 2941
2523 /// Message: IntegrationTestInterfaceMethod0 2942 /// Message: IntegrationTestInterfaceMethod0
2524 pub mod IntegrationTestInterfaceMethod0 { 2943 pub mod IntegrationTestInterfaceMethod0 {
2525 pub const ORDINAL: u32 = 0; 2944 pub const ORDINAL: u32 = 0;
2526 pub const MIN_VERSION: u32 = 0; 2945 pub const MIN_VERSION: u32 = 0;
2527 } 2946 }
2528 // -- IntegrationTestInterfaceMethod0Request -- 2947 // -- IntegrationTestInterfaceMethod0Request --
(...skipping 12 matching lines...) Expand all
2541 fn header_data(&self) -> DataHeaderValue { 2960 fn header_data(&self) -> DataHeaderValue {
2542 DataHeaderValue::Version(0) 2961 DataHeaderValue::Version(0)
2543 } 2962 }
2544 fn serialized_size(&self, _context: &Context) -> usize { 2963 fn serialized_size(&self, _context: &Context) -> usize {
2545 16 2964 16
2546 } 2965 }
2547 fn encode_value(self, encoder: &mut Encoder, context: Context) { 2966 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2548 MojomEncodable::encode(self.param0, encoder, context.clone()); 2967 MojomEncodable::encode(self.param0, encoder, context.clone());
2549 2968
2550 } 2969 }
2551 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 2970 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
2552 // TODO(mknyszek): Validate bytes and version 2971 let version = {
2553 let (_bytes, version) = {
2554 let mut state = decoder.get_mut(&context); 2972 let mut state = decoder.get_mut(&context);
2555 let bytes = state.decode::<u32>(); 2973 match state.decode_struct_header(&IntegrationTestInterfaceMethod0Req uestVersions) {
2556 let version = state.decode::<u32>(); 2974 Ok(header) => header.data(),
2557 (bytes, version) 2975 Err(err) => return Err(err),
2976 }
2558 }; 2977 };
2559 let param0 = <BasicStruct>::decode(decoder, context.clone()); 2978 let param0 = match <BasicStruct>::decode(decoder, context.clone()) {
2560 IntegrationTestInterfaceMethod0Request { param0: param0 } 2979 Ok(value) => value,
2980 Err(err) => return Err(err),
2981 };
2982 Ok(IntegrationTestInterfaceMethod0Request { param0: param0 })
2561 } 2983 }
2562 } 2984 }
2563 2985
2564 impl MojomEncodable for IntegrationTestInterfaceMethod0Request { 2986 impl MojomEncodable for IntegrationTestInterfaceMethod0Request {
2565 impl_encodable_for_pointer!(); 2987 impl_encodable_for_pointer!();
2566 fn compute_size(&self, context: Context) -> usize { 2988 fn compute_size(&self, context: Context) -> usize {
2567 encoding::align_default(self.serialized_size(&context)) + 2989 encoding::align_default(self.serialized_size(&context)) +
2568 self.param0.compute_size(context.clone()) 2990 self.param0.compute_size(context.clone())
2569 } 2991 }
2570 } 2992 }
(...skipping 25 matching lines...) Expand all
2596 fn header_data(&self) -> DataHeaderValue { 3018 fn header_data(&self) -> DataHeaderValue {
2597 DataHeaderValue::Version(0) 3019 DataHeaderValue::Version(0)
2598 } 3020 }
2599 fn serialized_size(&self, _context: &Context) -> usize { 3021 fn serialized_size(&self, _context: &Context) -> usize {
2600 16 3022 16
2601 } 3023 }
2602 fn encode_value(self, encoder: &mut Encoder, context: Context) { 3024 fn encode_value(self, encoder: &mut Encoder, context: Context) {
2603 MojomEncodable::encode(self.param0, encoder, context.clone()); 3025 MojomEncodable::encode(self.param0, encoder, context.clone());
2604 3026
2605 } 3027 }
2606 fn decode_value(decoder: &mut Decoder, context: Context) -> Self { 3028 fn decode_value(decoder: &mut Decoder, context: Context) -> Result<Self, Val idationError> {
2607 // TODO(mknyszek): Validate bytes and version 3029 let version = {
2608 let (_bytes, version) = {
2609 let mut state = decoder.get_mut(&context); 3030 let mut state = decoder.get_mut(&context);
2610 let bytes = state.decode::<u32>(); 3031 match state.decode_struct_header(&IntegrationTestInterfaceMethod0Res ponseVersions) {
2611 let version = state.decode::<u32>(); 3032 Ok(header) => header.data(),
2612 (bytes, version) 3033 Err(err) => return Err(err),
3034 }
2613 }; 3035 };
2614 let param0 = <Vec<u8>>::decode(decoder, context.clone()); 3036 let param0 = match <Vec<u8>>::decode(decoder, context.clone()) {
2615 IntegrationTestInterfaceMethod0Response { param0: param0 } 3037 Ok(value) => value,
3038 Err(err) => return Err(err),
3039 };
3040 Ok(IntegrationTestInterfaceMethod0Response { param0: param0 })
2616 } 3041 }
2617 } 3042 }
2618 3043
2619 impl MojomEncodable for IntegrationTestInterfaceMethod0Response { 3044 impl MojomEncodable for IntegrationTestInterfaceMethod0Response {
2620 impl_encodable_for_pointer!(); 3045 impl_encodable_for_pointer!();
2621 fn compute_size(&self, context: Context) -> usize { 3046 fn compute_size(&self, context: Context) -> usize {
2622 encoding::align_default(self.serialized_size(&context)) + 3047 encoding::align_default(self.serialized_size(&context)) +
2623 self.param0.compute_size(context.clone()) 3048 self.param0.compute_size(context.clone())
2624 } 3049 }
2625 } 3050 }
2626 3051
2627 impl MojomStruct for IntegrationTestInterfaceMethod0Response {} 3052 impl MojomStruct for IntegrationTestInterfaceMethod0Response {}
2628 3053
2629 impl MojomMessage for IntegrationTestInterfaceMethod0Response { 3054 impl MojomMessage for IntegrationTestInterfaceMethod0Response {
2630 fn create_header() -> MessageHeader { 3055 fn create_header() -> MessageHeader {
2631 MessageHeader::new(IntegrationTestInterface::VERSION, 3056 MessageHeader::new(IntegrationTestInterface::VERSION,
2632 IntegrationTestInterfaceMethod0::ORDINAL, 3057 IntegrationTestInterfaceMethod0::ORDINAL,
2633 message::MESSAGE_HEADER_IS_RESPONSE) 3058 message::MESSAGE_HEADER_IS_RESPONSE)
2634 } 3059 }
2635 } 3060 }
2636 impl IntegrationTestInterfaceResponse for IntegrationTestInterfaceMethod0Request {} 3061 impl IntegrationTestInterfaceResponse for IntegrationTestInterfaceMethod0Request {}
OLDNEW
« no previous file with comments | « mojo/public/rust/tests/util/mod.rs ('k') | mojo/public/rust/tests/validation.rs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698