Skip to main content

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