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
11#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
14pub enum PacketFormat {
15 Command,
17 AclData,
19 SynchronousData,
21 Event,
23 IsoData,
25 #[doc(hidden)]
26 __SourceBreaking { unknown_ordinal: u32 },
27}
28
29#[macro_export]
31macro_rules! PacketFormatUnknown {
32 () => {
33 _
34 };
35}
36
37impl PacketFormat {
38 #[inline]
39 pub fn from_primitive(prim: u32) -> Option<Self> {
40 match prim {
41 1 => Some(Self::Command),
42 2 => Some(Self::AclData),
43 3 => Some(Self::SynchronousData),
44 4 => Some(Self::Event),
45 5 => Some(Self::IsoData),
46 _ => None,
47 }
48 }
49
50 #[inline]
51 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
52 match prim {
53 1 => Self::Command,
54 2 => Self::AclData,
55 3 => Self::SynchronousData,
56 4 => Self::Event,
57 5 => Self::IsoData,
58 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
59 }
60 }
61
62 #[inline]
63 pub fn unknown() -> Self {
64 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
65 }
66
67 #[inline]
68 pub const fn into_primitive(self) -> u32 {
69 match self {
70 Self::Command => 1,
71 Self::AclData => 2,
72 Self::SynchronousData => 3,
73 Self::Event => 4,
74 Self::IsoData => 5,
75 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
76 }
77 }
78
79 #[inline]
80 pub fn is_unknown(&self) -> bool {
81 match self {
82 Self::__SourceBreaking { unknown_ordinal: _ } => true,
83 _ => false,
84 }
85 }
86}
87
88#[derive(Clone, Debug, Default, PartialEq)]
89pub struct DevicePackets {
90 pub host_device: Option<String>,
93 pub packets: Option<Vec<SnoopPacket>>,
96 #[doc(hidden)]
97 pub __source_breaking: fidl::marker::SourceBreaking,
98}
99
100impl fidl::Persistable for DevicePackets {}
101
102#[derive(Clone, Debug, Default, PartialEq)]
103pub struct SnoopPacket {
104 pub is_received: Option<bool>,
107 pub format: Option<PacketFormat>,
110 pub timestamp: Option<i64>,
113 pub length: Option<u32>,
116 pub data: Option<Vec<u8>>,
119 #[doc(hidden)]
120 pub __source_breaking: fidl::marker::SourceBreaking,
121}
122
123impl fidl::Persistable for SnoopPacket {}
124
125#[derive(Clone, Debug, Default, PartialEq)]
126pub struct UnrecognizedDeviceName {
127 #[doc(hidden)]
128 pub __source_breaking: fidl::marker::SourceBreaking,
129}
130
131impl fidl::Persistable for UnrecognizedDeviceName {}
132
133#[derive(Clone, Debug)]
134pub enum CaptureError {
135 UnrecognizedDeviceName(UnrecognizedDeviceName),
137 #[doc(hidden)]
138 __SourceBreaking { unknown_ordinal: u64 },
139}
140
141#[macro_export]
143macro_rules! CaptureErrorUnknown {
144 () => {
145 _
146 };
147}
148
149impl PartialEq for CaptureError {
151 fn eq(&self, other: &Self) -> bool {
152 match (self, other) {
153 (Self::UnrecognizedDeviceName(x), Self::UnrecognizedDeviceName(y)) => *x == *y,
154 _ => false,
155 }
156 }
157}
158
159impl CaptureError {
160 #[inline]
161 pub fn ordinal(&self) -> u64 {
162 match *self {
163 Self::UnrecognizedDeviceName(_) => 1,
164 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
165 }
166 }
167
168 #[inline]
169 pub fn unknown_variant_for_testing() -> Self {
170 Self::__SourceBreaking { unknown_ordinal: 0 }
171 }
172
173 #[inline]
174 pub fn is_unknown(&self) -> bool {
175 match self {
176 Self::__SourceBreaking { .. } => true,
177 _ => false,
178 }
179 }
180}
181
182impl fidl::Persistable for CaptureError {}
183
184mod internal {
185 use super::*;
186 unsafe impl fidl::encoding::TypeMarker for PacketFormat {
187 type Owned = Self;
188
189 #[inline(always)]
190 fn inline_align(_context: fidl::encoding::Context) -> usize {
191 std::mem::align_of::<u32>()
192 }
193
194 #[inline(always)]
195 fn inline_size(_context: fidl::encoding::Context) -> usize {
196 std::mem::size_of::<u32>()
197 }
198
199 #[inline(always)]
200 fn encode_is_copy() -> bool {
201 false
202 }
203
204 #[inline(always)]
205 fn decode_is_copy() -> bool {
206 false
207 }
208 }
209
210 impl fidl::encoding::ValueTypeMarker for PacketFormat {
211 type Borrowed<'a> = Self;
212 #[inline(always)]
213 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
214 *value
215 }
216 }
217
218 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PacketFormat {
219 #[inline]
220 unsafe fn encode(
221 self,
222 encoder: &mut fidl::encoding::Encoder<'_, D>,
223 offset: usize,
224 _depth: fidl::encoding::Depth,
225 ) -> fidl::Result<()> {
226 encoder.debug_check_bounds::<Self>(offset);
227 encoder.write_num(self.into_primitive(), offset);
228 Ok(())
229 }
230 }
231
232 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PacketFormat {
233 #[inline(always)]
234 fn new_empty() -> Self {
235 Self::unknown()
236 }
237
238 #[inline]
239 unsafe fn decode(
240 &mut self,
241 decoder: &mut fidl::encoding::Decoder<'_, D>,
242 offset: usize,
243 _depth: fidl::encoding::Depth,
244 ) -> fidl::Result<()> {
245 decoder.debug_check_bounds::<Self>(offset);
246 let prim = decoder.read_num::<u32>(offset);
247
248 *self = Self::from_primitive_allow_unknown(prim);
249 Ok(())
250 }
251 }
252
253 impl DevicePackets {
254 #[inline(always)]
255 fn max_ordinal_present(&self) -> u64 {
256 if let Some(_) = self.packets {
257 return 2;
258 }
259 if let Some(_) = self.host_device {
260 return 1;
261 }
262 0
263 }
264 }
265
266 impl fidl::encoding::ValueTypeMarker for DevicePackets {
267 type Borrowed<'a> = &'a Self;
268 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
269 value
270 }
271 }
272
273 unsafe impl fidl::encoding::TypeMarker for DevicePackets {
274 type Owned = Self;
275
276 #[inline(always)]
277 fn inline_align(_context: fidl::encoding::Context) -> usize {
278 8
279 }
280
281 #[inline(always)]
282 fn inline_size(_context: fidl::encoding::Context) -> usize {
283 16
284 }
285 }
286
287 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DevicePackets, D>
288 for &DevicePackets
289 {
290 unsafe fn encode(
291 self,
292 encoder: &mut fidl::encoding::Encoder<'_, D>,
293 offset: usize,
294 mut depth: fidl::encoding::Depth,
295 ) -> fidl::Result<()> {
296 encoder.debug_check_bounds::<DevicePackets>(offset);
297 let max_ordinal: u64 = self.max_ordinal_present();
299 encoder.write_num(max_ordinal, offset);
300 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
301 if max_ordinal == 0 {
303 return Ok(());
304 }
305 depth.increment()?;
306 let envelope_size = 8;
307 let bytes_len = max_ordinal as usize * envelope_size;
308 #[allow(unused_variables)]
309 let offset = encoder.out_of_line_offset(bytes_len);
310 let mut _prev_end_offset: usize = 0;
311 if 1 > max_ordinal {
312 return Ok(());
313 }
314
315 let cur_offset: usize = (1 - 1) * envelope_size;
318
319 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
321
322 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<255>, D>(
327 self.host_device.as_ref().map(
328 <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow,
329 ),
330 encoder,
331 offset + cur_offset,
332 depth,
333 )?;
334
335 _prev_end_offset = cur_offset + envelope_size;
336 if 2 > max_ordinal {
337 return Ok(());
338 }
339
340 let cur_offset: usize = (2 - 1) * envelope_size;
343
344 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
346
347 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<SnoopPacket>, D>(
352 self.packets.as_ref().map(<fidl::encoding::UnboundedVector<SnoopPacket> as fidl::encoding::ValueTypeMarker>::borrow),
353 encoder, offset + cur_offset, depth
354 )?;
355
356 _prev_end_offset = cur_offset + envelope_size;
357
358 Ok(())
359 }
360 }
361
362 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DevicePackets {
363 #[inline(always)]
364 fn new_empty() -> Self {
365 Self::default()
366 }
367
368 unsafe fn decode(
369 &mut self,
370 decoder: &mut fidl::encoding::Decoder<'_, D>,
371 offset: usize,
372 mut depth: fidl::encoding::Depth,
373 ) -> fidl::Result<()> {
374 decoder.debug_check_bounds::<Self>(offset);
375 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
376 None => return Err(fidl::Error::NotNullable),
377 Some(len) => len,
378 };
379 if len == 0 {
381 return Ok(());
382 };
383 depth.increment()?;
384 let envelope_size = 8;
385 let bytes_len = len * envelope_size;
386 let offset = decoder.out_of_line_offset(bytes_len)?;
387 let mut _next_ordinal_to_read = 0;
389 let mut next_offset = offset;
390 let end_offset = offset + bytes_len;
391 _next_ordinal_to_read += 1;
392 if next_offset >= end_offset {
393 return Ok(());
394 }
395
396 while _next_ordinal_to_read < 1 {
398 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
399 _next_ordinal_to_read += 1;
400 next_offset += envelope_size;
401 }
402
403 let next_out_of_line = decoder.next_out_of_line();
404 let handles_before = decoder.remaining_handles();
405 if let Some((inlined, num_bytes, num_handles)) =
406 fidl::encoding::decode_envelope_header(decoder, next_offset)?
407 {
408 let member_inline_size =
409 <fidl::encoding::BoundedString<255> as fidl::encoding::TypeMarker>::inline_size(
410 decoder.context,
411 );
412 if inlined != (member_inline_size <= 4) {
413 return Err(fidl::Error::InvalidInlineBitInEnvelope);
414 }
415 let inner_offset;
416 let mut inner_depth = depth.clone();
417 if inlined {
418 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
419 inner_offset = next_offset;
420 } else {
421 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
422 inner_depth.increment()?;
423 }
424 let val_ref = self
425 .host_device
426 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<255>, D));
427 fidl::decode!(
428 fidl::encoding::BoundedString<255>,
429 D,
430 val_ref,
431 decoder,
432 inner_offset,
433 inner_depth
434 )?;
435 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
436 {
437 return Err(fidl::Error::InvalidNumBytesInEnvelope);
438 }
439 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
440 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
441 }
442 }
443
444 next_offset += envelope_size;
445 _next_ordinal_to_read += 1;
446 if next_offset >= end_offset {
447 return Ok(());
448 }
449
450 while _next_ordinal_to_read < 2 {
452 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
453 _next_ordinal_to_read += 1;
454 next_offset += envelope_size;
455 }
456
457 let next_out_of_line = decoder.next_out_of_line();
458 let handles_before = decoder.remaining_handles();
459 if let Some((inlined, num_bytes, num_handles)) =
460 fidl::encoding::decode_envelope_header(decoder, next_offset)?
461 {
462 let member_inline_size = <fidl::encoding::UnboundedVector<SnoopPacket> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
463 if inlined != (member_inline_size <= 4) {
464 return Err(fidl::Error::InvalidInlineBitInEnvelope);
465 }
466 let inner_offset;
467 let mut inner_depth = depth.clone();
468 if inlined {
469 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
470 inner_offset = next_offset;
471 } else {
472 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
473 inner_depth.increment()?;
474 }
475 let val_ref = self.packets.get_or_insert_with(|| {
476 fidl::new_empty!(fidl::encoding::UnboundedVector<SnoopPacket>, D)
477 });
478 fidl::decode!(
479 fidl::encoding::UnboundedVector<SnoopPacket>,
480 D,
481 val_ref,
482 decoder,
483 inner_offset,
484 inner_depth
485 )?;
486 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
487 {
488 return Err(fidl::Error::InvalidNumBytesInEnvelope);
489 }
490 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
491 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
492 }
493 }
494
495 next_offset += envelope_size;
496
497 while next_offset < end_offset {
499 _next_ordinal_to_read += 1;
500 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
501 next_offset += envelope_size;
502 }
503
504 Ok(())
505 }
506 }
507
508 impl SnoopPacket {
509 #[inline(always)]
510 fn max_ordinal_present(&self) -> u64 {
511 if let Some(_) = self.data {
512 return 5;
513 }
514 if let Some(_) = self.length {
515 return 4;
516 }
517 if let Some(_) = self.timestamp {
518 return 3;
519 }
520 if let Some(_) = self.format {
521 return 2;
522 }
523 if let Some(_) = self.is_received {
524 return 1;
525 }
526 0
527 }
528 }
529
530 impl fidl::encoding::ValueTypeMarker for SnoopPacket {
531 type Borrowed<'a> = &'a Self;
532 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
533 value
534 }
535 }
536
537 unsafe impl fidl::encoding::TypeMarker for SnoopPacket {
538 type Owned = Self;
539
540 #[inline(always)]
541 fn inline_align(_context: fidl::encoding::Context) -> usize {
542 8
543 }
544
545 #[inline(always)]
546 fn inline_size(_context: fidl::encoding::Context) -> usize {
547 16
548 }
549 }
550
551 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SnoopPacket, D>
552 for &SnoopPacket
553 {
554 unsafe fn encode(
555 self,
556 encoder: &mut fidl::encoding::Encoder<'_, D>,
557 offset: usize,
558 mut depth: fidl::encoding::Depth,
559 ) -> fidl::Result<()> {
560 encoder.debug_check_bounds::<SnoopPacket>(offset);
561 let max_ordinal: u64 = self.max_ordinal_present();
563 encoder.write_num(max_ordinal, offset);
564 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
565 if max_ordinal == 0 {
567 return Ok(());
568 }
569 depth.increment()?;
570 let envelope_size = 8;
571 let bytes_len = max_ordinal as usize * envelope_size;
572 #[allow(unused_variables)]
573 let offset = encoder.out_of_line_offset(bytes_len);
574 let mut _prev_end_offset: usize = 0;
575 if 1 > max_ordinal {
576 return Ok(());
577 }
578
579 let cur_offset: usize = (1 - 1) * envelope_size;
582
583 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
585
586 fidl::encoding::encode_in_envelope_optional::<bool, D>(
591 self.is_received.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
592 encoder,
593 offset + cur_offset,
594 depth,
595 )?;
596
597 _prev_end_offset = cur_offset + envelope_size;
598 if 2 > max_ordinal {
599 return Ok(());
600 }
601
602 let cur_offset: usize = (2 - 1) * envelope_size;
605
606 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
608
609 fidl::encoding::encode_in_envelope_optional::<PacketFormat, D>(
614 self.format.as_ref().map(<PacketFormat as fidl::encoding::ValueTypeMarker>::borrow),
615 encoder,
616 offset + cur_offset,
617 depth,
618 )?;
619
620 _prev_end_offset = cur_offset + envelope_size;
621 if 3 > max_ordinal {
622 return Ok(());
623 }
624
625 let cur_offset: usize = (3 - 1) * envelope_size;
628
629 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
631
632 fidl::encoding::encode_in_envelope_optional::<i64, D>(
637 self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
638 encoder,
639 offset + cur_offset,
640 depth,
641 )?;
642
643 _prev_end_offset = cur_offset + envelope_size;
644 if 4 > max_ordinal {
645 return Ok(());
646 }
647
648 let cur_offset: usize = (4 - 1) * envelope_size;
651
652 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
654
655 fidl::encoding::encode_in_envelope_optional::<u32, D>(
660 self.length.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
661 encoder,
662 offset + cur_offset,
663 depth,
664 )?;
665
666 _prev_end_offset = cur_offset + envelope_size;
667 if 5 > max_ordinal {
668 return Ok(());
669 }
670
671 let cur_offset: usize = (5 - 1) * envelope_size;
674
675 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
677
678 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<u8>, D>(
683 self.data.as_ref().map(<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow),
684 encoder, offset + cur_offset, depth
685 )?;
686
687 _prev_end_offset = cur_offset + envelope_size;
688
689 Ok(())
690 }
691 }
692
693 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SnoopPacket {
694 #[inline(always)]
695 fn new_empty() -> Self {
696 Self::default()
697 }
698
699 unsafe fn decode(
700 &mut self,
701 decoder: &mut fidl::encoding::Decoder<'_, D>,
702 offset: usize,
703 mut depth: fidl::encoding::Depth,
704 ) -> fidl::Result<()> {
705 decoder.debug_check_bounds::<Self>(offset);
706 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
707 None => return Err(fidl::Error::NotNullable),
708 Some(len) => len,
709 };
710 if len == 0 {
712 return Ok(());
713 };
714 depth.increment()?;
715 let envelope_size = 8;
716 let bytes_len = len * envelope_size;
717 let offset = decoder.out_of_line_offset(bytes_len)?;
718 let mut _next_ordinal_to_read = 0;
720 let mut next_offset = offset;
721 let end_offset = offset + bytes_len;
722 _next_ordinal_to_read += 1;
723 if next_offset >= end_offset {
724 return Ok(());
725 }
726
727 while _next_ordinal_to_read < 1 {
729 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
730 _next_ordinal_to_read += 1;
731 next_offset += envelope_size;
732 }
733
734 let next_out_of_line = decoder.next_out_of_line();
735 let handles_before = decoder.remaining_handles();
736 if let Some((inlined, num_bytes, num_handles)) =
737 fidl::encoding::decode_envelope_header(decoder, next_offset)?
738 {
739 let member_inline_size =
740 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
741 if inlined != (member_inline_size <= 4) {
742 return Err(fidl::Error::InvalidInlineBitInEnvelope);
743 }
744 let inner_offset;
745 let mut inner_depth = depth.clone();
746 if inlined {
747 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
748 inner_offset = next_offset;
749 } else {
750 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
751 inner_depth.increment()?;
752 }
753 let val_ref = self.is_received.get_or_insert_with(|| fidl::new_empty!(bool, D));
754 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
755 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
756 {
757 return Err(fidl::Error::InvalidNumBytesInEnvelope);
758 }
759 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
760 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
761 }
762 }
763
764 next_offset += envelope_size;
765 _next_ordinal_to_read += 1;
766 if next_offset >= end_offset {
767 return Ok(());
768 }
769
770 while _next_ordinal_to_read < 2 {
772 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
773 _next_ordinal_to_read += 1;
774 next_offset += envelope_size;
775 }
776
777 let next_out_of_line = decoder.next_out_of_line();
778 let handles_before = decoder.remaining_handles();
779 if let Some((inlined, num_bytes, num_handles)) =
780 fidl::encoding::decode_envelope_header(decoder, next_offset)?
781 {
782 let member_inline_size =
783 <PacketFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
784 if inlined != (member_inline_size <= 4) {
785 return Err(fidl::Error::InvalidInlineBitInEnvelope);
786 }
787 let inner_offset;
788 let mut inner_depth = depth.clone();
789 if inlined {
790 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
791 inner_offset = next_offset;
792 } else {
793 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
794 inner_depth.increment()?;
795 }
796 let val_ref = self.format.get_or_insert_with(|| fidl::new_empty!(PacketFormat, D));
797 fidl::decode!(PacketFormat, D, val_ref, decoder, inner_offset, inner_depth)?;
798 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
799 {
800 return Err(fidl::Error::InvalidNumBytesInEnvelope);
801 }
802 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
803 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
804 }
805 }
806
807 next_offset += envelope_size;
808 _next_ordinal_to_read += 1;
809 if next_offset >= end_offset {
810 return Ok(());
811 }
812
813 while _next_ordinal_to_read < 3 {
815 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
816 _next_ordinal_to_read += 1;
817 next_offset += envelope_size;
818 }
819
820 let next_out_of_line = decoder.next_out_of_line();
821 let handles_before = decoder.remaining_handles();
822 if let Some((inlined, num_bytes, num_handles)) =
823 fidl::encoding::decode_envelope_header(decoder, next_offset)?
824 {
825 let member_inline_size =
826 <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
827 if inlined != (member_inline_size <= 4) {
828 return Err(fidl::Error::InvalidInlineBitInEnvelope);
829 }
830 let inner_offset;
831 let mut inner_depth = depth.clone();
832 if inlined {
833 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
834 inner_offset = next_offset;
835 } else {
836 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
837 inner_depth.increment()?;
838 }
839 let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
840 fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
841 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
842 {
843 return Err(fidl::Error::InvalidNumBytesInEnvelope);
844 }
845 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
846 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
847 }
848 }
849
850 next_offset += envelope_size;
851 _next_ordinal_to_read += 1;
852 if next_offset >= end_offset {
853 return Ok(());
854 }
855
856 while _next_ordinal_to_read < 4 {
858 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
859 _next_ordinal_to_read += 1;
860 next_offset += envelope_size;
861 }
862
863 let next_out_of_line = decoder.next_out_of_line();
864 let handles_before = decoder.remaining_handles();
865 if let Some((inlined, num_bytes, num_handles)) =
866 fidl::encoding::decode_envelope_header(decoder, next_offset)?
867 {
868 let member_inline_size =
869 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
870 if inlined != (member_inline_size <= 4) {
871 return Err(fidl::Error::InvalidInlineBitInEnvelope);
872 }
873 let inner_offset;
874 let mut inner_depth = depth.clone();
875 if inlined {
876 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
877 inner_offset = next_offset;
878 } else {
879 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
880 inner_depth.increment()?;
881 }
882 let val_ref = self.length.get_or_insert_with(|| fidl::new_empty!(u32, D));
883 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
884 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
885 {
886 return Err(fidl::Error::InvalidNumBytesInEnvelope);
887 }
888 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
889 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
890 }
891 }
892
893 next_offset += envelope_size;
894 _next_ordinal_to_read += 1;
895 if next_offset >= end_offset {
896 return Ok(());
897 }
898
899 while _next_ordinal_to_read < 5 {
901 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
902 _next_ordinal_to_read += 1;
903 next_offset += envelope_size;
904 }
905
906 let next_out_of_line = decoder.next_out_of_line();
907 let handles_before = decoder.remaining_handles();
908 if let Some((inlined, num_bytes, num_handles)) =
909 fidl::encoding::decode_envelope_header(decoder, next_offset)?
910 {
911 let member_inline_size = <fidl::encoding::UnboundedVector<u8> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
912 if inlined != (member_inline_size <= 4) {
913 return Err(fidl::Error::InvalidInlineBitInEnvelope);
914 }
915 let inner_offset;
916 let mut inner_depth = depth.clone();
917 if inlined {
918 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
919 inner_offset = next_offset;
920 } else {
921 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
922 inner_depth.increment()?;
923 }
924 let val_ref = self.data.get_or_insert_with(|| {
925 fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D)
926 });
927 fidl::decode!(
928 fidl::encoding::UnboundedVector<u8>,
929 D,
930 val_ref,
931 decoder,
932 inner_offset,
933 inner_depth
934 )?;
935 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
936 {
937 return Err(fidl::Error::InvalidNumBytesInEnvelope);
938 }
939 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
940 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
941 }
942 }
943
944 next_offset += envelope_size;
945
946 while next_offset < end_offset {
948 _next_ordinal_to_read += 1;
949 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
950 next_offset += envelope_size;
951 }
952
953 Ok(())
954 }
955 }
956
957 impl UnrecognizedDeviceName {
958 #[inline(always)]
959 fn max_ordinal_present(&self) -> u64 {
960 0
961 }
962 }
963
964 impl fidl::encoding::ValueTypeMarker for UnrecognizedDeviceName {
965 type Borrowed<'a> = &'a Self;
966 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
967 value
968 }
969 }
970
971 unsafe impl fidl::encoding::TypeMarker for UnrecognizedDeviceName {
972 type Owned = Self;
973
974 #[inline(always)]
975 fn inline_align(_context: fidl::encoding::Context) -> usize {
976 8
977 }
978
979 #[inline(always)]
980 fn inline_size(_context: fidl::encoding::Context) -> usize {
981 16
982 }
983 }
984
985 unsafe impl<D: fidl::encoding::ResourceDialect>
986 fidl::encoding::Encode<UnrecognizedDeviceName, D> for &UnrecognizedDeviceName
987 {
988 unsafe fn encode(
989 self,
990 encoder: &mut fidl::encoding::Encoder<'_, D>,
991 offset: usize,
992 mut depth: fidl::encoding::Depth,
993 ) -> fidl::Result<()> {
994 encoder.debug_check_bounds::<UnrecognizedDeviceName>(offset);
995 let max_ordinal: u64 = self.max_ordinal_present();
997 encoder.write_num(max_ordinal, offset);
998 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
999 if max_ordinal == 0 {
1001 return Ok(());
1002 }
1003 depth.increment()?;
1004 let envelope_size = 8;
1005 let bytes_len = max_ordinal as usize * envelope_size;
1006 #[allow(unused_variables)]
1007 let offset = encoder.out_of_line_offset(bytes_len);
1008 let mut _prev_end_offset: usize = 0;
1009
1010 Ok(())
1011 }
1012 }
1013
1014 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1015 for UnrecognizedDeviceName
1016 {
1017 #[inline(always)]
1018 fn new_empty() -> Self {
1019 Self::default()
1020 }
1021
1022 unsafe fn decode(
1023 &mut self,
1024 decoder: &mut fidl::encoding::Decoder<'_, D>,
1025 offset: usize,
1026 mut depth: fidl::encoding::Depth,
1027 ) -> fidl::Result<()> {
1028 decoder.debug_check_bounds::<Self>(offset);
1029 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1030 None => return Err(fidl::Error::NotNullable),
1031 Some(len) => len,
1032 };
1033 if len == 0 {
1035 return Ok(());
1036 };
1037 depth.increment()?;
1038 let envelope_size = 8;
1039 let bytes_len = len * envelope_size;
1040 let offset = decoder.out_of_line_offset(bytes_len)?;
1041 let mut _next_ordinal_to_read = 0;
1043 let mut next_offset = offset;
1044 let end_offset = offset + bytes_len;
1045
1046 while next_offset < end_offset {
1048 _next_ordinal_to_read += 1;
1049 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1050 next_offset += envelope_size;
1051 }
1052
1053 Ok(())
1054 }
1055 }
1056
1057 impl fidl::encoding::ValueTypeMarker for CaptureError {
1058 type Borrowed<'a> = &'a Self;
1059 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1060 value
1061 }
1062 }
1063
1064 unsafe impl fidl::encoding::TypeMarker for CaptureError {
1065 type Owned = Self;
1066
1067 #[inline(always)]
1068 fn inline_align(_context: fidl::encoding::Context) -> usize {
1069 8
1070 }
1071
1072 #[inline(always)]
1073 fn inline_size(_context: fidl::encoding::Context) -> usize {
1074 16
1075 }
1076 }
1077
1078 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CaptureError, D>
1079 for &CaptureError
1080 {
1081 #[inline]
1082 unsafe fn encode(
1083 self,
1084 encoder: &mut fidl::encoding::Encoder<'_, D>,
1085 offset: usize,
1086 _depth: fidl::encoding::Depth,
1087 ) -> fidl::Result<()> {
1088 encoder.debug_check_bounds::<CaptureError>(offset);
1089 encoder.write_num::<u64>(self.ordinal(), offset);
1090 match self {
1091 CaptureError::UnrecognizedDeviceName(ref val) => {
1092 fidl::encoding::encode_in_envelope::<UnrecognizedDeviceName, D>(
1093 <UnrecognizedDeviceName as fidl::encoding::ValueTypeMarker>::borrow(val),
1094 encoder,
1095 offset + 8,
1096 _depth,
1097 )
1098 }
1099 CaptureError::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1100 }
1101 }
1102 }
1103
1104 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CaptureError {
1105 #[inline(always)]
1106 fn new_empty() -> Self {
1107 Self::__SourceBreaking { unknown_ordinal: 0 }
1108 }
1109
1110 #[inline]
1111 unsafe fn decode(
1112 &mut self,
1113 decoder: &mut fidl::encoding::Decoder<'_, D>,
1114 offset: usize,
1115 mut depth: fidl::encoding::Depth,
1116 ) -> fidl::Result<()> {
1117 decoder.debug_check_bounds::<Self>(offset);
1118 #[allow(unused_variables)]
1119 let next_out_of_line = decoder.next_out_of_line();
1120 let handles_before = decoder.remaining_handles();
1121 let (ordinal, inlined, num_bytes, num_handles) =
1122 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1123
1124 let member_inline_size = match ordinal {
1125 1 => <UnrecognizedDeviceName as fidl::encoding::TypeMarker>::inline_size(
1126 decoder.context,
1127 ),
1128 0 => return Err(fidl::Error::UnknownUnionTag),
1129 _ => num_bytes as usize,
1130 };
1131
1132 if inlined != (member_inline_size <= 4) {
1133 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1134 }
1135 let _inner_offset;
1136 if inlined {
1137 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1138 _inner_offset = offset + 8;
1139 } else {
1140 depth.increment()?;
1141 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1142 }
1143 match ordinal {
1144 1 => {
1145 #[allow(irrefutable_let_patterns)]
1146 if let CaptureError::UnrecognizedDeviceName(_) = self {
1147 } else {
1149 *self = CaptureError::UnrecognizedDeviceName(fidl::new_empty!(
1151 UnrecognizedDeviceName,
1152 D
1153 ));
1154 }
1155 #[allow(irrefutable_let_patterns)]
1156 if let CaptureError::UnrecognizedDeviceName(ref mut val) = self {
1157 fidl::decode!(
1158 UnrecognizedDeviceName,
1159 D,
1160 val,
1161 decoder,
1162 _inner_offset,
1163 depth
1164 )?;
1165 } else {
1166 unreachable!()
1167 }
1168 }
1169 #[allow(deprecated)]
1170 ordinal => {
1171 for _ in 0..num_handles {
1172 decoder.drop_next_handle()?;
1173 }
1174 *self = CaptureError::__SourceBreaking { unknown_ordinal: ordinal };
1175 }
1176 }
1177 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1178 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1179 }
1180 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1181 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1182 }
1183 Ok(())
1184 }
1185 }
1186}