Skip to main content

fidl_fuchsia_usb_policy_common/
fidl_fuchsia_usb_policy_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub const MAX_DETAILS_LENGTH: u32 = 128;
12
13/// Status of the physical USB cable connection.
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub enum CableStatus {
16    Disconnected,
17    Connected,
18    #[doc(hidden)]
19    __SourceBreaking {
20        unknown_ordinal: u32,
21    },
22}
23
24/// Pattern that matches an unknown `CableStatus` member.
25#[macro_export]
26macro_rules! CableStatusUnknown {
27    () => {
28        _
29    };
30}
31
32impl CableStatus {
33    #[inline]
34    pub fn from_primitive(prim: u32) -> Option<Self> {
35        match prim {
36            0 => Some(Self::Disconnected),
37            1 => Some(Self::Connected),
38            _ => None,
39        }
40    }
41
42    #[inline]
43    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
44        match prim {
45            0 => Self::Disconnected,
46            1 => Self::Connected,
47            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
48        }
49    }
50
51    #[inline]
52    pub fn unknown() -> Self {
53        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
54    }
55
56    #[inline]
57    pub const fn into_primitive(self) -> u32 {
58        match self {
59            Self::Disconnected => 0,
60            Self::Connected => 1,
61            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
62        }
63    }
64
65    #[inline]
66    pub fn is_unknown(&self) -> bool {
67        match self {
68            Self::__SourceBreaking { unknown_ordinal: _ } => true,
69            _ => false,
70        }
71    }
72}
73
74/// Health status of a USB function driver or connection.
75#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
76pub enum FunctionStatus {
77    Disabled,
78    Disconnected,
79    Connected,
80    Error,
81    #[doc(hidden)]
82    __SourceBreaking {
83        unknown_ordinal: u32,
84    },
85}
86
87/// Pattern that matches an unknown `FunctionStatus` member.
88#[macro_export]
89macro_rules! FunctionStatusUnknown {
90    () => {
91        _
92    };
93}
94
95impl FunctionStatus {
96    #[inline]
97    pub fn from_primitive(prim: u32) -> Option<Self> {
98        match prim {
99            0 => Some(Self::Disabled),
100            1 => Some(Self::Disconnected),
101            2 => Some(Self::Connected),
102            3 => Some(Self::Error),
103            _ => None,
104        }
105    }
106
107    #[inline]
108    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
109        match prim {
110            0 => Self::Disabled,
111            1 => Self::Disconnected,
112            2 => Self::Connected,
113            3 => Self::Error,
114            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
115        }
116    }
117
118    #[inline]
119    pub fn unknown() -> Self {
120        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
121    }
122
123    #[inline]
124    pub const fn into_primitive(self) -> u32 {
125        match self {
126            Self::Disabled => 0,
127            Self::Disconnected => 1,
128            Self::Connected => 2,
129            Self::Error => 3,
130            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
131        }
132    }
133
134    #[inline]
135    pub fn is_unknown(&self) -> bool {
136        match self {
137            Self::__SourceBreaking { unknown_ordinal: _ } => true,
138            _ => false,
139        }
140    }
141}
142
143#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
144#[repr(C)]
145pub struct ConfigurationDisconnectCableRequest {
146    pub duration: i64,
147}
148
149impl fidl::Persistable for ConfigurationDisconnectCableRequest {}
150
151#[derive(Clone, Debug, PartialEq)]
152pub struct ConfigurationSetConfigurationRequest {
153    pub device_desc: fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor,
154    pub config_descriptors:
155        Vec<Vec<fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor>>,
156}
157
158impl fidl::Persistable for ConfigurationSetConfigurationRequest {}
159
160#[derive(Clone, Debug, PartialEq)]
161pub struct ConfigurationGetConfigurationResponse {
162    pub device_desc: fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor,
163    pub config_descriptors:
164        Vec<Vec<fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor>>,
165}
166
167impl fidl::Persistable for ConfigurationGetConfigurationResponse {}
168
169/// Health information for the USB ADB function subsystem.
170#[derive(Clone, Debug, Default, PartialEq)]
171pub struct AdbHealth {
172    /// Describes the high-level policy and configuration state of the ADB function.
173    pub status: Option<FunctionStatus>,
174    /// Provides additional diagnostic details or state description.
175    pub details: Option<String>,
176    /// Indicates whether the underlying ADB daemon connection and transport are actively online and
177    /// communicating with the host. In contrast to `status == CONNECTED` (which indicates the USB
178    /// peripheral function descriptor is configured and bound), `online` indicates that end-to-end
179    /// ADB transport is active.
180    pub online: Option<bool>,
181    /// Describes the runtime execution state reported by the ADB function driver
182    /// (e.g. "kAwaitingUsbConnection", "kOnline", "kStoppingForReconnect", "kStoppingForUnbind").
183    pub driver_state: Option<String>,
184    #[doc(hidden)]
185    pub __source_breaking: fidl::marker::SourceBreaking,
186}
187
188impl fidl::Persistable for AdbHealth {}
189
190/// Health information for the USB CDC Ethernet function subsystem.
191#[derive(Clone, Debug, Default, PartialEq)]
192pub struct CdcEthernetHealth {
193    /// Describes the high-level policy and configuration state of the CDC Ethernet function.
194    pub status: Option<FunctionStatus>,
195    /// Provides additional diagnostic details or state description.
196    pub details: Option<String>,
197    /// Indicates whether the underlying Ethernet network interface and link are actively online and ready
198    /// for network traffic. In contrast to `status == CONNECTED` (which indicates the USB CDC
199    /// interface is configured on the bus), `online` indicates that the link state is up.
200    pub online: Option<bool>,
201    #[doc(hidden)]
202    pub __source_breaking: fidl::marker::SourceBreaking,
203}
204
205impl fidl::Persistable for CdcEthernetHealth {}
206
207/// A snapshot of the USB controller's current status and health.
208#[derive(Clone, Debug, Default, PartialEq)]
209pub struct HealthReport {
210    /// Describes the current state of the device as defined by the USB 2.0 spec.
211    pub state: Option<fidl_fuchsia_hardware_usb_policy_common::DeviceState>,
212    /// The address assigned to the USB device.
213    pub address: Option<u8>,
214    /// Indicates whether the USB physical cable / `VBUS` is attached ([CableStatus]).
215    pub cable_status: Option<CableStatus>,
216    /// Describes the health status of the ADB function subsystem ([AdbHealth]).
217    pub adb: Option<AdbHealth>,
218    /// Describes the health status of the CDC Ethernet function subsystem ([CdcEthernetHealth]).
219    pub cdc_ethernet: Option<CdcEthernetHealth>,
220    /// Describes the health status of the VSOCK function subsystem ([VsockHealth]).
221    pub vsock: Option<VsockHealth>,
222    #[doc(hidden)]
223    pub __source_breaking: fidl::marker::SourceBreaking,
224}
225
226impl fidl::Persistable for HealthReport {}
227
228/// Health information for the USB VSOCK function subsystem.
229#[derive(Clone, Debug, Default, PartialEq)]
230pub struct VsockHealth {
231    /// Describes the high-level policy and configuration state of the VSOCK function.
232    pub status: Option<FunctionStatus>,
233    /// The number of currently active or open multiplexed VSOCK socket channels. If unknown or
234    /// unsupported by the function driver, this field is absent (None).
235    pub active_channels: Option<u32>,
236    /// Provides additional diagnostic details or state description.
237    pub details: Option<String>,
238    /// Indicates whether the underlying VSOCK transport driver is actively online and ready for traffic.
239    /// In contrast to `status == CONNECTED` (which indicates the USB function is configured on the bus),
240    /// `online` indicates that the VSOCK service is bound and ready to accept connections.
241    pub online: Option<bool>,
242    /// Describes the runtime execution state reported by the VSOCK function driver
243    /// (e.g. "Unconfigured", "Running").
244    pub driver_state: Option<String>,
245    #[doc(hidden)]
246    pub __source_breaking: fidl::marker::SourceBreaking,
247}
248
249impl fidl::Persistable for VsockHealth {}
250
251pub mod configuration_ordinals {
252    pub const GET_CONFIGURATION: u64 = 0x451bbf2edea95fec;
253    pub const SET_CONFIGURATION: u64 = 0x188b98e71fce9223;
254    pub const DISCONNECT_CABLE: u64 = 0x50d03f08bd3ab65;
255    pub const CONNECT_CABLE: u64 = 0x2d2227bd122b2847;
256}
257
258pub mod health_ordinals {
259    pub const GET_REPORT: u64 = 0x45f3bc8cbb38e701;
260}
261
262pub mod policy_provider_ordinals {
263    pub const WATCH_DEVICE_STATE: u64 = 0x44628a2275753738;
264}
265
266mod internal {
267    use super::*;
268    unsafe impl fidl::encoding::TypeMarker for CableStatus {
269        type Owned = Self;
270
271        #[inline(always)]
272        fn inline_align(_context: fidl::encoding::Context) -> usize {
273            std::mem::align_of::<u32>()
274        }
275
276        #[inline(always)]
277        fn inline_size(_context: fidl::encoding::Context) -> usize {
278            std::mem::size_of::<u32>()
279        }
280
281        #[inline(always)]
282        fn encode_is_copy() -> bool {
283            false
284        }
285
286        #[inline(always)]
287        fn decode_is_copy() -> bool {
288            false
289        }
290    }
291
292    impl fidl::encoding::ValueTypeMarker for CableStatus {
293        type Borrowed<'a> = Self;
294        #[inline(always)]
295        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
296            *value
297        }
298    }
299
300    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for CableStatus {
301        #[inline]
302        unsafe fn encode(
303            self,
304            encoder: &mut fidl::encoding::Encoder<'_, D>,
305            offset: usize,
306            _depth: fidl::encoding::Depth,
307        ) -> fidl::Result<()> {
308            encoder.debug_check_bounds::<Self>(offset);
309            encoder.write_num(self.into_primitive(), offset);
310            Ok(())
311        }
312    }
313
314    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CableStatus {
315        #[inline(always)]
316        fn new_empty() -> Self {
317            Self::unknown()
318        }
319
320        #[inline]
321        unsafe fn decode(
322            &mut self,
323            decoder: &mut fidl::encoding::Decoder<'_, D>,
324            offset: usize,
325            _depth: fidl::encoding::Depth,
326        ) -> fidl::Result<()> {
327            decoder.debug_check_bounds::<Self>(offset);
328            let prim = decoder.read_num::<u32>(offset);
329
330            *self = Self::from_primitive_allow_unknown(prim);
331            Ok(())
332        }
333    }
334    unsafe impl fidl::encoding::TypeMarker for FunctionStatus {
335        type Owned = Self;
336
337        #[inline(always)]
338        fn inline_align(_context: fidl::encoding::Context) -> usize {
339            std::mem::align_of::<u32>()
340        }
341
342        #[inline(always)]
343        fn inline_size(_context: fidl::encoding::Context) -> usize {
344            std::mem::size_of::<u32>()
345        }
346
347        #[inline(always)]
348        fn encode_is_copy() -> bool {
349            false
350        }
351
352        #[inline(always)]
353        fn decode_is_copy() -> bool {
354            false
355        }
356    }
357
358    impl fidl::encoding::ValueTypeMarker for FunctionStatus {
359        type Borrowed<'a> = Self;
360        #[inline(always)]
361        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
362            *value
363        }
364    }
365
366    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for FunctionStatus {
367        #[inline]
368        unsafe fn encode(
369            self,
370            encoder: &mut fidl::encoding::Encoder<'_, D>,
371            offset: usize,
372            _depth: fidl::encoding::Depth,
373        ) -> fidl::Result<()> {
374            encoder.debug_check_bounds::<Self>(offset);
375            encoder.write_num(self.into_primitive(), offset);
376            Ok(())
377        }
378    }
379
380    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FunctionStatus {
381        #[inline(always)]
382        fn new_empty() -> Self {
383            Self::unknown()
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
396            *self = Self::from_primitive_allow_unknown(prim);
397            Ok(())
398        }
399    }
400
401    impl fidl::encoding::ValueTypeMarker for ConfigurationDisconnectCableRequest {
402        type Borrowed<'a> = &'a Self;
403        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
404            value
405        }
406    }
407
408    unsafe impl fidl::encoding::TypeMarker for ConfigurationDisconnectCableRequest {
409        type Owned = Self;
410
411        #[inline(always)]
412        fn inline_align(_context: fidl::encoding::Context) -> usize {
413            8
414        }
415
416        #[inline(always)]
417        fn inline_size(_context: fidl::encoding::Context) -> usize {
418            8
419        }
420        #[inline(always)]
421        fn encode_is_copy() -> bool {
422            true
423        }
424
425        #[inline(always)]
426        fn decode_is_copy() -> bool {
427            true
428        }
429    }
430
431    unsafe impl<D: fidl::encoding::ResourceDialect>
432        fidl::encoding::Encode<ConfigurationDisconnectCableRequest, D>
433        for &ConfigurationDisconnectCableRequest
434    {
435        #[inline]
436        unsafe fn encode(
437            self,
438            encoder: &mut fidl::encoding::Encoder<'_, D>,
439            offset: usize,
440            _depth: fidl::encoding::Depth,
441        ) -> fidl::Result<()> {
442            encoder.debug_check_bounds::<ConfigurationDisconnectCableRequest>(offset);
443            unsafe {
444                // Copy the object into the buffer.
445                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
446                (buf_ptr as *mut ConfigurationDisconnectCableRequest)
447                    .write_unaligned((self as *const ConfigurationDisconnectCableRequest).read());
448                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
449                // done second because the memcpy will write garbage to these bytes.
450            }
451            Ok(())
452        }
453    }
454    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
455        fidl::encoding::Encode<ConfigurationDisconnectCableRequest, D> for (T0,)
456    {
457        #[inline]
458        unsafe fn encode(
459            self,
460            encoder: &mut fidl::encoding::Encoder<'_, D>,
461            offset: usize,
462            depth: fidl::encoding::Depth,
463        ) -> fidl::Result<()> {
464            encoder.debug_check_bounds::<ConfigurationDisconnectCableRequest>(offset);
465            // Zero out padding regions. There's no need to apply masks
466            // because the unmasked parts will be overwritten by fields.
467            // Write the fields.
468            self.0.encode(encoder, offset + 0, depth)?;
469            Ok(())
470        }
471    }
472
473    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
474        for ConfigurationDisconnectCableRequest
475    {
476        #[inline(always)]
477        fn new_empty() -> Self {
478            Self { duration: fidl::new_empty!(i64, D) }
479        }
480
481        #[inline]
482        unsafe fn decode(
483            &mut self,
484            decoder: &mut fidl::encoding::Decoder<'_, D>,
485            offset: usize,
486            _depth: fidl::encoding::Depth,
487        ) -> fidl::Result<()> {
488            decoder.debug_check_bounds::<Self>(offset);
489            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
490            // Verify that padding bytes are zero.
491            // Copy from the buffer into the object.
492            unsafe {
493                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
494            }
495            Ok(())
496        }
497    }
498
499    impl fidl::encoding::ValueTypeMarker for ConfigurationSetConfigurationRequest {
500        type Borrowed<'a> = &'a Self;
501        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
502            value
503        }
504    }
505
506    unsafe impl fidl::encoding::TypeMarker for ConfigurationSetConfigurationRequest {
507        type Owned = Self;
508
509        #[inline(always)]
510        fn inline_align(_context: fidl::encoding::Context) -> usize {
511            8
512        }
513
514        #[inline(always)]
515        fn inline_size(_context: fidl::encoding::Context) -> usize {
516            88
517        }
518    }
519
520    unsafe impl<D: fidl::encoding::ResourceDialect>
521        fidl::encoding::Encode<ConfigurationSetConfigurationRequest, D>
522        for &ConfigurationSetConfigurationRequest
523    {
524        #[inline]
525        unsafe fn encode(
526            self,
527            encoder: &mut fidl::encoding::Encoder<'_, D>,
528            offset: usize,
529            _depth: fidl::encoding::Depth,
530        ) -> fidl::Result<()> {
531            encoder.debug_check_bounds::<ConfigurationSetConfigurationRequest>(offset);
532            // Delegate to tuple encoding.
533            fidl::encoding::Encode::<ConfigurationSetConfigurationRequest, D>::encode(
534                (
535                    <fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor as fidl::encoding::ValueTypeMarker>::borrow(&self.device_desc),
536                    <fidl::encoding::Vector<fidl::encoding::Vector<fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor, 32>, 5> as fidl::encoding::ValueTypeMarker>::borrow(&self.config_descriptors),
537                ),
538                encoder, offset, _depth
539            )
540        }
541    }
542    unsafe impl<
543        D: fidl::encoding::ResourceDialect,
544        T0: fidl::encoding::Encode<fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor, D>,
545        T1: fidl::encoding::Encode<
546                fidl::encoding::Vector<
547                    fidl::encoding::Vector<
548                        fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor,
549                        32,
550                    >,
551                    5,
552                >,
553                D,
554            >,
555    > fidl::encoding::Encode<ConfigurationSetConfigurationRequest, D> for (T0, T1)
556    {
557        #[inline]
558        unsafe fn encode(
559            self,
560            encoder: &mut fidl::encoding::Encoder<'_, D>,
561            offset: usize,
562            depth: fidl::encoding::Depth,
563        ) -> fidl::Result<()> {
564            encoder.debug_check_bounds::<ConfigurationSetConfigurationRequest>(offset);
565            // Zero out padding regions. There's no need to apply masks
566            // because the unmasked parts will be overwritten by fields.
567            // Write the fields.
568            self.0.encode(encoder, offset + 0, depth)?;
569            self.1.encode(encoder, offset + 72, depth)?;
570            Ok(())
571        }
572    }
573
574    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
575        for ConfigurationSetConfigurationRequest
576    {
577        #[inline(always)]
578        fn new_empty() -> Self {
579            Self {
580                device_desc: fidl::new_empty!(
581                    fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor,
582                    D
583                ),
584                config_descriptors: fidl::new_empty!(
585                    fidl::encoding::Vector<
586                        fidl::encoding::Vector<
587                            fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor,
588                            32,
589                        >,
590                        5,
591                    >,
592                    D
593                ),
594            }
595        }
596
597        #[inline]
598        unsafe fn decode(
599            &mut self,
600            decoder: &mut fidl::encoding::Decoder<'_, D>,
601            offset: usize,
602            _depth: fidl::encoding::Depth,
603        ) -> fidl::Result<()> {
604            decoder.debug_check_bounds::<Self>(offset);
605            // Verify that padding bytes are zero.
606            fidl::decode!(
607                fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor,
608                D,
609                &mut self.device_desc,
610                decoder,
611                offset + 0,
612                _depth
613            )?;
614            fidl::decode!(
615                fidl::encoding::Vector<
616                    fidl::encoding::Vector<
617                        fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor,
618                        32,
619                    >,
620                    5,
621                >,
622                D,
623                &mut self.config_descriptors,
624                decoder,
625                offset + 72,
626                _depth
627            )?;
628            Ok(())
629        }
630    }
631
632    impl fidl::encoding::ValueTypeMarker for ConfigurationGetConfigurationResponse {
633        type Borrowed<'a> = &'a Self;
634        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
635            value
636        }
637    }
638
639    unsafe impl fidl::encoding::TypeMarker for ConfigurationGetConfigurationResponse {
640        type Owned = Self;
641
642        #[inline(always)]
643        fn inline_align(_context: fidl::encoding::Context) -> usize {
644            8
645        }
646
647        #[inline(always)]
648        fn inline_size(_context: fidl::encoding::Context) -> usize {
649            88
650        }
651    }
652
653    unsafe impl<D: fidl::encoding::ResourceDialect>
654        fidl::encoding::Encode<ConfigurationGetConfigurationResponse, D>
655        for &ConfigurationGetConfigurationResponse
656    {
657        #[inline]
658        unsafe fn encode(
659            self,
660            encoder: &mut fidl::encoding::Encoder<'_, D>,
661            offset: usize,
662            _depth: fidl::encoding::Depth,
663        ) -> fidl::Result<()> {
664            encoder.debug_check_bounds::<ConfigurationGetConfigurationResponse>(offset);
665            // Delegate to tuple encoding.
666            fidl::encoding::Encode::<ConfigurationGetConfigurationResponse, D>::encode(
667                (
668                    <fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor as fidl::encoding::ValueTypeMarker>::borrow(&self.device_desc),
669                    <fidl::encoding::Vector<fidl::encoding::Vector<fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor, 32>, 5> as fidl::encoding::ValueTypeMarker>::borrow(&self.config_descriptors),
670                ),
671                encoder, offset, _depth
672            )
673        }
674    }
675    unsafe impl<
676        D: fidl::encoding::ResourceDialect,
677        T0: fidl::encoding::Encode<fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor, D>,
678        T1: fidl::encoding::Encode<
679                fidl::encoding::Vector<
680                    fidl::encoding::Vector<
681                        fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor,
682                        32,
683                    >,
684                    5,
685                >,
686                D,
687            >,
688    > fidl::encoding::Encode<ConfigurationGetConfigurationResponse, D> for (T0, T1)
689    {
690        #[inline]
691        unsafe fn encode(
692            self,
693            encoder: &mut fidl::encoding::Encoder<'_, D>,
694            offset: usize,
695            depth: fidl::encoding::Depth,
696        ) -> fidl::Result<()> {
697            encoder.debug_check_bounds::<ConfigurationGetConfigurationResponse>(offset);
698            // Zero out padding regions. There's no need to apply masks
699            // because the unmasked parts will be overwritten by fields.
700            // Write the fields.
701            self.0.encode(encoder, offset + 0, depth)?;
702            self.1.encode(encoder, offset + 72, depth)?;
703            Ok(())
704        }
705    }
706
707    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
708        for ConfigurationGetConfigurationResponse
709    {
710        #[inline(always)]
711        fn new_empty() -> Self {
712            Self {
713                device_desc: fidl::new_empty!(
714                    fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor,
715                    D
716                ),
717                config_descriptors: fidl::new_empty!(
718                    fidl::encoding::Vector<
719                        fidl::encoding::Vector<
720                            fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor,
721                            32,
722                        >,
723                        5,
724                    >,
725                    D
726                ),
727            }
728        }
729
730        #[inline]
731        unsafe fn decode(
732            &mut self,
733            decoder: &mut fidl::encoding::Decoder<'_, D>,
734            offset: usize,
735            _depth: fidl::encoding::Depth,
736        ) -> fidl::Result<()> {
737            decoder.debug_check_bounds::<Self>(offset);
738            // Verify that padding bytes are zero.
739            fidl::decode!(
740                fidl_fuchsia_hardware_usb_peripheral_common::DeviceDescriptor,
741                D,
742                &mut self.device_desc,
743                decoder,
744                offset + 0,
745                _depth
746            )?;
747            fidl::decode!(
748                fidl::encoding::Vector<
749                    fidl::encoding::Vector<
750                        fidl_fuchsia_hardware_usb_peripheral_common::FunctionDescriptor,
751                        32,
752                    >,
753                    5,
754                >,
755                D,
756                &mut self.config_descriptors,
757                decoder,
758                offset + 72,
759                _depth
760            )?;
761            Ok(())
762        }
763    }
764
765    impl AdbHealth {
766        #[inline(always)]
767        fn max_ordinal_present(&self) -> u64 {
768            if let Some(_) = self.driver_state {
769                return 4;
770            }
771            if let Some(_) = self.online {
772                return 3;
773            }
774            if let Some(_) = self.details {
775                return 2;
776            }
777            if let Some(_) = self.status {
778                return 1;
779            }
780            0
781        }
782    }
783
784    impl fidl::encoding::ValueTypeMarker for AdbHealth {
785        type Borrowed<'a> = &'a Self;
786        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
787            value
788        }
789    }
790
791    unsafe impl fidl::encoding::TypeMarker for AdbHealth {
792        type Owned = Self;
793
794        #[inline(always)]
795        fn inline_align(_context: fidl::encoding::Context) -> usize {
796            8
797        }
798
799        #[inline(always)]
800        fn inline_size(_context: fidl::encoding::Context) -> usize {
801            16
802        }
803    }
804
805    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AdbHealth, D>
806        for &AdbHealth
807    {
808        unsafe fn encode(
809            self,
810            encoder: &mut fidl::encoding::Encoder<'_, D>,
811            offset: usize,
812            mut depth: fidl::encoding::Depth,
813        ) -> fidl::Result<()> {
814            encoder.debug_check_bounds::<AdbHealth>(offset);
815            // Vector header
816            let max_ordinal: u64 = self.max_ordinal_present();
817            encoder.write_num(max_ordinal, offset);
818            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
819            // Calling encoder.out_of_line_offset(0) is not allowed.
820            if max_ordinal == 0 {
821                return Ok(());
822            }
823            depth.increment()?;
824            let envelope_size = 8;
825            let bytes_len = max_ordinal as usize * envelope_size;
826            #[allow(unused_variables)]
827            let offset = encoder.out_of_line_offset(bytes_len);
828            let mut _prev_end_offset: usize = 0;
829            if 1 > max_ordinal {
830                return Ok(());
831            }
832
833            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
834            // are envelope_size bytes.
835            let cur_offset: usize = (1 - 1) * envelope_size;
836
837            // Zero reserved fields.
838            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
839
840            // Safety:
841            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
842            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
843            //   envelope_size bytes, there is always sufficient room.
844            fidl::encoding::encode_in_envelope_optional::<FunctionStatus, D>(
845                self.status
846                    .as_ref()
847                    .map(<FunctionStatus as fidl::encoding::ValueTypeMarker>::borrow),
848                encoder,
849                offset + cur_offset,
850                depth,
851            )?;
852
853            _prev_end_offset = cur_offset + envelope_size;
854            if 2 > max_ordinal {
855                return Ok(());
856            }
857
858            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
859            // are envelope_size bytes.
860            let cur_offset: usize = (2 - 1) * envelope_size;
861
862            // Zero reserved fields.
863            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
864
865            // Safety:
866            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
867            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
868            //   envelope_size bytes, there is always sufficient room.
869            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
870                self.details.as_ref().map(
871                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
872                ),
873                encoder,
874                offset + cur_offset,
875                depth,
876            )?;
877
878            _prev_end_offset = cur_offset + envelope_size;
879            if 3 > max_ordinal {
880                return Ok(());
881            }
882
883            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
884            // are envelope_size bytes.
885            let cur_offset: usize = (3 - 1) * envelope_size;
886
887            // Zero reserved fields.
888            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
889
890            // Safety:
891            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
892            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
893            //   envelope_size bytes, there is always sufficient room.
894            fidl::encoding::encode_in_envelope_optional::<bool, D>(
895                self.online.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
896                encoder,
897                offset + cur_offset,
898                depth,
899            )?;
900
901            _prev_end_offset = cur_offset + envelope_size;
902            if 4 > max_ordinal {
903                return Ok(());
904            }
905
906            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
907            // are envelope_size bytes.
908            let cur_offset: usize = (4 - 1) * envelope_size;
909
910            // Zero reserved fields.
911            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
912
913            // Safety:
914            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
915            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
916            //   envelope_size bytes, there is always sufficient room.
917            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<32>, D>(
918                self.driver_state.as_ref().map(
919                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow,
920                ),
921                encoder,
922                offset + cur_offset,
923                depth,
924            )?;
925
926            _prev_end_offset = cur_offset + envelope_size;
927
928            Ok(())
929        }
930    }
931
932    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AdbHealth {
933        #[inline(always)]
934        fn new_empty() -> Self {
935            Self::default()
936        }
937
938        unsafe fn decode(
939            &mut self,
940            decoder: &mut fidl::encoding::Decoder<'_, D>,
941            offset: usize,
942            mut depth: fidl::encoding::Depth,
943        ) -> fidl::Result<()> {
944            decoder.debug_check_bounds::<Self>(offset);
945            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
946                None => return Err(fidl::Error::NotNullable),
947                Some(len) => len,
948            };
949            // Calling decoder.out_of_line_offset(0) is not allowed.
950            if len == 0 {
951                return Ok(());
952            };
953            depth.increment()?;
954            let envelope_size = 8;
955            let bytes_len = len * envelope_size;
956            let offset = decoder.out_of_line_offset(bytes_len)?;
957            // Decode the envelope for each type.
958            let mut _next_ordinal_to_read = 0;
959            let mut next_offset = offset;
960            let end_offset = offset + bytes_len;
961            _next_ordinal_to_read += 1;
962            if next_offset >= end_offset {
963                return Ok(());
964            }
965
966            // Decode unknown envelopes for gaps in ordinals.
967            while _next_ordinal_to_read < 1 {
968                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
969                _next_ordinal_to_read += 1;
970                next_offset += envelope_size;
971            }
972
973            let next_out_of_line = decoder.next_out_of_line();
974            let handles_before = decoder.remaining_handles();
975            if let Some((inlined, num_bytes, num_handles)) =
976                fidl::encoding::decode_envelope_header(decoder, next_offset)?
977            {
978                let member_inline_size =
979                    <FunctionStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
980                if inlined != (member_inline_size <= 4) {
981                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
982                }
983                let inner_offset;
984                let mut inner_depth = depth.clone();
985                if inlined {
986                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
987                    inner_offset = next_offset;
988                } else {
989                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
990                    inner_depth.increment()?;
991                }
992                let val_ref =
993                    self.status.get_or_insert_with(|| fidl::new_empty!(FunctionStatus, D));
994                fidl::decode!(FunctionStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
995                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
996                {
997                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
998                }
999                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1000                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1001                }
1002            }
1003
1004            next_offset += envelope_size;
1005            _next_ordinal_to_read += 1;
1006            if next_offset >= end_offset {
1007                return Ok(());
1008            }
1009
1010            // Decode unknown envelopes for gaps in ordinals.
1011            while _next_ordinal_to_read < 2 {
1012                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1013                _next_ordinal_to_read += 1;
1014                next_offset += envelope_size;
1015            }
1016
1017            let next_out_of_line = decoder.next_out_of_line();
1018            let handles_before = decoder.remaining_handles();
1019            if let Some((inlined, num_bytes, num_handles)) =
1020                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1021            {
1022                let member_inline_size =
1023                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
1024                        decoder.context,
1025                    );
1026                if inlined != (member_inline_size <= 4) {
1027                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1028                }
1029                let inner_offset;
1030                let mut inner_depth = depth.clone();
1031                if inlined {
1032                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1033                    inner_offset = next_offset;
1034                } else {
1035                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1036                    inner_depth.increment()?;
1037                }
1038                let val_ref = self
1039                    .details
1040                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
1041                fidl::decode!(
1042                    fidl::encoding::BoundedString<128>,
1043                    D,
1044                    val_ref,
1045                    decoder,
1046                    inner_offset,
1047                    inner_depth
1048                )?;
1049                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1050                {
1051                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1052                }
1053                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1054                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1055                }
1056            }
1057
1058            next_offset += envelope_size;
1059            _next_ordinal_to_read += 1;
1060            if next_offset >= end_offset {
1061                return Ok(());
1062            }
1063
1064            // Decode unknown envelopes for gaps in ordinals.
1065            while _next_ordinal_to_read < 3 {
1066                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1067                _next_ordinal_to_read += 1;
1068                next_offset += envelope_size;
1069            }
1070
1071            let next_out_of_line = decoder.next_out_of_line();
1072            let handles_before = decoder.remaining_handles();
1073            if let Some((inlined, num_bytes, num_handles)) =
1074                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1075            {
1076                let member_inline_size =
1077                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1078                if inlined != (member_inline_size <= 4) {
1079                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1080                }
1081                let inner_offset;
1082                let mut inner_depth = depth.clone();
1083                if inlined {
1084                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1085                    inner_offset = next_offset;
1086                } else {
1087                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1088                    inner_depth.increment()?;
1089                }
1090                let val_ref = self.online.get_or_insert_with(|| fidl::new_empty!(bool, D));
1091                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1092                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1093                {
1094                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1095                }
1096                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1097                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1098                }
1099            }
1100
1101            next_offset += envelope_size;
1102            _next_ordinal_to_read += 1;
1103            if next_offset >= end_offset {
1104                return Ok(());
1105            }
1106
1107            // Decode unknown envelopes for gaps in ordinals.
1108            while _next_ordinal_to_read < 4 {
1109                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1110                _next_ordinal_to_read += 1;
1111                next_offset += envelope_size;
1112            }
1113
1114            let next_out_of_line = decoder.next_out_of_line();
1115            let handles_before = decoder.remaining_handles();
1116            if let Some((inlined, num_bytes, num_handles)) =
1117                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1118            {
1119                let member_inline_size =
1120                    <fidl::encoding::BoundedString<32> as fidl::encoding::TypeMarker>::inline_size(
1121                        decoder.context,
1122                    );
1123                if inlined != (member_inline_size <= 4) {
1124                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1125                }
1126                let inner_offset;
1127                let mut inner_depth = depth.clone();
1128                if inlined {
1129                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1130                    inner_offset = next_offset;
1131                } else {
1132                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1133                    inner_depth.increment()?;
1134                }
1135                let val_ref = self
1136                    .driver_state
1137                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<32>, D));
1138                fidl::decode!(
1139                    fidl::encoding::BoundedString<32>,
1140                    D,
1141                    val_ref,
1142                    decoder,
1143                    inner_offset,
1144                    inner_depth
1145                )?;
1146                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1147                {
1148                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1149                }
1150                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1151                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1152                }
1153            }
1154
1155            next_offset += envelope_size;
1156
1157            // Decode the remaining unknown envelopes.
1158            while next_offset < end_offset {
1159                _next_ordinal_to_read += 1;
1160                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1161                next_offset += envelope_size;
1162            }
1163
1164            Ok(())
1165        }
1166    }
1167
1168    impl CdcEthernetHealth {
1169        #[inline(always)]
1170        fn max_ordinal_present(&self) -> u64 {
1171            if let Some(_) = self.online {
1172                return 3;
1173            }
1174            if let Some(_) = self.details {
1175                return 2;
1176            }
1177            if let Some(_) = self.status {
1178                return 1;
1179            }
1180            0
1181        }
1182    }
1183
1184    impl fidl::encoding::ValueTypeMarker for CdcEthernetHealth {
1185        type Borrowed<'a> = &'a Self;
1186        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1187            value
1188        }
1189    }
1190
1191    unsafe impl fidl::encoding::TypeMarker for CdcEthernetHealth {
1192        type Owned = Self;
1193
1194        #[inline(always)]
1195        fn inline_align(_context: fidl::encoding::Context) -> usize {
1196            8
1197        }
1198
1199        #[inline(always)]
1200        fn inline_size(_context: fidl::encoding::Context) -> usize {
1201            16
1202        }
1203    }
1204
1205    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CdcEthernetHealth, D>
1206        for &CdcEthernetHealth
1207    {
1208        unsafe fn encode(
1209            self,
1210            encoder: &mut fidl::encoding::Encoder<'_, D>,
1211            offset: usize,
1212            mut depth: fidl::encoding::Depth,
1213        ) -> fidl::Result<()> {
1214            encoder.debug_check_bounds::<CdcEthernetHealth>(offset);
1215            // Vector header
1216            let max_ordinal: u64 = self.max_ordinal_present();
1217            encoder.write_num(max_ordinal, offset);
1218            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1219            // Calling encoder.out_of_line_offset(0) is not allowed.
1220            if max_ordinal == 0 {
1221                return Ok(());
1222            }
1223            depth.increment()?;
1224            let envelope_size = 8;
1225            let bytes_len = max_ordinal as usize * envelope_size;
1226            #[allow(unused_variables)]
1227            let offset = encoder.out_of_line_offset(bytes_len);
1228            let mut _prev_end_offset: usize = 0;
1229            if 1 > max_ordinal {
1230                return Ok(());
1231            }
1232
1233            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1234            // are envelope_size bytes.
1235            let cur_offset: usize = (1 - 1) * envelope_size;
1236
1237            // Zero reserved fields.
1238            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1239
1240            // Safety:
1241            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1242            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1243            //   envelope_size bytes, there is always sufficient room.
1244            fidl::encoding::encode_in_envelope_optional::<FunctionStatus, D>(
1245                self.status
1246                    .as_ref()
1247                    .map(<FunctionStatus as fidl::encoding::ValueTypeMarker>::borrow),
1248                encoder,
1249                offset + cur_offset,
1250                depth,
1251            )?;
1252
1253            _prev_end_offset = cur_offset + envelope_size;
1254            if 2 > max_ordinal {
1255                return Ok(());
1256            }
1257
1258            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1259            // are envelope_size bytes.
1260            let cur_offset: usize = (2 - 1) * envelope_size;
1261
1262            // Zero reserved fields.
1263            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1264
1265            // Safety:
1266            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1267            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1268            //   envelope_size bytes, there is always sufficient room.
1269            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
1270                self.details.as_ref().map(
1271                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
1272                ),
1273                encoder,
1274                offset + cur_offset,
1275                depth,
1276            )?;
1277
1278            _prev_end_offset = cur_offset + envelope_size;
1279            if 3 > max_ordinal {
1280                return Ok(());
1281            }
1282
1283            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1284            // are envelope_size bytes.
1285            let cur_offset: usize = (3 - 1) * envelope_size;
1286
1287            // Zero reserved fields.
1288            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1289
1290            // Safety:
1291            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1292            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1293            //   envelope_size bytes, there is always sufficient room.
1294            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1295                self.online.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1296                encoder,
1297                offset + cur_offset,
1298                depth,
1299            )?;
1300
1301            _prev_end_offset = cur_offset + envelope_size;
1302
1303            Ok(())
1304        }
1305    }
1306
1307    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CdcEthernetHealth {
1308        #[inline(always)]
1309        fn new_empty() -> Self {
1310            Self::default()
1311        }
1312
1313        unsafe fn decode(
1314            &mut self,
1315            decoder: &mut fidl::encoding::Decoder<'_, D>,
1316            offset: usize,
1317            mut depth: fidl::encoding::Depth,
1318        ) -> fidl::Result<()> {
1319            decoder.debug_check_bounds::<Self>(offset);
1320            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1321                None => return Err(fidl::Error::NotNullable),
1322                Some(len) => len,
1323            };
1324            // Calling decoder.out_of_line_offset(0) is not allowed.
1325            if len == 0 {
1326                return Ok(());
1327            };
1328            depth.increment()?;
1329            let envelope_size = 8;
1330            let bytes_len = len * envelope_size;
1331            let offset = decoder.out_of_line_offset(bytes_len)?;
1332            // Decode the envelope for each type.
1333            let mut _next_ordinal_to_read = 0;
1334            let mut next_offset = offset;
1335            let end_offset = offset + bytes_len;
1336            _next_ordinal_to_read += 1;
1337            if next_offset >= end_offset {
1338                return Ok(());
1339            }
1340
1341            // Decode unknown envelopes for gaps in ordinals.
1342            while _next_ordinal_to_read < 1 {
1343                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1344                _next_ordinal_to_read += 1;
1345                next_offset += envelope_size;
1346            }
1347
1348            let next_out_of_line = decoder.next_out_of_line();
1349            let handles_before = decoder.remaining_handles();
1350            if let Some((inlined, num_bytes, num_handles)) =
1351                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1352            {
1353                let member_inline_size =
1354                    <FunctionStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1355                if inlined != (member_inline_size <= 4) {
1356                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1357                }
1358                let inner_offset;
1359                let mut inner_depth = depth.clone();
1360                if inlined {
1361                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1362                    inner_offset = next_offset;
1363                } else {
1364                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1365                    inner_depth.increment()?;
1366                }
1367                let val_ref =
1368                    self.status.get_or_insert_with(|| fidl::new_empty!(FunctionStatus, D));
1369                fidl::decode!(FunctionStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1370                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1371                {
1372                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1373                }
1374                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1375                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1376                }
1377            }
1378
1379            next_offset += envelope_size;
1380            _next_ordinal_to_read += 1;
1381            if next_offset >= end_offset {
1382                return Ok(());
1383            }
1384
1385            // Decode unknown envelopes for gaps in ordinals.
1386            while _next_ordinal_to_read < 2 {
1387                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1388                _next_ordinal_to_read += 1;
1389                next_offset += envelope_size;
1390            }
1391
1392            let next_out_of_line = decoder.next_out_of_line();
1393            let handles_before = decoder.remaining_handles();
1394            if let Some((inlined, num_bytes, num_handles)) =
1395                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1396            {
1397                let member_inline_size =
1398                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
1399                        decoder.context,
1400                    );
1401                if inlined != (member_inline_size <= 4) {
1402                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1403                }
1404                let inner_offset;
1405                let mut inner_depth = depth.clone();
1406                if inlined {
1407                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1408                    inner_offset = next_offset;
1409                } else {
1410                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1411                    inner_depth.increment()?;
1412                }
1413                let val_ref = self
1414                    .details
1415                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
1416                fidl::decode!(
1417                    fidl::encoding::BoundedString<128>,
1418                    D,
1419                    val_ref,
1420                    decoder,
1421                    inner_offset,
1422                    inner_depth
1423                )?;
1424                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1425                {
1426                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1427                }
1428                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1429                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1430                }
1431            }
1432
1433            next_offset += envelope_size;
1434            _next_ordinal_to_read += 1;
1435            if next_offset >= end_offset {
1436                return Ok(());
1437            }
1438
1439            // Decode unknown envelopes for gaps in ordinals.
1440            while _next_ordinal_to_read < 3 {
1441                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1442                _next_ordinal_to_read += 1;
1443                next_offset += envelope_size;
1444            }
1445
1446            let next_out_of_line = decoder.next_out_of_line();
1447            let handles_before = decoder.remaining_handles();
1448            if let Some((inlined, num_bytes, num_handles)) =
1449                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1450            {
1451                let member_inline_size =
1452                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1453                if inlined != (member_inline_size <= 4) {
1454                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1455                }
1456                let inner_offset;
1457                let mut inner_depth = depth.clone();
1458                if inlined {
1459                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1460                    inner_offset = next_offset;
1461                } else {
1462                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1463                    inner_depth.increment()?;
1464                }
1465                let val_ref = self.online.get_or_insert_with(|| fidl::new_empty!(bool, D));
1466                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1467                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1468                {
1469                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1470                }
1471                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1472                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1473                }
1474            }
1475
1476            next_offset += envelope_size;
1477
1478            // Decode the remaining unknown envelopes.
1479            while next_offset < end_offset {
1480                _next_ordinal_to_read += 1;
1481                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1482                next_offset += envelope_size;
1483            }
1484
1485            Ok(())
1486        }
1487    }
1488
1489    impl HealthReport {
1490        #[inline(always)]
1491        fn max_ordinal_present(&self) -> u64 {
1492            if let Some(_) = self.vsock {
1493                return 6;
1494            }
1495            if let Some(_) = self.cdc_ethernet {
1496                return 5;
1497            }
1498            if let Some(_) = self.adb {
1499                return 4;
1500            }
1501            if let Some(_) = self.cable_status {
1502                return 3;
1503            }
1504            if let Some(_) = self.address {
1505                return 2;
1506            }
1507            if let Some(_) = self.state {
1508                return 1;
1509            }
1510            0
1511        }
1512    }
1513
1514    impl fidl::encoding::ValueTypeMarker for HealthReport {
1515        type Borrowed<'a> = &'a Self;
1516        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1517            value
1518        }
1519    }
1520
1521    unsafe impl fidl::encoding::TypeMarker for HealthReport {
1522        type Owned = Self;
1523
1524        #[inline(always)]
1525        fn inline_align(_context: fidl::encoding::Context) -> usize {
1526            8
1527        }
1528
1529        #[inline(always)]
1530        fn inline_size(_context: fidl::encoding::Context) -> usize {
1531            16
1532        }
1533    }
1534
1535    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<HealthReport, D>
1536        for &HealthReport
1537    {
1538        unsafe fn encode(
1539            self,
1540            encoder: &mut fidl::encoding::Encoder<'_, D>,
1541            offset: usize,
1542            mut depth: fidl::encoding::Depth,
1543        ) -> fidl::Result<()> {
1544            encoder.debug_check_bounds::<HealthReport>(offset);
1545            // Vector header
1546            let max_ordinal: u64 = self.max_ordinal_present();
1547            encoder.write_num(max_ordinal, offset);
1548            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1549            // Calling encoder.out_of_line_offset(0) is not allowed.
1550            if max_ordinal == 0 {
1551                return Ok(());
1552            }
1553            depth.increment()?;
1554            let envelope_size = 8;
1555            let bytes_len = max_ordinal as usize * envelope_size;
1556            #[allow(unused_variables)]
1557            let offset = encoder.out_of_line_offset(bytes_len);
1558            let mut _prev_end_offset: usize = 0;
1559            if 1 > max_ordinal {
1560                return Ok(());
1561            }
1562
1563            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1564            // are envelope_size bytes.
1565            let cur_offset: usize = (1 - 1) * envelope_size;
1566
1567            // Zero reserved fields.
1568            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1569
1570            // Safety:
1571            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1572            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1573            //   envelope_size bytes, there is always sufficient room.
1574            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_usb_policy_common::DeviceState, D>(
1575            self.state.as_ref().map(<fidl_fuchsia_hardware_usb_policy_common::DeviceState as fidl::encoding::ValueTypeMarker>::borrow),
1576            encoder, offset + cur_offset, depth
1577        )?;
1578
1579            _prev_end_offset = cur_offset + envelope_size;
1580            if 2 > max_ordinal {
1581                return Ok(());
1582            }
1583
1584            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1585            // are envelope_size bytes.
1586            let cur_offset: usize = (2 - 1) * envelope_size;
1587
1588            // Zero reserved fields.
1589            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1590
1591            // Safety:
1592            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1593            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1594            //   envelope_size bytes, there is always sufficient room.
1595            fidl::encoding::encode_in_envelope_optional::<u8, D>(
1596                self.address.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
1597                encoder,
1598                offset + cur_offset,
1599                depth,
1600            )?;
1601
1602            _prev_end_offset = cur_offset + envelope_size;
1603            if 3 > max_ordinal {
1604                return Ok(());
1605            }
1606
1607            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1608            // are envelope_size bytes.
1609            let cur_offset: usize = (3 - 1) * envelope_size;
1610
1611            // Zero reserved fields.
1612            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1613
1614            // Safety:
1615            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1616            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1617            //   envelope_size bytes, there is always sufficient room.
1618            fidl::encoding::encode_in_envelope_optional::<CableStatus, D>(
1619                self.cable_status
1620                    .as_ref()
1621                    .map(<CableStatus as fidl::encoding::ValueTypeMarker>::borrow),
1622                encoder,
1623                offset + cur_offset,
1624                depth,
1625            )?;
1626
1627            _prev_end_offset = cur_offset + envelope_size;
1628            if 4 > max_ordinal {
1629                return Ok(());
1630            }
1631
1632            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1633            // are envelope_size bytes.
1634            let cur_offset: usize = (4 - 1) * envelope_size;
1635
1636            // Zero reserved fields.
1637            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1638
1639            // Safety:
1640            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1641            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1642            //   envelope_size bytes, there is always sufficient room.
1643            fidl::encoding::encode_in_envelope_optional::<AdbHealth, D>(
1644                self.adb.as_ref().map(<AdbHealth as fidl::encoding::ValueTypeMarker>::borrow),
1645                encoder,
1646                offset + cur_offset,
1647                depth,
1648            )?;
1649
1650            _prev_end_offset = cur_offset + envelope_size;
1651            if 5 > max_ordinal {
1652                return Ok(());
1653            }
1654
1655            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1656            // are envelope_size bytes.
1657            let cur_offset: usize = (5 - 1) * envelope_size;
1658
1659            // Zero reserved fields.
1660            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1661
1662            // Safety:
1663            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1664            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1665            //   envelope_size bytes, there is always sufficient room.
1666            fidl::encoding::encode_in_envelope_optional::<CdcEthernetHealth, D>(
1667                self.cdc_ethernet
1668                    .as_ref()
1669                    .map(<CdcEthernetHealth as fidl::encoding::ValueTypeMarker>::borrow),
1670                encoder,
1671                offset + cur_offset,
1672                depth,
1673            )?;
1674
1675            _prev_end_offset = cur_offset + envelope_size;
1676            if 6 > max_ordinal {
1677                return Ok(());
1678            }
1679
1680            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1681            // are envelope_size bytes.
1682            let cur_offset: usize = (6 - 1) * envelope_size;
1683
1684            // Zero reserved fields.
1685            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1686
1687            // Safety:
1688            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1689            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1690            //   envelope_size bytes, there is always sufficient room.
1691            fidl::encoding::encode_in_envelope_optional::<VsockHealth, D>(
1692                self.vsock.as_ref().map(<VsockHealth as fidl::encoding::ValueTypeMarker>::borrow),
1693                encoder,
1694                offset + cur_offset,
1695                depth,
1696            )?;
1697
1698            _prev_end_offset = cur_offset + envelope_size;
1699
1700            Ok(())
1701        }
1702    }
1703
1704    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HealthReport {
1705        #[inline(always)]
1706        fn new_empty() -> Self {
1707            Self::default()
1708        }
1709
1710        unsafe fn decode(
1711            &mut self,
1712            decoder: &mut fidl::encoding::Decoder<'_, D>,
1713            offset: usize,
1714            mut depth: fidl::encoding::Depth,
1715        ) -> fidl::Result<()> {
1716            decoder.debug_check_bounds::<Self>(offset);
1717            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1718                None => return Err(fidl::Error::NotNullable),
1719                Some(len) => len,
1720            };
1721            // Calling decoder.out_of_line_offset(0) is not allowed.
1722            if len == 0 {
1723                return Ok(());
1724            };
1725            depth.increment()?;
1726            let envelope_size = 8;
1727            let bytes_len = len * envelope_size;
1728            let offset = decoder.out_of_line_offset(bytes_len)?;
1729            // Decode the envelope for each type.
1730            let mut _next_ordinal_to_read = 0;
1731            let mut next_offset = offset;
1732            let end_offset = offset + bytes_len;
1733            _next_ordinal_to_read += 1;
1734            if next_offset >= end_offset {
1735                return Ok(());
1736            }
1737
1738            // Decode unknown envelopes for gaps in ordinals.
1739            while _next_ordinal_to_read < 1 {
1740                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1741                _next_ordinal_to_read += 1;
1742                next_offset += envelope_size;
1743            }
1744
1745            let next_out_of_line = decoder.next_out_of_line();
1746            let handles_before = decoder.remaining_handles();
1747            if let Some((inlined, num_bytes, num_handles)) =
1748                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1749            {
1750                let member_inline_size = <fidl_fuchsia_hardware_usb_policy_common::DeviceState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1751                if inlined != (member_inline_size <= 4) {
1752                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1753                }
1754                let inner_offset;
1755                let mut inner_depth = depth.clone();
1756                if inlined {
1757                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1758                    inner_offset = next_offset;
1759                } else {
1760                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1761                    inner_depth.increment()?;
1762                }
1763                let val_ref = self.state.get_or_insert_with(|| {
1764                    fidl::new_empty!(fidl_fuchsia_hardware_usb_policy_common::DeviceState, D)
1765                });
1766                fidl::decode!(
1767                    fidl_fuchsia_hardware_usb_policy_common::DeviceState,
1768                    D,
1769                    val_ref,
1770                    decoder,
1771                    inner_offset,
1772                    inner_depth
1773                )?;
1774                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1775                {
1776                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1777                }
1778                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1779                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1780                }
1781            }
1782
1783            next_offset += envelope_size;
1784            _next_ordinal_to_read += 1;
1785            if next_offset >= end_offset {
1786                return Ok(());
1787            }
1788
1789            // Decode unknown envelopes for gaps in ordinals.
1790            while _next_ordinal_to_read < 2 {
1791                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1792                _next_ordinal_to_read += 1;
1793                next_offset += envelope_size;
1794            }
1795
1796            let next_out_of_line = decoder.next_out_of_line();
1797            let handles_before = decoder.remaining_handles();
1798            if let Some((inlined, num_bytes, num_handles)) =
1799                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1800            {
1801                let member_inline_size =
1802                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1803                if inlined != (member_inline_size <= 4) {
1804                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1805                }
1806                let inner_offset;
1807                let mut inner_depth = depth.clone();
1808                if inlined {
1809                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1810                    inner_offset = next_offset;
1811                } else {
1812                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1813                    inner_depth.increment()?;
1814                }
1815                let val_ref = self.address.get_or_insert_with(|| fidl::new_empty!(u8, D));
1816                fidl::decode!(u8, D, val_ref, decoder, inner_offset, inner_depth)?;
1817                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1818                {
1819                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1820                }
1821                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1822                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1823                }
1824            }
1825
1826            next_offset += envelope_size;
1827            _next_ordinal_to_read += 1;
1828            if next_offset >= end_offset {
1829                return Ok(());
1830            }
1831
1832            // Decode unknown envelopes for gaps in ordinals.
1833            while _next_ordinal_to_read < 3 {
1834                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1835                _next_ordinal_to_read += 1;
1836                next_offset += envelope_size;
1837            }
1838
1839            let next_out_of_line = decoder.next_out_of_line();
1840            let handles_before = decoder.remaining_handles();
1841            if let Some((inlined, num_bytes, num_handles)) =
1842                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1843            {
1844                let member_inline_size =
1845                    <CableStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1846                if inlined != (member_inline_size <= 4) {
1847                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1848                }
1849                let inner_offset;
1850                let mut inner_depth = depth.clone();
1851                if inlined {
1852                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1853                    inner_offset = next_offset;
1854                } else {
1855                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1856                    inner_depth.increment()?;
1857                }
1858                let val_ref =
1859                    self.cable_status.get_or_insert_with(|| fidl::new_empty!(CableStatus, D));
1860                fidl::decode!(CableStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
1861                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1862                {
1863                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1864                }
1865                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1866                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1867                }
1868            }
1869
1870            next_offset += envelope_size;
1871            _next_ordinal_to_read += 1;
1872            if next_offset >= end_offset {
1873                return Ok(());
1874            }
1875
1876            // Decode unknown envelopes for gaps in ordinals.
1877            while _next_ordinal_to_read < 4 {
1878                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1879                _next_ordinal_to_read += 1;
1880                next_offset += envelope_size;
1881            }
1882
1883            let next_out_of_line = decoder.next_out_of_line();
1884            let handles_before = decoder.remaining_handles();
1885            if let Some((inlined, num_bytes, num_handles)) =
1886                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1887            {
1888                let member_inline_size =
1889                    <AdbHealth as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1890                if inlined != (member_inline_size <= 4) {
1891                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1892                }
1893                let inner_offset;
1894                let mut inner_depth = depth.clone();
1895                if inlined {
1896                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1897                    inner_offset = next_offset;
1898                } else {
1899                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1900                    inner_depth.increment()?;
1901                }
1902                let val_ref = self.adb.get_or_insert_with(|| fidl::new_empty!(AdbHealth, D));
1903                fidl::decode!(AdbHealth, D, val_ref, decoder, inner_offset, inner_depth)?;
1904                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1905                {
1906                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1907                }
1908                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1909                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1910                }
1911            }
1912
1913            next_offset += envelope_size;
1914            _next_ordinal_to_read += 1;
1915            if next_offset >= end_offset {
1916                return Ok(());
1917            }
1918
1919            // Decode unknown envelopes for gaps in ordinals.
1920            while _next_ordinal_to_read < 5 {
1921                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1922                _next_ordinal_to_read += 1;
1923                next_offset += envelope_size;
1924            }
1925
1926            let next_out_of_line = decoder.next_out_of_line();
1927            let handles_before = decoder.remaining_handles();
1928            if let Some((inlined, num_bytes, num_handles)) =
1929                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1930            {
1931                let member_inline_size =
1932                    <CdcEthernetHealth as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1933                if inlined != (member_inline_size <= 4) {
1934                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1935                }
1936                let inner_offset;
1937                let mut inner_depth = depth.clone();
1938                if inlined {
1939                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1940                    inner_offset = next_offset;
1941                } else {
1942                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1943                    inner_depth.increment()?;
1944                }
1945                let val_ref =
1946                    self.cdc_ethernet.get_or_insert_with(|| fidl::new_empty!(CdcEthernetHealth, D));
1947                fidl::decode!(CdcEthernetHealth, D, val_ref, decoder, inner_offset, inner_depth)?;
1948                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1949                {
1950                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1951                }
1952                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1953                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1954                }
1955            }
1956
1957            next_offset += envelope_size;
1958            _next_ordinal_to_read += 1;
1959            if next_offset >= end_offset {
1960                return Ok(());
1961            }
1962
1963            // Decode unknown envelopes for gaps in ordinals.
1964            while _next_ordinal_to_read < 6 {
1965                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1966                _next_ordinal_to_read += 1;
1967                next_offset += envelope_size;
1968            }
1969
1970            let next_out_of_line = decoder.next_out_of_line();
1971            let handles_before = decoder.remaining_handles();
1972            if let Some((inlined, num_bytes, num_handles)) =
1973                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1974            {
1975                let member_inline_size =
1976                    <VsockHealth as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1977                if inlined != (member_inline_size <= 4) {
1978                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1979                }
1980                let inner_offset;
1981                let mut inner_depth = depth.clone();
1982                if inlined {
1983                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1984                    inner_offset = next_offset;
1985                } else {
1986                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1987                    inner_depth.increment()?;
1988                }
1989                let val_ref = self.vsock.get_or_insert_with(|| fidl::new_empty!(VsockHealth, D));
1990                fidl::decode!(VsockHealth, D, val_ref, decoder, inner_offset, inner_depth)?;
1991                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1992                {
1993                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1994                }
1995                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1996                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1997                }
1998            }
1999
2000            next_offset += envelope_size;
2001
2002            // Decode the remaining unknown envelopes.
2003            while next_offset < end_offset {
2004                _next_ordinal_to_read += 1;
2005                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2006                next_offset += envelope_size;
2007            }
2008
2009            Ok(())
2010        }
2011    }
2012
2013    impl VsockHealth {
2014        #[inline(always)]
2015        fn max_ordinal_present(&self) -> u64 {
2016            if let Some(_) = self.driver_state {
2017                return 5;
2018            }
2019            if let Some(_) = self.online {
2020                return 4;
2021            }
2022            if let Some(_) = self.details {
2023                return 3;
2024            }
2025            if let Some(_) = self.active_channels {
2026                return 2;
2027            }
2028            if let Some(_) = self.status {
2029                return 1;
2030            }
2031            0
2032        }
2033    }
2034
2035    impl fidl::encoding::ValueTypeMarker for VsockHealth {
2036        type Borrowed<'a> = &'a Self;
2037        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2038            value
2039        }
2040    }
2041
2042    unsafe impl fidl::encoding::TypeMarker for VsockHealth {
2043        type Owned = Self;
2044
2045        #[inline(always)]
2046        fn inline_align(_context: fidl::encoding::Context) -> usize {
2047            8
2048        }
2049
2050        #[inline(always)]
2051        fn inline_size(_context: fidl::encoding::Context) -> usize {
2052            16
2053        }
2054    }
2055
2056    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VsockHealth, D>
2057        for &VsockHealth
2058    {
2059        unsafe fn encode(
2060            self,
2061            encoder: &mut fidl::encoding::Encoder<'_, D>,
2062            offset: usize,
2063            mut depth: fidl::encoding::Depth,
2064        ) -> fidl::Result<()> {
2065            encoder.debug_check_bounds::<VsockHealth>(offset);
2066            // Vector header
2067            let max_ordinal: u64 = self.max_ordinal_present();
2068            encoder.write_num(max_ordinal, offset);
2069            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2070            // Calling encoder.out_of_line_offset(0) is not allowed.
2071            if max_ordinal == 0 {
2072                return Ok(());
2073            }
2074            depth.increment()?;
2075            let envelope_size = 8;
2076            let bytes_len = max_ordinal as usize * envelope_size;
2077            #[allow(unused_variables)]
2078            let offset = encoder.out_of_line_offset(bytes_len);
2079            let mut _prev_end_offset: usize = 0;
2080            if 1 > max_ordinal {
2081                return Ok(());
2082            }
2083
2084            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2085            // are envelope_size bytes.
2086            let cur_offset: usize = (1 - 1) * envelope_size;
2087
2088            // Zero reserved fields.
2089            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2090
2091            // Safety:
2092            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2093            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2094            //   envelope_size bytes, there is always sufficient room.
2095            fidl::encoding::encode_in_envelope_optional::<FunctionStatus, D>(
2096                self.status
2097                    .as_ref()
2098                    .map(<FunctionStatus as fidl::encoding::ValueTypeMarker>::borrow),
2099                encoder,
2100                offset + cur_offset,
2101                depth,
2102            )?;
2103
2104            _prev_end_offset = cur_offset + envelope_size;
2105            if 2 > max_ordinal {
2106                return Ok(());
2107            }
2108
2109            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2110            // are envelope_size bytes.
2111            let cur_offset: usize = (2 - 1) * envelope_size;
2112
2113            // Zero reserved fields.
2114            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2115
2116            // Safety:
2117            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2118            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2119            //   envelope_size bytes, there is always sufficient room.
2120            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2121                self.active_channels.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2122                encoder,
2123                offset + cur_offset,
2124                depth,
2125            )?;
2126
2127            _prev_end_offset = cur_offset + envelope_size;
2128            if 3 > max_ordinal {
2129                return Ok(());
2130            }
2131
2132            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2133            // are envelope_size bytes.
2134            let cur_offset: usize = (3 - 1) * envelope_size;
2135
2136            // Zero reserved fields.
2137            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2138
2139            // Safety:
2140            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2141            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2142            //   envelope_size bytes, there is always sufficient room.
2143            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<128>, D>(
2144                self.details.as_ref().map(
2145                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
2146                ),
2147                encoder,
2148                offset + cur_offset,
2149                depth,
2150            )?;
2151
2152            _prev_end_offset = cur_offset + envelope_size;
2153            if 4 > max_ordinal {
2154                return Ok(());
2155            }
2156
2157            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2158            // are envelope_size bytes.
2159            let cur_offset: usize = (4 - 1) * envelope_size;
2160
2161            // Zero reserved fields.
2162            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2163
2164            // Safety:
2165            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2166            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2167            //   envelope_size bytes, there is always sufficient room.
2168            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2169                self.online.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2170                encoder,
2171                offset + cur_offset,
2172                depth,
2173            )?;
2174
2175            _prev_end_offset = cur_offset + envelope_size;
2176            if 5 > max_ordinal {
2177                return Ok(());
2178            }
2179
2180            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2181            // are envelope_size bytes.
2182            let cur_offset: usize = (5 - 1) * envelope_size;
2183
2184            // Zero reserved fields.
2185            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2186
2187            // Safety:
2188            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2189            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2190            //   envelope_size bytes, there is always sufficient room.
2191            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<32>, D>(
2192                self.driver_state.as_ref().map(
2193                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow,
2194                ),
2195                encoder,
2196                offset + cur_offset,
2197                depth,
2198            )?;
2199
2200            _prev_end_offset = cur_offset + envelope_size;
2201
2202            Ok(())
2203        }
2204    }
2205
2206    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VsockHealth {
2207        #[inline(always)]
2208        fn new_empty() -> Self {
2209            Self::default()
2210        }
2211
2212        unsafe fn decode(
2213            &mut self,
2214            decoder: &mut fidl::encoding::Decoder<'_, D>,
2215            offset: usize,
2216            mut depth: fidl::encoding::Depth,
2217        ) -> fidl::Result<()> {
2218            decoder.debug_check_bounds::<Self>(offset);
2219            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2220                None => return Err(fidl::Error::NotNullable),
2221                Some(len) => len,
2222            };
2223            // Calling decoder.out_of_line_offset(0) is not allowed.
2224            if len == 0 {
2225                return Ok(());
2226            };
2227            depth.increment()?;
2228            let envelope_size = 8;
2229            let bytes_len = len * envelope_size;
2230            let offset = decoder.out_of_line_offset(bytes_len)?;
2231            // Decode the envelope for each type.
2232            let mut _next_ordinal_to_read = 0;
2233            let mut next_offset = offset;
2234            let end_offset = offset + bytes_len;
2235            _next_ordinal_to_read += 1;
2236            if next_offset >= end_offset {
2237                return Ok(());
2238            }
2239
2240            // Decode unknown envelopes for gaps in ordinals.
2241            while _next_ordinal_to_read < 1 {
2242                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2243                _next_ordinal_to_read += 1;
2244                next_offset += envelope_size;
2245            }
2246
2247            let next_out_of_line = decoder.next_out_of_line();
2248            let handles_before = decoder.remaining_handles();
2249            if let Some((inlined, num_bytes, num_handles)) =
2250                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2251            {
2252                let member_inline_size =
2253                    <FunctionStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2254                if inlined != (member_inline_size <= 4) {
2255                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2256                }
2257                let inner_offset;
2258                let mut inner_depth = depth.clone();
2259                if inlined {
2260                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2261                    inner_offset = next_offset;
2262                } else {
2263                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2264                    inner_depth.increment()?;
2265                }
2266                let val_ref =
2267                    self.status.get_or_insert_with(|| fidl::new_empty!(FunctionStatus, D));
2268                fidl::decode!(FunctionStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
2269                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2270                {
2271                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2272                }
2273                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2274                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2275                }
2276            }
2277
2278            next_offset += envelope_size;
2279            _next_ordinal_to_read += 1;
2280            if next_offset >= end_offset {
2281                return Ok(());
2282            }
2283
2284            // Decode unknown envelopes for gaps in ordinals.
2285            while _next_ordinal_to_read < 2 {
2286                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2287                _next_ordinal_to_read += 1;
2288                next_offset += envelope_size;
2289            }
2290
2291            let next_out_of_line = decoder.next_out_of_line();
2292            let handles_before = decoder.remaining_handles();
2293            if let Some((inlined, num_bytes, num_handles)) =
2294                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2295            {
2296                let member_inline_size =
2297                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2298                if inlined != (member_inline_size <= 4) {
2299                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2300                }
2301                let inner_offset;
2302                let mut inner_depth = depth.clone();
2303                if inlined {
2304                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2305                    inner_offset = next_offset;
2306                } else {
2307                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2308                    inner_depth.increment()?;
2309                }
2310                let val_ref = self.active_channels.get_or_insert_with(|| fidl::new_empty!(u32, D));
2311                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2312                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2313                {
2314                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2315                }
2316                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2317                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2318                }
2319            }
2320
2321            next_offset += envelope_size;
2322            _next_ordinal_to_read += 1;
2323            if next_offset >= end_offset {
2324                return Ok(());
2325            }
2326
2327            // Decode unknown envelopes for gaps in ordinals.
2328            while _next_ordinal_to_read < 3 {
2329                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2330                _next_ordinal_to_read += 1;
2331                next_offset += envelope_size;
2332            }
2333
2334            let next_out_of_line = decoder.next_out_of_line();
2335            let handles_before = decoder.remaining_handles();
2336            if let Some((inlined, num_bytes, num_handles)) =
2337                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2338            {
2339                let member_inline_size =
2340                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
2341                        decoder.context,
2342                    );
2343                if inlined != (member_inline_size <= 4) {
2344                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2345                }
2346                let inner_offset;
2347                let mut inner_depth = depth.clone();
2348                if inlined {
2349                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2350                    inner_offset = next_offset;
2351                } else {
2352                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2353                    inner_depth.increment()?;
2354                }
2355                let val_ref = self
2356                    .details
2357                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<128>, D));
2358                fidl::decode!(
2359                    fidl::encoding::BoundedString<128>,
2360                    D,
2361                    val_ref,
2362                    decoder,
2363                    inner_offset,
2364                    inner_depth
2365                )?;
2366                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2367                {
2368                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2369                }
2370                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2371                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2372                }
2373            }
2374
2375            next_offset += envelope_size;
2376            _next_ordinal_to_read += 1;
2377            if next_offset >= end_offset {
2378                return Ok(());
2379            }
2380
2381            // Decode unknown envelopes for gaps in ordinals.
2382            while _next_ordinal_to_read < 4 {
2383                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2384                _next_ordinal_to_read += 1;
2385                next_offset += envelope_size;
2386            }
2387
2388            let next_out_of_line = decoder.next_out_of_line();
2389            let handles_before = decoder.remaining_handles();
2390            if let Some((inlined, num_bytes, num_handles)) =
2391                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2392            {
2393                let member_inline_size =
2394                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2395                if inlined != (member_inline_size <= 4) {
2396                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2397                }
2398                let inner_offset;
2399                let mut inner_depth = depth.clone();
2400                if inlined {
2401                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2402                    inner_offset = next_offset;
2403                } else {
2404                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2405                    inner_depth.increment()?;
2406                }
2407                let val_ref = self.online.get_or_insert_with(|| fidl::new_empty!(bool, D));
2408                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2409                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2410                {
2411                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2412                }
2413                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2414                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2415                }
2416            }
2417
2418            next_offset += envelope_size;
2419            _next_ordinal_to_read += 1;
2420            if next_offset >= end_offset {
2421                return Ok(());
2422            }
2423
2424            // Decode unknown envelopes for gaps in ordinals.
2425            while _next_ordinal_to_read < 5 {
2426                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2427                _next_ordinal_to_read += 1;
2428                next_offset += envelope_size;
2429            }
2430
2431            let next_out_of_line = decoder.next_out_of_line();
2432            let handles_before = decoder.remaining_handles();
2433            if let Some((inlined, num_bytes, num_handles)) =
2434                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2435            {
2436                let member_inline_size =
2437                    <fidl::encoding::BoundedString<32> as fidl::encoding::TypeMarker>::inline_size(
2438                        decoder.context,
2439                    );
2440                if inlined != (member_inline_size <= 4) {
2441                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2442                }
2443                let inner_offset;
2444                let mut inner_depth = depth.clone();
2445                if inlined {
2446                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2447                    inner_offset = next_offset;
2448                } else {
2449                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2450                    inner_depth.increment()?;
2451                }
2452                let val_ref = self
2453                    .driver_state
2454                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<32>, D));
2455                fidl::decode!(
2456                    fidl::encoding::BoundedString<32>,
2457                    D,
2458                    val_ref,
2459                    decoder,
2460                    inner_offset,
2461                    inner_depth
2462                )?;
2463                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2464                {
2465                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2466                }
2467                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2468                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2469                }
2470            }
2471
2472            next_offset += envelope_size;
2473
2474            // Decode the remaining unknown envelopes.
2475            while next_offset < end_offset {
2476                _next_ordinal_to_read += 1;
2477                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2478                next_offset += envelope_size;
2479            }
2480
2481            Ok(())
2482        }
2483    }
2484}