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