1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub const MAX_RECORDS: u8 = 3;
13
14pub const MAX_SERVICE_DESCRIPTION_LENGTH: u8 = 128;
16
17#[derive(Clone, Debug, Default, PartialEq)]
19pub struct DeviceIdentificationRecord {
20 pub vendor_id: Option<VendorId>,
22 pub product_id: Option<u16>,
24 pub version: Option<DeviceReleaseNumber>,
26 pub primary: Option<bool>,
29 pub service_description: Option<String>,
32 #[doc(hidden)]
33 pub __source_breaking: fidl::marker::SourceBreaking,
34}
35
36impl fidl::Persistable for DeviceIdentificationRecord {}
37
38#[derive(Clone, Debug, Default, PartialEq)]
42pub struct DeviceReleaseNumber {
43 pub major: Option<u8>,
45 pub minor: Option<u8>,
47 pub subminor: Option<u8>,
49 #[doc(hidden)]
50 pub __source_breaking: fidl::marker::SourceBreaking,
51}
52
53impl fidl::Persistable for DeviceReleaseNumber {}
54
55#[derive(Clone, Debug)]
58pub enum VendorId {
59 BluetoothSigId(u16),
62 UsbIfId(u16),
65 #[doc(hidden)]
66 __SourceBreaking { unknown_ordinal: u64 },
67}
68
69#[macro_export]
71macro_rules! VendorIdUnknown {
72 () => {
73 _
74 };
75}
76
77impl PartialEq for VendorId {
79 fn eq(&self, other: &Self) -> bool {
80 match (self, other) {
81 (Self::BluetoothSigId(x), Self::BluetoothSigId(y)) => *x == *y,
82 (Self::UsbIfId(x), Self::UsbIfId(y)) => *x == *y,
83 _ => false,
84 }
85 }
86}
87
88impl VendorId {
89 #[inline]
90 pub fn ordinal(&self) -> u64 {
91 match *self {
92 Self::BluetoothSigId(_) => 1,
93 Self::UsbIfId(_) => 2,
94 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
95 }
96 }
97
98 #[inline]
99 pub fn unknown_variant_for_testing() -> Self {
100 Self::__SourceBreaking { unknown_ordinal: 0 }
101 }
102
103 #[inline]
104 pub fn is_unknown(&self) -> bool {
105 match self {
106 Self::__SourceBreaking { .. } => true,
107 _ => false,
108 }
109 }
110}
111
112impl fidl::Persistable for VendorId {}
113
114mod internal {
115 use super::*;
116
117 impl DeviceIdentificationRecord {
118 #[inline(always)]
119 fn max_ordinal_present(&self) -> u64 {
120 if let Some(_) = self.service_description {
121 return 5;
122 }
123 if let Some(_) = self.primary {
124 return 4;
125 }
126 if let Some(_) = self.version {
127 return 3;
128 }
129 if let Some(_) = self.product_id {
130 return 2;
131 }
132 if let Some(_) = self.vendor_id {
133 return 1;
134 }
135 0
136 }
137 }
138
139 impl fidl::encoding::ValueTypeMarker for DeviceIdentificationRecord {
140 type Borrowed<'a> = &'a Self;
141 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
142 value
143 }
144 }
145
146 unsafe impl fidl::encoding::TypeMarker for DeviceIdentificationRecord {
147 type Owned = Self;
148
149 #[inline(always)]
150 fn inline_align(_context: fidl::encoding::Context) -> usize {
151 8
152 }
153
154 #[inline(always)]
155 fn inline_size(_context: fidl::encoding::Context) -> usize {
156 16
157 }
158 }
159
160 unsafe impl<D: fidl::encoding::ResourceDialect>
161 fidl::encoding::Encode<DeviceIdentificationRecord, D> for &DeviceIdentificationRecord
162 {
163 unsafe fn encode(
164 self,
165 encoder: &mut fidl::encoding::Encoder<'_, D>,
166 offset: usize,
167 mut depth: fidl::encoding::Depth,
168 ) -> fidl::Result<()> {
169 encoder.debug_check_bounds::<DeviceIdentificationRecord>(offset);
170 let max_ordinal: u64 = self.max_ordinal_present();
172 encoder.write_num(max_ordinal, offset);
173 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
174 if max_ordinal == 0 {
176 return Ok(());
177 }
178 depth.increment()?;
179 let envelope_size = 8;
180 let bytes_len = max_ordinal as usize * envelope_size;
181 #[allow(unused_variables)]
182 let offset = encoder.out_of_line_offset(bytes_len);
183 let mut _prev_end_offset: usize = 0;
184 if 1 > max_ordinal {
185 return Ok(());
186 }
187
188 let cur_offset: usize = (1 - 1) * envelope_size;
191
192 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
194
195 fidl::encoding::encode_in_envelope_optional::<VendorId, D>(
200 self.vendor_id.as_ref().map(<VendorId as fidl::encoding::ValueTypeMarker>::borrow),
201 encoder,
202 offset + cur_offset,
203 depth,
204 )?;
205
206 _prev_end_offset = cur_offset + envelope_size;
207 if 2 > max_ordinal {
208 return Ok(());
209 }
210
211 let cur_offset: usize = (2 - 1) * envelope_size;
214
215 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
217
218 fidl::encoding::encode_in_envelope_optional::<u16, D>(
223 self.product_id.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
224 encoder,
225 offset + cur_offset,
226 depth,
227 )?;
228
229 _prev_end_offset = cur_offset + envelope_size;
230 if 3 > max_ordinal {
231 return Ok(());
232 }
233
234 let cur_offset: usize = (3 - 1) * envelope_size;
237
238 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
240
241 fidl::encoding::encode_in_envelope_optional::<DeviceReleaseNumber, D>(
246 self.version
247 .as_ref()
248 .map(<DeviceReleaseNumber as fidl::encoding::ValueTypeMarker>::borrow),
249 encoder,
250 offset + cur_offset,
251 depth,
252 )?;
253
254 _prev_end_offset = cur_offset + envelope_size;
255 if 4 > max_ordinal {
256 return Ok(());
257 }
258
259 let cur_offset: usize = (4 - 1) * envelope_size;
262
263 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
265
266 fidl::encoding::encode_in_envelope_optional::<bool, D>(
271 self.primary.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
272 encoder,
273 offset + cur_offset,
274 depth,
275 )?;
276
277 _prev_end_offset = cur_offset + envelope_size;
278 if 5 > max_ordinal {
279 return Ok(());
280 }
281
282 let cur_offset: usize = (5 - 1) * envelope_size;
285
286 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
288
289 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
294 self.service_description.as_ref().map(
295 <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
296 ),
297 encoder,
298 offset + cur_offset,
299 depth,
300 )?;
301
302 _prev_end_offset = cur_offset + envelope_size;
303
304 Ok(())
305 }
306 }
307
308 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
309 for DeviceIdentificationRecord
310 {
311 #[inline(always)]
312 fn new_empty() -> Self {
313 Self::default()
314 }
315
316 unsafe fn decode(
317 &mut self,
318 decoder: &mut fidl::encoding::Decoder<'_, D>,
319 offset: usize,
320 mut depth: fidl::encoding::Depth,
321 ) -> fidl::Result<()> {
322 decoder.debug_check_bounds::<Self>(offset);
323 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
324 None => return Err(fidl::Error::NotNullable),
325 Some(len) => len,
326 };
327 if len == 0 {
329 return Ok(());
330 };
331 depth.increment()?;
332 let envelope_size = 8;
333 let bytes_len = len * envelope_size;
334 let offset = decoder.out_of_line_offset(bytes_len)?;
335 let mut _next_ordinal_to_read = 0;
337 let mut next_offset = offset;
338 let end_offset = offset + bytes_len;
339 _next_ordinal_to_read += 1;
340 if next_offset >= end_offset {
341 return Ok(());
342 }
343
344 while _next_ordinal_to_read < 1 {
346 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
347 _next_ordinal_to_read += 1;
348 next_offset += envelope_size;
349 }
350
351 let next_out_of_line = decoder.next_out_of_line();
352 let handles_before = decoder.remaining_handles();
353 if let Some((inlined, num_bytes, num_handles)) =
354 fidl::encoding::decode_envelope_header(decoder, next_offset)?
355 {
356 let member_inline_size =
357 <VendorId as fidl::encoding::TypeMarker>::inline_size(decoder.context);
358 if inlined != (member_inline_size <= 4) {
359 return Err(fidl::Error::InvalidInlineBitInEnvelope);
360 }
361 let inner_offset;
362 let mut inner_depth = depth.clone();
363 if inlined {
364 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
365 inner_offset = next_offset;
366 } else {
367 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
368 inner_depth.increment()?;
369 }
370 let val_ref = self.vendor_id.get_or_insert_with(|| fidl::new_empty!(VendorId, D));
371 fidl::decode!(VendorId, D, val_ref, decoder, inner_offset, inner_depth)?;
372 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
373 {
374 return Err(fidl::Error::InvalidNumBytesInEnvelope);
375 }
376 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
377 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
378 }
379 }
380
381 next_offset += envelope_size;
382 _next_ordinal_to_read += 1;
383 if next_offset >= end_offset {
384 return Ok(());
385 }
386
387 while _next_ordinal_to_read < 2 {
389 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
390 _next_ordinal_to_read += 1;
391 next_offset += envelope_size;
392 }
393
394 let next_out_of_line = decoder.next_out_of_line();
395 let handles_before = decoder.remaining_handles();
396 if let Some((inlined, num_bytes, num_handles)) =
397 fidl::encoding::decode_envelope_header(decoder, next_offset)?
398 {
399 let member_inline_size =
400 <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
401 if inlined != (member_inline_size <= 4) {
402 return Err(fidl::Error::InvalidInlineBitInEnvelope);
403 }
404 let inner_offset;
405 let mut inner_depth = depth.clone();
406 if inlined {
407 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
408 inner_offset = next_offset;
409 } else {
410 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
411 inner_depth.increment()?;
412 }
413 let val_ref = self.product_id.get_or_insert_with(|| fidl::new_empty!(u16, D));
414 fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
415 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
416 {
417 return Err(fidl::Error::InvalidNumBytesInEnvelope);
418 }
419 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
420 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
421 }
422 }
423
424 next_offset += envelope_size;
425 _next_ordinal_to_read += 1;
426 if next_offset >= end_offset {
427 return Ok(());
428 }
429
430 while _next_ordinal_to_read < 3 {
432 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
433 _next_ordinal_to_read += 1;
434 next_offset += envelope_size;
435 }
436
437 let next_out_of_line = decoder.next_out_of_line();
438 let handles_before = decoder.remaining_handles();
439 if let Some((inlined, num_bytes, num_handles)) =
440 fidl::encoding::decode_envelope_header(decoder, next_offset)?
441 {
442 let member_inline_size =
443 <DeviceReleaseNumber as fidl::encoding::TypeMarker>::inline_size(
444 decoder.context,
445 );
446 if inlined != (member_inline_size <= 4) {
447 return Err(fidl::Error::InvalidInlineBitInEnvelope);
448 }
449 let inner_offset;
450 let mut inner_depth = depth.clone();
451 if inlined {
452 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
453 inner_offset = next_offset;
454 } else {
455 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
456 inner_depth.increment()?;
457 }
458 let val_ref =
459 self.version.get_or_insert_with(|| fidl::new_empty!(DeviceReleaseNumber, D));
460 fidl::decode!(DeviceReleaseNumber, D, val_ref, decoder, inner_offset, inner_depth)?;
461 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
462 {
463 return Err(fidl::Error::InvalidNumBytesInEnvelope);
464 }
465 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
466 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
467 }
468 }
469
470 next_offset += envelope_size;
471 _next_ordinal_to_read += 1;
472 if next_offset >= end_offset {
473 return Ok(());
474 }
475
476 while _next_ordinal_to_read < 4 {
478 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
479 _next_ordinal_to_read += 1;
480 next_offset += envelope_size;
481 }
482
483 let next_out_of_line = decoder.next_out_of_line();
484 let handles_before = decoder.remaining_handles();
485 if let Some((inlined, num_bytes, num_handles)) =
486 fidl::encoding::decode_envelope_header(decoder, next_offset)?
487 {
488 let member_inline_size =
489 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
490 if inlined != (member_inline_size <= 4) {
491 return Err(fidl::Error::InvalidInlineBitInEnvelope);
492 }
493 let inner_offset;
494 let mut inner_depth = depth.clone();
495 if inlined {
496 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
497 inner_offset = next_offset;
498 } else {
499 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
500 inner_depth.increment()?;
501 }
502 let val_ref = self.primary.get_or_insert_with(|| fidl::new_empty!(bool, D));
503 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
504 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
505 {
506 return Err(fidl::Error::InvalidNumBytesInEnvelope);
507 }
508 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
509 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
510 }
511 }
512
513 next_offset += envelope_size;
514 _next_ordinal_to_read += 1;
515 if next_offset >= end_offset {
516 return Ok(());
517 }
518
519 while _next_ordinal_to_read < 5 {
521 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
522 _next_ordinal_to_read += 1;
523 next_offset += envelope_size;
524 }
525
526 let next_out_of_line = decoder.next_out_of_line();
527 let handles_before = decoder.remaining_handles();
528 if let Some((inlined, num_bytes, num_handles)) =
529 fidl::encoding::decode_envelope_header(decoder, next_offset)?
530 {
531 let member_inline_size =
532 <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
533 decoder.context,
534 );
535 if inlined != (member_inline_size <= 4) {
536 return Err(fidl::Error::InvalidInlineBitInEnvelope);
537 }
538 let inner_offset;
539 let mut inner_depth = depth.clone();
540 if inlined {
541 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
542 inner_offset = next_offset;
543 } else {
544 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
545 inner_depth.increment()?;
546 }
547 let val_ref = self
548 .service_description
549 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
550 fidl::decode!(
551 fidl::encoding::BoundedString<128>,
552 D,
553 val_ref,
554 decoder,
555 inner_offset,
556 inner_depth
557 )?;
558 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
559 {
560 return Err(fidl::Error::InvalidNumBytesInEnvelope);
561 }
562 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
563 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
564 }
565 }
566
567 next_offset += envelope_size;
568
569 while next_offset < end_offset {
571 _next_ordinal_to_read += 1;
572 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
573 next_offset += envelope_size;
574 }
575
576 Ok(())
577 }
578 }
579
580 impl DeviceReleaseNumber {
581 #[inline(always)]
582 fn max_ordinal_present(&self) -> u64 {
583 if let Some(_) = self.subminor {
584 return 3;
585 }
586 if let Some(_) = self.minor {
587 return 2;
588 }
589 if let Some(_) = self.major {
590 return 1;
591 }
592 0
593 }
594 }
595
596 impl fidl::encoding::ValueTypeMarker for DeviceReleaseNumber {
597 type Borrowed<'a> = &'a Self;
598 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
599 value
600 }
601 }
602
603 unsafe impl fidl::encoding::TypeMarker for DeviceReleaseNumber {
604 type Owned = Self;
605
606 #[inline(always)]
607 fn inline_align(_context: fidl::encoding::Context) -> usize {
608 8
609 }
610
611 #[inline(always)]
612 fn inline_size(_context: fidl::encoding::Context) -> usize {
613 16
614 }
615 }
616
617 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceReleaseNumber, D>
618 for &DeviceReleaseNumber
619 {
620 unsafe fn encode(
621 self,
622 encoder: &mut fidl::encoding::Encoder<'_, D>,
623 offset: usize,
624 mut depth: fidl::encoding::Depth,
625 ) -> fidl::Result<()> {
626 encoder.debug_check_bounds::<DeviceReleaseNumber>(offset);
627 let max_ordinal: u64 = self.max_ordinal_present();
629 encoder.write_num(max_ordinal, offset);
630 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
631 if max_ordinal == 0 {
633 return Ok(());
634 }
635 depth.increment()?;
636 let envelope_size = 8;
637 let bytes_len = max_ordinal as usize * envelope_size;
638 #[allow(unused_variables)]
639 let offset = encoder.out_of_line_offset(bytes_len);
640 let mut _prev_end_offset: usize = 0;
641 if 1 > max_ordinal {
642 return Ok(());
643 }
644
645 let cur_offset: usize = (1 - 1) * envelope_size;
648
649 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
651
652 fidl::encoding::encode_in_envelope_optional::<u8, D>(
657 self.major.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
658 encoder,
659 offset + cur_offset,
660 depth,
661 )?;
662
663 _prev_end_offset = cur_offset + envelope_size;
664 if 2 > max_ordinal {
665 return Ok(());
666 }
667
668 let cur_offset: usize = (2 - 1) * envelope_size;
671
672 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
674
675 fidl::encoding::encode_in_envelope_optional::<u8, D>(
680 self.minor.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
681 encoder,
682 offset + cur_offset,
683 depth,
684 )?;
685
686 _prev_end_offset = cur_offset + envelope_size;
687 if 3 > max_ordinal {
688 return Ok(());
689 }
690
691 let cur_offset: usize = (3 - 1) * envelope_size;
694
695 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
697
698 fidl::encoding::encode_in_envelope_optional::<u8, D>(
703 self.subminor.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
704 encoder,
705 offset + cur_offset,
706 depth,
707 )?;
708
709 _prev_end_offset = cur_offset + envelope_size;
710
711 Ok(())
712 }
713 }
714
715 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceReleaseNumber {
716 #[inline(always)]
717 fn new_empty() -> Self {
718 Self::default()
719 }
720
721 unsafe fn decode(
722 &mut self,
723 decoder: &mut fidl::encoding::Decoder<'_, D>,
724 offset: usize,
725 mut depth: fidl::encoding::Depth,
726 ) -> fidl::Result<()> {
727 decoder.debug_check_bounds::<Self>(offset);
728 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
729 None => return Err(fidl::Error::NotNullable),
730 Some(len) => len,
731 };
732 if len == 0 {
734 return Ok(());
735 };
736 depth.increment()?;
737 let envelope_size = 8;
738 let bytes_len = len * envelope_size;
739 let offset = decoder.out_of_line_offset(bytes_len)?;
740 let mut _next_ordinal_to_read = 0;
742 let mut next_offset = offset;
743 let end_offset = offset + bytes_len;
744 _next_ordinal_to_read += 1;
745 if next_offset >= end_offset {
746 return Ok(());
747 }
748
749 while _next_ordinal_to_read < 1 {
751 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
752 _next_ordinal_to_read += 1;
753 next_offset += envelope_size;
754 }
755
756 let next_out_of_line = decoder.next_out_of_line();
757 let handles_before = decoder.remaining_handles();
758 if let Some((inlined, num_bytes, num_handles)) =
759 fidl::encoding::decode_envelope_header(decoder, next_offset)?
760 {
761 let member_inline_size =
762 <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
763 if inlined != (member_inline_size <= 4) {
764 return Err(fidl::Error::InvalidInlineBitInEnvelope);
765 }
766 let inner_offset;
767 let mut inner_depth = depth.clone();
768 if inlined {
769 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
770 inner_offset = next_offset;
771 } else {
772 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
773 inner_depth.increment()?;
774 }
775 let val_ref = self.major.get_or_insert_with(|| fidl::new_empty!(u8, D));
776 fidl::decode!(u8, D, val_ref, decoder, inner_offset, inner_depth)?;
777 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
778 {
779 return Err(fidl::Error::InvalidNumBytesInEnvelope);
780 }
781 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
782 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
783 }
784 }
785
786 next_offset += envelope_size;
787 _next_ordinal_to_read += 1;
788 if next_offset >= end_offset {
789 return Ok(());
790 }
791
792 while _next_ordinal_to_read < 2 {
794 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
795 _next_ordinal_to_read += 1;
796 next_offset += envelope_size;
797 }
798
799 let next_out_of_line = decoder.next_out_of_line();
800 let handles_before = decoder.remaining_handles();
801 if let Some((inlined, num_bytes, num_handles)) =
802 fidl::encoding::decode_envelope_header(decoder, next_offset)?
803 {
804 let member_inline_size =
805 <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
806 if inlined != (member_inline_size <= 4) {
807 return Err(fidl::Error::InvalidInlineBitInEnvelope);
808 }
809 let inner_offset;
810 let mut inner_depth = depth.clone();
811 if inlined {
812 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
813 inner_offset = next_offset;
814 } else {
815 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
816 inner_depth.increment()?;
817 }
818 let val_ref = self.minor.get_or_insert_with(|| fidl::new_empty!(u8, D));
819 fidl::decode!(u8, D, val_ref, decoder, inner_offset, inner_depth)?;
820 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
821 {
822 return Err(fidl::Error::InvalidNumBytesInEnvelope);
823 }
824 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
825 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
826 }
827 }
828
829 next_offset += envelope_size;
830 _next_ordinal_to_read += 1;
831 if next_offset >= end_offset {
832 return Ok(());
833 }
834
835 while _next_ordinal_to_read < 3 {
837 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
838 _next_ordinal_to_read += 1;
839 next_offset += envelope_size;
840 }
841
842 let next_out_of_line = decoder.next_out_of_line();
843 let handles_before = decoder.remaining_handles();
844 if let Some((inlined, num_bytes, num_handles)) =
845 fidl::encoding::decode_envelope_header(decoder, next_offset)?
846 {
847 let member_inline_size =
848 <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
849 if inlined != (member_inline_size <= 4) {
850 return Err(fidl::Error::InvalidInlineBitInEnvelope);
851 }
852 let inner_offset;
853 let mut inner_depth = depth.clone();
854 if inlined {
855 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
856 inner_offset = next_offset;
857 } else {
858 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
859 inner_depth.increment()?;
860 }
861 let val_ref = self.subminor.get_or_insert_with(|| fidl::new_empty!(u8, D));
862 fidl::decode!(u8, D, val_ref, decoder, inner_offset, inner_depth)?;
863 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
864 {
865 return Err(fidl::Error::InvalidNumBytesInEnvelope);
866 }
867 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
868 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
869 }
870 }
871
872 next_offset += envelope_size;
873
874 while next_offset < end_offset {
876 _next_ordinal_to_read += 1;
877 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
878 next_offset += envelope_size;
879 }
880
881 Ok(())
882 }
883 }
884
885 impl fidl::encoding::ValueTypeMarker for VendorId {
886 type Borrowed<'a> = &'a Self;
887 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
888 value
889 }
890 }
891
892 unsafe impl fidl::encoding::TypeMarker for VendorId {
893 type Owned = Self;
894
895 #[inline(always)]
896 fn inline_align(_context: fidl::encoding::Context) -> usize {
897 8
898 }
899
900 #[inline(always)]
901 fn inline_size(_context: fidl::encoding::Context) -> usize {
902 16
903 }
904 }
905
906 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VendorId, D> for &VendorId {
907 #[inline]
908 unsafe fn encode(
909 self,
910 encoder: &mut fidl::encoding::Encoder<'_, D>,
911 offset: usize,
912 _depth: fidl::encoding::Depth,
913 ) -> fidl::Result<()> {
914 encoder.debug_check_bounds::<VendorId>(offset);
915 encoder.write_num::<u64>(self.ordinal(), offset);
916 match self {
917 VendorId::BluetoothSigId(ref val) => fidl::encoding::encode_in_envelope::<u16, D>(
918 <u16 as fidl::encoding::ValueTypeMarker>::borrow(val),
919 encoder,
920 offset + 8,
921 _depth,
922 ),
923 VendorId::UsbIfId(ref val) => fidl::encoding::encode_in_envelope::<u16, D>(
924 <u16 as fidl::encoding::ValueTypeMarker>::borrow(val),
925 encoder,
926 offset + 8,
927 _depth,
928 ),
929 VendorId::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
930 }
931 }
932 }
933
934 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VendorId {
935 #[inline(always)]
936 fn new_empty() -> Self {
937 Self::__SourceBreaking { unknown_ordinal: 0 }
938 }
939
940 #[inline]
941 unsafe fn decode(
942 &mut self,
943 decoder: &mut fidl::encoding::Decoder<'_, D>,
944 offset: usize,
945 mut depth: fidl::encoding::Depth,
946 ) -> fidl::Result<()> {
947 decoder.debug_check_bounds::<Self>(offset);
948 #[allow(unused_variables)]
949 let next_out_of_line = decoder.next_out_of_line();
950 let handles_before = decoder.remaining_handles();
951 let (ordinal, inlined, num_bytes, num_handles) =
952 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
953
954 let member_inline_size = match ordinal {
955 1 => <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
956 2 => <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
957 0 => return Err(fidl::Error::UnknownUnionTag),
958 _ => num_bytes as usize,
959 };
960
961 if inlined != (member_inline_size <= 4) {
962 return Err(fidl::Error::InvalidInlineBitInEnvelope);
963 }
964 let _inner_offset;
965 if inlined {
966 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
967 _inner_offset = offset + 8;
968 } else {
969 depth.increment()?;
970 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
971 }
972 match ordinal {
973 1 => {
974 #[allow(irrefutable_let_patterns)]
975 if let VendorId::BluetoothSigId(_) = self {
976 } else {
978 *self = VendorId::BluetoothSigId(fidl::new_empty!(u16, D));
980 }
981 #[allow(irrefutable_let_patterns)]
982 if let VendorId::BluetoothSigId(ref mut val) = self {
983 fidl::decode!(u16, D, val, decoder, _inner_offset, depth)?;
984 } else {
985 unreachable!()
986 }
987 }
988 2 => {
989 #[allow(irrefutable_let_patterns)]
990 if let VendorId::UsbIfId(_) = self {
991 } else {
993 *self = VendorId::UsbIfId(fidl::new_empty!(u16, D));
995 }
996 #[allow(irrefutable_let_patterns)]
997 if let VendorId::UsbIfId(ref mut val) = self {
998 fidl::decode!(u16, D, val, decoder, _inner_offset, depth)?;
999 } else {
1000 unreachable!()
1001 }
1002 }
1003 #[allow(deprecated)]
1004 ordinal => {
1005 for _ in 0..num_handles {
1006 decoder.drop_next_handle()?;
1007 }
1008 *self = VendorId::__SourceBreaking { unknown_ordinal: ordinal };
1009 }
1010 }
1011 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1012 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1013 }
1014 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1015 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1016 }
1017 Ok(())
1018 }
1019 }
1020}