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 FIFO_DEPTH: u16 = 128;
13
14pub const MAX_MTU: u32 = 16384;
16
17pub const MAX_MULTICAST_FILTERS: u32 = 64;
19
20pub const MAX_PENDING_OPERATIONS: u32 = 32;
23
24bitflags! {
25 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
28 pub struct Signals: u32 {
29 const WRITABLE = 16777216;
32 const READABLE = 33554432;
35 }
36}
37
38impl Signals {
39 #[deprecated = "Strict bits should not use `has_unknown_bits`"]
40 #[inline(always)]
41 pub fn has_unknown_bits(&self) -> bool {
42 false
43 }
44
45 #[deprecated = "Strict bits should not use `get_unknown_bits`"]
46 #[inline(always)]
47 pub fn get_unknown_bits(&self) -> u32 {
48 0
49 }
50}
51
52#[derive(Clone, Debug, PartialEq)]
53pub struct DevicePairAddPortRequest {
54 pub config: DevicePairPortConfig,
55}
56
57impl fidl::Persistable for DevicePairAddPortRequest {}
58
59#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
60#[repr(C)]
61pub struct DevicePairRemovePortRequest {
62 pub id: u8,
63}
64
65impl fidl::Persistable for DevicePairRemovePortRequest {}
66
67#[derive(Clone, Debug, PartialEq)]
68pub struct DeviceWriteFrameRequest {
69 pub frame: Frame,
70}
71
72impl fidl::Persistable for DeviceWriteFrameRequest {}
73
74#[derive(Clone, Debug, PartialEq)]
75pub struct DeviceReadFrameResponse {
76 pub frame: Frame,
77}
78
79impl fidl::Persistable for DeviceReadFrameResponse {}
80
81#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
82pub struct FrameMetadata {
83 pub info_type: fidl_fuchsia_hardware_network::InfoType,
88 pub info: Vec<u8>,
92 pub flags: u32,
97}
98
99impl fidl::Persistable for FrameMetadata {}
100
101#[derive(Clone, Debug, PartialEq)]
102pub struct PortGetStateResponse {
103 pub state: InternalState,
104}
105
106impl fidl::Persistable for PortGetStateResponse {}
107
108#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
109pub struct PortSetOnlineRequest {
110 pub online: bool,
111}
112
113impl fidl::Persistable for PortSetOnlineRequest {}
114
115#[derive(Clone, Debug, PartialEq)]
116pub struct PortWatchStateResponse {
117 pub state: InternalState,
118}
119
120impl fidl::Persistable for PortWatchStateResponse {}
121
122#[derive(Clone, Debug, Default, PartialEq)]
124pub struct BaseDeviceConfig {
125 pub report_metadata: Option<bool>,
129 pub min_tx_buffer_length: Option<u32>,
133 pub min_rx_buffer_length: Option<u32>,
137 #[doc(hidden)]
138 pub __source_breaking: fidl::marker::SourceBreaking,
139}
140
141impl fidl::Persistable for BaseDeviceConfig {}
142
143#[derive(Clone, Debug, Default, PartialEq)]
145pub struct BasePortConfig {
146 pub id: Option<u8>,
150 pub mtu: Option<u32>,
156 pub rx_types: Option<Vec<fidl_fuchsia_hardware_network::FrameType>>,
162 pub tx_types: Option<Vec<fidl_fuchsia_hardware_network::FrameTypeSupport>>,
168 pub port_class: Option<fidl_fuchsia_hardware_network::PortClass>,
172 #[doc(hidden)]
173 pub __source_breaking: fidl::marker::SourceBreaking,
174}
175
176impl fidl::Persistable for BasePortConfig {}
177
178#[derive(Clone, Debug, Default, PartialEq)]
179pub struct DeviceConfig {
180 pub base: Option<BaseDeviceConfig>,
184 pub blocking: Option<bool>,
190 #[doc(hidden)]
191 pub __source_breaking: fidl::marker::SourceBreaking,
192}
193
194impl fidl::Persistable for DeviceConfig {}
195
196#[derive(Clone, Debug, Default, PartialEq)]
197pub struct DevicePairConfig {
198 pub base: Option<BaseDeviceConfig>,
202 pub fallible_transmit_left: Option<bool>,
209 pub fallible_transmit_right: Option<bool>,
214 #[doc(hidden)]
215 pub __source_breaking: fidl::marker::SourceBreaking,
216}
217
218impl fidl::Persistable for DevicePairConfig {}
219
220#[derive(Clone, Debug, Default, PartialEq)]
221pub struct DevicePairPortConfig {
222 pub base: Option<BasePortConfig>,
226 pub mac_left: Option<fidl_fuchsia_net::MacAddress>,
232 pub mac_right: Option<fidl_fuchsia_net::MacAddress>,
238 #[doc(hidden)]
239 pub __source_breaking: fidl::marker::SourceBreaking,
240}
241
242impl fidl::Persistable for DevicePairPortConfig {}
243
244#[derive(Clone, Debug, Default, PartialEq)]
245pub struct DevicePortConfig {
246 pub base: Option<BasePortConfig>,
250 pub online: Option<bool>,
254 pub mac: Option<fidl_fuchsia_net::MacAddress>,
260 #[doc(hidden)]
261 pub __source_breaking: fidl::marker::SourceBreaking,
262}
263
264impl fidl::Persistable for DevicePortConfig {}
265
266#[derive(Clone, Debug, Default, PartialEq)]
272pub struct Frame {
273 pub frame_type: Option<fidl_fuchsia_hardware_network::FrameType>,
277 pub data: Option<Vec<u8>>,
283 pub meta: Option<FrameMetadata>,
290 pub port: Option<u8>,
294 #[doc(hidden)]
295 pub __source_breaking: fidl::marker::SourceBreaking,
296}
297
298impl fidl::Persistable for Frame {}
299
300#[derive(Clone, Debug, Default, PartialEq)]
302pub struct InternalState {
303 pub mac: Option<MacState>,
313 pub has_session: Option<bool>,
317 #[doc(hidden)]
318 pub __source_breaking: fidl::marker::SourceBreaking,
319}
320
321impl fidl::Persistable for InternalState {}
322
323#[derive(Clone, Debug, Default, PartialEq)]
324pub struct MacState {
325 pub mode: Option<fidl_fuchsia_hardware_network::MacFilterMode>,
329 pub multicast_filters: Option<Vec<fidl_fuchsia_net::MacAddress>>,
333 #[doc(hidden)]
334 pub __source_breaking: fidl::marker::SourceBreaking,
335}
336
337impl fidl::Persistable for MacState {}
338
339mod internal {
340 use super::*;
341 unsafe impl fidl::encoding::TypeMarker for Signals {
342 type Owned = Self;
343
344 #[inline(always)]
345 fn inline_align(_context: fidl::encoding::Context) -> usize {
346 4
347 }
348
349 #[inline(always)]
350 fn inline_size(_context: fidl::encoding::Context) -> usize {
351 4
352 }
353 }
354
355 impl fidl::encoding::ValueTypeMarker for Signals {
356 type Borrowed<'a> = Self;
357 #[inline(always)]
358 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
359 *value
360 }
361 }
362
363 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Signals {
364 #[inline]
365 unsafe fn encode(
366 self,
367 encoder: &mut fidl::encoding::Encoder<'_, D>,
368 offset: usize,
369 _depth: fidl::encoding::Depth,
370 ) -> fidl::Result<()> {
371 encoder.debug_check_bounds::<Self>(offset);
372 if self.bits() & Self::all().bits() != self.bits() {
373 return Err(fidl::Error::InvalidBitsValue);
374 }
375 encoder.write_num(self.bits(), offset);
376 Ok(())
377 }
378 }
379
380 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Signals {
381 #[inline(always)]
382 fn new_empty() -> Self {
383 Self::empty()
384 }
385
386 #[inline]
387 unsafe fn decode(
388 &mut self,
389 decoder: &mut fidl::encoding::Decoder<'_, D>,
390 offset: usize,
391 _depth: fidl::encoding::Depth,
392 ) -> fidl::Result<()> {
393 decoder.debug_check_bounds::<Self>(offset);
394 let prim = decoder.read_num::<u32>(offset);
395 *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
396 Ok(())
397 }
398 }
399
400 impl fidl::encoding::ValueTypeMarker for DevicePairAddPortRequest {
401 type Borrowed<'a> = &'a Self;
402 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
403 value
404 }
405 }
406
407 unsafe impl fidl::encoding::TypeMarker for DevicePairAddPortRequest {
408 type Owned = Self;
409
410 #[inline(always)]
411 fn inline_align(_context: fidl::encoding::Context) -> usize {
412 8
413 }
414
415 #[inline(always)]
416 fn inline_size(_context: fidl::encoding::Context) -> usize {
417 16
418 }
419 }
420
421 unsafe impl<D: fidl::encoding::ResourceDialect>
422 fidl::encoding::Encode<DevicePairAddPortRequest, D> for &DevicePairAddPortRequest
423 {
424 #[inline]
425 unsafe fn encode(
426 self,
427 encoder: &mut fidl::encoding::Encoder<'_, D>,
428 offset: usize,
429 _depth: fidl::encoding::Depth,
430 ) -> fidl::Result<()> {
431 encoder.debug_check_bounds::<DevicePairAddPortRequest>(offset);
432 fidl::encoding::Encode::<DevicePairAddPortRequest, D>::encode(
434 (<DevicePairPortConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),),
435 encoder,
436 offset,
437 _depth,
438 )
439 }
440 }
441 unsafe impl<
442 D: fidl::encoding::ResourceDialect,
443 T0: fidl::encoding::Encode<DevicePairPortConfig, D>,
444 > fidl::encoding::Encode<DevicePairAddPortRequest, D> for (T0,)
445 {
446 #[inline]
447 unsafe fn encode(
448 self,
449 encoder: &mut fidl::encoding::Encoder<'_, D>,
450 offset: usize,
451 depth: fidl::encoding::Depth,
452 ) -> fidl::Result<()> {
453 encoder.debug_check_bounds::<DevicePairAddPortRequest>(offset);
454 self.0.encode(encoder, offset + 0, depth)?;
458 Ok(())
459 }
460 }
461
462 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
463 for DevicePairAddPortRequest
464 {
465 #[inline(always)]
466 fn new_empty() -> Self {
467 Self { config: fidl::new_empty!(DevicePairPortConfig, D) }
468 }
469
470 #[inline]
471 unsafe fn decode(
472 &mut self,
473 decoder: &mut fidl::encoding::Decoder<'_, D>,
474 offset: usize,
475 _depth: fidl::encoding::Depth,
476 ) -> fidl::Result<()> {
477 decoder.debug_check_bounds::<Self>(offset);
478 fidl::decode!(DevicePairPortConfig, D, &mut self.config, decoder, offset + 0, _depth)?;
480 Ok(())
481 }
482 }
483
484 impl fidl::encoding::ValueTypeMarker for DevicePairRemovePortRequest {
485 type Borrowed<'a> = &'a Self;
486 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
487 value
488 }
489 }
490
491 unsafe impl fidl::encoding::TypeMarker for DevicePairRemovePortRequest {
492 type Owned = Self;
493
494 #[inline(always)]
495 fn inline_align(_context: fidl::encoding::Context) -> usize {
496 1
497 }
498
499 #[inline(always)]
500 fn inline_size(_context: fidl::encoding::Context) -> usize {
501 1
502 }
503 #[inline(always)]
504 fn encode_is_copy() -> bool {
505 true
506 }
507
508 #[inline(always)]
509 fn decode_is_copy() -> bool {
510 true
511 }
512 }
513
514 unsafe impl<D: fidl::encoding::ResourceDialect>
515 fidl::encoding::Encode<DevicePairRemovePortRequest, D> for &DevicePairRemovePortRequest
516 {
517 #[inline]
518 unsafe fn encode(
519 self,
520 encoder: &mut fidl::encoding::Encoder<'_, D>,
521 offset: usize,
522 _depth: fidl::encoding::Depth,
523 ) -> fidl::Result<()> {
524 encoder.debug_check_bounds::<DevicePairRemovePortRequest>(offset);
525 unsafe {
526 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
528 (buf_ptr as *mut DevicePairRemovePortRequest)
529 .write_unaligned((self as *const DevicePairRemovePortRequest).read());
530 }
533 Ok(())
534 }
535 }
536 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
537 fidl::encoding::Encode<DevicePairRemovePortRequest, D> for (T0,)
538 {
539 #[inline]
540 unsafe fn encode(
541 self,
542 encoder: &mut fidl::encoding::Encoder<'_, D>,
543 offset: usize,
544 depth: fidl::encoding::Depth,
545 ) -> fidl::Result<()> {
546 encoder.debug_check_bounds::<DevicePairRemovePortRequest>(offset);
547 self.0.encode(encoder, offset + 0, depth)?;
551 Ok(())
552 }
553 }
554
555 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
556 for DevicePairRemovePortRequest
557 {
558 #[inline(always)]
559 fn new_empty() -> Self {
560 Self { id: fidl::new_empty!(u8, D) }
561 }
562
563 #[inline]
564 unsafe fn decode(
565 &mut self,
566 decoder: &mut fidl::encoding::Decoder<'_, D>,
567 offset: usize,
568 _depth: fidl::encoding::Depth,
569 ) -> fidl::Result<()> {
570 decoder.debug_check_bounds::<Self>(offset);
571 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
572 unsafe {
575 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
576 }
577 Ok(())
578 }
579 }
580
581 impl fidl::encoding::ValueTypeMarker for DeviceWriteFrameRequest {
582 type Borrowed<'a> = &'a Self;
583 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
584 value
585 }
586 }
587
588 unsafe impl fidl::encoding::TypeMarker for DeviceWriteFrameRequest {
589 type Owned = Self;
590
591 #[inline(always)]
592 fn inline_align(_context: fidl::encoding::Context) -> usize {
593 8
594 }
595
596 #[inline(always)]
597 fn inline_size(_context: fidl::encoding::Context) -> usize {
598 16
599 }
600 }
601
602 unsafe impl<D: fidl::encoding::ResourceDialect>
603 fidl::encoding::Encode<DeviceWriteFrameRequest, D> for &DeviceWriteFrameRequest
604 {
605 #[inline]
606 unsafe fn encode(
607 self,
608 encoder: &mut fidl::encoding::Encoder<'_, D>,
609 offset: usize,
610 _depth: fidl::encoding::Depth,
611 ) -> fidl::Result<()> {
612 encoder.debug_check_bounds::<DeviceWriteFrameRequest>(offset);
613 fidl::encoding::Encode::<DeviceWriteFrameRequest, D>::encode(
615 (<Frame as fidl::encoding::ValueTypeMarker>::borrow(&self.frame),),
616 encoder,
617 offset,
618 _depth,
619 )
620 }
621 }
622 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Frame, D>>
623 fidl::encoding::Encode<DeviceWriteFrameRequest, D> for (T0,)
624 {
625 #[inline]
626 unsafe fn encode(
627 self,
628 encoder: &mut fidl::encoding::Encoder<'_, D>,
629 offset: usize,
630 depth: fidl::encoding::Depth,
631 ) -> fidl::Result<()> {
632 encoder.debug_check_bounds::<DeviceWriteFrameRequest>(offset);
633 self.0.encode(encoder, offset + 0, depth)?;
637 Ok(())
638 }
639 }
640
641 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
642 for DeviceWriteFrameRequest
643 {
644 #[inline(always)]
645 fn new_empty() -> Self {
646 Self { frame: fidl::new_empty!(Frame, D) }
647 }
648
649 #[inline]
650 unsafe fn decode(
651 &mut self,
652 decoder: &mut fidl::encoding::Decoder<'_, D>,
653 offset: usize,
654 _depth: fidl::encoding::Depth,
655 ) -> fidl::Result<()> {
656 decoder.debug_check_bounds::<Self>(offset);
657 fidl::decode!(Frame, D, &mut self.frame, decoder, offset + 0, _depth)?;
659 Ok(())
660 }
661 }
662
663 impl fidl::encoding::ValueTypeMarker for DeviceReadFrameResponse {
664 type Borrowed<'a> = &'a Self;
665 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
666 value
667 }
668 }
669
670 unsafe impl fidl::encoding::TypeMarker for DeviceReadFrameResponse {
671 type Owned = Self;
672
673 #[inline(always)]
674 fn inline_align(_context: fidl::encoding::Context) -> usize {
675 8
676 }
677
678 #[inline(always)]
679 fn inline_size(_context: fidl::encoding::Context) -> usize {
680 16
681 }
682 }
683
684 unsafe impl<D: fidl::encoding::ResourceDialect>
685 fidl::encoding::Encode<DeviceReadFrameResponse, D> for &DeviceReadFrameResponse
686 {
687 #[inline]
688 unsafe fn encode(
689 self,
690 encoder: &mut fidl::encoding::Encoder<'_, D>,
691 offset: usize,
692 _depth: fidl::encoding::Depth,
693 ) -> fidl::Result<()> {
694 encoder.debug_check_bounds::<DeviceReadFrameResponse>(offset);
695 fidl::encoding::Encode::<DeviceReadFrameResponse, D>::encode(
697 (<Frame as fidl::encoding::ValueTypeMarker>::borrow(&self.frame),),
698 encoder,
699 offset,
700 _depth,
701 )
702 }
703 }
704 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Frame, D>>
705 fidl::encoding::Encode<DeviceReadFrameResponse, D> for (T0,)
706 {
707 #[inline]
708 unsafe fn encode(
709 self,
710 encoder: &mut fidl::encoding::Encoder<'_, D>,
711 offset: usize,
712 depth: fidl::encoding::Depth,
713 ) -> fidl::Result<()> {
714 encoder.debug_check_bounds::<DeviceReadFrameResponse>(offset);
715 self.0.encode(encoder, offset + 0, depth)?;
719 Ok(())
720 }
721 }
722
723 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
724 for DeviceReadFrameResponse
725 {
726 #[inline(always)]
727 fn new_empty() -> Self {
728 Self { frame: fidl::new_empty!(Frame, D) }
729 }
730
731 #[inline]
732 unsafe fn decode(
733 &mut self,
734 decoder: &mut fidl::encoding::Decoder<'_, D>,
735 offset: usize,
736 _depth: fidl::encoding::Depth,
737 ) -> fidl::Result<()> {
738 decoder.debug_check_bounds::<Self>(offset);
739 fidl::decode!(Frame, D, &mut self.frame, decoder, offset + 0, _depth)?;
741 Ok(())
742 }
743 }
744
745 impl fidl::encoding::ValueTypeMarker for FrameMetadata {
746 type Borrowed<'a> = &'a Self;
747 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
748 value
749 }
750 }
751
752 unsafe impl fidl::encoding::TypeMarker for FrameMetadata {
753 type Owned = Self;
754
755 #[inline(always)]
756 fn inline_align(_context: fidl::encoding::Context) -> usize {
757 8
758 }
759
760 #[inline(always)]
761 fn inline_size(_context: fidl::encoding::Context) -> usize {
762 32
763 }
764 }
765
766 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FrameMetadata, D>
767 for &FrameMetadata
768 {
769 #[inline]
770 unsafe fn encode(
771 self,
772 encoder: &mut fidl::encoding::Encoder<'_, D>,
773 offset: usize,
774 _depth: fidl::encoding::Depth,
775 ) -> fidl::Result<()> {
776 encoder.debug_check_bounds::<FrameMetadata>(offset);
777 fidl::encoding::Encode::<FrameMetadata, D>::encode(
779 (
780 <fidl_fuchsia_hardware_network::InfoType as fidl::encoding::ValueTypeMarker>::borrow(&self.info_type),
781 <fidl::encoding::Vector<u8, 4096> as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
782 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
783 ),
784 encoder, offset, _depth
785 )
786 }
787 }
788 unsafe impl<
789 D: fidl::encoding::ResourceDialect,
790 T0: fidl::encoding::Encode<fidl_fuchsia_hardware_network::InfoType, D>,
791 T1: fidl::encoding::Encode<fidl::encoding::Vector<u8, 4096>, D>,
792 T2: fidl::encoding::Encode<u32, D>,
793 > fidl::encoding::Encode<FrameMetadata, D> for (T0, T1, T2)
794 {
795 #[inline]
796 unsafe fn encode(
797 self,
798 encoder: &mut fidl::encoding::Encoder<'_, D>,
799 offset: usize,
800 depth: fidl::encoding::Depth,
801 ) -> fidl::Result<()> {
802 encoder.debug_check_bounds::<FrameMetadata>(offset);
803 unsafe {
806 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
807 (ptr as *mut u64).write_unaligned(0);
808 }
809 unsafe {
810 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
811 (ptr as *mut u64).write_unaligned(0);
812 }
813 self.0.encode(encoder, offset + 0, depth)?;
815 self.1.encode(encoder, offset + 8, depth)?;
816 self.2.encode(encoder, offset + 24, depth)?;
817 Ok(())
818 }
819 }
820
821 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FrameMetadata {
822 #[inline(always)]
823 fn new_empty() -> Self {
824 Self {
825 info_type: fidl::new_empty!(fidl_fuchsia_hardware_network::InfoType, D),
826 info: fidl::new_empty!(fidl::encoding::Vector<u8, 4096>, D),
827 flags: fidl::new_empty!(u32, D),
828 }
829 }
830
831 #[inline]
832 unsafe fn decode(
833 &mut self,
834 decoder: &mut fidl::encoding::Decoder<'_, D>,
835 offset: usize,
836 _depth: fidl::encoding::Depth,
837 ) -> fidl::Result<()> {
838 decoder.debug_check_bounds::<Self>(offset);
839 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
841 let padval = unsafe { (ptr as *const u64).read_unaligned() };
842 let mask = 0xffffffff00000000u64;
843 let maskedval = padval & mask;
844 if maskedval != 0 {
845 return Err(fidl::Error::NonZeroPadding {
846 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
847 });
848 }
849 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
850 let padval = unsafe { (ptr as *const u64).read_unaligned() };
851 let mask = 0xffffffff00000000u64;
852 let maskedval = padval & mask;
853 if maskedval != 0 {
854 return Err(fidl::Error::NonZeroPadding {
855 padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
856 });
857 }
858 fidl::decode!(
859 fidl_fuchsia_hardware_network::InfoType,
860 D,
861 &mut self.info_type,
862 decoder,
863 offset + 0,
864 _depth
865 )?;
866 fidl::decode!(fidl::encoding::Vector<u8, 4096>, D, &mut self.info, decoder, offset + 8, _depth)?;
867 fidl::decode!(u32, D, &mut self.flags, decoder, offset + 24, _depth)?;
868 Ok(())
869 }
870 }
871
872 impl fidl::encoding::ValueTypeMarker for PortGetStateResponse {
873 type Borrowed<'a> = &'a Self;
874 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
875 value
876 }
877 }
878
879 unsafe impl fidl::encoding::TypeMarker for PortGetStateResponse {
880 type Owned = Self;
881
882 #[inline(always)]
883 fn inline_align(_context: fidl::encoding::Context) -> usize {
884 8
885 }
886
887 #[inline(always)]
888 fn inline_size(_context: fidl::encoding::Context) -> usize {
889 16
890 }
891 }
892
893 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PortGetStateResponse, D>
894 for &PortGetStateResponse
895 {
896 #[inline]
897 unsafe fn encode(
898 self,
899 encoder: &mut fidl::encoding::Encoder<'_, D>,
900 offset: usize,
901 _depth: fidl::encoding::Depth,
902 ) -> fidl::Result<()> {
903 encoder.debug_check_bounds::<PortGetStateResponse>(offset);
904 fidl::encoding::Encode::<PortGetStateResponse, D>::encode(
906 (<InternalState as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
907 encoder,
908 offset,
909 _depth,
910 )
911 }
912 }
913 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<InternalState, D>>
914 fidl::encoding::Encode<PortGetStateResponse, D> for (T0,)
915 {
916 #[inline]
917 unsafe fn encode(
918 self,
919 encoder: &mut fidl::encoding::Encoder<'_, D>,
920 offset: usize,
921 depth: fidl::encoding::Depth,
922 ) -> fidl::Result<()> {
923 encoder.debug_check_bounds::<PortGetStateResponse>(offset);
924 self.0.encode(encoder, offset + 0, depth)?;
928 Ok(())
929 }
930 }
931
932 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PortGetStateResponse {
933 #[inline(always)]
934 fn new_empty() -> Self {
935 Self { state: fidl::new_empty!(InternalState, D) }
936 }
937
938 #[inline]
939 unsafe fn decode(
940 &mut self,
941 decoder: &mut fidl::encoding::Decoder<'_, D>,
942 offset: usize,
943 _depth: fidl::encoding::Depth,
944 ) -> fidl::Result<()> {
945 decoder.debug_check_bounds::<Self>(offset);
946 fidl::decode!(InternalState, D, &mut self.state, decoder, offset + 0, _depth)?;
948 Ok(())
949 }
950 }
951
952 impl fidl::encoding::ValueTypeMarker for PortSetOnlineRequest {
953 type Borrowed<'a> = &'a Self;
954 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
955 value
956 }
957 }
958
959 unsafe impl fidl::encoding::TypeMarker for PortSetOnlineRequest {
960 type Owned = Self;
961
962 #[inline(always)]
963 fn inline_align(_context: fidl::encoding::Context) -> usize {
964 1
965 }
966
967 #[inline(always)]
968 fn inline_size(_context: fidl::encoding::Context) -> usize {
969 1
970 }
971 }
972
973 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PortSetOnlineRequest, D>
974 for &PortSetOnlineRequest
975 {
976 #[inline]
977 unsafe fn encode(
978 self,
979 encoder: &mut fidl::encoding::Encoder<'_, D>,
980 offset: usize,
981 _depth: fidl::encoding::Depth,
982 ) -> fidl::Result<()> {
983 encoder.debug_check_bounds::<PortSetOnlineRequest>(offset);
984 fidl::encoding::Encode::<PortSetOnlineRequest, D>::encode(
986 (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.online),),
987 encoder,
988 offset,
989 _depth,
990 )
991 }
992 }
993 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
994 fidl::encoding::Encode<PortSetOnlineRequest, D> for (T0,)
995 {
996 #[inline]
997 unsafe fn encode(
998 self,
999 encoder: &mut fidl::encoding::Encoder<'_, D>,
1000 offset: usize,
1001 depth: fidl::encoding::Depth,
1002 ) -> fidl::Result<()> {
1003 encoder.debug_check_bounds::<PortSetOnlineRequest>(offset);
1004 self.0.encode(encoder, offset + 0, depth)?;
1008 Ok(())
1009 }
1010 }
1011
1012 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PortSetOnlineRequest {
1013 #[inline(always)]
1014 fn new_empty() -> Self {
1015 Self { online: fidl::new_empty!(bool, D) }
1016 }
1017
1018 #[inline]
1019 unsafe fn decode(
1020 &mut self,
1021 decoder: &mut fidl::encoding::Decoder<'_, D>,
1022 offset: usize,
1023 _depth: fidl::encoding::Depth,
1024 ) -> fidl::Result<()> {
1025 decoder.debug_check_bounds::<Self>(offset);
1026 fidl::decode!(bool, D, &mut self.online, decoder, offset + 0, _depth)?;
1028 Ok(())
1029 }
1030 }
1031
1032 impl fidl::encoding::ValueTypeMarker for PortWatchStateResponse {
1033 type Borrowed<'a> = &'a Self;
1034 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1035 value
1036 }
1037 }
1038
1039 unsafe impl fidl::encoding::TypeMarker for PortWatchStateResponse {
1040 type Owned = Self;
1041
1042 #[inline(always)]
1043 fn inline_align(_context: fidl::encoding::Context) -> usize {
1044 8
1045 }
1046
1047 #[inline(always)]
1048 fn inline_size(_context: fidl::encoding::Context) -> usize {
1049 16
1050 }
1051 }
1052
1053 unsafe impl<D: fidl::encoding::ResourceDialect>
1054 fidl::encoding::Encode<PortWatchStateResponse, D> for &PortWatchStateResponse
1055 {
1056 #[inline]
1057 unsafe fn encode(
1058 self,
1059 encoder: &mut fidl::encoding::Encoder<'_, D>,
1060 offset: usize,
1061 _depth: fidl::encoding::Depth,
1062 ) -> fidl::Result<()> {
1063 encoder.debug_check_bounds::<PortWatchStateResponse>(offset);
1064 fidl::encoding::Encode::<PortWatchStateResponse, D>::encode(
1066 (<InternalState as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
1067 encoder,
1068 offset,
1069 _depth,
1070 )
1071 }
1072 }
1073 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<InternalState, D>>
1074 fidl::encoding::Encode<PortWatchStateResponse, D> for (T0,)
1075 {
1076 #[inline]
1077 unsafe fn encode(
1078 self,
1079 encoder: &mut fidl::encoding::Encoder<'_, D>,
1080 offset: usize,
1081 depth: fidl::encoding::Depth,
1082 ) -> fidl::Result<()> {
1083 encoder.debug_check_bounds::<PortWatchStateResponse>(offset);
1084 self.0.encode(encoder, offset + 0, depth)?;
1088 Ok(())
1089 }
1090 }
1091
1092 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1093 for PortWatchStateResponse
1094 {
1095 #[inline(always)]
1096 fn new_empty() -> Self {
1097 Self { state: fidl::new_empty!(InternalState, D) }
1098 }
1099
1100 #[inline]
1101 unsafe fn decode(
1102 &mut self,
1103 decoder: &mut fidl::encoding::Decoder<'_, D>,
1104 offset: usize,
1105 _depth: fidl::encoding::Depth,
1106 ) -> fidl::Result<()> {
1107 decoder.debug_check_bounds::<Self>(offset);
1108 fidl::decode!(InternalState, D, &mut self.state, decoder, offset + 0, _depth)?;
1110 Ok(())
1111 }
1112 }
1113
1114 impl BaseDeviceConfig {
1115 #[inline(always)]
1116 fn max_ordinal_present(&self) -> u64 {
1117 if let Some(_) = self.min_rx_buffer_length {
1118 return 3;
1119 }
1120 if let Some(_) = self.min_tx_buffer_length {
1121 return 2;
1122 }
1123 if let Some(_) = self.report_metadata {
1124 return 1;
1125 }
1126 0
1127 }
1128 }
1129
1130 impl fidl::encoding::ValueTypeMarker for BaseDeviceConfig {
1131 type Borrowed<'a> = &'a Self;
1132 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1133 value
1134 }
1135 }
1136
1137 unsafe impl fidl::encoding::TypeMarker for BaseDeviceConfig {
1138 type Owned = Self;
1139
1140 #[inline(always)]
1141 fn inline_align(_context: fidl::encoding::Context) -> usize {
1142 8
1143 }
1144
1145 #[inline(always)]
1146 fn inline_size(_context: fidl::encoding::Context) -> usize {
1147 16
1148 }
1149 }
1150
1151 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BaseDeviceConfig, D>
1152 for &BaseDeviceConfig
1153 {
1154 unsafe fn encode(
1155 self,
1156 encoder: &mut fidl::encoding::Encoder<'_, D>,
1157 offset: usize,
1158 mut depth: fidl::encoding::Depth,
1159 ) -> fidl::Result<()> {
1160 encoder.debug_check_bounds::<BaseDeviceConfig>(offset);
1161 let max_ordinal: u64 = self.max_ordinal_present();
1163 encoder.write_num(max_ordinal, offset);
1164 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1165 if max_ordinal == 0 {
1167 return Ok(());
1168 }
1169 depth.increment()?;
1170 let envelope_size = 8;
1171 let bytes_len = max_ordinal as usize * envelope_size;
1172 #[allow(unused_variables)]
1173 let offset = encoder.out_of_line_offset(bytes_len);
1174 let mut _prev_end_offset: usize = 0;
1175 if 1 > max_ordinal {
1176 return Ok(());
1177 }
1178
1179 let cur_offset: usize = (1 - 1) * envelope_size;
1182
1183 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1185
1186 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1191 self.report_metadata
1192 .as_ref()
1193 .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1194 encoder,
1195 offset + cur_offset,
1196 depth,
1197 )?;
1198
1199 _prev_end_offset = cur_offset + envelope_size;
1200 if 2 > max_ordinal {
1201 return Ok(());
1202 }
1203
1204 let cur_offset: usize = (2 - 1) * envelope_size;
1207
1208 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1210
1211 fidl::encoding::encode_in_envelope_optional::<u32, D>(
1216 self.min_tx_buffer_length
1217 .as_ref()
1218 .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1219 encoder,
1220 offset + cur_offset,
1221 depth,
1222 )?;
1223
1224 _prev_end_offset = cur_offset + envelope_size;
1225 if 3 > max_ordinal {
1226 return Ok(());
1227 }
1228
1229 let cur_offset: usize = (3 - 1) * envelope_size;
1232
1233 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1235
1236 fidl::encoding::encode_in_envelope_optional::<u32, D>(
1241 self.min_rx_buffer_length
1242 .as_ref()
1243 .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1244 encoder,
1245 offset + cur_offset,
1246 depth,
1247 )?;
1248
1249 _prev_end_offset = cur_offset + envelope_size;
1250
1251 Ok(())
1252 }
1253 }
1254
1255 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BaseDeviceConfig {
1256 #[inline(always)]
1257 fn new_empty() -> Self {
1258 Self::default()
1259 }
1260
1261 unsafe fn decode(
1262 &mut self,
1263 decoder: &mut fidl::encoding::Decoder<'_, D>,
1264 offset: usize,
1265 mut depth: fidl::encoding::Depth,
1266 ) -> fidl::Result<()> {
1267 decoder.debug_check_bounds::<Self>(offset);
1268 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1269 None => return Err(fidl::Error::NotNullable),
1270 Some(len) => len,
1271 };
1272 if len == 0 {
1274 return Ok(());
1275 };
1276 depth.increment()?;
1277 let envelope_size = 8;
1278 let bytes_len = len * envelope_size;
1279 let offset = decoder.out_of_line_offset(bytes_len)?;
1280 let mut _next_ordinal_to_read = 0;
1282 let mut next_offset = offset;
1283 let end_offset = offset + bytes_len;
1284 _next_ordinal_to_read += 1;
1285 if next_offset >= end_offset {
1286 return Ok(());
1287 }
1288
1289 while _next_ordinal_to_read < 1 {
1291 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1292 _next_ordinal_to_read += 1;
1293 next_offset += envelope_size;
1294 }
1295
1296 let next_out_of_line = decoder.next_out_of_line();
1297 let handles_before = decoder.remaining_handles();
1298 if let Some((inlined, num_bytes, num_handles)) =
1299 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1300 {
1301 let member_inline_size =
1302 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1303 if inlined != (member_inline_size <= 4) {
1304 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1305 }
1306 let inner_offset;
1307 let mut inner_depth = depth.clone();
1308 if inlined {
1309 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1310 inner_offset = next_offset;
1311 } else {
1312 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1313 inner_depth.increment()?;
1314 }
1315 let val_ref = self.report_metadata.get_or_insert_with(|| fidl::new_empty!(bool, D));
1316 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1317 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1318 {
1319 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1320 }
1321 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1322 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1323 }
1324 }
1325
1326 next_offset += envelope_size;
1327 _next_ordinal_to_read += 1;
1328 if next_offset >= end_offset {
1329 return Ok(());
1330 }
1331
1332 while _next_ordinal_to_read < 2 {
1334 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1335 _next_ordinal_to_read += 1;
1336 next_offset += envelope_size;
1337 }
1338
1339 let next_out_of_line = decoder.next_out_of_line();
1340 let handles_before = decoder.remaining_handles();
1341 if let Some((inlined, num_bytes, num_handles)) =
1342 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1343 {
1344 let member_inline_size =
1345 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1346 if inlined != (member_inline_size <= 4) {
1347 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1348 }
1349 let inner_offset;
1350 let mut inner_depth = depth.clone();
1351 if inlined {
1352 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1353 inner_offset = next_offset;
1354 } else {
1355 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1356 inner_depth.increment()?;
1357 }
1358 let val_ref =
1359 self.min_tx_buffer_length.get_or_insert_with(|| fidl::new_empty!(u32, D));
1360 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1361 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1362 {
1363 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1364 }
1365 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1366 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1367 }
1368 }
1369
1370 next_offset += envelope_size;
1371 _next_ordinal_to_read += 1;
1372 if next_offset >= end_offset {
1373 return Ok(());
1374 }
1375
1376 while _next_ordinal_to_read < 3 {
1378 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1379 _next_ordinal_to_read += 1;
1380 next_offset += envelope_size;
1381 }
1382
1383 let next_out_of_line = decoder.next_out_of_line();
1384 let handles_before = decoder.remaining_handles();
1385 if let Some((inlined, num_bytes, num_handles)) =
1386 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1387 {
1388 let member_inline_size =
1389 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1390 if inlined != (member_inline_size <= 4) {
1391 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1392 }
1393 let inner_offset;
1394 let mut inner_depth = depth.clone();
1395 if inlined {
1396 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1397 inner_offset = next_offset;
1398 } else {
1399 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1400 inner_depth.increment()?;
1401 }
1402 let val_ref =
1403 self.min_rx_buffer_length.get_or_insert_with(|| fidl::new_empty!(u32, D));
1404 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1405 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1406 {
1407 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1408 }
1409 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1410 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1411 }
1412 }
1413
1414 next_offset += envelope_size;
1415
1416 while next_offset < end_offset {
1418 _next_ordinal_to_read += 1;
1419 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1420 next_offset += envelope_size;
1421 }
1422
1423 Ok(())
1424 }
1425 }
1426
1427 impl BasePortConfig {
1428 #[inline(always)]
1429 fn max_ordinal_present(&self) -> u64 {
1430 if let Some(_) = self.port_class {
1431 return 5;
1432 }
1433 if let Some(_) = self.tx_types {
1434 return 4;
1435 }
1436 if let Some(_) = self.rx_types {
1437 return 3;
1438 }
1439 if let Some(_) = self.mtu {
1440 return 2;
1441 }
1442 if let Some(_) = self.id {
1443 return 1;
1444 }
1445 0
1446 }
1447 }
1448
1449 impl fidl::encoding::ValueTypeMarker for BasePortConfig {
1450 type Borrowed<'a> = &'a Self;
1451 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1452 value
1453 }
1454 }
1455
1456 unsafe impl fidl::encoding::TypeMarker for BasePortConfig {
1457 type Owned = Self;
1458
1459 #[inline(always)]
1460 fn inline_align(_context: fidl::encoding::Context) -> usize {
1461 8
1462 }
1463
1464 #[inline(always)]
1465 fn inline_size(_context: fidl::encoding::Context) -> usize {
1466 16
1467 }
1468 }
1469
1470 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BasePortConfig, D>
1471 for &BasePortConfig
1472 {
1473 unsafe fn encode(
1474 self,
1475 encoder: &mut fidl::encoding::Encoder<'_, D>,
1476 offset: usize,
1477 mut depth: fidl::encoding::Depth,
1478 ) -> fidl::Result<()> {
1479 encoder.debug_check_bounds::<BasePortConfig>(offset);
1480 let max_ordinal: u64 = self.max_ordinal_present();
1482 encoder.write_num(max_ordinal, offset);
1483 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1484 if max_ordinal == 0 {
1486 return Ok(());
1487 }
1488 depth.increment()?;
1489 let envelope_size = 8;
1490 let bytes_len = max_ordinal as usize * envelope_size;
1491 #[allow(unused_variables)]
1492 let offset = encoder.out_of_line_offset(bytes_len);
1493 let mut _prev_end_offset: usize = 0;
1494 if 1 > max_ordinal {
1495 return Ok(());
1496 }
1497
1498 let cur_offset: usize = (1 - 1) * envelope_size;
1501
1502 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1504
1505 fidl::encoding::encode_in_envelope_optional::<u8, D>(
1510 self.id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
1511 encoder,
1512 offset + cur_offset,
1513 depth,
1514 )?;
1515
1516 _prev_end_offset = cur_offset + envelope_size;
1517 if 2 > max_ordinal {
1518 return Ok(());
1519 }
1520
1521 let cur_offset: usize = (2 - 1) * envelope_size;
1524
1525 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1527
1528 fidl::encoding::encode_in_envelope_optional::<u32, D>(
1533 self.mtu.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1534 encoder,
1535 offset + cur_offset,
1536 depth,
1537 )?;
1538
1539 _prev_end_offset = cur_offset + envelope_size;
1540 if 3 > max_ordinal {
1541 return Ok(());
1542 }
1543
1544 let cur_offset: usize = (3 - 1) * envelope_size;
1547
1548 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1550
1551 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_hardware_network::FrameType, 4>, D>(
1556 self.rx_types.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_hardware_network::FrameType, 4> as fidl::encoding::ValueTypeMarker>::borrow),
1557 encoder, offset + cur_offset, depth
1558 )?;
1559
1560 _prev_end_offset = cur_offset + envelope_size;
1561 if 4 > max_ordinal {
1562 return Ok(());
1563 }
1564
1565 let cur_offset: usize = (4 - 1) * envelope_size;
1568
1569 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1571
1572 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_hardware_network::FrameTypeSupport, 4>, D>(
1577 self.tx_types.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_hardware_network::FrameTypeSupport, 4> as fidl::encoding::ValueTypeMarker>::borrow),
1578 encoder, offset + cur_offset, depth
1579 )?;
1580
1581 _prev_end_offset = cur_offset + envelope_size;
1582 if 5 > max_ordinal {
1583 return Ok(());
1584 }
1585
1586 let cur_offset: usize = (5 - 1) * envelope_size;
1589
1590 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1592
1593 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_network::PortClass, D>(
1598 self.port_class.as_ref().map(<fidl_fuchsia_hardware_network::PortClass as fidl::encoding::ValueTypeMarker>::borrow),
1599 encoder, offset + cur_offset, depth
1600 )?;
1601
1602 _prev_end_offset = cur_offset + envelope_size;
1603
1604 Ok(())
1605 }
1606 }
1607
1608 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BasePortConfig {
1609 #[inline(always)]
1610 fn new_empty() -> Self {
1611 Self::default()
1612 }
1613
1614 unsafe fn decode(
1615 &mut self,
1616 decoder: &mut fidl::encoding::Decoder<'_, D>,
1617 offset: usize,
1618 mut depth: fidl::encoding::Depth,
1619 ) -> fidl::Result<()> {
1620 decoder.debug_check_bounds::<Self>(offset);
1621 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1622 None => return Err(fidl::Error::NotNullable),
1623 Some(len) => len,
1624 };
1625 if len == 0 {
1627 return Ok(());
1628 };
1629 depth.increment()?;
1630 let envelope_size = 8;
1631 let bytes_len = len * envelope_size;
1632 let offset = decoder.out_of_line_offset(bytes_len)?;
1633 let mut _next_ordinal_to_read = 0;
1635 let mut next_offset = offset;
1636 let end_offset = offset + bytes_len;
1637 _next_ordinal_to_read += 1;
1638 if next_offset >= end_offset {
1639 return Ok(());
1640 }
1641
1642 while _next_ordinal_to_read < 1 {
1644 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1645 _next_ordinal_to_read += 1;
1646 next_offset += envelope_size;
1647 }
1648
1649 let next_out_of_line = decoder.next_out_of_line();
1650 let handles_before = decoder.remaining_handles();
1651 if let Some((inlined, num_bytes, num_handles)) =
1652 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1653 {
1654 let member_inline_size =
1655 <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1656 if inlined != (member_inline_size <= 4) {
1657 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1658 }
1659 let inner_offset;
1660 let mut inner_depth = depth.clone();
1661 if inlined {
1662 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1663 inner_offset = next_offset;
1664 } else {
1665 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1666 inner_depth.increment()?;
1667 }
1668 let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u8, D));
1669 fidl::decode!(u8, D, val_ref, decoder, inner_offset, inner_depth)?;
1670 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1671 {
1672 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1673 }
1674 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1675 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1676 }
1677 }
1678
1679 next_offset += envelope_size;
1680 _next_ordinal_to_read += 1;
1681 if next_offset >= end_offset {
1682 return Ok(());
1683 }
1684
1685 while _next_ordinal_to_read < 2 {
1687 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1688 _next_ordinal_to_read += 1;
1689 next_offset += envelope_size;
1690 }
1691
1692 let next_out_of_line = decoder.next_out_of_line();
1693 let handles_before = decoder.remaining_handles();
1694 if let Some((inlined, num_bytes, num_handles)) =
1695 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1696 {
1697 let member_inline_size =
1698 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1699 if inlined != (member_inline_size <= 4) {
1700 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1701 }
1702 let inner_offset;
1703 let mut inner_depth = depth.clone();
1704 if inlined {
1705 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1706 inner_offset = next_offset;
1707 } else {
1708 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1709 inner_depth.increment()?;
1710 }
1711 let val_ref = self.mtu.get_or_insert_with(|| fidl::new_empty!(u32, D));
1712 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1713 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1714 {
1715 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1716 }
1717 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1718 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1719 }
1720 }
1721
1722 next_offset += envelope_size;
1723 _next_ordinal_to_read += 1;
1724 if next_offset >= end_offset {
1725 return Ok(());
1726 }
1727
1728 while _next_ordinal_to_read < 3 {
1730 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1731 _next_ordinal_to_read += 1;
1732 next_offset += envelope_size;
1733 }
1734
1735 let next_out_of_line = decoder.next_out_of_line();
1736 let handles_before = decoder.remaining_handles();
1737 if let Some((inlined, num_bytes, num_handles)) =
1738 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1739 {
1740 let member_inline_size = <fidl::encoding::Vector<
1741 fidl_fuchsia_hardware_network::FrameType,
1742 4,
1743 > as fidl::encoding::TypeMarker>::inline_size(
1744 decoder.context
1745 );
1746 if inlined != (member_inline_size <= 4) {
1747 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1748 }
1749 let inner_offset;
1750 let mut inner_depth = depth.clone();
1751 if inlined {
1752 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1753 inner_offset = next_offset;
1754 } else {
1755 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1756 inner_depth.increment()?;
1757 }
1758 let val_ref =
1759 self.rx_types.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_network::FrameType, 4>, D));
1760 fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_network::FrameType, 4>, D, val_ref, decoder, inner_offset, inner_depth)?;
1761 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1762 {
1763 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1764 }
1765 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1766 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1767 }
1768 }
1769
1770 next_offset += envelope_size;
1771 _next_ordinal_to_read += 1;
1772 if next_offset >= end_offset {
1773 return Ok(());
1774 }
1775
1776 while _next_ordinal_to_read < 4 {
1778 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1779 _next_ordinal_to_read += 1;
1780 next_offset += envelope_size;
1781 }
1782
1783 let next_out_of_line = decoder.next_out_of_line();
1784 let handles_before = decoder.remaining_handles();
1785 if let Some((inlined, num_bytes, num_handles)) =
1786 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1787 {
1788 let member_inline_size = <fidl::encoding::Vector<
1789 fidl_fuchsia_hardware_network::FrameTypeSupport,
1790 4,
1791 > as fidl::encoding::TypeMarker>::inline_size(
1792 decoder.context
1793 );
1794 if inlined != (member_inline_size <= 4) {
1795 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1796 }
1797 let inner_offset;
1798 let mut inner_depth = depth.clone();
1799 if inlined {
1800 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1801 inner_offset = next_offset;
1802 } else {
1803 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1804 inner_depth.increment()?;
1805 }
1806 let val_ref =
1807 self.tx_types.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_network::FrameTypeSupport, 4>, D));
1808 fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_network::FrameTypeSupport, 4>, D, val_ref, decoder, inner_offset, inner_depth)?;
1809 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1810 {
1811 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1812 }
1813 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1814 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1815 }
1816 }
1817
1818 next_offset += envelope_size;
1819 _next_ordinal_to_read += 1;
1820 if next_offset >= end_offset {
1821 return Ok(());
1822 }
1823
1824 while _next_ordinal_to_read < 5 {
1826 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1827 _next_ordinal_to_read += 1;
1828 next_offset += envelope_size;
1829 }
1830
1831 let next_out_of_line = decoder.next_out_of_line();
1832 let handles_before = decoder.remaining_handles();
1833 if let Some((inlined, num_bytes, num_handles)) =
1834 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1835 {
1836 let member_inline_size = <fidl_fuchsia_hardware_network::PortClass as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1837 if inlined != (member_inline_size <= 4) {
1838 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1839 }
1840 let inner_offset;
1841 let mut inner_depth = depth.clone();
1842 if inlined {
1843 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1844 inner_offset = next_offset;
1845 } else {
1846 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1847 inner_depth.increment()?;
1848 }
1849 let val_ref = self.port_class.get_or_insert_with(|| {
1850 fidl::new_empty!(fidl_fuchsia_hardware_network::PortClass, D)
1851 });
1852 fidl::decode!(
1853 fidl_fuchsia_hardware_network::PortClass,
1854 D,
1855 val_ref,
1856 decoder,
1857 inner_offset,
1858 inner_depth
1859 )?;
1860 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1861 {
1862 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1863 }
1864 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1865 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1866 }
1867 }
1868
1869 next_offset += envelope_size;
1870
1871 while next_offset < end_offset {
1873 _next_ordinal_to_read += 1;
1874 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1875 next_offset += envelope_size;
1876 }
1877
1878 Ok(())
1879 }
1880 }
1881
1882 impl DeviceConfig {
1883 #[inline(always)]
1884 fn max_ordinal_present(&self) -> u64 {
1885 if let Some(_) = self.blocking {
1886 return 2;
1887 }
1888 if let Some(_) = self.base {
1889 return 1;
1890 }
1891 0
1892 }
1893 }
1894
1895 impl fidl::encoding::ValueTypeMarker for DeviceConfig {
1896 type Borrowed<'a> = &'a Self;
1897 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1898 value
1899 }
1900 }
1901
1902 unsafe impl fidl::encoding::TypeMarker for DeviceConfig {
1903 type Owned = Self;
1904
1905 #[inline(always)]
1906 fn inline_align(_context: fidl::encoding::Context) -> usize {
1907 8
1908 }
1909
1910 #[inline(always)]
1911 fn inline_size(_context: fidl::encoding::Context) -> usize {
1912 16
1913 }
1914 }
1915
1916 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceConfig, D>
1917 for &DeviceConfig
1918 {
1919 unsafe fn encode(
1920 self,
1921 encoder: &mut fidl::encoding::Encoder<'_, D>,
1922 offset: usize,
1923 mut depth: fidl::encoding::Depth,
1924 ) -> fidl::Result<()> {
1925 encoder.debug_check_bounds::<DeviceConfig>(offset);
1926 let max_ordinal: u64 = self.max_ordinal_present();
1928 encoder.write_num(max_ordinal, offset);
1929 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1930 if max_ordinal == 0 {
1932 return Ok(());
1933 }
1934 depth.increment()?;
1935 let envelope_size = 8;
1936 let bytes_len = max_ordinal as usize * envelope_size;
1937 #[allow(unused_variables)]
1938 let offset = encoder.out_of_line_offset(bytes_len);
1939 let mut _prev_end_offset: usize = 0;
1940 if 1 > max_ordinal {
1941 return Ok(());
1942 }
1943
1944 let cur_offset: usize = (1 - 1) * envelope_size;
1947
1948 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1950
1951 fidl::encoding::encode_in_envelope_optional::<BaseDeviceConfig, D>(
1956 self.base
1957 .as_ref()
1958 .map(<BaseDeviceConfig as fidl::encoding::ValueTypeMarker>::borrow),
1959 encoder,
1960 offset + cur_offset,
1961 depth,
1962 )?;
1963
1964 _prev_end_offset = cur_offset + envelope_size;
1965 if 2 > max_ordinal {
1966 return Ok(());
1967 }
1968
1969 let cur_offset: usize = (2 - 1) * envelope_size;
1972
1973 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1975
1976 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1981 self.blocking.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1982 encoder,
1983 offset + cur_offset,
1984 depth,
1985 )?;
1986
1987 _prev_end_offset = cur_offset + envelope_size;
1988
1989 Ok(())
1990 }
1991 }
1992
1993 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceConfig {
1994 #[inline(always)]
1995 fn new_empty() -> Self {
1996 Self::default()
1997 }
1998
1999 unsafe fn decode(
2000 &mut self,
2001 decoder: &mut fidl::encoding::Decoder<'_, D>,
2002 offset: usize,
2003 mut depth: fidl::encoding::Depth,
2004 ) -> fidl::Result<()> {
2005 decoder.debug_check_bounds::<Self>(offset);
2006 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2007 None => return Err(fidl::Error::NotNullable),
2008 Some(len) => len,
2009 };
2010 if len == 0 {
2012 return Ok(());
2013 };
2014 depth.increment()?;
2015 let envelope_size = 8;
2016 let bytes_len = len * envelope_size;
2017 let offset = decoder.out_of_line_offset(bytes_len)?;
2018 let mut _next_ordinal_to_read = 0;
2020 let mut next_offset = offset;
2021 let end_offset = offset + bytes_len;
2022 _next_ordinal_to_read += 1;
2023 if next_offset >= end_offset {
2024 return Ok(());
2025 }
2026
2027 while _next_ordinal_to_read < 1 {
2029 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2030 _next_ordinal_to_read += 1;
2031 next_offset += envelope_size;
2032 }
2033
2034 let next_out_of_line = decoder.next_out_of_line();
2035 let handles_before = decoder.remaining_handles();
2036 if let Some((inlined, num_bytes, num_handles)) =
2037 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2038 {
2039 let member_inline_size =
2040 <BaseDeviceConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2041 if inlined != (member_inline_size <= 4) {
2042 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2043 }
2044 let inner_offset;
2045 let mut inner_depth = depth.clone();
2046 if inlined {
2047 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2048 inner_offset = next_offset;
2049 } else {
2050 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2051 inner_depth.increment()?;
2052 }
2053 let val_ref =
2054 self.base.get_or_insert_with(|| fidl::new_empty!(BaseDeviceConfig, D));
2055 fidl::decode!(BaseDeviceConfig, D, val_ref, decoder, inner_offset, inner_depth)?;
2056 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2057 {
2058 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2059 }
2060 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2061 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2062 }
2063 }
2064
2065 next_offset += envelope_size;
2066 _next_ordinal_to_read += 1;
2067 if next_offset >= end_offset {
2068 return Ok(());
2069 }
2070
2071 while _next_ordinal_to_read < 2 {
2073 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2074 _next_ordinal_to_read += 1;
2075 next_offset += envelope_size;
2076 }
2077
2078 let next_out_of_line = decoder.next_out_of_line();
2079 let handles_before = decoder.remaining_handles();
2080 if let Some((inlined, num_bytes, num_handles)) =
2081 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2082 {
2083 let member_inline_size =
2084 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2085 if inlined != (member_inline_size <= 4) {
2086 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2087 }
2088 let inner_offset;
2089 let mut inner_depth = depth.clone();
2090 if inlined {
2091 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2092 inner_offset = next_offset;
2093 } else {
2094 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2095 inner_depth.increment()?;
2096 }
2097 let val_ref = self.blocking.get_or_insert_with(|| fidl::new_empty!(bool, D));
2098 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2099 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2100 {
2101 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2102 }
2103 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2104 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2105 }
2106 }
2107
2108 next_offset += envelope_size;
2109
2110 while next_offset < end_offset {
2112 _next_ordinal_to_read += 1;
2113 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2114 next_offset += envelope_size;
2115 }
2116
2117 Ok(())
2118 }
2119 }
2120
2121 impl DevicePairConfig {
2122 #[inline(always)]
2123 fn max_ordinal_present(&self) -> u64 {
2124 if let Some(_) = self.fallible_transmit_right {
2125 return 3;
2126 }
2127 if let Some(_) = self.fallible_transmit_left {
2128 return 2;
2129 }
2130 if let Some(_) = self.base {
2131 return 1;
2132 }
2133 0
2134 }
2135 }
2136
2137 impl fidl::encoding::ValueTypeMarker for DevicePairConfig {
2138 type Borrowed<'a> = &'a Self;
2139 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2140 value
2141 }
2142 }
2143
2144 unsafe impl fidl::encoding::TypeMarker for DevicePairConfig {
2145 type Owned = Self;
2146
2147 #[inline(always)]
2148 fn inline_align(_context: fidl::encoding::Context) -> usize {
2149 8
2150 }
2151
2152 #[inline(always)]
2153 fn inline_size(_context: fidl::encoding::Context) -> usize {
2154 16
2155 }
2156 }
2157
2158 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DevicePairConfig, D>
2159 for &DevicePairConfig
2160 {
2161 unsafe fn encode(
2162 self,
2163 encoder: &mut fidl::encoding::Encoder<'_, D>,
2164 offset: usize,
2165 mut depth: fidl::encoding::Depth,
2166 ) -> fidl::Result<()> {
2167 encoder.debug_check_bounds::<DevicePairConfig>(offset);
2168 let max_ordinal: u64 = self.max_ordinal_present();
2170 encoder.write_num(max_ordinal, offset);
2171 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2172 if max_ordinal == 0 {
2174 return Ok(());
2175 }
2176 depth.increment()?;
2177 let envelope_size = 8;
2178 let bytes_len = max_ordinal as usize * envelope_size;
2179 #[allow(unused_variables)]
2180 let offset = encoder.out_of_line_offset(bytes_len);
2181 let mut _prev_end_offset: usize = 0;
2182 if 1 > max_ordinal {
2183 return Ok(());
2184 }
2185
2186 let cur_offset: usize = (1 - 1) * envelope_size;
2189
2190 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2192
2193 fidl::encoding::encode_in_envelope_optional::<BaseDeviceConfig, D>(
2198 self.base
2199 .as_ref()
2200 .map(<BaseDeviceConfig as fidl::encoding::ValueTypeMarker>::borrow),
2201 encoder,
2202 offset + cur_offset,
2203 depth,
2204 )?;
2205
2206 _prev_end_offset = cur_offset + envelope_size;
2207 if 2 > max_ordinal {
2208 return Ok(());
2209 }
2210
2211 let cur_offset: usize = (2 - 1) * envelope_size;
2214
2215 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2217
2218 fidl::encoding::encode_in_envelope_optional::<bool, D>(
2223 self.fallible_transmit_left
2224 .as_ref()
2225 .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2226 encoder,
2227 offset + cur_offset,
2228 depth,
2229 )?;
2230
2231 _prev_end_offset = cur_offset + envelope_size;
2232 if 3 > max_ordinal {
2233 return Ok(());
2234 }
2235
2236 let cur_offset: usize = (3 - 1) * envelope_size;
2239
2240 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2242
2243 fidl::encoding::encode_in_envelope_optional::<bool, D>(
2248 self.fallible_transmit_right
2249 .as_ref()
2250 .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2251 encoder,
2252 offset + cur_offset,
2253 depth,
2254 )?;
2255
2256 _prev_end_offset = cur_offset + envelope_size;
2257
2258 Ok(())
2259 }
2260 }
2261
2262 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DevicePairConfig {
2263 #[inline(always)]
2264 fn new_empty() -> Self {
2265 Self::default()
2266 }
2267
2268 unsafe fn decode(
2269 &mut self,
2270 decoder: &mut fidl::encoding::Decoder<'_, D>,
2271 offset: usize,
2272 mut depth: fidl::encoding::Depth,
2273 ) -> fidl::Result<()> {
2274 decoder.debug_check_bounds::<Self>(offset);
2275 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2276 None => return Err(fidl::Error::NotNullable),
2277 Some(len) => len,
2278 };
2279 if len == 0 {
2281 return Ok(());
2282 };
2283 depth.increment()?;
2284 let envelope_size = 8;
2285 let bytes_len = len * envelope_size;
2286 let offset = decoder.out_of_line_offset(bytes_len)?;
2287 let mut _next_ordinal_to_read = 0;
2289 let mut next_offset = offset;
2290 let end_offset = offset + bytes_len;
2291 _next_ordinal_to_read += 1;
2292 if next_offset >= end_offset {
2293 return Ok(());
2294 }
2295
2296 while _next_ordinal_to_read < 1 {
2298 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2299 _next_ordinal_to_read += 1;
2300 next_offset += envelope_size;
2301 }
2302
2303 let next_out_of_line = decoder.next_out_of_line();
2304 let handles_before = decoder.remaining_handles();
2305 if let Some((inlined, num_bytes, num_handles)) =
2306 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2307 {
2308 let member_inline_size =
2309 <BaseDeviceConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2310 if inlined != (member_inline_size <= 4) {
2311 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2312 }
2313 let inner_offset;
2314 let mut inner_depth = depth.clone();
2315 if inlined {
2316 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2317 inner_offset = next_offset;
2318 } else {
2319 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2320 inner_depth.increment()?;
2321 }
2322 let val_ref =
2323 self.base.get_or_insert_with(|| fidl::new_empty!(BaseDeviceConfig, D));
2324 fidl::decode!(BaseDeviceConfig, D, val_ref, decoder, inner_offset, inner_depth)?;
2325 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2326 {
2327 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2328 }
2329 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2330 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2331 }
2332 }
2333
2334 next_offset += envelope_size;
2335 _next_ordinal_to_read += 1;
2336 if next_offset >= end_offset {
2337 return Ok(());
2338 }
2339
2340 while _next_ordinal_to_read < 2 {
2342 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2343 _next_ordinal_to_read += 1;
2344 next_offset += envelope_size;
2345 }
2346
2347 let next_out_of_line = decoder.next_out_of_line();
2348 let handles_before = decoder.remaining_handles();
2349 if let Some((inlined, num_bytes, num_handles)) =
2350 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2351 {
2352 let member_inline_size =
2353 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2354 if inlined != (member_inline_size <= 4) {
2355 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2356 }
2357 let inner_offset;
2358 let mut inner_depth = depth.clone();
2359 if inlined {
2360 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2361 inner_offset = next_offset;
2362 } else {
2363 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2364 inner_depth.increment()?;
2365 }
2366 let val_ref =
2367 self.fallible_transmit_left.get_or_insert_with(|| fidl::new_empty!(bool, D));
2368 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2369 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2370 {
2371 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2372 }
2373 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2374 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2375 }
2376 }
2377
2378 next_offset += envelope_size;
2379 _next_ordinal_to_read += 1;
2380 if next_offset >= end_offset {
2381 return Ok(());
2382 }
2383
2384 while _next_ordinal_to_read < 3 {
2386 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2387 _next_ordinal_to_read += 1;
2388 next_offset += envelope_size;
2389 }
2390
2391 let next_out_of_line = decoder.next_out_of_line();
2392 let handles_before = decoder.remaining_handles();
2393 if let Some((inlined, num_bytes, num_handles)) =
2394 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2395 {
2396 let member_inline_size =
2397 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2398 if inlined != (member_inline_size <= 4) {
2399 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2400 }
2401 let inner_offset;
2402 let mut inner_depth = depth.clone();
2403 if inlined {
2404 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2405 inner_offset = next_offset;
2406 } else {
2407 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2408 inner_depth.increment()?;
2409 }
2410 let val_ref =
2411 self.fallible_transmit_right.get_or_insert_with(|| fidl::new_empty!(bool, D));
2412 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2413 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2414 {
2415 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2416 }
2417 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2418 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2419 }
2420 }
2421
2422 next_offset += envelope_size;
2423
2424 while next_offset < end_offset {
2426 _next_ordinal_to_read += 1;
2427 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2428 next_offset += envelope_size;
2429 }
2430
2431 Ok(())
2432 }
2433 }
2434
2435 impl DevicePairPortConfig {
2436 #[inline(always)]
2437 fn max_ordinal_present(&self) -> u64 {
2438 if let Some(_) = self.mac_right {
2439 return 3;
2440 }
2441 if let Some(_) = self.mac_left {
2442 return 2;
2443 }
2444 if let Some(_) = self.base {
2445 return 1;
2446 }
2447 0
2448 }
2449 }
2450
2451 impl fidl::encoding::ValueTypeMarker for DevicePairPortConfig {
2452 type Borrowed<'a> = &'a Self;
2453 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2454 value
2455 }
2456 }
2457
2458 unsafe impl fidl::encoding::TypeMarker for DevicePairPortConfig {
2459 type Owned = Self;
2460
2461 #[inline(always)]
2462 fn inline_align(_context: fidl::encoding::Context) -> usize {
2463 8
2464 }
2465
2466 #[inline(always)]
2467 fn inline_size(_context: fidl::encoding::Context) -> usize {
2468 16
2469 }
2470 }
2471
2472 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DevicePairPortConfig, D>
2473 for &DevicePairPortConfig
2474 {
2475 unsafe fn encode(
2476 self,
2477 encoder: &mut fidl::encoding::Encoder<'_, D>,
2478 offset: usize,
2479 mut depth: fidl::encoding::Depth,
2480 ) -> fidl::Result<()> {
2481 encoder.debug_check_bounds::<DevicePairPortConfig>(offset);
2482 let max_ordinal: u64 = self.max_ordinal_present();
2484 encoder.write_num(max_ordinal, offset);
2485 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2486 if max_ordinal == 0 {
2488 return Ok(());
2489 }
2490 depth.increment()?;
2491 let envelope_size = 8;
2492 let bytes_len = max_ordinal as usize * envelope_size;
2493 #[allow(unused_variables)]
2494 let offset = encoder.out_of_line_offset(bytes_len);
2495 let mut _prev_end_offset: usize = 0;
2496 if 1 > max_ordinal {
2497 return Ok(());
2498 }
2499
2500 let cur_offset: usize = (1 - 1) * envelope_size;
2503
2504 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2506
2507 fidl::encoding::encode_in_envelope_optional::<BasePortConfig, D>(
2512 self.base.as_ref().map(<BasePortConfig as fidl::encoding::ValueTypeMarker>::borrow),
2513 encoder,
2514 offset + cur_offset,
2515 depth,
2516 )?;
2517
2518 _prev_end_offset = cur_offset + envelope_size;
2519 if 2 > max_ordinal {
2520 return Ok(());
2521 }
2522
2523 let cur_offset: usize = (2 - 1) * envelope_size;
2526
2527 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2529
2530 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_net::MacAddress, D>(
2535 self.mac_left
2536 .as_ref()
2537 .map(<fidl_fuchsia_net::MacAddress as fidl::encoding::ValueTypeMarker>::borrow),
2538 encoder,
2539 offset + cur_offset,
2540 depth,
2541 )?;
2542
2543 _prev_end_offset = cur_offset + envelope_size;
2544 if 3 > max_ordinal {
2545 return Ok(());
2546 }
2547
2548 let cur_offset: usize = (3 - 1) * envelope_size;
2551
2552 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2554
2555 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_net::MacAddress, D>(
2560 self.mac_right
2561 .as_ref()
2562 .map(<fidl_fuchsia_net::MacAddress as fidl::encoding::ValueTypeMarker>::borrow),
2563 encoder,
2564 offset + cur_offset,
2565 depth,
2566 )?;
2567
2568 _prev_end_offset = cur_offset + envelope_size;
2569
2570 Ok(())
2571 }
2572 }
2573
2574 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DevicePairPortConfig {
2575 #[inline(always)]
2576 fn new_empty() -> Self {
2577 Self::default()
2578 }
2579
2580 unsafe fn decode(
2581 &mut self,
2582 decoder: &mut fidl::encoding::Decoder<'_, D>,
2583 offset: usize,
2584 mut depth: fidl::encoding::Depth,
2585 ) -> fidl::Result<()> {
2586 decoder.debug_check_bounds::<Self>(offset);
2587 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2588 None => return Err(fidl::Error::NotNullable),
2589 Some(len) => len,
2590 };
2591 if len == 0 {
2593 return Ok(());
2594 };
2595 depth.increment()?;
2596 let envelope_size = 8;
2597 let bytes_len = len * envelope_size;
2598 let offset = decoder.out_of_line_offset(bytes_len)?;
2599 let mut _next_ordinal_to_read = 0;
2601 let mut next_offset = offset;
2602 let end_offset = offset + bytes_len;
2603 _next_ordinal_to_read += 1;
2604 if next_offset >= end_offset {
2605 return Ok(());
2606 }
2607
2608 while _next_ordinal_to_read < 1 {
2610 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2611 _next_ordinal_to_read += 1;
2612 next_offset += envelope_size;
2613 }
2614
2615 let next_out_of_line = decoder.next_out_of_line();
2616 let handles_before = decoder.remaining_handles();
2617 if let Some((inlined, num_bytes, num_handles)) =
2618 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2619 {
2620 let member_inline_size =
2621 <BasePortConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2622 if inlined != (member_inline_size <= 4) {
2623 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2624 }
2625 let inner_offset;
2626 let mut inner_depth = depth.clone();
2627 if inlined {
2628 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2629 inner_offset = next_offset;
2630 } else {
2631 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2632 inner_depth.increment()?;
2633 }
2634 let val_ref = self.base.get_or_insert_with(|| fidl::new_empty!(BasePortConfig, D));
2635 fidl::decode!(BasePortConfig, D, val_ref, decoder, inner_offset, inner_depth)?;
2636 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2637 {
2638 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2639 }
2640 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2641 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2642 }
2643 }
2644
2645 next_offset += envelope_size;
2646 _next_ordinal_to_read += 1;
2647 if next_offset >= end_offset {
2648 return Ok(());
2649 }
2650
2651 while _next_ordinal_to_read < 2 {
2653 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2654 _next_ordinal_to_read += 1;
2655 next_offset += envelope_size;
2656 }
2657
2658 let next_out_of_line = decoder.next_out_of_line();
2659 let handles_before = decoder.remaining_handles();
2660 if let Some((inlined, num_bytes, num_handles)) =
2661 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2662 {
2663 let member_inline_size =
2664 <fidl_fuchsia_net::MacAddress as fidl::encoding::TypeMarker>::inline_size(
2665 decoder.context,
2666 );
2667 if inlined != (member_inline_size <= 4) {
2668 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2669 }
2670 let inner_offset;
2671 let mut inner_depth = depth.clone();
2672 if inlined {
2673 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2674 inner_offset = next_offset;
2675 } else {
2676 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2677 inner_depth.increment()?;
2678 }
2679 let val_ref = self
2680 .mac_left
2681 .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_net::MacAddress, D));
2682 fidl::decode!(
2683 fidl_fuchsia_net::MacAddress,
2684 D,
2685 val_ref,
2686 decoder,
2687 inner_offset,
2688 inner_depth
2689 )?;
2690 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2691 {
2692 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2693 }
2694 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2695 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2696 }
2697 }
2698
2699 next_offset += envelope_size;
2700 _next_ordinal_to_read += 1;
2701 if next_offset >= end_offset {
2702 return Ok(());
2703 }
2704
2705 while _next_ordinal_to_read < 3 {
2707 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2708 _next_ordinal_to_read += 1;
2709 next_offset += envelope_size;
2710 }
2711
2712 let next_out_of_line = decoder.next_out_of_line();
2713 let handles_before = decoder.remaining_handles();
2714 if let Some((inlined, num_bytes, num_handles)) =
2715 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2716 {
2717 let member_inline_size =
2718 <fidl_fuchsia_net::MacAddress as fidl::encoding::TypeMarker>::inline_size(
2719 decoder.context,
2720 );
2721 if inlined != (member_inline_size <= 4) {
2722 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2723 }
2724 let inner_offset;
2725 let mut inner_depth = depth.clone();
2726 if inlined {
2727 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2728 inner_offset = next_offset;
2729 } else {
2730 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2731 inner_depth.increment()?;
2732 }
2733 let val_ref = self
2734 .mac_right
2735 .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_net::MacAddress, D));
2736 fidl::decode!(
2737 fidl_fuchsia_net::MacAddress,
2738 D,
2739 val_ref,
2740 decoder,
2741 inner_offset,
2742 inner_depth
2743 )?;
2744 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2745 {
2746 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2747 }
2748 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2749 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2750 }
2751 }
2752
2753 next_offset += envelope_size;
2754
2755 while next_offset < end_offset {
2757 _next_ordinal_to_read += 1;
2758 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2759 next_offset += envelope_size;
2760 }
2761
2762 Ok(())
2763 }
2764 }
2765
2766 impl DevicePortConfig {
2767 #[inline(always)]
2768 fn max_ordinal_present(&self) -> u64 {
2769 if let Some(_) = self.mac {
2770 return 3;
2771 }
2772 if let Some(_) = self.online {
2773 return 2;
2774 }
2775 if let Some(_) = self.base {
2776 return 1;
2777 }
2778 0
2779 }
2780 }
2781
2782 impl fidl::encoding::ValueTypeMarker for DevicePortConfig {
2783 type Borrowed<'a> = &'a Self;
2784 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2785 value
2786 }
2787 }
2788
2789 unsafe impl fidl::encoding::TypeMarker for DevicePortConfig {
2790 type Owned = Self;
2791
2792 #[inline(always)]
2793 fn inline_align(_context: fidl::encoding::Context) -> usize {
2794 8
2795 }
2796
2797 #[inline(always)]
2798 fn inline_size(_context: fidl::encoding::Context) -> usize {
2799 16
2800 }
2801 }
2802
2803 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DevicePortConfig, D>
2804 for &DevicePortConfig
2805 {
2806 unsafe fn encode(
2807 self,
2808 encoder: &mut fidl::encoding::Encoder<'_, D>,
2809 offset: usize,
2810 mut depth: fidl::encoding::Depth,
2811 ) -> fidl::Result<()> {
2812 encoder.debug_check_bounds::<DevicePortConfig>(offset);
2813 let max_ordinal: u64 = self.max_ordinal_present();
2815 encoder.write_num(max_ordinal, offset);
2816 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2817 if max_ordinal == 0 {
2819 return Ok(());
2820 }
2821 depth.increment()?;
2822 let envelope_size = 8;
2823 let bytes_len = max_ordinal as usize * envelope_size;
2824 #[allow(unused_variables)]
2825 let offset = encoder.out_of_line_offset(bytes_len);
2826 let mut _prev_end_offset: usize = 0;
2827 if 1 > max_ordinal {
2828 return Ok(());
2829 }
2830
2831 let cur_offset: usize = (1 - 1) * envelope_size;
2834
2835 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2837
2838 fidl::encoding::encode_in_envelope_optional::<BasePortConfig, D>(
2843 self.base.as_ref().map(<BasePortConfig as fidl::encoding::ValueTypeMarker>::borrow),
2844 encoder,
2845 offset + cur_offset,
2846 depth,
2847 )?;
2848
2849 _prev_end_offset = cur_offset + envelope_size;
2850 if 2 > max_ordinal {
2851 return Ok(());
2852 }
2853
2854 let cur_offset: usize = (2 - 1) * envelope_size;
2857
2858 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2860
2861 fidl::encoding::encode_in_envelope_optional::<bool, D>(
2866 self.online.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2867 encoder,
2868 offset + cur_offset,
2869 depth,
2870 )?;
2871
2872 _prev_end_offset = cur_offset + envelope_size;
2873 if 3 > max_ordinal {
2874 return Ok(());
2875 }
2876
2877 let cur_offset: usize = (3 - 1) * envelope_size;
2880
2881 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2883
2884 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_net::MacAddress, D>(
2889 self.mac
2890 .as_ref()
2891 .map(<fidl_fuchsia_net::MacAddress as fidl::encoding::ValueTypeMarker>::borrow),
2892 encoder,
2893 offset + cur_offset,
2894 depth,
2895 )?;
2896
2897 _prev_end_offset = cur_offset + envelope_size;
2898
2899 Ok(())
2900 }
2901 }
2902
2903 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DevicePortConfig {
2904 #[inline(always)]
2905 fn new_empty() -> Self {
2906 Self::default()
2907 }
2908
2909 unsafe fn decode(
2910 &mut self,
2911 decoder: &mut fidl::encoding::Decoder<'_, D>,
2912 offset: usize,
2913 mut depth: fidl::encoding::Depth,
2914 ) -> fidl::Result<()> {
2915 decoder.debug_check_bounds::<Self>(offset);
2916 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2917 None => return Err(fidl::Error::NotNullable),
2918 Some(len) => len,
2919 };
2920 if len == 0 {
2922 return Ok(());
2923 };
2924 depth.increment()?;
2925 let envelope_size = 8;
2926 let bytes_len = len * envelope_size;
2927 let offset = decoder.out_of_line_offset(bytes_len)?;
2928 let mut _next_ordinal_to_read = 0;
2930 let mut next_offset = offset;
2931 let end_offset = offset + bytes_len;
2932 _next_ordinal_to_read += 1;
2933 if next_offset >= end_offset {
2934 return Ok(());
2935 }
2936
2937 while _next_ordinal_to_read < 1 {
2939 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2940 _next_ordinal_to_read += 1;
2941 next_offset += envelope_size;
2942 }
2943
2944 let next_out_of_line = decoder.next_out_of_line();
2945 let handles_before = decoder.remaining_handles();
2946 if let Some((inlined, num_bytes, num_handles)) =
2947 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2948 {
2949 let member_inline_size =
2950 <BasePortConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2951 if inlined != (member_inline_size <= 4) {
2952 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2953 }
2954 let inner_offset;
2955 let mut inner_depth = depth.clone();
2956 if inlined {
2957 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2958 inner_offset = next_offset;
2959 } else {
2960 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2961 inner_depth.increment()?;
2962 }
2963 let val_ref = self.base.get_or_insert_with(|| fidl::new_empty!(BasePortConfig, D));
2964 fidl::decode!(BasePortConfig, D, val_ref, decoder, inner_offset, inner_depth)?;
2965 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2966 {
2967 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2968 }
2969 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2970 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2971 }
2972 }
2973
2974 next_offset += envelope_size;
2975 _next_ordinal_to_read += 1;
2976 if next_offset >= end_offset {
2977 return Ok(());
2978 }
2979
2980 while _next_ordinal_to_read < 2 {
2982 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2983 _next_ordinal_to_read += 1;
2984 next_offset += envelope_size;
2985 }
2986
2987 let next_out_of_line = decoder.next_out_of_line();
2988 let handles_before = decoder.remaining_handles();
2989 if let Some((inlined, num_bytes, num_handles)) =
2990 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2991 {
2992 let member_inline_size =
2993 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2994 if inlined != (member_inline_size <= 4) {
2995 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2996 }
2997 let inner_offset;
2998 let mut inner_depth = depth.clone();
2999 if inlined {
3000 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3001 inner_offset = next_offset;
3002 } else {
3003 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3004 inner_depth.increment()?;
3005 }
3006 let val_ref = self.online.get_or_insert_with(|| fidl::new_empty!(bool, D));
3007 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3008 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3009 {
3010 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3011 }
3012 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3013 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3014 }
3015 }
3016
3017 next_offset += envelope_size;
3018 _next_ordinal_to_read += 1;
3019 if next_offset >= end_offset {
3020 return Ok(());
3021 }
3022
3023 while _next_ordinal_to_read < 3 {
3025 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3026 _next_ordinal_to_read += 1;
3027 next_offset += envelope_size;
3028 }
3029
3030 let next_out_of_line = decoder.next_out_of_line();
3031 let handles_before = decoder.remaining_handles();
3032 if let Some((inlined, num_bytes, num_handles)) =
3033 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3034 {
3035 let member_inline_size =
3036 <fidl_fuchsia_net::MacAddress as fidl::encoding::TypeMarker>::inline_size(
3037 decoder.context,
3038 );
3039 if inlined != (member_inline_size <= 4) {
3040 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3041 }
3042 let inner_offset;
3043 let mut inner_depth = depth.clone();
3044 if inlined {
3045 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3046 inner_offset = next_offset;
3047 } else {
3048 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3049 inner_depth.increment()?;
3050 }
3051 let val_ref = self
3052 .mac
3053 .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_net::MacAddress, D));
3054 fidl::decode!(
3055 fidl_fuchsia_net::MacAddress,
3056 D,
3057 val_ref,
3058 decoder,
3059 inner_offset,
3060 inner_depth
3061 )?;
3062 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3063 {
3064 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3065 }
3066 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3067 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3068 }
3069 }
3070
3071 next_offset += envelope_size;
3072
3073 while next_offset < end_offset {
3075 _next_ordinal_to_read += 1;
3076 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3077 next_offset += envelope_size;
3078 }
3079
3080 Ok(())
3081 }
3082 }
3083
3084 impl Frame {
3085 #[inline(always)]
3086 fn max_ordinal_present(&self) -> u64 {
3087 if let Some(_) = self.port {
3088 return 4;
3089 }
3090 if let Some(_) = self.meta {
3091 return 3;
3092 }
3093 if let Some(_) = self.data {
3094 return 2;
3095 }
3096 if let Some(_) = self.frame_type {
3097 return 1;
3098 }
3099 0
3100 }
3101 }
3102
3103 impl fidl::encoding::ValueTypeMarker for Frame {
3104 type Borrowed<'a> = &'a Self;
3105 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3106 value
3107 }
3108 }
3109
3110 unsafe impl fidl::encoding::TypeMarker for Frame {
3111 type Owned = Self;
3112
3113 #[inline(always)]
3114 fn inline_align(_context: fidl::encoding::Context) -> usize {
3115 8
3116 }
3117
3118 #[inline(always)]
3119 fn inline_size(_context: fidl::encoding::Context) -> usize {
3120 16
3121 }
3122 }
3123
3124 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Frame, D> for &Frame {
3125 unsafe fn encode(
3126 self,
3127 encoder: &mut fidl::encoding::Encoder<'_, D>,
3128 offset: usize,
3129 mut depth: fidl::encoding::Depth,
3130 ) -> fidl::Result<()> {
3131 encoder.debug_check_bounds::<Frame>(offset);
3132 let max_ordinal: u64 = self.max_ordinal_present();
3134 encoder.write_num(max_ordinal, offset);
3135 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3136 if max_ordinal == 0 {
3138 return Ok(());
3139 }
3140 depth.increment()?;
3141 let envelope_size = 8;
3142 let bytes_len = max_ordinal as usize * envelope_size;
3143 #[allow(unused_variables)]
3144 let offset = encoder.out_of_line_offset(bytes_len);
3145 let mut _prev_end_offset: usize = 0;
3146 if 1 > max_ordinal {
3147 return Ok(());
3148 }
3149
3150 let cur_offset: usize = (1 - 1) * envelope_size;
3153
3154 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3156
3157 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_network::FrameType, D>(
3162 self.frame_type.as_ref().map(<fidl_fuchsia_hardware_network::FrameType as fidl::encoding::ValueTypeMarker>::borrow),
3163 encoder, offset + cur_offset, depth
3164 )?;
3165
3166 _prev_end_offset = cur_offset + envelope_size;
3167 if 2 > max_ordinal {
3168 return Ok(());
3169 }
3170
3171 let cur_offset: usize = (2 - 1) * envelope_size;
3174
3175 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3177
3178 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 16384>, D>(
3183 self.data.as_ref().map(
3184 <fidl::encoding::Vector<u8, 16384> as fidl::encoding::ValueTypeMarker>::borrow,
3185 ),
3186 encoder,
3187 offset + cur_offset,
3188 depth,
3189 )?;
3190
3191 _prev_end_offset = cur_offset + envelope_size;
3192 if 3 > max_ordinal {
3193 return Ok(());
3194 }
3195
3196 let cur_offset: usize = (3 - 1) * envelope_size;
3199
3200 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3202
3203 fidl::encoding::encode_in_envelope_optional::<FrameMetadata, D>(
3208 self.meta.as_ref().map(<FrameMetadata as fidl::encoding::ValueTypeMarker>::borrow),
3209 encoder,
3210 offset + cur_offset,
3211 depth,
3212 )?;
3213
3214 _prev_end_offset = cur_offset + envelope_size;
3215 if 4 > max_ordinal {
3216 return Ok(());
3217 }
3218
3219 let cur_offset: usize = (4 - 1) * envelope_size;
3222
3223 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3225
3226 fidl::encoding::encode_in_envelope_optional::<u8, D>(
3231 self.port.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
3232 encoder,
3233 offset + cur_offset,
3234 depth,
3235 )?;
3236
3237 _prev_end_offset = cur_offset + envelope_size;
3238
3239 Ok(())
3240 }
3241 }
3242
3243 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Frame {
3244 #[inline(always)]
3245 fn new_empty() -> Self {
3246 Self::default()
3247 }
3248
3249 unsafe fn decode(
3250 &mut self,
3251 decoder: &mut fidl::encoding::Decoder<'_, D>,
3252 offset: usize,
3253 mut depth: fidl::encoding::Depth,
3254 ) -> fidl::Result<()> {
3255 decoder.debug_check_bounds::<Self>(offset);
3256 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3257 None => return Err(fidl::Error::NotNullable),
3258 Some(len) => len,
3259 };
3260 if len == 0 {
3262 return Ok(());
3263 };
3264 depth.increment()?;
3265 let envelope_size = 8;
3266 let bytes_len = len * envelope_size;
3267 let offset = decoder.out_of_line_offset(bytes_len)?;
3268 let mut _next_ordinal_to_read = 0;
3270 let mut next_offset = offset;
3271 let end_offset = offset + bytes_len;
3272 _next_ordinal_to_read += 1;
3273 if next_offset >= end_offset {
3274 return Ok(());
3275 }
3276
3277 while _next_ordinal_to_read < 1 {
3279 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3280 _next_ordinal_to_read += 1;
3281 next_offset += envelope_size;
3282 }
3283
3284 let next_out_of_line = decoder.next_out_of_line();
3285 let handles_before = decoder.remaining_handles();
3286 if let Some((inlined, num_bytes, num_handles)) =
3287 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3288 {
3289 let member_inline_size = <fidl_fuchsia_hardware_network::FrameType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3290 if inlined != (member_inline_size <= 4) {
3291 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3292 }
3293 let inner_offset;
3294 let mut inner_depth = depth.clone();
3295 if inlined {
3296 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3297 inner_offset = next_offset;
3298 } else {
3299 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3300 inner_depth.increment()?;
3301 }
3302 let val_ref = self.frame_type.get_or_insert_with(|| {
3303 fidl::new_empty!(fidl_fuchsia_hardware_network::FrameType, D)
3304 });
3305 fidl::decode!(
3306 fidl_fuchsia_hardware_network::FrameType,
3307 D,
3308 val_ref,
3309 decoder,
3310 inner_offset,
3311 inner_depth
3312 )?;
3313 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3314 {
3315 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3316 }
3317 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3318 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3319 }
3320 }
3321
3322 next_offset += envelope_size;
3323 _next_ordinal_to_read += 1;
3324 if next_offset >= end_offset {
3325 return Ok(());
3326 }
3327
3328 while _next_ordinal_to_read < 2 {
3330 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3331 _next_ordinal_to_read += 1;
3332 next_offset += envelope_size;
3333 }
3334
3335 let next_out_of_line = decoder.next_out_of_line();
3336 let handles_before = decoder.remaining_handles();
3337 if let Some((inlined, num_bytes, num_handles)) =
3338 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3339 {
3340 let member_inline_size =
3341 <fidl::encoding::Vector<u8, 16384> as fidl::encoding::TypeMarker>::inline_size(
3342 decoder.context,
3343 );
3344 if inlined != (member_inline_size <= 4) {
3345 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3346 }
3347 let inner_offset;
3348 let mut inner_depth = depth.clone();
3349 if inlined {
3350 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3351 inner_offset = next_offset;
3352 } else {
3353 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3354 inner_depth.increment()?;
3355 }
3356 let val_ref = self
3357 .data
3358 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 16384>, D));
3359 fidl::decode!(fidl::encoding::Vector<u8, 16384>, D, val_ref, decoder, inner_offset, inner_depth)?;
3360 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3361 {
3362 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3363 }
3364 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3365 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3366 }
3367 }
3368
3369 next_offset += envelope_size;
3370 _next_ordinal_to_read += 1;
3371 if next_offset >= end_offset {
3372 return Ok(());
3373 }
3374
3375 while _next_ordinal_to_read < 3 {
3377 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3378 _next_ordinal_to_read += 1;
3379 next_offset += envelope_size;
3380 }
3381
3382 let next_out_of_line = decoder.next_out_of_line();
3383 let handles_before = decoder.remaining_handles();
3384 if let Some((inlined, num_bytes, num_handles)) =
3385 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3386 {
3387 let member_inline_size =
3388 <FrameMetadata as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3389 if inlined != (member_inline_size <= 4) {
3390 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3391 }
3392 let inner_offset;
3393 let mut inner_depth = depth.clone();
3394 if inlined {
3395 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3396 inner_offset = next_offset;
3397 } else {
3398 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3399 inner_depth.increment()?;
3400 }
3401 let val_ref = self.meta.get_or_insert_with(|| fidl::new_empty!(FrameMetadata, D));
3402 fidl::decode!(FrameMetadata, D, val_ref, decoder, inner_offset, inner_depth)?;
3403 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3404 {
3405 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3406 }
3407 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3408 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3409 }
3410 }
3411
3412 next_offset += envelope_size;
3413 _next_ordinal_to_read += 1;
3414 if next_offset >= end_offset {
3415 return Ok(());
3416 }
3417
3418 while _next_ordinal_to_read < 4 {
3420 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3421 _next_ordinal_to_read += 1;
3422 next_offset += envelope_size;
3423 }
3424
3425 let next_out_of_line = decoder.next_out_of_line();
3426 let handles_before = decoder.remaining_handles();
3427 if let Some((inlined, num_bytes, num_handles)) =
3428 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3429 {
3430 let member_inline_size =
3431 <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3432 if inlined != (member_inline_size <= 4) {
3433 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3434 }
3435 let inner_offset;
3436 let mut inner_depth = depth.clone();
3437 if inlined {
3438 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3439 inner_offset = next_offset;
3440 } else {
3441 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3442 inner_depth.increment()?;
3443 }
3444 let val_ref = self.port.get_or_insert_with(|| fidl::new_empty!(u8, D));
3445 fidl::decode!(u8, D, val_ref, decoder, inner_offset, inner_depth)?;
3446 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3447 {
3448 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3449 }
3450 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3451 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3452 }
3453 }
3454
3455 next_offset += envelope_size;
3456
3457 while next_offset < end_offset {
3459 _next_ordinal_to_read += 1;
3460 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3461 next_offset += envelope_size;
3462 }
3463
3464 Ok(())
3465 }
3466 }
3467
3468 impl InternalState {
3469 #[inline(always)]
3470 fn max_ordinal_present(&self) -> u64 {
3471 if let Some(_) = self.has_session {
3472 return 2;
3473 }
3474 if let Some(_) = self.mac {
3475 return 1;
3476 }
3477 0
3478 }
3479 }
3480
3481 impl fidl::encoding::ValueTypeMarker for InternalState {
3482 type Borrowed<'a> = &'a Self;
3483 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3484 value
3485 }
3486 }
3487
3488 unsafe impl fidl::encoding::TypeMarker for InternalState {
3489 type Owned = Self;
3490
3491 #[inline(always)]
3492 fn inline_align(_context: fidl::encoding::Context) -> usize {
3493 8
3494 }
3495
3496 #[inline(always)]
3497 fn inline_size(_context: fidl::encoding::Context) -> usize {
3498 16
3499 }
3500 }
3501
3502 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InternalState, D>
3503 for &InternalState
3504 {
3505 unsafe fn encode(
3506 self,
3507 encoder: &mut fidl::encoding::Encoder<'_, D>,
3508 offset: usize,
3509 mut depth: fidl::encoding::Depth,
3510 ) -> fidl::Result<()> {
3511 encoder.debug_check_bounds::<InternalState>(offset);
3512 let max_ordinal: u64 = self.max_ordinal_present();
3514 encoder.write_num(max_ordinal, offset);
3515 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3516 if max_ordinal == 0 {
3518 return Ok(());
3519 }
3520 depth.increment()?;
3521 let envelope_size = 8;
3522 let bytes_len = max_ordinal as usize * envelope_size;
3523 #[allow(unused_variables)]
3524 let offset = encoder.out_of_line_offset(bytes_len);
3525 let mut _prev_end_offset: usize = 0;
3526 if 1 > max_ordinal {
3527 return Ok(());
3528 }
3529
3530 let cur_offset: usize = (1 - 1) * envelope_size;
3533
3534 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3536
3537 fidl::encoding::encode_in_envelope_optional::<MacState, D>(
3542 self.mac.as_ref().map(<MacState as fidl::encoding::ValueTypeMarker>::borrow),
3543 encoder,
3544 offset + cur_offset,
3545 depth,
3546 )?;
3547
3548 _prev_end_offset = cur_offset + envelope_size;
3549 if 2 > max_ordinal {
3550 return Ok(());
3551 }
3552
3553 let cur_offset: usize = (2 - 1) * envelope_size;
3556
3557 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3559
3560 fidl::encoding::encode_in_envelope_optional::<bool, D>(
3565 self.has_session.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3566 encoder,
3567 offset + cur_offset,
3568 depth,
3569 )?;
3570
3571 _prev_end_offset = cur_offset + envelope_size;
3572
3573 Ok(())
3574 }
3575 }
3576
3577 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InternalState {
3578 #[inline(always)]
3579 fn new_empty() -> Self {
3580 Self::default()
3581 }
3582
3583 unsafe fn decode(
3584 &mut self,
3585 decoder: &mut fidl::encoding::Decoder<'_, D>,
3586 offset: usize,
3587 mut depth: fidl::encoding::Depth,
3588 ) -> fidl::Result<()> {
3589 decoder.debug_check_bounds::<Self>(offset);
3590 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3591 None => return Err(fidl::Error::NotNullable),
3592 Some(len) => len,
3593 };
3594 if len == 0 {
3596 return Ok(());
3597 };
3598 depth.increment()?;
3599 let envelope_size = 8;
3600 let bytes_len = len * envelope_size;
3601 let offset = decoder.out_of_line_offset(bytes_len)?;
3602 let mut _next_ordinal_to_read = 0;
3604 let mut next_offset = offset;
3605 let end_offset = offset + bytes_len;
3606 _next_ordinal_to_read += 1;
3607 if next_offset >= end_offset {
3608 return Ok(());
3609 }
3610
3611 while _next_ordinal_to_read < 1 {
3613 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3614 _next_ordinal_to_read += 1;
3615 next_offset += envelope_size;
3616 }
3617
3618 let next_out_of_line = decoder.next_out_of_line();
3619 let handles_before = decoder.remaining_handles();
3620 if let Some((inlined, num_bytes, num_handles)) =
3621 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3622 {
3623 let member_inline_size =
3624 <MacState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3625 if inlined != (member_inline_size <= 4) {
3626 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3627 }
3628 let inner_offset;
3629 let mut inner_depth = depth.clone();
3630 if inlined {
3631 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3632 inner_offset = next_offset;
3633 } else {
3634 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3635 inner_depth.increment()?;
3636 }
3637 let val_ref = self.mac.get_or_insert_with(|| fidl::new_empty!(MacState, D));
3638 fidl::decode!(MacState, D, val_ref, decoder, inner_offset, inner_depth)?;
3639 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3640 {
3641 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3642 }
3643 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3644 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3645 }
3646 }
3647
3648 next_offset += envelope_size;
3649 _next_ordinal_to_read += 1;
3650 if next_offset >= end_offset {
3651 return Ok(());
3652 }
3653
3654 while _next_ordinal_to_read < 2 {
3656 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3657 _next_ordinal_to_read += 1;
3658 next_offset += envelope_size;
3659 }
3660
3661 let next_out_of_line = decoder.next_out_of_line();
3662 let handles_before = decoder.remaining_handles();
3663 if let Some((inlined, num_bytes, num_handles)) =
3664 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3665 {
3666 let member_inline_size =
3667 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3668 if inlined != (member_inline_size <= 4) {
3669 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3670 }
3671 let inner_offset;
3672 let mut inner_depth = depth.clone();
3673 if inlined {
3674 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3675 inner_offset = next_offset;
3676 } else {
3677 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3678 inner_depth.increment()?;
3679 }
3680 let val_ref = self.has_session.get_or_insert_with(|| fidl::new_empty!(bool, D));
3681 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
3682 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3683 {
3684 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3685 }
3686 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3687 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3688 }
3689 }
3690
3691 next_offset += envelope_size;
3692
3693 while next_offset < end_offset {
3695 _next_ordinal_to_read += 1;
3696 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3697 next_offset += envelope_size;
3698 }
3699
3700 Ok(())
3701 }
3702 }
3703
3704 impl MacState {
3705 #[inline(always)]
3706 fn max_ordinal_present(&self) -> u64 {
3707 if let Some(_) = self.multicast_filters {
3708 return 2;
3709 }
3710 if let Some(_) = self.mode {
3711 return 1;
3712 }
3713 0
3714 }
3715 }
3716
3717 impl fidl::encoding::ValueTypeMarker for MacState {
3718 type Borrowed<'a> = &'a Self;
3719 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3720 value
3721 }
3722 }
3723
3724 unsafe impl fidl::encoding::TypeMarker for MacState {
3725 type Owned = Self;
3726
3727 #[inline(always)]
3728 fn inline_align(_context: fidl::encoding::Context) -> usize {
3729 8
3730 }
3731
3732 #[inline(always)]
3733 fn inline_size(_context: fidl::encoding::Context) -> usize {
3734 16
3735 }
3736 }
3737
3738 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MacState, D> for &MacState {
3739 unsafe fn encode(
3740 self,
3741 encoder: &mut fidl::encoding::Encoder<'_, D>,
3742 offset: usize,
3743 mut depth: fidl::encoding::Depth,
3744 ) -> fidl::Result<()> {
3745 encoder.debug_check_bounds::<MacState>(offset);
3746 let max_ordinal: u64 = self.max_ordinal_present();
3748 encoder.write_num(max_ordinal, offset);
3749 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3750 if max_ordinal == 0 {
3752 return Ok(());
3753 }
3754 depth.increment()?;
3755 let envelope_size = 8;
3756 let bytes_len = max_ordinal as usize * envelope_size;
3757 #[allow(unused_variables)]
3758 let offset = encoder.out_of_line_offset(bytes_len);
3759 let mut _prev_end_offset: usize = 0;
3760 if 1 > max_ordinal {
3761 return Ok(());
3762 }
3763
3764 let cur_offset: usize = (1 - 1) * envelope_size;
3767
3768 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3770
3771 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_network::MacFilterMode, D>(
3776 self.mode.as_ref().map(<fidl_fuchsia_hardware_network::MacFilterMode as fidl::encoding::ValueTypeMarker>::borrow),
3777 encoder, offset + cur_offset, depth
3778 )?;
3779
3780 _prev_end_offset = cur_offset + envelope_size;
3781 if 2 > max_ordinal {
3782 return Ok(());
3783 }
3784
3785 let cur_offset: usize = (2 - 1) * envelope_size;
3788
3789 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3791
3792 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_net::MacAddress, 64>, D>(
3797 self.multicast_filters.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_net::MacAddress, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3798 encoder, offset + cur_offset, depth
3799 )?;
3800
3801 _prev_end_offset = cur_offset + envelope_size;
3802
3803 Ok(())
3804 }
3805 }
3806
3807 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MacState {
3808 #[inline(always)]
3809 fn new_empty() -> Self {
3810 Self::default()
3811 }
3812
3813 unsafe fn decode(
3814 &mut self,
3815 decoder: &mut fidl::encoding::Decoder<'_, D>,
3816 offset: usize,
3817 mut depth: fidl::encoding::Depth,
3818 ) -> fidl::Result<()> {
3819 decoder.debug_check_bounds::<Self>(offset);
3820 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3821 None => return Err(fidl::Error::NotNullable),
3822 Some(len) => len,
3823 };
3824 if len == 0 {
3826 return Ok(());
3827 };
3828 depth.increment()?;
3829 let envelope_size = 8;
3830 let bytes_len = len * envelope_size;
3831 let offset = decoder.out_of_line_offset(bytes_len)?;
3832 let mut _next_ordinal_to_read = 0;
3834 let mut next_offset = offset;
3835 let end_offset = offset + bytes_len;
3836 _next_ordinal_to_read += 1;
3837 if next_offset >= end_offset {
3838 return Ok(());
3839 }
3840
3841 while _next_ordinal_to_read < 1 {
3843 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3844 _next_ordinal_to_read += 1;
3845 next_offset += envelope_size;
3846 }
3847
3848 let next_out_of_line = decoder.next_out_of_line();
3849 let handles_before = decoder.remaining_handles();
3850 if let Some((inlined, num_bytes, num_handles)) =
3851 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3852 {
3853 let member_inline_size = <fidl_fuchsia_hardware_network::MacFilterMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3854 if inlined != (member_inline_size <= 4) {
3855 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3856 }
3857 let inner_offset;
3858 let mut inner_depth = depth.clone();
3859 if inlined {
3860 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3861 inner_offset = next_offset;
3862 } else {
3863 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3864 inner_depth.increment()?;
3865 }
3866 let val_ref = self.mode.get_or_insert_with(|| {
3867 fidl::new_empty!(fidl_fuchsia_hardware_network::MacFilterMode, D)
3868 });
3869 fidl::decode!(
3870 fidl_fuchsia_hardware_network::MacFilterMode,
3871 D,
3872 val_ref,
3873 decoder,
3874 inner_offset,
3875 inner_depth
3876 )?;
3877 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3878 {
3879 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3880 }
3881 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3882 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3883 }
3884 }
3885
3886 next_offset += envelope_size;
3887 _next_ordinal_to_read += 1;
3888 if next_offset >= end_offset {
3889 return Ok(());
3890 }
3891
3892 while _next_ordinal_to_read < 2 {
3894 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3895 _next_ordinal_to_read += 1;
3896 next_offset += envelope_size;
3897 }
3898
3899 let next_out_of_line = decoder.next_out_of_line();
3900 let handles_before = decoder.remaining_handles();
3901 if let Some((inlined, num_bytes, num_handles)) =
3902 fidl::encoding::decode_envelope_header(decoder, next_offset)?
3903 {
3904 let member_inline_size = <fidl::encoding::Vector<fidl_fuchsia_net::MacAddress, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3905 if inlined != (member_inline_size <= 4) {
3906 return Err(fidl::Error::InvalidInlineBitInEnvelope);
3907 }
3908 let inner_offset;
3909 let mut inner_depth = depth.clone();
3910 if inlined {
3911 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3912 inner_offset = next_offset;
3913 } else {
3914 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3915 inner_depth.increment()?;
3916 }
3917 let val_ref =
3918 self.multicast_filters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_net::MacAddress, 64>, D));
3919 fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_net::MacAddress, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
3920 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3921 {
3922 return Err(fidl::Error::InvalidNumBytesInEnvelope);
3923 }
3924 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3925 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3926 }
3927 }
3928
3929 next_offset += envelope_size;
3930
3931 while next_offset < end_offset {
3933 _next_ordinal_to_read += 1;
3934 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3935 next_offset += envelope_size;
3936 }
3937
3938 Ok(())
3939 }
3940 }
3941}