fidl_fuchsia_audio_controller_common/
fidl_fuchsia_audio_controller_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/// For devices with Codec or Dai drivers, there is only one DAI_INTERCONNECT entity. When a method
12/// requires us to address the interconnect by ID, we use element_id 1. Codec and Dai drivers that
13/// implement signalprocessing must not assign this ID to other elements.
14pub const DEFAULT_DAI_INTERCONNECT_ELEMENT_ID: u64 = 1;
15
16/// For devices with Dai or StreamConfig drivers, there is only one RING_BUFFER entity. When a
17/// method requires us to address the RingBuffer by ID, we use element_id 0. Dai and StreamConfig
18/// drivers that implement signalprocessing must not assign this ID to other elements.
19pub const DEFAULT_RING_BUFFER_ELEMENT_ID: u64 = 0;
20
21#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
22pub enum DeviceType {
23    /// The device uses the `fuchsia.hardware.audio/Codec` protocol.
24    Codec,
25    /// The device uses the `fuchsia.hardware.audio/Composite` protocol.
26    Composite,
27    /// The device uses the `fuchsia.hardware.audio/Dai` protocol.
28    Dai,
29    /// The device uses the `fuchsia.hardware.audio/StreamConfig` protocol and
30    /// is an audio source.
31    Input,
32    /// The device uses the `fuchsia.hardware.audio/StreamConfig` protocol and
33    /// is an audio destination.
34    Output,
35    #[doc(hidden)]
36    __SourceBreaking { unknown_ordinal: u32 },
37}
38
39/// Pattern that matches an unknown `DeviceType` member.
40#[macro_export]
41macro_rules! DeviceTypeUnknown {
42    () => {
43        _
44    };
45}
46
47impl DeviceType {
48    #[inline]
49    pub fn from_primitive(prim: u32) -> Option<Self> {
50        match prim {
51            1 => Some(Self::Codec),
52            2 => Some(Self::Composite),
53            3 => Some(Self::Dai),
54            4 => Some(Self::Input),
55            5 => Some(Self::Output),
56            _ => None,
57        }
58    }
59
60    #[inline]
61    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
62        match prim {
63            1 => Self::Codec,
64            2 => Self::Composite,
65            3 => Self::Dai,
66            4 => Self::Input,
67            5 => Self::Output,
68            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
69        }
70    }
71
72    #[inline]
73    pub fn unknown() -> Self {
74        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
75    }
76
77    #[inline]
78    pub const fn into_primitive(self) -> u32 {
79        match self {
80            Self::Codec => 1,
81            Self::Composite => 2,
82            Self::Dai => 3,
83            Self::Input => 4,
84            Self::Output => 5,
85            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
86        }
87    }
88
89    #[inline]
90    pub fn is_unknown(&self) -> bool {
91        match self {
92            Self::__SourceBreaking { unknown_ordinal: _ } => true,
93            _ => false,
94        }
95    }
96}
97
98/// Error Codes for fuchsia.audio.controller methods.
99#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
100pub enum Error {
101    /// The operation is not implemented, supported, or enabled.
102    NotSupported,
103    /// Some other problem occurred that cannot be classified using one of the
104    /// more specific statuses. Future requests to this method will also fail.
105    UnknownFatal,
106    /// Some other problem occurred, but there is reason to
107    /// believe this operation may succeed in the future.
108    /// Client can retry this request.
109    UnknownCanRetry,
110    /// Necessary arguments missing on request.
111    ArgumentsMissing,
112    /// Unsupported arguments on request.
113    InvalidArguments,
114    /// Could not find a device matching client request parameters.
115    DeviceNotFound,
116    /// Could not connect to device at specified location.
117    DeviceNotReachable,
118    #[doc(hidden)]
119    __SourceBreaking { unknown_ordinal: u32 },
120}
121
122/// Pattern that matches an unknown `Error` member.
123#[macro_export]
124macro_rules! ErrorUnknown {
125    () => {
126        _
127    };
128}
129
130impl Error {
131    #[inline]
132    pub fn from_primitive(prim: u32) -> Option<Self> {
133        match prim {
134            1 => Some(Self::NotSupported),
135            2 => Some(Self::UnknownFatal),
136            3 => Some(Self::UnknownCanRetry),
137            4 => Some(Self::ArgumentsMissing),
138            5 => Some(Self::InvalidArguments),
139            6 => Some(Self::DeviceNotFound),
140            7 => Some(Self::DeviceNotReachable),
141            _ => None,
142        }
143    }
144
145    #[inline]
146    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
147        match prim {
148            1 => Self::NotSupported,
149            2 => Self::UnknownFatal,
150            3 => Self::UnknownCanRetry,
151            4 => Self::ArgumentsMissing,
152            5 => Self::InvalidArguments,
153            6 => Self::DeviceNotFound,
154            7 => Self::DeviceNotReachable,
155            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
156        }
157    }
158
159    #[inline]
160    pub fn unknown() -> Self {
161        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
162    }
163
164    #[inline]
165    pub const fn into_primitive(self) -> u32 {
166        match self {
167            Self::NotSupported => 1,
168            Self::UnknownFatal => 2,
169            Self::UnknownCanRetry => 3,
170            Self::ArgumentsMissing => 4,
171            Self::InvalidArguments => 5,
172            Self::DeviceNotFound => 6,
173            Self::DeviceNotReachable => 7,
174            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
175        }
176    }
177
178    #[inline]
179    pub fn is_unknown(&self) -> bool {
180        match self {
181            Self::__SourceBreaking { unknown_ordinal: _ } => true,
182            _ => false,
183        }
184    }
185}
186
187#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
188pub struct Devfs {
189    /// Name of this device's devfs node, e.g. `3d99d780`.
190    pub name: String,
191    /// Device type.
192    pub device_type: DeviceType,
193}
194
195impl fidl::Persistable for Devfs {}
196
197/// Identifies a device ring buffer for playing/recording.
198#[derive(Clone, Debug, PartialEq)]
199pub struct DeviceRingBuffer {
200    /// The device that has a ring buffer.
201    pub selector: DeviceSelector,
202    /// The ID of an ENDPOINT (with type RING_BUFFER) signal processing element
203    /// of the desired ring buffer.
204    ///
205    /// For Dai and StreamConfig devices, this should be `DEFAULT_RING_BUFFER_ELEMENT_ID`.
206    pub ring_buffer_element_id: u64,
207}
208
209impl fidl::Persistable for DeviceRingBuffer {}
210
211#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
212pub struct Flexible;
213
214impl fidl::Persistable for Flexible {}
215
216#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
217pub struct Loopback;
218
219impl fidl::Persistable for Loopback {}
220
221#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
222pub struct SystemMonotonic;
223
224impl fidl::Persistable for SystemMonotonic {}
225
226#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
227pub struct UltrasoundCapturer;
228
229impl fidl::Persistable for UltrasoundCapturer {}
230
231#[derive(Clone, Debug, Default, PartialEq)]
232pub struct CustomClockConfig {
233    /// Frequency rate adjustment to a clone of the system monotonic clock,
234    /// in parts per million relative to the system monotonic rate.
235    ///
236    /// Must fall within [ZX_CLOCK_UPDATE_MIN_RATE_ADJUST, ZX_CLOCK_UPDATE_MAX_RATE_ADJUST].
237    /// For more info, see `zx_clock_update`.
238    ///
239    /// Optional. If not specified, the reference clock's default rate is used.
240    pub rate_adjust: Option<i32>,
241    /// Starting delta between the reference clock passed to AudioRenderer or Capturer
242    /// and the system monotonic clock.
243    ///
244    /// Optional. If not specified, the reference clock offset is unchanged.
245    pub offset: Option<i32>,
246    #[doc(hidden)]
247    pub __source_breaking: fidl::marker::SourceBreaking,
248}
249
250impl fidl::Persistable for CustomClockConfig {}
251
252/// Gain settings.
253#[derive(Clone, Debug, Default, PartialEq)]
254pub struct GainSettings {
255    /// Whether to mute the audio stream. If unspecified, do not adjust the existing mute value.
256    ///
257    /// Optional.
258    pub mute: Option<bool>,
259    /// Gain level in dB. If unspecified, do not adjust stream or device gain.
260    ///
261    /// Optional.
262    pub gain: Option<f32>,
263    #[doc(hidden)]
264    pub __source_breaking: fidl::marker::SourceBreaking,
265}
266
267impl fidl::Persistable for GainSettings {}
268
269#[derive(Clone, Debug, Default, PartialEq)]
270pub struct StandardCapturerConfig {
271    /// The usage of the audio stream.
272    ///
273    /// Required.
274    pub usage: Option<fidl_fuchsia_media::AudioCaptureUsage2>,
275    /// The reference clock type used by the stream.
276    ///
277    /// Optional. If not specified, the default reference clock
278    /// provided by the capturer is used.
279    pub clock: Option<ClockType>,
280    #[doc(hidden)]
281    pub __source_breaking: fidl::marker::SourceBreaking,
282}
283
284impl fidl::Persistable for StandardCapturerConfig {}
285
286#[derive(Clone, Debug, Default, PartialEq)]
287pub struct StandardRendererConfig {
288    /// The usage of the audio stream.
289    ///
290    /// One of 'usage' or 'usage2' is required.
291    pub usage: Option<fidl_fuchsia_media::AudioRenderUsage2>,
292    /// The reference clock type used by the stream.
293    ///
294    /// Optional. If not specified, the default reference clock
295    /// provided by the renderer is used.
296    pub clock: Option<ClockType>,
297    /// How many packets to use when sending data to the `AudioRenderer`.
298    ///
299    /// Optional. If not specified, defaults to four packets.
300    pub packet_count: Option<u32>,
301    #[doc(hidden)]
302    pub __source_breaking: fidl::marker::SourceBreaking,
303}
304
305impl fidl::Persistable for StandardRendererConfig {}
306
307#[derive(Clone, Debug, Default, PartialEq)]
308pub struct UltrasoundRendererConfig {
309    /// How many packets to use when sending data to the `AudioRenderer`.
310    ///
311    /// Optional. If not specified, defaults to four packets.
312    pub packet_count: Option<u32>,
313    #[doc(hidden)]
314    pub __source_breaking: fidl::marker::SourceBreaking,
315}
316
317impl fidl::Persistable for UltrasoundRendererConfig {}
318
319#[derive(Clone, Debug)]
320pub enum CapturerConfig {
321    /// `AudioCapturer` for standard frequencies.
322    StandardCapturer(StandardCapturerConfig),
323    /// `AudioCapturer` for ultrasonic frequencies.
324    UltrasoundCapturer(UltrasoundCapturer),
325    #[doc(hidden)]
326    __SourceBreaking { unknown_ordinal: u64 },
327}
328
329/// Pattern that matches an unknown `CapturerConfig` member.
330#[macro_export]
331macro_rules! CapturerConfigUnknown {
332    () => {
333        _
334    };
335}
336
337// Custom PartialEq so that unknown variants are not equal to themselves.
338impl PartialEq for CapturerConfig {
339    fn eq(&self, other: &Self) -> bool {
340        match (self, other) {
341            (Self::StandardCapturer(x), Self::StandardCapturer(y)) => *x == *y,
342            (Self::UltrasoundCapturer(x), Self::UltrasoundCapturer(y)) => *x == *y,
343            _ => false,
344        }
345    }
346}
347
348impl CapturerConfig {
349    #[inline]
350    pub fn ordinal(&self) -> u64 {
351        match *self {
352            Self::StandardCapturer(_) => 1,
353            Self::UltrasoundCapturer(_) => 2,
354            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
355        }
356    }
357
358    #[inline]
359    pub fn unknown_variant_for_testing() -> Self {
360        Self::__SourceBreaking { unknown_ordinal: 0 }
361    }
362
363    #[inline]
364    pub fn is_unknown(&self) -> bool {
365        match self {
366            Self::__SourceBreaking { .. } => true,
367            _ => false,
368        }
369    }
370}
371
372impl fidl::Persistable for CapturerConfig {}
373
374/// Reference clock options for an `AudioRenderer` or `AudioCapturer`.
375#[derive(Clone, Debug)]
376pub enum ClockType {
377    /// Use a flexible clock.
378    Flexible(Flexible),
379    /// Use the system monotonic clock.
380    SystemMonotonic(SystemMonotonic),
381    /// Use a monotonic clock with possible rate adjustment and offset relative to the system
382    /// monotonic clock.
383    Custom(CustomClockConfig),
384    #[doc(hidden)]
385    __SourceBreaking { unknown_ordinal: u64 },
386}
387
388/// Pattern that matches an unknown `ClockType` member.
389#[macro_export]
390macro_rules! ClockTypeUnknown {
391    () => {
392        _
393    };
394}
395
396// Custom PartialEq so that unknown variants are not equal to themselves.
397impl PartialEq for ClockType {
398    fn eq(&self, other: &Self) -> bool {
399        match (self, other) {
400            (Self::Flexible(x), Self::Flexible(y)) => *x == *y,
401            (Self::SystemMonotonic(x), Self::SystemMonotonic(y)) => *x == *y,
402            (Self::Custom(x), Self::Custom(y)) => *x == *y,
403            _ => false,
404        }
405    }
406}
407
408impl ClockType {
409    #[inline]
410    pub fn ordinal(&self) -> u64 {
411        match *self {
412            Self::Flexible(_) => 1,
413            Self::SystemMonotonic(_) => 2,
414            Self::Custom(_) => 3,
415            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
416        }
417    }
418
419    #[inline]
420    pub fn unknown_variant_for_testing() -> Self {
421        Self::__SourceBreaking { unknown_ordinal: 0 }
422    }
423
424    #[inline]
425    pub fn is_unknown(&self) -> bool {
426        match self {
427            Self::__SourceBreaking { .. } => true,
428            _ => false,
429        }
430    }
431}
432
433impl fidl::Persistable for ClockType {}
434
435/// Identifies an audio device.
436#[derive(Clone, Debug)]
437pub enum DeviceSelector {
438    /// Driver node in devfs, e.g. `/dev/class/audio-input/3d99d780`.
439    Devfs(Devfs),
440    /// A device available through the `fuchsia.audio.device/Registry` protocol.
441    Registry(u64),
442    #[doc(hidden)]
443    __SourceBreaking { unknown_ordinal: u64 },
444}
445
446/// Pattern that matches an unknown `DeviceSelector` member.
447#[macro_export]
448macro_rules! DeviceSelectorUnknown {
449    () => {
450        _
451    };
452}
453
454// Custom PartialEq so that unknown variants are not equal to themselves.
455impl PartialEq for DeviceSelector {
456    fn eq(&self, other: &Self) -> bool {
457        match (self, other) {
458            (Self::Devfs(x), Self::Devfs(y)) => *x == *y,
459            (Self::Registry(x), Self::Registry(y)) => *x == *y,
460            _ => false,
461        }
462    }
463}
464
465impl DeviceSelector {
466    #[inline]
467    pub fn ordinal(&self) -> u64 {
468        match *self {
469            Self::Devfs(_) => 1,
470            Self::Registry(_) => 2,
471            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
472        }
473    }
474
475    #[inline]
476    pub fn unknown_variant_for_testing() -> Self {
477        Self::__SourceBreaking { unknown_ordinal: 0 }
478    }
479
480    #[inline]
481    pub fn is_unknown(&self) -> bool {
482        match self {
483            Self::__SourceBreaking { .. } => true,
484            _ => false,
485        }
486    }
487}
488
489impl fidl::Persistable for DeviceSelector {}
490
491#[derive(Clone, Debug)]
492pub enum PlayDestination {
493    /// Create an `AudioRenderer` using the audio_core API and play audio through it.
494    Renderer(RendererConfig),
495    /// A device ring buffer.
496    DeviceRingBuffer(DeviceRingBuffer),
497    #[doc(hidden)]
498    __SourceBreaking { unknown_ordinal: u64 },
499}
500
501/// Pattern that matches an unknown `PlayDestination` member.
502#[macro_export]
503macro_rules! PlayDestinationUnknown {
504    () => {
505        _
506    };
507}
508
509// Custom PartialEq so that unknown variants are not equal to themselves.
510impl PartialEq for PlayDestination {
511    fn eq(&self, other: &Self) -> bool {
512        match (self, other) {
513            (Self::Renderer(x), Self::Renderer(y)) => *x == *y,
514            (Self::DeviceRingBuffer(x), Self::DeviceRingBuffer(y)) => *x == *y,
515            _ => false,
516        }
517    }
518}
519
520impl PlayDestination {
521    #[inline]
522    pub fn ordinal(&self) -> u64 {
523        match *self {
524            Self::Renderer(_) => 1,
525            Self::DeviceRingBuffer(_) => 2,
526            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
527        }
528    }
529
530    #[inline]
531    pub fn unknown_variant_for_testing() -> Self {
532        Self::__SourceBreaking { unknown_ordinal: 0 }
533    }
534
535    #[inline]
536    pub fn is_unknown(&self) -> bool {
537        match self {
538            Self::__SourceBreaking { .. } => true,
539            _ => false,
540        }
541    }
542}
543
544impl fidl::Persistable for PlayDestination {}
545
546#[derive(Clone, Debug)]
547pub enum RecordSource {
548    /// An audio_core `AudioCapturer` protocol connection.
549    Capturer(CapturerConfig),
550    /// An audio_core `AudioCapturer` protocol connection with loopback enabled.
551    Loopback(Loopback),
552    /// A device ring buffer.
553    DeviceRingBuffer(DeviceRingBuffer),
554    #[doc(hidden)]
555    __SourceBreaking { unknown_ordinal: u64 },
556}
557
558/// Pattern that matches an unknown `RecordSource` member.
559#[macro_export]
560macro_rules! RecordSourceUnknown {
561    () => {
562        _
563    };
564}
565
566// Custom PartialEq so that unknown variants are not equal to themselves.
567impl PartialEq for RecordSource {
568    fn eq(&self, other: &Self) -> bool {
569        match (self, other) {
570            (Self::Capturer(x), Self::Capturer(y)) => *x == *y,
571            (Self::Loopback(x), Self::Loopback(y)) => *x == *y,
572            (Self::DeviceRingBuffer(x), Self::DeviceRingBuffer(y)) => *x == *y,
573            _ => false,
574        }
575    }
576}
577
578impl RecordSource {
579    #[inline]
580    pub fn ordinal(&self) -> u64 {
581        match *self {
582            Self::Capturer(_) => 1,
583            Self::Loopback(_) => 2,
584            Self::DeviceRingBuffer(_) => 3,
585            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
586        }
587    }
588
589    #[inline]
590    pub fn unknown_variant_for_testing() -> Self {
591        Self::__SourceBreaking { unknown_ordinal: 0 }
592    }
593
594    #[inline]
595    pub fn is_unknown(&self) -> bool {
596        match self {
597            Self::__SourceBreaking { .. } => true,
598            _ => false,
599        }
600    }
601}
602
603impl fidl::Persistable for RecordSource {}
604
605#[derive(Clone, Debug)]
606pub enum RendererConfig {
607    /// Renderer for standard frequencies.
608    StandardRenderer(StandardRendererConfig),
609    /// Renderer for ultrasonic frequencies.
610    UltrasoundRenderer(UltrasoundRendererConfig),
611    #[doc(hidden)]
612    __SourceBreaking { unknown_ordinal: u64 },
613}
614
615/// Pattern that matches an unknown `RendererConfig` member.
616#[macro_export]
617macro_rules! RendererConfigUnknown {
618    () => {
619        _
620    };
621}
622
623// Custom PartialEq so that unknown variants are not equal to themselves.
624impl PartialEq for RendererConfig {
625    fn eq(&self, other: &Self) -> bool {
626        match (self, other) {
627            (Self::StandardRenderer(x), Self::StandardRenderer(y)) => *x == *y,
628            (Self::UltrasoundRenderer(x), Self::UltrasoundRenderer(y)) => *x == *y,
629            _ => false,
630        }
631    }
632}
633
634impl RendererConfig {
635    #[inline]
636    pub fn ordinal(&self) -> u64 {
637        match *self {
638            Self::StandardRenderer(_) => 1,
639            Self::UltrasoundRenderer(_) => 2,
640            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
641        }
642    }
643
644    #[inline]
645    pub fn unknown_variant_for_testing() -> Self {
646        Self::__SourceBreaking { unknown_ordinal: 0 }
647    }
648
649    #[inline]
650    pub fn is_unknown(&self) -> bool {
651        match self {
652            Self::__SourceBreaking { .. } => true,
653            _ => false,
654        }
655    }
656}
657
658impl fidl::Persistable for RendererConfig {}
659
660mod internal {
661    use super::*;
662    unsafe impl fidl::encoding::TypeMarker for DeviceType {
663        type Owned = Self;
664
665        #[inline(always)]
666        fn inline_align(_context: fidl::encoding::Context) -> usize {
667            std::mem::align_of::<u32>()
668        }
669
670        #[inline(always)]
671        fn inline_size(_context: fidl::encoding::Context) -> usize {
672            std::mem::size_of::<u32>()
673        }
674
675        #[inline(always)]
676        fn encode_is_copy() -> bool {
677            false
678        }
679
680        #[inline(always)]
681        fn decode_is_copy() -> bool {
682            false
683        }
684    }
685
686    impl fidl::encoding::ValueTypeMarker for DeviceType {
687        type Borrowed<'a> = Self;
688        #[inline(always)]
689        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
690            *value
691        }
692    }
693
694    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DeviceType {
695        #[inline]
696        unsafe fn encode(
697            self,
698            encoder: &mut fidl::encoding::Encoder<'_, D>,
699            offset: usize,
700            _depth: fidl::encoding::Depth,
701        ) -> fidl::Result<()> {
702            encoder.debug_check_bounds::<Self>(offset);
703            encoder.write_num(self.into_primitive(), offset);
704            Ok(())
705        }
706    }
707
708    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceType {
709        #[inline(always)]
710        fn new_empty() -> Self {
711            Self::unknown()
712        }
713
714        #[inline]
715        unsafe fn decode(
716            &mut self,
717            decoder: &mut fidl::encoding::Decoder<'_, D>,
718            offset: usize,
719            _depth: fidl::encoding::Depth,
720        ) -> fidl::Result<()> {
721            decoder.debug_check_bounds::<Self>(offset);
722            let prim = decoder.read_num::<u32>(offset);
723
724            *self = Self::from_primitive_allow_unknown(prim);
725            Ok(())
726        }
727    }
728    unsafe impl fidl::encoding::TypeMarker for Error {
729        type Owned = Self;
730
731        #[inline(always)]
732        fn inline_align(_context: fidl::encoding::Context) -> usize {
733            std::mem::align_of::<u32>()
734        }
735
736        #[inline(always)]
737        fn inline_size(_context: fidl::encoding::Context) -> usize {
738            std::mem::size_of::<u32>()
739        }
740
741        #[inline(always)]
742        fn encode_is_copy() -> bool {
743            false
744        }
745
746        #[inline(always)]
747        fn decode_is_copy() -> bool {
748            false
749        }
750    }
751
752    impl fidl::encoding::ValueTypeMarker for Error {
753        type Borrowed<'a> = Self;
754        #[inline(always)]
755        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
756            *value
757        }
758    }
759
760    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
761        #[inline]
762        unsafe fn encode(
763            self,
764            encoder: &mut fidl::encoding::Encoder<'_, D>,
765            offset: usize,
766            _depth: fidl::encoding::Depth,
767        ) -> fidl::Result<()> {
768            encoder.debug_check_bounds::<Self>(offset);
769            encoder.write_num(self.into_primitive(), offset);
770            Ok(())
771        }
772    }
773
774    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
775        #[inline(always)]
776        fn new_empty() -> Self {
777            Self::unknown()
778        }
779
780        #[inline]
781        unsafe fn decode(
782            &mut self,
783            decoder: &mut fidl::encoding::Decoder<'_, D>,
784            offset: usize,
785            _depth: fidl::encoding::Depth,
786        ) -> fidl::Result<()> {
787            decoder.debug_check_bounds::<Self>(offset);
788            let prim = decoder.read_num::<u32>(offset);
789
790            *self = Self::from_primitive_allow_unknown(prim);
791            Ok(())
792        }
793    }
794
795    impl fidl::encoding::ValueTypeMarker for Devfs {
796        type Borrowed<'a> = &'a Self;
797        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
798            value
799        }
800    }
801
802    unsafe impl fidl::encoding::TypeMarker for Devfs {
803        type Owned = Self;
804
805        #[inline(always)]
806        fn inline_align(_context: fidl::encoding::Context) -> usize {
807            8
808        }
809
810        #[inline(always)]
811        fn inline_size(_context: fidl::encoding::Context) -> usize {
812            24
813        }
814    }
815
816    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Devfs, D> for &Devfs {
817        #[inline]
818        unsafe fn encode(
819            self,
820            encoder: &mut fidl::encoding::Encoder<'_, D>,
821            offset: usize,
822            _depth: fidl::encoding::Depth,
823        ) -> fidl::Result<()> {
824            encoder.debug_check_bounds::<Devfs>(offset);
825            // Delegate to tuple encoding.
826            fidl::encoding::Encode::<Devfs, D>::encode(
827                (
828                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
829                        &self.name,
830                    ),
831                    <DeviceType as fidl::encoding::ValueTypeMarker>::borrow(&self.device_type),
832                ),
833                encoder,
834                offset,
835                _depth,
836            )
837        }
838    }
839    unsafe impl<
840            D: fidl::encoding::ResourceDialect,
841            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<255>, D>,
842            T1: fidl::encoding::Encode<DeviceType, D>,
843        > fidl::encoding::Encode<Devfs, D> for (T0, T1)
844    {
845        #[inline]
846        unsafe fn encode(
847            self,
848            encoder: &mut fidl::encoding::Encoder<'_, D>,
849            offset: usize,
850            depth: fidl::encoding::Depth,
851        ) -> fidl::Result<()> {
852            encoder.debug_check_bounds::<Devfs>(offset);
853            // Zero out padding regions. There's no need to apply masks
854            // because the unmasked parts will be overwritten by fields.
855            unsafe {
856                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
857                (ptr as *mut u64).write_unaligned(0);
858            }
859            // Write the fields.
860            self.0.encode(encoder, offset + 0, depth)?;
861            self.1.encode(encoder, offset + 16, depth)?;
862            Ok(())
863        }
864    }
865
866    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Devfs {
867        #[inline(always)]
868        fn new_empty() -> Self {
869            Self {
870                name: fidl::new_empty!(fidl::encoding::BoundedString<255>, D),
871                device_type: fidl::new_empty!(DeviceType, D),
872            }
873        }
874
875        #[inline]
876        unsafe fn decode(
877            &mut self,
878            decoder: &mut fidl::encoding::Decoder<'_, D>,
879            offset: usize,
880            _depth: fidl::encoding::Depth,
881        ) -> fidl::Result<()> {
882            decoder.debug_check_bounds::<Self>(offset);
883            // Verify that padding bytes are zero.
884            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
885            let padval = unsafe { (ptr as *const u64).read_unaligned() };
886            let mask = 0xffffffff00000000u64;
887            let maskedval = padval & mask;
888            if maskedval != 0 {
889                return Err(fidl::Error::NonZeroPadding {
890                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
891                });
892            }
893            fidl::decode!(
894                fidl::encoding::BoundedString<255>,
895                D,
896                &mut self.name,
897                decoder,
898                offset + 0,
899                _depth
900            )?;
901            fidl::decode!(DeviceType, D, &mut self.device_type, decoder, offset + 16, _depth)?;
902            Ok(())
903        }
904    }
905
906    impl fidl::encoding::ValueTypeMarker for DeviceRingBuffer {
907        type Borrowed<'a> = &'a Self;
908        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
909            value
910        }
911    }
912
913    unsafe impl fidl::encoding::TypeMarker for DeviceRingBuffer {
914        type Owned = Self;
915
916        #[inline(always)]
917        fn inline_align(_context: fidl::encoding::Context) -> usize {
918            8
919        }
920
921        #[inline(always)]
922        fn inline_size(_context: fidl::encoding::Context) -> usize {
923            24
924        }
925    }
926
927    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceRingBuffer, D>
928        for &DeviceRingBuffer
929    {
930        #[inline]
931        unsafe fn encode(
932            self,
933            encoder: &mut fidl::encoding::Encoder<'_, D>,
934            offset: usize,
935            _depth: fidl::encoding::Depth,
936        ) -> fidl::Result<()> {
937            encoder.debug_check_bounds::<DeviceRingBuffer>(offset);
938            // Delegate to tuple encoding.
939            fidl::encoding::Encode::<DeviceRingBuffer, D>::encode(
940                (
941                    <DeviceSelector as fidl::encoding::ValueTypeMarker>::borrow(&self.selector),
942                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ring_buffer_element_id),
943                ),
944                encoder,
945                offset,
946                _depth,
947            )
948        }
949    }
950    unsafe impl<
951            D: fidl::encoding::ResourceDialect,
952            T0: fidl::encoding::Encode<DeviceSelector, D>,
953            T1: fidl::encoding::Encode<u64, D>,
954        > fidl::encoding::Encode<DeviceRingBuffer, D> for (T0, T1)
955    {
956        #[inline]
957        unsafe fn encode(
958            self,
959            encoder: &mut fidl::encoding::Encoder<'_, D>,
960            offset: usize,
961            depth: fidl::encoding::Depth,
962        ) -> fidl::Result<()> {
963            encoder.debug_check_bounds::<DeviceRingBuffer>(offset);
964            // Zero out padding regions. There's no need to apply masks
965            // because the unmasked parts will be overwritten by fields.
966            // Write the fields.
967            self.0.encode(encoder, offset + 0, depth)?;
968            self.1.encode(encoder, offset + 16, depth)?;
969            Ok(())
970        }
971    }
972
973    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceRingBuffer {
974        #[inline(always)]
975        fn new_empty() -> Self {
976            Self {
977                selector: fidl::new_empty!(DeviceSelector, D),
978                ring_buffer_element_id: fidl::new_empty!(u64, D),
979            }
980        }
981
982        #[inline]
983        unsafe fn decode(
984            &mut self,
985            decoder: &mut fidl::encoding::Decoder<'_, D>,
986            offset: usize,
987            _depth: fidl::encoding::Depth,
988        ) -> fidl::Result<()> {
989            decoder.debug_check_bounds::<Self>(offset);
990            // Verify that padding bytes are zero.
991            fidl::decode!(DeviceSelector, D, &mut self.selector, decoder, offset + 0, _depth)?;
992            fidl::decode!(u64, D, &mut self.ring_buffer_element_id, decoder, offset + 16, _depth)?;
993            Ok(())
994        }
995    }
996
997    impl fidl::encoding::ValueTypeMarker for Flexible {
998        type Borrowed<'a> = &'a Self;
999        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1000            value
1001        }
1002    }
1003
1004    unsafe impl fidl::encoding::TypeMarker for Flexible {
1005        type Owned = Self;
1006
1007        #[inline(always)]
1008        fn inline_align(_context: fidl::encoding::Context) -> usize {
1009            1
1010        }
1011
1012        #[inline(always)]
1013        fn inline_size(_context: fidl::encoding::Context) -> usize {
1014            1
1015        }
1016    }
1017
1018    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Flexible, D> for &Flexible {
1019        #[inline]
1020        unsafe fn encode(
1021            self,
1022            encoder: &mut fidl::encoding::Encoder<'_, D>,
1023            offset: usize,
1024            _depth: fidl::encoding::Depth,
1025        ) -> fidl::Result<()> {
1026            encoder.debug_check_bounds::<Flexible>(offset);
1027            encoder.write_num(0u8, offset);
1028            Ok(())
1029        }
1030    }
1031
1032    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Flexible {
1033        #[inline(always)]
1034        fn new_empty() -> Self {
1035            Self
1036        }
1037
1038        #[inline]
1039        unsafe fn decode(
1040            &mut self,
1041            decoder: &mut fidl::encoding::Decoder<'_, D>,
1042            offset: usize,
1043            _depth: fidl::encoding::Depth,
1044        ) -> fidl::Result<()> {
1045            decoder.debug_check_bounds::<Self>(offset);
1046            match decoder.read_num::<u8>(offset) {
1047                0 => Ok(()),
1048                _ => Err(fidl::Error::Invalid),
1049            }
1050        }
1051    }
1052
1053    impl fidl::encoding::ValueTypeMarker for Loopback {
1054        type Borrowed<'a> = &'a Self;
1055        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1056            value
1057        }
1058    }
1059
1060    unsafe impl fidl::encoding::TypeMarker for Loopback {
1061        type Owned = Self;
1062
1063        #[inline(always)]
1064        fn inline_align(_context: fidl::encoding::Context) -> usize {
1065            1
1066        }
1067
1068        #[inline(always)]
1069        fn inline_size(_context: fidl::encoding::Context) -> usize {
1070            1
1071        }
1072    }
1073
1074    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Loopback, D> for &Loopback {
1075        #[inline]
1076        unsafe fn encode(
1077            self,
1078            encoder: &mut fidl::encoding::Encoder<'_, D>,
1079            offset: usize,
1080            _depth: fidl::encoding::Depth,
1081        ) -> fidl::Result<()> {
1082            encoder.debug_check_bounds::<Loopback>(offset);
1083            encoder.write_num(0u8, offset);
1084            Ok(())
1085        }
1086    }
1087
1088    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Loopback {
1089        #[inline(always)]
1090        fn new_empty() -> Self {
1091            Self
1092        }
1093
1094        #[inline]
1095        unsafe fn decode(
1096            &mut self,
1097            decoder: &mut fidl::encoding::Decoder<'_, D>,
1098            offset: usize,
1099            _depth: fidl::encoding::Depth,
1100        ) -> fidl::Result<()> {
1101            decoder.debug_check_bounds::<Self>(offset);
1102            match decoder.read_num::<u8>(offset) {
1103                0 => Ok(()),
1104                _ => Err(fidl::Error::Invalid),
1105            }
1106        }
1107    }
1108
1109    impl fidl::encoding::ValueTypeMarker for SystemMonotonic {
1110        type Borrowed<'a> = &'a Self;
1111        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1112            value
1113        }
1114    }
1115
1116    unsafe impl fidl::encoding::TypeMarker for SystemMonotonic {
1117        type Owned = Self;
1118
1119        #[inline(always)]
1120        fn inline_align(_context: fidl::encoding::Context) -> usize {
1121            1
1122        }
1123
1124        #[inline(always)]
1125        fn inline_size(_context: fidl::encoding::Context) -> usize {
1126            1
1127        }
1128    }
1129
1130    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SystemMonotonic, D>
1131        for &SystemMonotonic
1132    {
1133        #[inline]
1134        unsafe fn encode(
1135            self,
1136            encoder: &mut fidl::encoding::Encoder<'_, D>,
1137            offset: usize,
1138            _depth: fidl::encoding::Depth,
1139        ) -> fidl::Result<()> {
1140            encoder.debug_check_bounds::<SystemMonotonic>(offset);
1141            encoder.write_num(0u8, offset);
1142            Ok(())
1143        }
1144    }
1145
1146    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SystemMonotonic {
1147        #[inline(always)]
1148        fn new_empty() -> Self {
1149            Self
1150        }
1151
1152        #[inline]
1153        unsafe fn decode(
1154            &mut self,
1155            decoder: &mut fidl::encoding::Decoder<'_, D>,
1156            offset: usize,
1157            _depth: fidl::encoding::Depth,
1158        ) -> fidl::Result<()> {
1159            decoder.debug_check_bounds::<Self>(offset);
1160            match decoder.read_num::<u8>(offset) {
1161                0 => Ok(()),
1162                _ => Err(fidl::Error::Invalid),
1163            }
1164        }
1165    }
1166
1167    impl fidl::encoding::ValueTypeMarker for UltrasoundCapturer {
1168        type Borrowed<'a> = &'a Self;
1169        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1170            value
1171        }
1172    }
1173
1174    unsafe impl fidl::encoding::TypeMarker for UltrasoundCapturer {
1175        type Owned = Self;
1176
1177        #[inline(always)]
1178        fn inline_align(_context: fidl::encoding::Context) -> usize {
1179            1
1180        }
1181
1182        #[inline(always)]
1183        fn inline_size(_context: fidl::encoding::Context) -> usize {
1184            1
1185        }
1186    }
1187
1188    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UltrasoundCapturer, D>
1189        for &UltrasoundCapturer
1190    {
1191        #[inline]
1192        unsafe fn encode(
1193            self,
1194            encoder: &mut fidl::encoding::Encoder<'_, D>,
1195            offset: usize,
1196            _depth: fidl::encoding::Depth,
1197        ) -> fidl::Result<()> {
1198            encoder.debug_check_bounds::<UltrasoundCapturer>(offset);
1199            encoder.write_num(0u8, offset);
1200            Ok(())
1201        }
1202    }
1203
1204    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UltrasoundCapturer {
1205        #[inline(always)]
1206        fn new_empty() -> Self {
1207            Self
1208        }
1209
1210        #[inline]
1211        unsafe fn decode(
1212            &mut self,
1213            decoder: &mut fidl::encoding::Decoder<'_, D>,
1214            offset: usize,
1215            _depth: fidl::encoding::Depth,
1216        ) -> fidl::Result<()> {
1217            decoder.debug_check_bounds::<Self>(offset);
1218            match decoder.read_num::<u8>(offset) {
1219                0 => Ok(()),
1220                _ => Err(fidl::Error::Invalid),
1221            }
1222        }
1223    }
1224
1225    impl CustomClockConfig {
1226        #[inline(always)]
1227        fn max_ordinal_present(&self) -> u64 {
1228            if let Some(_) = self.offset {
1229                return 2;
1230            }
1231            if let Some(_) = self.rate_adjust {
1232                return 1;
1233            }
1234            0
1235        }
1236    }
1237
1238    impl fidl::encoding::ValueTypeMarker for CustomClockConfig {
1239        type Borrowed<'a> = &'a Self;
1240        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1241            value
1242        }
1243    }
1244
1245    unsafe impl fidl::encoding::TypeMarker for CustomClockConfig {
1246        type Owned = Self;
1247
1248        #[inline(always)]
1249        fn inline_align(_context: fidl::encoding::Context) -> usize {
1250            8
1251        }
1252
1253        #[inline(always)]
1254        fn inline_size(_context: fidl::encoding::Context) -> usize {
1255            16
1256        }
1257    }
1258
1259    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CustomClockConfig, D>
1260        for &CustomClockConfig
1261    {
1262        unsafe fn encode(
1263            self,
1264            encoder: &mut fidl::encoding::Encoder<'_, D>,
1265            offset: usize,
1266            mut depth: fidl::encoding::Depth,
1267        ) -> fidl::Result<()> {
1268            encoder.debug_check_bounds::<CustomClockConfig>(offset);
1269            // Vector header
1270            let max_ordinal: u64 = self.max_ordinal_present();
1271            encoder.write_num(max_ordinal, offset);
1272            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1273            // Calling encoder.out_of_line_offset(0) is not allowed.
1274            if max_ordinal == 0 {
1275                return Ok(());
1276            }
1277            depth.increment()?;
1278            let envelope_size = 8;
1279            let bytes_len = max_ordinal as usize * envelope_size;
1280            #[allow(unused_variables)]
1281            let offset = encoder.out_of_line_offset(bytes_len);
1282            let mut _prev_end_offset: usize = 0;
1283            if 1 > max_ordinal {
1284                return Ok(());
1285            }
1286
1287            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1288            // are envelope_size bytes.
1289            let cur_offset: usize = (1 - 1) * envelope_size;
1290
1291            // Zero reserved fields.
1292            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1293
1294            // Safety:
1295            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1296            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1297            //   envelope_size bytes, there is always sufficient room.
1298            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1299                self.rate_adjust.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1300                encoder,
1301                offset + cur_offset,
1302                depth,
1303            )?;
1304
1305            _prev_end_offset = cur_offset + envelope_size;
1306            if 2 > max_ordinal {
1307                return Ok(());
1308            }
1309
1310            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1311            // are envelope_size bytes.
1312            let cur_offset: usize = (2 - 1) * envelope_size;
1313
1314            // Zero reserved fields.
1315            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1316
1317            // Safety:
1318            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1319            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1320            //   envelope_size bytes, there is always sufficient room.
1321            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1322                self.offset.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1323                encoder,
1324                offset + cur_offset,
1325                depth,
1326            )?;
1327
1328            _prev_end_offset = cur_offset + envelope_size;
1329
1330            Ok(())
1331        }
1332    }
1333
1334    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CustomClockConfig {
1335        #[inline(always)]
1336        fn new_empty() -> Self {
1337            Self::default()
1338        }
1339
1340        unsafe fn decode(
1341            &mut self,
1342            decoder: &mut fidl::encoding::Decoder<'_, D>,
1343            offset: usize,
1344            mut depth: fidl::encoding::Depth,
1345        ) -> fidl::Result<()> {
1346            decoder.debug_check_bounds::<Self>(offset);
1347            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1348                None => return Err(fidl::Error::NotNullable),
1349                Some(len) => len,
1350            };
1351            // Calling decoder.out_of_line_offset(0) is not allowed.
1352            if len == 0 {
1353                return Ok(());
1354            };
1355            depth.increment()?;
1356            let envelope_size = 8;
1357            let bytes_len = len * envelope_size;
1358            let offset = decoder.out_of_line_offset(bytes_len)?;
1359            // Decode the envelope for each type.
1360            let mut _next_ordinal_to_read = 0;
1361            let mut next_offset = offset;
1362            let end_offset = offset + bytes_len;
1363            _next_ordinal_to_read += 1;
1364            if next_offset >= end_offset {
1365                return Ok(());
1366            }
1367
1368            // Decode unknown envelopes for gaps in ordinals.
1369            while _next_ordinal_to_read < 1 {
1370                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1371                _next_ordinal_to_read += 1;
1372                next_offset += envelope_size;
1373            }
1374
1375            let next_out_of_line = decoder.next_out_of_line();
1376            let handles_before = decoder.remaining_handles();
1377            if let Some((inlined, num_bytes, num_handles)) =
1378                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1379            {
1380                let member_inline_size =
1381                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1382                if inlined != (member_inline_size <= 4) {
1383                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1384                }
1385                let inner_offset;
1386                let mut inner_depth = depth.clone();
1387                if inlined {
1388                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1389                    inner_offset = next_offset;
1390                } else {
1391                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1392                    inner_depth.increment()?;
1393                }
1394                let val_ref = self.rate_adjust.get_or_insert_with(|| fidl::new_empty!(i32, D));
1395                fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
1396                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1397                {
1398                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1399                }
1400                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1401                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1402                }
1403            }
1404
1405            next_offset += envelope_size;
1406            _next_ordinal_to_read += 1;
1407            if next_offset >= end_offset {
1408                return Ok(());
1409            }
1410
1411            // Decode unknown envelopes for gaps in ordinals.
1412            while _next_ordinal_to_read < 2 {
1413                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1414                _next_ordinal_to_read += 1;
1415                next_offset += envelope_size;
1416            }
1417
1418            let next_out_of_line = decoder.next_out_of_line();
1419            let handles_before = decoder.remaining_handles();
1420            if let Some((inlined, num_bytes, num_handles)) =
1421                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1422            {
1423                let member_inline_size =
1424                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1425                if inlined != (member_inline_size <= 4) {
1426                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1427                }
1428                let inner_offset;
1429                let mut inner_depth = depth.clone();
1430                if inlined {
1431                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1432                    inner_offset = next_offset;
1433                } else {
1434                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1435                    inner_depth.increment()?;
1436                }
1437                let val_ref = self.offset.get_or_insert_with(|| fidl::new_empty!(i32, D));
1438                fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
1439                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1440                {
1441                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1442                }
1443                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1444                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1445                }
1446            }
1447
1448            next_offset += envelope_size;
1449
1450            // Decode the remaining unknown envelopes.
1451            while next_offset < end_offset {
1452                _next_ordinal_to_read += 1;
1453                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1454                next_offset += envelope_size;
1455            }
1456
1457            Ok(())
1458        }
1459    }
1460
1461    impl GainSettings {
1462        #[inline(always)]
1463        fn max_ordinal_present(&self) -> u64 {
1464            if let Some(_) = self.gain {
1465                return 2;
1466            }
1467            if let Some(_) = self.mute {
1468                return 1;
1469            }
1470            0
1471        }
1472    }
1473
1474    impl fidl::encoding::ValueTypeMarker for GainSettings {
1475        type Borrowed<'a> = &'a Self;
1476        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1477            value
1478        }
1479    }
1480
1481    unsafe impl fidl::encoding::TypeMarker for GainSettings {
1482        type Owned = Self;
1483
1484        #[inline(always)]
1485        fn inline_align(_context: fidl::encoding::Context) -> usize {
1486            8
1487        }
1488
1489        #[inline(always)]
1490        fn inline_size(_context: fidl::encoding::Context) -> usize {
1491            16
1492        }
1493    }
1494
1495    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GainSettings, D>
1496        for &GainSettings
1497    {
1498        unsafe fn encode(
1499            self,
1500            encoder: &mut fidl::encoding::Encoder<'_, D>,
1501            offset: usize,
1502            mut depth: fidl::encoding::Depth,
1503        ) -> fidl::Result<()> {
1504            encoder.debug_check_bounds::<GainSettings>(offset);
1505            // Vector header
1506            let max_ordinal: u64 = self.max_ordinal_present();
1507            encoder.write_num(max_ordinal, offset);
1508            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1509            // Calling encoder.out_of_line_offset(0) is not allowed.
1510            if max_ordinal == 0 {
1511                return Ok(());
1512            }
1513            depth.increment()?;
1514            let envelope_size = 8;
1515            let bytes_len = max_ordinal as usize * envelope_size;
1516            #[allow(unused_variables)]
1517            let offset = encoder.out_of_line_offset(bytes_len);
1518            let mut _prev_end_offset: usize = 0;
1519            if 1 > max_ordinal {
1520                return Ok(());
1521            }
1522
1523            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1524            // are envelope_size bytes.
1525            let cur_offset: usize = (1 - 1) * envelope_size;
1526
1527            // Zero reserved fields.
1528            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1529
1530            // Safety:
1531            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1532            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1533            //   envelope_size bytes, there is always sufficient room.
1534            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1535                self.mute.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1536                encoder,
1537                offset + cur_offset,
1538                depth,
1539            )?;
1540
1541            _prev_end_offset = cur_offset + envelope_size;
1542            if 2 > max_ordinal {
1543                return Ok(());
1544            }
1545
1546            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1547            // are envelope_size bytes.
1548            let cur_offset: usize = (2 - 1) * envelope_size;
1549
1550            // Zero reserved fields.
1551            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1552
1553            // Safety:
1554            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1555            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1556            //   envelope_size bytes, there is always sufficient room.
1557            fidl::encoding::encode_in_envelope_optional::<f32, D>(
1558                self.gain.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
1559                encoder,
1560                offset + cur_offset,
1561                depth,
1562            )?;
1563
1564            _prev_end_offset = cur_offset + envelope_size;
1565
1566            Ok(())
1567        }
1568    }
1569
1570    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GainSettings {
1571        #[inline(always)]
1572        fn new_empty() -> Self {
1573            Self::default()
1574        }
1575
1576        unsafe fn decode(
1577            &mut self,
1578            decoder: &mut fidl::encoding::Decoder<'_, D>,
1579            offset: usize,
1580            mut depth: fidl::encoding::Depth,
1581        ) -> fidl::Result<()> {
1582            decoder.debug_check_bounds::<Self>(offset);
1583            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1584                None => return Err(fidl::Error::NotNullable),
1585                Some(len) => len,
1586            };
1587            // Calling decoder.out_of_line_offset(0) is not allowed.
1588            if len == 0 {
1589                return Ok(());
1590            };
1591            depth.increment()?;
1592            let envelope_size = 8;
1593            let bytes_len = len * envelope_size;
1594            let offset = decoder.out_of_line_offset(bytes_len)?;
1595            // Decode the envelope for each type.
1596            let mut _next_ordinal_to_read = 0;
1597            let mut next_offset = offset;
1598            let end_offset = offset + bytes_len;
1599            _next_ordinal_to_read += 1;
1600            if next_offset >= end_offset {
1601                return Ok(());
1602            }
1603
1604            // Decode unknown envelopes for gaps in ordinals.
1605            while _next_ordinal_to_read < 1 {
1606                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1607                _next_ordinal_to_read += 1;
1608                next_offset += envelope_size;
1609            }
1610
1611            let next_out_of_line = decoder.next_out_of_line();
1612            let handles_before = decoder.remaining_handles();
1613            if let Some((inlined, num_bytes, num_handles)) =
1614                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1615            {
1616                let member_inline_size =
1617                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1618                if inlined != (member_inline_size <= 4) {
1619                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1620                }
1621                let inner_offset;
1622                let mut inner_depth = depth.clone();
1623                if inlined {
1624                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1625                    inner_offset = next_offset;
1626                } else {
1627                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1628                    inner_depth.increment()?;
1629                }
1630                let val_ref = self.mute.get_or_insert_with(|| fidl::new_empty!(bool, D));
1631                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1632                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1633                {
1634                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1635                }
1636                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1637                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1638                }
1639            }
1640
1641            next_offset += envelope_size;
1642            _next_ordinal_to_read += 1;
1643            if next_offset >= end_offset {
1644                return Ok(());
1645            }
1646
1647            // Decode unknown envelopes for gaps in ordinals.
1648            while _next_ordinal_to_read < 2 {
1649                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1650                _next_ordinal_to_read += 1;
1651                next_offset += envelope_size;
1652            }
1653
1654            let next_out_of_line = decoder.next_out_of_line();
1655            let handles_before = decoder.remaining_handles();
1656            if let Some((inlined, num_bytes, num_handles)) =
1657                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1658            {
1659                let member_inline_size =
1660                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1661                if inlined != (member_inline_size <= 4) {
1662                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1663                }
1664                let inner_offset;
1665                let mut inner_depth = depth.clone();
1666                if inlined {
1667                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1668                    inner_offset = next_offset;
1669                } else {
1670                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1671                    inner_depth.increment()?;
1672                }
1673                let val_ref = self.gain.get_or_insert_with(|| fidl::new_empty!(f32, D));
1674                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
1675                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1676                {
1677                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1678                }
1679                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1680                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1681                }
1682            }
1683
1684            next_offset += envelope_size;
1685
1686            // Decode the remaining unknown envelopes.
1687            while next_offset < end_offset {
1688                _next_ordinal_to_read += 1;
1689                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1690                next_offset += envelope_size;
1691            }
1692
1693            Ok(())
1694        }
1695    }
1696
1697    impl StandardCapturerConfig {
1698        #[inline(always)]
1699        fn max_ordinal_present(&self) -> u64 {
1700            if let Some(_) = self.clock {
1701                return 2;
1702            }
1703            if let Some(_) = self.usage {
1704                return 1;
1705            }
1706            0
1707        }
1708    }
1709
1710    impl fidl::encoding::ValueTypeMarker for StandardCapturerConfig {
1711        type Borrowed<'a> = &'a Self;
1712        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1713            value
1714        }
1715    }
1716
1717    unsafe impl fidl::encoding::TypeMarker for StandardCapturerConfig {
1718        type Owned = Self;
1719
1720        #[inline(always)]
1721        fn inline_align(_context: fidl::encoding::Context) -> usize {
1722            8
1723        }
1724
1725        #[inline(always)]
1726        fn inline_size(_context: fidl::encoding::Context) -> usize {
1727            16
1728        }
1729    }
1730
1731    unsafe impl<D: fidl::encoding::ResourceDialect>
1732        fidl::encoding::Encode<StandardCapturerConfig, D> for &StandardCapturerConfig
1733    {
1734        unsafe fn encode(
1735            self,
1736            encoder: &mut fidl::encoding::Encoder<'_, D>,
1737            offset: usize,
1738            mut depth: fidl::encoding::Depth,
1739        ) -> fidl::Result<()> {
1740            encoder.debug_check_bounds::<StandardCapturerConfig>(offset);
1741            // Vector header
1742            let max_ordinal: u64 = self.max_ordinal_present();
1743            encoder.write_num(max_ordinal, offset);
1744            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1745            // Calling encoder.out_of_line_offset(0) is not allowed.
1746            if max_ordinal == 0 {
1747                return Ok(());
1748            }
1749            depth.increment()?;
1750            let envelope_size = 8;
1751            let bytes_len = max_ordinal as usize * envelope_size;
1752            #[allow(unused_variables)]
1753            let offset = encoder.out_of_line_offset(bytes_len);
1754            let mut _prev_end_offset: usize = 0;
1755            if 1 > max_ordinal {
1756                return Ok(());
1757            }
1758
1759            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1760            // are envelope_size bytes.
1761            let cur_offset: usize = (1 - 1) * envelope_size;
1762
1763            // Zero reserved fields.
1764            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1765
1766            // Safety:
1767            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1768            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1769            //   envelope_size bytes, there is always sufficient room.
1770            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media::AudioCaptureUsage2, D>(
1771            self.usage.as_ref().map(<fidl_fuchsia_media::AudioCaptureUsage2 as fidl::encoding::ValueTypeMarker>::borrow),
1772            encoder, offset + cur_offset, depth
1773        )?;
1774
1775            _prev_end_offset = cur_offset + envelope_size;
1776            if 2 > max_ordinal {
1777                return Ok(());
1778            }
1779
1780            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1781            // are envelope_size bytes.
1782            let cur_offset: usize = (2 - 1) * envelope_size;
1783
1784            // Zero reserved fields.
1785            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1786
1787            // Safety:
1788            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1789            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1790            //   envelope_size bytes, there is always sufficient room.
1791            fidl::encoding::encode_in_envelope_optional::<ClockType, D>(
1792                self.clock.as_ref().map(<ClockType as fidl::encoding::ValueTypeMarker>::borrow),
1793                encoder,
1794                offset + cur_offset,
1795                depth,
1796            )?;
1797
1798            _prev_end_offset = cur_offset + envelope_size;
1799
1800            Ok(())
1801        }
1802    }
1803
1804    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1805        for StandardCapturerConfig
1806    {
1807        #[inline(always)]
1808        fn new_empty() -> Self {
1809            Self::default()
1810        }
1811
1812        unsafe fn decode(
1813            &mut self,
1814            decoder: &mut fidl::encoding::Decoder<'_, D>,
1815            offset: usize,
1816            mut depth: fidl::encoding::Depth,
1817        ) -> fidl::Result<()> {
1818            decoder.debug_check_bounds::<Self>(offset);
1819            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1820                None => return Err(fidl::Error::NotNullable),
1821                Some(len) => len,
1822            };
1823            // Calling decoder.out_of_line_offset(0) is not allowed.
1824            if len == 0 {
1825                return Ok(());
1826            };
1827            depth.increment()?;
1828            let envelope_size = 8;
1829            let bytes_len = len * envelope_size;
1830            let offset = decoder.out_of_line_offset(bytes_len)?;
1831            // Decode the envelope for each type.
1832            let mut _next_ordinal_to_read = 0;
1833            let mut next_offset = offset;
1834            let end_offset = offset + bytes_len;
1835            _next_ordinal_to_read += 1;
1836            if next_offset >= end_offset {
1837                return Ok(());
1838            }
1839
1840            // Decode unknown envelopes for gaps in ordinals.
1841            while _next_ordinal_to_read < 1 {
1842                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1843                _next_ordinal_to_read += 1;
1844                next_offset += envelope_size;
1845            }
1846
1847            let next_out_of_line = decoder.next_out_of_line();
1848            let handles_before = decoder.remaining_handles();
1849            if let Some((inlined, num_bytes, num_handles)) =
1850                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1851            {
1852                let member_inline_size = <fidl_fuchsia_media::AudioCaptureUsage2 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1853                if inlined != (member_inline_size <= 4) {
1854                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1855                }
1856                let inner_offset;
1857                let mut inner_depth = depth.clone();
1858                if inlined {
1859                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1860                    inner_offset = next_offset;
1861                } else {
1862                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1863                    inner_depth.increment()?;
1864                }
1865                let val_ref = self.usage.get_or_insert_with(|| {
1866                    fidl::new_empty!(fidl_fuchsia_media::AudioCaptureUsage2, D)
1867                });
1868                fidl::decode!(
1869                    fidl_fuchsia_media::AudioCaptureUsage2,
1870                    D,
1871                    val_ref,
1872                    decoder,
1873                    inner_offset,
1874                    inner_depth
1875                )?;
1876                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1877                {
1878                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1879                }
1880                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1881                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1882                }
1883            }
1884
1885            next_offset += envelope_size;
1886            _next_ordinal_to_read += 1;
1887            if next_offset >= end_offset {
1888                return Ok(());
1889            }
1890
1891            // Decode unknown envelopes for gaps in ordinals.
1892            while _next_ordinal_to_read < 2 {
1893                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1894                _next_ordinal_to_read += 1;
1895                next_offset += envelope_size;
1896            }
1897
1898            let next_out_of_line = decoder.next_out_of_line();
1899            let handles_before = decoder.remaining_handles();
1900            if let Some((inlined, num_bytes, num_handles)) =
1901                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1902            {
1903                let member_inline_size =
1904                    <ClockType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1905                if inlined != (member_inline_size <= 4) {
1906                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1907                }
1908                let inner_offset;
1909                let mut inner_depth = depth.clone();
1910                if inlined {
1911                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1912                    inner_offset = next_offset;
1913                } else {
1914                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1915                    inner_depth.increment()?;
1916                }
1917                let val_ref = self.clock.get_or_insert_with(|| fidl::new_empty!(ClockType, D));
1918                fidl::decode!(ClockType, D, val_ref, decoder, inner_offset, inner_depth)?;
1919                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1920                {
1921                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1922                }
1923                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1924                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1925                }
1926            }
1927
1928            next_offset += envelope_size;
1929
1930            // Decode the remaining unknown envelopes.
1931            while next_offset < end_offset {
1932                _next_ordinal_to_read += 1;
1933                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1934                next_offset += envelope_size;
1935            }
1936
1937            Ok(())
1938        }
1939    }
1940
1941    impl StandardRendererConfig {
1942        #[inline(always)]
1943        fn max_ordinal_present(&self) -> u64 {
1944            if let Some(_) = self.packet_count {
1945                return 3;
1946            }
1947            if let Some(_) = self.clock {
1948                return 2;
1949            }
1950            if let Some(_) = self.usage {
1951                return 1;
1952            }
1953            0
1954        }
1955    }
1956
1957    impl fidl::encoding::ValueTypeMarker for StandardRendererConfig {
1958        type Borrowed<'a> = &'a Self;
1959        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1960            value
1961        }
1962    }
1963
1964    unsafe impl fidl::encoding::TypeMarker for StandardRendererConfig {
1965        type Owned = Self;
1966
1967        #[inline(always)]
1968        fn inline_align(_context: fidl::encoding::Context) -> usize {
1969            8
1970        }
1971
1972        #[inline(always)]
1973        fn inline_size(_context: fidl::encoding::Context) -> usize {
1974            16
1975        }
1976    }
1977
1978    unsafe impl<D: fidl::encoding::ResourceDialect>
1979        fidl::encoding::Encode<StandardRendererConfig, D> for &StandardRendererConfig
1980    {
1981        unsafe fn encode(
1982            self,
1983            encoder: &mut fidl::encoding::Encoder<'_, D>,
1984            offset: usize,
1985            mut depth: fidl::encoding::Depth,
1986        ) -> fidl::Result<()> {
1987            encoder.debug_check_bounds::<StandardRendererConfig>(offset);
1988            // Vector header
1989            let max_ordinal: u64 = self.max_ordinal_present();
1990            encoder.write_num(max_ordinal, offset);
1991            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1992            // Calling encoder.out_of_line_offset(0) is not allowed.
1993            if max_ordinal == 0 {
1994                return Ok(());
1995            }
1996            depth.increment()?;
1997            let envelope_size = 8;
1998            let bytes_len = max_ordinal as usize * envelope_size;
1999            #[allow(unused_variables)]
2000            let offset = encoder.out_of_line_offset(bytes_len);
2001            let mut _prev_end_offset: usize = 0;
2002            if 1 > max_ordinal {
2003                return Ok(());
2004            }
2005
2006            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2007            // are envelope_size bytes.
2008            let cur_offset: usize = (1 - 1) * envelope_size;
2009
2010            // Zero reserved fields.
2011            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2012
2013            // Safety:
2014            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2015            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2016            //   envelope_size bytes, there is always sufficient room.
2017            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media::AudioRenderUsage2, D>(
2018            self.usage.as_ref().map(<fidl_fuchsia_media::AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow),
2019            encoder, offset + cur_offset, depth
2020        )?;
2021
2022            _prev_end_offset = cur_offset + envelope_size;
2023            if 2 > max_ordinal {
2024                return Ok(());
2025            }
2026
2027            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2028            // are envelope_size bytes.
2029            let cur_offset: usize = (2 - 1) * envelope_size;
2030
2031            // Zero reserved fields.
2032            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2033
2034            // Safety:
2035            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2036            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2037            //   envelope_size bytes, there is always sufficient room.
2038            fidl::encoding::encode_in_envelope_optional::<ClockType, D>(
2039                self.clock.as_ref().map(<ClockType as fidl::encoding::ValueTypeMarker>::borrow),
2040                encoder,
2041                offset + cur_offset,
2042                depth,
2043            )?;
2044
2045            _prev_end_offset = cur_offset + envelope_size;
2046            if 3 > max_ordinal {
2047                return Ok(());
2048            }
2049
2050            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2051            // are envelope_size bytes.
2052            let cur_offset: usize = (3 - 1) * envelope_size;
2053
2054            // Zero reserved fields.
2055            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2056
2057            // Safety:
2058            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2059            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2060            //   envelope_size bytes, there is always sufficient room.
2061            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2062                self.packet_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2063                encoder,
2064                offset + cur_offset,
2065                depth,
2066            )?;
2067
2068            _prev_end_offset = cur_offset + envelope_size;
2069
2070            Ok(())
2071        }
2072    }
2073
2074    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2075        for StandardRendererConfig
2076    {
2077        #[inline(always)]
2078        fn new_empty() -> Self {
2079            Self::default()
2080        }
2081
2082        unsafe fn decode(
2083            &mut self,
2084            decoder: &mut fidl::encoding::Decoder<'_, D>,
2085            offset: usize,
2086            mut depth: fidl::encoding::Depth,
2087        ) -> fidl::Result<()> {
2088            decoder.debug_check_bounds::<Self>(offset);
2089            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2090                None => return Err(fidl::Error::NotNullable),
2091                Some(len) => len,
2092            };
2093            // Calling decoder.out_of_line_offset(0) is not allowed.
2094            if len == 0 {
2095                return Ok(());
2096            };
2097            depth.increment()?;
2098            let envelope_size = 8;
2099            let bytes_len = len * envelope_size;
2100            let offset = decoder.out_of_line_offset(bytes_len)?;
2101            // Decode the envelope for each type.
2102            let mut _next_ordinal_to_read = 0;
2103            let mut next_offset = offset;
2104            let end_offset = offset + bytes_len;
2105            _next_ordinal_to_read += 1;
2106            if next_offset >= end_offset {
2107                return Ok(());
2108            }
2109
2110            // Decode unknown envelopes for gaps in ordinals.
2111            while _next_ordinal_to_read < 1 {
2112                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2113                _next_ordinal_to_read += 1;
2114                next_offset += envelope_size;
2115            }
2116
2117            let next_out_of_line = decoder.next_out_of_line();
2118            let handles_before = decoder.remaining_handles();
2119            if let Some((inlined, num_bytes, num_handles)) =
2120                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2121            {
2122                let member_inline_size = <fidl_fuchsia_media::AudioRenderUsage2 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2123                if inlined != (member_inline_size <= 4) {
2124                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2125                }
2126                let inner_offset;
2127                let mut inner_depth = depth.clone();
2128                if inlined {
2129                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2130                    inner_offset = next_offset;
2131                } else {
2132                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2133                    inner_depth.increment()?;
2134                }
2135                let val_ref = self.usage.get_or_insert_with(|| {
2136                    fidl::new_empty!(fidl_fuchsia_media::AudioRenderUsage2, D)
2137                });
2138                fidl::decode!(
2139                    fidl_fuchsia_media::AudioRenderUsage2,
2140                    D,
2141                    val_ref,
2142                    decoder,
2143                    inner_offset,
2144                    inner_depth
2145                )?;
2146                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2147                {
2148                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2149                }
2150                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2151                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2152                }
2153            }
2154
2155            next_offset += envelope_size;
2156            _next_ordinal_to_read += 1;
2157            if next_offset >= end_offset {
2158                return Ok(());
2159            }
2160
2161            // Decode unknown envelopes for gaps in ordinals.
2162            while _next_ordinal_to_read < 2 {
2163                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2164                _next_ordinal_to_read += 1;
2165                next_offset += envelope_size;
2166            }
2167
2168            let next_out_of_line = decoder.next_out_of_line();
2169            let handles_before = decoder.remaining_handles();
2170            if let Some((inlined, num_bytes, num_handles)) =
2171                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2172            {
2173                let member_inline_size =
2174                    <ClockType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2175                if inlined != (member_inline_size <= 4) {
2176                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2177                }
2178                let inner_offset;
2179                let mut inner_depth = depth.clone();
2180                if inlined {
2181                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2182                    inner_offset = next_offset;
2183                } else {
2184                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2185                    inner_depth.increment()?;
2186                }
2187                let val_ref = self.clock.get_or_insert_with(|| fidl::new_empty!(ClockType, D));
2188                fidl::decode!(ClockType, D, val_ref, decoder, inner_offset, inner_depth)?;
2189                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2190                {
2191                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2192                }
2193                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2194                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2195                }
2196            }
2197
2198            next_offset += envelope_size;
2199            _next_ordinal_to_read += 1;
2200            if next_offset >= end_offset {
2201                return Ok(());
2202            }
2203
2204            // Decode unknown envelopes for gaps in ordinals.
2205            while _next_ordinal_to_read < 3 {
2206                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2207                _next_ordinal_to_read += 1;
2208                next_offset += envelope_size;
2209            }
2210
2211            let next_out_of_line = decoder.next_out_of_line();
2212            let handles_before = decoder.remaining_handles();
2213            if let Some((inlined, num_bytes, num_handles)) =
2214                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2215            {
2216                let member_inline_size =
2217                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2218                if inlined != (member_inline_size <= 4) {
2219                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2220                }
2221                let inner_offset;
2222                let mut inner_depth = depth.clone();
2223                if inlined {
2224                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2225                    inner_offset = next_offset;
2226                } else {
2227                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2228                    inner_depth.increment()?;
2229                }
2230                let val_ref = self.packet_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
2231                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2232                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2233                {
2234                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2235                }
2236                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2237                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2238                }
2239            }
2240
2241            next_offset += envelope_size;
2242
2243            // Decode the remaining unknown envelopes.
2244            while next_offset < end_offset {
2245                _next_ordinal_to_read += 1;
2246                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2247                next_offset += envelope_size;
2248            }
2249
2250            Ok(())
2251        }
2252    }
2253
2254    impl UltrasoundRendererConfig {
2255        #[inline(always)]
2256        fn max_ordinal_present(&self) -> u64 {
2257            if let Some(_) = self.packet_count {
2258                return 1;
2259            }
2260            0
2261        }
2262    }
2263
2264    impl fidl::encoding::ValueTypeMarker for UltrasoundRendererConfig {
2265        type Borrowed<'a> = &'a Self;
2266        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2267            value
2268        }
2269    }
2270
2271    unsafe impl fidl::encoding::TypeMarker for UltrasoundRendererConfig {
2272        type Owned = Self;
2273
2274        #[inline(always)]
2275        fn inline_align(_context: fidl::encoding::Context) -> usize {
2276            8
2277        }
2278
2279        #[inline(always)]
2280        fn inline_size(_context: fidl::encoding::Context) -> usize {
2281            16
2282        }
2283    }
2284
2285    unsafe impl<D: fidl::encoding::ResourceDialect>
2286        fidl::encoding::Encode<UltrasoundRendererConfig, D> for &UltrasoundRendererConfig
2287    {
2288        unsafe fn encode(
2289            self,
2290            encoder: &mut fidl::encoding::Encoder<'_, D>,
2291            offset: usize,
2292            mut depth: fidl::encoding::Depth,
2293        ) -> fidl::Result<()> {
2294            encoder.debug_check_bounds::<UltrasoundRendererConfig>(offset);
2295            // Vector header
2296            let max_ordinal: u64 = self.max_ordinal_present();
2297            encoder.write_num(max_ordinal, offset);
2298            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2299            // Calling encoder.out_of_line_offset(0) is not allowed.
2300            if max_ordinal == 0 {
2301                return Ok(());
2302            }
2303            depth.increment()?;
2304            let envelope_size = 8;
2305            let bytes_len = max_ordinal as usize * envelope_size;
2306            #[allow(unused_variables)]
2307            let offset = encoder.out_of_line_offset(bytes_len);
2308            let mut _prev_end_offset: usize = 0;
2309            if 1 > max_ordinal {
2310                return Ok(());
2311            }
2312
2313            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2314            // are envelope_size bytes.
2315            let cur_offset: usize = (1 - 1) * envelope_size;
2316
2317            // Zero reserved fields.
2318            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2319
2320            // Safety:
2321            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2322            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2323            //   envelope_size bytes, there is always sufficient room.
2324            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2325                self.packet_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2326                encoder,
2327                offset + cur_offset,
2328                depth,
2329            )?;
2330
2331            _prev_end_offset = cur_offset + envelope_size;
2332
2333            Ok(())
2334        }
2335    }
2336
2337    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2338        for UltrasoundRendererConfig
2339    {
2340        #[inline(always)]
2341        fn new_empty() -> Self {
2342            Self::default()
2343        }
2344
2345        unsafe fn decode(
2346            &mut self,
2347            decoder: &mut fidl::encoding::Decoder<'_, D>,
2348            offset: usize,
2349            mut depth: fidl::encoding::Depth,
2350        ) -> fidl::Result<()> {
2351            decoder.debug_check_bounds::<Self>(offset);
2352            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2353                None => return Err(fidl::Error::NotNullable),
2354                Some(len) => len,
2355            };
2356            // Calling decoder.out_of_line_offset(0) is not allowed.
2357            if len == 0 {
2358                return Ok(());
2359            };
2360            depth.increment()?;
2361            let envelope_size = 8;
2362            let bytes_len = len * envelope_size;
2363            let offset = decoder.out_of_line_offset(bytes_len)?;
2364            // Decode the envelope for each type.
2365            let mut _next_ordinal_to_read = 0;
2366            let mut next_offset = offset;
2367            let end_offset = offset + bytes_len;
2368            _next_ordinal_to_read += 1;
2369            if next_offset >= end_offset {
2370                return Ok(());
2371            }
2372
2373            // Decode unknown envelopes for gaps in ordinals.
2374            while _next_ordinal_to_read < 1 {
2375                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2376                _next_ordinal_to_read += 1;
2377                next_offset += envelope_size;
2378            }
2379
2380            let next_out_of_line = decoder.next_out_of_line();
2381            let handles_before = decoder.remaining_handles();
2382            if let Some((inlined, num_bytes, num_handles)) =
2383                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2384            {
2385                let member_inline_size =
2386                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2387                if inlined != (member_inline_size <= 4) {
2388                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2389                }
2390                let inner_offset;
2391                let mut inner_depth = depth.clone();
2392                if inlined {
2393                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2394                    inner_offset = next_offset;
2395                } else {
2396                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2397                    inner_depth.increment()?;
2398                }
2399                let val_ref = self.packet_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
2400                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2401                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2402                {
2403                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2404                }
2405                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2406                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2407                }
2408            }
2409
2410            next_offset += envelope_size;
2411
2412            // Decode the remaining unknown envelopes.
2413            while next_offset < end_offset {
2414                _next_ordinal_to_read += 1;
2415                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2416                next_offset += envelope_size;
2417            }
2418
2419            Ok(())
2420        }
2421    }
2422
2423    impl fidl::encoding::ValueTypeMarker for CapturerConfig {
2424        type Borrowed<'a> = &'a Self;
2425        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2426            value
2427        }
2428    }
2429
2430    unsafe impl fidl::encoding::TypeMarker for CapturerConfig {
2431        type Owned = Self;
2432
2433        #[inline(always)]
2434        fn inline_align(_context: fidl::encoding::Context) -> usize {
2435            8
2436        }
2437
2438        #[inline(always)]
2439        fn inline_size(_context: fidl::encoding::Context) -> usize {
2440            16
2441        }
2442    }
2443
2444    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CapturerConfig, D>
2445        for &CapturerConfig
2446    {
2447        #[inline]
2448        unsafe fn encode(
2449            self,
2450            encoder: &mut fidl::encoding::Encoder<'_, D>,
2451            offset: usize,
2452            _depth: fidl::encoding::Depth,
2453        ) -> fidl::Result<()> {
2454            encoder.debug_check_bounds::<CapturerConfig>(offset);
2455            encoder.write_num::<u64>(self.ordinal(), offset);
2456            match self {
2457                CapturerConfig::StandardCapturer(ref val) => {
2458                    fidl::encoding::encode_in_envelope::<StandardCapturerConfig, D>(
2459                        <StandardCapturerConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
2460                        encoder,
2461                        offset + 8,
2462                        _depth,
2463                    )
2464                }
2465                CapturerConfig::UltrasoundCapturer(ref val) => {
2466                    fidl::encoding::encode_in_envelope::<UltrasoundCapturer, D>(
2467                        <UltrasoundCapturer as fidl::encoding::ValueTypeMarker>::borrow(val),
2468                        encoder,
2469                        offset + 8,
2470                        _depth,
2471                    )
2472                }
2473                CapturerConfig::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2474            }
2475        }
2476    }
2477
2478    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CapturerConfig {
2479        #[inline(always)]
2480        fn new_empty() -> Self {
2481            Self::__SourceBreaking { unknown_ordinal: 0 }
2482        }
2483
2484        #[inline]
2485        unsafe fn decode(
2486            &mut self,
2487            decoder: &mut fidl::encoding::Decoder<'_, D>,
2488            offset: usize,
2489            mut depth: fidl::encoding::Depth,
2490        ) -> fidl::Result<()> {
2491            decoder.debug_check_bounds::<Self>(offset);
2492            #[allow(unused_variables)]
2493            let next_out_of_line = decoder.next_out_of_line();
2494            let handles_before = decoder.remaining_handles();
2495            let (ordinal, inlined, num_bytes, num_handles) =
2496                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2497
2498            let member_inline_size = match ordinal {
2499                1 => <StandardCapturerConfig as fidl::encoding::TypeMarker>::inline_size(
2500                    decoder.context,
2501                ),
2502                2 => {
2503                    <UltrasoundCapturer as fidl::encoding::TypeMarker>::inline_size(decoder.context)
2504                }
2505                0 => return Err(fidl::Error::UnknownUnionTag),
2506                _ => num_bytes as usize,
2507            };
2508
2509            if inlined != (member_inline_size <= 4) {
2510                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2511            }
2512            let _inner_offset;
2513            if inlined {
2514                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2515                _inner_offset = offset + 8;
2516            } else {
2517                depth.increment()?;
2518                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2519            }
2520            match ordinal {
2521                1 => {
2522                    #[allow(irrefutable_let_patterns)]
2523                    if let CapturerConfig::StandardCapturer(_) = self {
2524                        // Do nothing, read the value into the object
2525                    } else {
2526                        // Initialize `self` to the right variant
2527                        *self = CapturerConfig::StandardCapturer(fidl::new_empty!(
2528                            StandardCapturerConfig,
2529                            D
2530                        ));
2531                    }
2532                    #[allow(irrefutable_let_patterns)]
2533                    if let CapturerConfig::StandardCapturer(ref mut val) = self {
2534                        fidl::decode!(
2535                            StandardCapturerConfig,
2536                            D,
2537                            val,
2538                            decoder,
2539                            _inner_offset,
2540                            depth
2541                        )?;
2542                    } else {
2543                        unreachable!()
2544                    }
2545                }
2546                2 => {
2547                    #[allow(irrefutable_let_patterns)]
2548                    if let CapturerConfig::UltrasoundCapturer(_) = self {
2549                        // Do nothing, read the value into the object
2550                    } else {
2551                        // Initialize `self` to the right variant
2552                        *self = CapturerConfig::UltrasoundCapturer(fidl::new_empty!(
2553                            UltrasoundCapturer,
2554                            D
2555                        ));
2556                    }
2557                    #[allow(irrefutable_let_patterns)]
2558                    if let CapturerConfig::UltrasoundCapturer(ref mut val) = self {
2559                        fidl::decode!(UltrasoundCapturer, D, val, decoder, _inner_offset, depth)?;
2560                    } else {
2561                        unreachable!()
2562                    }
2563                }
2564                #[allow(deprecated)]
2565                ordinal => {
2566                    for _ in 0..num_handles {
2567                        decoder.drop_next_handle()?;
2568                    }
2569                    *self = CapturerConfig::__SourceBreaking { unknown_ordinal: ordinal };
2570                }
2571            }
2572            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2573                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2574            }
2575            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2576                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2577            }
2578            Ok(())
2579        }
2580    }
2581
2582    impl fidl::encoding::ValueTypeMarker for ClockType {
2583        type Borrowed<'a> = &'a Self;
2584        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2585            value
2586        }
2587    }
2588
2589    unsafe impl fidl::encoding::TypeMarker for ClockType {
2590        type Owned = Self;
2591
2592        #[inline(always)]
2593        fn inline_align(_context: fidl::encoding::Context) -> usize {
2594            8
2595        }
2596
2597        #[inline(always)]
2598        fn inline_size(_context: fidl::encoding::Context) -> usize {
2599            16
2600        }
2601    }
2602
2603    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ClockType, D>
2604        for &ClockType
2605    {
2606        #[inline]
2607        unsafe fn encode(
2608            self,
2609            encoder: &mut fidl::encoding::Encoder<'_, D>,
2610            offset: usize,
2611            _depth: fidl::encoding::Depth,
2612        ) -> fidl::Result<()> {
2613            encoder.debug_check_bounds::<ClockType>(offset);
2614            encoder.write_num::<u64>(self.ordinal(), offset);
2615            match self {
2616                ClockType::Flexible(ref val) => fidl::encoding::encode_in_envelope::<Flexible, D>(
2617                    <Flexible as fidl::encoding::ValueTypeMarker>::borrow(val),
2618                    encoder,
2619                    offset + 8,
2620                    _depth,
2621                ),
2622                ClockType::SystemMonotonic(ref val) => {
2623                    fidl::encoding::encode_in_envelope::<SystemMonotonic, D>(
2624                        <SystemMonotonic as fidl::encoding::ValueTypeMarker>::borrow(val),
2625                        encoder,
2626                        offset + 8,
2627                        _depth,
2628                    )
2629                }
2630                ClockType::Custom(ref val) => {
2631                    fidl::encoding::encode_in_envelope::<CustomClockConfig, D>(
2632                        <CustomClockConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
2633                        encoder,
2634                        offset + 8,
2635                        _depth,
2636                    )
2637                }
2638                ClockType::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2639            }
2640        }
2641    }
2642
2643    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ClockType {
2644        #[inline(always)]
2645        fn new_empty() -> Self {
2646            Self::__SourceBreaking { unknown_ordinal: 0 }
2647        }
2648
2649        #[inline]
2650        unsafe fn decode(
2651            &mut self,
2652            decoder: &mut fidl::encoding::Decoder<'_, D>,
2653            offset: usize,
2654            mut depth: fidl::encoding::Depth,
2655        ) -> fidl::Result<()> {
2656            decoder.debug_check_bounds::<Self>(offset);
2657            #[allow(unused_variables)]
2658            let next_out_of_line = decoder.next_out_of_line();
2659            let handles_before = decoder.remaining_handles();
2660            let (ordinal, inlined, num_bytes, num_handles) =
2661                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2662
2663            let member_inline_size = match ordinal {
2664                1 => <Flexible as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2665                2 => <SystemMonotonic as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2666                3 => {
2667                    <CustomClockConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context)
2668                }
2669                0 => return Err(fidl::Error::UnknownUnionTag),
2670                _ => num_bytes as usize,
2671            };
2672
2673            if inlined != (member_inline_size <= 4) {
2674                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2675            }
2676            let _inner_offset;
2677            if inlined {
2678                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2679                _inner_offset = offset + 8;
2680            } else {
2681                depth.increment()?;
2682                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2683            }
2684            match ordinal {
2685                1 => {
2686                    #[allow(irrefutable_let_patterns)]
2687                    if let ClockType::Flexible(_) = self {
2688                        // Do nothing, read the value into the object
2689                    } else {
2690                        // Initialize `self` to the right variant
2691                        *self = ClockType::Flexible(fidl::new_empty!(Flexible, D));
2692                    }
2693                    #[allow(irrefutable_let_patterns)]
2694                    if let ClockType::Flexible(ref mut val) = self {
2695                        fidl::decode!(Flexible, D, val, decoder, _inner_offset, depth)?;
2696                    } else {
2697                        unreachable!()
2698                    }
2699                }
2700                2 => {
2701                    #[allow(irrefutable_let_patterns)]
2702                    if let ClockType::SystemMonotonic(_) = self {
2703                        // Do nothing, read the value into the object
2704                    } else {
2705                        // Initialize `self` to the right variant
2706                        *self = ClockType::SystemMonotonic(fidl::new_empty!(SystemMonotonic, D));
2707                    }
2708                    #[allow(irrefutable_let_patterns)]
2709                    if let ClockType::SystemMonotonic(ref mut val) = self {
2710                        fidl::decode!(SystemMonotonic, D, val, decoder, _inner_offset, depth)?;
2711                    } else {
2712                        unreachable!()
2713                    }
2714                }
2715                3 => {
2716                    #[allow(irrefutable_let_patterns)]
2717                    if let ClockType::Custom(_) = self {
2718                        // Do nothing, read the value into the object
2719                    } else {
2720                        // Initialize `self` to the right variant
2721                        *self = ClockType::Custom(fidl::new_empty!(CustomClockConfig, D));
2722                    }
2723                    #[allow(irrefutable_let_patterns)]
2724                    if let ClockType::Custom(ref mut val) = self {
2725                        fidl::decode!(CustomClockConfig, D, val, decoder, _inner_offset, depth)?;
2726                    } else {
2727                        unreachable!()
2728                    }
2729                }
2730                #[allow(deprecated)]
2731                ordinal => {
2732                    for _ in 0..num_handles {
2733                        decoder.drop_next_handle()?;
2734                    }
2735                    *self = ClockType::__SourceBreaking { unknown_ordinal: ordinal };
2736                }
2737            }
2738            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2739                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2740            }
2741            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2742                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2743            }
2744            Ok(())
2745        }
2746    }
2747
2748    impl fidl::encoding::ValueTypeMarker for DeviceSelector {
2749        type Borrowed<'a> = &'a Self;
2750        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2751            value
2752        }
2753    }
2754
2755    unsafe impl fidl::encoding::TypeMarker for DeviceSelector {
2756        type Owned = Self;
2757
2758        #[inline(always)]
2759        fn inline_align(_context: fidl::encoding::Context) -> usize {
2760            8
2761        }
2762
2763        #[inline(always)]
2764        fn inline_size(_context: fidl::encoding::Context) -> usize {
2765            16
2766        }
2767    }
2768
2769    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceSelector, D>
2770        for &DeviceSelector
2771    {
2772        #[inline]
2773        unsafe fn encode(
2774            self,
2775            encoder: &mut fidl::encoding::Encoder<'_, D>,
2776            offset: usize,
2777            _depth: fidl::encoding::Depth,
2778        ) -> fidl::Result<()> {
2779            encoder.debug_check_bounds::<DeviceSelector>(offset);
2780            encoder.write_num::<u64>(self.ordinal(), offset);
2781            match self {
2782                DeviceSelector::Devfs(ref val) => fidl::encoding::encode_in_envelope::<Devfs, D>(
2783                    <Devfs as fidl::encoding::ValueTypeMarker>::borrow(val),
2784                    encoder,
2785                    offset + 8,
2786                    _depth,
2787                ),
2788                DeviceSelector::Registry(ref val) => fidl::encoding::encode_in_envelope::<u64, D>(
2789                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2790                    encoder,
2791                    offset + 8,
2792                    _depth,
2793                ),
2794                DeviceSelector::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2795            }
2796        }
2797    }
2798
2799    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceSelector {
2800        #[inline(always)]
2801        fn new_empty() -> Self {
2802            Self::__SourceBreaking { unknown_ordinal: 0 }
2803        }
2804
2805        #[inline]
2806        unsafe fn decode(
2807            &mut self,
2808            decoder: &mut fidl::encoding::Decoder<'_, D>,
2809            offset: usize,
2810            mut depth: fidl::encoding::Depth,
2811        ) -> fidl::Result<()> {
2812            decoder.debug_check_bounds::<Self>(offset);
2813            #[allow(unused_variables)]
2814            let next_out_of_line = decoder.next_out_of_line();
2815            let handles_before = decoder.remaining_handles();
2816            let (ordinal, inlined, num_bytes, num_handles) =
2817                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2818
2819            let member_inline_size = match ordinal {
2820                1 => <Devfs as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2821                2 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2822                0 => return Err(fidl::Error::UnknownUnionTag),
2823                _ => num_bytes as usize,
2824            };
2825
2826            if inlined != (member_inline_size <= 4) {
2827                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2828            }
2829            let _inner_offset;
2830            if inlined {
2831                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2832                _inner_offset = offset + 8;
2833            } else {
2834                depth.increment()?;
2835                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2836            }
2837            match ordinal {
2838                1 => {
2839                    #[allow(irrefutable_let_patterns)]
2840                    if let DeviceSelector::Devfs(_) = self {
2841                        // Do nothing, read the value into the object
2842                    } else {
2843                        // Initialize `self` to the right variant
2844                        *self = DeviceSelector::Devfs(fidl::new_empty!(Devfs, D));
2845                    }
2846                    #[allow(irrefutable_let_patterns)]
2847                    if let DeviceSelector::Devfs(ref mut val) = self {
2848                        fidl::decode!(Devfs, D, val, decoder, _inner_offset, depth)?;
2849                    } else {
2850                        unreachable!()
2851                    }
2852                }
2853                2 => {
2854                    #[allow(irrefutable_let_patterns)]
2855                    if let DeviceSelector::Registry(_) = self {
2856                        // Do nothing, read the value into the object
2857                    } else {
2858                        // Initialize `self` to the right variant
2859                        *self = DeviceSelector::Registry(fidl::new_empty!(u64, D));
2860                    }
2861                    #[allow(irrefutable_let_patterns)]
2862                    if let DeviceSelector::Registry(ref mut val) = self {
2863                        fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2864                    } else {
2865                        unreachable!()
2866                    }
2867                }
2868                #[allow(deprecated)]
2869                ordinal => {
2870                    for _ in 0..num_handles {
2871                        decoder.drop_next_handle()?;
2872                    }
2873                    *self = DeviceSelector::__SourceBreaking { unknown_ordinal: ordinal };
2874                }
2875            }
2876            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2877                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2878            }
2879            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2880                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2881            }
2882            Ok(())
2883        }
2884    }
2885
2886    impl fidl::encoding::ValueTypeMarker for PlayDestination {
2887        type Borrowed<'a> = &'a Self;
2888        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2889            value
2890        }
2891    }
2892
2893    unsafe impl fidl::encoding::TypeMarker for PlayDestination {
2894        type Owned = Self;
2895
2896        #[inline(always)]
2897        fn inline_align(_context: fidl::encoding::Context) -> usize {
2898            8
2899        }
2900
2901        #[inline(always)]
2902        fn inline_size(_context: fidl::encoding::Context) -> usize {
2903            16
2904        }
2905    }
2906
2907    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PlayDestination, D>
2908        for &PlayDestination
2909    {
2910        #[inline]
2911        unsafe fn encode(
2912            self,
2913            encoder: &mut fidl::encoding::Encoder<'_, D>,
2914            offset: usize,
2915            _depth: fidl::encoding::Depth,
2916        ) -> fidl::Result<()> {
2917            encoder.debug_check_bounds::<PlayDestination>(offset);
2918            encoder.write_num::<u64>(self.ordinal(), offset);
2919            match self {
2920                PlayDestination::Renderer(ref val) => {
2921                    fidl::encoding::encode_in_envelope::<RendererConfig, D>(
2922                        <RendererConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
2923                        encoder,
2924                        offset + 8,
2925                        _depth,
2926                    )
2927                }
2928                PlayDestination::DeviceRingBuffer(ref val) => {
2929                    fidl::encoding::encode_in_envelope::<DeviceRingBuffer, D>(
2930                        <DeviceRingBuffer as fidl::encoding::ValueTypeMarker>::borrow(val),
2931                        encoder,
2932                        offset + 8,
2933                        _depth,
2934                    )
2935                }
2936                PlayDestination::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2937            }
2938        }
2939    }
2940
2941    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PlayDestination {
2942        #[inline(always)]
2943        fn new_empty() -> Self {
2944            Self::__SourceBreaking { unknown_ordinal: 0 }
2945        }
2946
2947        #[inline]
2948        unsafe fn decode(
2949            &mut self,
2950            decoder: &mut fidl::encoding::Decoder<'_, D>,
2951            offset: usize,
2952            mut depth: fidl::encoding::Depth,
2953        ) -> fidl::Result<()> {
2954            decoder.debug_check_bounds::<Self>(offset);
2955            #[allow(unused_variables)]
2956            let next_out_of_line = decoder.next_out_of_line();
2957            let handles_before = decoder.remaining_handles();
2958            let (ordinal, inlined, num_bytes, num_handles) =
2959                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2960
2961            let member_inline_size = match ordinal {
2962                1 => <RendererConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2963                2 => <DeviceRingBuffer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2964                0 => return Err(fidl::Error::UnknownUnionTag),
2965                _ => num_bytes as usize,
2966            };
2967
2968            if inlined != (member_inline_size <= 4) {
2969                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2970            }
2971            let _inner_offset;
2972            if inlined {
2973                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2974                _inner_offset = offset + 8;
2975            } else {
2976                depth.increment()?;
2977                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2978            }
2979            match ordinal {
2980                1 => {
2981                    #[allow(irrefutable_let_patterns)]
2982                    if let PlayDestination::Renderer(_) = self {
2983                        // Do nothing, read the value into the object
2984                    } else {
2985                        // Initialize `self` to the right variant
2986                        *self = PlayDestination::Renderer(fidl::new_empty!(RendererConfig, D));
2987                    }
2988                    #[allow(irrefutable_let_patterns)]
2989                    if let PlayDestination::Renderer(ref mut val) = self {
2990                        fidl::decode!(RendererConfig, D, val, decoder, _inner_offset, depth)?;
2991                    } else {
2992                        unreachable!()
2993                    }
2994                }
2995                2 => {
2996                    #[allow(irrefutable_let_patterns)]
2997                    if let PlayDestination::DeviceRingBuffer(_) = self {
2998                        // Do nothing, read the value into the object
2999                    } else {
3000                        // Initialize `self` to the right variant
3001                        *self = PlayDestination::DeviceRingBuffer(fidl::new_empty!(
3002                            DeviceRingBuffer,
3003                            D
3004                        ));
3005                    }
3006                    #[allow(irrefutable_let_patterns)]
3007                    if let PlayDestination::DeviceRingBuffer(ref mut val) = self {
3008                        fidl::decode!(DeviceRingBuffer, D, val, decoder, _inner_offset, depth)?;
3009                    } else {
3010                        unreachable!()
3011                    }
3012                }
3013                #[allow(deprecated)]
3014                ordinal => {
3015                    for _ in 0..num_handles {
3016                        decoder.drop_next_handle()?;
3017                    }
3018                    *self = PlayDestination::__SourceBreaking { unknown_ordinal: ordinal };
3019                }
3020            }
3021            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3022                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3023            }
3024            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3025                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3026            }
3027            Ok(())
3028        }
3029    }
3030
3031    impl fidl::encoding::ValueTypeMarker for RecordSource {
3032        type Borrowed<'a> = &'a Self;
3033        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3034            value
3035        }
3036    }
3037
3038    unsafe impl fidl::encoding::TypeMarker for RecordSource {
3039        type Owned = Self;
3040
3041        #[inline(always)]
3042        fn inline_align(_context: fidl::encoding::Context) -> usize {
3043            8
3044        }
3045
3046        #[inline(always)]
3047        fn inline_size(_context: fidl::encoding::Context) -> usize {
3048            16
3049        }
3050    }
3051
3052    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RecordSource, D>
3053        for &RecordSource
3054    {
3055        #[inline]
3056        unsafe fn encode(
3057            self,
3058            encoder: &mut fidl::encoding::Encoder<'_, D>,
3059            offset: usize,
3060            _depth: fidl::encoding::Depth,
3061        ) -> fidl::Result<()> {
3062            encoder.debug_check_bounds::<RecordSource>(offset);
3063            encoder.write_num::<u64>(self.ordinal(), offset);
3064            match self {
3065                RecordSource::Capturer(ref val) => {
3066                    fidl::encoding::encode_in_envelope::<CapturerConfig, D>(
3067                        <CapturerConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
3068                        encoder,
3069                        offset + 8,
3070                        _depth,
3071                    )
3072                }
3073                RecordSource::Loopback(ref val) => {
3074                    fidl::encoding::encode_in_envelope::<Loopback, D>(
3075                        <Loopback as fidl::encoding::ValueTypeMarker>::borrow(val),
3076                        encoder,
3077                        offset + 8,
3078                        _depth,
3079                    )
3080                }
3081                RecordSource::DeviceRingBuffer(ref val) => {
3082                    fidl::encoding::encode_in_envelope::<DeviceRingBuffer, D>(
3083                        <DeviceRingBuffer as fidl::encoding::ValueTypeMarker>::borrow(val),
3084                        encoder,
3085                        offset + 8,
3086                        _depth,
3087                    )
3088                }
3089                RecordSource::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
3090            }
3091        }
3092    }
3093
3094    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RecordSource {
3095        #[inline(always)]
3096        fn new_empty() -> Self {
3097            Self::__SourceBreaking { unknown_ordinal: 0 }
3098        }
3099
3100        #[inline]
3101        unsafe fn decode(
3102            &mut self,
3103            decoder: &mut fidl::encoding::Decoder<'_, D>,
3104            offset: usize,
3105            mut depth: fidl::encoding::Depth,
3106        ) -> fidl::Result<()> {
3107            decoder.debug_check_bounds::<Self>(offset);
3108            #[allow(unused_variables)]
3109            let next_out_of_line = decoder.next_out_of_line();
3110            let handles_before = decoder.remaining_handles();
3111            let (ordinal, inlined, num_bytes, num_handles) =
3112                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3113
3114            let member_inline_size = match ordinal {
3115                1 => <CapturerConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3116                2 => <Loopback as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3117                3 => <DeviceRingBuffer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3118                0 => return Err(fidl::Error::UnknownUnionTag),
3119                _ => num_bytes as usize,
3120            };
3121
3122            if inlined != (member_inline_size <= 4) {
3123                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3124            }
3125            let _inner_offset;
3126            if inlined {
3127                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3128                _inner_offset = offset + 8;
3129            } else {
3130                depth.increment()?;
3131                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3132            }
3133            match ordinal {
3134                1 => {
3135                    #[allow(irrefutable_let_patterns)]
3136                    if let RecordSource::Capturer(_) = self {
3137                        // Do nothing, read the value into the object
3138                    } else {
3139                        // Initialize `self` to the right variant
3140                        *self = RecordSource::Capturer(fidl::new_empty!(CapturerConfig, D));
3141                    }
3142                    #[allow(irrefutable_let_patterns)]
3143                    if let RecordSource::Capturer(ref mut val) = self {
3144                        fidl::decode!(CapturerConfig, D, val, decoder, _inner_offset, depth)?;
3145                    } else {
3146                        unreachable!()
3147                    }
3148                }
3149                2 => {
3150                    #[allow(irrefutable_let_patterns)]
3151                    if let RecordSource::Loopback(_) = self {
3152                        // Do nothing, read the value into the object
3153                    } else {
3154                        // Initialize `self` to the right variant
3155                        *self = RecordSource::Loopback(fidl::new_empty!(Loopback, D));
3156                    }
3157                    #[allow(irrefutable_let_patterns)]
3158                    if let RecordSource::Loopback(ref mut val) = self {
3159                        fidl::decode!(Loopback, D, val, decoder, _inner_offset, depth)?;
3160                    } else {
3161                        unreachable!()
3162                    }
3163                }
3164                3 => {
3165                    #[allow(irrefutable_let_patterns)]
3166                    if let RecordSource::DeviceRingBuffer(_) = self {
3167                        // Do nothing, read the value into the object
3168                    } else {
3169                        // Initialize `self` to the right variant
3170                        *self =
3171                            RecordSource::DeviceRingBuffer(fidl::new_empty!(DeviceRingBuffer, D));
3172                    }
3173                    #[allow(irrefutable_let_patterns)]
3174                    if let RecordSource::DeviceRingBuffer(ref mut val) = self {
3175                        fidl::decode!(DeviceRingBuffer, D, val, decoder, _inner_offset, depth)?;
3176                    } else {
3177                        unreachable!()
3178                    }
3179                }
3180                #[allow(deprecated)]
3181                ordinal => {
3182                    for _ in 0..num_handles {
3183                        decoder.drop_next_handle()?;
3184                    }
3185                    *self = RecordSource::__SourceBreaking { unknown_ordinal: ordinal };
3186                }
3187            }
3188            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3189                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3190            }
3191            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3192                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3193            }
3194            Ok(())
3195        }
3196    }
3197
3198    impl fidl::encoding::ValueTypeMarker for RendererConfig {
3199        type Borrowed<'a> = &'a Self;
3200        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3201            value
3202        }
3203    }
3204
3205    unsafe impl fidl::encoding::TypeMarker for RendererConfig {
3206        type Owned = Self;
3207
3208        #[inline(always)]
3209        fn inline_align(_context: fidl::encoding::Context) -> usize {
3210            8
3211        }
3212
3213        #[inline(always)]
3214        fn inline_size(_context: fidl::encoding::Context) -> usize {
3215            16
3216        }
3217    }
3218
3219    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RendererConfig, D>
3220        for &RendererConfig
3221    {
3222        #[inline]
3223        unsafe fn encode(
3224            self,
3225            encoder: &mut fidl::encoding::Encoder<'_, D>,
3226            offset: usize,
3227            _depth: fidl::encoding::Depth,
3228        ) -> fidl::Result<()> {
3229            encoder.debug_check_bounds::<RendererConfig>(offset);
3230            encoder.write_num::<u64>(self.ordinal(), offset);
3231            match self {
3232                RendererConfig::StandardRenderer(ref val) => {
3233                    fidl::encoding::encode_in_envelope::<StandardRendererConfig, D>(
3234                        <StandardRendererConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
3235                        encoder,
3236                        offset + 8,
3237                        _depth,
3238                    )
3239                }
3240                RendererConfig::UltrasoundRenderer(ref val) => {
3241                    fidl::encoding::encode_in_envelope::<UltrasoundRendererConfig, D>(
3242                        <UltrasoundRendererConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
3243                        encoder,
3244                        offset + 8,
3245                        _depth,
3246                    )
3247                }
3248                RendererConfig::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
3249            }
3250        }
3251    }
3252
3253    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RendererConfig {
3254        #[inline(always)]
3255        fn new_empty() -> Self {
3256            Self::__SourceBreaking { unknown_ordinal: 0 }
3257        }
3258
3259        #[inline]
3260        unsafe fn decode(
3261            &mut self,
3262            decoder: &mut fidl::encoding::Decoder<'_, D>,
3263            offset: usize,
3264            mut depth: fidl::encoding::Depth,
3265        ) -> fidl::Result<()> {
3266            decoder.debug_check_bounds::<Self>(offset);
3267            #[allow(unused_variables)]
3268            let next_out_of_line = decoder.next_out_of_line();
3269            let handles_before = decoder.remaining_handles();
3270            let (ordinal, inlined, num_bytes, num_handles) =
3271                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3272
3273            let member_inline_size = match ordinal {
3274                1 => <StandardRendererConfig as fidl::encoding::TypeMarker>::inline_size(
3275                    decoder.context,
3276                ),
3277                2 => <UltrasoundRendererConfig as fidl::encoding::TypeMarker>::inline_size(
3278                    decoder.context,
3279                ),
3280                0 => return Err(fidl::Error::UnknownUnionTag),
3281                _ => num_bytes as usize,
3282            };
3283
3284            if inlined != (member_inline_size <= 4) {
3285                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3286            }
3287            let _inner_offset;
3288            if inlined {
3289                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3290                _inner_offset = offset + 8;
3291            } else {
3292                depth.increment()?;
3293                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3294            }
3295            match ordinal {
3296                1 => {
3297                    #[allow(irrefutable_let_patterns)]
3298                    if let RendererConfig::StandardRenderer(_) = self {
3299                        // Do nothing, read the value into the object
3300                    } else {
3301                        // Initialize `self` to the right variant
3302                        *self = RendererConfig::StandardRenderer(fidl::new_empty!(
3303                            StandardRendererConfig,
3304                            D
3305                        ));
3306                    }
3307                    #[allow(irrefutable_let_patterns)]
3308                    if let RendererConfig::StandardRenderer(ref mut val) = self {
3309                        fidl::decode!(
3310                            StandardRendererConfig,
3311                            D,
3312                            val,
3313                            decoder,
3314                            _inner_offset,
3315                            depth
3316                        )?;
3317                    } else {
3318                        unreachable!()
3319                    }
3320                }
3321                2 => {
3322                    #[allow(irrefutable_let_patterns)]
3323                    if let RendererConfig::UltrasoundRenderer(_) = self {
3324                        // Do nothing, read the value into the object
3325                    } else {
3326                        // Initialize `self` to the right variant
3327                        *self = RendererConfig::UltrasoundRenderer(fidl::new_empty!(
3328                            UltrasoundRendererConfig,
3329                            D
3330                        ));
3331                    }
3332                    #[allow(irrefutable_let_patterns)]
3333                    if let RendererConfig::UltrasoundRenderer(ref mut val) = self {
3334                        fidl::decode!(
3335                            UltrasoundRendererConfig,
3336                            D,
3337                            val,
3338                            decoder,
3339                            _inner_offset,
3340                            depth
3341                        )?;
3342                    } else {
3343                        unreachable!()
3344                    }
3345                }
3346                #[allow(deprecated)]
3347                ordinal => {
3348                    for _ in 0..num_handles {
3349                        decoder.drop_next_handle()?;
3350                    }
3351                    *self = RendererConfig::__SourceBreaking { unknown_ordinal: ordinal };
3352                }
3353            }
3354            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3355                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3356            }
3357            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3358                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3359            }
3360            Ok(())
3361        }
3362    }
3363}